{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://local.llm.platform/schemas/1c-metadata-snapshot.schema.json",
  "title": "1C Metadata Snapshot",
  "type": "object",
  "required": ["schema_version", "source", "created_at", "objects"],
  "properties": {
    "schema_version": {
      "type": "integer",
      "const": 1
    },
    "source": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "environment": { "type": "string" },
        "notes": { "type": "string" }
      },
      "additionalProperties": true
    },
    "created_at": {
      "type": "string"
    },
    "objects": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["kind", "name"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["catalog", "document", "register", "common_module", "enum", "report", "processing", "other"]
          },
          "name": { "type": "string" },
          "synonym": { "type": "string" },
          "description": { "type": "string" },
          "attributes": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": { "type": "string" },
                "type": { "type": "string" },
                "synonym": { "type": "string" },
                "description": { "type": "string" }
              },
              "additionalProperties": true
            }
          },
          "tabular_sections": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": { "type": "string" },
                "synonym": { "type": "string" },
                "attributes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": ["name"],
                    "properties": {
                      "name": { "type": "string" },
                      "type": { "type": "string" },
                      "synonym": { "type": "string" }
                    },
                    "additionalProperties": true
                  }
                }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      }
    },
    "access": {
      "type": "object",
      "description": "Optional normalized access-rights snapshot for users, access groups, profiles, roles, permissions, and data restrictions.",
      "properties": {
        "users": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
        "groups": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
        "profiles": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
        "roles": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
        "data_restrictions": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
        "assignments": { "type": "array", "items": { "type": "object", "additionalProperties": true } }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
