# Extension Registry Schema
# Multi-instance extension distribution via Git sources (Gitea, Forgejo, GitHub) and OCI registries

{
  # Gitea/Forgejo/GitHub source backend configuration
  SourceBackendConfig = {
    id | String | optional,
    url | String,
    organization | String,
    token_path | String,
    timeout_seconds | Number | default = 30,
    verify_ssl | Bool | default = true,
  },

  # OCI registry distribution backend configuration
  DistributionBackendConfig = {
    id | String | optional,
    registry | String,
    namespace | String,
    auth_token_path | String | optional,
    timeout_seconds | Number | default = 30,
    verify_ssl | Bool | default = true,
  },

  # Multi-instance source backends configuration
  SourcesConfig = {
    gitea | Array SourceBackendConfig | default = [],
    forgejo | Array SourceBackendConfig | default = [],
    github | Array SourceBackendConfig | default = [],
  },

  # Multi-instance distribution backends configuration
  DistributionsConfig = {
    oci | Array DistributionBackendConfig | default = [],
  },

  # Server configuration
  ServerConfig = {
    host | String | default = "0.0.0.0",
    port | Number | default = 8082,
    workers | Number | default = 4,
    enable_cors | Bool | default = false,
    enable_compression | Bool | default = true,
  },

  # Cache configuration
  CacheConfig = {
    capacity | Number | default = 1000,
    ttl_seconds | Number | default = 300,
    enable_metadata_cache | Bool | default = true,
    enable_list_cache | Bool | default = true,
  },

  # Legacy single-instance configuration (auto-migrated to multi-instance)
  LegacySourceConfig = {
    url | String,
    organization | String,
    token_path | String,
    timeout_seconds | Number | optional,
    verify_ssl | Bool | optional,
  },

  LegacyDistributionConfig = {
    registry | String,
    namespace | String,
    auth_token_path | String | optional,
    timeout_seconds | Number | optional,
    verify_ssl | Bool | optional,
  },

  # Main registry configuration
  RegistryConfig = {
    server | ServerConfig | default = {},

    # New multi-instance format (recommended)
    sources | SourcesConfig | default = {},
    distributions | DistributionsConfig | default = {},

    # Legacy single-instance format (auto-migrated on startup)
    gitea | LegacySourceConfig | optional,
    oci | LegacyDistributionConfig | optional,

    # Cache configuration
    cache | CacheConfig | default = {},
  },
}
