{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v2/graphs.schema.json",
  "title": "PublicGraphProjectionV2",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "graph_projection_id",
    "mode",
    "layers",
    "identity_statuses",
    "period",
    "named_stage_ids",
    "filters",
    "nodes",
    "edges",
    "algorithm_version",
    "input_sha256"
  ],
  "properties": {
    "graph_projection_id": {
      "$ref": "../v1/graphs.schema.json#/properties/graph_projection_id"
    },
    "mode": {
      "$ref": "../v1/graphs.schema.json#/properties/mode"
    },
    "layers": {
      "$ref": "../v1/graphs.schema.json#/properties/layers"
    },
    "identity_statuses": {
      "$ref": "../v1/graphs.schema.json#/properties/identity_statuses"
    },
    "period": {
      "$ref": "../v1/common.schema.json#/$defs/period"
    },
    "named_stage_ids": {
      "type": "array",
      "items": { "type": "string", "pattern": "^HS[A-Z0-9_-]{2,62}$" },
      "uniqueItems": true
    },
    "filters": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "include_peripheral": { "type": "boolean" },
        "group_version_ids": {
          "type": "array",
          "items": { "type": "string", "pattern": "^GV[A-Z0-9_-]{2,62}$" },
          "uniqueItems": true
        },
        "topic_ids": {
          "type": "array",
          "items": { "type": "string", "pattern": "^T[A-Z0-9_-]{3,63}$" },
          "uniqueItems": true
        },
        "organization_ids": {
          "type": "array",
          "items": { "type": "string", "pattern": "^O[A-Z0-9_-]{3,63}$" },
          "uniqueItems": true
        },
        "relation_types": {
          "type": "array",
          "items": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
          "uniqueItems": true
        },
        "work_ids": {
          "type": "array",
          "items": { "type": "string", "pattern": "^W[A-Z0-9_-]{3,63}$" },
          "uniqueItems": true
        }
      }
    },
    "community_analysis": {
      "$ref": "../v1/graphs.schema.json#/properties/community_analysis"
    },
    "nodes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "entity_type",
          "label",
          "position",
          "group_version_ids",
          "historical_stage_ids"
        ],
        "properties": {
          "id": {
            "$ref": "../v1/common.schema.json#/$defs/stableId"
          },
          "entity_type": {
            "enum": [
              "person",
              "work",
              "topic",
              "organization",
              "group",
              "group_version",
              "historical_stage"
            ]
          },
          "label": { "type": "string", "minLength": 1 },
          "position": {
            "type": "object",
            "additionalProperties": false,
            "required": ["x", "y"],
            "properties": {
              "x": { "type": "number" },
              "y": { "type": "number" }
            }
          },
          "group_version_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^GV[A-Z0-9_-]{2,62}$" },
            "uniqueItems": true
          },
          "core_group_version_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^GV[A-Z0-9_-]{2,62}$" },
            "uniqueItems": true
          },
          "peripheral_group_version_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^GV[A-Z0-9_-]{2,62}$" },
            "uniqueItems": true
          },
          "historical_stage_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^HS[A-Z0-9_-]{2,62}$" },
            "uniqueItems": true
          }
        }
      }
    },
    "edges": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "source",
          "target",
          "relation_type",
          "directed",
          "period",
          "work_ids",
          "evidence_summary_ids",
          "source_ids",
          "confidence",
          "status",
          "derivation_method",
          "derivation_version"
        ],
        "properties": {
          "id": { "type": "string", "pattern": "^[A-Z][A-Z0-9_-]{3,63}$" },
          "source": {
            "$ref": "../v1/common.schema.json#/$defs/stableId"
          },
          "target": {
            "$ref": "../v1/common.schema.json#/$defs/stableId"
          },
          "relation_type": {
            "enum": [
              "coauthored_with",
              "authored",
              "supervised_by",
              "academic_descendant_of",
              "worked_on_component",
              "same_project_as",
              "affiliated_with",
              "continued_work_of",
              "related_by_topic",
              "member_of_group_version",
              "version_of_group",
              "active_during_stage"
            ]
          },
          "directed": { "type": "boolean" },
          "weight": { "type": "number" },
          "period": {
            "$ref": "../v1/common.schema.json#/$defs/period"
          },
          "work_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^W[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "evidence_summary_ids": {
            "$ref": "../v1/common.schema.json#/$defs/evidenceIds"
          },
          "source_ids": {
            "$ref": "../v1/common.schema.json#/$defs/sourceIds"
          },
          "confidence": { "enum": ["low", "medium", "high"] },
          "status": { "enum": ["algorithmic", "probable", "confirmed"] },
          "derivation_method": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "derivation_version": { "type": "string", "minLength": 1 }
        }
      }
    },
    "algorithm_version": {
      "$ref": "../v1/graphs.schema.json#/properties/algorithm_version"
    },
    "input_sha256": {
      "$ref": "../v1/graphs.schema.json#/properties/input_sha256"
    }
  }
}
