{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "IACPaaS target IR universal JSON representation schema",
  "description": "JSON Schema for target information resources of IACPaaS platform, universal format",

  "$defs" : {
    "successor": {
      "type": "object",
      "properties": {
          "name": {
            "type": "string",
            "description": "name of vertex (if it has ROOT or NONTERNIMAL or TERMINAL-SORT type",
            "examples": [
              "Наблюдения", "Признаки", "События"
            ]
          },
          "value": {
            "type": ["string", "integer", "boolean"],
            "description": "stringed representation of the vertex value",
            "examples": [
              "Наблюдения", "100", "-1.0", "true", "09.10.2024-14:11:17.592", "aacb042f"
            ]
          },
          
          "type": {
            "type": "string",
            "description": "type of the vertex, one of 4 possible values - see 'enum'",
            "enum": ["КОРЕНЬ", "НЕТЕРМИНАЛ", "ТЕРМИНАЛ-СОРТ", "ТЕРМИНАЛ-ЗНАЧЕНИЕ"]
          },
          "valtype": {
            "type": "string",
            "description": "type of the value of the vertex, one of 6 possible values - see 'enum'",
            "enum": ["STRING", "INTEGER", "REAL", "BOOLEAN", "DATE", "BLOB"]
          },
          "meta": {
            "type": "string",
            "description": "name of value of the meta vertex which corresponds to the current vertex",
            "examples": [
              "Структура решателя задач"
            ]
          },
            
          "original": {
            "type": "string",
            "description": "path to the original vertex within 'My fund' of the user and the information resource which holds that vertex; must have '$' as a delimiter between them and ';' at the end",
            "examples": [
              "user@domain.com / Мой Фонд / База наблюдений$ / События;"
            ]
          },
          "link": {
            "type": "string",
            "description": "path to the linked vertex within 'My fund' of the user and the information resource which holds that vertex; must have '$' as a delimiter between them and ';' at the end",
            "examples": [
              "user@domain.com / Мой Фонд / База наблюдений$ / Наблюдения;"
            ]
          },    
          "comment": {
            "type": "string",
            "description": "comment fore concept",
            "examples": [
              "Программный инструмент для задания информационно-управляющих графов решателей задач"
            ]
          },
            
          "rcomment": {
            "type": "string",
            "description": "comment for incoming relation from parent-concept to this concept",
            "examples": [
              "Программный инструмент для задания информационно-управляющих графов решателей задач"
            ]
          },
          "successors": {
            "type": "array",
            "description": "descr for direct successors of the vertex",
            "items": { "$ref" : "#/$defs/successor" }
          }
        },
      "oneOf": [
          {
            "required": ["type", "meta", "name"]
          },
          {
            "required": ["type", "meta", "value"]
          }
      ],
      "additionalProperties": false
    }
  },

  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "name of information resource (same as name of root vertex)",
      "examples": [
        "База знаний"
      ]
    },
    "code": {
      "type": "string",
      "description": "could be a 64-bit unsigned integer but currently it's a String",
      "examples": [
        "9876543210987654321"
      ]
    },
    "path": {
      "type": "string",
      "description": "path to information resource within 'My fund' of the user; must have '$;' at the end",
      "examples": [
        "user@domain.com / Мой Фонд / База знаний$;"
      ]
    },
    "date": {
      "type": "string",
      "description": "date and time of recent changes; could be in date-time format but currently its a string",
      "examples": [
        "09.10.2024-14:11:17.592"
      ]
    },
    "creation": {
      "type": "string",
      "description": "date and time of resource creation; could be in date-time format but currently its a string",
      "examples": [
        "19.01.1970-16:11:52.660"
      ]
    },
    "owner_id": {
      "type": "integer",
      "description": "id of the creator, used within the platform user database",
      "examples": [
        7
      ]
    },
    "json_type": {
      "type": "string",
      "enum": ["universal", "meta", "simple"],
      "examples": [
        "universal"
      ]
    },
    "ontology": {
      "type": "string",
      "description": "path to information resource ontology within 'My fund' of the user or common fund; must have '$;' at the end",
      "examples": [
        "user@domain.com / Мой Фонд / Структура базы знаний$;"
      ]
    },
    
    "name": {
      "type": "string",
      "description": "name of vertex (if it has ROOT or NONTERNIMAL or TERMINAL-SORT type",
      "examples": [
        "Наблюдения", "Признаки", "События"
      ]
    },
    "value": {
      "type": ["string", "integer", "boolean"],
      "description": "stringed representation of the vertex value",
      "examples": [
        "Наблюдения", "100", "-1.0", "true", "09.10.2024-14:11:17.592", "aacb042f"
      ]
    },
    
    "type": {
      "type": "string",
      "description": "type of the vertex, one of 4 possible values - see 'enum'",
      "enum": ["КОРЕНЬ", "НЕТЕРМИНАЛ", "ТЕРМИНАЛ-СОРТ", "ТЕРМИНАЛ-ЗНАЧЕНИЕ"],
      "examples": [
        "КОРЕНЬ"
      ]
    },
    "meta": {
      "type": "string",
      "description": "name of value of the meta vertex which corresponds to the current vertex",
      "examples": [
        "Структура решателя задач"
      ]
    },
    
    "original": {
      "type": "string",
      "description": "path to the original vertex within 'My fund' of the user and the information resource which holds that vertex; must have '$' as a delimiter between them and ';' at the end",
      "examples": [
        "user@domain.com / Мой Фонд / База наблюдений$ / События;"
      ]
    },
    "link": {
      "type": "string",
      "description": "path to the linked vertex within 'My fund' of the user and the information resource which holds that vertex; must have '$' as a delimiter between them and ';' at the end",
      "examples": [
        "user@domain.com / Мой Фонд / База наблюдений$ / Наблюдения;"
      ]
    },

    "comment": {
      "type": "string",
      "description": "comment fore concept",
      "examples": [
        "Программный инструмент для задания информационно-управляющих графов решателей задач"
      ]
    },
    "rcomment": {
      "type": "string",
      "description": "comment for incoming relation from parent-concept to this concept",
      "examples": [
        "Программный инструмент для задания информационно-управляющих графов решателей задач"
      ]
    },
    
    "successors": {
      "type": "array",
      "items": { "$ref" : "#/$defs/successor" }
    }
  },
  "oneOf": [
    {
      "required": ["title", "path", "json_type", "ontology", "type", "name", "meta"]
    },
    {
      "required": ["title", "path", "json_type", "ontology", "type", "value", "meta"]
    }
  ],
  "additionalProperties": false
}
