{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://confighub.github.io/helm-expt/site/chart.schema.json",
  "title": "CatalogChart",
  "description": "One Helm chart in the ConfigHub Workshop Catalog: its versions newest first, the bases of each version with their listing and retained object file, one stored summary line for each adjacent pair of versions, and the recipe that computes any other diff on demand. Every fact about a base is read from its listing, which stays the authority.",
  "type": "object",
  "additionalProperties": false,
  "required": ["apiVersion", "kind", "chartVersion", "schema", "chart", "format", "url", "page", "counts", "versions", "summaries", "compare", "liveExample"],
  "properties": {
    "apiVersion": { "const": "catalog.confighub.com/v1alpha1" },
    "kind": { "const": "CatalogChart" },
    "chartVersion": { "const": "1", "description": "The version of this file's field meanings. It is not a chart version." },
    "schema": { "type": "string", "format": "uri" },
    "chart": { "type": "string", "description": "The chart as the Catalog names it, repository and name." },
    "format": { "const": "helm" },
    "url": { "type": "string", "format": "uri" },
    "page": { "type": "string", "format": "uri" },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "required": ["versions", "bases"],
      "properties": {
        "versions": { "type": "integer", "minimum": 1 },
        "bases": { "type": "integer", "minimum": 1 }
      }
    },
    "versions": {
      "type": "array",
      "minItems": 1,
      "description": "Newest first, ordered as versions and not as strings.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["version", "page", "defaultBase", "package", "bases"],
        "properties": {
          "version": { "type": "string" },
          "page": { "type": "string", "format": "uri" },
          "defaultBase": { "type": "string" },
          "package": {
            "type": "object",
            "additionalProperties": false,
            "required": ["published", "signed", "ociRef"],
            "properties": {
              "published": { "type": "boolean", "description": "True when the installer package of this version has a committed publication receipt." },
              "signed": { "type": "boolean" },
              "ociRef": { "type": "string" }
            }
          },
          "bases": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["base", "default", "listing", "objectCount", "verdict", "published", "flagged", "objects"],
              "properties": {
                "base": { "type": "string" },
                "default": { "type": "boolean" },
                "listing": {
                  "description": "The listing of this base, or null when the base has none yet.",
                  "oneOf": [
                    { "type": "null" },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": ["id", "url"],
                      "properties": { "id": { "type": "string" }, "url": { "type": "string", "format": "uri" } }
                    }
                  ]
                },
                "objectCount": { "type": ["integer", "null"] },
                "verdict": { "type": ["string", "null"], "description": "The flattening verdict the listing records." },
                "published": { "type": ["boolean", "null"], "description": "True when the listing records a public OCI reference for this base." },
                "flagged": { "type": ["boolean", "null"], "description": "True when the listing marks the entry watch, a checked result with a limit to review." },
                "objects": {
                  "description": "The retained object file, or null when the base has no listing.",
                  "oneOf": [
                    { "type": "null" },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": ["path", "url", "sha256", "objectSetDigest"],
                      "properties": {
                        "path": { "type": "string", "description": "The file's path in the repository. The site serves the repository root one level above site/." },
                        "url": { "type": "string", "format": "uri" },
                        "sha256": { "type": ["string", "null"], "pattern": "^sha256:[0-9a-f]{64}$", "description": "The SHA-256 of the file bytes, when the listing records one." },
                        "objectSetDigest": { "type": ["string", "null"], "description": "The object-set digest the listing records." }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "summaries": {
      "type": "array",
      "description": "One line for each adjacent pair of versions, on the default base of each. This is the only diff content the site stores. It is computed when the site is generated, by the code named in compare.core.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["from", "to", "added", "removed", "changed", "unchanged", "line"],
        "properties": {
          "from": { "$ref": "#/definitions/side" },
          "to": { "$ref": "#/definitions/side" },
          "added": { "type": "integer", "minimum": 0 },
          "removed": { "type": "integer", "minimum": 0 },
          "changed": { "type": "integer", "minimum": 0 },
          "unchanged": { "type": "integer", "minimum": 0 },
          "line": { "type": "string" }
        }
      }
    },
    "compare": {
      "type": "object",
      "additionalProperties": false,
      "required": ["computedOnDemand", "core", "recipe"],
      "properties": {
        "computedOnDemand": { "const": true },
        "core": {
          "type": "object",
          "additionalProperties": false,
          "required": ["command", "repository", "commit", "path", "sha256"],
          "properties": {
            "command": { "const": "cub config diff" },
            "repository": { "type": "string", "format": "uri" },
            "commit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
            "path": { "type": "string" },
            "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$", "description": "The SHA-256 of the vendored comparison core." }
          }
        },
        "recipe": {
          "type": "array",
          "description": "The commands that compute the diff between any two bases. Replace each name in angle brackets with the field it names, read from the two bases.",
          "items": { "type": "string" }
        }
      }
    },
    "liveExample": {
      "description": "A live example of this chart in ConfigHub, or null when the maintainer has approved none. An example is not a run for any Catalog entry.",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["organization", "holds", "observedOn", "done", "notDone", "addresses", "commands"],
          "properties": {
            "organization": { "type": "string" },
            "holds": { "type": "string" },
            "observedOn": { "type": "string", "format": "date" },
            "done": { "type": "string" },
            "notDone": { "type": "string" },
            "addresses": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": ["label", "url"],
                "properties": { "label": { "type": "string" }, "url": { "type": "string", "format": "uri" } }
              }
            },
            "commands": { "type": "array", "items": { "type": "string" } }
          }
        }
      ]
    }
  },
  "definitions": {
    "side": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "base", "listing"],
      "properties": {
        "version": { "type": "string" },
        "base": { "type": "string" },
        "listing": { "type": "string", "description": "The id of the listing for this side." }
      }
    }
  }
}
