mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-07 20:20:20 +03:00
fix(meta-compile,meta-edit): sync type handling and validation between scripts
meta-compile: bare Number→Number(10,0), ValueStorage→xs:base64Binary, lowercase ref synonyms (catalogref, documentref, enumref). meta-edit: bare String default 0→10, reserved attribute name warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
843916642c
commit
72a4015a8d
@@ -297,7 +297,7 @@ function Build-TypeContentXml {
|
||||
|
||||
# String or String(N)
|
||||
if ($typeStr -match '^String(\((\d+)\))?$') {
|
||||
$len = if ($Matches[2]) { $Matches[2] } else { "0" }
|
||||
$len = if ($Matches[2]) { $Matches[2] } else { "10" }
|
||||
$sb.AppendLine("$indent<v8:Type>xs:string</v8:Type>") | Out-Null
|
||||
$sb.AppendLine("$indent<v8:StringQualifiers>") | Out-Null
|
||||
$sb.AppendLine("$indent`t<v8:Length>$len</v8:Length>") | Out-Null
|
||||
@@ -689,10 +689,34 @@ function Get-AttributeContext {
|
||||
}
|
||||
}
|
||||
|
||||
$script: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"="ПериодДействияБазовый"
|
||||
}
|
||||
|
||||
function Build-AttributeFragment {
|
||||
param($parsed, [string]$context, [string]$indent)
|
||||
|
||||
if (-not $context) { $context = Get-AttributeContext }
|
||||
|
||||
# Check reserved attribute names
|
||||
$attrName = $parsed.name
|
||||
if ($script:reservedAttrNames.ContainsKey($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
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ def build_type_content_xml(indent, type_str):
|
||||
# String or String(N)
|
||||
m = re.match(r"^String(\((\d+)\))?$", type_str)
|
||||
if m:
|
||||
length = m.group(2) if m.group(2) else "0"
|
||||
length = m.group(2) if m.group(2) else "10"
|
||||
lines.append(f"{indent}<v8:Type>xs:string</v8:Type>")
|
||||
lines.append(f"{indent}<v8:StringQualifiers>")
|
||||
lines.append(f"{indent}\t<v8:Length>{length}</v8:Length>")
|
||||
@@ -600,10 +600,38 @@ def get_attribute_context():
|
||||
return "object"
|
||||
|
||||
|
||||
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_ATTR_NAMES_RU = {
|
||||
'Ссылка', 'ПометкаУдаления', 'Код', 'Наименование',
|
||||
'Дата', 'Номер', 'Проведен', 'Родитель', 'Владелец',
|
||||
'ЭтоГруппа', 'Предопределенный', 'ИмяПредопределенныхДанных',
|
||||
'Регистратор', 'Период', 'НомерСтроки', 'Активность',
|
||||
'Порядок', 'Тип', 'Забалансовый',
|
||||
'Стартован', 'Завершен', 'ВедущаяЗадача',
|
||||
'Выполнена', 'ТочкаМаршрута', 'БизнесПроцесс',
|
||||
'ЭтотУзел', 'НомерОтправленного', 'НомерПринятого',
|
||||
'ВидРасчета', 'ПериодРегистрации', 'СторноЗапись',
|
||||
'Счет', 'ТипЗначения', 'ПериодДействияБазовый',
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
attr_name = parsed['name']
|
||||
if 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()
|
||||
lines = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user