{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "drawpack.spec.schema.json",
  "title": "Drawing pack spec",
  "description": "Describes an A4 first-angle technical drawing pack. The same file drives the browser tool, drawpack.py and drawpack.ts. Geometry always comes from the loaded STEP file.",
  "type": "object",
  "required": ["sheets"],
  "additionalProperties": false,
  "properties": {
    "company": { "type": "string", "description": "Short company name in the title strip, e.g. OTT" },
    "product": { "type": "string", "description": "Product title in caps, e.g. LIGHTER CASE HOLDER" },
    "rev": { "type": "string", "description": "Revision letter, e.g. H" },
    "doc": { "type": "string", "description": "Document number, e.g. OTT-LH-DOC-003" },
    "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$", "description": "YYYY-MM-DD" },
    "conventions": { "type": "array", "items": { "type": "string" }, "description": "Lines of text for the Units and source block on the conventions sheet" },
    "font": {
      "type": "object", "additionalProperties": false, "required": ["family"],
      "properties": { "family": { "type": "string" }, "file": { "type": "string", "description": "CLI only. In the browser, upload the font file in the UI." } }
    },
    "step": { "type": "string", "description": "CLI only: path to the STEP file. Ignored in the browser." },
    "sheets": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/sheet" } }
  },
  "definitions": {
    "hidden": {
      "description": "Dashed hidden lines. true/false for every drawing on the sheet, or per drawing e.g. {\"front\": true, \"right\": false}. Defaults: dashed on ortho, off on iso/cover/single/sections.",
      "oneOf": [ { "type": "boolean" }, { "type": "object", "additionalProperties": { "type": "boolean" } } ]
    },
    "cell": { "oneOf": [ { "type": "string" }, { "type": "number" }, { "type": "array", "items": { "type": "string" } } ], "description": "Text, number, or a list of lines. A string may contain \\n." },
    "sheet": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "title": { "type": "string", "description": "Sheet title; shown in the title strip and contents" },
        "layout": { "enum": ["cover", "iso", "single", "ortho", "sections", "table", "contents", "conventions", "blank"] },
        "section": { "type": "string", "description": "Top-left label, e.g. 1 OVERVIEW. Also groups the contents sheet." },
        "desc": { "type": "string", "description": "One-line description shown in the contents" },
        "subline": { "type": "string", "description": "Overrides the line under the section label" },
        "scale": { "type": "number", "exclusiveMinimum": 0, "description": "Factor: 2 = 2:1, 0.5 = 1:2. Omit for automatic." },
        "notes_head": { "type": "string" },
        "notes": { "type": "array", "items": { "type": "string" }, "description": "Short plain paragraphs for the right-hand notes column" },
        "hidden": { "$ref": "#/definitions/hidden" },
        "view": { "enum": ["iso", "front", "right", "left", "back", "plan", "bottom"], "description": "single/iso/cover only" },
        "plan": { "type": "boolean", "description": "ortho: add the plan view below the front" },
        "dims": { "type": "boolean", "description": "ortho: draw overall dimensions (default true)" },
        "views": { "type": "array", "items": { "enum": ["right", "front", "left"] }, "description": "ortho: override the row of views" },
        "cuts": {
          "type": "array", "description": "sections: each cut is labelled A-A, B-B... in order",
          "items": { "type": "object", "required": ["axis", "at"], "additionalProperties": false,
            "properties": { "axis": { "enum": ["x", "y", "z"] }, "at": { "type": "number", "description": "Position on that axis in mm" }, "hidden": { "type": "boolean" } } }
        },
        "columns": { "type": "array", "items": { "type": "string" } },
        "widths": { "type": "array", "items": { "type": "number" }, "description": "Column widths in pt; table area is about 765 pt wide" },
        "rows": { "type": "array", "items": { "type": "array", "items": { "$ref": "#/definitions/cell" } } },
        "heading": { "type": "string" },
        "subheading": { "type": "string" },
        "check": {
          "type": "object", "required": ["pack", "price", "each"], "additionalProperties": false,
          "description": "Column names. The tool warns for any row where each != price / pack.",
          "properties": { "pack": { "type": "string" }, "price": { "type": "string" }, "each": { "type": "string" } }
        },
        "blocks": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "heading": { "type": "string" }, "lines": { "type": "array", "items": { "type": "string" } } } } }
      }
    }
  }
}
