From 5793f91ebb8c05d60254c90aaaa4f8e3984016fc Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 23 May 2026 16:54:26 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd):=20StandardPeriod=20=D1=81=20=D1=8F?= =?UTF-8?q?=D0=B2=D0=BD=D1=8B=D0=BC=D0=B8=20dat=D0=B0=D0=BC=D0=B8=20=D0=B2?= =?UTF-8?q?=20dataParameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Когда v8:StandardPeriod имеет non-default startDate/endDate, decompile выдаёт object form {parameter, value:{variant, startDate, endDate}, ...} вместо shorthand "P = Custom". Compile использует переданные даты вместо boilerplate 0001-01-01. sample30: −24 строки (2690 → 2666). --- .../skd-compile/scripts/skd-compile.ps1 | 27 ++++++++------- .../skills/skd-compile/scripts/skd-compile.py | 10 +++--- .../skd-decompile/scripts/skd-decompile.ps1 | 33 +++++++++++++++---- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index f54784d6..b9312c69 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.69 — Compile 1C DCS from JSON +# skd-compile v1.70 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -2520,19 +2520,22 @@ function Emit-DataParameters { Emit-EmptyValue -type "$($dp.valueType)" -indent "$indent`t`t" -tagPrefix "dcscor:" -valueListAllowed $false } elseif ($null -ne $dp.value) { $vtype = "$($dp.valueType)" - if ($dp.value -is [PSCustomObject] -and $dp.value.variant) { - # StandardPeriod (object form from JSON) + if (($dp.value -is [PSCustomObject] -or $dp.value -is [hashtable]) -and ($dp.value.variant)) { + # StandardPeriod (PSCustomObject from JSON / hashtable from shorthand parser) + $_sd = $null; $_ed = $null + if ($dp.value -is [PSCustomObject]) { + if ($dp.value.PSObject.Properties['startDate']) { $_sd = "$($dp.value.startDate)" } + if ($dp.value.PSObject.Properties['endDate']) { $_ed = "$($dp.value.endDate)" } + } else { + if ($dp.value.Contains('startDate')) { $_sd = "$($dp.value['startDate'])" } + if ($dp.value.Contains('endDate')) { $_ed = "$($dp.value['endDate'])" } + } + if (-not $_sd) { $_sd = '0001-01-01T00:00:00' } + if (-not $_ed) { $_ed = '0001-01-01T00:00:00' } X "$indent`t`t" X "$indent`t`t`t$(Esc-Xml "$($dp.value.variant)")" - X "$indent`t`t`t0001-01-01T00:00:00" - X "$indent`t`t`t0001-01-01T00:00:00" - X "$indent`t`t" - } elseif ($dp.value -is [hashtable] -and $dp.value.variant) { - # StandardPeriod (hashtable from shorthand parser) - X "$indent`t`t" - X "$indent`t`t`t$(Esc-Xml "$($dp.value.variant)")" - X "$indent`t`t`t0001-01-01T00:00:00" - X "$indent`t`t`t0001-01-01T00:00:00" + X "$indent`t`t`t$(Esc-Xml $_sd)" + X "$indent`t`t`t$(Esc-Xml $_ed)" X "$indent`t`t" } elseif ($vtype -eq 'boolean' -or $dp.value -is [bool]) { $bv = "$($dp.value)".ToLower() diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index 4aca5089..479f84a7 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.69 — Compile 1C DCS from JSON +# skd-compile v1.70 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -2054,11 +2054,13 @@ def emit_data_parameters(lines, items, indent): val = dp['value'] vtype = str(dp.get('valueType') or '') if isinstance(val, dict) and val.get('variant'): - # StandardPeriod + # StandardPeriod (с явными датами или boilerplate) + sd = str(val.get('startDate') or '0001-01-01T00:00:00') + ed = str(val.get('endDate') or '0001-01-01T00:00:00') lines.append(f'{indent}\t\t') lines.append(f'{indent}\t\t\t{esc_xml(str(val["variant"]))}') - lines.append(f'{indent}\t\t\t0001-01-01T00:00:00') - lines.append(f'{indent}\t\t\t0001-01-01T00:00:00') + lines.append(f'{indent}\t\t\t{esc_xml(sd)}') + lines.append(f'{indent}\t\t\t{esc_xml(ed)}') lines.append(f'{indent}\t\t') elif vtype == 'boolean' or isinstance(val, bool): bv = str(val).lower() diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index fc177afe..bfb105c5 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.53 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.54 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1751,9 +1751,20 @@ function Build-DataParameters { if ($use -eq 'false') { $flags += '@off' } $vt = Get-LocalXsiType $valNode $vDisplay = $null + $stdPeriodObj = $null if ($vt -eq 'StandardPeriod') { $variant = Get-Text $valNode "v8:variant" - if ($variant) { $vDisplay = $variant } + $sd = Get-Text $valNode "v8:startDate" + $ed = Get-Text $valNode "v8:endDate" + $hasExplicitDates = ($sd -and $sd -ne '0001-01-01T00:00:00') -or ($ed -and $ed -ne '0001-01-01T00:00:00') + if ($hasExplicitDates) { + $stdPeriodObj = [ordered]@{ variant = $variant } + if ($sd) { $stdPeriodObj['startDate'] = $sd } + if ($ed) { $stdPeriodObj['endDate'] = $ed } + $canAuto = $false + } elseif ($variant) { + $vDisplay = $variant + } } elseif ($vt -eq 'DesignTimeValue') { $vDisplay = $valNode.InnerText } elseif ($vt -eq 'LocalStringType') { @@ -1764,11 +1775,19 @@ function Build-DataParameters { # Compare to top-level default if ($tp -and $tp.valueDisplay -ne $vDisplay) { $canAuto = $false } if (-not $tp) { $canAuto = $false } # extra param not in top-level - # Build shorthand entry - $s = $pn - if ($null -ne $vDisplay -and $vDisplay -ne '') { $s += " = $vDisplay" } - if ($flags) { $s += ' ' + ($flags -join ' ') } - $entries += $s + if ($stdPeriodObj) { + # Object form для StandardPeriod с явными датами + $obj = [ordered]@{ parameter = $pn; value = $stdPeriodObj } + if ($use -eq 'false') { $obj['use'] = $false } + if ($usid) { $obj['userSettingID'] = 'auto' } + $entries += $obj + } else { + # Build shorthand entry + $s = $pn + if ($null -ne $vDisplay -and $vDisplay -ne '') { $s += " = $vDisplay" } + if ($flags) { $s += ' ' + ($flags -join ' ') } + $entries += $s + } } # Check that all visible top-level params are present foreach ($vn in $visibleTop.Keys) { if (-not $presentNames.ContainsKey($vn)) { $canAuto = $false } }