# example_parameters.yaml
#
# This file illustrates the structure of a parameters.yaml for a Skeleton Entity template.
# Place it at skeleton/parameters.yaml in your template repository.
#
# The file has two top-level sections:
#   parameters            - derived/computed fields; accessible as parameters.* in catalog-info.yaml
#   environmentParameters - per-environment values;  accessible as env.*        in catalog-info.yaml
#   values                - static fields;           accessible as values.*     in catalog-info.yaml

parameters:
  # --- Name normalization (reusable across catalog-info.yaml) ---
  #
  # Strip the "domain:" prefix, spaces and hyphens from the domain URN.
  # "domain:default/finance marketing" -> "financemarketing"
  domainNameNormalized: ${{ parameters.domain | replace(r/domain:| |-/, "") }}

  # Extract the data product name segment (index 1 of the dot-separated identifier) and strip spaces and hyphens.
  # "namespace.my-data-product.1" -> "mydataproduct"
  dataProductNameNormalized: ${{ parameters.dataproduct.split(".")[1] | replace(r/ |-/g, "") }}

  # Extract the major version from the component identifier (index 2).
  # "namespace.my-data-product.3.my-component" -> "3"
  dataProductMajorVersion: ${{ parameters.identifier.split(".")[2] }}

  # --- Chained derived fields ---
  #
  # Build environment-specific database names from the normalized domain name. 
  # This can be directly computed on the environmentParamters if they not need to be referenced in the catalog-info
  databaseDevelopment: ${{ parameters.domainNameNormalized | upper }}_DEVELOPMENT
  databaseQa: ${{ parameters.domainNameNormalized | upper }}_QA
  databaseProduction: ${{ parameters.domainNameNormalized | upper }}_PRODUCTION

  # Compute the Snowflake schema name from the data product name + major version.
  # "mydataproduct" + "3" -> "MYDATAPRODUCT_3"
  schema: ${{ parameters.dataProductNameNormalized | upper }}_${{ parameters.dataProductMajorVersion }}

  # --- Schema inheritance override (Output Port pattern) ---
  #
  # If the user chose to inherit the schema at creation time, populate editSchemaColumns
  # from the inherited value. Otherwise start empty.
  # After creation, the Editor Wizard writes directly to this field via WittyTableTemplate.
  editSchemaColumns: ${{ parameters.schemaDefinition.schemaColumns if parameters.inheritSchema else [] }}

# --- Environment-specific parameters ---
#
# Witboost selects the block matching the active environment and makes
# each key available as env.<key> inside catalog-info.yaml.
environmentParameters:
  development:
    # Resolved from the derived field above: FINANCE_DEVELOPMENT
    database: ${{ parameters.databaseDevelopment }}
  qa:
    database: ${{ parameters.databaseQa }}
  production:
    database: ${{ parameters.databaseProduction }}
