From e29c184f8e7eae977e7f41f1cde5e87c6832dba3 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 15 Feb 2026 20:42:04 +0300 Subject: [PATCH] fix(meta-compile): fix invalid XML properties and improve JSON input flexibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A) XML bugs: skip FillFromFillingValue/FillValue for tabular attributes, emit Use=ForItem only for Catalog tabular sections (not Document). B) JSON input: accept "objectType" as alias for "type", normalize array-format tabularSections, add "Каталог" synonym for "Catalog". C) Update specs to match corrected behavior. Co-Authored-By: Claude Opus 4.6 --- .../meta-compile/scripts/meta-compile.ps1 | 45 ++++++++++++++----- docs/1c-config-objects-spec.md | 3 +- docs/meta-dsl-spec.md | 2 +- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.claude/skills/meta-compile/scripts/meta-compile.ps1 b/.claude/skills/meta-compile/scripts/meta-compile.ps1 index daabf518..ca8f5ac0 100644 --- a/.claude/skills/meta-compile/scripts/meta-compile.ps1 +++ b/.claude/skills/meta-compile/scripts/meta-compile.ps1 @@ -21,9 +21,15 @@ if (-not (Test-Path $JsonPath)) { $json = Get-Content -Raw -Encoding UTF8 $JsonPath $def = $json | ConvertFrom-Json +# Normalize field synonyms: accept "objectType" as alias for "type" +if (-not $def.type -and $def.objectType) { + $def | Add-Member -NotePropertyName "type" -NotePropertyValue $def.objectType +} + # Object type synonyms (Russian → English) $script:objectTypeSynonyms = @{ "Справочник" = "Catalog" + "Каталог" = "Catalog" "Документ" = "Document" "Перечисление" = "Enum" "Константа" = "Constant" @@ -601,11 +607,15 @@ function Emit-Attribute { X "$indent`t`t" X "$indent`t`t" - # FillFromFillingValue - X "$indent`t`tfalse" + # FillFromFillingValue — not for tabular section attributes + if ($context -ne "tabular") { + X "$indent`t`tfalse" + } - # FillValue - Emit-FillValue "$indent`t`t" $typeStr + # FillValue — not for tabular section attributes + if ($context -ne "tabular") { + Emit-FillValue "$indent`t`t" $typeStr + } # FillChecking $fillChecking = "DontCheck" @@ -672,8 +682,8 @@ function Emit-TabularSection { X "$indent`t`t" X "$indent`t`tDontCheck" Emit-TabularStandardAttributes "$indent`t`t" - # Use=ForItem only for Catalog/Document - if ($objectType -in @("Catalog","Document")) { + # Use=ForItem only for Catalog tabular sections (Document does not have Use) + if ($objectType -eq "Catalog") { X "$indent`t`tForItem" } X "$indent`t" @@ -2400,10 +2410,19 @@ if ($objType -in $typesWithAttrTS) { $attrs += Parse-AttributeShorthand $a } } - $tsSections = @{} + $tsSections = [ordered]@{} if ($def.tabularSections) { - $def.tabularSections.PSObject.Properties | ForEach-Object { - $tsSections[$_.Name] = @($_.Value) + # Normalize array format: [{name:"X", attributes:[...]}, ...] → {"X": [...]} + if ($def.tabularSections -is [array] -or $def.tabularSections.GetType().Name -eq "Object[]") { + foreach ($ts in $def.tabularSections) { + $tsName = $ts.name + $tsCols = if ($ts.attributes) { @($ts.attributes) } else { @() } + $tsSections[$tsName] = $tsCols + } + } else { + $def.tabularSections.PSObject.Properties | ForEach-Object { + $tsSections[$_.Name] = @($_.Value) + } } } @@ -2764,7 +2783,13 @@ $valCount = 0 $colCount = 0 if ($def.attributes) { $attrCount = @($def.attributes).Count } -if ($def.tabularSections) { $tsCount = @($def.tabularSections.PSObject.Properties).Count } +if ($def.tabularSections) { + if ($def.tabularSections -is [array] -or $def.tabularSections.GetType().Name -eq "Object[]") { + $tsCount = @($def.tabularSections).Count + } else { + $tsCount = @($def.tabularSections.PSObject.Properties).Count + } +} if ($def.dimensions) { $dimCount = @($def.dimensions).Count } if ($def.resources) { $resCount = @($def.resources).Count } if ($def.values) { $valCount = @($def.values).Count } diff --git a/docs/1c-config-objects-spec.md b/docs/1c-config-objects-spec.md index ece3c3a1..cb33d19c 100644 --- a/docs/1c-config-objects-spec.md +++ b/docs/1c-config-objects-spec.md @@ -748,7 +748,8 @@ Ext/ # Расширение конфигураци - + diff --git a/docs/meta-dsl-spec.md b/docs/meta-dsl-spec.md index 9cac2986..a5792a15 100644 --- a/docs/meta-dsl-spec.md +++ b/docs/meta-dsl-spec.md @@ -167,7 +167,7 @@ JSON DSL для описания объектов метаданных конф Ключ — имя табличной части, значение — массив реквизитов (в строковой или объектной форме). -Для Catalog и Document добавляется `ForItem` в Properties табличной части. +Для Catalog добавляется `ForItem` в Properties табличной части. Для Document Use не применяется. ---