From a66246095c17fceaa6e98b3426a7260ce13ad105 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 23 May 2026 12:54:53 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd):=20multi-orderExpression=20=D0=BD?= =?UTF-8?q?=D0=B0=20dataSet=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit На одном поле может быть несколько (multi-sort fallback). decompile сохраняет массив (single → object back-compat), compile принимает оба. sample30: −30 строк, +2 отчёта в bit-perfect (27 with-diff). --- .../skd-compile/scripts/skd-compile.ps1 | 31 +++++++++++------ .../skills/skd-compile/scripts/skd-compile.py | 24 +++++++------ .../skd-decompile/scripts/skd-decompile.ps1 | 34 ++++++++++++------- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index bfd49299..f10a2076 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.ps1 +++ b/.claude/skills/skd-compile/scripts/skd-compile.ps1 @@ -1,4 +1,4 @@ -# skd-compile v1.63 — Compile 1C DCS from JSON +# skd-compile v1.64 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -948,17 +948,26 @@ function Emit-Field { X "$indent`t" } - # OrderExpression — после role, до valueType + # OrderExpression — после role, до valueType. Допустим массив (multi-sort). if ($f["orderExpression"]) { - $oe = $f["orderExpression"] - $expr = if ($oe.expression) { "$($oe.expression)" } else { '' } - $oType = if ($oe.orderType) { "$($oe.orderType)" } else { 'Asc' } - $autoOrder = if ($null -ne $oe.autoOrder) { $(if ($oe.autoOrder) { 'true' } else { 'false' }) } else { 'false' } - X "$indent`t" - X "$indent`t`t$(Esc-Xml $expr)" - X "$indent`t`t$oType" - X "$indent`t`t$autoOrder" - X "$indent`t" + $oeRaw = $f["orderExpression"] + if ($oeRaw -is [System.Collections.IDictionary]) { + $oeList = @($oeRaw) + } elseif ($oeRaw -is [System.Collections.IList]) { + $oeList = $oeRaw + } else { + $oeList = @($oeRaw) + } + foreach ($oe in $oeList) { + $expr = if ($oe.expression) { "$($oe.expression)" } else { '' } + $oType = if ($oe.orderType) { "$($oe.orderType)" } else { 'Asc' } + $autoOrder = if ($null -ne $oe.autoOrder) { $(if ($oe.autoOrder) { 'true' } else { 'false' }) } else { 'false' } + X "$indent`t" + X "$indent`t`t$(Esc-Xml $expr)" + X "$indent`t`t$oType" + X "$indent`t`t$autoOrder" + X "$indent`t" + } } # ValueType diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index bc567558..fc3b57f5 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.py +++ b/.claude/skills/skd-compile/scripts/skd-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-compile v1.63 — Compile 1C DCS from JSON +# skd-compile v1.64 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -726,16 +726,18 @@ def emit_field(lines, field_def, indent): # OrderExpression — после role, до valueType if f.get('orderExpression'): - oe = f['orderExpression'] - expr = str(oe.get('expression', '')) - o_type = str(oe.get('orderType', 'Asc')) - auto = oe.get('autoOrder', False) - auto_str = 'true' if auto else 'false' - lines.append(f'{indent}\t') - lines.append(f'{indent}\t\t{esc_xml(expr)}') - lines.append(f'{indent}\t\t{o_type}') - lines.append(f'{indent}\t\t{auto_str}') - lines.append(f'{indent}\t') + oe_raw = f['orderExpression'] + oe_list = oe_raw if isinstance(oe_raw, list) else [oe_raw] + for oe in oe_list: + expr = str(oe.get('expression', '')) + o_type = str(oe.get('orderType', 'Asc')) + auto = oe.get('autoOrder', False) + auto_str = 'true' if auto else 'false' + lines.append(f'{indent}\t') + lines.append(f'{indent}\t\t{esc_xml(expr)}') + lines.append(f'{indent}\t\t{o_type}') + lines.append(f'{indent}\t\t{auto_str}') + lines.append(f'{indent}\t') # ValueType if f.get('type'): diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index 73ea0bff..585e9bac 100644 --- a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 +++ b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 @@ -1,4 +1,4 @@ -# skd-decompile v0.47 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.48 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -523,19 +523,27 @@ function Build-Field { param($fieldNode, [string]$loc) # inputParameters теперь поддерживается в DSL — читается ниже в needsObject $inputParameters = Read-InputParameters -parentNode $fieldNode - # orderExpression теперь поддерживается в DSL — читается ниже в needsObject - $orderExprNode = $fieldNode.SelectSingleNode("r:orderExpression", $ns) + # orderExpression теперь поддерживается в DSL — читается ниже в needsObject. + # На одном поле может быть несколько (multi-sort fallback), + # в этом случае сохраняем массив; единичный — как объект (back-compat). + $orderExprNodes = $fieldNode.SelectNodes("r:orderExpression", $ns) $orderExpression = $null - if ($orderExprNode) { - $oeExpr = Get-Text $orderExprNode "dcscom:expression" - $oeType = Get-Text $orderExprNode "dcscom:orderType" - $oeAuto = Get-Text $orderExprNode "dcscom:autoOrder" - $orderExpression = [ordered]@{} - if ($oeExpr) { $orderExpression['expression'] = $oeExpr } - if ($oeType) { $orderExpression['orderType'] = $oeType } - # autoOrder=false — это дефолт; emit'им только если true (или явно записан false) - if ($oeAuto -eq 'true') { $orderExpression['autoOrder'] = $true } - elseif ($oeAuto -eq 'false') { $orderExpression['autoOrder'] = $false } + $orderExpressionList = @() + foreach ($oeN in $orderExprNodes) { + $oeExpr = Get-Text $oeN "dcscom:expression" + $oeType = Get-Text $oeN "dcscom:orderType" + $oeAuto = Get-Text $oeN "dcscom:autoOrder" + $oe = [ordered]@{} + if ($oeExpr) { $oe['expression'] = $oeExpr } + if ($oeType) { $oe['orderType'] = $oeType } + if ($oeAuto -eq 'true') { $oe['autoOrder'] = $true } + elseif ($oeAuto -eq 'false') { $oe['autoOrder'] = $false } + $orderExpressionList += ,$oe + } + if ($orderExpressionList.Count -eq 1) { + $orderExpression = $orderExpressionList[0] + } elseif ($orderExpressionList.Count -gt 1) { + $orderExpression = $orderExpressionList } $dataPath = Get-Text $fieldNode "r:dataPath" $fieldName = Get-Text $fieldNode "r:field"