{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://unpkg.com/context-room@latest/schemas/document-metadata-profile.schema.json",
  "title": "Context Room metadata profile",
  "type": "object",
  "required": ["schemaVersion", "id", "version", "match"],
  "properties": {
    "schemaVersion": { "const": "context-room.metadata-profile/1" },
    "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9.-]*$" },
    "version": { "type": "string", "minLength": 1 },
    "match": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
    "identity": {
      "type": "object",
      "required": ["path"],
      "properties": { "path": { "type": "string", "minLength": 1 } },
      "additionalProperties": false
    },
    "relations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["path", "type", "label", "reverseLabel"],
        "properties": {
          "path": { "type": "string", "minLength": 1 },
          "type": { "type": "string", "minLength": 1 },
          "label": { "type": "string", "minLength": 1 },
          "reverseLabel": { "type": "string", "minLength": 1 },
          "strength": { "enum": ["declared", "reference"] }
        },
        "additionalProperties": false
      }
    },
    "display": { "type": "object" },
    "schema": {
      "type": "object",
      "properties": {
        "path": { "type": "string" },
        "url": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
      },
      "anyOf": [
        { "required": ["path"] },
        { "required": ["url", "sha256"] }
      ],
      "additionalProperties": false
    },
    "lintRules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "path", "operator", "message"],
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "path": { "type": "string", "minLength": 1 },
          "operator": { "enum": ["required", "equals", "one-of", "matches"] },
          "value": {},
          "values": { "type": "array" },
          "pattern": { "type": "string" },
          "severity": { "enum": ["low", "medium", "high", "critical", "warning", "error"] },
          "message": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
