/** Shared types for push page composables and components */

export type SyncMode = 'incremental' | 'full' | 'checksum'

export interface PushServerItem {
  id: number
  name: string
  domain?: string
  is_online?: boolean
  category?: string
}

export type ServerProgressStatus = 'pending' | 'running' | 'success' | 'failed' | 'cancelled'

export interface ServerProgress {
  id: number
  name: string
  status: ServerProgressStatus
  detail?: string
}

export interface SyncProgressMsg {
  type: string
  batch_id?: string
  server_id?: number
  status?: string
  error_message?: string | null
  duration_seconds?: number | null
}

export interface UploadedZip {
  name: string
  sourcePath: string
  fileCount: number
  size: number
}

export interface PreviewStats {
  files_total?: number
  files_created?: number
  files_deleted?: number
  files_transferred?: number
  total_size_bytes?: number
  transfer_size_bytes?: number
}

export interface PreviewServerRow {
  server_id: number
  server_name: string
  error?: string
  stats?: PreviewStats
}

export interface DiagnoseResult {
  server_id: number
  server_name: string
  ssh_ok: boolean
  disk_avail: string | null
  disk_used_pct: number | null
  path_exists: boolean | null
  path_perms: string | null
  path_writable: boolean | null
  errors: string[]
}

export const TERMINAL_PROGRESS_STATUSES: ServerProgressStatus[] = ['success', 'failed', 'cancelled']

/** Parallel preview requests per batch */
export const PREVIEW_CONCURRENCY = 4

/** Show a warning when previewing more than this many servers */
export const PREVIEW_WARN_THRESHOLD = 30
