import { Uuid } from './value-object/Uuid' ; export abstract class DomainEvent { static EVENT_NAME : string ; static fromPrimitives : ( ... args : any [ ] ) => any ; readonly aggregateId : string ; readonly eventId : string ; readonly occurredOn : Date ; readonly eventName : string ; constructor ( eventName , aggregateId , eventId ? , occurredOn ? ) { this . aggregateId = aggregateId ; this . eventId = eventId || Uuid . random ( ) . value ; this . occurredOn = occurredOn || new Date ( ) ; this . eventName = eventName ; } abstract toPrimitive ( ) ; } export type DomainEventClass = { EVENT_NAME : string ; fromPrimitives ( ... args ) : DomainEvent ; } ;