From 540af9655d234bb2d075651efc36304db6d2a3b1 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Fri, 22 May 2026 18:19:20 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd-compile):=20filter=20right=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=BE=D0=B9=20ValueListType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DSL: value на filter item может быть массив: - value: [] — пустой ValueListType placeholder (для InList с пользовательскими настройками — пользователь заполнит значения через UI) - value: [3, 4, 5] — InList с несколькими конкретными значениями (compile эмитит несколько подряд) - value: 3 — single value (как раньше) Compile автоопределяет тип каждого значения (bool/decimal/dateTime/string). Co-Authored-By: Claude Opus 4.7 --- .../skd-compile/scripts/skd-compile.ps1 | 28 ++++++++++++-- .../skills/skd-compile/scripts/skd-compile.py | 37 +++++++++++++++---- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index 4efb3e45..25ad2e22 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.46 — Compile 1C DCS from JSON +# skd-compile v1.47 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -1994,8 +1994,30 @@ function Emit-FilterItem { if (-not $compType) { $compType = "$($item.op)" } X "$indent`t$(Esc-Xml $compType)" - # Right value - if ($null -ne $item.value) { + # Right value: один, несколько (InList) или ValueListType (пустой list-placeholder) + $valIsArray = ($item.value -is [array]) -or ($item.value -is [System.Collections.IList] -and $item.value -isnot [string]) + if ($valIsArray) { + # Пустой массив → пустой ValueListType placeholder + if (@($item.value).Count -eq 0) { + X "$indent`t" + X "$indent`t`t" + X "$indent`t`t-1" + X "$indent`t" + } else { + # Несколько подряд (multi-value InList) + foreach ($v in $item.value) { + $vt = if ($item.valueType) { "$($item.valueType)" } else { "" } + if (-not $vt) { + if ($v -is [bool]) { $vt = 'xs:boolean' } + elseif ($v -is [int] -or $v -is [long] -or $v -is [double]) { $vt = 'xs:decimal' } + elseif ("$v" -match '^\d{4}-\d{2}-\d{2}T') { $vt = 'xs:dateTime' } + else { $vt = 'xs:string' } + } + $vStr = if ($v -is [bool]) { "$v".ToLower() } else { Esc-Xml "$v" } + X "$indent`t$vStr" + } + } + } elseif ($null -ne $item.value) { $vt = if ($item.valueType) { "$($item.valueType)" } else { "" } if (-not $vt) { $v = $item.value diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index 93fbd3fb..faee46b0 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.46 — Compile 1C DCS from JSON +# skd-compile v1.47 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -1658,11 +1658,34 @@ def emit_filter_item(lines, item, indent): comp_type = COMPARISON_TYPES.get(str(item.get('op', '')), str(item.get('op', ''))) lines.append(f'{indent}\t{esc_xml(comp_type)}') - # Right value - if item.get('value') is not None: + # Right value: один, несколько (InList) или ValueListType (пустой list-placeholder) + val = item.get('value') + val_is_array = isinstance(val, list) + if val_is_array: + if len(val) == 0: + # Пустой массив → пустой ValueListType placeholder + lines.append(f'{indent}\t') + lines.append(f'{indent}\t\t') + lines.append(f'{indent}\t\t-1') + lines.append(f'{indent}\t') + else: + for v in val: + vt = str(item.get('valueType', '')) if item.get('valueType') else '' + if not vt: + if isinstance(v, bool): + vt = 'xs:boolean' + elif isinstance(v, (int, float)): + vt = 'xs:decimal' + elif re.match(r'^\d{4}-\d{2}-\d{2}T', str(v)): + vt = 'xs:dateTime' + else: + vt = 'xs:string' + v_str = str(v).lower() if isinstance(v, bool) else esc_xml(str(v)) + lines.append(f'{indent}\t{v_str}') + elif val is not None: vt = str(item.get('valueType', '')) if item.get('valueType') else '' if not vt: - v = item['value'] + v = val if isinstance(v, bool): vt = 'xs:boolean' elif isinstance(v, (int, float)): @@ -1671,10 +1694,10 @@ def emit_filter_item(lines, item, indent): vt = 'xs:dateTime' else: vt = 'xs:string' - if isinstance(item['value'], bool): - v_str = str(item['value']).lower() + if isinstance(val, bool): + v_str = str(val).lower() else: - v_str = esc_xml(str(item['value'])) + v_str = esc_xml(str(val)) lines.append(f'{indent}\t{v_str}') if item.get('presentation'):