/**
 * Shared row + DTO shapes for every per-module send-queue table. The
 * existing iMessage `macsync.send_queue` table predates this generic layer
 * and stays on its own bespoke schema; new modules (calendar, reminders,
 * notes) use the generic `<module>_send_queue` shape stored in a JSONB
 * payload column.
 */
export type SendQueueStatus = 'queued' | 'sent' | 'failed';

/** Row shape as returned by `<module>_send_queue` tables. */
export interface SendQueueRow<TPayload = unknown> {
  id: string;
  device_id: string;
  action: string;
  payload: TPayload;
  status: SendQueueStatus;
  sent_at: string | null;
  failure_reason: string | null;
  created_at: string;
  updated_at: string;
}

/** Domain-shaped envelope handed to client/Mac. */
export interface PendingItem<TPayload = unknown> {
  id: string;
  action: string;
  payload: TPayload;
  createdAt: string;
}

export interface EnqueueInput<TPayload> {
  deviceId: string;
  action: string;
  payload: TPayload;
}

export interface SendResultInput {
  id: string;
  status: 'sent' | 'failed';
  error?: string | null;
}
