增加了项目侧关于steps的处理。允许保存和提取steps信息。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
@@ -77,6 +78,8 @@ async def add_create_action(
|
||||
binding_status=BindingStatus.NORMAL,
|
||||
action=SyncAction.CREATE,
|
||||
)
|
||||
if src_node.context:
|
||||
new_node.context.update(copy.deepcopy(src_node.context))
|
||||
await to_collection.add(new_node)
|
||||
|
||||
if source_is_local:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Callable, List, Optional
|
||||
|
||||
@@ -20,6 +21,17 @@ if TYPE_CHECKING:
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _extract_snapshot_steps(snapshot) -> List:
|
||||
if not isinstance(snapshot, dict):
|
||||
return []
|
||||
steps = snapshot.get("steps")
|
||||
return copy.deepcopy(steps) if isinstance(steps, list) else []
|
||||
|
||||
|
||||
def _steps_payload_changed(source_snapshot, target_snapshot) -> bool:
|
||||
return _extract_snapshot_steps(source_snapshot) != _extract_snapshot_steps(target_snapshot)
|
||||
|
||||
|
||||
def _safe_repr(value, *, max_len: int = 120) -> str:
|
||||
text = repr(value)
|
||||
if len(text) <= max_len:
|
||||
@@ -151,6 +163,17 @@ async def add_update_action(
|
||||
update_id_resolve_ok = data is not None
|
||||
has_diff = False
|
||||
diff_descriptions: List[str] = []
|
||||
source_snapshot = src_node.context.get("approval_snapshot") if isinstance(src_node.context, dict) else None
|
||||
target_snapshot = target_node.context.get("approval_snapshot") if isinstance(target_node.context, dict) else None
|
||||
steps_changed = False
|
||||
if isinstance(source_snapshot, dict):
|
||||
steps_changed = _steps_payload_changed(source_snapshot, target_snapshot)
|
||||
pending_snapshot = copy.deepcopy(source_snapshot)
|
||||
pending_snapshot["steps_changed"] = steps_changed
|
||||
target_node.context["pending_approval_snapshot"] = pending_snapshot
|
||||
else:
|
||||
target_node.context.pop("pending_approval_snapshot", None)
|
||||
|
||||
if update_id_resolve_ok:
|
||||
try:
|
||||
should_update = needs_update_check(src_node, target_node, resolved_data=data, data_id_map=data_id_map)
|
||||
@@ -163,6 +186,10 @@ async def add_update_action(
|
||||
if has_diff:
|
||||
diff_descriptions = _collect_diff_descriptions(data, target_node.get_data(), data_id_map=data_id_map or {})
|
||||
|
||||
if steps_changed:
|
||||
has_diff = True
|
||||
diff_descriptions.append("steps: approval flow changed")
|
||||
|
||||
if target_has_data_id and update_id_resolve_ok and not has_diff:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user