import type { CaseStatus, SupportActorType, TicketState } from './events.js';

export type SupportCaseEffect =
  | {
      kind: 'record-transition';
      parentType: 'case' | 'ticket';
      parentId: string;
      fromState: CaseStatus | TicketState;
      toState: CaseStatus | TicketState;
      actorType: SupportActorType;
      actorId: string | null;
      reason?: string;
      metadata: Record<string, unknown>;
    }
  | {
      kind: 'set-case-status';
      caseId: string;
      status: CaseStatus;
      at?: Date;
      resolvedAt?: Date | null;
      reopenCount?: number;
    }
  | { kind: 'set-ticket-status'; ticketId: string; status: TicketState; at?: Date }
  | {
      kind: 'enqueue-outbox';
      aggregateType: 'case' | 'ticket';
      aggregateId: string;
      eventType:
        | 'support.notif.email'
        | 'support.notif.push'
        | 'support.ai.dispatch'
        | 'support-case.refund.requested';
      payload: Record<string, unknown>;
    };
