mirror of
https://github.com/standardnotes/server
synced 2026-07-31 05:16:40 -04:00
* feat(syncing-server): refactor container config into server and worker * fix(syncing-server): yarn lock * fix(api-gateway): add client update response on v1 revision endpoints * fix(syncing-server): linter issue
135 lines
3.3 KiB
TypeScript
135 lines
3.3 KiB
TypeScript
/* istanbul ignore file */
|
|
import {
|
|
DomainEventService,
|
|
DuplicateItemSyncedEvent,
|
|
EmailRequestedEvent,
|
|
ItemDumpedEvent,
|
|
ItemRevisionCreationRequestedEvent,
|
|
RevisionsCopyRequestedEvent,
|
|
UserContentSizeRecalculationRequestedEvent,
|
|
} from '@standardnotes/domain-events'
|
|
import { TimerInterface } from '@standardnotes/time'
|
|
import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
|
|
|
|
export class DomainEventFactory implements DomainEventFactoryInterface {
|
|
constructor(private timer: TimerInterface) {}
|
|
|
|
createRevisionsCopyRequestedEvent(
|
|
userUuid: string,
|
|
dto: {
|
|
originalItemUuid: string
|
|
newItemUuid: string
|
|
},
|
|
): RevisionsCopyRequestedEvent {
|
|
return {
|
|
type: 'REVISIONS_COPY_REQUESTED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: userUuid,
|
|
userIdentifierType: 'uuid',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: dto,
|
|
}
|
|
}
|
|
|
|
createItemDumpedEvent(fileDumpPath: string, userUuid: string): ItemDumpedEvent {
|
|
return {
|
|
type: 'ITEM_DUMPED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: userUuid,
|
|
userIdentifierType: 'uuid',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: {
|
|
fileDumpPath,
|
|
},
|
|
}
|
|
}
|
|
|
|
createItemRevisionCreationRequested(itemUuid: string, userUuid: string): ItemRevisionCreationRequestedEvent {
|
|
return {
|
|
type: 'ITEM_REVISION_CREATION_REQUESTED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: userUuid,
|
|
userIdentifierType: 'uuid',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: {
|
|
itemUuid,
|
|
},
|
|
}
|
|
}
|
|
|
|
createUserContentSizeRecalculationRequestedEvent(userUuid: string): UserContentSizeRecalculationRequestedEvent {
|
|
return {
|
|
type: 'USER_CONTENT_SIZE_RECALCULATION_REQUESTED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: userUuid,
|
|
userIdentifierType: 'uuid',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: {
|
|
userUuid,
|
|
},
|
|
}
|
|
}
|
|
|
|
createDuplicateItemSyncedEvent(itemUuid: string, userUuid: string): DuplicateItemSyncedEvent {
|
|
return {
|
|
type: 'DUPLICATE_ITEM_SYNCED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: userUuid,
|
|
userIdentifierType: 'uuid',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: {
|
|
itemUuid,
|
|
userUuid,
|
|
},
|
|
}
|
|
}
|
|
|
|
createEmailRequestedEvent(dto: {
|
|
userEmail: string
|
|
messageIdentifier: string
|
|
level: string
|
|
body: string
|
|
subject: string
|
|
sender?: string
|
|
attachments?: Array<{
|
|
filePath: string
|
|
fileName: string
|
|
attachmentFileName: string
|
|
attachmentContentType: string
|
|
}>
|
|
}): EmailRequestedEvent {
|
|
return {
|
|
type: 'EMAIL_REQUESTED',
|
|
createdAt: this.timer.getUTCDate(),
|
|
meta: {
|
|
correlation: {
|
|
userIdentifier: dto.userEmail,
|
|
userIdentifierType: 'email',
|
|
},
|
|
origin: DomainEventService.SyncingServer,
|
|
},
|
|
payload: dto,
|
|
}
|
|
}
|
|
}
|