mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-07 02:30:53 +03:00
fix(form-compile): лояльно стрипать cfg: префикс главного реквизита
Раньше тип `cfg:CatalogObject.X` мимо regex попадал в fallback и получал второй `cfg:` поверх → `cfg:cfg:...`, db-load-xml падал. Теперь Resolve-TypeStr срезает ведущий `cfg:` сразу, обе формы записи валидны. Заодно сообщение об ошибке FormDataStructure согласовано с примером — без префикса. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
42b96bbd21
commit
433a2955b5
@@ -1,4 +1,4 @@
|
|||||||
# form-compile v1.6 — Compile 1C managed form from JSON or object metadata
|
# form-compile v1.7 — Compile 1C managed form from JSON or object metadata
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$JsonPath,
|
[string]$JsonPath,
|
||||||
@@ -1554,7 +1554,7 @@ $script:formTypeSynonyms["определяемыйтип"] = "Define
|
|||||||
|
|
||||||
# Known invalid types (runtime/UI types that don't exist in XDTO schema)
|
# Known invalid types (runtime/UI types that don't exist in XDTO schema)
|
||||||
$script:knownInvalidTypes = @{
|
$script:knownInvalidTypes = @{
|
||||||
"FormDataStructure" = "Runtime type. Use cfg:*Object.XXX (e.g. CatalogObject.XXX)"
|
"FormDataStructure" = "Runtime type. Use object type without cfg: prefix (e.g. CatalogObject.Контрагенты, DocumentObject.Приход)"
|
||||||
"FormDataCollection" = "Runtime type. Use ValueTable"
|
"FormDataCollection" = "Runtime type. Use ValueTable"
|
||||||
"FormDataTree" = "Runtime type. Use ValueTree"
|
"FormDataTree" = "Runtime type. Use ValueTree"
|
||||||
"FormDataTreeItem" = "Runtime type, not valid in XML"
|
"FormDataTreeItem" = "Runtime type, not valid in XML"
|
||||||
@@ -1569,6 +1569,8 @@ $script:knownInvalidTypes = @{
|
|||||||
function Resolve-TypeStr {
|
function Resolve-TypeStr {
|
||||||
param([string]$typeStr)
|
param([string]$typeStr)
|
||||||
if (-not $typeStr) { return $typeStr }
|
if (-not $typeStr) { return $typeStr }
|
||||||
|
# Lenient: strip leading cfg: prefix if user passed it (canonical form is without prefix)
|
||||||
|
if ($typeStr -match '^cfg:(.+)$') { $typeStr = $Matches[1] }
|
||||||
if ($typeStr -match '^([^(]+)\((.+)\)$') {
|
if ($typeStr -match '^([^(]+)\((.+)\)$') {
|
||||||
$base = $Matches[1].Trim(); $params = $Matches[2]
|
$base = $Matches[1].Trim(); $params = $Matches[2]
|
||||||
$r = $script:formTypeSynonyms[$base.ToLower()]
|
$r = $script:formTypeSynonyms[$base.ToLower()]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# form-compile v1.6 — Compile 1C managed form from JSON or object metadata
|
# form-compile v1.7 — Compile 1C managed form from JSON or object metadata
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import copy
|
import copy
|
||||||
@@ -1455,7 +1455,7 @@ CFG_REF_PATTERN = re.compile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
KNOWN_INVALID_TYPES = {
|
KNOWN_INVALID_TYPES = {
|
||||||
'FormDataStructure': 'Runtime type. Use cfg:*Object.XXX (e.g. CatalogObject.XXX)',
|
'FormDataStructure': 'Runtime type. Use object type without cfg: prefix (e.g. CatalogObject.Контрагенты, DocumentObject.Приход)',
|
||||||
'FormDataCollection': 'Runtime type. Use ValueTable',
|
'FormDataCollection': 'Runtime type. Use ValueTable',
|
||||||
'FormDataTree': 'Runtime type. Use ValueTree',
|
'FormDataTree': 'Runtime type. Use ValueTree',
|
||||||
'FormDataTreeItem': 'Runtime type, not valid in XML',
|
'FormDataTreeItem': 'Runtime type, not valid in XML',
|
||||||
@@ -1489,6 +1489,9 @@ _FORM_TYPE_SYNONYMS = {
|
|||||||
def resolve_type_str(type_str):
|
def resolve_type_str(type_str):
|
||||||
if not type_str:
|
if not type_str:
|
||||||
return type_str
|
return type_str
|
||||||
|
# Lenient: strip leading cfg: prefix if user passed it (canonical form is without prefix)
|
||||||
|
if type_str.startswith('cfg:'):
|
||||||
|
type_str = type_str[4:]
|
||||||
m = re.match(r'^([^(]+)\((.+)\)$', type_str)
|
m = re.match(r'^([^(]+)\((.+)\)$', type_str)
|
||||||
if m:
|
if m:
|
||||||
base, params = m.group(1).strip(), m.group(2)
|
base, params = m.group(1).strip(), m.group(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user