diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index c030a8344..485ac01fd 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -20,6 +20,8 @@ import { cleanEdges, getHandleId, getNodeId, + isInputNode, + isOutputNode, scapeJSONParse, scapedJSONStringfy, } from "../utils/reactflowUtils"; @@ -153,6 +155,21 @@ const useFlowStore = create((set, get) => ({ }) ); }, + checkInputandOutput: () => { + let has_input = false; + let has_output = false; + const nodes = get().nodes; + nodes.forEach((node) => { + const nodeData: NodeDataType = node.data as NodeDataType; + if (isInputNode(nodeData)) { + has_input = true; + } + if (isOutputNode(nodeData)) { + has_output = true; + } + }); + return has_input && has_output; + }, getNode: (id: string) => { return get().nodes.find((node) => node.id === id); },