{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kernelcad.com/manufacturing-partners/supplier-bridge-v1.schema.json",
  "title": "KernelCAD Supplier Bridge v1 quote request",
  "description": "Request body sent by KernelCAD to an allowlisted manufacturing supplier quote endpoint.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "requestId", "destinationCountry", "process", "material", "quantity", "part", "file"],
  "properties": {
    "schema": { "const": "kernelcad.manufacturing.quote.v1" },
    "requestId": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "destinationCountry": { "type": "string", "pattern": "^[A-Z]{2}$" },
    "process": {
      "type": "string",
      "enum": ["laser_cut", "sheetmetal", "cnc", "fdm_print", "resin_print"]
    },
    "material": { "type": "string", "minLength": 1, "maxLength": 80 },
    "quantity": { "type": "integer", "minimum": 1, "maximum": 10000 },
    "part": {
      "type": "object",
      "additionalProperties": false,
      "required": ["item", "name", "bboxMm", "massGPerUnit", "thicknessMm"],
      "properties": {
        "item": { "type": "integer", "minimum": 1 },
        "name": { "type": "string", "minLength": 1, "maxLength": 200 },
        "bboxMm": {
          "type": "object",
          "additionalProperties": false,
          "required": ["min", "max"],
          "properties": {
            "min": { "$ref": "#/$defs/vector3" },
            "max": { "$ref": "#/$defs/vector3" }
          }
        },
        "massGPerUnit": { "type": ["number", "null"], "minimum": 0 },
        "thicknessMm": { "type": ["number", "null"], "exclusiveMinimum": 0 }
      }
    },
    "file": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "kind", "sha256", "contentBase64"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "maxLength": 255 },
        "kind": { "type": "string", "enum": ["step", "stl", "dxf"] },
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "contentBase64": { "type": "string", "minLength": 1, "contentEncoding": "base64" }
      }
    }
  },
  "$defs": {
    "vector3": {
      "type": "array",
      "prefixItems": [
        { "type": "number" },
        { "type": "number" },
        { "type": "number" }
      ],
      "items": false,
      "minItems": 3,
      "maxItems": 3
    }
  }
}
