{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulineletters.com/data/agent/commons/v1/people.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": "people"
    },
    "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",
          "protectedEntityId",
          "aliases",
          "namedVerseKeys",
          "contextualVerseKeys",
          "relatedCommonsIds",
          "kind",
          "identityModel",
          "authorities",
          "referencePartitions",
          "identityClaims",
          "relationshipClaims",
          "placeClaims",
          "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
          },
          "protectedEntityId": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(person|place)\\.[a-z0-9-]+$"
              },
              {
                "type": "null"
              }
            ]
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 0,
            "uniqueItems": true
          },
          "namedVerseKeys": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^(ACT|ROM|1CO|2CO|GAL|EPH|PHI|COL|1TH|2TH|1TI|2TI|TIT|PHM) [1-9][0-9]*:[1-9][0-9]*$"
            }
          },
          "contextualVerseKeys": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^(ACT|ROM|1CO|2CO|GAL|EPH|PHI|COL|1TH|2TH|1TI|2TI|TIT|PHM) [1-9][0-9]*:[1-9][0-9]*$"
            }
          },
          "relatedCommonsIds": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            "minItems": 0,
            "uniqueItems": true
          },
          "kind": {
            "const": "person"
          },
          "identityModel": {
            "enum": [
              "individual",
              "comparison-cluster"
            ]
          },
          "authorities": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "scheme",
                "id",
                "targetKind",
                "receiptId"
              ],
              "properties": {
                "scheme": {
                  "enum": [
                    "wikidata",
                    "pleiades",
                    "trismegistos"
                  ]
                },
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "targetKind": {
                  "enum": [
                    "person"
                  ]
                },
                "receiptId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "referencePartitions": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "document",
                "namedVerseKeys",
                "contextualVerseKeys"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "document": {
                  "enum": [
                    "ACT",
                    "ROM",
                    "1CO",
                    "2CO",
                    "GAL",
                    "EPH",
                    "PHI",
                    "COL",
                    "1TH",
                    "2TH",
                    "1TI",
                    "2TI",
                    "TIT",
                    "PHM"
                  ]
                },
                "namedVerseKeys": {
                  "type": "array",
                  "uniqueItems": true,
                  "items": {
                    "type": "string",
                    "pattern": "^(ACT|ROM|1CO|2CO|GAL|EPH|PHI|COL|1TH|2TH|1TI|2TI|TIT|PHM) [1-9][0-9]*:[1-9][0-9]*$"
                  }
                },
                "contextualVerseKeys": {
                  "type": "array",
                  "uniqueItems": true,
                  "items": {
                    "type": "string",
                    "pattern": "^(ACT|ROM|1CO|2CO|GAL|EPH|PHI|COL|1TH|2TH|1TI|2TI|TIT|PHM) [1-9][0-9]*:[1-9][0-9]*$"
                  }
                }
              }
            },
            "minItems": 1
          },
          "identityClaims": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "claimId",
                "partitionIds"
              ],
              "properties": {
                "claimId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "partitionIds": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                  },
                  "minItems": 2,
                  "uniqueItems": true
                }
              }
            },
            "minItems": 0
          },
          "relationshipClaims": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "targetPersonId",
                "predicate",
                "claimId"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "targetPersonId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "predicate": {
                  "enum": [
                    "parent-of",
                    "sibling-of",
                    "spouse-of",
                    "coworker-of",
                    "host-of",
                    "patron-of",
                    "teacher-of",
                    "proposed-same-person"
                  ]
                },
                "claimId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "placeClaims": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "placeId",
                "claimId"
              ],
              "properties": {
                "placeId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "claimId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "canonicalUrl": {
            "type": "string",
            "format": "uri"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "identityModel": {
                  "const": "comparison-cluster"
                }
              },
              "required": [
                "identityModel"
              ]
            },
            "then": {
              "properties": {
                "authorities": {
                  "type": "array",
                  "maxItems": 0
                },
                "referencePartitions": {
                  "type": "array",
                  "minItems": 2
                },
                "identityClaims": {
                  "type": "array",
                  "minItems": 1
                }
              }
            }
          }
        ]
      },
      "minItems": 1
    }
  }
}
