{ "kind": "open-flow-workflow", "version": 1, "name": "Merge Ingredient and Band Lists", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_b1cfc39aa63aa6dd": { "name": "Run merge examples", "kind": "start", "inputDefs": [] }, "n_fe034c9a38f0fe66": { "inputs": {}, "name": "Match, enrich, and append", "kind": "task", "task": { "inputs": [], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "available" }, { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "recipe" }, { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "band" } ], "name": "Match, enrich, and append", "moduleId": "n_8002a3ac7b86092d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_7dc1b7e570cb0d85": { "name": "Merged lists", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "available" }, { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "recipe" }, { "jsonSchema": { "type": "array", "items": { "type": "object" } }, "nullable": false, "handle": "band" } ], "outputMappings": { "available": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fe034c9a38f0fe66", "output": "available" } ] }, "recipe": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fe034c9a38f0fe66", "output": "recipe" } ] }, "band": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fe034c9a38f0fe66", "output": "band" } ] } } } }, "edges": [ { "source": "n_b1cfc39aa63aa6dd", "target": "n_fe034c9a38f0fe66" }, { "source": "n_fe034c9a38f0fe66", "target": "n_7dc1b7e570cb0d85" } ] } }, "modules": { "n_8002a3ac7b86092d": { "name": "Match, enrich, and append", "imports": [], "source": "export default function mergeExamples(){\nconst [needed,stock,ingredients,quantities,queen,zeppelin]=[[{\"Name\":\"Flour\"},{\"Name\":\"Eggs\"},{\"Name\":\"Milk\"},{\"Name\":\"Lemon\"},{\"Name\":\"Sugar\"}],[{\"Name\":\"Eggs\"},{\"Name\":\"Lemon\"},{\"Name\":\"Sugar\"}],[{\"Name\":\"Flour\"},{\"Name\":\"Eggs\"},{\"Name\":\"Milk\"},{\"Name\":\"Lemon\"},{\"Name\":\"Sugar\"}],[{\"Name\":\"Flour\",\"Quantity\":\"100g\"},{\"Name\":\"Eggs\",\"Quantity\":2},{\"Name\":\"Salt\",\"Quantity\":\"50g\"},{\"Name\":\"Lemon\",\"Quantity\":1},{\"Name\":\"Sugar\",\"Quantity\":\"6tbsp\"}],[{\"FirstName\":\"John\",\"LastName\":\"Deacon\",\"Instrument\":\"Drums\"},{\"FirstName\":\"Freddy\",\"LastName\":\"Mercury\",\"Instrument\":\"Vocals and Piano\",\"Superpower\":\"Crowd control\"},{\"FirstName\":\"Brian\",\"LastName\":\"May\",\"Instrument\":\"Guitar\"},{\"FirstName\":\"Roger\",\"LastName\":\"Taylor\",\"Instrument\":\"Bass\"}],[{\"FirstName\":\"Jimmy\",\"LastName\":\"Page\",\"Instrument\":\"Guitar\"},{\"FirstName\":\"Robert\",\"LastName\":\"Plant\",\"Instrument\":\"Vocals\"},{\"FirstName\":\"John\",\"LastName\":\"Bonham\",\"Instrument\":\"Drums\"},{\"FirstName\":\"John\",\"LastName\":\"Paul Jones\",\"Instrument\":\"Bass\",\"Second Instrument\":\"Keyboard\"}]];\nconst stockNames=new Set(stock.map(x=>x.Name));const available=needed.filter(x=>stockNames.has(x.Name)).map(x=>({...x,...stock.find(y=>y.Name===x.Name)}));const matched=ingredients.filter(x=>quantities.some(y=>y.Name===x.Name)).map(x=>({...x,...quantities.find(y=>y.Name===x.Name)}));const unmatched=ingredients.filter(x=>!quantities.some(y=>y.Name===x.Name));return {available,recipe:[...matched,...unmatched],band:[...queen,...zeppelin]};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }