{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.3/fabrication/piece.schema.json",
  "title": "Piece",
  "description": "A fabricated unit: what leaves the factory as one piece (fabrication profile).",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "mark": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40
    },
    "name": {
      "type": "string",
      "maxLength": 120
    },
    "kind": {
      "type": "string",
      "enum": [
        "steel",
        "precast"
      ]
    },
    "mainId": {
      "type": "string",
      "minLength": 1
    },
    "partIds": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "maxItems": 500
    },
    "specs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "value": {
            "type": "string",
            "maxLength": 160
          }
        },
        "required": [
          "label",
          "value"
        ],
        "x-eik-closed": true
      },
      "maxItems": 40
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 300
      },
      "maxItems": 20
    },
    "from": {
      "type": "string",
      "enum": [
        "exterior",
        "interior"
      ]
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "section",
              "plan",
              "detail"
            ]
          },
          "at": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              }
            ]
          },
          "letter": {
            "type": "string",
            "pattern": "^[A-Z]{1,2}$"
          }
        },
        "required": [
          "kind",
          "at"
        ],
        "x-eik-closed": true
      },
      "maxItems": 12
    },
    "drawing": {
      "type": "object",
      "properties": {
        "sheetId": {
          "type": "string",
          "minLength": 1
        },
        "fingerprint": {
          "type": "string",
          "maxLength": 40
        }
      },
      "required": [
        "sheetId"
      ],
      "x-eik-closed": true
    },
    "revision": {
      "type": "integer",
      "minimum": 0,
      "default": 0
    },
    "classifications": {
      "$ref": "../classifications/classifications.schema.json"
    }
  },
  "required": [
    "id",
    "mark",
    "kind",
    "mainId",
    "partIds"
  ],
  "x-eik-closed": true
}
