{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://handl.law/schema/corpus.schema.json",
  "title": "handl.law corpus 2.1",
  "type": "object",
  "required": [
    "schema_version",
    "last_updated",
    "canonical_url",
    "entity",
    "organization",
    "topics",
    "sources",
    "claims",
    "services",
    "work",
    "legacy_routes"
  ],
  "properties": {
    "schema_version": {
      "const": "2.1.0"
    },
    "last_updated": {
      "type": "string",
      "format": "date"
    },
    "canonical_url": {
      "const": "https://handl.law/"
    },
    "entity": {
      "type": "object",
      "required": [
        "id",
        "name",
        "full_professional_name",
        "aliases",
        "same_as",
        "related_resources",
        "canonical_summary",
        "summary_de",
        "portrait"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "full_professional_name": {
          "type": "string",
          "minLength": 1
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "same_as": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
          },
          "uniqueItems": true
        },
        "related_resources": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "relationship",
              "url",
              "source_ids"
            ],
            "properties": {
              "relationship": {
                "type": "string",
                "minLength": 1
              },
              "url": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
              },
              "source_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9-]+$"
                },
                "uniqueItems": true,
                "minItems": 1
              },
              "work_id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9-]+$"
              }
            }
          }
        },
        "canonical_summary": {
          "type": "string",
          "minLength": 1
        },
        "summary_de": {
          "type": "string",
          "minLength": 1
        },
        "portrait": {
          "type": "object",
          "required": [
            "url",
            "source_url",
            "alt"
          ],
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
            },
            "source_url": {
              "type": "string",
              "format": "uri",
              "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
            },
            "alt": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "organization": {
      "type": "object",
      "required": [
        "id",
        "name",
        "url",
        "source_ids",
        "address"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
        },
        "source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "uniqueItems": true,
          "minItems": 1
        },
        "address": {
          "type": "object",
          "required": [
            "street",
            "postal_code",
            "locality",
            "country"
          ],
          "properties": {
            "street": {
              "type": "string",
              "minLength": 1
            },
            "postal_code": {
              "type": "string",
              "minLength": 1
            },
            "locality": {
              "type": "string",
              "minLength": 1
            },
            "country": {
              "const": "AT"
            }
          }
        }
      }
    },
    "topics": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "slug",
          "title",
          "title_de",
          "summary",
          "claim_ids",
          "service_ids",
          "work_tags"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "title_de": {
            "type": "string",
            "minLength": 1
          },
          "summary": {
            "type": "string",
            "minLength": 1
          },
          "claim_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]+$"
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "service_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]+$"
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "work_tags": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1
          }
        }
      }
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "url",
          "title",
          "published_date"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://[^/\\s]+(?:/[^\\s]*)?$"
          },
          "title": {
            "type": "string"
          },
          "published_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "observed_date": {
            "type": "string",
            "format": "date"
          },
          "event_date": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?(?:/\\d{4}-\\d{2}-\\d{2})?$"
          }
        }
      }
    },
    "claims": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "statement",
          "evidence_source_ids"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "statement": {
            "type": "string",
            "minLength": 1
          },
          "evidence_source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]+$"
            },
            "uniqueItems": true,
            "minItems": 1
          }
        }
      }
    },
    "services": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "claim_ids",
          "intent_patterns"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "claim_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]+$"
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "intent_patterns": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1
          }
        }
      }
    },
    "work": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "title",
          "date",
          "status",
          "topics",
          "source_ids",
          "attributes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "kind": {
            "type": "string",
            "minLength": 1
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?(?:/\\d{4}-\\d{2}-\\d{2})?$"
          },
          "status": {
            "enum": [
              "future",
              "current_or_historical",
              "date_unverified"
            ]
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]+$"
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "attributes": {
            "type": "object"
          }
        }
      }
    },
    "legacy_routes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "path",
          "target"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]+$"
          },
          "path": {
            "type": "string",
            "pattern": "^/(?!.*\\.\\.)[a-z0-9/.-]+$"
          },
          "target": {
            "type": "string",
            "pattern": "^https://handl\\.law/"
          }
        }
      }
    }
  }
}
