{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://interchange.stellarview.net/schemas/mappings/catalogue.schema.json",
  "title": "Mapping: the product catalogue in JSM Assets and Jira. Data, editable in Setup, versioned, with its source.",
  "type": "object",
  "required": ["mapping", "version", "updated", "updated_by", "source", "contract", "jira", "installed_item", "model", "install_ticket"],
  "additionalProperties": false,
  "$defs": {
    "objectType": {
      "type": "object",
      "required": ["object_type", "tag_attribute", "attributes"],
      "additionalProperties": false,
      "properties": {
        "object_type": { "type": "string", "minLength": 1 },
        "tag_attribute": { "type": "string", "minLength": 1 },
        "attributes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["name", "type", "from"],
            "additionalProperties": false,
            "properties": {
              "name": { "type": "string", "minLength": 1 },
              "type": { "enum": ["Text", "Integer", "Boolean", "Double", "Date", "DateTime", "URL", "Email", "Textarea"] },
              "from": { "type": "string", "minLength": 1 }
            }
          }
        }
      }
    }
  },
  "properties": {
    "mapping": { "const": "catalogue" },
    "version": { "type": "integer", "minimum": 1 },
    "updated": { "type": "string" },
    "updated_by": { "type": "string", "minLength": 1 },
    "about": { "type": "string" },
    "source": {
      "type": "object",
      "required": ["cite"],
      "additionalProperties": false,
      "properties": { "cite": { "type": "string", "minLength": 1 }, "read": { "type": "string" } }
    },
    "contract": { "const": "product-catalogue@1" },
    "jira": {
      "type": "object",
      "required": ["object_schema", "label_attribute", "labels"],
      "additionalProperties": false,
      "properties": {
        "object_schema": {
          "type": "object",
          "required": ["name", "key", "description"],
          "additionalProperties": false,
          "properties": { "name": { "type": "string" }, "key": { "type": "string", "pattern": "^[A-Z][A-Z0-9]+$" }, "description": { "type": "string" } }
        },
        "label_attribute": { "type": "string", "minLength": 1 },
        "labels": {
          "type": "object",
          "required": ["fixture", "real"],
          "additionalProperties": false,
          "properties": { "fixture": { "type": "string" }, "real": { "type": "string" } }
        }
      }
    },
    "installed_item": { "$ref": "#/$defs/objectType" },
    "model": { "$ref": "#/$defs/objectType" },
    "install_ticket": {
      "type": "object",
      "required": ["issuetype", "summary", "labels", "state"],
      "additionalProperties": false,
      "properties": {
        "issuetype": { "type": "string" },
        "summary": { "type": "string" },
        "labels": { "type": "array", "items": { "type": "string" } },
        "state": { "const": "proposed" },
        "note": { "type": "string" }
      }
    }
  }
}
