19 lines
503 B
TypeScript
19 lines
503 B
TypeScript
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
export abstract class DomainEvent {
|
|
public readonly eventId: string;
|
|
public readonly occurredAt: Date;
|
|
public readonly version: number;
|
|
|
|
protected constructor(version: number = 1) {
|
|
this.eventId = uuidv4();
|
|
this.occurredAt = new Date();
|
|
this.version = version;
|
|
}
|
|
|
|
abstract get eventType(): string;
|
|
abstract get aggregateId(): string;
|
|
abstract get aggregateType(): string;
|
|
abstract toPayload(): Record<string, any>;
|
|
}
|