# Requirements schema — contract types for tool declarations and execution contexts.
# Imported by: reflection/requirements/base.ncl, reflection/requirements/contexts.ncl
#
# NOTE: This file is a contract library — do not `nickel export` it directly.
#       Export base.ncl or contexts.ncl instead.

let severity_type = [| 'Hard, 'Soft |] in

# A tool or external dependency that operations in this project require.
let tool_type = {
  id              | String | default = "",
  binary          | String | default = "",
  description     | String | default = "",
  version_min     | String | default = "0.0.0",
  check_cmd       | String | default = "",
  version_extract | String | default = "(\\d+\\.\\d+\\.\\d+)",
  install_hint    | String | default = "",
  docs_url        | String | optional,
  severity        | severity_type | default = 'Soft,
  contexts        | Array String | default = [],
  used_by_forms   | Array String | default = [],
  used_by_modes   | Array String | default = [],
  config_check    | String | optional,
  config_hint     | String | optional,
  # When set, presence is checked via `plugin list` instead of `which`.
  # The check_cmd is still run to extract version from `plugin list` output.
  plugin_name     | String | optional,
} in

# A named execution context with a subset of required tools.
let context_type = {
  id          | String | default = "",
  description | String | default = "",
  requires    | Array String | default = [],
  note        | String | optional,
} in

{
  Tool    = tool_type,
  Context = context_type,
  Severity = severity_type,
}
