{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.1/proposed/drawings/defs.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. No file of OpenEik 0.1 is held to it; a validator applies it only when asked for the proposal (@openeik/tools: proposals [\"drawings\"]).",
  "title": "Drawings: shared definitions",
  "description": "The definitions the schemas of the proposal drawings share (Part XIV, proposed for 0.2): hashes, times, ids, the people they name, codes and the status of a revision. It asserts nothing of its own.",
  "$defs": {
    "hash": {
      "description": "A SHA-256 as 64 lowercase hexadecimal digits, with no sha256: prefix: a JSON file's hash (the SHA-256 of its canonical form, Part III, 6), or a digest of bytes (an SVG's, a PDF's, a font's) (XIV.7.2).",
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "commit": {
      "description": "A version's id (64 hexadecimal digits) or a git commit's id (40 or 64), as Part VI, 8.2 names a version.",
      "type": "string",
      "pattern": "^([0-9a-f]{40}|[0-9a-f]{64})$"
    },
    "version": {
      "description": "The version a thing was drawn or made from, as Part VI, 8.2's computedFrom.version names one: a version's or a commit's id, or null for a folder under no version control.",
      "anyOf": [
        {
          "$ref": "#/$defs/commit"
        },
        {
          "type": "null"
        }
      ]
    },
    "time": {
      "description": "A date and time in UTC, as RFC 3339 writes it with Z (XIV.7.2).",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?Z$"
    },
    "date": {
      "description": "A date, YYYY-MM-DD (XIV.7.2).",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "id": {
      "description": "An id (Part I, 6), minted without coordination where it names a file.",
      "type": "string",
      "minLength": 1,
      "pattern": "^[^/]+$"
    },
    "person": {
      "description": "A person or an agent of the registry, project/people/<id>.json (XIV.5), by its id: never an email address (XIV.5.2, rules 2 and 3, which a validator checks in code).",
      "type": "string",
      "minLength": 1,
      "pattern": "^[^/]+$",
      "x-eik-ref": "person"
    },
    "number": {
      "description": "A drawing's number, ISO 7200's identification number: 1 to 80 characters (XIV.2.1).",
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "revisionCode": {
      "description": "A revision code as printed (P02, C01, B), 0 to 20 characters: empty where the drawing profile prints none (XIV.8.2).",
      "type": "string",
      "maxLength": 20
    },
    "code": {
      "description": "A code of the project's drawing profile: a plain value, which OpenEik lists none of and checks against no code list (Part II, 8, rules 3 and 4; XIV.4.1).",
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "x-eik-values": "national"
    },
    "role": {
      "description": "A role the project gives a person (approver, checker): a plain value.",
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "x-eik-values": "national"
    },
    "profileId": {
      "description": "A drawing profile's id, as revision records cite it (XIV.4.1).",
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "x-eik-values": "national"
    },
    "state": {
      "description": "OpenEik's state of a revision (XIV.8.2). Superseded and withdrawn are the register's; live is never stored.",
      "type": "string",
      "enum": [
        "draft",
        "shared",
        "published",
        "asBuilt"
      ]
    },
    "sharedFor": {
      "description": "What a shared revision is shared for.",
      "type": "string",
      "enum": [
        "information",
        "review"
      ]
    },
    "status": {
      "description": "A revision's status: the drawing profile's id, its status code, and its purpose code where the project uses one (XIV.8.1).",
      "type": "object",
      "properties": {
        "profile": {
          "$ref": "#/$defs/profileId"
        },
        "code": {
          "$ref": "#/$defs/code"
        },
        "purpose": {
          "$ref": "#/$defs/code"
        }
      },
      "required": [
        "profile",
        "code"
      ],
      "x-eik-closed": true
    },
    "base64": {
      "description": "Bytes in base64, standard or URL-safe, padded or not.",
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z0-9+/_-]+={0,2}$"
    },
    "base64url": {
      "description": "Bytes in base64url (RFC 4648, 5), without padding as WebAuthn writes them, or with it.",
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z0-9_-]+={0,2}$"
    },
    "asset": {
      "description": "An asset's path: assets/<sha256>.<ext>, a binary named by the SHA-256 of its bytes (XIV.7.3).",
      "type": "string",
      "pattern": "^assets/[0-9a-f]{64}\\.[a-z0-9]{1,8}$"
    },
    "mediaType": {
      "description": "A media type (application/pdf, image/jpeg).",
      "type": "string",
      "minLength": 3,
      "maxLength": 200,
      "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*(;.*)?$"
    },
    "point": {
      "description": "A point [x, y].",
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ]
    },
    "point3": {
      "description": "A point [x, y, z], in mm of the model (Part I, 4).",
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ]
    },
    "feature": {
      "description": "A named feature of an element: layer:<id>, face:<name> or edge:<id>, never an index (XIV.3.3).",
      "type": "string",
      "minLength": 3,
      "maxLength": 200,
      "pattern": "^(layer|face|edge):.+$"
    },
    "shapeForm": {
      "description": "How a shape's points are drawn (XIV.13.2; open question 61): freehand, a stroke of a pen; polyline, open; polygon, closed; rectangle, the four corners of a rectangle in order, which may be turned; ellipse, the ellipse that fills the rectangle of its four points. Absent, the points are drawn straight, closed where closed is true. XIV.13.4, rule 9, which a validator checks in code, says how many points each takes and whether it is closed.",
      "type": "string",
      "enum": [
        "freehand",
        "polyline",
        "polygon",
        "rectangle",
        "ellipse"
      ]
    },
    "action": {
      "description": "What a sign-off says the signer did (XIV.14.1). An agent signs only checkedByTool, and a person never signs it (XIV.14.7, rule 6).",
      "type": "string",
      "enum": [
        "checked",
        "reviewed",
        "approved",
        "authorised",
        "accepted",
        "rejected",
        "withdrawn",
        "checkedByTool"
      ]
    }
  }
}
