// ABOUTME: Type definitions for the automated scheduling system
// ABOUTME: Defines schedule types, configurations, and execution context interfaces

export enum ScheduleType {
  MORNING_SCRAPE = 'morning_scrape',
  PRE_RACE_T60 = 'pre_race_t60',
  PRE_RACE_T15 = 'pre_race_t15',
  POST_RACE_T5 = 'post_race_t5',
  ODDS_UPDATE = 'odds_update',
  CLEANUP_JOB_RUNS = 'cleanup_job_runs',
}

export interface SchedulerConfig {
  // Cron expression for schedule
  // Examples:
  // - '0 6 * * *' = Daily at 6 AM
  // - '*/5 * * * *' = Every 5 minutes
  cronExpression: string;

  // Timezone for cron expression
  // Default: 'Pacific/Auckland'
  timezone?: string;

  // Whether scheduler is enabled
  enabled: boolean;

  // Description of what this scheduler does
  description: string;
}

export interface JobContext {
  // Type of scheduled job
  type: ScheduleType;

  // When the job was triggered
  triggeredAt: Date;

  // JobRun ID for tracking this execution
  jobRunId: string;

  // Additional context data
  data?: Record<string, any>;
}

export interface JobResult {
  // Whether the job completed successfully
  success: boolean;

  // Number of items processed
  itemsProcessed: number;

  // Duration in milliseconds
  durationMs: number;

  // Errors encountered during processing (simple strings for DB storage)
  errors: string[];

  // Additional result metadata
  metadata?: Record<string, any>;
}
