/**
 * Redemption domain effects — discriminated union.
 *
 * Pure module: no imports from @/server/db, do-client, outbox-producer, payments, fetch.
 *
 * Effect ordering in apply-effects.ts:
 *   1. mark-expired (DB conditional UPDATE on voucher table)
 *   2. enqueue-outbox (DB insert + queue send)
 *   3. send-user-push (best-effort external I/O)
 */

export type RedemptionEffect =
  /** Conditional state write: UNREDEEMED → EXPIRED on all line vouchers. */
  | {
      kind: 'mark-expired';
      purchaseId: string;
    }
  /** Insert outbox row + enqueue. */
  | {
      kind: 'enqueue-outbox';
      aggregateType: 'purchase';
      aggregateId: string;
      eventType: string;
      payload: Record<string, unknown>;
    }
  /** Best-effort user push (silently fails). */
  | {
      kind: 'send-user-push';
      userId: string;
      purchaseId: string;
      dealId: string;
    };
