{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/Nikodem01/printwright-x402/main/public/external-profile-v1.schema.json",
  "title": "Printwright External Profile v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "profile", "models"],
  "properties": {
    "schema_version": {"const": 1},
    "profile": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "url"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "url": {"type": "string", "format": "uri", "pattern": "^https://"}
      }
    },
    "models": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
        "type": "object",
        "required": ["id", "title", "slug", "source_url", "source_license", "files", "offers"],
        "properties": {
          "id": {"type": "string", "pattern": "^[a-zA-Z0-9._:-]{1,100}$"},
          "title": {"type": "string", "minLength": 1},
          "slug": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"},
          "description": {"type": "string"},
          "tags": {"type": "array", "items": {"type": "string"}},
          "category": {"type": ["string", "null"]},
          "collections": {"type": "array", "items": {"type": "string"}},
          "printability": {"type": ["object", "null"]},
          "source_url": {"type": "string", "format": "uri", "pattern": "^https://"},
          "source_license": {"type": "string"},
          "files": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["kind", "url", "sha256"],
              "properties": {
                "kind": {"type": "string", "enum": ["stl", "3mf", "step", "render"]},
                "url": {"type": "string", "format": "uri", "pattern": "^https://"},
                "sha256": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
              }
            }
          },
          "offers": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["kind", "price_cents"],
              "properties": {
                "kind": {"type": "string", "enum": ["personal", "commercial_unit"]},
                "price_cents": {"type": "integer", "minimum": 1},
                "currency": {"type": "string", "enum": ["USDC", "HBAR"]},
                "max_units": {"type": ["integer", "null"], "minimum": 1}
              }
            }
          }
        }
      }
    }
  }
}
