{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://digitalrocketads.com/sources/claim-registry.schema.json",
  "title": "Digital Rocket material claim registry",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "registry", "claims"],
  "properties": {
    "schema": { "const": "https://digitalrocketads.com/sources/claim-registry.schema.json" },
    "registry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "url", "version", "last_reviewed", "owner", "review_policy"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "url": { "const": "https://digitalrocketads.com/sources/claim-registry.json" },
        "version": { "type": "integer", "minimum": 1 },
        "last_reviewed": { "type": "string", "format": "date" },
        "owner": { "type": "string", "minLength": 1 },
        "review_policy": { "type": "string", "minLength": 1 }
      }
    },
    "claims": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/claim" }
    }
  },
  "$defs": {
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claim_id",
        "route",
        "file",
        "proposition",
        "status",
        "source_ids",
        "proof_ids",
        "jurisdiction",
        "visible_text_fingerprint",
        "citation_mode",
        "reviewer",
        "reviewed_on",
        "expires_on"
      ],
      "properties": {
        "claim_id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
        "route": { "type": "string", "pattern": "^/(?:.*/)?$" },
        "file": { "type": "string", "pattern": "(?:^|/)index\\.html$" },
        "proposition": { "type": "string", "minLength": 12 },
        "status": {
          "enum": ["official_primary", "approved_first_party", "dr_definition", "hypothetical", "opinion", "removed", "blocked"]
        },
        "source_ids": {
          "type": "array",
          "uniqueItems": true,
          "items": { "type": "string", "pattern": "^[MGFAUB]-[1-9][0-9]*$" }
        },
        "proof_ids": {
          "type": "array",
          "uniqueItems": true,
          "items": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" }
        },
        "jurisdiction": { "enum": ["GLOBAL", "US", "AU", "NZ", "GB", "CA", "MULTI"] },
        "visible_text_fingerprint": { "type": "string", "minLength": 8 },
        "citation_mode": { "enum": ["visible_and_schema", "proof_registry", "definition_owner", "none_until_published"] },
        "reviewer": { "type": "string", "minLength": 1 },
        "reviewed_on": { "type": "string", "format": "date" },
        "expires_on": {
          "anyOf": [
            { "type": "string", "format": "date" },
            { "type": "null" }
          ]
        }
      },
      "allOf": [
        {
          "if": { "properties": { "status": { "const": "official_primary" } }, "required": ["status"] },
          "then": {
            "properties": {
              "source_ids": { "type": "array", "minItems": 1 },
              "citation_mode": { "const": "visible_and_schema" }
            }
          }
        },
        {
          "if": { "properties": { "status": { "const": "approved_first_party" } }, "required": ["status"] },
          "then": {
            "properties": {
              "proof_ids": { "type": "array", "minItems": 1 },
              "citation_mode": { "const": "proof_registry" }
            }
          }
        }
      ]
    }
  }
}
