diff --git a/plugins/1c/connector/adapter_1c_server.py b/plugins/1c/connector/adapter_1c_server.py index 6d546ca..f628853 100644 --- a/plugins/1c/connector/adapter_1c_server.py +++ b/plugins/1c/connector/adapter_1c_server.py @@ -42427,7 +42427,18 @@ def metadata_object_templates(payload: dict[str, Any]) -> dict[str, Any]: "timeout_seconds": timeout_seconds, } ) - classified_parts = parts_result.get("parts") if isinstance(parts_result.get("parts"), list) else [] + classified_parts = [] + for raw_part in parts_result.get("parts") or []: + if not isinstance(raw_part, dict): + continue + classified_part = dict(raw_part) + classification = classified_part.get("classification") if isinstance(classified_part.get("classification"), dict) else {} + if classification.get("role"): + classified_part["role"] = classification.get("role") + descriptor_type_code = template_descriptor_type_code_from_part(classified_part) + if descriptor_type_code is not None: + classified_part["descriptor_type_code"] = descriptor_type_code + classified_parts.append(classified_part) common_summary = public_template_summary(classified_parts, include_storage=include_storage) if classified_parts else {} templates = [] for template_item in direct.get("templates") or []: diff --git a/tests/1c/test_payload_codec.py b/tests/1c/test_payload_codec.py index cf0e586..572c763 100644 --- a/tests/1c/test_payload_codec.py +++ b/tests/1c/test_payload_codec.py @@ -7075,6 +7075,22 @@ def test_common_template_inventory_preserves_unmapped_descriptor_code(monkeypatc assert result["templates"][0]["name"] == "Оформление" +def test_top_level_common_template_summary_preserves_descriptor_code(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(adapter_server, "resolve_object_guid", lambda *_args, **_kwargs: ("a" * 36, None, {"name": "Оформление", "ref": "CommonTemplate.Оформление"}, None)) + monkeypatch.setattr(adapter_server, "read_template_by_guid", lambda _payload: {"status": "ok", "source": {"kind": "live_sql"}, "templates": [{"guid": "a" * 36}]}) + monkeypatch.setattr(adapter_server, "metadata_object_parts", lambda _payload: {"parts": [{ + "classification": {"role": "metadata_payload", "tree": {"type": "list", "items": [ + {"type": "atom", "value": "1"}, {"type": "list", "items": [ + {"type": "atom", "value": "4"}, {"type": "list", "items": []}, {"type": "atom", "value": "7"}, + ]}, + ]}}, + }, {"classification": {"role": "binary_or_unknown_payload", "xml_root": "AppearanceTemplate"}}]}) + + result = adapter_server.metadata_object_templates({"base_id": "upo_test", "kind": "CommonTemplate", "name": "Оформление"}) + + assert result["templates"][0]["descriptor_type_evidence"]["codes"] == ["7"] + + def test_moxel_template_artifact_kind_tracks_coordinate_hint_schema() -> None: assert adapter_server.MOXEL_TEMPLATE_ARTIFACT_KIND == "template_part_moxel_v11"