{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.3/drawings/register.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": "Register",
  "description": "Every snapshot ever taken of one drawing, oldest first: drawings/register/<drawing>.json (Part XIV, 11), append-only. An issued entry is a revision, by its revision record's hash and its SVG's digest and derivation's hash (linked) or its file's digest (unlinked), and what it was drawn from; a rendition entry a PDF rendition kept as an asset; a withdrawn entry the drawing's end. Superseded is implied: each issued entry supersedes the one before. The issuer adds entries, in the building; a host never writes it.",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-drawing-register/0.1"
    },
    "drawing": {
      "$ref": "defs.schema.json#/$defs/number"
    },
    "kind": {
      "type": "string",
      "enum": [
        "linked",
        "unlinked"
      ]
    },
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      }
    }
  },
  "required": [
    "format",
    "drawing",
    "kind",
    "entries"
  ],
  "x-eik-closed": true,
  "$defs": {
    "entry": {
      "type": "object",
      "properties": {
        "event": {
          "type": "string",
          "enum": [
            "issued",
            "rendition",
            "withdrawn"
          ]
        }
      },
      "required": [
        "event"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "event": {
                "const": "issued"
              }
            },
            "required": [
              "event"
            ]
          },
          "then": {
            "$ref": "#/$defs/issued"
          }
        },
        {
          "if": {
            "properties": {
              "event": {
                "const": "rendition"
              }
            },
            "required": [
              "event"
            ]
          },
          "then": {
            "$ref": "#/$defs/rendition"
          }
        },
        {
          "if": {
            "properties": {
              "event": {
                "const": "withdrawn"
              }
            },
            "required": [
              "event"
            ]
          },
          "then": {
            "$ref": "#/$defs/withdrawn"
          }
        }
      ],
      "x-eik-closed": true
    },
    "issued": {
      "description": "A revision: record, its revision record's hash; svg, its SVG's digest, and derivation, its derivation's hash (linked), or asset, its file's digest (unlinked); source, what it was drawn from, so that history finds its files.",
      "properties": {
        "event": {
          "const": "issued"
        },
        "sequence": {
          "type": "integer",
          "minimum": 1
        },
        "revision": {
          "$ref": "defs.schema.json#/$defs/revisionCode"
        },
        "date": {
          "$ref": "defs.schema.json#/$defs/date"
        },
        "state": {
          "$ref": "defs.schema.json#/$defs/state"
        },
        "sharedFor": {
          "$ref": "defs.schema.json#/$defs/sharedFor"
        },
        "status": {
          "$ref": "defs.schema.json#/$defs/status"
        },
        "record": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "svg": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "derivation": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "asset": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "source": {
          "type": "object",
          "properties": {
            "version": {
              "$ref": "defs.schema.json#/$defs/version"
            },
            "root": {
              "$ref": "defs.schema.json#/$defs/hash"
            }
          },
          "required": [
            "version",
            "root"
          ],
          "x-eik-closed": true
        },
        "by": {
          "$ref": "defs.schema.json#/$defs/person",
          "description": "Who issued it: its revision record's by (Part XIV, 11.1), so that a revision table signs each row from the register."
        }
      },
      "required": [
        "event",
        "sequence",
        "revision",
        "date",
        "state",
        "status",
        "record"
      ]
    },
    "rendition": {
      "description": "A PDF rendition kept as an asset (XIV.15): the revision it renders, the asset's digest (assets/<sha256>.pdf), the standard it meets (PDF/A-3b), and whether it is signed.",
      "properties": {
        "event": {
          "const": "rendition"
        },
        "sequence": {
          "type": "integer",
          "minimum": 1
        },
        "asset": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "standard": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "signed": {
          "type": "boolean"
        }
      },
      "required": [
        "event",
        "sequence",
        "asset",
        "standard",
        "signed"
      ]
    },
    "withdrawn": {
      "description": "The drawing's end: its last revision stays in the folder.",
      "properties": {
        "event": {
          "const": "withdrawn"
        },
        "date": {
          "$ref": "defs.schema.json#/$defs/date"
        },
        "by": {
          "$ref": "defs.schema.json#/$defs/person"
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 400
        }
      },
      "required": [
        "event",
        "date",
        "by"
      ]
    }
  }
}
