export enum AsyncTaskStatus {
  PENDING = 1,
  PROCESSING = 2,
  COMPLETED = 3,
  FAILED = 4,
  CANCELED = 5
}

export interface AsyncTaskProgress {
  task_id?: number
  status: number
  status_name?: string
  total_count?: number
  success_count?: number
  failed_count?: number
  failure_details?: unknown[] | null
  error_code?: string
  error_summary?: string
  updated_at?: string
}

export const isAsyncTaskActive = (status?: AsyncTaskStatus) =>
  status === AsyncTaskStatus.PENDING || status === AsyncTaskStatus.PROCESSING

export const isAsyncTaskTerminal = (status?: AsyncTaskStatus) =>
  status === AsyncTaskStatus.COMPLETED ||
  status === AsyncTaskStatus.FAILED ||
  status === AsyncTaskStatus.CANCELED
