{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulineletters.com/data/agent/commons/v1/places.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schemaVersion",
    "version",
    "dataset",
    "locale",
    "title",
    "description",
    "method",
    "license",
    "attribution",
    "canonicalUrl",
    "scripture",
    "rights",
    "contentDigest",
    "itemCount",
    "items"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "schemaVersion": {
      "const": "1.0"
    },
    "version": {
      "const": "1.0.0"
    },
    "dataset": {
      "const": "places"
    },
    "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
    },
    "rights": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "projectLicenseScope",
        "upstream",
        "coordinateChanges",
        "components"
      ],
      "properties": {
        "projectLicenseScope": {
          "const": "project-owned-editorial-and-compilation-only"
        },
        "upstream": {
          "const": {
            "attributionPolicyUrl": "https://pleiades.stoa.org/help/how-to-cite-pleiades",
            "copyrightNotices": {
              "contributors": "Copyright © The Contributors. Sharing and remixing permitted under terms of the Creative Commons Attribution 3.0 License (cc-by).",
              "creators": "Copyright © The Creators. Sharing and remixing permitted under terms of the Creative Commons Attribution 3.0 License (cc-by)."
            },
            "licenseId": "CC-BY-3.0-US",
            "licenseUrl": "https://creativecommons.org/licenses/by/3.0/us/",
            "name": "Pleiades gazetteer of ancient places",
            "sourceKey": "pleiades",
            "url": "https://pleiades.stoa.org/"
          }
        },
        "coordinateChanges": {
          "const": "Selected representative points and named their latitude/longitude fields; numeric coordinate values are unchanged. Precision/basis labels and project prose are separately authored by Pauline Letters."
        },
        "components": {
          "type": "array",
          "maxItems": 160,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "subjectId",
              "sourceAnchorId",
              "url",
              "title",
              "creators",
              "contributors",
              "copyrightNotice",
              "use",
              "scopes"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^pleiades-[1-9][0-9]*$"
              },
              "subjectId": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "sourceAnchorId": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "url": {
                "type": "string",
                "pattern": "^https://pleiades\\.stoa\\.org/places/[1-9][0-9]*$"
              },
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              "creators": {
                "type": "array",
                "minItems": 1,
                "maxItems": 128,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 320
                }
              },
              "contributors": {
                "type": "array",
                "maxItems": 128,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 320
                }
              },
              "copyrightNotice": {
                "enum": [
                  "creators",
                  "contributors"
                ]
              },
              "use": {
                "enum": [
                  "representative-point-and-source-metadata",
                  "source-metadata-only"
                ]
              },
              "scopes": {
                "type": "array",
                "minItems": 1,
                "maxItems": 19,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "pattern": "^/items/[0-9]+/(anchors/[0-9]+/source|geometry/(latitude|longitude)|authorities/[0-9]+/id)$"
                }
              }
            }
          }
        }
      }
    },
    "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",
          "placeKind",
          "authorities",
          "chronologyPlaceId",
          "geometry",
          "presenceClaims",
          "linkedLetterIds",
          "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": "place"
          },
          "placeKind": {
            "enum": [
              "city",
              "region",
              "province",
              "island",
              "water",
              "site"
            ]
          },
          "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": [
                    "city",
                    "region",
                    "province",
                    "island",
                    "water",
                    "site"
                  ]
                },
                "receiptId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "chronologyPlaceId": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              {
                "type": "null"
              }
            ]
          },
          "geometry": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "latitude",
                  "longitude",
                  "precision",
                  "basisAnchorIds"
                ],
                "properties": {
                  "latitude": {
                    "type": "number",
                    "minimum": -90,
                    "maximum": 90
                  },
                  "longitude": {
                    "type": "number",
                    "minimum": -180,
                    "maximum": 180
                  },
                  "precision": {
                    "enum": [
                      "site",
                      "settlement",
                      "regional-representative",
                      "disputed"
                    ]
                  },
                  "basisAnchorIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                    },
                    "minItems": 1,
                    "uniqueItems": true
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "presenceClaims": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "personId",
                "relation",
                "claimId"
              ],
              "properties": {
                "personId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                },
                "relation": {
                  "enum": [
                    "mentioned",
                    "intended",
                    "visited-as-reported",
                    "reconstructed"
                  ]
                },
                "claimId": {
                  "type": "string",
                  "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                }
              }
            },
            "minItems": 0
          },
          "linkedLetterIds": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            "minItems": 0,
            "uniqueItems": true
          },
          "canonicalUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "minItems": 1
    }
  }
}
