export type DomainDeployStatus = 'started' | 'success' | 'failed'

export interface DomainListItem {
  id: number
  host: string
  businessId: number
  businessName: string
  sslEnabled: boolean
  isActive: boolean
  expiresAt: string | null
  createdAt: string
  /** Present when this apex has a storefront on the websites VM */
  deploySlug: string | null
  lastDeployedAt: string | null
  lastDeployStatus: DomainDeployStatus | null
}

export interface DomainsListResponse {
  items: DomainListItem[]
  total: number
  page: number
  pageSize: number
}

export interface DeployDomainResponse {
  status: 'ok' | 'accepted'
  slug: string
  host: string
  message: string
  lastDeployedAt: string | null
  lastDeployStatus: DomainDeployStatus | null
}

export interface SyncSslResponse {
  status: 'accepted'
  message: string
}

export interface IssueWebsiteSslResponse {
  status: 'ok'
  message: string
  issued: string[]
  failed: Array<{ host: string; error: string }>
}

export interface IssueDomainSslHostResult {
  host: string
  status: 'ok' | 'issued' | 'failed' | 'skipped'
  detail?: string
}

export interface IssueDomainSslResponse {
  status: 'ok' | 'partial'
  host: string
  sslEnabled: boolean
  hosts: {
    apex: IssueDomainSslHostResult
    www: IssueDomainSslHostResult
    business: IssueDomainSslHostResult
    customer: IssueDomainSslHostResult
  }
  issued: string[]
  failed: Array<{ host: string; error: string }>
  message: string
}
