Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
feat: allow events to be registered without collection specified (#972)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman authored Nov 7, 2023
1 parent 6354675 commit d10e754
Show file tree
Hide file tree
Showing 5 changed files with 1,900 additions and 212 deletions.
38 changes: 26 additions & 12 deletions packages/core/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,33 +1121,46 @@ export interface EventData {

export interface PrePublishEventListener {
name: 'prePublish';
collection: string;
collection?: string;
file?: string;
handler: (event: { data: EventData; collection: string }) => void | Promise<void>;
handler: (event: {
data: EventData;
collection: string;
file: string | undefined;
}) => void | Promise<void>;
}

export interface PostPublishEventListener {
name: 'postPublish';
collection: string;
collection?: string;
file?: string;
handler: (event: { data: EventData; collection: string }) => void | Promise<void>;
handler: (event: {
data: EventData;
collection: string;
file: string | undefined;
}) => void | Promise<void>;
}

export interface PreSaveEventListener {
name: 'preSave';
collection: string;
collection?: string;
file?: string;
handler: (event: {
data: EventData;
collection: string;
file: string | undefined;
}) => EntryData | undefined | null | void | Promise<EntryData | undefined | null | void>;
}

export interface PostSaveEventListener {
name: 'postSave';
collection: string;
collection?: string;
file?: string;
handler: (event: { data: EventData; collection: string }) => void | Promise<void>;
handler: (event: {
data: EventData;
collection: string;
file: string | undefined;
}) => void | Promise<void>;
}

export interface MountedEventListener {
Expand All @@ -1157,9 +1170,7 @@ export interface MountedEventListener {

export interface LoginEventListener {
name: 'login';
handler: (event: {
author: AuthorData;
}) => EntryData | undefined | null | void | Promise<EntryData | undefined | null | void>;
handler: (event: { author: AuthorData }) => void | Promise<void>;
}

export interface LogoutEventListener {
Expand All @@ -1169,17 +1180,20 @@ export interface LogoutEventListener {

export interface ChangeEventListener {
name: 'change';
collection: string;
collection?: string;
file?: string;
field: string;
field?: string;
handler: (event: {
data: EntryData;
collection: string;
file: string | undefined;
field: string;
}) => EntryData | undefined | null | void | Promise<EntryData | undefined | null | void>;
}

export type EventListener =
| PrePublishEventListener
| PostPublishEventListener
| PreSaveEventListener
| PostSaveEventListener
| ChangeEventListener
Expand Down
Loading

0 comments on commit d10e754

Please sign in to comment.