import { DomainEvent } from '../../../Shared/domain/DomainEvent' ; type CreateCourseDomainEventBody = { readonly duration : string ; readonly name : string ; readonly eventName : string ; readonly id : string ; } ; export class CourseCreatedDomainEvent extends DomainEvent { static readonly EVENT_NAME = 'course.created' ; readonly duration : string ; readonly name : string ; constructor ( { id , name , duration , eventId , occurredOn } ) { super ( CourseCreatedDomainEvent . EVENT_NAME , id , eventId , occurredOn ) ; this . duration = duration ; this . name = name ; } toPrimitive ( ) { const { name , duration , aggregateId } = this ; return { name , duration , eventName : CourseCreatedDomainEvent . EVENT_NAME , id : aggregateId } ; } static fromPrimitives ( aggregateId , body , eventId , occurredOn ) { return new CourseCreatedDomainEvent ( { id : aggregateId , duration : body . duration , name : body . name , eventId , occurredOn } ) ; } }