mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-18 16:49:41 +03:00
fix(skd-compile): DesignTimeValue, useRestriction for hidden, named structure groups
- fix: auto-detect DesignTimeValue for ПланСчетов/Справочник/Перечисление/Документ values (#9) - fix: hidden params auto-set useRestriction=true alongside availableAsField=false (#11) - feat: named groups in structure shorthand "ИмяГруппы[Поле] > details" (#10) - version bump: skd-compile v1.5 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# skd-compile v1.4 — Compile 1C DCS from JSON
|
# skd-compile v1.5 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -857,8 +857,14 @@ function Emit-SingleParam {
|
|||||||
# Value
|
# Value
|
||||||
Emit-ParamValue -type $parsed.type -val $parsed.value -indent "`t`t"
|
Emit-ParamValue -type $parsed.type -val $parsed.value -indent "`t`t"
|
||||||
|
|
||||||
|
# Hidden implies useRestriction=true + availableAsField=false
|
||||||
|
if ($parsed.hidden -eq $true) {
|
||||||
|
$parsed.availableAsField = $false
|
||||||
|
$parsed.useRestriction = $true
|
||||||
|
}
|
||||||
|
|
||||||
# UseRestriction
|
# UseRestriction
|
||||||
if ($p -isnot [string] -and $p.useRestriction -eq $true) {
|
if ($parsed.useRestriction -eq $true -or ($p -isnot [string] -and $p.useRestriction -eq $true)) {
|
||||||
X "`t`t<useRestriction>true</useRestriction>"
|
X "`t`t<useRestriction>true</useRestriction>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,9 +873,6 @@ function Emit-SingleParam {
|
|||||||
X "`t`t<expression>$(Esc-Xml $parsed.expression)</expression>"
|
X "`t`t<expression>$(Esc-Xml $parsed.expression)</expression>"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hidden implies availableAsField=false
|
|
||||||
if ($parsed.hidden -eq $true) { $parsed.availableAsField = $false }
|
|
||||||
|
|
||||||
# AvailableAsField
|
# AvailableAsField
|
||||||
if ($parsed.availableAsField -eq $false) {
|
if ($parsed.availableAsField -eq $false) {
|
||||||
X "`t`t<availableAsField>false</availableAsField>"
|
X "`t`t<availableAsField>false</availableAsField>"
|
||||||
@@ -957,6 +960,8 @@ function Emit-ParamValue {
|
|||||||
X "$indent<value xsi:type=`"xs:dateTime`">$(Esc-Xml $valStr)</value>"
|
X "$indent<value xsi:type=`"xs:dateTime`">$(Esc-Xml $valStr)</value>"
|
||||||
} elseif ($valStr -eq "true" -or $valStr -eq "false") {
|
} elseif ($valStr -eq "true" -or $valStr -eq "false") {
|
||||||
X "$indent<value xsi:type=`"xs:boolean`">$(Esc-Xml $valStr)</value>"
|
X "$indent<value xsi:type=`"xs:boolean`">$(Esc-Xml $valStr)</value>"
|
||||||
|
} elseif ($valStr -match '^(ПланСчетов|Справочник|Перечисление|Документ|ПланВидовХарактеристик|ПланВидовРасчета|БизнесПроцесс|Задача|РегистрСведений|ПланОбмена)\.' -or $valStr -match '^(ChartOfAccounts|Catalog|Enum|Document|ChartOfCharacteristicTypes|ChartOfCalculationTypes|BusinessProcess|Task|InformationRegister|ExchangePlan)\.') {
|
||||||
|
X "$indent<value xsi:type=`"dcscor:DesignTimeValue`">$(Esc-Xml $valStr)</value>"
|
||||||
} else {
|
} else {
|
||||||
X "$indent<value xsi:type=`"xs:string`">$(Esc-Xml $valStr)</value>"
|
X "$indent<value xsi:type=`"xs:string`">$(Esc-Xml $valStr)</value>"
|
||||||
}
|
}
|
||||||
@@ -1744,6 +1749,10 @@ function Parse-StructureShorthand {
|
|||||||
if ($seg -match '^(?i)(details|детали)$') {
|
if ($seg -match '^(?i)(details|детали)$') {
|
||||||
# Empty groupBy = detailed records
|
# Empty groupBy = detailed records
|
||||||
$group | Add-Member -NotePropertyName "groupBy" -NotePropertyValue @()
|
$group | Add-Member -NotePropertyName "groupBy" -NotePropertyValue @()
|
||||||
|
} elseif ($seg -match '^(.+)\[(.+)\]$') {
|
||||||
|
# Named group: "ИмяГруппы[Поле]"
|
||||||
|
$group | Add-Member -NotePropertyName "name" -NotePropertyValue $Matches[1].Trim()
|
||||||
|
$group | Add-Member -NotePropertyName "groupBy" -NotePropertyValue @($Matches[2].Trim())
|
||||||
} else {
|
} else {
|
||||||
$group | Add-Member -NotePropertyName "groupBy" -NotePropertyValue @($seg)
|
$group | Add-Member -NotePropertyName "groupBy" -NotePropertyValue @($seg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# skd-compile v1.4 — Compile 1C DCS from JSON
|
# skd-compile v1.5 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -702,6 +702,8 @@ def emit_param_value(lines, type_str, val, indent):
|
|||||||
lines.append(f'{indent}<value xsi:type="xs:dateTime">{esc_xml(val_str)}</value>')
|
lines.append(f'{indent}<value xsi:type="xs:dateTime">{esc_xml(val_str)}</value>')
|
||||||
elif val_str == 'true' or val_str == 'false':
|
elif val_str == 'true' or val_str == 'false':
|
||||||
lines.append(f'{indent}<value xsi:type="xs:boolean">{esc_xml(val_str)}</value>')
|
lines.append(f'{indent}<value xsi:type="xs:boolean">{esc_xml(val_str)}</value>')
|
||||||
|
elif re.match(r'^(ПланСчетов|Справочник|Перечисление|Документ|ПланВидовХарактеристик|ПланВидовРасчета|БизнесПроцесс|Задача|РегистрСведений|ПланОбмена|ChartOfAccounts|Catalog|Enum|Document|ChartOfCharacteristicTypes|ChartOfCalculationTypes|BusinessProcess|Task|InformationRegister|ExchangePlan)\.', val_str):
|
||||||
|
lines.append(f'{indent}<value xsi:type="dcscor:DesignTimeValue">{esc_xml(val_str)}</value>')
|
||||||
else:
|
else:
|
||||||
lines.append(f'{indent}<value xsi:type="xs:string">{esc_xml(val_str)}</value>')
|
lines.append(f'{indent}<value xsi:type="xs:string">{esc_xml(val_str)}</value>')
|
||||||
|
|
||||||
@@ -726,15 +728,18 @@ def emit_single_param(lines, p, parsed):
|
|||||||
# Value
|
# Value
|
||||||
emit_param_value(lines, parsed.get('type', ''), parsed.get('value'), '\t\t')
|
emit_param_value(lines, parsed.get('type', ''), parsed.get('value'), '\t\t')
|
||||||
|
|
||||||
|
# Hidden implies useRestriction=true + availableAsField=false
|
||||||
|
if parsed.get('hidden') is True:
|
||||||
|
parsed['availableAsField'] = False
|
||||||
|
parsed['useRestriction'] = True
|
||||||
|
|
||||||
# UseRestriction
|
# UseRestriction
|
||||||
if p is not None and not isinstance(p, str) and p.get('useRestriction') is True:
|
if parsed.get('useRestriction') is True or (p is not None and not isinstance(p, str) and p.get('useRestriction') is True):
|
||||||
lines.append('\t\t<useRestriction>true</useRestriction>')
|
lines.append('\t\t<useRestriction>true</useRestriction>')
|
||||||
|
|
||||||
# Expression
|
# Expression
|
||||||
if parsed.get('expression'):
|
if parsed.get('expression'):
|
||||||
lines.append(f'\t\t<expression>{esc_xml(parsed["expression"])}</expression>')
|
lines.append(f'\t\t<expression>{esc_xml(parsed["expression"])}</expression>')
|
||||||
|
|
||||||
# Hidden implies availableAsField=false
|
|
||||||
if parsed.get('hidden'):
|
if parsed.get('hidden'):
|
||||||
parsed['availableAsField'] = False
|
parsed['availableAsField'] = False
|
||||||
|
|
||||||
@@ -1461,7 +1466,13 @@ def parse_structure_shorthand(s):
|
|||||||
if re.match(r'(?i)^(details|\u0434\u0435\u0442\u0430\u043b\u0438)$', seg):
|
if re.match(r'(?i)^(details|\u0434\u0435\u0442\u0430\u043b\u0438)$', seg):
|
||||||
group['groupBy'] = []
|
group['groupBy'] = []
|
||||||
else:
|
else:
|
||||||
group['groupBy'] = [seg]
|
# Named group: "ИмяГруппы[Поле]"
|
||||||
|
m_named = re.match(r'^(.+)\[(.+)\]$', seg)
|
||||||
|
if m_named:
|
||||||
|
group['name'] = m_named.group(1).strip()
|
||||||
|
group['groupBy'] = [m_named.group(2).strip()]
|
||||||
|
else:
|
||||||
|
group['groupBy'] = [seg]
|
||||||
|
|
||||||
if innermost is not None:
|
if innermost is not None:
|
||||||
group['children'] = [innermost]
|
group['children'] = [innermost]
|
||||||
|
|||||||
Reference in New Issue
Block a user