{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://local.llm.platform/schemas/1c-metadata-snapshot-v2.schema.json",
  "title": "1C Metadata Snapshot v2",
  "type": "object",
  "required": ["schema_version", "source", "created_at", "objects"],
  "properties": {
    "schema_version": { "type": "integer", "const": 2 },
    "source": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "environment": { "type": "string" },
        "configuration_name": { "type": "string" },
        "configuration_version": { "type": "string" },
        "platform_version": { "type": "string" },
        "notes": { "type": "string" }
      },
      "additionalProperties": true
    },
    "created_at": { "type": "string" },
    "objects": {
      "type": "array",
      "items": { "$ref": "#/$defs/metadataObject" }
    }
  },
  "$defs": {
    "metadataObject": {
      "type": "object",
      "required": ["kind", "name"],
      "properties": {
        "kind": {
          "type": "string",
          "enum": ["catalog", "document", "register", "common_module", "enum", "report", "processing", "role", "form", "other"]
        },
        "name": { "type": "string" },
        "full_name": { "type": "string" },
        "synonym": { "type": "string" },
        "description": { "type": "string" },
        "attributes": {
          "type": "array",
          "items": { "$ref": "#/$defs/field" }
        },
        "tabular_sections": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name"],
            "properties": {
              "name": { "type": "string" },
              "synonym": { "type": "string" },
              "attributes": {
                "type": "array",
                "items": { "$ref": "#/$defs/field" }
              }
            },
            "additionalProperties": true
          }
        },
        "forms": {
          "type": "array",
          "items": { "$ref": "#/$defs/namedRef" }
        },
        "commands": {
          "type": "array",
          "items": { "$ref": "#/$defs/namedRef" }
        },
        "modules": {
          "type": "array",
          "items": { "$ref": "#/$defs/moduleRef" }
        }
      },
      "additionalProperties": true
    },
    "field": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "type": { "type": "string" },
        "synonym": { "type": "string" },
        "description": { "type": "string" },
        "required": { "type": "boolean" },
        "indexed": { "type": "boolean" }
      },
      "additionalProperties": true
    },
    "namedRef": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "synonym": { "type": "string" }
      },
      "additionalProperties": true
    },
    "moduleRef": {
      "type": "object",
      "required": ["module_id", "module_type"],
      "properties": {
        "module_id": { "type": "string" },
        "module_type": { "type": "string" },
        "name": { "type": "string" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
