mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-11 08:24:57 +03:00
feat(skd): nested folder + nestedObject + groupItem object form (round-trip)
Закрывает категорию B полностью на ERP-корпусе:
- selection.folder теперь рекурсивный: внутри items могут быть string,
{field, title}, или ещё одна {folder, items: [...]}. Compile/decompile
обходят дерево рекурсивно (Emit-SelectionItem / Build-SelectionItem).
- structure: новая ветка type=nestedObject с {objectID, settings:
{selection, filter, order, conditionalAppearance, outputParameters}}.
- groupFields теперь объектная форма {field, groupType?, periodAdditionType?}
когда не дефолт (Items / None). Compile уже принимал; decompile перестаёт
ставить warning GroupItemDetails. Try-StructureShorthand игнорирует
object-form поля при сворачивании в строку.
- Refactor: Build-Structure для StructureItemGroup теперь использует
общий Get-GroupFields вместо дублированного inline-кода.
В SKILL.md не добавляем (формы редкие/сложные, модель не пишет с нуля).
Новый тест structure-nested-and-folder покрывает все три случая bit-perfect.
Versions: compile v1.30→v1.31, decompile v0.12→v0.13.
На сэмпле 30 ERP-отчётов: 754 → 32 sentinel'ов (-96%), clean 4 → 24/30.
Остаточные 32 — все TemplateStyleMismatch (категория C, диагностика).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.30 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.31 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1787,6 +1787,51 @@ function Emit-GroupTemplates {
|
||||
|
||||
# === Settings Variants ===
|
||||
|
||||
function Emit-SelectionItem {
|
||||
param($item, [string]$indent)
|
||||
if ($item -is [string]) {
|
||||
if ($item -eq "Auto") {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:SelectedItemAuto`"/>"
|
||||
} else {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:SelectedItemField`">"
|
||||
X "$indent`t<dcsset:field>$(Esc-Xml $item)</dcsset:field>"
|
||||
X "$indent</dcsset:item>"
|
||||
}
|
||||
return
|
||||
}
|
||||
if ($item.folder -or (Has-JsonProp $item 'folder')) {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:SelectedItemFolder`">"
|
||||
# Optional <dcsset:field> на folder (редкий случай, для round-trip-целостности)
|
||||
if ($item.field) {
|
||||
X "$indent`t<dcsset:field>$(Esc-Xml "$($item.field)")</dcsset:field>"
|
||||
}
|
||||
X "$indent`t<dcsset:lwsTitle>"
|
||||
X "$indent`t`t<v8:item>"
|
||||
X "$indent`t`t`t<v8:lang>ru</v8:lang>"
|
||||
X "$indent`t`t`t<v8:content>$(Esc-Xml "$($item.folder)")</v8:content>"
|
||||
X "$indent`t`t</v8:item>"
|
||||
X "$indent`t</dcsset:lwsTitle>"
|
||||
foreach ($sub in $item.items) {
|
||||
Emit-SelectionItem -item $sub -indent "$indent`t"
|
||||
}
|
||||
X "$indent`t<dcsset:placement>Auto</dcsset:placement>"
|
||||
X "$indent</dcsset:item>"
|
||||
return
|
||||
}
|
||||
# field with optional title
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:SelectedItemField`">"
|
||||
X "$indent`t<dcsset:field>$(Esc-Xml "$($item.field)")</dcsset:field>"
|
||||
if ($item.title) {
|
||||
X "$indent`t<dcsset:lwsTitle>"
|
||||
X "$indent`t`t<v8:item>"
|
||||
X "$indent`t`t`t<v8:lang>ru</v8:lang>"
|
||||
X "$indent`t`t`t<v8:content>$(Esc-Xml "$($item.title)")</v8:content>"
|
||||
X "$indent`t`t</v8:item>"
|
||||
X "$indent`t</dcsset:lwsTitle>"
|
||||
}
|
||||
X "$indent</dcsset:item>"
|
||||
}
|
||||
|
||||
function Emit-Selection {
|
||||
param($items, [string]$indent, [switch]$skipAuto)
|
||||
|
||||
@@ -1794,45 +1839,8 @@ function Emit-Selection {
|
||||
|
||||
X "$indent<dcsset:selection>"
|
||||
foreach ($item in $items) {
|
||||
if ($item -is [string]) {
|
||||
if ($item -eq "Auto") {
|
||||
if (-not $skipAuto) {
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:SelectedItemAuto`"/>"
|
||||
}
|
||||
} else {
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:SelectedItemField`">"
|
||||
X "$indent`t`t<dcsset:field>$(Esc-Xml $item)</dcsset:field>"
|
||||
X "$indent`t</dcsset:item>"
|
||||
}
|
||||
} elseif ($item.folder) {
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:SelectedItemFolder`">"
|
||||
X "$indent`t`t<dcsset:lwsTitle>"
|
||||
X "$indent`t`t`t<v8:item>"
|
||||
X "$indent`t`t`t`t<v8:lang>ru</v8:lang>"
|
||||
X "$indent`t`t`t`t<v8:content>$(Esc-Xml "$($item.folder)")</v8:content>"
|
||||
X "$indent`t`t`t</v8:item>"
|
||||
X "$indent`t`t</dcsset:lwsTitle>"
|
||||
foreach ($sub in $item.items) {
|
||||
$subName = if ($sub -is [string]) { $sub } else { "$($sub.field)" }
|
||||
X "$indent`t`t<dcsset:item xsi:type=`"dcsset:SelectedItemField`">"
|
||||
X "$indent`t`t`t<dcsset:field>$(Esc-Xml $subName)</dcsset:field>"
|
||||
X "$indent`t`t</dcsset:item>"
|
||||
}
|
||||
X "$indent`t`t<dcsset:placement>Auto</dcsset:placement>"
|
||||
X "$indent`t</dcsset:item>"
|
||||
} else {
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:SelectedItemField`">"
|
||||
X "$indent`t`t<dcsset:field>$(Esc-Xml "$($item.field)")</dcsset:field>"
|
||||
if ($item.title) {
|
||||
X "$indent`t`t<dcsset:lwsTitle>"
|
||||
X "$indent`t`t`t<v8:item>"
|
||||
X "$indent`t`t`t`t<v8:lang>ru</v8:lang>"
|
||||
X "$indent`t`t`t`t<v8:content>$(Esc-Xml "$($item.title)")</v8:content>"
|
||||
X "$indent`t`t`t</v8:item>"
|
||||
X "$indent`t`t</dcsset:lwsTitle>"
|
||||
}
|
||||
X "$indent`t</dcsset:item>"
|
||||
}
|
||||
if ($skipAuto -and ($item -is [string]) -and $item -eq 'Auto') { continue }
|
||||
Emit-SelectionItem -item $item -indent "$indent`t"
|
||||
}
|
||||
X "$indent</dcsset:selection>"
|
||||
}
|
||||
@@ -2370,6 +2378,21 @@ function Emit-StructureItem {
|
||||
|
||||
X "$indent</dcsset:item>"
|
||||
}
|
||||
elseif ($type -eq "nestedObject") {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:StructureItemNestedObject`">"
|
||||
if ($item.objectID) { X "$indent`t<dcsset:objectID>$(Esc-Xml "$($item.objectID)")</dcsset:objectID>" }
|
||||
X "$indent`t<dcsset:settings>"
|
||||
$s = $item.settings
|
||||
if ($s) {
|
||||
if ($s.selection) { Emit-Selection -items $s.selection -indent "$indent`t`t" }
|
||||
if ($s.filter) { Emit-Filter -items $s.filter -indent "$indent`t`t" }
|
||||
if ($s.order) { Emit-Order -items $s.order -indent "$indent`t`t" }
|
||||
if ($s.conditionalAppearance) { Emit-ConditionalAppearance -items $s.conditionalAppearance -indent "$indent`t`t" }
|
||||
if ($s.outputParameters) { Emit-OutputParameters -params $s.outputParameters -indent "$indent`t`t" }
|
||||
}
|
||||
X "$indent`t</dcsset:settings>"
|
||||
X "$indent</dcsset:item>"
|
||||
}
|
||||
}
|
||||
|
||||
function Emit-SettingsVariants {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.30 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.31 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1481,46 +1481,51 @@ def emit_group_templates(lines, defn):
|
||||
|
||||
# === Settings Variants ===
|
||||
|
||||
def emit_selection_item(lines, item, indent):
|
||||
if isinstance(item, str):
|
||||
if item == 'Auto':
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>')
|
||||
else:
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:SelectedItemField">')
|
||||
lines.append(f'{indent}\t<dcsset:field>{esc_xml(item)}</dcsset:field>')
|
||||
lines.append(f'{indent}</dcsset:item>')
|
||||
return
|
||||
if 'folder' in item:
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:SelectedItemFolder">')
|
||||
if item.get('field'):
|
||||
lines.append(f'{indent}\t<dcsset:field>{esc_xml(str(item["field"]))}</dcsset:field>')
|
||||
lines.append(f'{indent}\t<dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}\t\t<v8:item>')
|
||||
lines.append(f'{indent}\t\t\t<v8:lang>ru</v8:lang>')
|
||||
lines.append(f'{indent}\t\t\t<v8:content>{esc_xml(str(item["folder"]))}</v8:content>')
|
||||
lines.append(f'{indent}\t\t</v8:item>')
|
||||
lines.append(f'{indent}\t</dcsset:lwsTitle>')
|
||||
for sub in (item.get('items') or []):
|
||||
emit_selection_item(lines, sub, f'{indent}\t')
|
||||
lines.append(f'{indent}\t<dcsset:placement>Auto</dcsset:placement>')
|
||||
lines.append(f'{indent}</dcsset:item>')
|
||||
return
|
||||
# field with optional title
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:SelectedItemField">')
|
||||
lines.append(f'{indent}\t<dcsset:field>{esc_xml(str(item["field"]))}</dcsset:field>')
|
||||
if item.get('title'):
|
||||
lines.append(f'{indent}\t<dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}\t\t<v8:item>')
|
||||
lines.append(f'{indent}\t\t\t<v8:lang>ru</v8:lang>')
|
||||
lines.append(f'{indent}\t\t\t<v8:content>{esc_xml(str(item["title"]))}</v8:content>')
|
||||
lines.append(f'{indent}\t\t</v8:item>')
|
||||
lines.append(f'{indent}\t</dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}</dcsset:item>')
|
||||
|
||||
|
||||
def emit_selection(lines, items, indent, skip_auto=False):
|
||||
if not items or len(items) == 0:
|
||||
return
|
||||
|
||||
lines.append(f'{indent}<dcsset:selection>')
|
||||
for item in items:
|
||||
if isinstance(item, str):
|
||||
if item == 'Auto':
|
||||
if not skip_auto:
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>')
|
||||
else:
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:SelectedItemField">')
|
||||
lines.append(f'{indent}\t\t<dcsset:field>{esc_xml(item)}</dcsset:field>')
|
||||
lines.append(f'{indent}\t</dcsset:item>')
|
||||
elif item.get('folder'):
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:SelectedItemFolder">')
|
||||
lines.append(f'{indent}\t\t<dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}\t\t\t<v8:item>')
|
||||
lines.append(f'{indent}\t\t\t\t<v8:lang>ru</v8:lang>')
|
||||
lines.append(f'{indent}\t\t\t\t<v8:content>{esc_xml(str(item["folder"]))}</v8:content>')
|
||||
lines.append(f'{indent}\t\t\t</v8:item>')
|
||||
lines.append(f'{indent}\t\t</dcsset:lwsTitle>')
|
||||
for sub in (item.get('items') or []):
|
||||
sub_name = str(sub.get('field', sub)) if isinstance(sub, dict) else str(sub)
|
||||
lines.append(f'{indent}\t\t<dcsset:item xsi:type="dcsset:SelectedItemField">')
|
||||
lines.append(f'{indent}\t\t\t<dcsset:field>{esc_xml(sub_name)}</dcsset:field>')
|
||||
lines.append(f'{indent}\t\t</dcsset:item>')
|
||||
lines.append(f'{indent}\t\t<dcsset:placement>Auto</dcsset:placement>')
|
||||
lines.append(f'{indent}\t</dcsset:item>')
|
||||
else:
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:SelectedItemField">')
|
||||
lines.append(f'{indent}\t\t<dcsset:field>{esc_xml(str(item["field"]))}</dcsset:field>')
|
||||
if item.get('title'):
|
||||
lines.append(f'{indent}\t\t<dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}\t\t\t<v8:item>')
|
||||
lines.append(f'{indent}\t\t\t\t<v8:lang>ru</v8:lang>')
|
||||
lines.append(f'{indent}\t\t\t\t<v8:content>{esc_xml(str(item["title"]))}</v8:content>')
|
||||
lines.append(f'{indent}\t\t\t</v8:item>')
|
||||
lines.append(f'{indent}\t\t</dcsset:lwsTitle>')
|
||||
lines.append(f'{indent}\t</dcsset:item>')
|
||||
if skip_auto and isinstance(item, str) and item == 'Auto':
|
||||
continue
|
||||
emit_selection_item(lines, item, f'{indent}\t')
|
||||
lines.append(f'{indent}</dcsset:selection>')
|
||||
|
||||
|
||||
@@ -1962,6 +1967,20 @@ def emit_structure_item(lines, item, indent):
|
||||
|
||||
lines.append(f'{indent}</dcsset:item>')
|
||||
|
||||
elif item_type == 'nestedObject':
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:StructureItemNestedObject">')
|
||||
if item.get('objectID'):
|
||||
lines.append(f'{indent}\t<dcsset:objectID>{esc_xml(str(item["objectID"]))}</dcsset:objectID>')
|
||||
lines.append(f'{indent}\t<dcsset:settings>')
|
||||
s = item.get('settings') or {}
|
||||
if s.get('selection'): emit_selection(lines, s['selection'], f'{indent}\t\t')
|
||||
if s.get('filter'): emit_filter(lines, s['filter'], f'{indent}\t\t')
|
||||
if s.get('order'): emit_order(lines, s['order'], f'{indent}\t\t')
|
||||
if s.get('conditionalAppearance'): emit_conditional_appearance(lines, s['conditionalAppearance'], f'{indent}\t\t')
|
||||
if s.get('outputParameters'): emit_output_parameters(lines, s['outputParameters'], f'{indent}\t\t')
|
||||
lines.append(f'{indent}\t</dcsset:settings>')
|
||||
lines.append(f'{indent}</dcsset:item>')
|
||||
|
||||
|
||||
def emit_settings_variants(lines, defn):
|
||||
variants = defn.get('settingsVariants')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.12 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.13 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -1028,42 +1028,51 @@ function Build-FilterItem {
|
||||
return $s
|
||||
}
|
||||
|
||||
# Recursive helper для одного элемента selection. Возвращает либо строку (имя поля / "Auto"),
|
||||
# либо ordered hashtable ({field, title} / {folder, items: [...]} / sentinel).
|
||||
function Build-SelectionItem {
|
||||
param($item, [string]$loc)
|
||||
$xt = Get-LocalXsiType $item
|
||||
# Implicit SelectedItemField: <item> без xsi:type, но с <field>
|
||||
if (-not $xt) {
|
||||
$fName = Get-Text $item "dcsset:field"
|
||||
if ($fName) { return $fName }
|
||||
}
|
||||
switch ($xt) {
|
||||
'SelectedItemAuto' { return 'Auto' }
|
||||
'SelectedItemField' {
|
||||
$fName = Get-Text $item "dcsset:field"
|
||||
$titleNode = $item.SelectSingleNode("dcsset:lwsTitle", $ns)
|
||||
$title = Get-MLText $titleNode
|
||||
if ($title) { return [ordered]@{ field = $fName; title = $title } }
|
||||
return $fName
|
||||
}
|
||||
'SelectedItemFolder' {
|
||||
$titleNode = $item.SelectSingleNode("dcsset:lwsTitle", $ns)
|
||||
$folderTitle = Get-MLText $titleNode
|
||||
$inner = @()
|
||||
foreach ($sub in $item.SelectNodes("dcsset:item", $ns)) {
|
||||
$inner += (Build-SelectionItem -item $sub -loc "$loc/folder")
|
||||
}
|
||||
$entry = [ordered]@{ folder = $folderTitle; items = $inner }
|
||||
# folder может также иметь свой <dcsset:field> (редко, но встречается)
|
||||
$folderField = Get-Text $item "dcsset:field"
|
||||
if ($folderField) { $entry['field'] = $folderField }
|
||||
return $entry
|
||||
}
|
||||
default {
|
||||
return (New-Sentinel -kind "SelectionItem:$xt" -loc $loc -detail 'Неизвестный тип элемента selection')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Build selection items array
|
||||
function Build-Selection {
|
||||
param($selNode, [string]$loc)
|
||||
if (-not $selNode) { return @() }
|
||||
$out = @()
|
||||
foreach ($it in $selNode.SelectNodes("dcsset:item", $ns)) {
|
||||
$xt = Get-LocalXsiType $it
|
||||
# Implicit SelectedItemField: <dcsset:item> without xsi:type but with <dcsset:field> child.
|
||||
# Платформа эмитит это в conditionalAppearance/selection.
|
||||
if (-not $xt) {
|
||||
$fName = Get-Text $it "dcsset:field"
|
||||
if ($fName) { $out += $fName; continue }
|
||||
}
|
||||
switch ($xt) {
|
||||
'SelectedItemAuto' { $out += 'Auto' }
|
||||
'SelectedItemField' { $out += (Get-Text $it "dcsset:field") }
|
||||
'SelectedItemFolder' {
|
||||
$titleNode = $it.SelectSingleNode("dcsset:lwsTitle", $ns)
|
||||
$folderTitle = Get-MLText $titleNode
|
||||
$inner = @()
|
||||
foreach ($sub in $it.SelectNodes("dcsset:item", $ns)) {
|
||||
$st = Get-LocalXsiType $sub
|
||||
if (-not $st) {
|
||||
$subF = Get-Text $sub "dcsset:field"
|
||||
if ($subF) { $inner += $subF; continue }
|
||||
}
|
||||
if ($st -eq 'SelectedItemField') { $inner += (Get-Text $sub "dcsset:field") }
|
||||
elseif ($st -eq 'SelectedItemAuto') { $inner += 'Auto' }
|
||||
else { $inner += (New-Sentinel -kind "SelectionInFolder:$st" -loc "$loc/folder" -detail 'Неизвестный тип элемента папки выбора') }
|
||||
}
|
||||
$out += [ordered]@{ folder = $folderTitle; items = $inner }
|
||||
}
|
||||
default {
|
||||
$out += (New-Sentinel -kind "SelectionItem:$xt" -loc $loc -detail 'Неизвестный тип элемента selection')
|
||||
}
|
||||
}
|
||||
$out += (Build-SelectionItem -item $it -loc $loc)
|
||||
}
|
||||
return ,$out
|
||||
}
|
||||
@@ -1219,7 +1228,8 @@ function Build-DataParameters {
|
||||
return ,$entries
|
||||
}
|
||||
|
||||
# Read groupItems -> array of field names (with periodAddition/groupType warnings)
|
||||
# Read groupItems → array. Простые поля → string. С нестандартным groupType/periodAdditionType
|
||||
# → object form {field, groupType?, periodAdditionType?} (compile принимает оба варианта).
|
||||
function Get-GroupFields {
|
||||
param($parentNode, [string]$loc)
|
||||
$gFields = @()
|
||||
@@ -1231,10 +1241,15 @@ function Get-GroupFields {
|
||||
$gf = Get-Text $gItem "dcsset:field"
|
||||
$pat = Get-Text $gItem "dcsset:periodAdditionType"
|
||||
$gt = Get-Text $gItem "dcsset:groupType"
|
||||
if (($pat -and $pat -ne 'None') -or ($gt -and $gt -ne 'Items')) {
|
||||
$null = Add-Warning -kind 'GroupItemDetails' -loc "$loc/groupItems" -detail "Группировка $gf использует groupType=$gt, periodAdditionType=$pat — не воспроизводится в shorthand"
|
||||
$isDefault = (-not $pat -or $pat -eq 'None') -and (-not $gt -or $gt -eq 'Items')
|
||||
if ($isDefault) {
|
||||
$gFields += $gf
|
||||
} else {
|
||||
$obj = [ordered]@{ field = $gf }
|
||||
if ($gt -and $gt -ne 'Items') { $obj['groupType'] = $gt }
|
||||
if ($pat -and $pat -ne 'None') { $obj['periodAdditionType'] = $pat }
|
||||
$gFields += $obj
|
||||
}
|
||||
$gFields += $gf
|
||||
} else {
|
||||
$gFields += (New-Sentinel -kind "GroupItem:$gxt" -loc "$loc/groupItems" -detail 'Тип элемента группировки не покрыт')
|
||||
}
|
||||
@@ -1293,6 +1308,39 @@ function Build-Structure {
|
||||
$idx++
|
||||
continue
|
||||
}
|
||||
if ($xt -eq 'StructureItemNestedObject') {
|
||||
$entry = [ordered]@{ type = 'nestedObject' }
|
||||
$objID = Get-Text $it "dcsset:objectID"
|
||||
if ($objID) { $entry['objectID'] = $objID }
|
||||
$settingsNode = $it.SelectSingleNode("dcsset:settings", $ns)
|
||||
if ($settingsNode) {
|
||||
$nestedSettings = [ordered]@{}
|
||||
$selNode = $settingsNode.SelectSingleNode("dcsset:selection", $ns)
|
||||
$selI = Build-Selection -selNode $selNode -loc "$loc/$idx/nested/selection"
|
||||
if ($selI.Count -gt 0) { $nestedSettings['selection'] = $selI }
|
||||
$fNode = $settingsNode.SelectSingleNode("dcsset:filter", $ns)
|
||||
if ($fNode -and $fNode.SelectNodes("dcsset:item", $ns).Count -gt 0) {
|
||||
$fa = @()
|
||||
foreach ($fc in $fNode.SelectNodes("dcsset:item", $ns)) { $fa += (Build-FilterItem -itemNode $fc -loc "$loc/$idx/nested/filter") }
|
||||
$nestedSettings['filter'] = $fa
|
||||
}
|
||||
$oNode = $settingsNode.SelectSingleNode("dcsset:order", $ns)
|
||||
$oI = Build-Order -ordNode $oNode -loc "$loc/$idx/nested/order"
|
||||
if ($oI.Count -gt 0) { $nestedSettings['order'] = $oI }
|
||||
$caNode = $settingsNode.SelectSingleNode("dcsset:conditionalAppearance", $ns)
|
||||
if ($caNode) {
|
||||
$ca = Build-ConditionalAppearance -caNode $caNode -loc "$loc/$idx/nested/ca"
|
||||
if ($ca.Count -gt 0) { $nestedSettings['conditionalAppearance'] = $ca }
|
||||
}
|
||||
$opNode = $settingsNode.SelectSingleNode("dcsset:outputParameters", $ns)
|
||||
$op = Build-OutputParameters -opNode $opNode
|
||||
if ($op -and $op.Count -gt 0) { $nestedSettings['outputParameters'] = $op }
|
||||
$entry['settings'] = $nestedSettings
|
||||
}
|
||||
$items += $entry
|
||||
$idx++
|
||||
continue
|
||||
}
|
||||
if ($xt -eq 'StructureItemChart') {
|
||||
$entry = [ordered]@{ type = 'chart' }
|
||||
$nm = Get-Text $it "dcsset:name"
|
||||
@@ -1322,28 +1370,8 @@ function Build-Structure {
|
||||
# Optional name
|
||||
$nm = Get-Text $it "dcsset:name"
|
||||
if ($nm) { $entry['name'] = $nm }
|
||||
# groupItems → groupFields
|
||||
$gi = $it.SelectSingleNode("dcsset:groupItems", $ns)
|
||||
$gFields = @()
|
||||
if ($gi) {
|
||||
foreach ($gItem in $gi.SelectNodes("dcsset:item", $ns)) {
|
||||
$gxt = Get-LocalXsiType $gItem
|
||||
if ($gxt -eq 'GroupItemField') {
|
||||
$gf = Get-Text $gItem "dcsset:field"
|
||||
# Look at periodAdditionType — non-None or non-default → sentinel
|
||||
$pat = Get-Text $gItem "dcsset:periodAdditionType"
|
||||
$gt = Get-Text $gItem "dcsset:groupType"
|
||||
if (($pat -and $pat -ne 'None') -or ($gt -and $gt -ne 'Items')) {
|
||||
# Non-default grouping — record but don't fail
|
||||
# We still emit the field; flag in warnings only
|
||||
$null = Add-Warning -kind 'GroupItemDetails' -loc "$loc/groupItems" -detail "Группировка $gf использует groupType=$gt, periodAdditionType=$pat — не воспроизводится в shorthand"
|
||||
}
|
||||
$gFields += $gf
|
||||
} else {
|
||||
$gFields += (New-Sentinel -kind "GroupItem:$gxt" -loc "$loc/groupItems" -detail 'Тип элемента группировки не покрыт')
|
||||
}
|
||||
}
|
||||
}
|
||||
# groupItems → groupFields (через общий Get-GroupFields с object form поддержкой)
|
||||
$gFields = Get-GroupFields -parentNode $it -loc $loc
|
||||
if ($gFields.Count -gt 0) { $entry['groupFields'] = $gFields }
|
||||
|
||||
# Local selection — only emit if not "[Auto]" default
|
||||
@@ -1398,6 +1426,8 @@ function Try-StructureShorthand {
|
||||
break
|
||||
}
|
||||
if ($gfs.Count -ne 1) { return $null }
|
||||
# Только простые имена-строки сворачиваем в shorthand
|
||||
if ($gfs[0] -isnot [string]) { return $null }
|
||||
$parts += $gfs[0]
|
||||
$children = $cur['children']
|
||||
if ($null -eq $children -or $children.Count -eq 0) { break }
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DataCompositionSchema xmlns="http://v8.1c.ru/8.1/data-composition-system/schema"
|
||||
xmlns:dcscom="http://v8.1c.ru/8.1/data-composition-system/common"
|
||||
xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core"
|
||||
xmlns:dcsset="http://v8.1c.ru/8.1/data-composition-system/settings"
|
||||
xmlns:v8="http://v8.1c.ru/8.1/data/core"
|
||||
xmlns:v8ui="http://v8.1c.ru/8.1/data/ui"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<dataSource>
|
||||
<name>ИсточникДанных1</name>
|
||||
<dataSourceType>Local</dataSourceType>
|
||||
</dataSource>
|
||||
<dataSet xsi:type="DataSetUnion">
|
||||
<name>DSОбъединение</name>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Период</dataPath>
|
||||
<field>Период</field>
|
||||
<valueType>
|
||||
<v8:Type>xs:dateTime</v8:Type>
|
||||
<v8:DateQualifiers>
|
||||
<v8:DateFractions>Date</v8:DateFractions>
|
||||
</v8:DateQualifiers>
|
||||
</valueType>
|
||||
</field>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>ВидРасчета</dataPath>
|
||||
<field>ВидРасчета</field>
|
||||
<valueType>
|
||||
<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:CatalogRef.ВидыРасчета</v8:Type>
|
||||
</valueType>
|
||||
</field>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Сумма</dataPath>
|
||||
<field>Сумма</field>
|
||||
<valueType>
|
||||
<v8:Type>xs:decimal</v8:Type>
|
||||
<v8:NumberQualifiers>
|
||||
<v8:Digits>15</v8:Digits>
|
||||
<v8:FractionDigits>2</v8:FractionDigits>
|
||||
<v8:AllowedSign>Any</v8:AllowedSign>
|
||||
</v8:NumberQualifiers>
|
||||
</valueType>
|
||||
</field>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Подразделение</dataPath>
|
||||
<field>Подразделение</field>
|
||||
<valueType>
|
||||
<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:CatalogRef.Подразделения</v8:Type>
|
||||
</valueType>
|
||||
</field>
|
||||
<dataSet xsi:type="DataSetObject">
|
||||
<name>Часть1</name>
|
||||
<dataSource>ИсточникДанных1</dataSource>
|
||||
<objectName>ДанныеЧасть1</objectName>
|
||||
</dataSet>
|
||||
<dataSet xsi:type="DataSetObject">
|
||||
<name>Часть2</name>
|
||||
<dataSource>ИсточникДанных1</dataSource>
|
||||
<objectName>ДанныеЧасть2</objectName>
|
||||
</dataSet>
|
||||
</dataSet>
|
||||
<settingsVariant>
|
||||
<dcsset:name>Основной</dcsset:name>
|
||||
<dcsset:presentation xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Основной</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:presentation>
|
||||
<dcsset:settings xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows">
|
||||
<dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>Период</dcsset:field>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>Сумма</dcsset:field>
|
||||
<dcsset:lwsTitle>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Итого</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:lwsTitle>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemFolder">
|
||||
<dcsset:lwsTitle>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Группа итогов</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:lwsTitle>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>ВидРасчета</dcsset:field>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>Сумма</dcsset:field>
|
||||
<dcsset:lwsTitle>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Сумма с расшифровкой</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:lwsTitle>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemFolder">
|
||||
<dcsset:lwsTitle>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Подгруппа</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:lwsTitle>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>Подразделение</dcsset:field>
|
||||
</dcsset:item>
|
||||
<dcsset:placement>Auto</dcsset:placement>
|
||||
</dcsset:item>
|
||||
<dcsset:placement>Auto</dcsset:placement>
|
||||
</dcsset:item>
|
||||
</dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:StructureItemGroup">
|
||||
<dcsset:name>Группа1</dcsset:name>
|
||||
<dcsset:groupItems>
|
||||
<dcsset:item xsi:type="dcsset:GroupItemField">
|
||||
<dcsset:field>Период</dcsset:field>
|
||||
<dcsset:groupType>Items</dcsset:groupType>
|
||||
<dcsset:periodAdditionType>Day</dcsset:periodAdditionType>
|
||||
<dcsset:periodAdditionBegin xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionBegin>
|
||||
<dcsset:periodAdditionEnd xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionEnd>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:GroupItemField">
|
||||
<dcsset:field>Подразделение</dcsset:field>
|
||||
<dcsset:groupType>Hierarchy</dcsset:groupType>
|
||||
<dcsset:periodAdditionType>None</dcsset:periodAdditionType>
|
||||
<dcsset:periodAdditionBegin xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionBegin>
|
||||
<dcsset:periodAdditionEnd xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionEnd>
|
||||
</dcsset:item>
|
||||
</dcsset:groupItems>
|
||||
<dcsset:order>
|
||||
<dcsset:item xsi:type="dcsset:OrderItemAuto"/>
|
||||
</dcsset:order>
|
||||
<dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>
|
||||
</dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:StructureItemNestedObject">
|
||||
<dcsset:objectID>ДанныеЧасть1</dcsset:objectID>
|
||||
<dcsset:settings>
|
||||
<dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>ВидРасчета</dcsset:field>
|
||||
</dcsset:item>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemField">
|
||||
<dcsset:field>Сумма</dcsset:field>
|
||||
</dcsset:item>
|
||||
</dcsset:selection>
|
||||
</dcsset:settings>
|
||||
</dcsset:item>
|
||||
</dcsset:item>
|
||||
</dcsset:settings>
|
||||
</settingsVariant>
|
||||
</DataCompositionSchema>
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"dataSets": [
|
||||
{
|
||||
"name": "DSОбъединение",
|
||||
"items": [
|
||||
{
|
||||
"name": "Часть1",
|
||||
"objectName": "ДанныеЧасть1"
|
||||
},
|
||||
{
|
||||
"name": "Часть2",
|
||||
"objectName": "ДанныеЧасть2"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
"Период: date",
|
||||
"ВидРасчета: CatalogRef.ВидыРасчета",
|
||||
"Сумма: decimal(15,2)",
|
||||
"Подразделение: CatalogRef.Подразделения"
|
||||
]
|
||||
}
|
||||
],
|
||||
"settingsVariants": [
|
||||
{
|
||||
"name": "Основной",
|
||||
"settings": {
|
||||
"selection": [
|
||||
"Период",
|
||||
{
|
||||
"field": "Сумма",
|
||||
"title": "Итого"
|
||||
},
|
||||
{
|
||||
"folder": "Группа итогов",
|
||||
"items": [
|
||||
"ВидРасчета",
|
||||
{
|
||||
"field": "Сумма",
|
||||
"title": "Сумма с расшифровкой"
|
||||
},
|
||||
{
|
||||
"folder": "Подгруппа",
|
||||
"items": [
|
||||
"Подразделение"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"structure": [
|
||||
{
|
||||
"name": "Группа1",
|
||||
"groupFields": [
|
||||
{
|
||||
"field": "Период",
|
||||
"periodAdditionType": "Day"
|
||||
},
|
||||
{
|
||||
"field": "Подразделение",
|
||||
"groupType": "Hierarchy"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "nestedObject",
|
||||
"objectID": "ДанныеЧасть1",
|
||||
"settings": {
|
||||
"selection": [
|
||||
"ВидРасчета",
|
||||
"Сумма"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "Структура: nestedObject + selection с вложенными folder и field-with-title + groupItem object form",
|
||||
"preRun": [
|
||||
{
|
||||
"script": "skd-compile/scripts/skd-compile",
|
||||
"input": {
|
||||
"dataSets": [
|
||||
{
|
||||
"name": "DSОбъединение",
|
||||
"items": [
|
||||
{ "name": "Часть1", "objectName": "ДанныеЧасть1" },
|
||||
{ "name": "Часть2", "objectName": "ДанныеЧасть2" }
|
||||
],
|
||||
"fields": [
|
||||
"Период: date",
|
||||
"ВидРасчета: CatalogRef.ВидыРасчета",
|
||||
"Сумма: decimal(15,2)",
|
||||
"Подразделение: CatalogRef.Подразделения"
|
||||
]
|
||||
}
|
||||
],
|
||||
"settingsVariants": [
|
||||
{
|
||||
"name": "Основной",
|
||||
"settings": {
|
||||
"selection": [
|
||||
"Период",
|
||||
{ "field": "Сумма", "title": "Итого" },
|
||||
{
|
||||
"folder": "Группа итогов",
|
||||
"items": [
|
||||
"ВидРасчета",
|
||||
{ "field": "Сумма", "title": "Сумма с расшифровкой" },
|
||||
{
|
||||
"folder": "Подгруппа",
|
||||
"items": ["Подразделение"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"structure": [
|
||||
{
|
||||
"name": "Группа1",
|
||||
"groupFields": [
|
||||
{ "field": "Период", "periodAdditionType": "Day" },
|
||||
{ "field": "Подразделение", "groupType": "Hierarchy" }
|
||||
],
|
||||
"children": [
|
||||
{ "type": "nestedObject", "objectID": "ДанныеЧасть1", "settings": {
|
||||
"selection": ["ВидРасчета", "Сумма"]
|
||||
}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "Template.xml" },
|
||||
"cwd": "{workDir}"
|
||||
}
|
||||
],
|
||||
"params": { "templatePath": "Template.xml" },
|
||||
"outputPath": "decompiled.json"
|
||||
}
|
||||
Reference in New Issue
Block a user