# Base form for Provisioning system configuration
# Uses fragments for modular, conditional provisioning configuration
# Location: .typedialog/provisioning/form.toml (generated per project)

description = "Interactive configuration for deployment provisioning (Docker Compose, Kubernetes, databases, monitoring)"
display_mode = "complete"
locales_path = ""
name = "Provisioning Configuration Form"

# ============================================================================
# PROJECT INFORMATION (Always shown)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "project_header"
title = "📦 Project Information"
type = "section_header"

[[elements]]
help = "Project name (lowercase alphanumeric with hyphens)"
name = "project_name"
nickel_path = ["provisioning", "project", "name"]
placeholder = "my-app"
prompt = "Project name"
required = true
type = "text"
validation_pattern = "^[a-z0-9-]+$"

[[elements]]
help = "Semantic version (X.Y.Z)"
name = "project_version"
nickel_path = ["provisioning", "project", "version"]
placeholder = "0.1.0"
prompt = "Project version"
required = true
type = "text"
default = "0.1.0"
validation_pattern = "^[0-9]+\\.[0-9]+\\.[0-9]+$"

[[elements]]
help = "Brief description of the project"
name = "project_description"
nickel_path = ["provisioning", "project", "description"]
placeholder = "API service for managing resources"
prompt = "Project description"
required = false
type = "text"

# ============================================================================
# DATABASE SELECTION (Always shown)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "database_header"
title = "💾 Database Configuration"
type = "section_header"

[[elements]]
help = "Select the database type for your application"
name = "database_type"
nickel_path = ["provisioning", "database", "type"]
prompt = "Database type"
required = true
type = "select"
options = ["none", "sqlite", "postgres", "mysql", "surrealdb"]
default = "sqlite"

# Load database-specific fragments (conditional)
load_fragments = [
    "fragments/database-sqlite.toml",
    "fragments/database-postgres.toml",
    "fragments/database-mysql.toml",
    "fragments/database-surrealdb.toml"
]

# ============================================================================
# API SERVICE CONFIGURATION (Always shown)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "service_header"
title = "🚀 Service Configuration"
type = "section_header"

[[elements]]
help = "Name of the main API service"
name = "api_service_name"
nickel_path = ["provisioning", "services", "api", "name"]
placeholder = "api"
prompt = "API service name"
required = true
type = "text"
default = "api"

[[elements]]
help = "Container port for the API service"
name = "api_container_port"
nickel_path = ["provisioning", "services", "api", "ports", "0", "container_port"]
prompt = "Container port"
required = true
type = "custom"
custom_type = "u16"
default = "8080"
minimum = "1"
maximum = "65535"

[[elements]]
help = "Host port to expose the API service"
name = "api_host_port"
nickel_path = ["provisioning", "services", "api", "ports", "0", "host_port"]
prompt = "Host port"
required = true
type = "custom"
custom_type = "u16"
default = "8080"
minimum = "1024"
maximum = "65535"

[[elements]]
help = "Health check endpoint for the API"
name = "api_healthcheck_endpoint"
nickel_path = ["provisioning", "services", "api", "healthcheck", "endpoint"]
placeholder = "/health"
prompt = "Health check endpoint"
required = true
type = "text"
default = "/health"

[[elements]]
help = "Number of service replicas"
name = "api_replicas"
nickel_path = ["provisioning", "services", "api", "replicas"]
prompt = "Number of replicas"
required = true
type = "custom"
custom_type = "u16"
default = "1"
minimum = "1"
maximum = "100"

# ============================================================================
# DEPLOYMENT TARGET (Always shown)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "deployment_header"
title = "🚢 Deployment Target"
type = "section_header"

[[elements]]
help = "Select the deployment platform"
name = "deployment_target"
nickel_path = ["provisioning", "deployment", "target"]
prompt = "Deployment target"
required = true
type = "select"
options = ["docker", "kubernetes", "both"]
default = "docker"

# Load deployment-specific fragments (conditional)
load_fragments = [
    "fragments/deployment-docker.toml",
    "fragments/deployment-k8s.toml"
]

# ============================================================================
# MONITORING (Optional)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "monitoring_header"
title = "📊 Monitoring & Observability"
type = "section_header"

[[elements]]
help = "Enable monitoring stack (Prometheus, Grafana)"
name = "enable_monitoring"
nickel_path = ["provisioning", "monitoring", "enabled"]
prompt = "Enable monitoring?"
required = true
type = "confirm"
default = false

# Load monitoring fragment (conditional)
load_fragments = [
    "fragments/monitoring.toml"
]

# ============================================================================
# SECURITY (Optional)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "security_header"
title = "🔒 Security Configuration"
type = "section_header"

[[elements]]
help = "Enable TLS/SSL for services"
name = "enable_tls"
nickel_path = ["provisioning", "security", "tls", "enabled"]
prompt = "Enable TLS/SSL?"
required = true
type = "confirm"
default = false

[[elements]]
help = "Authentication method"
name = "auth_method"
nickel_path = ["provisioning", "security", "auth", "method"]
prompt = "Authentication method"
required = true
type = "select"
options = ["none", "basic", "bearer", "oauth2", "jwt", "api_key"]
default = "none"

# Load security fragments (conditional)
load_fragments = [
    "fragments/auth-jwt.toml",
    "fragments/auth-api-key.toml"
]

# ============================================================================
# CONFIRMATION (Always shown)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "confirmation_header"
title = "✅ Confirmation"
type = "section_header"

[[elements]]
help = "Review your configuration and confirm to generate"
name = "confirm_generation"
prompt = "Generate provisioning configuration?"
required = true
type = "confirm"
default = true
