{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.1/proposed/drawings/issue.schema.json",
  "$comment": "Proposed for OpenEik 0.2: Part XIV, drawings. Written by hand from the outline of Part XIV, not generated: tools/generate-schemas.mjs keeps this folder and lists none of it in index.json. In 0.1 the file is a kept file; a validator holds it to this schema only when asked for the proposal (@openeik/tools: proposals [\"drawings\"]).",
  "title": "Issue",
  "description": "A transmittal, the release of revisions, versions of the model or both to recipients for a purpose: drawings/issues/<issue>.json (Part XIV, 12, proposed for 0.2). Each revision by its revision record's hash, each version by its root tree hash (Part XVIII, 3, proposed beside it), the prints sent with it by their digests and the terms it is sent under by theirs; recipients by their ids in the registry, or by name for someone outside it, never by an email address. Delivery, links and read receipts are the host's, and stay there.",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-drawing-issue/0.1"
    },
    "id": {
      "description": "The file's name, minted without coordination.",
      "$ref": "defs.schema.json#/$defs/id"
    },
    "purpose": {
      "description": "A purpose of the drawing profile.",
      "type": "object",
      "properties": {
        "profile": {
          "$ref": "defs.schema.json#/$defs/profileId"
        },
        "code": {
          "$ref": "defs.schema.json#/$defs/code"
        }
      },
      "required": [
        "profile",
        "code"
      ],
      "x-eik-closed": true
    },
    "sent": {
      "description": "Who sent it, a person of the registry, and when.",
      "type": "object",
      "properties": {
        "by": {
          "$ref": "defs.schema.json#/$defs/person"
        },
        "at": {
          "$ref": "defs.schema.json#/$defs/time"
        }
      },
      "required": [
        "by",
        "at"
      ],
      "x-eik-closed": true
    },
    "revisions": {
      "description": "The revisions released, each by its revision record's hash.",
      "type": "array",
      "minItems": 1,
      "maxItems": 10000,
      "items": {
        "type": "object",
        "properties": {
          "drawing": {
            "$ref": "defs.schema.json#/$defs/number"
          },
          "sequence": {
            "type": "integer",
            "minimum": 1
          },
          "revision": {
            "$ref": "defs.schema.json#/$defs/revisionCode"
          },
          "record": {
            "$ref": "defs.schema.json#/$defs/hash"
          }
        },
        "required": [
          "drawing",
          "sequence",
          "revision",
          "record"
        ],
        "x-eik-closed": true
      }
    },
    "versions": {
      "description": "Part XVIII, 3.1: the versions of the model released, each by its root tree hash, its id (null for a folder under no version control) and its line of work. XVIII.3.2, rule 1, which a validator checks in code: each root once.",
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/version"
      }
    },
    "renditions": {
      "description": "Part XVIII, 3.1: the prints sent with the issue, each by the SHA-256 and the length of the file sent, what it was printed from (a version the issue releases, by its root, or a revision, by its drawing and sequence: XVIII.3.2, rule 2, checked in code), its kind by its file's extension, and the bridge or renderer that made it. A print is kept nowhere.",
      "type": "array",
      "maxItems": 10000,
      "items": {
        "$ref": "#/$defs/rendition"
      }
    },
    "terms": {
      "description": "Part XVIII, 3.1: the terms the issue is sent under, by the SHA-256 of their text, with their title and version as people know them.",
      "type": "array",
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/terms"
      }
    },
    "recipients": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "$ref": "#/$defs/recipient"
      }
    },
    "note": {
      "type": "string",
      "maxLength": 2000
    }
  },
  "required": [
    "format",
    "id",
    "sent",
    "recipients"
  ],
  "anyOf": [
    {
      "required": [
        "revisions"
      ]
    },
    {
      "required": [
        "versions"
      ]
    }
  ],
  "x-eik-closed": true,
  "$defs": {
    "recipient": {
      "description": "A person of the registry, or someone outside it by name and organisation: personal data, kept in every version that holds it.",
      "type": "object",
      "properties": {
        "person": {
          "$ref": "defs.schema.json#/$defs/person"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "organisation": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        }
      },
      "oneOf": [
        {
          "required": [
            "person"
          ]
        },
        {
          "required": [
            "name"
          ]
        }
      ],
      "x-eik-closed": true
    },
    "version": {
      "description": "A version of the model released: its root tree hash (Part VI, 2, rule 4), its id as Part VI, 8.2 names a version, and its line of work.",
      "type": "object",
      "properties": {
        "version": {
          "$ref": "defs.schema.json#/$defs/version"
        },
        "root": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "required": [
        "version",
        "root"
      ],
      "x-eik-closed": true
    },
    "rendition": {
      "description": "A print sent with the issue (Part XVIII, 3.1): what it was printed from, its kind by its file's extension, the SHA-256 and the length of the file sent, and the bridge or renderer that made it.",
      "type": "object",
      "properties": {
        "of": {
          "description": "A version the issue releases, by its root, or a revision it releases, by its drawing and sequence.",
          "type": "object",
          "properties": {
            "root": {
              "$ref": "defs.schema.json#/$defs/hash"
            },
            "drawing": {
              "$ref": "defs.schema.json#/$defs/number"
            },
            "sequence": {
              "type": "integer",
              "minimum": 1
            }
          },
          "oneOf": [
            {
              "required": [
                "root"
              ]
            },
            {
              "required": [
                "drawing",
                "sequence"
              ]
            }
          ],
          "dependentRequired": {
            "drawing": [
              "sequence"
            ],
            "sequence": [
              "drawing"
            ]
          },
          "x-eik-closed": true
        },
        "format": {
          "description": "The print's kind, by its file's extension, in lower case: pdf, ifc.",
          "type": "string",
          "pattern": "^[a-z0-9]{1,16}$"
        },
        "sha256": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "by": {
          "description": "The bridge or the renderer that made it, and its version.",
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "version": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          },
          "required": [
            "name",
            "version"
          ],
          "x-eik-closed": true
        }
      },
      "required": [
        "of",
        "format",
        "sha256",
        "bytes",
        "by"
      ],
      "x-eik-closed": true
    },
    "terms": {
      "description": "Terms, by the SHA-256 of their text, with their title and version as people know them (Part XVIII, 3.1 and 6).",
      "type": "object",
      "properties": {
        "sha256": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        }
      },
      "required": [
        "sha256",
        "title"
      ],
      "x-eik-closed": true
    }
  }
}
