{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.2/drawings/read-set.schema.json",
  "$comment": "OpenEik 0.2: folded by tools/fold-schemas.mjs from the proposal drawings, which 0.2 makes a rule (decision D5). Written by hand from the text, not generated.",
  "title": "Read set",
  "description": "Every record an issued revision's drawing read, with its hash, and the elements its views' volumes held: drawings/issued/<drawing>/read-set.json (Part XIV, 9.2. A pair is [path, hash] as Part VI, 8.3 says: a record's leaf path and its hash, or a kept file's own path and the hash of its text as a canonical JSON string; a view gives one pair for view.json and one for each detail chunk. Each list is sorted by path, each path once (XIV.9.7, rule 1, which a validator checks in code).",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-drawing-read-set/0.1"
    },
    "drawing": {
      "$ref": "defs.schema.json#/$defs/number"
    },
    "sequence": {
      "type": "integer",
      "minimum": 1
    },
    "sheet": {
      "description": "The pairs the sheet as a whole read: the sheet record, its title block, the project, the levels, the drawing profile, the people whose names it prints, the sheets its reference list names.",
      "$ref": "#/$defs/pairs"
    },
    "viewports": {
      "description": "One entry per viewport of the derivation, in its order.",
      "type": "array",
      "maxItems": 200,
      "items": {
        "$ref": "#/$defs/viewport"
      }
    }
  },
  "required": [
    "format",
    "drawing",
    "sequence",
    "sheet",
    "viewports"
  ],
  "x-eik-closed": true,
  "$defs": {
    "pair": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "$ref": "defs.schema.json#/$defs/hash"
        }
      ]
    },
    "pairs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/pair"
      }
    },
    "viewport": {
      "description": "A viewport: what it consulted (read), the elements the volume test held at the source version that read does not hold (inVolume), and the test's parameters (volume).",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "view": {
          "$ref": "defs.schema.json#/$defs/id"
        },
        "volume": {
          "$ref": "#/$defs/volume"
        },
        "read": {
          "$ref": "#/$defs/pairs"
        },
        "inVolume": {
          "$ref": "#/$defs/pairs"
        }
      },
      "required": [
        "id",
        "view",
        "volume",
        "read",
        "inVolume"
      ],
      "x-eik-closed": true
    },
    "end": {
      "description": "A bound, or null for an open end.",
      "type": [
        "number",
        "null"
      ]
    },
    "volume": {
      "description": "Where a view can show something (XIV.9.3): a plan, its crop in plan [x0, x1, y0, y1], its rotation, and z [bottom, top] in absolute elevations; a section or an elevation, its origin and direction, its crop across [u0, u1, v0, v1] and its depth [0, far]; a drafting view, which holds no element; a 3D view, whose volume is the whole model, every element of which is in its read or inVolume. Each gives margin, mm, added all round.",
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "plan",
            "section",
            "elevation",
            "drafting",
            "3d"
          ]
        },
        "crop": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": {
            "$ref": "#/$defs/end"
          }
        },
        "rotation": {
          "type": "number",
          "minimum": -360,
          "maximum": 360
        },
        "z": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/end"
          }
        },
        "origin": {
          "$ref": "defs.schema.json#/$defs/point"
        },
        "direction": {
          "$ref": "defs.schema.json#/$defs/point"
        },
        "depth": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/end"
          }
        },
        "margin": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "kind"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "const": "plan"
              }
            },
            "required": [
              "kind"
            ]
          },
          "then": {
            "required": [
              "crop",
              "rotation",
              "z",
              "margin"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "enum": [
                  "section",
                  "elevation"
                ]
              }
            },
            "required": [
              "kind"
            ]
          },
          "then": {
            "required": [
              "origin",
              "direction",
              "crop",
              "depth",
              "margin"
            ]
          }
        }
      ],
      "x-eik-closed": true
    }
  }
}
