{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://local.llm.platform/schemas/1c-bsl-module-snapshot.schema.json",
  "title": "1C BSL Module Snapshot",
  "type": "object",
  "required": ["schema_version", "source", "created_at", "modules"],
  "properties": {
    "schema_version": { "type": "integer", "const": 1 },
    "source": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "environment": { "type": "string" },
        "configuration_name": { "type": "string" },
        "configuration_version": { "type": "string" }
      },
      "additionalProperties": true
    },
    "created_at": { "type": "string" },
    "modules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["module_id", "object_name", "module_type", "content"],
        "properties": {
          "module_id": { "type": "string" },
          "object_kind": { "type": "string" },
          "object_name": { "type": "string" },
          "module_type": { "type": "string" },
          "content": { "type": "string" },
          "content_hash": { "type": "string" },
          "procedures": {
            "type": "array",
            "items": { "$ref": "#/$defs/routine" }
          },
          "functions": {
            "type": "array",
            "items": { "$ref": "#/$defs/routine" }
          },
          "references": {
            "type": "array",
            "items": { "type": "string" }
          }
        },
        "additionalProperties": true
      }
    }
  },
  "$defs": {
    "routine": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "export": { "type": "boolean" },
        "line": { "type": "integer" },
        "params": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
