{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v3/component_views.schema.json",
  "title": "PublicComponentViewsV3",
  "type": "array",
  "items": {
    "type": "object",
    "allOf": [
      { "$ref": "../v1/common.schema.json#/$defs/recordMetadata" },
      {
        "type": "object",
        "required": [
          "component_view_id",
          "view_version",
          "labels",
          "descriptions",
          "purpose",
          "audience",
          "component_ids",
          "root_component_ids",
          "edges",
          "evidence_summary_ids",
          "source_ids",
          "derivation_method",
          "derivation_version",
          "limitations"
        ],
        "properties": {
          "component_view_id": {
            "type": "string",
            "pattern": "^CV[A-Z0-9_-]{2,62}$"
          },
          "view_version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "labels": {
            "$ref": "../v1/common.schema.json#/$defs/localizedText"
          },
          "descriptions": {
            "$ref": "../v1/common.schema.json#/$defs/localizedText"
          },
          "purpose": {
            "enum": [
              "overview",
              "scientific",
              "software",
              "data",
              "validation",
              "comparative"
            ]
          },
          "audience": {
            "enum": ["new_reader", "researcher", "developer", "expert"]
          },
          "component_ids": { "$ref": "#/$defs/componentIds" },
          "root_component_ids": {
            "allOf": [
              { "$ref": "#/$defs/componentIds" },
              { "type": "array", "minItems": 1 }
            ]
          },
          "edges": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["parent_component_id", "child_component_id"],
              "properties": {
                "parent_component_id": {
                  "type": "string",
                  "pattern": "^CMP[A-Z0-9_-]{1,61}$"
                },
                "child_component_id": {
                  "type": "string",
                  "pattern": "^CMP[A-Z0-9_-]{1,61}$"
                }
              }
            },
            "uniqueItems": true
          },
          "evidence_summary_ids": {
            "$ref": "../v1/common.schema.json#/$defs/evidenceIds"
          },
          "source_ids": {
            "allOf": [
              { "$ref": "../v1/common.schema.json#/$defs/sourceIds" },
              { "type": "array", "minItems": 1 }
            ]
          },
          "derivation_method": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "derivation_version": { "type": "string", "minLength": 1 },
          "limitations": {
            "$ref": "../v1/common.schema.json#/$defs/localizedText"
          }
        }
      }
    ],
    "unevaluatedProperties": false
  },
  "$defs": {
    "componentIds": {
      "type": "array",
      "items": { "type": "string", "pattern": "^CMP[A-Z0-9_-]{1,61}$" },
      "uniqueItems": true
    }
  }
}
