{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ksn-advisory.com/templates/catalogue.schema.json",
  "title": "Template Hub catalogue",
  "description": "Metadata for every guide and template in the hub. Contains no paid document bodies. Each items/<id>.json file validates against #/$defs/item.",
  "type": "object",
  "required": [
    "site",
    "publisher",
    "base_url",
    "generated",
    "licence",
    "ai_usage",
    "count",
    "items"
  ],
  "properties": {
    "site": {
      "type": "string"
    },
    "publisher": {
      "type": "string"
    },
    "base_url": {
      "type": "string",
      "format": "uri"
    },
    "generated": {
      "type": "string",
      "format": "date-time"
    },
    "licence": {
      "type": "string",
      "format": "uri"
    },
    "ai_usage": {
      "type": "string",
      "format": "uri"
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "item": {
      "type": "object",
      "required": [
        "id",
        "title",
        "type",
        "pack",
        "tier",
        "access",
        "iso13485",
        "eu_mdr",
        "other_refs",
        "device_scope",
        "version",
        "last_reviewed",
        "summary",
        "topics",
        "formats",
        "html_url",
        "md_url",
        "json_url"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^TH-(QP|QF|TF|QR|G)[0-9]{2,3}[a-z]?$",
          "description": "Neutral hub document ID"
        },
        "title": {
          "type": "string"
        },
        "type": {
          "enum": [
            "procedure",
            "form",
            "template",
            "register",
            "guide"
          ]
        },
        "pack": {
          "enum": [
            "qms",
            "techfile",
            "guide"
          ]
        },
        "tier": {
          "enum": [
            "free",
            "paid"
          ]
        },
        "access": {
          "enum": [
            "full",
            "metadata_only"
          ],
          "description": "full: body is public. metadata_only: body is for buyers of the pack only."
        },
        "iso13485": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "ISO 13485:2016 clause numbers, e.g. \"8.5.2\""
        },
        "eu_mdr": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Regulation (EU) 2017/745 articles/annexes, e.g. \"Art. 10(9)\""
        },
        "other_refs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "device_scope": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "last_reviewed": {
          "type": "string",
          "format": "date"
        },
        "summary": {
          "type": "string"
        },
        "topics": {
          "type": "array",
          "items": {
            "enum": [
              "qms",
              "technical-documentation",
              "clinical",
              "pms-vigilance",
              "software-lifecycle",
              "risk-management",
              "data-protection-security"
            ]
          }
        },
        "formats": {
          "type": "array",
          "items": {
            "enum": [
              "docx",
              "xlsx",
              "md",
              "html"
            ]
          }
        },
        "html_url": {
          "type": "string",
          "format": "uri"
        },
        "md_url": {
          "type": "string",
          "format": "uri",
          "description": "Markdown twin. Full body for free items, metadata and headings only for paid."
        },
        "json_url": {
          "type": "string",
          "format": "uri",
          "description": "This entry as a standalone JSON file."
        },
        "docx_url": {
          "type": "string",
          "format": "uri",
          "description": "Free items only."
        },
        "xlsx_url": {
          "type": "string",
          "format": "uri",
          "description": "Free items only."
        },
        "buy_url": {
          "type": "string",
          "format": "uri",
          "description": "Paid items only: one-time purchase of the item's pack (no subscription)."
        }
      }
    }
  }
}
