{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.1/proposed/drawings/profile.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": "Drawing profile",
  "description": "The project's drawing conventions, drawings/profile.json (Part XIV, 4, proposed for 0.2): its status, purpose, decision and review-state codes mapped onto OpenEik's neutral states, the revision series of each status, the cloud rules, the sign-offs each status needs, and the pinned font set. A drawing file, not a record. Every code is a plain value: OpenEik lists none and checks none against a code list (Part II, 8, rules 3 and 4).",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-drawing-profile/0.1"
    },
    "id": {
      "description": "The profile's name, as revision records cite it (example, iso19650-uk-2021, beast-2.1).",
      "$ref": "defs.schema.json#/$defs/profileId"
    },
    "statuses": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/status"
      }
    },
    "purposes": {
      "description": "Purposes of issue (in Sweden, the handling).",
      "type": "array",
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/purpose"
      }
    },
    "decisions": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/decision"
      }
    },
    "reviewStates": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/reviewState"
      }
    },
    "newRevisionOnStatusChange": {
      "description": "Whether a change of status alone takes a new revision code; absent, false.",
      "type": "boolean"
    },
    "numbering": {
      "description": "A regular expression (ECMAScript, u flag) that drawing numbers match.",
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "fonts": {
      "description": "The declared, pinned font set: each family, the SHA-256 of its font file, and the asset that holds it. A font the project may not store is named by its digest alone (XIV.4.3, rule 4). Required where the folder holds a linked issued drawing (XIV.4.3, rule 5), which a validator checks in code; a profile that only gives a model's reviews their codes (Part XVIII, 2) needs none.",
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/font"
      }
    },
    "keepEarlierClouds": {
      "description": "Whether a revision keeps the clouds of the revisions before it; absent, false.",
      "type": "boolean"
    },
    "reanchor": {
      "type": "object",
      "properties": {
        "threshold": {
          "description": "The score below which a moved anchor fails (XIV.3.3).",
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "required": [
        "threshold"
      ],
      "x-eik-closed": true
    },
    "owners": {
      "description": "Who is responsible for each drawing, by its number: a person of the registry, so that a host can route its reviews.",
      "type": "object",
      "propertyNames": {
        "$ref": "defs.schema.json#/$defs/number"
      },
      "additionalProperties": {
        "$ref": "defs.schema.json#/$defs/person"
      }
    }
  },
  "required": [
    "format",
    "id",
    "statuses"
  ],
  "x-eik-closed": true,
  "$defs": {
    "status": {
      "description": "A status code; its name as people read it; the OpenEik state it means; for shared, what it is shared for; whether the sheet prints it; the revision series it uses (XIV.8.2); whether clouds print by default; and the sign-offs it needs.",
      "type": "object",
      "properties": {
        "code": {
          "$ref": "defs.schema.json#/$defs/code"
        },
        "name": {
          "$ref": "#/$defs/name"
        },
        "state": {
          "$ref": "defs.schema.json#/$defs/state"
        },
        "sharedFor": {
          "$ref": "defs.schema.json#/$defs/sharedFor"
        },
        "printed": {
          "type": "boolean"
        },
        "revisions": {
          "description": "The revision series: none (dated only), P (P01, P02), P.minor (P01.01), C (C01), letters (A to Z, then AA, AB, leaving out I and O) or numbers (1, 2).",
          "type": "string",
          "enum": [
            "none",
            "P",
            "P.minor",
            "C",
            "letters",
            "numbers"
          ]
        },
        "clouds": {
          "type": "string",
          "enum": [
            "on",
            "off"
          ]
        },
        "requires": {
          "description": "The sign-offs a revision of this status needs (XIV.14.7, rule 12).",
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "object",
            "properties": {
              "action": {
                "$ref": "defs.schema.json#/$defs/action"
              },
              "role": {
                "$ref": "defs.schema.json#/$defs/role"
              }
            },
            "required": [
              "action"
            ],
            "x-eik-closed": true
          }
        }
      },
      "required": [
        "code",
        "state",
        "printed",
        "revisions",
        "clouds"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "state": {
                "const": "shared"
              }
            },
            "required": [
              "state"
            ]
          },
          "then": {
            "required": [
              "sharedFor"
            ]
          }
        }
      ],
      "x-eik-closed": true
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "purpose": {
      "type": "object",
      "properties": {
        "code": {
          "$ref": "defs.schema.json#/$defs/code"
        },
        "name": {
          "$ref": "#/$defs/name"
        }
      },
      "required": [
        "code"
      ],
      "x-eik-closed": true
    },
    "decision": {
      "description": "A decision code: gate A approves for sharing, gate B authorises and accepts; its outcome.",
      "type": "object",
      "properties": {
        "code": {
          "$ref": "defs.schema.json#/$defs/code"
        },
        "gate": {
          "type": "string",
          "enum": [
            "A",
            "B"
          ]
        },
        "outcome": {
          "type": "string",
          "enum": [
            "accept",
            "acceptWithComments",
            "reject"
          ]
        },
        "name": {
          "$ref": "#/$defs/name"
        }
      },
      "required": [
        "code",
        "gate",
        "outcome"
      ],
      "x-eik-closed": true
    },
    "reviewState": {
      "description": "A state of review items, and whether it leaves an item open.",
      "type": "object",
      "properties": {
        "code": {
          "$ref": "defs.schema.json#/$defs/code"
        },
        "open": {
          "type": "boolean"
        },
        "name": {
          "$ref": "#/$defs/name"
        }
      },
      "required": [
        "code",
        "open"
      ],
      "x-eik-closed": true
    },
    "font": {
      "type": "object",
      "properties": {
        "family": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "sha256": {
          "$ref": "defs.schema.json#/$defs/hash"
        },
        "file": {
          "description": "The asset that holds the font: assets/<sha256>.ttf or .otf.",
          "type": "string",
          "pattern": "^assets/[0-9a-f]{64}\\.(ttf|otf)$"
        }
      },
      "required": [
        "family",
        "sha256"
      ],
      "x-eik-closed": true
    }
  }
}
