import { v4 as uuidv4 } from 'uuid'

export interface IDomainEvent {
  eventId: string
  eventType: string
  aggregateId: string
  occurredAt: Date
  payload: Record<string, any>
}

export abstract class DomainEvent implements IDomainEvent {
  public readonly eventId: string
  public readonly occurredAt: Date
  public abstract readonly eventType: string
  public abstract readonly aggregateId: string
  public abstract readonly payload: Record<string, any>

  constructor() {
    this.eventId = uuidv4()
    this.occurredAt = new Date()
  }
}
