platform-core/modules/workflowAutomation/engine/udmUpstreamShapes.py
ValueOn AG 4a60086c80
Some checks failed
Deploy Plattform-Core (Int) / test (push) Failing after 15s
Deploy Plattform-Core (Int) / deploy (push) Has been skipped
cp adapted to 2026 poweron
2026-06-09 09:53:31 +02:00

37 lines
1.2 KiB
Python

# Copyright (c) 2026 PowerOn AG
# All rights reserved.
"""
Pure shape coercion for UDM-related upstream payloads (tests + optional tooling).
No runtime wire-handover — kept only so unit tests can assert stable normalisation rules.
"""
from __future__ import annotations
from typing import Any, Dict
def _coerceUdmDocumentInput(upstream: Dict[str, Any]) -> Dict[str, Any]:
if upstream.get("children") is not None and upstream.get("sourceType"):
return upstream
udm = upstream.get("udm")
if isinstance(udm, dict) and udm.get("children") is not None:
return udm
return {}
def _coerceUdmNodeListInput(upstream: Dict[str, Any]) -> Dict[str, Any]:
nodes = upstream.get("nodes")
if isinstance(nodes, list):
return {"nodes": nodes, "count": len(nodes)}
children = upstream.get("children")
if isinstance(children, list):
return {"nodes": children, "count": len(children)}
return {}
def _coerceConsolidateResultInput(upstream: Dict[str, Any]) -> Dict[str, Any]:
result: Dict[str, Any] = {}
for key in ("result", "mode", "count"):
if key in upstream:
result[key] = upstream[key]
return result