export type PipelineRunStatus =
  | 'queued'
  | 'running'
  | 'succeeded'
  | 'failed'
  | 'blocked'
  | 'cancelling'
  | 'cancelled'
  | 'deadline_exceeded'
  | 'blocked_previous_run'

export type PipelineStepStatus =
  | 'pending'
  | 'ready'
  | 'running'
  | 'retry_wait'
  | 'succeeded'
  | 'failed'
  | 'blocked'
  | 'timed_out'
  | 'cancelled'

export interface PipelineStepRun {
  step_run_id: string
  run_id: string
  step_key: string
  step_order: number
  attempt: number
  status: PipelineStepStatus
  critical: boolean
  timeout_seconds: number
  started_at: string | null
  finished_at: string | null
  heartbeat_at: string | null
  result: Record<string, unknown> | null
  error_code: string | null
  error_message: string | null
  log_uri: string | null
}

export interface PipelineEffect {
  outbox_id: string
  step_run_id: string
  effect_type: string
  payload_hash: string
  payload_uri: string | null
  status: 'dry_run_recorded' | 'record_failed'
  dry_run: boolean
  created_at: string | null
}

export interface PipelineRun {
  run_id: string
  pipeline_key: string
  biz_dt: string
  trigger_type: string
  trigger_source: string | null
  run_mode: string
  dry_run: boolean
  status: PipelineRunStatus
  current_step: string | null
  scheduled_for: string | null
  deadline_at: string | null
  started_at: string | null
  finished_at: string | null
  heartbeat_at: string | null
  summary: Record<string, unknown> | null
  error_code: string | null
  error_message: string | null
  created_at: string
  updated_at: string
  steps?: PipelineStepRun[]
  effects?: PipelineEffect[]
}
