{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://digitaltwin-os.com/data/assurances.schema.json",
  "title": "DigitalTwin OS public explanatory diagram model",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "version",
    "title",
    "diagrams"
  ],
  "properties": {
    "$schema": {
      "const": "https://digitaltwin-os.com/data/assurances.schema.json"
    },
    "version": {
      "const": 1
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "diagrams": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {
        "$ref": "#/$defs/diagram"
      }
    }
  },
  "$defs": {
    "node": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "label",
        "hint",
        "detail"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "maxLength": 40
        },
        "type": {
          "enum": [
            "system",
            "workflow",
            "human",
            "record",
            "principle",
            "portal",
            "access"
          ]
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 18
        },
        "hint": {
          "type": "string",
          "minLength": 1,
          "maxLength": 18
        },
        "detail": {
          "type": "string",
          "minLength": 1,
          "maxLength": 300
        }
      }
    },
    "edge": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "from",
        "to",
        "type",
        "label"
      ],
      "properties": {
        "from": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "maxLength": 40
        },
        "to": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "maxLength": 40
        },
        "type": {
          "enum": [
            "feeds",
            "gates",
            "records",
            "mirrors",
            "uploads",
            "authorizes"
          ]
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 40
        }
      }
    },
    "diagram": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "kind",
        "title",
        "summary",
        "nodes",
        "edges"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "maxLength": 40
        },
        "kind": {
          "enum": [
            "process",
            "principles",
            "architecture"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 40
        },
        "summary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 90
        },
        "nodes": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": {
            "$ref": "#/$defs/node"
          }
        },
        "edges": {
          "type": "array",
          "maxItems": 12,
          "items": {
            "$ref": "#/$defs/edge"
          }
        }
      }
    }
  }
}
