import { DomainEvent } from './domain-event.base';
import { ReportType } from '../value-objects/report-type.enum';
import { ReportPeriod } from '../value-objects/report-period.enum';

export interface SnapshotCreatedPayload {
  snapshotId: string;
  reportType: ReportType;
  reportCode: string;
  reportPeriod: ReportPeriod;
  periodKey: string;
  rowCount: number;
  periodStartAt: Date;
  periodEndAt: Date;
}

export class SnapshotCreatedEvent extends DomainEvent {
  constructor(private readonly payload: SnapshotCreatedPayload) {
    super();
  }

  get eventType(): string {
    return 'SnapshotCreated';
  }

  get aggregateId(): string {
    return this.payload.snapshotId;
  }

  get aggregateType(): string {
    return 'ReportSnapshot';
  }

  toPayload(): SnapshotCreatedPayload {
    return { ...this.payload };
  }
}
