export type ProjectStatus = 'running' | 'stopped' | 'paused' | 'starting' | 'stopping' | string

export interface DdevProjectSummary {
  name: string
  status: ProjectStatus
  status_desc: string
  type: string
  approot: string
  shortroot: string
  docroot: string
  primary_url: string
  httpurl: string
  httpsurl: string
  mutagen_enabled: boolean
  mutagen_status?: string
}

export interface DdevServiceHostPortMapping {
  exposed_port: string
  host_port: string
}

export interface DdevService {
  short_name: string
  full_name: string
  status: string
  image: string
  exposed_ports: string
  host_ports: string
  host_ports_mapping: DdevServiceHostPortMapping[]
  http_url?: string
  https_url?: string
  host_http_url?: string
  host_https_url?: string
  virtual_host?: string
  'describe-info'?: string
  'describe-url-port'?: string
}

export interface DdevDbInfo {
  database_type: string
  database_version: string
  dbPort: string
  dbname: string
  host: string
  password: string
  published_port: number
  username: string
}

export interface DdevProjectDetail extends DdevProjectSummary {
  database_type: string
  database_version: string
  dbinfo: DdevDbInfo
  hostname: string
  hostnames: string[]
  httpURLs: string[]
  httpsURLs: string[]
  urls: string[]
  php_version?: string
  nodejs_version?: string
  webserver_type?: string
  performance_mode?: string
  router: string
  router_status?: string
  services: Record<string, DdevService>
  xdebug_enabled: boolean
}

export interface EnvironmentUpdate {
  phpVersion?: string
  webserverType?: string
  database?: string
  xdebugEnabled?: boolean
}

export interface DdevSnapshot {
  Name: string
  Created: string
}

export interface DdevAddonRegistryEntry {
  title: string
  github_url: string
  description: string
  user: string
  repo: string
  repo_id: number
  default_branch: string
  tag_name: string | null
  ddev_version_constraint: string
  dependencies: string[] | null
  type: string
  created_at: string
  updated_at: string
  workflow_status: string
  stars: number
}

export interface DdevInstalledAddon {
  Name: string
  Repository: string
  Version: string
  Dependencies: string[] | null
  InstallDate: string
  ProjectFiles: string[] | null
  GlobalFiles: string[] | null
  RemovalActions: string[] | null
}

export interface TerminalDataEvent {
  operationId: string
  stream: 'stdout' | 'stderr'
  chunk: string
}

export interface TerminalExitEvent {
  operationId: string
  exitCode: number | null
  cancelled: boolean
}

export interface LogDataEvent {
  operationId: string
  stream: 'stdout' | 'stderr'
  chunk: string
}

export interface LogExitEvent {
  operationId: string
}
