mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-25 06:01:02 +03:00
feat(meta-edit,meta-validate): типозависимый отказ на зарезервированные имена реквизитов
Имя собственного реквизита, совпадающее со стандартным (англ. ИЛИ рус., регистронезависимо), платформа не примет — теперь жёсткий отказ вместо предупреждения (как в meta-compile). meta-edit: reservedByContext (catalog/document) в Build-AttributeFragment; прочие контексты — прежнее предупреждение, реквизиты ТЧ не проверяются. meta-validate Check 7b: было плоско и только по англ. именам с Warn — стало типозависимо через standardAttributesByType, EN+RU, Report-Error. Проверка типозависима: «Номер» — легальный реквизит справочника (стандартный только у документа). Негативные кейсы error-reserved-attr (meta-edit + meta-validate с фикстурой). Регресс 11/11 и 13/13 ps1+py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c2703f043f
commit
d007da5eb8
@@ -1,4 +1,4 @@
|
||||
# meta-edit v1.9 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts)
|
||||
# meta-edit v1.10 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -890,20 +890,33 @@ $script:reservedAttrNames = @{
|
||||
"Account"="Счет"; "ValueType"="ТипЗначения"; "ActionPeriodIsBasic"="ПериодДействияБазовый"
|
||||
}
|
||||
|
||||
# Стандартные реквизиты по типу объекта (ключи из reservedAttrNames). Имя реквизита, совпадающее
|
||||
# с ними (англ. ИЛИ рус.), платформа не позволит — жёсткий отказ. Контексты вне карты → предупреждение.
|
||||
$script:reservedByContext = @{
|
||||
"catalog" = @("Ref","DeletionMark","Predefined","PredefinedDataName","Code","Description","Owner","Parent","IsFolder")
|
||||
"document" = @("Ref","DeletionMark","Date","Number","Posted")
|
||||
}
|
||||
|
||||
function Build-AttributeFragment {
|
||||
param($parsed, [string]$context, [string]$indent)
|
||||
|
||||
if (-not $context) { $context = Get-AttributeContext }
|
||||
|
||||
# Check reserved attribute names
|
||||
# Check reserved attribute names (типозависимо: catalog/document — жёсткий отказ; прочее — предупреждение)
|
||||
$attrName = $parsed.name
|
||||
if ($script:reservedAttrNames.ContainsKey($attrName)) {
|
||||
$ctxReserved = $script:reservedByContext[$context]
|
||||
if ($ctxReserved) {
|
||||
foreach ($en in $ctxReserved) {
|
||||
$ru = $script:reservedAttrNames[$en]
|
||||
if (($attrName -ieq $en) -or ($ru -and $attrName -ieq $ru)) {
|
||||
Write-Error "Имя реквизита '$attrName' зарезервировано стандартным реквизитом ($en/$ru) объекта '$context'. Выберите другое имя."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
} elseif ($context -notin @("tabular", "processor-tabular") -and
|
||||
($script:reservedAttrNames.ContainsKey($attrName) -or ($script:reservedAttrNames.Values -contains $attrName))) {
|
||||
Write-Warning "Attribute '$attrName' conflicts with a standard attribute name. This may cause errors when loading into 1C."
|
||||
}
|
||||
$ruValues = $script:reservedAttrNames.Values
|
||||
if ($ruValues -contains $attrName) {
|
||||
Write-Warning "Attribute '$attrName' conflicts with a standard attribute name (Russian). This may cause errors when loading into 1C."
|
||||
}
|
||||
|
||||
$uuid = New-Guid-String
|
||||
$sb = New-Object System.Text.StringBuilder
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# meta-edit v1.9 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts)
|
||||
# meta-edit v1.10 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
@@ -861,14 +861,43 @@ RESERVED_ATTR_NAMES_RU = {
|
||||
}
|
||||
|
||||
|
||||
# Стандартные реквизиты по типу объекта (EN + RU). Совпадение имени реквизита с ними платформа
|
||||
# не позволит — жёсткий отказ. Контексты вне карты → предупреждение по плоскому списку.
|
||||
RESERVED_BY_CONTEXT = {
|
||||
'catalog': {
|
||||
'ref', 'ссылка',
|
||||
'deletionmark', 'пометкаудаления',
|
||||
'predefined', 'предопределенный',
|
||||
'predefineddataname', 'имяпредопределенныхданных',
|
||||
'code', 'код',
|
||||
'description', 'наименование',
|
||||
'owner', 'владелец',
|
||||
'parent', 'родитель',
|
||||
'isfolder', 'этогруппа',
|
||||
},
|
||||
'document': {
|
||||
'ref', 'ссылка',
|
||||
'deletionmark', 'пометкаудаления',
|
||||
'date', 'дата',
|
||||
'number', 'номер',
|
||||
'posted', 'проведен',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def build_attribute_fragment(parsed, context, indent):
|
||||
"""Build XML fragment string for an Attribute element."""
|
||||
if not context:
|
||||
context = get_attribute_context()
|
||||
|
||||
# Check reserved attribute names
|
||||
# Check reserved attribute names (типозависимо: catalog/document — отказ; прочее — предупреждение)
|
||||
attr_name = parsed['name']
|
||||
if attr_name in RESERVED_ATTR_NAMES or attr_name in RESERVED_ATTR_NAMES_RU:
|
||||
ctx_reserved = RESERVED_BY_CONTEXT.get(context)
|
||||
if ctx_reserved is not None:
|
||||
if attr_name.lower() in ctx_reserved:
|
||||
print(f"meta-edit: имя реквизита '{attr_name}' зарезервировано стандартным реквизитом объекта '{context}'. Выберите другое имя.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
elif context not in ('tabular', 'processor-tabular') and (attr_name in RESERVED_ATTR_NAMES or attr_name in RESERVED_ATTR_NAMES_RU):
|
||||
print(f"WARNING: Attribute '{attr_name}' conflicts with a standard attribute name. This may cause errors when loading into 1C.", file=sys.stderr)
|
||||
|
||||
uid = new_uuid()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-validate v1.4 — Validate 1C metadata object structure
|
||||
# meta-validate v1.5 — Validate 1C metadata object structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -699,17 +699,31 @@ if ($childObjNode) {
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
|
||||
# --- Check 7b: Reserved attribute names ---
|
||||
# --- Check 7b: Reserved attribute names (типозависимо: стандартные реквизиты ДАННОГО типа, EN+RU) ---
|
||||
# Совпадение имени собственного реквизита со стандартным (англ. или рус.) платформа не примет → ошибка.
|
||||
|
||||
$reservedAttrNames = @(
|
||||
"Ref","DeletionMark","Code","Description","Date","Number","Posted","Parent","Owner",
|
||||
"IsFolder","Predefined","PredefinedDataName","Recorder","Period","LineNumber","Active",
|
||||
"Order","Type","OffBalance","Started","Completed","HeadTask","Executed","RoutePoint",
|
||||
"BusinessProcess","ThisNode","SentNo","ReceivedNo","CalculationType","RegistrationPeriod",
|
||||
"ReversingEntry","Account","ValueType","ActionPeriodIsBasic"
|
||||
)
|
||||
$reservedEnRu = @{
|
||||
"Ref"="Ссылка"; "DeletionMark"="ПометкаУдаления"; "Code"="Код"; "Description"="Наименование"
|
||||
"Date"="Дата"; "Number"="Номер"; "Posted"="Проведен"; "Parent"="Родитель"; "Owner"="Владелец"
|
||||
"IsFolder"="ЭтоГруппа"; "Predefined"="Предопределенный"; "PredefinedDataName"="ИмяПредопределенныхДанных"
|
||||
"Recorder"="Регистратор"; "Period"="Период"; "LineNumber"="НомерСтроки"; "Active"="Активность"
|
||||
"Order"="Порядок"; "Type"="Тип"; "OffBalance"="Забалансовый"; "RecordType"="ВидДвижения"
|
||||
"Started"="Стартован"; "Completed"="Завершен"; "HeadTask"="ВедущаяЗадача"
|
||||
"Executed"="Выполнена"; "RoutePoint"="ТочкаМаршрута"; "BusinessProcess"="БизнесПроцесс"
|
||||
"ThisNode"="ЭтотУзел"; "SentNo"="НомерОтправленного"; "ReceivedNo"="НомерПринятого"
|
||||
"CalculationType"="ВидРасчета"; "RegistrationPeriod"="ПериодРегистрации"; "ReversingEntry"="СторноЗапись"
|
||||
"Account"="Счет"; "ValueType"="ТипЗначения"; "ActionPeriodIsBasic"="ПериодДействияБазовый"
|
||||
}
|
||||
|
||||
if ($childObjNode) {
|
||||
$stdForType = $standardAttributesByType[$mdType]
|
||||
if ($childObjNode -and $stdForType) {
|
||||
# Множество зарезервированных имён (EN + RU) в нижнем регистре.
|
||||
$reservedSet = @{}
|
||||
foreach ($en in $stdForType) {
|
||||
$reservedSet[$en.ToLower()] = $true
|
||||
$ru = $reservedEnRu[$en]
|
||||
if ($ru) { $reservedSet[$ru.ToLower()] = $true }
|
||||
}
|
||||
$check7bOk = $true
|
||||
$attrNodes = $childObjNode.SelectNodes("md:Attribute", $ns)
|
||||
foreach ($attrNode in $attrNodes) {
|
||||
@@ -718,8 +732,8 @@ if ($childObjNode) {
|
||||
$attrNameNode = $attrProps.SelectSingleNode("md:Name", $ns)
|
||||
if ($attrNameNode -and $attrNameNode.InnerText) {
|
||||
$an = $attrNameNode.InnerText
|
||||
if ($reservedAttrNames -contains $an) {
|
||||
Report-Warn "7b. Attribute '$an' conflicts with a standard attribute name"
|
||||
if ($reservedSet.ContainsKey($an.ToLower())) {
|
||||
Report-Error "7b. Attribute '$an' conflicts with a standard attribute of $mdType"
|
||||
$check7bOk = $false
|
||||
}
|
||||
}
|
||||
@@ -728,6 +742,8 @@ if ($childObjNode) {
|
||||
if ($check7bOk) {
|
||||
Report-OK "7b. Reserved attribute names: no conflicts"
|
||||
}
|
||||
} elseif ($childObjNode) {
|
||||
Report-OK "7b. Reserved attribute names: no conflicts (no standard set for $mdType)"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-validate v1.4 — Validate 1C metadata object structure (Python port)
|
||||
# meta-validate v1.5 — Validate 1C metadata object structure (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -676,18 +676,30 @@ if stopped:
|
||||
finalize()
|
||||
sys.exit(1)
|
||||
|
||||
# ── Check 7b: Reserved attribute names ───────────────────────
|
||||
# ── Check 7b: Reserved attribute names (типозависимо: стандартные ДАННОГО типа, EN+RU) ───────
|
||||
# Совпадение имени собственного реквизита со стандартным (англ. или рус.) платформа не примет → ошибка.
|
||||
|
||||
RESERVED_ATTR_NAMES = {
|
||||
'Ref', 'DeletionMark', 'Code', 'Description', 'Date', 'Number', 'Posted',
|
||||
'Parent', 'Owner', 'IsFolder', 'Predefined', 'PredefinedDataName',
|
||||
'Recorder', 'Period', 'LineNumber', 'Active', 'Order', 'Type', 'OffBalance',
|
||||
'Started', 'Completed', 'HeadTask', 'Executed', 'RoutePoint', 'BusinessProcess',
|
||||
'ThisNode', 'SentNo', 'ReceivedNo', 'CalculationType', 'RegistrationPeriod',
|
||||
'ReversingEntry', 'Account', 'ValueType', 'ActionPeriodIsBasic',
|
||||
RESERVED_EN_RU = {
|
||||
'Ref': 'Ссылка', 'DeletionMark': 'ПометкаУдаления', 'Code': 'Код', 'Description': 'Наименование',
|
||||
'Date': 'Дата', 'Number': 'Номер', 'Posted': 'Проведен', 'Parent': 'Родитель', 'Owner': 'Владелец',
|
||||
'IsFolder': 'ЭтоГруппа', 'Predefined': 'Предопределенный', 'PredefinedDataName': 'ИмяПредопределенныхДанных',
|
||||
'Recorder': 'Регистратор', 'Period': 'Период', 'LineNumber': 'НомерСтроки', 'Active': 'Активность',
|
||||
'Order': 'Порядок', 'Type': 'Тип', 'OffBalance': 'Забалансовый', 'RecordType': 'ВидДвижения',
|
||||
'Started': 'Стартован', 'Completed': 'Завершен', 'HeadTask': 'ВедущаяЗадача',
|
||||
'Executed': 'Выполнена', 'RoutePoint': 'ТочкаМаршрута', 'BusinessProcess': 'БизнесПроцесс',
|
||||
'ThisNode': 'ЭтотУзел', 'SentNo': 'НомерОтправленного', 'ReceivedNo': 'НомерПринятого',
|
||||
'CalculationType': 'ВидРасчета', 'RegistrationPeriod': 'ПериодРегистрации', 'ReversingEntry': 'СторноЗапись',
|
||||
'Account': 'Счет', 'ValueType': 'ТипЗначения', 'ActionPeriodIsBasic': 'ПериодДействияБазовый',
|
||||
}
|
||||
|
||||
if child_obj_node is not None:
|
||||
std_for_type = standard_attributes_by_type.get(md_type)
|
||||
if child_obj_node is not None and std_for_type:
|
||||
reserved_set = set()
|
||||
for en in std_for_type:
|
||||
reserved_set.add(en.lower())
|
||||
ru = RESERVED_EN_RU.get(en)
|
||||
if ru:
|
||||
reserved_set.add(ru.lower())
|
||||
check7b_ok = True
|
||||
for attr_node in find_all(child_obj_node, 'md:Attribute'):
|
||||
attr_props = find(attr_node, 'md:Properties')
|
||||
@@ -695,11 +707,13 @@ if child_obj_node is not None:
|
||||
attr_name_node = find(attr_props, 'md:Name')
|
||||
if attr_name_node is not None and inner_text(attr_name_node):
|
||||
an = inner_text(attr_name_node)
|
||||
if an in RESERVED_ATTR_NAMES:
|
||||
report_warn(f"7b. Attribute '{an}' conflicts with a standard attribute name")
|
||||
if an.lower() in reserved_set:
|
||||
report_error(f"7b. Attribute '{an}' conflicts with a standard attribute of {md_type}")
|
||||
check7b_ok = False
|
||||
if check7b_ok:
|
||||
report_ok("7b. Reserved attribute names: no conflicts")
|
||||
elif child_obj_node is not None:
|
||||
report_ok(f"7b. Reserved attribute names: no conflicts (no standard set for {md_type})")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
|
||||
Reference in New Issue
Block a user