export const ACTIVE_JOB_STATUSES = ['queued', 'running'] as const;
export const JOBS_PRISMA = 'JOBS_PRISMA';

export type BackgroundJobStatus = 'queued' | 'running' | 'succeeded' | 'failed';

export interface BackgroundJobRecord {
  id: string;
  type: string;
  status: BackgroundJobStatus;
  dedupeKey?: string | null;
  payload: unknown;
  attempts: number;
  maxAttempts: number;
  availableAt?: Date;
  lockedBy?: string | null;
  lockedUntil?: Date | null;
  lastError?: string | null;
}

export interface EnqueueJobInput {
  type: string;
  dedupeKey?: string | null;
  payload?: unknown;
  maxAttempts?: number;
  availableAt?: Date;
}

export interface ClaimJobInput {
  workerId: string;
  types?: string[];
  now?: Date;
  leaseMs?: number;
}

export interface MarkFailedOptions {
  now?: Date;
  retryDelayMs?: number;
}
