{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.norruva.com/nrpf/v1/nrpf-supply-chain-node.schema.json",
  "title": "NRPF Supply Chain Node",
  "description": "A node in a Bill of Materials (BOM) hierarchy. Represents a product, sub-assembly, component, raw material, or packaging element. Derived from BOMNode entity (@modules/supply-chain-kernel/domain/product/entities/BOMNode.ts).",
  "$comment": "@task P2-W4-13 @epic P2-ConsumerDistribution",
  "type": "object",
  "required": ["id", "name", "nodeType", "quantity", "unitOfMeasure", "level"],
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Unique identifier for this BOM node."
    },
    "parentId": {
      "type": ["string", "null"],
      "format": "uuid",
      "description": "Parent node identifier. Null for the root node."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Name of the component, sub-assembly, or material."
    },
    "partNumber": {
      "type": "string",
      "description": "Manufacturer or internal part number."
    },
    "description": {
      "type": "string",
      "description": "Textual description of this node."
    },
    "nodeType": {
      "type": "string",
      "enum": ["PRODUCT", "ASSEMBLY", "COMPONENT", "RAW_MATERIAL", "PACKAGING"],
      "description": "Classification of this BOM node."
    },
    "quantity": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Quantity of this node used in the parent assembly."
    },
    "unitOfMeasure": {
      "type": "string",
      "description": "Unit of measure for quantity (e.g. kg, pcs, m, L).",
      "examples": ["kg", "pcs", "m", "L", "m2"]
    },
    "unitCost": {
      "type": "number",
      "minimum": 0,
      "description": "Unit cost of this component."
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "ISO 4217 currency code for unitCost.",
      "examples": ["EUR", "USD", "GBP"]
    },
    "materials": {
      "type": "array",
      "description": "Material composition breakdown for this node.",
      "items": {
        "type": "object",
        "required": ["materialName", "materialClass", "weightKg", "weightPercent"],
        "additionalProperties": false,
        "properties": {
          "materialName": {
            "type": "string",
            "description": "Common or chemical name of the material."
          },
          "materialClass": {
            "type": "string",
            "description": "Material class (e.g. plastic, metal, textile, glass, bio-based).",
            "examples": ["plastic", "metal", "textile", "glass", "bio-based", "ceramic"]
          },
          "weightKg": {
            "type": "number",
            "minimum": 0,
            "description": "Weight of this material in kilograms."
          },
          "weightPercent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Percentage of total node weight this material represents."
          },
          "recycledContentPercent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Percentage of this material that is recycled content (post-consumer or pre-consumer)."
          },
          "hazardClass": {
            "type": "string",
            "description": "Hazard classification code (e.g. none, H301, CMR-1A). 'none' if not hazardous.",
            "examples": ["none", "H301", "H311", "CMR-1A", "SVHC"]
          },
          "certifications": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Certification identifiers applicable to this material.",
            "examples": [["FSC-C012345", "GOTS"], ["ISO14001"]]
          }
        }
      }
    },
    "totalWeightKg": {
      "type": "number",
      "minimum": 0,
      "description": "Total weight of this node in kilograms."
    },
    "recycledContentPercent": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Weighted-average recycled content percentage across all materials in this node."
    },
    "supplierId": {
      "type": "string",
      "description": "Identifier of the supplier providing this component."
    },
    "supplierPartNumber": {
      "type": "string",
      "description": "Supplier's own part number for this component."
    },
    "leadTimeDays": {
      "type": "integer",
      "minimum": 0,
      "description": "Typical procurement lead time in calendar days."
    },
    "carbonFootprintKg": {
      "type": "number",
      "minimum": 0,
      "description": "Carbon footprint of this node in kg CO2-equivalent (cradle-to-gate)."
    },
    "countryOfOrigin": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "ISO 3166-1 alpha-2 country code of manufacturing origin.",
      "examples": ["DE", "CN", "US", "FR"]
    },
    "level": {
      "type": "integer",
      "minimum": 0,
      "description": "Depth of this node in the BOM tree (0 = root product)."
    },
    "sortOrder": {
      "type": "integer",
      "minimum": 0,
      "description": "Ordering position among sibling nodes."
    },
    "childCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Number of direct child nodes."
    }
  }
}
