fix(meta-compile): fix invalid XML properties and improve JSON input flexibility

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 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-02-15 20:42:04 +03:00
co-authored by Claude Opus 4.6
parent 38c0ce11a9
commit e29c184f8e
3 changed files with 38 additions and 12 deletions
@@ -21,9 +21,15 @@ if (-not (Test-Path $JsonPath)) {
$json = Get-Content -Raw -Encoding UTF8 $JsonPath $json = Get-Content -Raw -Encoding UTF8 $JsonPath
$def = $json | ConvertFrom-Json $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) # Object type synonyms (Russian → English)
$script:objectTypeSynonyms = @{ $script:objectTypeSynonyms = @{
"Справочник" = "Catalog" "Справочник" = "Catalog"
"Каталог" = "Catalog"
"Документ" = "Document" "Документ" = "Document"
"Перечисление" = "Enum" "Перечисление" = "Enum"
"Константа" = "Constant" "Константа" = "Constant"
@@ -601,11 +607,15 @@ function Emit-Attribute {
X "$indent`t`t<MinValue xsi:nil=`"true`"/>" X "$indent`t`t<MinValue xsi:nil=`"true`"/>"
X "$indent`t`t<MaxValue xsi:nil=`"true`"/>" X "$indent`t`t<MaxValue xsi:nil=`"true`"/>"
# FillFromFillingValue # FillFromFillingValue — not for tabular section attributes
X "$indent`t`t<FillFromFillingValue>false</FillFromFillingValue>" if ($context -ne "tabular") {
X "$indent`t`t<FillFromFillingValue>false</FillFromFillingValue>"
}
# FillValue # FillValue — not for tabular section attributes
Emit-FillValue "$indent`t`t" $typeStr if ($context -ne "tabular") {
Emit-FillValue "$indent`t`t" $typeStr
}
# FillChecking # FillChecking
$fillChecking = "DontCheck" $fillChecking = "DontCheck"
@@ -672,8 +682,8 @@ function Emit-TabularSection {
X "$indent`t`t<ToolTip/>" X "$indent`t`t<ToolTip/>"
X "$indent`t`t<FillChecking>DontCheck</FillChecking>" X "$indent`t`t<FillChecking>DontCheck</FillChecking>"
Emit-TabularStandardAttributes "$indent`t`t" Emit-TabularStandardAttributes "$indent`t`t"
# Use=ForItem only for Catalog/Document # Use=ForItem only for Catalog tabular sections (Document does not have Use)
if ($objectType -in @("Catalog","Document")) { if ($objectType -eq "Catalog") {
X "$indent`t`t<Use>ForItem</Use>" X "$indent`t`t<Use>ForItem</Use>"
} }
X "$indent`t</Properties>" X "$indent`t</Properties>"
@@ -2400,10 +2410,19 @@ if ($objType -in $typesWithAttrTS) {
$attrs += Parse-AttributeShorthand $a $attrs += Parse-AttributeShorthand $a
} }
} }
$tsSections = @{} $tsSections = [ordered]@{}
if ($def.tabularSections) { if ($def.tabularSections) {
$def.tabularSections.PSObject.Properties | ForEach-Object { # Normalize array format: [{name:"X", attributes:[...]}, ...] → {"X": [...]}
$tsSections[$_.Name] = @($_.Value) 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 $colCount = 0
if ($def.attributes) { $attrCount = @($def.attributes).Count } 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.dimensions) { $dimCount = @($def.dimensions).Count }
if ($def.resources) { $resCount = @($def.resources).Count } if ($def.resources) { $resCount = @($def.resources).Count }
if ($def.values) { $valCount = @($def.values).Count } if ($def.values) { $valCount = @($def.values).Count }
+2 -1
View File
@@ -748,7 +748,8 @@ Ext/ # Расширение конфигураци
</Properties> </Properties>
<ChildObjects> <ChildObjects>
<Attribute uuid="..."> <Attribute uuid="...">
<!-- Реквизиты-колонки таблицы, формат как у обычных реквизитов --> <!-- Реквизиты-колонки таблицы: формат как у обычных реквизитов,
но без FillFromFillingValue, FillValue, Use -->
</Attribute> </Attribute>
</ChildObjects> </ChildObjects>
</TabularSection> </TabularSection>
+1 -1
View File
@@ -167,7 +167,7 @@ JSON DSL для описания объектов метаданных конф
Ключ — имя табличной части, значение — массив реквизитов (в строковой или объектной форме). Ключ — имя табличной части, значение — массив реквизитов (в строковой или объектной форме).
Для Catalog и Document добавляется `<Use>ForItem</Use>` в Properties табличной части. Для Catalog добавляется `<Use>ForItem</Use>` в Properties табличной части. Для Document Use не применяется.
--- ---