callman-core 1.17.0 → 1.19.0
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/dist/scenario-runner/adapters/index.d.ts +1 -0
- package/dist/scenario-runner/adapters/index.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/index.js +3 -0
- package/dist/scenario-runner/adapters/index.js.map +1 -1
- package/dist/scenario-runner/adapters/types.d.ts +1 -0
- package/dist/scenario-runner/adapters/types.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/websocket-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/websocket-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/websocket-executor.js +20 -0
- package/dist/scenario-runner/adapters/websocket-executor.js.map +1 -0
- package/dist/scenario-runner/condition.d.ts.map +1 -1
- package/dist/scenario-runner/condition.js +53 -1
- package/dist/scenario-runner/condition.js.map +1 -1
- package/dist/scenario-runner/graphTraversal.d.ts +10 -0
- package/dist/scenario-runner/graphTraversal.d.ts.map +1 -1
- package/dist/scenario-runner/graphTraversal.js +16 -2
- package/dist/scenario-runner/graphTraversal.js.map +1 -1
- package/dist/scenario-runner/index.d.ts +1 -0
- package/dist/scenario-runner/index.d.ts.map +1 -1
- package/dist/scenario-runner/index.js +1 -0
- package/dist/scenario-runner/index.js.map +1 -1
- package/dist/scenario-runner/nodePolicy.d.ts +2 -2
- package/dist/scenario-runner/nodePolicy.d.ts.map +1 -1
- package/dist/scenario-runner/nodePolicy.js +5 -0
- package/dist/scenario-runner/nodePolicy.js.map +1 -1
- package/dist/scenario-runner/runScenario.d.ts.map +1 -1
- package/dist/scenario-runner/runScenario.js +412 -7
- package/dist/scenario-runner/runScenario.js.map +1 -1
- package/dist/scenario-runner/types.d.ts +137 -3
- package/dist/scenario-runner/types.d.ts.map +1 -1
- package/dist/scenario-runner/websocket.d.ts +17 -0
- package/dist/scenario-runner/websocket.d.ts.map +1 -0
- package/dist/scenario-runner/websocket.js +74 -0
- package/dist/scenario-runner/websocket.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/index.js +5 -1
- package/dist-cjs/scenario-runner/adapters/index.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/websocket-executor.js +24 -0
- package/dist-cjs/scenario-runner/adapters/websocket-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/condition.js +53 -1
- package/dist-cjs/scenario-runner/condition.js.map +1 -1
- package/dist-cjs/scenario-runner/graphTraversal.js +17 -3
- package/dist-cjs/scenario-runner/graphTraversal.js.map +1 -1
- package/dist-cjs/scenario-runner/index.js +1 -0
- package/dist-cjs/scenario-runner/index.js.map +1 -1
- package/dist-cjs/scenario-runner/nodePolicy.js +5 -0
- package/dist-cjs/scenario-runner/nodePolicy.js.map +1 -1
- package/dist-cjs/scenario-runner/runScenario.js +411 -6
- package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
- package/dist-cjs/scenario-runner/websocket.js +79 -0
- package/dist-cjs/scenario-runner/websocket.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphTraversal.js","sourceRoot":"","sources":["../../src/scenario-runner/graphTraversal.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,YAAoB,EACpB,WAAmB,EACX,EAAE,CAAC,GAAG,YAAY,GAAG,2BAA2B,GAAG,WAAW,EAAE,CAAC;AAE3E,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,wBAAwB,G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,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAM/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAM/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,iEAAiE;AACjE,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,iCAAiC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,2EAA2E;AAC3E,cAAc,iBAAiB,CAAC;AAChC,sEAAsE;AACtE,oEAAoE;AACpE,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,iEAAiE;AACjE,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,iCAAiC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,2EAA2E;AAC3E,cAAc,iBAAiB,CAAC;AAChC,sEAAsE;AACtE,oEAAoE;AACpE,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AggregatorScenarioNode, DbScenarioNode, EndScenarioNode, KafkaScenarioNode, NotificationScenarioNode, RedisScenarioNode, RequestScenarioNode, ScenarioNode, ScenarioNodeExecutionPolicy, ScenarioPolicyCapableNode, ScenarioPolicyCapableNodeType, ScriptScenarioNode, SubScenarioNode, WaitScenarioNode } from "./types.js";
|
|
1
|
+
import { AggregatorScenarioNode, DbScenarioNode, EndScenarioNode, KafkaScenarioNode, NotificationScenarioNode, RedisScenarioNode, RequestScenarioNode, ScenarioNode, ScenarioNodeExecutionPolicy, ScenarioPolicyCapableNode, ScenarioPolicyCapableNodeType, ScriptScenarioNode, SubScenarioNode, ForeachScenarioNode, WebsocketScenarioNode, WaitScenarioNode } from "./types.js";
|
|
2
2
|
export declare const STRICT_SCENARIO_NODE_EXECUTION_POLICY: ScenarioNodeExecutionPolicy;
|
|
3
3
|
export declare const supportsScenarioNodeExecutionPolicy: (nodeOrType: ScenarioNode | ScenarioPolicyCapableNodeType) => nodeOrType is ScenarioPolicyCapableNode | ScenarioPolicyCapableNodeType;
|
|
4
4
|
export declare const normalizeScenarioNodeExecutionPolicy: (value: unknown, fallback?: ScenarioNodeExecutionPolicy) => ScenarioNodeExecutionPolicy;
|
|
@@ -7,5 +7,5 @@ export declare const getNewScenarioNodeExecutionPolicyPreset: (type: ScenarioPol
|
|
|
7
7
|
export declare const getScenarioNodeExecutionPolicy: (node: ScenarioPolicyCapableNode) => ScenarioNodeExecutionPolicy;
|
|
8
8
|
export declare const getScenarioNodeMaxAttempts: (policy: ScenarioNodeExecutionPolicy) => number;
|
|
9
9
|
export declare const getScenarioNodePolicyBadges: (node: ScenarioPolicyCapableNode) => string[];
|
|
10
|
-
export declare const patchScenarioNodeExecutionPolicy: <TNode extends RequestScenarioNode | DbScenarioNode | WaitScenarioNode | ScriptScenarioNode | KafkaScenarioNode | RedisScenarioNode | NotificationScenarioNode | EndScenarioNode | AggregatorScenarioNode | SubScenarioNode>(node: TNode, executionPolicy: ScenarioNodeExecutionPolicy) => TNode;
|
|
10
|
+
export declare const patchScenarioNodeExecutionPolicy: <TNode extends RequestScenarioNode | DbScenarioNode | WaitScenarioNode | ScriptScenarioNode | KafkaScenarioNode | RedisScenarioNode | NotificationScenarioNode | EndScenarioNode | AggregatorScenarioNode | SubScenarioNode | ForeachScenarioNode | WebsocketScenarioNode>(node: TNode, executionPolicy: ScenarioNodeExecutionPolicy) => TNode;
|
|
11
11
|
//# sourceMappingURL=nodePolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodePolicy.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/nodePolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,qCAAqC,EAAE,2BAOnD,CAAC;
|
|
1
|
+
{"version":3,"file":"nodePolicy.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/nodePolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,qCAAqC,EAAE,2BAOnD,CAAC;AA8DF,eAAO,MAAM,mCAAmC,GAC9C,YAAY,YAAY,GAAG,6BAA6B,KACvD,UAAU,IAAI,yBAAyB,GAAG,6BAI5C,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAC/C,OAAO,OAAO,EACd,WAAU,2BAAmE,KAC5E,2BA+DF,CAAC;AAEF,eAAO,MAAM,oCAAoC,QAAO,2BACJ,CAAC;AAErD,eAAO,MAAM,uCAAuC,GAClD,MAAM,6BAA6B,KAClC,2BAAqF,CAAC;AAEzF,eAAO,MAAM,8BAA8B,GACzC,MAAM,yBAAyB,KAC9B,2BAIA,CAAC;AAEJ,eAAO,MAAM,0BAA0B,GACrC,QAAQ,2BAA2B,KAClC,MAA4E,CAAC;AAEhF,eAAO,MAAM,2BAA2B,GACtC,MAAM,yBAAyB,KAC9B,MAAM,EAeR,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAC3C,KAAK,SACD,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,wBAAwB,GACxB,eAAe,GACf,sBAAsB,GACtB,eAAe,GACf,mBAAmB,GACnB,qBAAqB,EAEzB,MAAM,KAAK,EACX,iBAAiB,2BAA2B,KAC3C,KASD,CAAC"}
|
|
@@ -45,6 +45,11 @@ const RECOMMENDED_NEW_NODE_POLICY_PRESETS = {
|
|
|
45
45
|
aggregator: STRICT_SCENARIO_NODE_EXECUTION_POLICY,
|
|
46
46
|
subscenario: STRICT_SCENARIO_NODE_EXECUTION_POLICY,
|
|
47
47
|
"scenario-ref": STRICT_SCENARIO_NODE_EXECUTION_POLICY,
|
|
48
|
+
// The item loop IS the repeat mechanism for this node type — retry stays
|
|
49
|
+
// off (and is force-disabled at execution time in runScenario).
|
|
50
|
+
foreach: STRICT_SCENARIO_NODE_EXECUTION_POLICY,
|
|
51
|
+
// Retry re-runs the WHOLE conversation (connect -> steps -> close).
|
|
52
|
+
websocket: STRICT_SCENARIO_NODE_EXECUTION_POLICY,
|
|
48
53
|
};
|
|
49
54
|
const clonePolicy = (policy) => ({
|
|
50
55
|
onFailure: policy.onFailure,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodePolicy.js","sourceRoot":"","sources":["../../src/scenario-runner/nodePolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodePolicy.js","sourceRoot":"","sources":["../../src/scenario-runner/nodePolicy.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,qCAAqC,GAAgC;IAChF,SAAS,EAAE,MAAM;IACjB,KAAK,EAAE;QACL,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;KACX;CACF,CAAC;AAEF,MAAM,mCAAmC,GAGrC;IACF,OAAO,EAAE,qCAAqC;IAC9C,EAAE,EAAE,qCAAqC;IACzC,IAAI,EAAE,qCAAqC;IAC3C,MAAM,EAAE,qCAAqC;IAC7C,sEAAsE;IACtE,SAAS,EAAE,qCAAqC;IAChD,KAAK,EAAE;QACL,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAI;SACd;KACF;IACD,KAAK,EAAE;QACL,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAI;SACd;KACF;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE;YACL,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,CAAC;YACd,OA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e,CAAC;SACvE;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runScenario.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/runScenario.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runScenario.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/runScenario.ts"],"names":[],"mappings":"AAyDA,OAAO,KAAK,EAKV,kBAAkB,EAUlB,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AAyuBpB,eAAO,MAAM,WAAW,GAAU,mGAQ/B,kBAAkB,KAAG,OAAO,CAAC,iBAAiB,CA06EhD,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { buildConditionOutputPayload, evaluateConditionConfig, evaluateConditionRule, resolveConditionRuntimeValue, validateConditionConfig, } from "./condition.js";
|
|
2
2
|
import { applyExtract } from "./extraction.js";
|
|
3
3
|
import { evaluateAssertionConfig, validateAssertionConfig, } from "./assertion.js";
|
|
4
|
-
import { createSubScenarioStepId, buildRuntimeStepDescriptors, DEFAULT_END_LOOP_DELAY_MS, DEFAULT_END_LOOP_ITERATIONS, flattenScenarioNodesForContext, MAX_END_LOOP_ITERATIONS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_MAX_ATTEMPTS, MAX_POLL_ATTEMPTS, } from "./graphTraversal.js";
|
|
4
|
+
import { createSubScenarioStepId, buildRuntimeStepDescriptors, DEFAULT_END_LOOP_DELAY_MS, DEFAULT_END_LOOP_ITERATIONS, flattenScenarioNodesForContext, MAX_END_LOOP_ITERATIONS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_MAX_ATTEMPTS, MAX_POLL_ATTEMPTS, DEFAULT_FOREACH_MAX_ITERATIONS, MAX_FOREACH_ITERATIONS, DEFAULT_WS_CONNECT_TIMEOUT_MS, MAX_WS_CONNECT_TIMEOUT_MS, DEFAULT_WS_EXPECT_TIMEOUT_MS, MAX_WS_EXPECT_TIMEOUT_MS, MAX_WS_WAIT_DURATION_MS, MAX_WS_STEPS, DEFAULT_WS_CLOSE_CODE, } from "./graphTraversal.js";
|
|
5
|
+
import { evaluateWebsocketExpect } from "./websocket.js";
|
|
5
6
|
import { executeWithScenarioNodePolicy } from "./executionPolicyRunner.js";
|
|
6
7
|
import { getLegacyScenarioNodeExecutionPolicy, getScenarioNodeExecutionPolicy, supportsScenarioNodeExecutionPolicy, } from "./nodePolicy.js";
|
|
7
8
|
import { buildScenarioExecutionGraph, buildScenarioTemplateValues, collectExclusiveBranchNodeIds, evaluateScenarioExpression, resolveScenarioJsonTemplateString, resolveScenarioTemplateString, } from "./templateResolver.js";
|
|
@@ -33,9 +34,19 @@ const buildTitle = (node) => {
|
|
|
33
34
|
return `${node.type[0]?.toUpperCase() ?? ""}${node.type.slice(1)}`;
|
|
34
35
|
};
|
|
35
36
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
|
-
// `loop`/`loops` are the loop-iteration template roots
|
|
37
|
+
// `loop`/`loops` are the loop-iteration template roots and `item`/`each`/
|
|
38
|
+
// `eaches` the foreach-iteration ones (see the loop-frame and foreach
|
|
37
39
|
// machinery in runScenario) — node labels must not shadow them.
|
|
38
|
-
const RESERVED_WORKFLOW_ROOT_LABELS = new Set([
|
|
40
|
+
const RESERVED_WORKFLOW_ROOT_LABELS = new Set([
|
|
41
|
+
"workflow",
|
|
42
|
+
"__meta",
|
|
43
|
+
"loop",
|
|
44
|
+
"loops",
|
|
45
|
+
"item",
|
|
46
|
+
"each",
|
|
47
|
+
"eaches",
|
|
48
|
+
"ws",
|
|
49
|
+
]);
|
|
39
50
|
const cloneNodeExecutionMeta = (meta) => ({
|
|
40
51
|
...meta,
|
|
41
52
|
...(meta.error ? { error: { ...meta.error } } : {}),
|
|
@@ -413,6 +424,18 @@ const updateRecordFromEvent = (records, event) => {
|
|
|
413
424
|
});
|
|
414
425
|
return;
|
|
415
426
|
}
|
|
427
|
+
if (event.type === "step:iteration") {
|
|
428
|
+
// Iteration progress marker only — the terminal success/fail event owns
|
|
429
|
+
// the record. Without this early return the generic fallback below would
|
|
430
|
+
// stamp status:"failed" on the foreach step.
|
|
431
|
+
records.set(event.stepId, {
|
|
432
|
+
...current,
|
|
433
|
+
stepType: event.stepType,
|
|
434
|
+
title: event.title,
|
|
435
|
+
startedAt: current.startedAt ?? event.at,
|
|
436
|
+
});
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
416
439
|
if (event.type === "step:condition") {
|
|
417
440
|
records.set(event.stepId, {
|
|
418
441
|
...current,
|
|
@@ -508,6 +531,9 @@ const callHandler = async (handlers, event) => {
|
|
|
508
531
|
case "step:poll":
|
|
509
532
|
await handlers?.onPollTick?.(event);
|
|
510
533
|
return;
|
|
534
|
+
case "step:iteration":
|
|
535
|
+
await handlers?.onForeachIteration?.(event);
|
|
536
|
+
return;
|
|
511
537
|
case "step:success":
|
|
512
538
|
await handlers?.onNodeSuccess?.(event);
|
|
513
539
|
return;
|
|
@@ -821,10 +847,10 @@ export const runScenario = async ({ scenario, environment = {}, globals = {}, ru
|
|
|
821
847
|
let executionPolicy = supportsScenarioNodeExecutionPolicy(node)
|
|
822
848
|
? withNotificationFailurePolicyOverride(node, getScenarioNodeExecutionPolicy(node))
|
|
823
849
|
: getLegacyScenarioNodeExecutionPolicy();
|
|
824
|
-
if (node.type === "poll") {
|
|
825
|
-
// The poll loop REPLACES per-node retry (nested retry loops would
|
|
826
|
-
// unexplainable). onFailure — incl. error edges — still governs the
|
|
827
|
-
//
|
|
850
|
+
if (node.type === "poll" || node.type === "foreach") {
|
|
851
|
+
// The poll/item loop REPLACES per-node retry (nested retry loops would
|
|
852
|
+
// be unexplainable). onFailure — incl. error edges — still governs the
|
|
853
|
+
// final outcome.
|
|
828
854
|
executionPolicy = {
|
|
829
855
|
...executionPolicy,
|
|
830
856
|
retry: { enabled: false, maxAttempts: 0, delayMs: 0 },
|
|
@@ -1421,6 +1447,163 @@ export const runScenario = async ({ scenario, environment = {}, globals = {}, ru
|
|
|
1421
1447
|
outputData = runtimeContext.kafkaEvent;
|
|
1422
1448
|
}
|
|
1423
1449
|
}
|
|
1450
|
+
if (node.type === "websocket") {
|
|
1451
|
+
const wsConfig = node.data.config;
|
|
1452
|
+
const resolvedUrl = resolveScenarioTemplateString(wsConfig.url ?? "", templateValues).trim();
|
|
1453
|
+
if (!resolvedUrl) {
|
|
1454
|
+
throw new ScenarioNodeFailureError("WebSocket URL is required.");
|
|
1455
|
+
}
|
|
1456
|
+
const configuredSteps = wsConfig.steps ?? [];
|
|
1457
|
+
if (configuredSteps.length > MAX_WS_STEPS) {
|
|
1458
|
+
throw new ScenarioNodeFailureError(`WebSocket conversations are capped at ${MAX_WS_STEPS} steps.`);
|
|
1459
|
+
}
|
|
1460
|
+
for (const [stepIndex, step] of configuredSteps.entries()) {
|
|
1461
|
+
if (step.kind === "expect" && (!step.rules || step.rules.length === 0)) {
|
|
1462
|
+
throw new ScenarioNodeFailureError(`WebSocket expect step ${stepIndex + 1} has no rules.`);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
const resolvedHeaders = (wsConfig.headers ?? [])
|
|
1466
|
+
.filter((header) => header.enabled !== false && header.key.trim())
|
|
1467
|
+
.map((header) => ({
|
|
1468
|
+
key: resolveScenarioTemplateString(header.key, templateValues).trim(),
|
|
1469
|
+
value: resolveScenarioTemplateString(header.value ?? "", templateValues),
|
|
1470
|
+
}));
|
|
1471
|
+
const resolvedSubprotocols = (wsConfig.subprotocols ?? [])
|
|
1472
|
+
.map((protocol) => resolveScenarioTemplateString(protocol, templateValues).trim())
|
|
1473
|
+
.filter((protocol) => protocol.length > 0);
|
|
1474
|
+
const connectTimeoutMs = Math.min(MAX_WS_CONNECT_TIMEOUT_MS, Math.max(100, Math.round(wsConfig.connectTimeoutMs ?? DEFAULT_WS_CONNECT_TIMEOUT_MS)));
|
|
1475
|
+
const resolvedSteps = configuredSteps.map((step) => {
|
|
1476
|
+
if (step.kind === "send") {
|
|
1477
|
+
return {
|
|
1478
|
+
id: step.id,
|
|
1479
|
+
kind: "send",
|
|
1480
|
+
payload: resolveScenarioJsonTemplateString(step.payload ?? "", templateValues),
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
if (step.kind === "wait") {
|
|
1484
|
+
return {
|
|
1485
|
+
id: step.id,
|
|
1486
|
+
kind: "wait",
|
|
1487
|
+
durationMs: Math.min(MAX_WS_WAIT_DURATION_MS, Math.max(0, Math.round(step.durationMs ?? 0))),
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
return {
|
|
1491
|
+
id: step.id,
|
|
1492
|
+
kind: "expect",
|
|
1493
|
+
timeoutMs: Math.min(MAX_WS_EXPECT_TIMEOUT_MS, Math.max(100, Math.round(step.timeoutMs ?? DEFAULT_WS_EXPECT_TIMEOUT_MS))),
|
|
1494
|
+
matchMode: step.matchMode === "any" ? "any" : "all",
|
|
1495
|
+
rules: step.rules,
|
|
1496
|
+
};
|
|
1497
|
+
});
|
|
1498
|
+
const wsExecution = await runtimeAdapters.websocketExecutor({
|
|
1499
|
+
runId,
|
|
1500
|
+
stepId,
|
|
1501
|
+
node,
|
|
1502
|
+
resolvedUrl,
|
|
1503
|
+
resolvedHeaders,
|
|
1504
|
+
subprotocols: resolvedSubprotocols,
|
|
1505
|
+
connectTimeoutMs,
|
|
1506
|
+
steps: resolvedSteps,
|
|
1507
|
+
closeCode: wsConfig.closeCode ?? DEFAULT_WS_CLOSE_CODE,
|
|
1508
|
+
rejectUnauthorized: wsConfig.rejectUnauthorized !== false,
|
|
1509
|
+
environment: { ...runtimeContext.environment },
|
|
1510
|
+
globals: { ...runtimeContext.globals },
|
|
1511
|
+
signal,
|
|
1512
|
+
});
|
|
1513
|
+
throwIfStopped(signal);
|
|
1514
|
+
// Authoritative expect evaluation over the recorded frames — the
|
|
1515
|
+
// host's early-stop is advisory only (kafka consume precedent).
|
|
1516
|
+
const evaluationScope = {
|
|
1517
|
+
environment: runtimeContext.environment,
|
|
1518
|
+
globals: runtimeContext.globals,
|
|
1519
|
+
workflowContext: runtimeContext.workflowContext,
|
|
1520
|
+
nodeMetaByLabel: runtimeContext.nodeMetaByLabel,
|
|
1521
|
+
responseRoot: runtimeContext.responseRoot,
|
|
1522
|
+
dbResult: runtimeContext.dbResult,
|
|
1523
|
+
kafkaEvent: runtimeContext.kafkaEvent,
|
|
1524
|
+
redisResult: runtimeContext.redisResult,
|
|
1525
|
+
};
|
|
1526
|
+
const outcomesByIndex = new Map(wsExecution.stepOutcomes.map((outcome) => [outcome.index, outcome]));
|
|
1527
|
+
let conversationBroken = !wsExecution.connected;
|
|
1528
|
+
const stepResults = resolvedSteps.map((step, index) => {
|
|
1529
|
+
const outcome = outcomesByIndex.get(index);
|
|
1530
|
+
const durationMs = outcome && outcome.startedAt && outcome.endedAt
|
|
1531
|
+
? Math.max(0, new Date(outcome.endedAt).getTime() - new Date(outcome.startedAt).getTime())
|
|
1532
|
+
: 0;
|
|
1533
|
+
if (!outcome) {
|
|
1534
|
+
return {
|
|
1535
|
+
index,
|
|
1536
|
+
kind: step.kind,
|
|
1537
|
+
status: "failed",
|
|
1538
|
+
durationMs: 0,
|
|
1539
|
+
error: conversationBroken
|
|
1540
|
+
? "Step not reached — the conversation ended early."
|
|
1541
|
+
: "Step was not executed by the host.",
|
|
1542
|
+
matchedMessageIndex: null,
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
if (step.kind !== "expect") {
|
|
1546
|
+
const failed = Boolean(outcome.error);
|
|
1547
|
+
if (failed)
|
|
1548
|
+
conversationBroken = true;
|
|
1549
|
+
return {
|
|
1550
|
+
index,
|
|
1551
|
+
kind: step.kind,
|
|
1552
|
+
status: failed ? "failed" : "passed",
|
|
1553
|
+
durationMs,
|
|
1554
|
+
error: outcome.error ?? null,
|
|
1555
|
+
matchedMessageIndex: null,
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
const candidates = wsExecution.messages.filter((message) => message.direction === "received" && message.stepIndex === index);
|
|
1559
|
+
let matchedMessageIndex = null;
|
|
1560
|
+
for (const candidate of candidates) {
|
|
1561
|
+
const evaluation = evaluateWebsocketExpect(step.rules ?? [], step.matchMode ?? "all", evaluationScope, candidate);
|
|
1562
|
+
if (evaluation.passed) {
|
|
1563
|
+
matchedMessageIndex = candidate.index;
|
|
1564
|
+
break;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
const failed = matchedMessageIndex === null;
|
|
1568
|
+
if (failed)
|
|
1569
|
+
conversationBroken = true;
|
|
1570
|
+
return {
|
|
1571
|
+
index,
|
|
1572
|
+
kind: step.kind,
|
|
1573
|
+
status: failed ? "failed" : "passed",
|
|
1574
|
+
durationMs,
|
|
1575
|
+
error: failed
|
|
1576
|
+
? (outcome.error ??
|
|
1577
|
+
`No message matched within ${step.timeoutMs}ms (${candidates.length} received).`)
|
|
1578
|
+
: null,
|
|
1579
|
+
matchedMessageIndex,
|
|
1580
|
+
};
|
|
1581
|
+
});
|
|
1582
|
+
const failedSteps = stepResults.filter((entry) => entry.status === "failed").length;
|
|
1583
|
+
const wsErrorMessage = !wsExecution.connected
|
|
1584
|
+
? (wsExecution.connectError ?? "WebSocket connection failed.")
|
|
1585
|
+
: failedSteps > 0
|
|
1586
|
+
? (() => {
|
|
1587
|
+
const firstFailed = stepResults.find((entry) => entry.status === "failed");
|
|
1588
|
+
return `WebSocket step ${(firstFailed?.index ?? 0) + 1} (${firstFailed?.kind}) failed: ${firstFailed?.error}`;
|
|
1589
|
+
})()
|
|
1590
|
+
: null;
|
|
1591
|
+
outputData = {
|
|
1592
|
+
url: resolvedUrl,
|
|
1593
|
+
connected: wsExecution.connected,
|
|
1594
|
+
closeCode: wsExecution.closeCode,
|
|
1595
|
+
closeReason: wsExecution.closeReason ?? null,
|
|
1596
|
+
durationMs: wsExecution.durationMs,
|
|
1597
|
+
messageCount: wsExecution.messages.length,
|
|
1598
|
+
messages: wsExecution.messages,
|
|
1599
|
+
steps: stepResults,
|
|
1600
|
+
failedSteps,
|
|
1601
|
+
errorMessage: wsErrorMessage,
|
|
1602
|
+
};
|
|
1603
|
+
if (wsErrorMessage) {
|
|
1604
|
+
throw new ScenarioNodeFailureError(wsErrorMessage);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1424
1607
|
if (node.type === "condition") {
|
|
1425
1608
|
const conditionIssues = validateConditionConfig(node.data.config);
|
|
1426
1609
|
const blockingConditionIssue = conditionIssues.find((issue) => issue.severity === "error");
|
|
@@ -1533,6 +1716,228 @@ export const runScenario = async ({ scenario, environment = {}, globals = {}, ru
|
|
|
1533
1716
|
shouldMarkPartialSuccess = degradedStepIds.size > degradedCountBefore;
|
|
1534
1717
|
outputData = groupedOutput;
|
|
1535
1718
|
}
|
|
1719
|
+
if (node.type === "foreach") {
|
|
1720
|
+
const foreachConfig = node.data.config;
|
|
1721
|
+
// ── Resolve the items array ──────────────────────────────────────
|
|
1722
|
+
let items;
|
|
1723
|
+
if (foreachConfig.sourceMode === "inline") {
|
|
1724
|
+
const rawInline = (foreachConfig.itemsInline ?? "").trim();
|
|
1725
|
+
if (!rawInline) {
|
|
1726
|
+
throw new ScenarioNodeFailureError("Foreach inline items are empty.");
|
|
1727
|
+
}
|
|
1728
|
+
const resolvedInline = resolveScenarioJsonTemplateString(rawInline, templateValues);
|
|
1729
|
+
let parsedInline;
|
|
1730
|
+
try {
|
|
1731
|
+
parsedInline = JSON.parse(resolvedInline);
|
|
1732
|
+
}
|
|
1733
|
+
catch {
|
|
1734
|
+
throw new ScenarioNodeFailureError("Foreach inline items are not valid JSON after template resolution.");
|
|
1735
|
+
}
|
|
1736
|
+
if (!Array.isArray(parsedInline)) {
|
|
1737
|
+
throw new ScenarioNodeFailureError("Foreach inline items must be a JSON array.");
|
|
1738
|
+
}
|
|
1739
|
+
items = parsedInline;
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
const itemsPath = (foreachConfig.itemsPath ?? "").trim();
|
|
1743
|
+
if (!itemsPath) {
|
|
1744
|
+
throw new ScenarioNodeFailureError("Foreach items path is required.");
|
|
1745
|
+
}
|
|
1746
|
+
const resolved = resolveConditionRuntimeValue({
|
|
1747
|
+
environment: runtimeContext.environment,
|
|
1748
|
+
globals: runtimeContext.globals,
|
|
1749
|
+
workflowContext: runtimeContext.workflowContext,
|
|
1750
|
+
nodeMetaByLabel: runtimeContext.nodeMetaByLabel,
|
|
1751
|
+
responseRoot: runtimeContext.responseRoot,
|
|
1752
|
+
dbResult: runtimeContext.dbResult,
|
|
1753
|
+
kafkaEvent: runtimeContext.kafkaEvent,
|
|
1754
|
+
redisResult: runtimeContext.redisResult,
|
|
1755
|
+
}, itemsPath);
|
|
1756
|
+
if (!resolved.exists || typeof resolved.value === "undefined") {
|
|
1757
|
+
throw new ScenarioNodeFailureError(`Foreach items path "${itemsPath}" resolved to nothing.`);
|
|
1758
|
+
}
|
|
1759
|
+
if (!Array.isArray(resolved.value)) {
|
|
1760
|
+
throw new ScenarioNodeFailureError(`Foreach items path "${itemsPath}" must resolve to an array (got ${typeof resolved.value}).`);
|
|
1761
|
+
}
|
|
1762
|
+
items = resolved.value;
|
|
1763
|
+
}
|
|
1764
|
+
const itemAlias = (foreachConfig.itemAlias ?? "").trim();
|
|
1765
|
+
if (itemAlias && RESERVED_WORKFLOW_ROOT_LABELS.has(itemAlias)) {
|
|
1766
|
+
throw new ScenarioNodeFailureError(`Foreach item alias "${itemAlias}" is a reserved name.`);
|
|
1767
|
+
}
|
|
1768
|
+
const maxIterations = Math.min(MAX_FOREACH_ITERATIONS, Math.max(1, Math.round(foreachConfig.maxIterations ?? DEFAULT_FOREACH_MAX_ITERATIONS)));
|
|
1769
|
+
const processLimit = Math.min(items.length, maxIterations);
|
|
1770
|
+
const iterationDelayMs = Math.max(0, Math.round(foreachConfig.delayMs ?? 0));
|
|
1771
|
+
const onItemFailure = foreachConfig.onItemFailure ?? "stop";
|
|
1772
|
+
const collectResults = foreachConfig.collectResults !== false;
|
|
1773
|
+
// Thinned emission keeps stored events bounded (~100 iteration markers).
|
|
1774
|
+
const iterationEmitStride = Math.max(1, Math.ceil(processLimit / 100));
|
|
1775
|
+
const internalGraph = buildScenarioExecutionGraph(foreachConfig.nodes, foreachConfig.edges);
|
|
1776
|
+
const internalScope = {
|
|
1777
|
+
graph: internalGraph,
|
|
1778
|
+
stepIdForNode: (childNodeId) => createSubScenarioStepId(stepId, childNodeId),
|
|
1779
|
+
stepIdForEdge: (edgeId) => createSubScenarioStepId(stepId, edgeId),
|
|
1780
|
+
};
|
|
1781
|
+
// ALL descendant step ids (nested containers included) — reset
|
|
1782
|
+
// targets between iterations.
|
|
1783
|
+
const internalStepIds = buildRuntimeStepDescriptors(foreachConfig.nodes, stepId).map((descriptor) => descriptor.stepId);
|
|
1784
|
+
const childLabels = flattenScenarioNodesForContext(foreachConfig.nodes)
|
|
1785
|
+
.map((childNode) => childNode.data.label.trim())
|
|
1786
|
+
.filter((childLabel) => childLabel.length > 0);
|
|
1787
|
+
const workflowRoots = runtimeContext.workflowContext;
|
|
1788
|
+
// Save the enclosing iteration roots so a NESTED foreach restores
|
|
1789
|
+
// its parent's {{item}}/{{each}} when it finishes mid-iteration.
|
|
1790
|
+
const hadItemRoot = Object.prototype.hasOwnProperty.call(workflowRoots, "item");
|
|
1791
|
+
const previousItemRoot = workflowRoots.item;
|
|
1792
|
+
const hadEachRoot = Object.prototype.hasOwnProperty.call(workflowRoots, "each");
|
|
1793
|
+
const previousEachRoot = workflowRoots.each;
|
|
1794
|
+
const hadAliasRoot = itemAlias
|
|
1795
|
+
? Object.prototype.hasOwnProperty.call(workflowRoots, itemAlias)
|
|
1796
|
+
: false;
|
|
1797
|
+
const previousAliasRoot = itemAlias ? workflowRoots[itemAlias] : undefined;
|
|
1798
|
+
const nodeLabelKey = nodeLabel;
|
|
1799
|
+
const previousEaches = workflowRoots.eaches;
|
|
1800
|
+
const degradedCountBefore = degradedStepIds.size;
|
|
1801
|
+
const results = [];
|
|
1802
|
+
let failedItems = 0;
|
|
1803
|
+
try {
|
|
1804
|
+
for (let index = 0; index < processLimit; index += 1) {
|
|
1805
|
+
throwIfStopped(signal);
|
|
1806
|
+
if (index > 0) {
|
|
1807
|
+
// Fresh pass: every internal step back to idle (including the
|
|
1808
|
+
// "skipped" stamped on unreached nodes last pass), degraded
|
|
1809
|
+
// marks cleared, records reset via the bulk step:reset event.
|
|
1810
|
+
for (const internalStepId of internalStepIds) {
|
|
1811
|
+
localStatuses.set(internalStepId, "idle");
|
|
1812
|
+
degradedStepIds.delete(internalStepId);
|
|
1813
|
+
}
|
|
1814
|
+
await emit({
|
|
1815
|
+
type: "step:reset",
|
|
1816
|
+
runId,
|
|
1817
|
+
scenarioId: scenario.id,
|
|
1818
|
+
stepIds: internalStepIds,
|
|
1819
|
+
at: new Date().toISOString(),
|
|
1820
|
+
reason: `Item ${index + 1}/${processLimit}: reset foreach body`,
|
|
1821
|
+
});
|
|
1822
|
+
if (iterationDelayMs > 0) {
|
|
1823
|
+
await waitForDuration(iterationDelayMs);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
// Fresh-pass isolation: a failed/short-circuited item must not
|
|
1827
|
+
// inherit the previous iteration's child outputs in its results
|
|
1828
|
+
// snapshot. The final iteration's children stay published after
|
|
1829
|
+
// the loop (last-iteration-wins for downstream reads).
|
|
1830
|
+
for (const childLabel of childLabels) {
|
|
1831
|
+
delete workflowRoots[childLabel];
|
|
1832
|
+
}
|
|
1833
|
+
const item = items[index];
|
|
1834
|
+
const frame = {
|
|
1835
|
+
index,
|
|
1836
|
+
iteration: index + 1,
|
|
1837
|
+
total: processLimit,
|
|
1838
|
+
remaining: processLimit - (index + 1),
|
|
1839
|
+
};
|
|
1840
|
+
workflowRoots.item = item;
|
|
1841
|
+
if (itemAlias) {
|
|
1842
|
+
workflowRoots[itemAlias] = item;
|
|
1843
|
+
}
|
|
1844
|
+
workflowRoots.each = frame;
|
|
1845
|
+
if (nodeLabelKey) {
|
|
1846
|
+
const eachesRoot = workflowRoots.eaches && typeof workflowRoots.eaches === "object"
|
|
1847
|
+
? workflowRoots.eaches
|
|
1848
|
+
: {};
|
|
1849
|
+
workflowRoots.eaches = { ...eachesRoot, [nodeLabelKey]: frame };
|
|
1850
|
+
}
|
|
1851
|
+
if (index === 0 ||
|
|
1852
|
+
index === processLimit - 1 ||
|
|
1853
|
+
(index + 1) % iterationEmitStride === 0) {
|
|
1854
|
+
const itemPreview = (() => {
|
|
1855
|
+
try {
|
|
1856
|
+
const serialized = JSON.stringify(item);
|
|
1857
|
+
if (typeof serialized !== "string")
|
|
1858
|
+
return String(item);
|
|
1859
|
+
return serialized.length > 2048 ? `${serialized.slice(0, 2048)}…` : serialized;
|
|
1860
|
+
}
|
|
1861
|
+
catch {
|
|
1862
|
+
return null;
|
|
1863
|
+
}
|
|
1864
|
+
})();
|
|
1865
|
+
await emit({
|
|
1866
|
+
type: "step:iteration",
|
|
1867
|
+
runId,
|
|
1868
|
+
scenarioId: scenario.id,
|
|
1869
|
+
stepId,
|
|
1870
|
+
stepType: node.type,
|
|
1871
|
+
title,
|
|
1872
|
+
at: new Date().toISOString(),
|
|
1873
|
+
index,
|
|
1874
|
+
iteration: index + 1,
|
|
1875
|
+
total: processLimit,
|
|
1876
|
+
itemPreview,
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
try {
|
|
1880
|
+
for (const startNodeId of internalGraph.startNodeIds) {
|
|
1881
|
+
throwIfStopped(signal);
|
|
1882
|
+
await executeNode(startNodeId, null, {}, internalScope);
|
|
1883
|
+
}
|
|
1884
|
+
await markScopeRemainingNodesSkipped(internalScope, `Internal node was not reached inside ${title} (item ${index + 1}).`);
|
|
1885
|
+
}
|
|
1886
|
+
catch (error) {
|
|
1887
|
+
if (error instanceof ScenarioStopError) {
|
|
1888
|
+
throw error;
|
|
1889
|
+
}
|
|
1890
|
+
failedItems += 1;
|
|
1891
|
+
if (onItemFailure === "stop") {
|
|
1892
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1893
|
+
throw new ScenarioNodeFailureError(`Foreach item ${index + 1}/${processLimit} failed: ${message}`);
|
|
1894
|
+
}
|
|
1895
|
+
// continue: unreached internal nodes stay consistent for the
|
|
1896
|
+
// report, the run degrades to partial success below.
|
|
1897
|
+
await markScopeRemainingNodesSkipped(internalScope, `Internal node was not reached inside ${title} (item ${index + 1} failed).`);
|
|
1898
|
+
}
|
|
1899
|
+
if (collectResults) {
|
|
1900
|
+
const iterationOutput = {};
|
|
1901
|
+
for (const childLabel of childLabels) {
|
|
1902
|
+
if (Object.prototype.hasOwnProperty.call(workflowRoots, childLabel)) {
|
|
1903
|
+
iterationOutput[childLabel] = workflowRoots[childLabel];
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
results.push(iterationOutput);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
finally {
|
|
1911
|
+
// Restore the enclosing iteration roots (or clear ours).
|
|
1912
|
+
if (hadItemRoot)
|
|
1913
|
+
workflowRoots.item = previousItemRoot;
|
|
1914
|
+
else
|
|
1915
|
+
delete workflowRoots.item;
|
|
1916
|
+
if (hadEachRoot)
|
|
1917
|
+
workflowRoots.each = previousEachRoot;
|
|
1918
|
+
else
|
|
1919
|
+
delete workflowRoots.each;
|
|
1920
|
+
if (itemAlias) {
|
|
1921
|
+
if (hadAliasRoot)
|
|
1922
|
+
workflowRoots[itemAlias] = previousAliasRoot;
|
|
1923
|
+
else
|
|
1924
|
+
delete workflowRoots[itemAlias];
|
|
1925
|
+
}
|
|
1926
|
+
if (typeof previousEaches === "undefined")
|
|
1927
|
+
delete workflowRoots.eaches;
|
|
1928
|
+
else
|
|
1929
|
+
workflowRoots.eaches = previousEaches;
|
|
1930
|
+
}
|
|
1931
|
+
shouldMarkPartialSuccess =
|
|
1932
|
+
degradedStepIds.size > degradedCountBefore || failedItems > 0;
|
|
1933
|
+
outputData = {
|
|
1934
|
+
...(collectResults ? { results } : {}),
|
|
1935
|
+
itemCount: items.length,
|
|
1936
|
+
processedCount: processLimit,
|
|
1937
|
+
truncated: items.length > processLimit,
|
|
1938
|
+
failedItems,
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1536
1941
|
if (node.type === "end") {
|
|
1537
1942
|
if (node.data.config.loop && node.data.config.loopTargetNodeId) {
|
|
1538
1943
|
const loopTargetNode = scope.graph.nodeMap.get(node.data.config.loopTargetNodeId);
|