{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://casoon.github.io/typst-business-templates/schema/credentials.schema.json",
  "title": "Credentials",
  "description": "Data for the credentials template (access data document): a title page and one section per service with technical settings, ports and logins.",
  "type": "object",
  "required": ["metadata", "services"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "URL or path of this schema, for editor support."
    },
    "metadata": {
      "type": "object",
      "description": "Document metadata shown on the title page, header and footer.",
      "required": ["document_number", "title", "client_name", "project_name", "created_at"],
      "properties": {
        "document_number": { "type": "string", "description": "Document number, e.g. ZD-2025-007." },
        "title": { "type": "string", "description": "Document title." },
        "client_name": { "type": "string", "description": "Client name, shown on the title page and in the footer." },
        "project_name": { "type": "string", "description": "Project name, shown on the title page." },
        "created_at": {
          "type": "object",
          "description": "Creation date. Must be an object; the template prints created_at.date as given.",
          "required": ["date"],
          "properties": {
            "date": { "type": "string", "description": "Date as printed, e.g. 2025-01-22." }
          }
        },
        "tags": {
          "type": "array",
          "description": "Tags shown as pills on the title page.",
          "items": { "type": "string" }
        },
        "security_level": { "type": "string", "description": "Classification, e.g. strictly_confidential. Not rendered by the template." },
        "notes": { "type": "string", "description": "Internal notes. Not rendered by the template." }
      }
    },
    "services": {
      "type": "array",
      "description": "Services, each rendered as its own section.",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": { "type": "string", "description": "Service name, used as section heading." },
          "description": { "type": ["string", "null"], "description": "Short description below the heading." },
          "url": { "type": ["string", "null"], "description": "Service URL, rendered as a link." },
          "technical": {
            "type": "array",
            "description": "Technical settings as key/value rows.",
            "items": {
              "type": "object",
              "required": ["key", "value"],
              "properties": {
                "key": { "type": "string", "description": "Setting name." },
                "value": { "type": ["string", "number", "boolean"], "description": "Setting value, rendered as code." }
              }
            }
          },
          "ports": {
            "type": "array",
            "description": "Ports and protocols table.",
            "items": {
              "type": "object",
              "required": ["port", "protocol"],
              "properties": {
                "port": { "type": ["string", "integer"], "description": "Port number." },
                "protocol": { "type": "string", "description": "Protocol, e.g. TCP." },
                "description": { "type": "string", "description": "What the port is used for." }
              }
            }
          },
          "credentials": {
            "type": "array",
            "description": "Logins for this service.",
            "items": {
              "type": "object",
              "required": ["username", "password"],
              "properties": {
                "username": { "type": "string", "description": "User name, rendered as code." },
                "password": { "type": "string", "description": "Password or a reference to where it is stored, rendered as code." },
                "credential_type": { "type": ["string", "null"], "description": "Kind of login, e.g. web, database, ssh, api_key." },
                "description": { "type": ["string", "null"], "description": "Bold label above the login, e.g. the role." }
              }
            }
          },
          "notes": { "type": ["string", "null"], "description": "Notes shown at the end of the service section." }
        }
      }
    }
  }
}
