{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hieropedia.org/schemas/hmif-record-1.0.schema.json",
  "type": "object",
  "required": [
    "@context",
    "@type",
    "hmifVersion",
    "recordId",
    "canonicalUrl",
    "name",
    "objectType",
    "status",
    "summary",
    "sourceLanguage",
    "humanEditions",
    "machineEdition",
    "taxonomy",
    "subjectState",
    "asOf",
    "provenanceRelations",
    "sources"
  ],
  "properties": {
    "@context": {
      "const": "https://hieropedia.org/vocab/context.jsonld"
    },
    "@type": {
      "const": "HieropediaRecord"
    },
    "hmifVersion": {
      "const": "1.0"
    },
    "recordId": {
      "type": "string",
      "pattern": "^hp:"
    },
    "canonicalUrl": {
      "type": "string",
      "format": "uri"
    },
    "name": {
      "type": "string"
    },
    "objectType": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "summary": {
      "type": "string"
    },
    "attributes": {
      "type": "array"
    },
    "relations": {
      "type": "array"
    },
    "evidenceStatus": {
      "type": [
        "string",
        "null"
      ]
    },
    "classificationConfidence": {
      "type": [
        "string",
        "null"
      ]
    },
    "classificationRationale": {
      "type": [
        "string",
        "null"
      ]
    },
    "sourceLimitations": {
      "type": [
        "string",
        "null"
      ]
    },
    "articleVersion": {
      "type": [
        "string",
        "null"
      ]
    },
    "publishedOnOrBefore": {
      "type": "string",
      "format": "date"
    },
    "lastRevised": {
      "type": "string",
      "format": "date"
    },
    "lastReviewed": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "sourceLanguage": {
      "const": "en"
    },
    "humanEditions": {
      "type": "array",
      "minItems": 6,
      "maxItems": 6
    },
    "machineEdition": {
      "type": "string",
      "format": "uri"
    },
    "citationMetadata": {
      "type": "string",
      "format": "uri"
    },
    "claimMap": {
      "type": "string",
      "format": "uri"
    },
    "evidenceDossier": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "null"
        }
      ]
    },
    "sourcePreservation": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "null"
        }
      ]
    },
    "editorialDisclosures": {
      "type": "string"
    },
    "sourceProfileNotice": {
      "type": "object"
    },
    "taxonomy": {
      "type": "object"
    },
    "subjectState": {
      "type": "string"
    },
    "asOf": {
      "type": "string",
      "format": "date"
    },
    "provenanceRelations": {
      "type": "array"
    },
    "sources": {
      "type": "array"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "articleHumanEdition": {
      "type": "object",
      "required": [
        "language",
        "url",
        "sourceVersion",
        "translationVersion",
        "revisedOn",
        "state",
        "method",
        "completeness"
      ],
      "properties": {
        "language": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "sourceVersion": {
          "type": "string"
        },
        "translationVersion": {
          "type": "string"
        },
        "revisedOn": {
          "type": "string",
          "format": "date"
        },
        "state": {
          "enum": [
            "source",
            "current",
            "stale",
            "review-needed",
            "missing"
          ]
        },
        "method": {
          "type": "string"
        },
        "completeness": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "stubHumanEdition": {
      "type": "object",
      "required": [
        "language",
        "url"
      ],
      "properties": {
        "language": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "stub"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "articleVersion": {
            "type": "null"
          },
          "lastReviewed": {
            "type": "null"
          },
          "publishedOnOrBefore": false,
          "lastRevised": false,
          "citationMetadata": false,
          "claimMap": false,
          "humanEditions": {
            "items": {
              "$ref": "#/$defs/stubHumanEdition"
            }
          }
        }
      },
      "else": {
        "required": [
          "@context",
          "@type",
          "hmifVersion",
          "recordId",
          "canonicalUrl",
          "name",
          "objectType",
          "status",
          "summary",
          "articleVersion",
          "publishedOnOrBefore",
          "lastReviewed",
          "sourceLanguage",
          "humanEditions",
          "machineEdition",
          "citationMetadata",
          "claimMap",
          "taxonomy",
          "subjectState",
          "asOf",
          "provenanceRelations",
          "sources"
        ],
        "properties": {
          "articleVersion": {
            "type": "string"
          },
          "lastReviewed": {
            "type": "string",
            "format": "date"
          },
          "humanEditions": {
            "items": {
              "$ref": "#/$defs/articleHumanEdition"
            }
          }
        }
      }
    }
  ]
}
