{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulineletters.com/data/agent/commons/v1/glossary.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schemaVersion",
    "version",
    "dataset",
    "locale",
    "title",
    "description",
    "method",
    "license",
    "attribution",
    "canonicalUrl",
    "scripture",
    "contentDigest",
    "itemCount",
    "items"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "schemaVersion": {
      "const": "1.0"
    },
    "version": {
      "const": "1.0.0"
    },
    "dataset": {
      "const": "glossary"
    },
    "locale": {
      "type": "string",
      "minLength": 1
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "method": {
      "type": "string",
      "minLength": 1
    },
    "license": {
      "type": "string",
      "format": "uri"
    },
    "attribution": {
      "type": "string",
      "minLength": 1
    },
    "canonicalUrl": {
      "type": "string",
      "format": "uri"
    },
    "scripture": {
      "type": "string",
      "minLength": 1
    },
    "contentDigest": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "itemCount": {
      "type": "integer",
      "minimum": 1
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "summary",
          "anchors",
          "claims",
          "alternatives",
          "kind",
          "forms",
          "relatedTermIds",
          "canonicalUrl"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "summary": {
            "type": "string",
            "minLength": 1
          },
          "anchors": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "kind",
                    "reference",
                    "bodyIncluded"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                    },
                    "kind": {
                      "const": "scripture-reference"
                    },
                    "reference": {
                      "type": "string",
                      "minLength": 1
                    },
                    "bodyIncluded": {
                      "const": false
                    }
                  }
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "kind",
                    "source"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                    },
                    "kind": {
                      "const": "source-locator"
                    },
                    "source": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "sourceKey",
                        "work",
                        "locator",
                        "url",
                        "publicDomain",
                        "role"
                      ],
                      "properties": {
                        "sourceKey": {
                          "type": "string",
                          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                        },
                        "work": {
                          "type": "string",
                          "minLength": 1
                        },
                        "locator": {
                          "type": "string",
                          "minLength": 1
                        },
                        "url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "publicDomain": {
                          "type": "boolean"
                        },
                        "role": {
                          "enum": [
                            "primary-text",
                            "catalogue-record",
                            "edition",
                            "early-study"
                          ]
                        },
                        "author": {
                          "type": "string",
                          "minLength": 1
                        },
                        "translator": {
                          "type": "string",
                          "minLength": 1
                        },
                        "year": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  }
                }
              ]
            },
            "minItems": 1
          },
          "claims": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "claimType",
                "epistemicStatus",
                "confidence",
                "supports",
                "qualifies",
                "challenges",
                "alternativeIds",
                "statement",
                "limit"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "claimType": {
                  "enum": [
                    "textual-observation",
                    "historical",
                    "interpretive",
                    "tradition"
                  ]
                },
                "epistemicStatus": {
                  "enum": [
                    "attested",
                    "source-supported",
                    "reconstructed",
                    "tradition",
                    "debated"
                  ]
                },
                "confidence": {
                  "enum": [
                    "high",
                    "medium-high",
                    "medium",
                    "low",
                    "debated"
                  ]
                },
                "supports": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 1,
                  "uniqueItems": true
                },
                "qualifies": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 0,
                  "uniqueItems": true
                },
                "challenges": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 0,
                  "uniqueItems": true
                },
                "alternativeIds": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 0,
                  "uniqueItems": true
                },
                "statement": {
                  "type": "string",
                  "minLength": 1
                },
                "limit": {
                  "type": "string"
                }
              }
            },
            "minItems": 1
          },
          "alternatives": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "supports",
                "qualifies",
                "label",
                "statement"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "supports": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 1,
                  "uniqueItems": true
                },
                "qualifies": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 0,
                  "uniqueItems": true
                },
                "label": {
                  "type": "string",
                  "minLength": 1
                },
                "statement": {
                  "type": "string",
                  "minLength": 1
                }
              }
            },
            "minItems": 0
          },
          "kind": {
            "const": "term"
          },
          "forms": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "text",
                "language",
                "anchorId"
              ],
              "properties": {
                "text": {
                  "type": "string",
                  "minLength": 1
                },
                "language": {
                  "type": "string",
                  "minLength": 1
                },
                "anchorId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "relatedTermIds": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            "minItems": 0,
            "uniqueItems": true
          },
          "canonicalUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "minItems": 1
    }
  }
}
