@usearazzo/runner 1.0.1-alpha.22 → 1.0.1-alpha.24
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/CHANGELOG.md +20 -0
- package/README.md +1 -1
- package/dist/arazzo-runner.browser.js +473 -293
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +4 -4
- package/src/action/ActionResolver.cjs +4 -4
- package/src/action/ActionResolver.mjs +4 -4
- package/src/criterion/CriterionEvaluator.cjs +8 -9
- package/src/criterion/CriterionEvaluator.mjs +8 -9
- package/src/criterion/JSONPathCriterionEvaluator.cjs +1 -2
- package/src/criterion/JSONPathCriterionEvaluator.mjs +1 -2
- package/src/criterion/RegexCriterionEvaluator.cjs +1 -2
- package/src/criterion/RegexCriterionEvaluator.mjs +1 -2
- package/src/criterion/SimpleCriterionEvaluator.cjs +1 -2
- package/src/criterion/SimpleCriterionEvaluator.mjs +1 -2
- package/src/criterion/XPathCriterionEvaluator.cjs +4 -5
- package/src/criterion/XPathCriterionEvaluator.mjs +4 -5
- package/src/errors/CriterionError.cjs +52 -2
- package/src/errors/CriterionError.mjs +53 -2
- package/src/errors/ExecutionError.cjs +73 -2
- package/src/errors/ExecutionError.mjs +74 -2
- package/src/errors/ResolverError.cjs +53 -2
- package/src/errors/ResolverError.mjs +54 -2
- package/src/errors/RuntimeExpressionError.cjs +32 -2
- package/src/errors/RuntimeExpressionError.mjs +33 -2
- package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +4 -4
- package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +4 -4
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +79 -47
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +80 -48
- package/src/executor/StepExecutor.cjs +42 -32
- package/src/executor/StepExecutor.mjs +42 -32
- package/src/executor/StepRetryRunner.cjs +1 -1
- package/src/executor/StepRetryRunner.mjs +1 -1
- package/src/executor/StepTransitionInterpreter.cjs +3 -3
- package/src/executor/StepTransitionInterpreter.mjs +3 -3
- package/src/executor/WorkflowCallStack.cjs +2 -2
- package/src/executor/WorkflowCallStack.mjs +2 -2
- package/src/executor/WorkflowExecutor.cjs +17 -16
- package/src/executor/WorkflowExecutor.mjs +17 -16
- package/src/executor/abort.cjs +3 -3
- package/src/executor/abort.mjs +3 -3
- package/src/expression/RuntimeExpressionEvaluator.cjs +5 -5
- package/src/expression/RuntimeExpressionEvaluator.mjs +5 -5
- package/src/index.cjs +0 -7
- package/src/index.mjs +0 -1
- package/src/resolver/OpenAPIOperationParameterResolver.cjs +6 -6
- package/src/resolver/OpenAPIOperationParameterResolver.mjs +6 -6
- package/src/resolver/OutputResolver.cjs +3 -3
- package/src/resolver/OutputResolver.mjs +3 -3
- package/src/resolver/RequestBodyResolver.cjs +6 -6
- package/src/resolver/RequestBodyResolver.mjs +6 -6
- package/src/resolver/WorkflowParameterResolver.cjs +1 -1
- package/src/resolver/WorkflowParameterResolver.mjs +1 -1
- package/types/runner.d.ts +236 -60
- package/src/criterion/CriterionErrorReason.cjs +0 -51
- package/src/criterion/CriterionErrorReason.mjs +0 -46
|
@@ -96,7 +96,7 @@ class StepTransitionInterpreter {
|
|
|
96
96
|
throw new ExecutionError(`goto action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
|
|
97
97
|
stepId,
|
|
98
98
|
workflowId,
|
|
99
|
-
reason:
|
|
99
|
+
reason: ExecutionError.AmbiguousTarget
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
if (hasStepId) {
|
|
@@ -114,13 +114,13 @@ class StepTransitionInterpreter {
|
|
|
114
114
|
throw new ExecutionError(`goto action on step "${stepId}" in workflow "${workflowId}" has neither stepId nor workflowId`, {
|
|
115
115
|
stepId,
|
|
116
116
|
workflowId,
|
|
117
|
-
reason:
|
|
117
|
+
reason: ExecutionError.GotoTargetMissing
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
throw new ExecutionError(`action on step "${stepId}" in workflow "${workflowId}" has unsupported type "${type}"`, {
|
|
121
121
|
stepId,
|
|
122
122
|
workflowId,
|
|
123
|
-
reason:
|
|
123
|
+
reason: ExecutionError.UnknownActionType
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -89,7 +89,7 @@ class WorkflowCallStack {
|
|
|
89
89
|
// detects both, so a loop crossing the two mechanisms cannot slip between
|
|
90
90
|
// them.
|
|
91
91
|
const closingEdges = [...this.#calls.slice(repeated + 1).map(call => call.via), via];
|
|
92
|
-
const reason = closingEdges.every(edge => edge === 'dependsOn') ?
|
|
92
|
+
const reason = closingEdges.every(edge => edge === 'dependsOn') ? _ExecutionError.default.DependsOnCycle : _ExecutionError.default.WorkflowCycle;
|
|
93
93
|
throw new _ExecutionError.default(`workflow "${workflowId}" is already in progress; its call chain forms a cycle (${path.join(' -> ')})`, {
|
|
94
94
|
workflowId,
|
|
95
95
|
reason,
|
|
@@ -99,7 +99,7 @@ class WorkflowCallStack {
|
|
|
99
99
|
if (this.#calls.length >= this.#maxDepth) {
|
|
100
100
|
throw new _ExecutionError.default(`workflow "${workflowId}" nests deeper than the limit of ${this.#maxDepth} workflows`, {
|
|
101
101
|
workflowId,
|
|
102
|
-
reason:
|
|
102
|
+
reason: _ExecutionError.default.WorkflowDepth,
|
|
103
103
|
path: [...this.path, this.#display(workflowId, documentURI)]
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -79,7 +79,7 @@ class WorkflowCallStack {
|
|
|
79
79
|
// detects both, so a loop crossing the two mechanisms cannot slip between
|
|
80
80
|
// them.
|
|
81
81
|
const closingEdges = [...this.#calls.slice(repeated + 1).map(call => call.via), via];
|
|
82
|
-
const reason = closingEdges.every(edge => edge === 'dependsOn') ?
|
|
82
|
+
const reason = closingEdges.every(edge => edge === 'dependsOn') ? ExecutionError.DependsOnCycle : ExecutionError.WorkflowCycle;
|
|
83
83
|
throw new ExecutionError(`workflow "${workflowId}" is already in progress; its call chain forms a cycle (${path.join(' -> ')})`, {
|
|
84
84
|
workflowId,
|
|
85
85
|
reason,
|
|
@@ -89,7 +89,7 @@ class WorkflowCallStack {
|
|
|
89
89
|
if (this.#calls.length >= this.#maxDepth) {
|
|
90
90
|
throw new ExecutionError(`workflow "${workflowId}" nests deeper than the limit of ${this.#maxDepth} workflows`, {
|
|
91
91
|
workflowId,
|
|
92
|
-
reason:
|
|
92
|
+
reason: ExecutionError.WorkflowDepth,
|
|
93
93
|
path: [...this.path, this.#display(workflowId, documentURI)]
|
|
94
94
|
});
|
|
95
95
|
}
|
|
@@ -245,7 +245,7 @@ class WorkflowExecutor {
|
|
|
245
245
|
const unknown = Object.keys(options).filter(key => !WorkflowExecutor.#EXECUTE_OPTION_KEYS.has(key));
|
|
246
246
|
if (unknown.length === 0) return;
|
|
247
247
|
throw new _ExecutionError.default(`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
|
|
248
|
-
reason:
|
|
248
|
+
reason: _ExecutionError.default.UnknownExecuteOption
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -378,7 +378,7 @@ class WorkflowExecutor {
|
|
|
378
378
|
break;
|
|
379
379
|
case 'goto':
|
|
380
380
|
index = this.#interpreter.indexOfStep(steps, transition.stepId, workflowId, {
|
|
381
|
-
reason:
|
|
381
|
+
reason: _ExecutionError.default.GotoTargetNotFound,
|
|
382
382
|
label: 'goto target'
|
|
383
383
|
});
|
|
384
384
|
break;
|
|
@@ -425,7 +425,7 @@ class WorkflowExecutor {
|
|
|
425
425
|
throw new _ExecutionError.default(`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
|
|
426
426
|
workflowId,
|
|
427
427
|
stepId,
|
|
428
|
-
reason:
|
|
428
|
+
reason: _ExecutionError.default.UnknownTransitionKind
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
}
|
|
@@ -513,7 +513,7 @@ class WorkflowExecutor {
|
|
|
513
513
|
throw new _ExecutionError.default(`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
|
|
514
514
|
workflowId: invocation.workflowId,
|
|
515
515
|
stepId,
|
|
516
|
-
reason:
|
|
516
|
+
reason: _ExecutionError.default.StepBudget,
|
|
517
517
|
path: invocation.callStack.path
|
|
518
518
|
});
|
|
519
519
|
}
|
|
@@ -618,7 +618,7 @@ class WorkflowExecutor {
|
|
|
618
618
|
throw new _ExecutionError.default(`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
|
|
619
619
|
stepId,
|
|
620
620
|
workflowId,
|
|
621
|
-
reason:
|
|
621
|
+
reason: _ExecutionError.default.AmbiguousTarget
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
if (hasWorkflowId) {
|
|
@@ -642,7 +642,7 @@ class WorkflowExecutor {
|
|
|
642
642
|
}
|
|
643
643
|
const refStepId = (0, _apidomCore.toValue)(action.stepId);
|
|
644
644
|
const refIndex = this.#interpreter.indexOfStep(steps, refStepId, workflowId, {
|
|
645
|
-
reason:
|
|
645
|
+
reason: _ExecutionError.default.RetryTargetNotFound,
|
|
646
646
|
label: 'retry reference'
|
|
647
647
|
});
|
|
648
648
|
const refStep = steps[refIndex];
|
|
@@ -761,14 +761,14 @@ class WorkflowExecutor {
|
|
|
761
761
|
if (!(0, _apidomDatamodel.isArrayElement)(dependsOn)) {
|
|
762
762
|
throw new _ExecutionError.default(`workflow "${workflowId}" has a non-list "dependsOn"`, {
|
|
763
763
|
workflowId,
|
|
764
|
-
reason:
|
|
764
|
+
reason: _ExecutionError.default.MalformedDependsOn
|
|
765
765
|
});
|
|
766
766
|
}
|
|
767
767
|
const references = [...dependsOn].map((entry, index) => {
|
|
768
768
|
if (!(0, _apidomDatamodel.isStringElement)(entry)) {
|
|
769
769
|
throw new _ExecutionError.default(`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
|
|
770
770
|
workflowId,
|
|
771
|
-
reason:
|
|
771
|
+
reason: _ExecutionError.default.MalformedDependsOn
|
|
772
772
|
});
|
|
773
773
|
}
|
|
774
774
|
return (0, _apidomCore.toValue)(entry);
|
|
@@ -810,10 +810,11 @@ class WorkflowExecutor {
|
|
|
810
810
|
callStack
|
|
811
811
|
} = invocation;
|
|
812
812
|
if (!(0, _apidomDatamodel.isStringElement)(step.workflowId)) {
|
|
813
|
-
return () => this.#stepExecutor.forDocument(document).execute(step, state, scope.executeOptions);
|
|
813
|
+
return () => this.#stepExecutor.forDocument(document).execute(step, state, scope.executeOptions, workflowId);
|
|
814
814
|
}
|
|
815
815
|
const reference = this.#subWorkflowReference(step, stepId, workflowId);
|
|
816
816
|
const stepScope = {
|
|
817
|
+
workflowId,
|
|
817
818
|
stepId
|
|
818
819
|
};
|
|
819
820
|
// the reference resolves to the same locator on every attempt, so it is
|
|
@@ -891,12 +892,12 @@ class WorkflowExecutor {
|
|
|
891
892
|
// evaluated by the parent document's step executor — only the sub-run
|
|
892
893
|
// itself switched documents.
|
|
893
894
|
const stepExecutor = this.#stepExecutor.forDocument(document);
|
|
894
|
-
const successCriteria = stepExecutor.evaluateCriteria(step, context);
|
|
895
|
+
const successCriteria = stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
895
896
|
const successful = !this.#settledFailed(result) && successCriteria.every(criterion => criterion.met);
|
|
896
897
|
const {
|
|
897
898
|
matchedActions,
|
|
898
899
|
actionCriteria
|
|
899
|
-
} = stepExecutor.selectActions(step, successful, context);
|
|
900
|
+
} = stepExecutor.selectActions(step, successful, context, workflowId);
|
|
900
901
|
return {
|
|
901
902
|
stepId,
|
|
902
903
|
successful,
|
|
@@ -952,7 +953,7 @@ class WorkflowExecutor {
|
|
|
952
953
|
throw new _ExecutionError.default(`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
|
|
953
954
|
stepId,
|
|
954
955
|
workflowId,
|
|
955
|
-
reason:
|
|
956
|
+
reason: _ExecutionError.default.AmbiguousTarget
|
|
956
957
|
});
|
|
957
958
|
}
|
|
958
959
|
return (0, _apidomCore.toValue)(step.workflowId);
|
|
@@ -998,7 +999,7 @@ class WorkflowExecutor {
|
|
|
998
999
|
if (!document.workflowIndex.has(workflowId)) {
|
|
999
1000
|
throw new _ExecutionError.default(`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
|
|
1000
1001
|
workflowId,
|
|
1001
|
-
reason:
|
|
1002
|
+
reason: _ExecutionError.default.WorkflowNotFound
|
|
1002
1003
|
});
|
|
1003
1004
|
}
|
|
1004
1005
|
const workflow = await this.#normalizer.normalize(this.#extractor.extract(document, workflowId), document);
|
|
@@ -1029,14 +1030,14 @@ class WorkflowExecutor {
|
|
|
1029
1030
|
if (!(0, _apidomDatamodel.isArrayElement)(steps)) {
|
|
1030
1031
|
throw new _ExecutionError.default(`workflow "${workflowId}" has a non-list "steps"`, {
|
|
1031
1032
|
workflowId,
|
|
1032
|
-
reason:
|
|
1033
|
+
reason: _ExecutionError.default.MalformedSteps
|
|
1033
1034
|
});
|
|
1034
1035
|
}
|
|
1035
1036
|
return [...steps].map((step, index) => {
|
|
1036
1037
|
if (!(0, _apidomNsArazzo.isStepElement)(step)) {
|
|
1037
1038
|
throw new _ExecutionError.default(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
|
|
1038
1039
|
workflowId,
|
|
1039
|
-
reason:
|
|
1040
|
+
reason: _ExecutionError.default.MalformedSteps
|
|
1040
1041
|
});
|
|
1041
1042
|
}
|
|
1042
1043
|
return step;
|
|
@@ -1059,7 +1060,7 @@ class WorkflowExecutor {
|
|
|
1059
1060
|
throw new _ResolverError.default('`outputs` is present but is not a map', {
|
|
1060
1061
|
workflowId,
|
|
1061
1062
|
target: 'outputs',
|
|
1062
|
-
reason:
|
|
1063
|
+
reason: _ResolverError.default.MalformedOutputs
|
|
1063
1064
|
});
|
|
1064
1065
|
}
|
|
1065
1066
|
|
|
@@ -231,7 +231,7 @@ class WorkflowExecutor {
|
|
|
231
231
|
const unknown = Object.keys(options).filter(key => !WorkflowExecutor.#EXECUTE_OPTION_KEYS.has(key));
|
|
232
232
|
if (unknown.length === 0) return;
|
|
233
233
|
throw new ExecutionError(`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
|
|
234
|
-
reason:
|
|
234
|
+
reason: ExecutionError.UnknownExecuteOption
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -364,7 +364,7 @@ class WorkflowExecutor {
|
|
|
364
364
|
break;
|
|
365
365
|
case 'goto':
|
|
366
366
|
index = this.#interpreter.indexOfStep(steps, transition.stepId, workflowId, {
|
|
367
|
-
reason:
|
|
367
|
+
reason: ExecutionError.GotoTargetNotFound,
|
|
368
368
|
label: 'goto target'
|
|
369
369
|
});
|
|
370
370
|
break;
|
|
@@ -411,7 +411,7 @@ class WorkflowExecutor {
|
|
|
411
411
|
throw new ExecutionError(`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
|
|
412
412
|
workflowId,
|
|
413
413
|
stepId,
|
|
414
|
-
reason:
|
|
414
|
+
reason: ExecutionError.UnknownTransitionKind
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
417
|
}
|
|
@@ -499,7 +499,7 @@ class WorkflowExecutor {
|
|
|
499
499
|
throw new ExecutionError(`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
|
|
500
500
|
workflowId: invocation.workflowId,
|
|
501
501
|
stepId,
|
|
502
|
-
reason:
|
|
502
|
+
reason: ExecutionError.StepBudget,
|
|
503
503
|
path: invocation.callStack.path
|
|
504
504
|
});
|
|
505
505
|
}
|
|
@@ -604,7 +604,7 @@ class WorkflowExecutor {
|
|
|
604
604
|
throw new ExecutionError(`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
|
|
605
605
|
stepId,
|
|
606
606
|
workflowId,
|
|
607
|
-
reason:
|
|
607
|
+
reason: ExecutionError.AmbiguousTarget
|
|
608
608
|
});
|
|
609
609
|
}
|
|
610
610
|
if (hasWorkflowId) {
|
|
@@ -628,7 +628,7 @@ class WorkflowExecutor {
|
|
|
628
628
|
}
|
|
629
629
|
const refStepId = toValue(action.stepId);
|
|
630
630
|
const refIndex = this.#interpreter.indexOfStep(steps, refStepId, workflowId, {
|
|
631
|
-
reason:
|
|
631
|
+
reason: ExecutionError.RetryTargetNotFound,
|
|
632
632
|
label: 'retry reference'
|
|
633
633
|
});
|
|
634
634
|
const refStep = steps[refIndex];
|
|
@@ -747,14 +747,14 @@ class WorkflowExecutor {
|
|
|
747
747
|
if (!isArrayElement(dependsOn)) {
|
|
748
748
|
throw new ExecutionError(`workflow "${workflowId}" has a non-list "dependsOn"`, {
|
|
749
749
|
workflowId,
|
|
750
|
-
reason:
|
|
750
|
+
reason: ExecutionError.MalformedDependsOn
|
|
751
751
|
});
|
|
752
752
|
}
|
|
753
753
|
const references = [...dependsOn].map((entry, index) => {
|
|
754
754
|
if (!isStringElement(entry)) {
|
|
755
755
|
throw new ExecutionError(`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
|
|
756
756
|
workflowId,
|
|
757
|
-
reason:
|
|
757
|
+
reason: ExecutionError.MalformedDependsOn
|
|
758
758
|
});
|
|
759
759
|
}
|
|
760
760
|
return toValue(entry);
|
|
@@ -796,10 +796,11 @@ class WorkflowExecutor {
|
|
|
796
796
|
callStack
|
|
797
797
|
} = invocation;
|
|
798
798
|
if (!isStringElement(step.workflowId)) {
|
|
799
|
-
return () => this.#stepExecutor.forDocument(document).execute(step, state, scope.executeOptions);
|
|
799
|
+
return () => this.#stepExecutor.forDocument(document).execute(step, state, scope.executeOptions, workflowId);
|
|
800
800
|
}
|
|
801
801
|
const reference = this.#subWorkflowReference(step, stepId, workflowId);
|
|
802
802
|
const stepScope = {
|
|
803
|
+
workflowId,
|
|
803
804
|
stepId
|
|
804
805
|
};
|
|
805
806
|
// the reference resolves to the same locator on every attempt, so it is
|
|
@@ -877,12 +878,12 @@ class WorkflowExecutor {
|
|
|
877
878
|
// evaluated by the parent document's step executor — only the sub-run
|
|
878
879
|
// itself switched documents.
|
|
879
880
|
const stepExecutor = this.#stepExecutor.forDocument(document);
|
|
880
|
-
const successCriteria = stepExecutor.evaluateCriteria(step, context);
|
|
881
|
+
const successCriteria = stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
881
882
|
const successful = !this.#settledFailed(result) && successCriteria.every(criterion => criterion.met);
|
|
882
883
|
const {
|
|
883
884
|
matchedActions,
|
|
884
885
|
actionCriteria
|
|
885
|
-
} = stepExecutor.selectActions(step, successful, context);
|
|
886
|
+
} = stepExecutor.selectActions(step, successful, context, workflowId);
|
|
886
887
|
return {
|
|
887
888
|
stepId,
|
|
888
889
|
successful,
|
|
@@ -938,7 +939,7 @@ class WorkflowExecutor {
|
|
|
938
939
|
throw new ExecutionError(`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
|
|
939
940
|
stepId,
|
|
940
941
|
workflowId,
|
|
941
|
-
reason:
|
|
942
|
+
reason: ExecutionError.AmbiguousTarget
|
|
942
943
|
});
|
|
943
944
|
}
|
|
944
945
|
return toValue(step.workflowId);
|
|
@@ -984,7 +985,7 @@ class WorkflowExecutor {
|
|
|
984
985
|
if (!document.workflowIndex.has(workflowId)) {
|
|
985
986
|
throw new ExecutionError(`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
|
|
986
987
|
workflowId,
|
|
987
|
-
reason:
|
|
988
|
+
reason: ExecutionError.WorkflowNotFound
|
|
988
989
|
});
|
|
989
990
|
}
|
|
990
991
|
const workflow = await this.#normalizer.normalize(this.#extractor.extract(document, workflowId), document);
|
|
@@ -1015,14 +1016,14 @@ class WorkflowExecutor {
|
|
|
1015
1016
|
if (!isArrayElement(steps)) {
|
|
1016
1017
|
throw new ExecutionError(`workflow "${workflowId}" has a non-list "steps"`, {
|
|
1017
1018
|
workflowId,
|
|
1018
|
-
reason:
|
|
1019
|
+
reason: ExecutionError.MalformedSteps
|
|
1019
1020
|
});
|
|
1020
1021
|
}
|
|
1021
1022
|
return [...steps].map((step, index) => {
|
|
1022
1023
|
if (!isStepElement(step)) {
|
|
1023
1024
|
throw new ExecutionError(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
|
|
1024
1025
|
workflowId,
|
|
1025
|
-
reason:
|
|
1026
|
+
reason: ExecutionError.MalformedSteps
|
|
1026
1027
|
});
|
|
1027
1028
|
}
|
|
1028
1029
|
return step;
|
|
@@ -1045,7 +1046,7 @@ class WorkflowExecutor {
|
|
|
1045
1046
|
throw new ResolverError('`outputs` is present but is not a map', {
|
|
1046
1047
|
workflowId,
|
|
1047
1048
|
target: 'outputs',
|
|
1048
|
-
reason:
|
|
1049
|
+
reason: ResolverError.MalformedOutputs
|
|
1049
1050
|
});
|
|
1050
1051
|
}
|
|
1051
1052
|
|
package/src/executor/abort.cjs
CHANGED
|
@@ -39,8 +39,8 @@ const readAbortSignal = options => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Throws
|
|
43
|
-
* nothing otherwise.
|
|
42
|
+
* Throws with reason `ExecutionError.Aborted` when the caller has cancelled
|
|
43
|
+
* the run, and does nothing otherwise.
|
|
44
44
|
*
|
|
45
45
|
* Cancellation throws rather than resolving as a `failed` result because it is
|
|
46
46
|
* not a workflow outcome: nothing was judged by `successCriteria`, no failure
|
|
@@ -62,7 +62,7 @@ const throwIfAborted = (signal, context) => {
|
|
|
62
62
|
throw new _ExecutionError.default(`run aborted before ${where}`, {
|
|
63
63
|
workflowId,
|
|
64
64
|
stepId,
|
|
65
|
-
reason:
|
|
65
|
+
reason: _ExecutionError.default.Aborted,
|
|
66
66
|
path: callStack?.path,
|
|
67
67
|
cause: signal.reason
|
|
68
68
|
});
|
package/src/executor/abort.mjs
CHANGED
|
@@ -31,8 +31,8 @@ export const readAbortSignal = options => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Throws
|
|
35
|
-
* nothing otherwise.
|
|
34
|
+
* Throws with reason `ExecutionError.Aborted` when the caller has cancelled
|
|
35
|
+
* the run, and does nothing otherwise.
|
|
36
36
|
*
|
|
37
37
|
* Cancellation throws rather than resolving as a `failed` result because it is
|
|
38
38
|
* not a workflow outcome: nothing was judged by `successCriteria`, no failure
|
|
@@ -53,7 +53,7 @@ export const throwIfAborted = (signal, context) => {
|
|
|
53
53
|
throw new ExecutionError(`run aborted before ${where}`, {
|
|
54
54
|
workflowId,
|
|
55
55
|
stepId,
|
|
56
|
-
reason:
|
|
56
|
+
reason: ExecutionError.Aborted,
|
|
57
57
|
path: callStack?.path,
|
|
58
58
|
cause: signal.reason
|
|
59
59
|
});
|
|
@@ -96,7 +96,7 @@ class RuntimeExpressionEvaluator {
|
|
|
96
96
|
if (value === undefined && this.#strict) {
|
|
97
97
|
throw new _RuntimeExpressionError.default(`Runtime expression "${expression}" could not be resolved against the context`, {
|
|
98
98
|
expression,
|
|
99
|
-
reason:
|
|
99
|
+
reason: _RuntimeExpressionError.default.UnresolvedReference
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
return value;
|
|
@@ -142,13 +142,13 @@ class RuntimeExpressionEvaluator {
|
|
|
142
142
|
throw new _RuntimeExpressionError.default(`Failed to parse runtime expression "${expression}"`, {
|
|
143
143
|
cause: error,
|
|
144
144
|
expression,
|
|
145
|
-
reason:
|
|
145
|
+
reason: _RuntimeExpressionError.default.ParseError
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
if (!result.result.success || result.tree === undefined) {
|
|
149
149
|
throw new _RuntimeExpressionError.default(`Invalid runtime expression "${expression}"`, {
|
|
150
150
|
expression,
|
|
151
|
-
reason:
|
|
151
|
+
reason: _RuntimeExpressionError.default.InvalidExpression
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
return result.tree;
|
|
@@ -166,7 +166,7 @@ class RuntimeExpressionEvaluator {
|
|
|
166
166
|
if (calledWorkflow === undefined || !HTTP_EXCHANGE_NODES.has(node.type)) return;
|
|
167
167
|
throw new _RuntimeExpressionError.default(`Runtime expression "${expression}" is not available: step "${calledWorkflow.stepId}" calls workflow "${calledWorkflow.workflowId}", not an operation, so it has no HTTP request or response`, {
|
|
168
168
|
expression,
|
|
169
|
-
reason:
|
|
169
|
+
reason: _RuntimeExpressionError.default.UnavailableExpression
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -203,7 +203,7 @@ class RuntimeExpressionEvaluator {
|
|
|
203
203
|
default:
|
|
204
204
|
throw new _RuntimeExpressionError.default(`Unsupported runtime expression node "${node.type}"`, {
|
|
205
205
|
expression,
|
|
206
|
-
reason:
|
|
206
|
+
reason: _RuntimeExpressionError.default.UnsupportedNode
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -87,7 +87,7 @@ class RuntimeExpressionEvaluator {
|
|
|
87
87
|
if (value === undefined && this.#strict) {
|
|
88
88
|
throw new RuntimeExpressionError(`Runtime expression "${expression}" could not be resolved against the context`, {
|
|
89
89
|
expression,
|
|
90
|
-
reason:
|
|
90
|
+
reason: RuntimeExpressionError.UnresolvedReference
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
return value;
|
|
@@ -133,13 +133,13 @@ class RuntimeExpressionEvaluator {
|
|
|
133
133
|
throw new RuntimeExpressionError(`Failed to parse runtime expression "${expression}"`, {
|
|
134
134
|
cause: error,
|
|
135
135
|
expression,
|
|
136
|
-
reason:
|
|
136
|
+
reason: RuntimeExpressionError.ParseError
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
if (!result.result.success || result.tree === undefined) {
|
|
140
140
|
throw new RuntimeExpressionError(`Invalid runtime expression "${expression}"`, {
|
|
141
141
|
expression,
|
|
142
|
-
reason:
|
|
142
|
+
reason: RuntimeExpressionError.InvalidExpression
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
return result.tree;
|
|
@@ -157,7 +157,7 @@ class RuntimeExpressionEvaluator {
|
|
|
157
157
|
if (calledWorkflow === undefined || !HTTP_EXCHANGE_NODES.has(node.type)) return;
|
|
158
158
|
throw new RuntimeExpressionError(`Runtime expression "${expression}" is not available: step "${calledWorkflow.stepId}" calls workflow "${calledWorkflow.workflowId}", not an operation, so it has no HTTP request or response`, {
|
|
159
159
|
expression,
|
|
160
|
-
reason:
|
|
160
|
+
reason: RuntimeExpressionError.UnavailableExpression
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -194,7 +194,7 @@ class RuntimeExpressionEvaluator {
|
|
|
194
194
|
default:
|
|
195
195
|
throw new RuntimeExpressionError(`Unsupported runtime expression node "${node.type}"`, {
|
|
196
196
|
expression,
|
|
197
|
-
reason:
|
|
197
|
+
reason: RuntimeExpressionError.UnsupportedNode
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
}
|
package/src/index.cjs
CHANGED
|
@@ -113,12 +113,6 @@ Object.defineProperty(exports, "CriterionError", {
|
|
|
113
113
|
return _CriterionError.default;
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
-
Object.defineProperty(exports, "CriterionErrorReason", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function () {
|
|
119
|
-
return _CriterionErrorReason.default;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
116
|
Object.defineProperty(exports, "CriterionEvaluationError", {
|
|
123
117
|
enumerable: true,
|
|
124
118
|
get: function () {
|
|
@@ -417,7 +411,6 @@ var _SimpleCriterionEvaluator = _interopRequireDefault(require("./criterion/Simp
|
|
|
417
411
|
var _RegexCriterionEvaluator = _interopRequireDefault(require("./criterion/RegexCriterionEvaluator.cjs"));
|
|
418
412
|
var _JSONPathCriterionEvaluator = _interopRequireDefault(require("./criterion/JSONPathCriterionEvaluator.cjs"));
|
|
419
413
|
var _XPathCriterionEvaluator = _interopRequireDefault(require("./criterion/XPathCriterionEvaluator.cjs"));
|
|
420
|
-
var _CriterionErrorReason = _interopRequireDefault(require("./criterion/CriterionErrorReason.cjs"));
|
|
421
414
|
var _WorkflowExecutionState = _interopRequireDefault(require("./state/WorkflowExecutionState.cjs"));
|
|
422
415
|
var _ArazzoValueResolver = _interopRequireDefault(require("./resolver/ArazzoValueResolver.cjs"));
|
|
423
416
|
var _StepParameterResolver = _interopRequireDefault(require("./resolver/StepParameterResolver.cjs"));
|
package/src/index.mjs
CHANGED
|
@@ -43,7 +43,6 @@ export { default as SimpleCriterionEvaluator } from "./criterion/SimpleCriterion
|
|
|
43
43
|
export { default as RegexCriterionEvaluator } from "./criterion/RegexCriterionEvaluator.mjs";
|
|
44
44
|
export { default as JSONPathCriterionEvaluator } from "./criterion/JSONPathCriterionEvaluator.mjs";
|
|
45
45
|
export { default as XPathCriterionEvaluator } from "./criterion/XPathCriterionEvaluator.mjs";
|
|
46
|
-
export { default as CriterionErrorReason } from "./criterion/CriterionErrorReason.mjs";
|
|
47
46
|
/* Execution State */
|
|
48
47
|
export { default as WorkflowExecutionState } from "./state/WorkflowExecutionState.mjs";
|
|
49
48
|
/* Resolvers */
|
|
@@ -70,7 +70,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver.default {
|
|
|
70
70
|
throw new _ResolverError.default('`parameters` is present but is not a list', {
|
|
71
71
|
...scope,
|
|
72
72
|
target: 'parameters',
|
|
73
|
-
reason:
|
|
73
|
+
reason: _ResolverError.default.MalformedParameters
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
for (const parameter of parameters) {
|
|
@@ -82,7 +82,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver.default {
|
|
|
82
82
|
if (identity === undefined) {
|
|
83
83
|
throw new _ResolverError.default('Parameter has a missing or non-string name', {
|
|
84
84
|
...scope,
|
|
85
|
-
reason:
|
|
85
|
+
reason: _ResolverError.default.MissingName
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
const {
|
|
@@ -93,21 +93,21 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver.default {
|
|
|
93
93
|
throw new _ResolverError.default(`Parameter "${name}" declares no location ("in"), which a step targeting an operation requires`, {
|
|
94
94
|
...scope,
|
|
95
95
|
target: name,
|
|
96
|
-
reason:
|
|
96
|
+
reason: _ResolverError.default.MissingLocation
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
if (location === null) {
|
|
100
100
|
throw new _ResolverError.default(`Parameter "${name}" has a non-string location ("in")`, {
|
|
101
101
|
...scope,
|
|
102
102
|
target: name,
|
|
103
|
-
reason:
|
|
103
|
+
reason: _ResolverError.default.MalformedLocation
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
if (!identity.hasDefinedLocation) {
|
|
107
107
|
throw new _ResolverError.default(`Parameter "${name}" has location "${location}", which is not one of ` + `${_ParameterIdentity.default.LOCATIONS.join(', ')}`, {
|
|
108
108
|
...scope,
|
|
109
109
|
target: name,
|
|
110
|
-
reason:
|
|
110
|
+
reason: _ResolverError.default.InvalidLocation
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
const {
|
|
@@ -121,7 +121,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver.default {
|
|
|
121
121
|
throw new _ResolverError.default(`Parameter "${name}" (in: ${location}) ${why} and cannot be delivered unambiguously`, {
|
|
122
122
|
...scope,
|
|
123
123
|
target: name,
|
|
124
|
-
reason:
|
|
124
|
+
reason: _ResolverError.default.AmbiguousDelivery
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
delivery.set(key, this.resolveValue(parameter.value, resolve));
|
|
@@ -63,7 +63,7 @@ class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
|
63
63
|
throw new ResolverError('`parameters` is present but is not a list', {
|
|
64
64
|
...scope,
|
|
65
65
|
target: 'parameters',
|
|
66
|
-
reason:
|
|
66
|
+
reason: ResolverError.MalformedParameters
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
for (const parameter of parameters) {
|
|
@@ -75,7 +75,7 @@ class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
|
75
75
|
if (identity === undefined) {
|
|
76
76
|
throw new ResolverError('Parameter has a missing or non-string name', {
|
|
77
77
|
...scope,
|
|
78
|
-
reason:
|
|
78
|
+
reason: ResolverError.MissingName
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const {
|
|
@@ -86,21 +86,21 @@ class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
|
86
86
|
throw new ResolverError(`Parameter "${name}" declares no location ("in"), which a step targeting an operation requires`, {
|
|
87
87
|
...scope,
|
|
88
88
|
target: name,
|
|
89
|
-
reason:
|
|
89
|
+
reason: ResolverError.MissingLocation
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
if (location === null) {
|
|
93
93
|
throw new ResolverError(`Parameter "${name}" has a non-string location ("in")`, {
|
|
94
94
|
...scope,
|
|
95
95
|
target: name,
|
|
96
|
-
reason:
|
|
96
|
+
reason: ResolverError.MalformedLocation
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
if (!identity.hasDefinedLocation) {
|
|
100
100
|
throw new ResolverError(`Parameter "${name}" has location "${location}", which is not one of ` + `${ParameterIdentity.LOCATIONS.join(', ')}`, {
|
|
101
101
|
...scope,
|
|
102
102
|
target: name,
|
|
103
|
-
reason:
|
|
103
|
+
reason: ResolverError.InvalidLocation
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
const {
|
|
@@ -114,7 +114,7 @@ class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
|
114
114
|
throw new ResolverError(`Parameter "${name}" (in: ${location}) ${why} and cannot be delivered unambiguously`, {
|
|
115
115
|
...scope,
|
|
116
116
|
target: name,
|
|
117
|
-
reason:
|
|
117
|
+
reason: ResolverError.AmbiguousDelivery
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
delivery.set(key, this.resolveValue(parameter.value, resolve));
|
|
@@ -30,7 +30,7 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
30
30
|
*
|
|
31
31
|
* `scope` names the step or workflow the outputs belong to, for a thrown
|
|
32
32
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
33
|
-
* expression throws with
|
|
33
|
+
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
34
34
|
*/
|
|
35
35
|
resolve(outputs, resolve, scope) {
|
|
36
36
|
const result = {};
|
|
@@ -41,7 +41,7 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
41
41
|
throw new _ResolverError.default('`outputs` is present but is not a map', {
|
|
42
42
|
...scope,
|
|
43
43
|
target: 'outputs',
|
|
44
|
-
reason:
|
|
44
|
+
reason: _ResolverError.default.MalformedOutputs
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
outputs.forEach((value, key) => {
|
|
@@ -51,7 +51,7 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
51
51
|
throw new _ResolverError.default(`Output "${name}" is not a valid runtime expression`, {
|
|
52
52
|
...scope,
|
|
53
53
|
target: 'outputs',
|
|
54
|
-
reason:
|
|
54
|
+
reason: _ResolverError.default.InvalidExpression
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
// defined rather than assigned: a name like `__proto__` hits the
|
|
@@ -23,7 +23,7 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
23
23
|
*
|
|
24
24
|
* `scope` names the step or workflow the outputs belong to, for a thrown
|
|
25
25
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
26
|
-
* expression throws with
|
|
26
|
+
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
27
27
|
*/
|
|
28
28
|
resolve(outputs, resolve, scope) {
|
|
29
29
|
const result = {};
|
|
@@ -34,7 +34,7 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
34
34
|
throw new ResolverError('`outputs` is present but is not a map', {
|
|
35
35
|
...scope,
|
|
36
36
|
target: 'outputs',
|
|
37
|
-
reason:
|
|
37
|
+
reason: ResolverError.MalformedOutputs
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
outputs.forEach((value, key) => {
|
|
@@ -44,7 +44,7 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
44
44
|
throw new ResolverError(`Output "${name}" is not a valid runtime expression`, {
|
|
45
45
|
...scope,
|
|
46
46
|
target: 'outputs',
|
|
47
|
-
reason:
|
|
47
|
+
reason: ResolverError.InvalidExpression
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
// defined rather than assigned: a name like `__proto__` hits the
|