# System Configuration Contracts
#
# Type definitions for system-level configuration.

{
  OsName = [| 'macos, 'linux, 'windows |],
  DatabaseBackend = [| 'memory, 'surrealdb |],
  KmsBackend = [| 'rustyvault, 'age, 'vault, 'aws_kms |],
  ProviderInterface = [| 'API, 'CLI |],
  CredentialsSourceType = [| 'rustyvault, 'vault, 'kms |],
  EncryptedKeyFormat = [| 'age, 'sops |],
  PreferredEditor = [| 'vim, 'nano, 'code |],
  OutputFormat = [| 'text, 'json, 'yaml |],
  LogLevel = [| 'error, 'warn, 'info, 'debug |],

  SystemConfig = {
    version | String,
    install_path | String,
    os_name | OsName,
    os_version | String,
    config_base_path | String,
    cache_base_path | String,
    workspaces_dir | String,
    system_architecture | String,
    cpu_count | Number,
    memory_total_gb | Number,
    disk_total_gb | Number,
    setup_date | String,
    setup_by_user | String,
    setup_hostname | String,
  },

  OrchestratorConfig = {
    enabled | Bool,
    endpoint | String,
    port | Number,
    timeout_seconds | Number,
    health_check_interval_seconds | Number,
  },

  DatabaseConfig = {
    backend | DatabaseBackend,
    url | optional | String,
  },

  ControlCenterConfig = {
    enabled | Bool,
    url | String,
    port | Number,
    timeout_seconds | Number,
    database,
  },

  KMSConfig = {
    enabled | Bool,
    backend | KmsBackend,
    endpoint | optional | String,
    port | optional | Number,
    rotation_days | optional | Number,
  },

  PlatformServicesConfig = {
    orchestrator,
    control_center,
    kms_service,
  },

  ProviderCredentialsReference = {
    credentials_source | String,
    credentials_source_type | CredentialsSourceType,
  },

  UpCloudConfig = {
    api_url | String,
    interface | ProviderInterface,
    credentials,
    timeout_seconds | Number,
  },

  AWSConfig = {
    region | String,
    credentials,
    timeout_seconds | Number,
  },

  HetznerConfig = {
    api_url | String,
    credentials,
    timeout_seconds | Number,
  },

  LocalConfig = {
    base_path | String,
    timeout_seconds | Number,
  },

  RustyVaultBootstrap = {
    encrypted_key_path | String,
    encrypted_key_format | EncryptedKeyFormat,
  },

  ProviderConfig = {
    upcloud | optional,
    aws | optional,
    hetzner | optional,
    local | optional,
    rustyvault_bootstrap | optional,
  },

  UserPreferences = {
    preferred_editor | PreferredEditor,
    preferred_output_format | OutputFormat,
    auto_confirm_operations | Bool,
    log_level | LogLevel,
    default_timeout_seconds | Number,
  },

  WorkspaceConfig = {
    workspace_name | String,
    workspace_path | String,
    active_infrastructure | String,
    active_providers,
    provider_config,
  },
}
