Added CollectionPost events

refs https://github.com/TryGhost/Arch/issues/95

These events can be used to know when an automatic collections posts have been
updated, as well as by the repository to optimise the storage of
CollectionPosts
This commit is contained in:
Fabien "egg" O'Carroll 2023-09-22 15:04:48 +07:00 committed by Fabien 'egg' O'Carroll
parent 22029bfd1b
commit 637724ba66
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,19 @@
type CollectionPostAddedData = {
collection_id: string;
post_id: string;
};
export class CollectionPostAdded {
data: CollectionPostAddedData;
timestamp: Date;
type = 'CollectionPostAdded' as const;
constructor(data: CollectionPostAddedData, timestamp: Date) {
this.data = data;
this.timestamp = timestamp;
}
static create(data: CollectionPostAddedData, timestamp = new Date()) {
return new CollectionPostAdded(data, timestamp);
}
}

View File

@ -0,0 +1,19 @@
type CollectionPostRemovedData = {
collection_id: string;
post_id: string;
};
export class CollectionPostRemoved {
data: CollectionPostRemovedData;
timestamp: Date;
type = 'CollectionPostRemoved' as const;
constructor(data: CollectionPostRemovedData, timestamp: Date) {
this.data = data;
this.timestamp = timestamp;
}
static create(data: CollectionPostRemovedData, timestamp = new Date()) {
return new CollectionPostRemoved(data, timestamp);
}
}

View File

@ -4,3 +4,5 @@ export * from './Collection';
export * from './events/PostAddedEvent';
export * from './events/PostEditedEvent';
export * from './events/TagDeletedEvent';
export * from './events/CollectionPostAdded';
export * from './events/CollectionPostRemoved';