mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-27 07:01:02 +03:00
fix(meta-compile,meta-edit,meta-validate): strict enum validation + fix RequireCalculationTypes
Normalize-EnumValue now uses 4-step logic: alias→case-insensitive→ error (if propName known)→pass-through (if unknown). Previously step 3 silently passed invalid values through to XML, causing cryptic 1C LoadConfigFromFiles errors. Also fixed RequireCalculationTypes→OnActionPeriod (the former never existed in 1C; verified against ERP/ACC dumps). Added NotUsed→DontUse alias, synced meta-edit.ps1 aliases with meta-compile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d1e770c843
commit
63de8bd27c
@@ -1,4 +1,4 @@
|
||||
# meta-edit v1.5 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts)
|
||||
# meta-edit v1.6 — 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,
|
||||
@@ -48,47 +48,65 @@ $script:enumValueAliases = @{
|
||||
"Balances" = "Balance"; "Остатки" = "Balance"; "Обороты" = "Turnovers"
|
||||
"RecordSubordinate" = "RecorderSubordinate"; "Subordinate" = "RecorderSubordinate"
|
||||
"ПодчинениеРегистратору" = "RecorderSubordinate"; "Независимый" = "Independent"
|
||||
"NotDependOnCalculationTypes" = "DontUse"; "NoDependence" = "DontUse"
|
||||
"NotDependOnCalculationTypes" = "DontUse"; "NoDependence" = "DontUse"; "NotUsed" = "DontUse"
|
||||
"Depend" = "OnActionPeriod"; "ПоПериодуДействия" = "OnActionPeriod"
|
||||
"None" = "Nonperiodical"; "Daily" = "Day"; "Monthly" = "Month"
|
||||
"Quarterly" = "Quarter"; "Yearly" = "Year"
|
||||
"Непериодический" = "Nonperiodical"; "День" = "Day"; "Месяц" = "Month"
|
||||
"Непериодический" = "Nonperiodical"; "Секунда" = "Second"; "День" = "Day"; "Месяц" = "Month"
|
||||
"Квартал" = "Quarter"; "Год" = "Year"
|
||||
"ПозицияРегистратора" = "RecorderPosition"
|
||||
"Автоматический" = "Automatic"; "Управляемый" = "Managed"
|
||||
"Использовать" = "Use"; "НеИспользовать" = "DontUse"
|
||||
"Разрешить" = "Allow"; "Запретить" = "Deny"
|
||||
"ВДиалоге" = "InDialog"; "ВСписке" = "InList"; "ОбаСпособа" = "BothWays"
|
||||
"ВВидеНаименования" = "AsDescription"; "ВВидеКода" = "AsCode"
|
||||
"НеПроверять" = "DontCheck"; "Ошибка" = "ShowError"; "Предупреждение" = "ShowWarning"
|
||||
"НеИндексировать" = "DontIndex"; "Индексировать" = "Index"
|
||||
"ИндексироватьСДопУпорядочиванием" = "IndexWithAdditionalOrder"
|
||||
}
|
||||
|
||||
$script:validEnumValues = @{
|
||||
"RegisterType" = @("Balance","Turnovers")
|
||||
"WriteMode" = @("Independent","RecorderSubordinate")
|
||||
"RegisterType" = @("Balance","Turnovers")
|
||||
"WriteMode" = @("Independent","RecorderSubordinate")
|
||||
"InformationRegisterPeriodicity" = @("Nonperiodical","Second","Day","Month","Quarter","Year","RecorderPosition")
|
||||
"DependenceOnCalculationTypes" = @("DontUse","RequireCalculationTypes")
|
||||
"DataLockControlMode" = @("Automatic","Managed")
|
||||
"FullTextSearch" = @("Use","DontUse")
|
||||
"DataHistory" = @("Use","DontUse")
|
||||
"DefaultPresentation" = @("AsDescription","AsCode")
|
||||
"Posting" = @("Allow","Deny")
|
||||
"RealTimePosting" = @("Allow","Deny")
|
||||
"EditType" = @("InDialog","InList","BothWays")
|
||||
"HierarchyType" = @("HierarchyFoldersAndItems","HierarchyItemsOnly")
|
||||
"FillChecking" = @("DontCheck","ShowError","ShowWarning")
|
||||
"Indexing" = @("DontIndex","Index","IndexWithAdditionalOrder")
|
||||
"DependenceOnCalculationTypes" = @("DontUse","OnActionPeriod")
|
||||
"DataLockControlMode" = @("Automatic","Managed")
|
||||
"FullTextSearch" = @("Use","DontUse")
|
||||
"DataHistory" = @("Use","DontUse")
|
||||
"DefaultPresentation" = @("AsDescription","AsCode")
|
||||
"Posting" = @("Allow","Deny")
|
||||
"RealTimePosting" = @("Allow","Deny")
|
||||
"EditType" = @("InDialog","InList","BothWays")
|
||||
"HierarchyType" = @("HierarchyFoldersAndItems","HierarchyItemsOnly")
|
||||
"CodeType" = @("String","Number")
|
||||
"CodeAllowedLength" = @("Variable","Fixed")
|
||||
"NumberType" = @("String","Number")
|
||||
"NumberAllowedLength" = @("Variable","Fixed")
|
||||
"RegisterRecordsDeletion" = @("AutoDelete","AutoDeleteOnUnpost","AutoDeleteOff")
|
||||
"RegisterRecordsWritingOnPost" = @("WriteModified","WriteSelected","WriteAll")
|
||||
"ReturnValuesReuse" = @("DontUse","DuringRequest","DuringSession")
|
||||
"ReuseSessions" = @("DontUse","AutoUse")
|
||||
"FillChecking" = @("DontCheck","ShowError","ShowWarning")
|
||||
"Indexing" = @("DontIndex","Index","IndexWithAdditionalOrder")
|
||||
}
|
||||
|
||||
function Normalize-EnumValue {
|
||||
param([string]$propName, [string]$value)
|
||||
# 1. Check alias dictionary — silent auto-correct
|
||||
if ($script:enumValueAliases.ContainsKey($value)) {
|
||||
return $script:enumValueAliases[$value]
|
||||
}
|
||||
# 2. Case-insensitive match against valid values — silent
|
||||
$valid = $script:validEnumValues[$propName]
|
||||
if ($valid) {
|
||||
foreach ($v in $valid) {
|
||||
if ($v -ieq $value) { return $v }
|
||||
}
|
||||
# 3. Known property, unknown value — error with hint
|
||||
Write-Error "Invalid value '$value' for property '$propName'. Valid values: $($valid -join ', ')"
|
||||
exit 1
|
||||
}
|
||||
# 4. Unknown property — pass-through (no validation data)
|
||||
return $value
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user