{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v1/works.schema.json",
  "title": "PublicWorks",
  "type": "array",
  "items": {
    "type": "object",
    "allOf": [
      { "$ref": "common.schema.json#/$defs/recordMetadata" },
      {
        "type": "object",
        "required": [
          "work_id",
          "title_original",
          "publication_year",
          "work_type",
          "languages",
          "person_ids",
          "urls",
          "relation_layer",
          "relation_types",
          "relation_confidence",
          "topic_ids",
          "screening_status",
          "relevance_status",
          "body_status",
          "doi_status",
          "access_status",
          "verification_status",
          "source_ids"
        ],
        "properties": {
          "work_id": { "type": "string", "pattern": "^W[A-Z0-9_-]{3,63}$" },
          "title_original": { "type": "string", "minLength": 1 },
          "title_translated_ru": { "type": ["string", "null"] },
          "publication_year": {
            "type": ["integer", "null"],
            "minimum": 1800,
            "maximum": 2200
          },
          "work_type": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
          "languages": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z]{2,3}(?:-[A-Za-z0-9]+)*$"
            },
            "uniqueItems": true
          },
          "person_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^P[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "venue": { "type": ["string", "null"] },
          "volume": { "type": ["string", "null"] },
          "issue": { "type": ["string", "null"] },
          "pages": { "type": ["string", "null"] },
          "doi": { "type": ["string", "null"] },
          "isbn": { "type": ["string", "null"] },
          "urls": {
            "type": "array",
            "items": { "type": "string", "format": "uri" },
            "uniqueItems": true
          },
          "relation_layer": {
            "enum": ["A_CORE", "B_COMPONENT", "C_ECOSYSTEM", "D_CONTEXT"]
          },
          "relation_types": {
            "type": "array",
            "items": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
            "uniqueItems": true
          },
          "relation_confidence": {
            "enum": ["1_indirect", "2_strong", "3_explicit"]
          },
          "topic_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^T[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "crops": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          },
          "locations": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          },
          "screening_status": { "enum": ["included", "needs_expert_review"] },
          "relevance_status": { "enum": ["included", "undetermined"] },
          "body_status": {
            "enum": [
              "local_fulltext_verified",
              "remote_fulltext_verified",
              "partial_or_abstract",
              "metadata_or_citation_only"
            ]
          },
          "doi_status": {
            "enum": ["confirmed", "not_confirmed", "search_boundary"]
          },
          "access_status": {
            "enum": ["accessible", "metadata_only", "search_boundary"]
          },
          "verification_status": {
            "enum": ["body_verified", "metadata_verified", "needs_review"]
          },
          "source_ids": { "$ref": "common.schema.json#/$defs/sourceIds" }
        }
      }
    ],
    "unevaluatedProperties": false
  }
}
