{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://corenetx.md/schema/parameters.schema.json",
  "title": "corenetx.md per-component parameters.json",
  "description": "Machine API for one CORENET X / IFC-SG component: its IFC classifications (bindings) and the parameters each one requires. A binding is one classification — IFC entity + SubType — and its parameters apply only to model elements exported with that entity and SubType: if the model has no such element, nothing in that binding is required. Unknown fields are rejected; a new field is added to this schema in the same change that adds it to the data.",
  "type": "object",
  "required": [
    "component",
    "discipline",
    "authorities",
    "source",
    "source_url",
    "ifc_bindings"
  ],
  "properties": {
    "component": {
      "type": "string"
    },
    "discipline": {
      "type": "string",
      "enum": [
        "",
        "ARC",
        "MEP",
        "STR"
      ],
      "description": "Blank in corpus 4: a component can mix disciplines (Wall and Staircase publish an architectural and a structural table), so discipline belongs to the classification and will be recorded there. The folder a component sits in (arc/ mep/ str/) is storage only."
    },
    "authorities": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Agencies that check this component. Reset to [] in corpus 4 (revision 1) pending a fresh review by the maintainer; an empty list means 'not yet recorded', not 'no agency'."
    },
    "source": {
      "type": "string"
    },
    "source_url": {
      "type": "string"
    },
    "source_related": {
      "type": "array"
    },
    "page_range": {
      "type": "array",
      "items": {
        "type": "integer"
      },
      "description": "First and last CoP 4th Edition PDF page of this component's IFC+SG tables."
    },
    "ifc_bindings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/binding"
      }
    }
  },
  "$defs": {
    "binding": {
      "type": "object",
      "required": [
        "ifc_entity",
        "ifc_subtype",
        "ifc_subtypes",
        "scope",
        "no_properties_required",
        "parameters"
      ],
      "properties": {
        "ifc_entity": {
          "type": "string",
          "description": "IFC entity of this classification, e.g. IfcDoor."
        },
        "ifc_subtype": {
          "type": [
            "string",
            "null"
          ]
        },
        "ifc_subtypes": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          },
          "description": "The SubType values (IFC PredefinedType / ObjectType) this classification covers; null when the page gives none (the entity alone classifies)."
        },
        "scope": {
          "type": [
            "string",
            "null"
          ],
          "description": "Label the official page published above this binding's table, verbatim, saying which subset of the component it describes — a model/discipline (\"architectural model\", \"structural model\"), a kind of object (\"object tanks\", \"RC tanks\"), a part of one (\"the internal space of the Household Shelter\"), a variant (\"Bidet\", \"Water Closet\"), or a level of application (\"Individual Pile\", \"project information for piles in general\"). null when the page published no label for that table.",
          "examples": [
            "architectural model",
            "structural model",
            "Water Closet",
            "Individual Pile",
            "voluntary",
            null
          ]
        },
        "no_properties_required": {
          "type": "boolean",
          "description": "True when the page says 'No IFC+SG properties required' for this classification; exactly then `parameters` is empty."
        },
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/parameter"
          }
        }
      },
      "description": "One IFC classification of the component: an IFC entity plus, where the page gives one, its SubType(s). Its parameters apply only to elements of this classification that exist in the model. A component often has several — a main element and its sub-components (Household Shelter: the space, its walls and slabs, its outlets), or one table per discipline (see `scope`).",
      "additionalProperties": false,
      "if": {
        "properties": {
          "parameters": {
            "maxItems": 0
          }
        }
      },
      "then": {
        "properties": {
          "no_properties_required": {
            "const": true
          }
        }
      },
      "else": {
        "properties": {
          "no_properties_required": {
            "const": false
          }
        }
      }
    },
    "parameter": {
      "type": "object",
      "required": [
        "property",
        "type",
        "input_limited"
      ],
      "properties": {
        "property": {
          "type": "string"
        },
        "type": {
          "type": [
            "string",
            "null"
          ]
        },
        "sn": {
          "type": "integer"
        },
        "sn_label": {
          "type": "string"
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "input_limited": {
          "type": "boolean"
        },
        "applies_to": {
          "type": "string"
        },
        "examples": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowed_values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowed_values_source": {
          "type": "string"
        },
        "reference_values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "reference_values_source": {
          "type": "string"
        },
        "value_source": {
          "type": "object",
          "description": "Pointer to a shared reference table this parameter draws its values from, rather than a per-component list. Carried ALONGSIDE any allowed_values / reference_values, not instead of them: the tables are structured (space names by category, AGF names by development use, occupancy types by authority mapping) and a flat list loses that. Some parameters carry only the pointer — their page marks them input-limited but enumerates nothing, pointing the reader at the shared table.",
          "required": [
            "catalogue",
            "file",
            "key"
          ],
          "properties": {
            "catalogue": {
              "type": "string",
              "enum": [
                "occupancy_types",
                "space_names",
                "agf_names"
              ]
            },
            "file": {
              "type": "string",
              "description": "Corpus-relative path to the reference JSON."
            },
            "key": {
              "type": "string",
              "description": "Top-level key inside that file holding the table."
            }
          }
        },
        "glossary_mandatory": {
          "type": "boolean",
          "description": "What the component's own official page note says about filling this parameter: true = the note requires it (must / shall / needs to), false = the note says it is optional or not mandatory, absent = the page is silent. Several requirements are conditional (e.g. 'for manhole', 'Civil defence shelter slab'); the condition is in glossary_mandatory_note."
        },
        "property_raw": {
          "type": "string",
          "description": "The property cell exactly as published, where it differs from `property`: a footnote marker (e.g. 'ClearWidth^') or an inline type (e.g. 'AGF_Name [Text]')."
        },
        "glossary_mandatory_note": {
          "type": "string",
          "description": "The official page sentence behind glossary_mandatory, verbatim (or 'Type of Elements: Optional' when the table itself says so)."
        },
        "footnote": {
          "type": "string",
          "description": "What the footnote marker in property_raw means, as the official source states it."
        },
        "only_subtypes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "uniqueItems": true,
          "description": "The footnote limits this parameter to these IFC SubTypes of its binding. Elements of the binding's other SubTypes do not need it."
        }
      },
      "additionalProperties": false,
      "anyOf": [
        {
          "required": [
            "sn"
          ]
        },
        {
          "required": [
            "sn_label"
          ]
        }
      ],
      "not": {
        "required": [
          "allowed_values",
          "reference_values"
        ]
      },
      "dependentRequired": {
        "allowed_values": [
          "allowed_values_source"
        ],
        "allowed_values_source": [
          "allowed_values"
        ],
        "reference_values": [
          "reference_values_source"
        ],
        "reference_values_source": [
          "reference_values"
        ],
        "glossary_mandatory": [
          "glossary_mandatory_note"
        ],
        "glossary_mandatory_note": [
          "glossary_mandatory"
        ]
      }
    }
  },
  "additionalProperties": false
}
