feat(meta-compile): support composite types and fix d5p1 namespace

- Add composite type support via + separator in Emit-TypeContent (PS/PY)
- Fix reference types: cfg: → d5p1: with local xmlns declaration
  in Emit-TypeContent, valueTypes loop, EventSubscription source
- Fix lxml stripping xmlns:d5p1 in meta-edit.py save_xml (post-process)
- Fix IndentationError in meta-compile.py and meta-validate.py
- Document composite type syntax in SKILL.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-05 12:00:09 +03:00
parent 4490aeb533
commit fde6d346d7
5 changed files with 34 additions and 10 deletions
+2
View File
@@ -69,6 +69,8 @@ Constant (Константа), DefinedType (ОпределяемыйТип), Com
Русские синонимы типов: `Строка`, `Число`, `Булево`, `Дата`, `СправочникСсылка.Xxx`, `ДокументСсылка.Xxx`, `ПланСчетовСсылка.Xxx`.
Составной тип (несколько допустимых типов через `+`): `"Значение: Строка + Число(15,2) + Дата + CatalogRef.Контрагенты"`.
Флаги: `req`, `index`, `indexAdditional`, `nonneg`, `master`, `mainFilter`, `denyIncomplete`, `useInTotals`.
## Примеры
@@ -198,6 +198,15 @@ function Emit-TypeContent {
param([string]$indent, [string]$typeStr)
if (-not $typeStr) { return }
# Composite type: "Type1 + Type2 + Type3"
if ($typeStr.Contains(' + ')) {
$parts = $typeStr -split '\s*\+\s*'
foreach ($part in $parts) {
Emit-TypeContent $indent $part.Trim()
}
return
}
$typeStr = Resolve-TypeStr $typeStr
# Boolean
@@ -254,9 +263,9 @@ function Emit-TypeContent {
return
}
# Reference types: CatalogRef.XXX, DocumentRef.XXX, etc.
# Reference types — use local xmlns declaration for 1C compatibility
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$') {
X "$indent<v8:Type>cfg:$typeStr</v8:Type>"
X "$indent<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$typeStr</v8:Type>"
return
}
@@ -1237,7 +1246,7 @@ function Emit-DefinedTypeProperties {
foreach ($vt in $valueTypes) {
$resolved = Resolve-TypeStr "$vt"
if ($resolved -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.') {
X "$i`t<v8:Type>cfg:$resolved</v8:Type>"
X "$i`t<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$resolved</v8:Type>"
} elseif ($resolved -eq "Boolean") {
X "$i`t<v8:Type>xs:boolean</v8:Type>"
} elseif ($resolved -match '^String') {
@@ -1342,7 +1351,7 @@ function Emit-EventSubscriptionProperties {
X "$i<Source>"
foreach ($src in $sources) {
$resolved = Resolve-TypeStr "$src"
X "$i`t<v8:Type>cfg:$resolved</v8:Type>"
X "$i`t<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$resolved</v8:Type>"
}
X "$i</Source>"
} else {
@@ -11,7 +11,7 @@ import uuid
import xml.etree.ElementTree as ET
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
# ---------------------------------------------------------------------------
# Inline utilities
@@ -207,6 +207,12 @@ def resolve_type_str(type_str):
def emit_type_content(indent, type_str):
if not type_str:
return
# Composite type: "Type1 + Type2 + Type3"
if ' + ' in type_str:
parts = [p.strip() for p in type_str.split('+')]
for part in parts:
emit_type_content(indent, part)
return
type_str = resolve_type_str(type_str)
# Boolean
if type_str == 'Boolean':
@@ -254,10 +260,10 @@ def emit_type_content(indent, type_str):
dt_name = m.group(1)
X(f'{indent}<v8:TypeSet>cfg:DefinedType.{dt_name}</v8:TypeSet>')
return
# Reference types
# Reference types — use local xmlns declaration for 1C compatibility
m = re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$', type_str)
if m:
X(f'{indent}<v8:Type>cfg:{type_str}</v8:Type>')
X(f'{indent}<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{type_str}</v8:Type>')
return
# Fallback
X(f'{indent}<v8:Type>{type_str}</v8:Type>')
@@ -1066,7 +1072,7 @@ def emit_defined_type_properties(indent):
for vt in value_types:
resolved = resolve_type_str(str(vt))
if re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.', resolved):
X(f'{i}\t<v8:Type>cfg:{resolved}</v8:Type>')
X(f'{i}\t<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{resolved}</v8:Type>')
elif resolved == 'Boolean':
X(f'{i}\t<v8:Type>xs:boolean</v8:Type>')
elif re.match(r'^String', resolved):
@@ -1155,7 +1161,7 @@ def emit_event_subscription_properties(indent):
X(f'{i}<Source>')
for src in sources:
resolved = resolve_type_str(str(src))
X(f'{i}\t<v8:Type>cfg:{resolved}</v8:Type>')
X(f'{i}\t<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{resolved}</v8:Type>')
X(f'{i}</Source>')
else:
X(f'{i}<Source/>')
@@ -1971,6 +1971,13 @@ def save_xml(tree, path):
xml_bytes = etree.tostring(tree, xml_declaration=True, encoding="UTF-8")
# Fix encoding quotes: encoding='UTF-8' -> encoding="UTF-8"
xml_bytes = xml_bytes.replace(b"encoding='UTF-8'", b'encoding="UTF-8"')
# Fix d5p1 namespace declarations stripped by lxml (it treats them as unused
# because d5p1: appears only in text content, not in element/attribute names)
xml_bytes = re.sub(
b'(<v8:Type)(?! xmlns:d5p1)(>d5p1:)',
b'\\1 xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config"\\2',
xml_bytes
)
with open(path, "wb") as f:
f.write(b"\xef\xbb\xbf")
f.write(xml_bytes)
@@ -8,7 +8,7 @@ import sys
from lxml import etree
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
# ── arg parsing ──────────────────────────────────────────────