@teleporthq/teleport-plugin-next-workflows 0.45.15 → 0.45.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/cron-route-loop-templateparams.test.ts +5 -4
- package/__tests__/custom-js-loop-scope.test.ts +10 -5
- package/__tests__/loop-collection-unwrap.test.ts +6 -1
- package/__tests__/server-loop-body-branches.test.ts +188 -0
- package/__tests__/server-nested-loops.test.ts +392 -0
- package/__tests__/streaming-route-if-branch.test.ts +107 -0
- package/dist/cjs/api-route-generator.d.ts.map +1 -1
- package/dist/cjs/api-route-generator.js +57 -251
- package/dist/cjs/api-route-generator.js.map +1 -1
- package/dist/cjs/executor-generator.d.ts.map +1 -1
- package/dist/cjs/executor-generator.js +22 -0
- package/dist/cjs/executor-generator.js.map +1 -1
- package/dist/cjs/server-runtime-code.d.ts.map +1 -1
- package/dist/cjs/server-runtime-code.js +67 -0
- package/dist/cjs/server-runtime-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/api-route-generator.d.ts.map +1 -1
- package/dist/esm/api-route-generator.js +57 -251
- package/dist/esm/api-route-generator.js.map +1 -1
- package/dist/esm/executor-generator.d.ts.map +1 -1
- package/dist/esm/executor-generator.js +22 -0
- package/dist/esm/executor-generator.js.map +1 -1
- package/dist/esm/server-runtime-code.d.ts.map +1 -1
- package/dist/esm/server-runtime-code.js +67 -0
- package/dist/esm/server-runtime-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/api-route-generator.ts +57 -251
- package/src/executor-generator.ts +22 -0
- package/src/server-runtime-code.ts +67 -0
|
@@ -854,7 +854,74 @@ function handOffPendingNodePromises(context) {
|
|
|
854
854
|
return Promise.resolve();
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
+
// One loop of a server route, a loop inside its body included: every route
|
|
858
|
+
// kind runs its loops through here and differs only in runBodyNode(node,
|
|
859
|
+
// resolvedConfig), which runs one ordinary body node and stores its result.
|
|
860
|
+
// The body is walked in step order, once per pass of the loop type (see
|
|
861
|
+
// createLoopSteps). An if-statement skips the branch it does not take for
|
|
862
|
+
// that pass only; a loop found in the body runs all of its own passes on
|
|
863
|
+
// every pass of this one, and its body nodes belong to it alone.
|
|
864
|
+
// Returns every node id between the loop and its loop-back edge (the bodies
|
|
865
|
+
// of inner loops included), which the route must not run again.
|
|
866
|
+
async function runServerLoop(loopNode, config, sortedNodes, edges, context, runBodyNode) {
|
|
867
|
+
var bodyNodeIds = {};
|
|
868
|
+
utils.getLoopBodyNodeIds(loopNode.id, edges).forEach(function(id) { bodyNodeIds[id] = true; });
|
|
869
|
+
var innerLoopBodyIds = {};
|
|
870
|
+
sortedNodes.forEach(function(n) {
|
|
871
|
+
if (!bodyNodeIds[n.id] || n.type !== 'general-loop') return;
|
|
872
|
+
utils.getLoopBodyNodeIds(n.id, edges).forEach(function(id) { innerLoopBodyIds[id] = true; });
|
|
873
|
+
});
|
|
874
|
+
var bodyNodes = sortedNodes.filter(function(n) { return bodyNodeIds[n.id] && !innerLoopBodyIds[n.id]; });
|
|
875
|
+
// A map loop publishes the output of its last body node per pass, as
|
|
876
|
+
// Array.prototype.map does (general-loop in node-context-schemas.json).
|
|
877
|
+
var isMap = (config.loopType || 'forEach') === 'map';
|
|
878
|
+
var lastBodyNode = bodyNodes[bodyNodes.length - 1];
|
|
879
|
+
// A helper node's envelope ({ result }, { records }, { matches }) is
|
|
880
|
+
// unwrapped to the one array it holds.
|
|
881
|
+
var collection = utils.unwrapWorkflowCollection(config.collection);
|
|
882
|
+
var results = [];
|
|
883
|
+
|
|
884
|
+
// The scope stack lets custom JavaScript tell the nodes before the outermost
|
|
885
|
+
// loop (params) from those inside a loop at each depth (innerParams); the
|
|
886
|
+
// registry keeps a finished inner loop recognisable as scaffolding.
|
|
887
|
+
if (!context.__loopScopeStack) context.__loopScopeStack = [];
|
|
888
|
+
context.__loopScopeStack.push({ loopNodeId: loopNode.id, bodyNodeIds: bodyNodeIds });
|
|
889
|
+
if (!context.__loopNodeIds) context.__loopNodeIds = {};
|
|
890
|
+
context.__loopNodeIds[loopNode.id] = true;
|
|
891
|
+
|
|
892
|
+
var steps = utils.createLoopSteps(loopNode, config, context, collection);
|
|
893
|
+
for (var pass = steps.next(context); pass; pass = steps.next(context)) {
|
|
894
|
+
context[pass.key] = pass.value;
|
|
895
|
+
var skippedThisPass = {};
|
|
896
|
+
for (var i = 0; i < bodyNodes.length; i++) {
|
|
897
|
+
var bodyNode = bodyNodes[i];
|
|
898
|
+
if (skippedThisPass[bodyNode.id]) continue;
|
|
899
|
+
var resolved = utils.resolveNodeConfig(bodyNode, context);
|
|
900
|
+
resolved.__nodeId = bodyNode.id;
|
|
901
|
+
if (bodyNode.type === 'general-if-statement') {
|
|
902
|
+
var held = utils.evaluateCondition(resolved, context, bodyNode.config);
|
|
903
|
+
context[bodyNode.id] = { result: held };
|
|
904
|
+
Object.assign(skippedThisPass, utils.nonTakenBranchNodeIds(edges, bodyNode.id, held, loopNode.id));
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
if (bodyNode.type === 'general-loop') {
|
|
908
|
+
await runServerLoop(bodyNode, resolved, sortedNodes, edges, context, runBodyNode);
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
await runBodyNode(bodyNode, resolved);
|
|
912
|
+
}
|
|
913
|
+
if (isMap) {
|
|
914
|
+
results.push(lastBodyNode ? context[lastBodyNode.id] : context[loopNode.id]);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
context.__loopScopeStack.pop();
|
|
919
|
+
context[loopNode.id] = { completed: true, iterations: steps.iterations(), results: results };
|
|
920
|
+
return bodyNodeIds;
|
|
921
|
+
}
|
|
922
|
+
|
|
857
923
|
module.exports = Object.assign({}, utils, {
|
|
924
|
+
runServerLoop: runServerLoop,
|
|
858
925
|
handOffPendingNodePromises: handOffPendingNodePromises,
|
|
859
926
|
claimSegmentContext: claimSegmentContext,
|
|
860
927
|
segmentReply: segmentReply,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-runtime-code.js","sourceRoot":"","sources":["../../src/server-runtime-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAAE,wCAAwC,EAAE,MAAM,2BAA2B,CAAA;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAA;AAEtE,wEAAwE;AACxE,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEtD,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,CAAA;AAEpD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,yCAAyC,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAA+C,EAAE,EACzC,EAAE,CAAC;;;;EAIX,iCAAiC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAoGX,wBAAwB;6BACrB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAsJ3B,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;;;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