// This file is auto-generated by @hey-api/openapi-ts

import * as z from 'zod'

/**
 * WorkflowRunArchiveDownloadPayload
 *
 * Request body for preparing one monthly workflow-run archive download.
 */
export const zWorkflowRunArchiveDownloadPayload = z.object({
  month: z.int().gte(1).lte(12),
  year: z.int().gte(1),
})

/**
 * WorkflowRunArchiveSummaryResponse
 */
export const zWorkflowRunArchiveSummaryResponse = z.object({
  archive_bytes: z.int(),
  archived_month_count: z.int(),
  latest_archived_at: z.iso.datetime().nullish(),
  workflow_run_count: z.int(),
})

/**
 * WorkflowRunArchiveDownloadStatus
 *
 * Lifecycle state for an asynchronous archive download request.
 */
export const zWorkflowRunArchiveDownloadStatus = z.enum([
  'failed',
  'pending',
  'processing',
  'ready',
])

/**
 * WorkflowRunArchiveDownloadTaskResponse
 */
export const zWorkflowRunArchiveDownloadTaskResponse = z.object({
  archive_bytes: z.int(),
  bundle_count: z.int(),
  created_at: z.iso.datetime(),
  download_id: z.string(),
  error: z.string().nullish(),
  expires_at: z.iso.datetime(),
  file_name: z.string().nullish(),
  file_size_bytes: z.int().nullish(),
  finished_at: z.iso.datetime().nullish(),
  month: z.int(),
  started_at: z.iso.datetime().nullish(),
  status: zWorkflowRunArchiveDownloadStatus,
  updated_at: z.iso.datetime(),
  year: z.int(),
})

/**
 * WorkflowRunArchiveMonthResponse
 */
export const zWorkflowRunArchiveMonthResponse = z.object({
  archive_bytes: z.int(),
  bundle_count: z.int(),
  download_task: zWorkflowRunArchiveDownloadTaskResponse.nullish(),
  latest_archived_at: z.iso.datetime(),
  month: z.int(),
  row_count: z.int(),
  workflow_run_count: z.int(),
  year: z.int(),
})

/**
 * WorkflowRunArchiveListResponse
 */
export const zWorkflowRunArchiveListResponse = z.object({
  months: z.array(zWorkflowRunArchiveMonthResponse),
  summary: zWorkflowRunArchiveSummaryResponse,
})

/**
 * Success
 */
export const zGetWorkflowRunArchivesResponse = zWorkflowRunArchiveListResponse

export const zPostWorkflowRunArchivesDownloadsBody = zWorkflowRunArchiveDownloadPayload

/**
 * Download task accepted
 */
export const zPostWorkflowRunArchivesDownloadsResponse = zWorkflowRunArchiveDownloadTaskResponse

export const zGetWorkflowRunArchivesDownloadsByDownloadIdPath = z.object({
  download_id: z.string(),
})

/**
 * Success
 */
export const zGetWorkflowRunArchivesDownloadsByDownloadIdResponse =
  zWorkflowRunArchiveDownloadTaskResponse
