{ "kind": "open-flow-workflow", "version": 1, "name": "Stop an Example Batch Loop at Index Five", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_427ce1281dfc2630": { "name": "Run the example", "kind": "start", "inputDefs": [] }, "n_04289403a5b02459": { "inputs": { "state": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_04289403a5b02459", "output": "state" } ] } }, "name": "Process one example item", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "state" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "message" } ], "name": "Process one example item", "moduleId": "n_d27887bc06f18619", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_d905432f0e900f50": { "inputs": {}, "name": "More items?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "yes", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_04289403a5b02459", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_945effd405932556": { "name": "Finished", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "message" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "visited" } ], "outputMappings": { "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_04289403a5b02459", "output": "message" } ] }, "visited": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_04289403a5b02459", "output": "state" } ] } } } }, "edges": [ { "source": "n_427ce1281dfc2630", "target": "n_04289403a5b02459" }, { "source": "n_04289403a5b02459", "target": "n_d905432f0e900f50" }, { "source": "n_d905432f0e900f50", "target": "n_04289403a5b02459", "sourceHandle": "yes" }, { "source": "n_d905432f0e900f50", "target": "n_945effd405932556", "sourceHandle": "otherwise" } ] } }, "modules": { "n_d27887bc06f18619": { "name": "Process one example item", "imports": [], "source": "export default function step({state}) {\n const visited=state ? [...state.visited] : [];\n if (visited.length > 5) throw Error('Invalid batch state');\n visited.push(visited.length);\n return {state:{visited},more:visited.length<6,message:visited.length===6?'Loop Ended':''};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }