Skip to main content

jellyflow_runtime/rules/delete/
mod.rs

1mod builder;
2mod diagnostics;
3mod planner;
4mod selection;
5mod validation;
6
7use crate::io::NodeGraphInteractionState;
8use jellyflow_core::core::{EdgeId, Graph, NodeId};
9
10use super::DeletePlan;
11use planner::DeletePlanner;
12
13/// Plans deleting a node with default interaction policy.
14pub fn plan_delete_node(graph: &Graph, node: NodeId) -> DeletePlan {
15    plan_delete_node_with_policy(graph, node, &NodeGraphInteractionState::default())
16}
17
18/// Plans deleting a node with explicit interaction policy.
19pub fn plan_delete_node_with_policy(
20    graph: &Graph,
21    node: NodeId,
22    state: &NodeGraphInteractionState,
23) -> DeletePlan {
24    plan_delete_elements_with_policy(graph, [node], std::iter::empty::<EdgeId>(), state)
25}
26
27/// Plans deleting an edge with default interaction policy.
28pub fn plan_delete_edge(graph: &Graph, edge: EdgeId) -> DeletePlan {
29    plan_delete_edge_with_policy(graph, edge, &NodeGraphInteractionState::default())
30}
31
32/// Plans deleting an edge with explicit interaction policy.
33pub fn plan_delete_edge_with_policy(
34    graph: &Graph,
35    edge: EdgeId,
36    state: &NodeGraphInteractionState,
37) -> DeletePlan {
38    plan_delete_elements_with_policy(graph, std::iter::empty::<NodeId>(), [edge], state)
39}
40
41/// Plans deleting nodes and edges with default interaction policy.
42pub fn plan_delete_elements(
43    graph: &Graph,
44    nodes: impl IntoIterator<Item = NodeId>,
45    edges: impl IntoIterator<Item = EdgeId>,
46) -> DeletePlan {
47    plan_delete_elements_with_policy(graph, nodes, edges, &NodeGraphInteractionState::default())
48}
49
50/// Plans deleting nodes and edges with explicit interaction policy.
51pub fn plan_delete_elements_with_policy(
52    graph: &Graph,
53    nodes: impl IntoIterator<Item = NodeId>,
54    edges: impl IntoIterator<Item = EdgeId>,
55    state: &NodeGraphInteractionState,
56) -> DeletePlan {
57    DeletePlanner::new(graph, state).plan(nodes, edges)
58}