/**
 * Redemption domain events — discriminated union.
 *
 *   UNREDEEMED + redeem_attempted(valid_token, ownership_ok, not_expired) → REDEEMED
 *   UNREDEEMED + redeem_attempted(already_REDEEMED state)                → rejected (ALREADY_REDEEMED)
 *   UNREDEEMED + redeem_attempted(expiresAt past)                        → rejected (EXPIRED)
 *   UNREDEEMED + redeem_attempted(vendor mismatch)                       → rejected (WRONG_VENDOR)
 *   UNREDEEMED + redeem_attempted(invalid token/signature)               → rejected (INVALID)
 *
 *   UNREDEEMED + expiry_passed                                           → EXPIRED
 *     effects: [mark-expired, enqueue-outbox(expired_split)]
 *
 * Pure module: no imports from @/server/db, do-client, outbox-producer, payments, fetch.
 */

import { type RedemptionStatus } from '@/lib/enums/redemption-status';

/** Full set alias — kept for domain-layer readability. */
export type RedemptionState = RedemptionStatus;

export type RedemptionEvent =
  | {
      kind: 'redeem_attempted';
      purchaseId: string;
      currentState: RedemptionState;
      scanningVendorId: string;
      purchaseVendorId: string;
      purchaseUserId: string | null;
      dealId: string;
      expiresAt: Date;
      at: Date;
    }
  | {
      kind: 'expiry_passed';
      purchaseId: string;
      currentState: RedemptionState;
      vendorId: string;
      amountPaid: string;
      at: Date;
    };
