# Integrations Contracts
#
# Type-safe contracts for runtime abstraction and GitOps integration.

{
  # ========================================================================
  # Runtime Abstraction Contracts
  # ========================================================================

  # Runtime types
  Runtime = String,  # "docker" | "podman" | "orbstack" | "colima" | "nerdctl"

  RuntimeConfig = {
    preferred | Runtime | optional,
    check_order | Array Runtime,
    timeout_secs | Number,
    enable_cache | Bool,
  },

  ComposeAdapterConfig = {
    runtime | Runtime,
    compose_file | String,
    environment | String,  # "dev" | "staging" | "prod"
    network_mode | String | optional,
    port_overrides | {_: String} | optional,
  },

  # ========================================================================
  # GitOps Contracts
  # ========================================================================

  GitProvider = String,  # "github" | "gitlab" | "gitea"
  EventType = String,  # "push" | "pull-request" | "webhook" | "scheduled" | "health-check" | "manual"
  Environment = String,  # "dev" | "staging" | "prod"

  GitOpsRule = {
    name | String,
    provider | GitProvider,
    repository | String,
    branch | String,
    events | Array EventType,
    targets | Array Environment,
    command | String,
    pre_deploy_hook | String | optional,
    post_deploy_hook | String | optional,
    require_approval | Bool,
    concurrency_limit | Number,
  },

  WebhookConfig = {
    provider | GitProvider,
    port | Number,
    secret | String | optional,
    allowed_events | Array EventType,
  },

  ScheduledTrigger = {
    name | String,
    cron | String,
    rule | String,
    environment | Environment,
  },

  HealthCheckTrigger = {
    name | String,
    endpoint | String,
    interval_secs | Number,
    failure_threshold | Number,
    on_failure_action | String,
  },

  GitOpsConfig = {
    rules | Array GitOpsRule,
    webhooks | Array WebhookConfig,
    scheduled | Array ScheduledTrigger,
    health_checks | Array HealthCheckTrigger,
    default_strategy | String,
    dry_run_by_default | Bool,
    enable_audit_log | Bool,
  },
}
