variable "region" {
  description = "AWS region"
  type        = string
  default     = "us-east-1"

  validation {
    condition     = contains(["us-east-1", "us-west-2"], var.region)
    error_message = "Only us-east-1 and us-west-2 are supported (Bedrock model availability)."
  }
}

variable "environment" {
  description = "Deployment environment (e.g. qa, prod)"
  type        = string
  default     = "qa"
}

variable "service_name" {
  description = "Service name used in resource naming"
  type        = string
  default     = "ows-coda"
}

variable "application_family" {
  description = "Application family to which ows-coda belongs"
  type        = string
  default     = "coda"
}

variable "team_name" {
  description = "Team responsible for ows-coda"
  type        = string
  default     = "coda"
}

#######
# Auth0
#######

variable "auth0_audience" {
  description = "Auth0 API audience identifier for ows-coda (shared workstation audience)"
  type        = string
  default     = "https://workstation.qaorch.com/api"
}

variable "auth0_client_id" {
  description = "Auth0 client ID"
  type        = string
  default     = "x937kb4f5c3hJRGazmCm5NDrx0hVk8eg"
}

variable "auth0_domain" {
  description = "Auth0 tenant domain"
  type        = string
  default     = "qalogin.theorchard.com"
}

#######
# Main app — Snowflake
#######

variable "snowflake_account" {
  description = "Snowflake account identifier for ows-coda"
  type        = string
  default     = "delphi.us-east-1"
}

variable "snowflake_username" {
  description = "Snowflake service account username for ows-coda"
  type        = string
  default     = "QA_CODA_SVC_USER"
}

variable "snowflake_database" {
  description = "Snowflake database name for ows-coda agent queries"
  type        = string
  default     = "ORCHARD_APP_REPORTING_V2"
}

variable "snowflake_role" {
  description = "Snowflake role for ows-coda"
  type        = string
  default     = "QA_CODA_SVC"
}

variable "snowflake_warehouse" {
  description = "Snowflake warehouse for ows-coda queries"
  type        = string
  default     = "QA_OWS_WAREHOUSE"
}

#######
# Search service — Snowflake
#######

variable "search_snowflake_account" {
  description = "Snowflake account identifier for ows-coda-search"
  type        = string
  default     = "delphi.us-east-1"
}

variable "search_snowflake_username" {
  description = "Snowflake service account username for ows-coda-search"
  type        = string
  default     = "QA_CODA_SEARCH_SVC_USER"
}

variable "search_snowflake_database" {
  description = "Snowflake database name for ows-coda-search schema introspection"
  type        = string
  default     = "ORCHARD_APP_REPORTING_V2"
}

variable "search_snowflake_role" {
  description = "Snowflake role for ows-coda-search"
  type        = string
  default     = "QA_CODA_SEARCH_SVC"
}

variable "search_snowflake_env" {
  description = "Environment override for Snowflake allowlist/blocklist placeholders in ows-coda-search"
  type        = string
  default     = "prod"
}

variable "search_snowflake_warehouse" {
  description = "Snowflake warehouse for ows-coda-search queries"
  type        = string
  default     = "QA_OWS_WAREHOUSE"
}

variable "search_graphql_poll_interval_ms" {
  description = "GraphQL schema poll interval in milliseconds for ows-coda-search"
  type        = number
  default     = 7200000
}

variable "search_snowflake_poll_interval_ms" {
  description = "Snowflake schema poll interval in milliseconds for ows-coda-search"
  type        = number
  default     = 7200000
}

#######
# Runner service — Snowflake
#######

variable "runner_snowflake_account" {
  description = "Snowflake account identifier for ows-coda-runner"
  type        = string
  default     = "delphi.us-east-1"
}

variable "runner_snowflake_username" {
  description = "Snowflake service account username for ows-coda-runner"
  type        = string
  default     = "QA_CODA_SEARCH_SVC_USER"
}

variable "runner_snowflake_database" {
  description = "Snowflake database name for ows-coda-runner pipeline queries"
  type        = string
  default     = "ORCHARD_APP_REPORTING_V2"
}

variable "runner_snowflake_role" {
  description = "Snowflake role for ows-coda-runner"
  type        = string
  default     = "QA_CODA_SEARCH_SVC"
}

variable "runner_snowflake_warehouse" {
  description = "Snowflake warehouse for ows-coda-runner queries"
  type        = string
  default     = "QA_OWS_WAREHOUSE"
}

#######
# Ephemeral instances
#######

variable "instance" {
  description = "Instance suffix for ephemeral environments (e.g. 'pr-42'). Leave empty for the main environment."
  type        = string
  default     = ""

  validation {
    condition     = var.instance == "" || can(regex("^[a-z][a-z0-9-]{0,20}$", var.instance))
    error_message = "Must be lowercase alphanumeric with hyphens, 1-21 chars, starting with a letter."
  }
}

#######
# Langfuse
#######

variable "langfuse_enabled" {
  description = "Enable Langfuse LLM observability infrastructure"
  type        = bool
  default     = true
}

variable "langfuse_db_username" {
  description = "Langfuse PostgreSQL master username"
  type        = string
  default     = "langfuse_admin"
}

#######
# API Gateway
#######

variable "api_gateway_domain" {
  description = "Custom domain for the API Gateway"
  type        = string
  default     = "qa-coda-api.theorchard.io"
}
