mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-26 22:51:03 +03:00
feat(meta-validate): базовая проверка нераспознанных валидных типов + прощающий ввод плоских объектов (Фаза 1.4, v1.9)
20 валидных типов метаданных без глубоких правил (Subsystem/Role/CommonForm/ CommonCommand/CommandGroup/CommonAttribute/CommonTemplate/CommonPicture/ SessionParameter/SettingsStorage/FilterCriterion/FunctionalOption/ FunctionalOptionsParameter/Language/Style/StyleItem/WSReference/XDTOPackage/ DocumentNumerator/Sequence) раньше падали как "Unrecognized" + exit 1 — ложная ошибка на валидном объекте. Теперь для них базовая структурная проверка (root/uuid + Name-идентификатор) с ранним выходом, без type-specific правил. Имена типов взяты из LocalName реальных файлов корпуса. По-настоящему неизвестный тип по-прежнему отвергается. Побочно: прощающий ввод для плоских объектов (один .xml без папки — SessionParameter, CommonAttribute, DefinedType, ...) — раньше не находились по голому имени Dir/Name (fallback покрывал только папочные Dir/Name/Name.xml), добавлено дописывание .xml. Тесты (фикстуры не самописные): valid-sessionparameter-basic (meta-compile preRun) + real-erp-sessionparameter (external, скип на Mac) + error-unknown-type (реальный каталог корпуса с переименованным корневым тип-элементом). meta-validate 21/21 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
b9ed48ccf2
commit
9b5908c3b2
@@ -1,4 +1,4 @@
|
||||
# meta-validate v1.8 — Validate 1C metadata object structure
|
||||
# meta-validate v1.9 — Validate 1C metadata object structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -65,6 +65,12 @@ if (Test-Path $ObjectPath -PathType Container) {
|
||||
}
|
||||
}
|
||||
|
||||
# File not found — прощающий ввод для плоских объектов (SessionParameter, CommonAttribute,
|
||||
# DefinedType, WSReference, … — один .xml без папки): дописать .xml к голому имени
|
||||
if (-not (Test-Path $ObjectPath) -and -not [System.IO.Path]::HasExtension($ObjectPath)) {
|
||||
if (Test-Path "$ObjectPath.xml") { $ObjectPath = "$ObjectPath.xml" }
|
||||
}
|
||||
|
||||
# File not found — check Dir/Name/Name.xml → Dir/Name.xml
|
||||
if (-not (Test-Path $ObjectPath)) {
|
||||
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($ObjectPath)
|
||||
@@ -162,6 +168,15 @@ $validTypes = @(
|
||||
"HTTPService","WebService","DefinedType"
|
||||
)
|
||||
|
||||
# Валидные типы метаданных без глубоких правил валидации — раньше падали как "Unrecognized"
|
||||
# (ложная ошибка на валидном объекте). Для них выполняется базовая структурная проверка (root/uuid/Name).
|
||||
$structuralOnlyTypes = @(
|
||||
"Subsystem","Role","CommonForm","CommonCommand","CommandGroup","CommonAttribute",
|
||||
"CommonTemplate","CommonPicture","SessionParameter","SettingsStorage","FilterCriterion",
|
||||
"FunctionalOption","FunctionalOptionsParameter","Language","Style","StyleItem",
|
||||
"WSReference","XDTOPackage","DocumentNumerator","Sequence"
|
||||
)
|
||||
|
||||
# GeneratedType categories by type
|
||||
$generatedTypeCategories = @{
|
||||
"Catalog" = @("Object","Ref","Selection","List","Manager")
|
||||
@@ -355,7 +370,7 @@ if ($childElements.Count -eq 0) {
|
||||
$typeNode = $childElements[0]
|
||||
$mdType = $typeNode.LocalName
|
||||
|
||||
if ($validTypes -notcontains $mdType) {
|
||||
if (($validTypes -notcontains $mdType) -and ($structuralOnlyTypes -notcontains $mdType)) {
|
||||
Report-Error "1. Unrecognized metadata type: $mdType"
|
||||
& $finalize
|
||||
exit 1
|
||||
@@ -383,6 +398,20 @@ if ($check1Ok) {
|
||||
Report-OK "1. Root structure: MetaDataObject/$mdType, version $version"
|
||||
}
|
||||
|
||||
# --- Structural-only types: базовая проверка (Name), без type-specific правил ---
|
||||
if ($structuralOnlyTypes -contains $mdType) {
|
||||
if ($objName -eq "(unknown)") {
|
||||
Report-Error "3. Properties: missing or empty Name"
|
||||
} elseif ($objName -notmatch $identPattern) {
|
||||
Report-Error "3. Properties: Name '$objName' is not a valid 1C identifier"
|
||||
} else {
|
||||
Report-OK "3. Properties: Name=`"$objName`" (базовая структурная проверка для $mdType)"
|
||||
}
|
||||
& $finalize
|
||||
if ($script:errors -gt 0) { exit 1 }
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
|
||||
# --- Check 2: InternalInfo ---
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-validate v1.8 — Validate 1C metadata object structure (Python port)
|
||||
# meta-validate v1.9 — Validate 1C metadata object structure (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -70,6 +70,12 @@ if os.path.isdir(object_path):
|
||||
print(f"[ERROR] No XML file found in directory: {object_path}")
|
||||
sys.exit(1)
|
||||
|
||||
# File not found -- прощающий ввод для плоских объектов (SessionParameter, CommonAttribute,
|
||||
# DefinedType, WSReference, ... -- один .xml без папки): дописать .xml к голому имени
|
||||
if not os.path.exists(object_path) and not os.path.splitext(object_path)[1]:
|
||||
if os.path.exists(object_path + ".xml"):
|
||||
object_path = object_path + ".xml"
|
||||
|
||||
# File not found -- check Dir/Name/Name.xml -> Dir/Name.xml
|
||||
if not os.path.exists(object_path):
|
||||
file_name = os.path.splitext(os.path.basename(object_path))[0]
|
||||
@@ -162,6 +168,15 @@ valid_types = (
|
||||
"HTTPService", "WebService", "DefinedType",
|
||||
)
|
||||
|
||||
# Валидные типы метаданных без глубоких правил валидации — раньше падали как "Unrecognized"
|
||||
# (ложная ошибка на валидном объекте). Для них выполняется базовая структурная проверка (root/uuid/Name).
|
||||
structural_only_types = (
|
||||
"Subsystem", "Role", "CommonForm", "CommonCommand", "CommandGroup", "CommonAttribute",
|
||||
"CommonTemplate", "CommonPicture", "SessionParameter", "SettingsStorage", "FilterCriterion",
|
||||
"FunctionalOption", "FunctionalOptionsParameter", "Language", "Style", "StyleItem",
|
||||
"WSReference", "XDTOPackage", "DocumentNumerator", "Sequence",
|
||||
)
|
||||
|
||||
# GeneratedType categories by type
|
||||
generated_type_categories = {
|
||||
"Catalog": ["Object", "Ref", "Selection", "List", "Manager"],
|
||||
@@ -379,7 +394,7 @@ elif len(child_elements) > 1:
|
||||
type_node = child_elements[0]
|
||||
md_type = local_name(type_node)
|
||||
|
||||
if md_type not in valid_types:
|
||||
if md_type not in valid_types and md_type not in structural_only_types:
|
||||
report_error(f"1. Unrecognized metadata type: {md_type}")
|
||||
finalize()
|
||||
sys.exit(1)
|
||||
@@ -404,6 +419,17 @@ output_lines.insert(0, f"=== Validation: {md_type}.{obj_name} ===")
|
||||
if check1_ok:
|
||||
report_ok(f"1. Root structure: MetaDataObject/{md_type}, version {version}")
|
||||
|
||||
# ── Structural-only types: базовая проверка (Name), без type-specific правил ──
|
||||
if md_type in structural_only_types:
|
||||
if obj_name == "(unknown)":
|
||||
report_error("3. Properties: missing or empty Name")
|
||||
elif not ident_pattern.match(obj_name):
|
||||
report_error(f"3. Properties: Name '{obj_name}' is not a valid 1C identifier")
|
||||
else:
|
||||
report_ok(f'3. Properties: Name="{obj_name}" (базовая структурная проверка для {md_type})')
|
||||
finalize()
|
||||
sys.exit(1 if errors > 0 else 0)
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user