@usearazzo/runner 1.0.1-alpha.26 → 1.0.1-alpha.28
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 +24 -0
- package/README.md +28 -2
- package/dist/arazzo-runner.browser.js +3604 -3033
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +16 -16
- package/src/ArazzoRunner.cjs +39 -4
- package/src/ArazzoRunner.mjs +38 -4
- package/src/criterion/CriterionEvaluator.cjs +2 -2
- package/src/criterion/CriterionEvaluator.mjs +3 -3
- package/src/errors/ResolverError.cjs +7 -0
- package/src/errors/ResolverError.mjs +7 -0
- package/src/executor/StepExecutor.cjs +24 -1
- package/src/executor/StepExecutor.mjs +24 -1
- package/src/executor/StepRetryRunner.cjs +1 -1
- package/src/executor/StepRetryRunner.mjs +1 -1
- package/src/executor/WorkflowExecutor.cjs +114 -24
- package/src/executor/WorkflowExecutor.mjs +115 -25
- package/src/resolver/WorkflowParameterResolver.cjs +2 -1
- package/src/resolver/WorkflowParameterResolver.mjs +2 -1
- package/src/state/WorkflowExecutionState.cjs +3 -1
- package/src/state/WorkflowExecutionState.mjs +3 -1
- package/types/runner.d.ts +73 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toValue } from '@speclynx/apidom-core';
|
|
2
2
|
import { isArrayElement, isObjectElement, isStringElement } from '@speclynx/apidom-datamodel';
|
|
3
|
-
import { isStepElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
3
|
+
import { isFailureActionElement, isParameterElement, isStepElement, isSuccessActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
4
4
|
import RuntimeExpressionEvaluator from "../expression/RuntimeExpressionEvaluator.mjs";
|
|
5
5
|
import ArazzoWorkflowExtractor from "../extractor/ArazzoWorkflowExtractor.mjs";
|
|
6
6
|
import ArazzoWorkflowNormalizer from "../normalizer/ArazzoWorkflowNormalizer.mjs";
|
|
@@ -149,7 +149,7 @@ class WorkflowExecutor {
|
|
|
149
149
|
#maxWorkflowDepth;
|
|
150
150
|
#now;
|
|
151
151
|
#extractor = new ArazzoWorkflowExtractor();
|
|
152
|
-
#normalizer
|
|
152
|
+
#normalizer;
|
|
153
153
|
#outputResolver = new OutputResolver();
|
|
154
154
|
#parameterResolver = new WorkflowParameterResolver();
|
|
155
155
|
#stepExecutor;
|
|
@@ -160,6 +160,7 @@ class WorkflowExecutor {
|
|
|
160
160
|
this.#document = options.document;
|
|
161
161
|
this.#registry = options.registry;
|
|
162
162
|
this.#workflowLocatorNormalizer = new ArazzoWorkflowLocatorNormalizer(options.registry);
|
|
163
|
+
this.#normalizer = options.workflowNormalizer ?? new ArazzoWorkflowNormalizer();
|
|
163
164
|
this.#maxSteps = options.maxSteps ?? WorkflowExecutor.#DEFAULT_MAX_STEPS;
|
|
164
165
|
this.#maxWorkflowDepth = options.maxWorkflowDepth ?? WorkflowExecutor.#DEFAULT_MAX_WORKFLOW_DEPTH;
|
|
165
166
|
this.#now = options.now ?? WorkflowExecutor.#DEFAULT_NOW;
|
|
@@ -287,6 +288,16 @@ class WorkflowExecutor {
|
|
|
287
288
|
// included: an unreadable assertion found at step three must not cost the
|
|
288
289
|
// run the requests of steps one and two.
|
|
289
290
|
for (const step of steps) this.#stepExecutor.assertSuccessCriteria(step, workflowId);
|
|
291
|
+
// and to every action's `parameters`, for the same reason: an `in` the
|
|
292
|
+
// specification forbids must not cost the run the requests before the
|
|
293
|
+
// step whose action carries it.
|
|
294
|
+
// the workflow's own default actions too: one every step overrides by
|
|
295
|
+
// name never reaches a step's list, yet the validator still reports it.
|
|
296
|
+
this.#assertActionParameters([workflow.successActions, workflow.failureActions], workflowId);
|
|
297
|
+
for (const step of steps) {
|
|
298
|
+
const stepId = toValue(step.stepId);
|
|
299
|
+
this.#assertActionParameters([step.onSuccess, step.onFailure], workflowId, stepId);
|
|
300
|
+
}
|
|
290
301
|
const dependencies = await this.#runDependencies(workflow, invocation, scope);
|
|
291
302
|
if (dependencies.some(dependency => this.#settledFailed(dependency))) {
|
|
292
303
|
// a declared prerequisite did not complete, so this workflow cannot be
|
|
@@ -382,7 +393,7 @@ class WorkflowExecutor {
|
|
|
382
393
|
stepId,
|
|
383
394
|
callStack: nested
|
|
384
395
|
});
|
|
385
|
-
const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto');
|
|
396
|
+
const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto', this.#actionInputs(action?.parameters, outcome, invocation, stepId));
|
|
386
397
|
runOutcome = {
|
|
387
398
|
kind: 'transferred',
|
|
388
399
|
transferredTo
|
|
@@ -558,16 +569,16 @@ class WorkflowExecutor {
|
|
|
558
569
|
* for entering the reference itself, matching the "1 for the step itself
|
|
559
570
|
* plus whatever its sub-run spends" convention a sub-workflow step
|
|
560
571
|
* already follows (without it, a reference to a workflow with few or no
|
|
561
|
-
* steps of its own would cost nothing to fire).
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* `
|
|
567
|
-
*
|
|
568
|
-
* or sub-workflow step sharing
|
|
569
|
-
* inputs value must not erase one
|
|
570
|
-
* already gave.
|
|
572
|
+
* steps of its own would cost nothing to fire). Its inputs are the
|
|
573
|
+
* action's `parameters` (`#115`), resolved again on every firing
|
|
574
|
+
* against the attempt that fired it — `{}` without them. Its outputs are
|
|
575
|
+
* recorded via `state.setWorkflow`, which *is* "context transfers back",
|
|
576
|
+
* together with the inputs it ran with when the action carries
|
|
577
|
+
* `parameters`. Without them, the recorded `inputs` are preserved rather
|
|
578
|
+
* than overwritten with `{}` when this workflowId was already recorded
|
|
579
|
+
* (by an earlier `dependsOn` prerequisite or sub-workflow step sharing
|
|
580
|
+
* the id): this call's own lack of a real inputs value must not erase one
|
|
581
|
+
* a different, better-informed caller already gave.
|
|
571
582
|
* - a `stepId` reference must name a step of the current workflow (checked
|
|
572
583
|
* lazily, at fire time, via the same lookup a `goto` target uses) and
|
|
573
584
|
* runs as one more attempt at that step, through
|
|
@@ -590,7 +601,7 @@ class WorkflowExecutor {
|
|
|
590
601
|
state,
|
|
591
602
|
callStack
|
|
592
603
|
} = invocation;
|
|
593
|
-
return async action => {
|
|
604
|
+
return async (action, outcome) => {
|
|
594
605
|
throwIfAborted(scope.signal, {
|
|
595
606
|
workflowId,
|
|
596
607
|
stepId,
|
|
@@ -609,13 +620,16 @@ class WorkflowExecutor {
|
|
|
609
620
|
}
|
|
610
621
|
if (hasWorkflowId) {
|
|
611
622
|
const reference = toValue(action.workflowId);
|
|
623
|
+
// resolved before the budget is charged, so an authoring error in them
|
|
624
|
+
// costs no budget unit.
|
|
625
|
+
const inputs = this.#actionInputs(action.parameters, outcome, invocation, stepId);
|
|
612
626
|
this.#chargeBudget(scope, invocation, stepId);
|
|
613
|
-
const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry');
|
|
627
|
+
const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry', inputs);
|
|
614
628
|
// the result's workflowId is the bare id the reference resolved to —
|
|
615
629
|
// the key run state is recorded under, whichever document owns it.
|
|
616
630
|
const refId = result.workflowId;
|
|
617
631
|
state.setWorkflow(refId, {
|
|
618
|
-
inputs: state.getWorkflow(refId)?.inputs ?? {},
|
|
632
|
+
inputs: action.hasKey('parameters') ? inputs : state.getWorkflow(refId)?.inputs ?? {},
|
|
619
633
|
outputs: result.outputs
|
|
620
634
|
});
|
|
621
635
|
retryReferences.push({
|
|
@@ -633,12 +647,12 @@ class WorkflowExecutor {
|
|
|
633
647
|
});
|
|
634
648
|
const refStep = steps[refIndex];
|
|
635
649
|
const refSubWorkflows = [];
|
|
636
|
-
const
|
|
637
|
-
state.setStepOutputs(
|
|
650
|
+
const refOutcome = await this.#chargedAttempt(this.#stepAttempt(refStep, refStepId, invocation, scope, refSubWorkflows), invocation, scope, refStepId)();
|
|
651
|
+
state.setStepOutputs(refOutcome.stepId, refOutcome.outputs);
|
|
638
652
|
retryReferences.push({
|
|
639
653
|
kind: 'step',
|
|
640
654
|
id: refStepId,
|
|
641
|
-
successful:
|
|
655
|
+
successful: refOutcome.successful,
|
|
642
656
|
...(refSubWorkflows.length > 0 ? {
|
|
643
657
|
subWorkflow: refSubWorkflows[0]
|
|
644
658
|
} : {})
|
|
@@ -891,7 +905,8 @@ class WorkflowExecutor {
|
|
|
891
905
|
action: matchedActions[0],
|
|
892
906
|
matchedActions,
|
|
893
907
|
successCriteria,
|
|
894
|
-
actionCriteria
|
|
908
|
+
actionCriteria,
|
|
909
|
+
actionContext: stepExecutor.actionContext(context, stepId, outputs)
|
|
895
910
|
};
|
|
896
911
|
};
|
|
897
912
|
}
|
|
@@ -948,20 +963,95 @@ class WorkflowExecutor {
|
|
|
948
963
|
/**
|
|
949
964
|
* Runs a workflow an action references directly — a retry's `workflowId`
|
|
950
965
|
* reference or a goto's transfer, plain id or cross-document expression —
|
|
951
|
-
* with
|
|
952
|
-
*
|
|
966
|
+
* with the inputs its action's `parameters` resolved to (`#115`), `{}`
|
|
967
|
+
* without them.
|
|
953
968
|
*
|
|
954
969
|
* Shared rather than duplicated by its two callers, which otherwise repeat
|
|
955
|
-
* the identical "resolve the reference, then run
|
|
970
|
+
* the identical "resolve the reference, then run it" sequence.
|
|
956
971
|
* A target its document does not define is rejected by the normalizer,
|
|
957
972
|
* attributed to the calling workflow and `stepId`.
|
|
958
973
|
*/
|
|
959
|
-
async #runReferencedWorkflow(reference, stepId, invocation, scope, via) {
|
|
974
|
+
async #runReferencedWorkflow(reference, stepId, invocation, scope, via, inputs) {
|
|
960
975
|
const locator = await this.#workflowLocatorNormalizer.normalize(reference, invocation.document, {
|
|
961
976
|
workflowId: invocation.workflowId,
|
|
962
977
|
stepId
|
|
963
978
|
});
|
|
964
|
-
return this.#run(locator,
|
|
979
|
+
return this.#run(locator, inputs, scope, invocation.callStack, via);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* The inputs a `goto` / `retry` action naming a `workflowId` passes its
|
|
984
|
+
* target: the action's own `parameters`, mapped by name and resolved against
|
|
985
|
+
* the context of the attempt that fired it — `$statusCode`, `$response.*`
|
|
986
|
+
* and the rest of that step outcome, plus the outputs it just produced.
|
|
987
|
+
* Resolved against the calling invocation's document, so its `$components`
|
|
988
|
+
* apply, never the target's. No `parameters` gives `{}`. Their shape was
|
|
989
|
+
* checked before the workflow's first request, by
|
|
990
|
+
* {@link WorkflowExecutor.#assertActionParameters}.
|
|
991
|
+
*/
|
|
992
|
+
#actionInputs(parameters, outcome, invocation, stepId) {
|
|
993
|
+
const {
|
|
994
|
+
workflowId,
|
|
995
|
+
document
|
|
996
|
+
} = invocation;
|
|
997
|
+
return this.#parameterResolver.resolve(parameters, expression => this.#evaluate(outcome.actionContext, expression, document), {
|
|
998
|
+
workflowId,
|
|
999
|
+
stepId
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Throws {@link ResolverError} unless every action in `lists` — a step's
|
|
1005
|
+
* `onSuccess` / `onFailure`, or the workflow's own `successActions` /
|
|
1006
|
+
* `failureActions` — has an absent `parameters` or a list free of inline `in`:
|
|
1007
|
+
* `malformed-parameters` for one that is present but not a list,
|
|
1008
|
+
* `action-parameter-location` for a Parameter Object that declares `in`. The
|
|
1009
|
+
* specification says outright that "The `in` field MUST NOT be used" on
|
|
1010
|
+
* them. An `in` arriving through a `$components.parameters` Reusable Object
|
|
1011
|
+
* is not inline — a shared component carries `in` for the operation steps
|
|
1012
|
+
* that use it — and the dereferencer marks the transcluded copy with
|
|
1013
|
+
* `ref-fields`.
|
|
1014
|
+
*
|
|
1015
|
+
* Checked for every action, `workflowId` or not, before any step of the
|
|
1016
|
+
* workflow runs: both are authoring errors the validator reports, so a run
|
|
1017
|
+
* must not make requests on the way to discovering them. Valid `parameters`
|
|
1018
|
+
* on an action naming no `workflowId` are still ignored, as the validator
|
|
1019
|
+
* only warns about them. A list that is not an array is skipped here and left
|
|
1020
|
+
* for the code that reads it to report. `stepId` is absent for the
|
|
1021
|
+
* workflow's own lists, and the error then names the workflow alone.
|
|
1022
|
+
*/
|
|
1023
|
+
#assertActionParameters(lists, workflowId, stepId) {
|
|
1024
|
+
const owner = stepId === undefined ? `workflow "${workflowId}"` : `step "${stepId}" in workflow "${workflowId}"`;
|
|
1025
|
+
for (const actions of lists) {
|
|
1026
|
+
if (!isArrayElement(actions)) continue;
|
|
1027
|
+
for (const action of actions) {
|
|
1028
|
+
if (!isSuccessActionElement(action) && !isFailureActionElement(action)) continue;
|
|
1029
|
+
if (!action.hasKey('parameters')) continue;
|
|
1030
|
+
const scope = {
|
|
1031
|
+
workflowId,
|
|
1032
|
+
...(stepId === undefined ? {} : {
|
|
1033
|
+
stepId
|
|
1034
|
+
}),
|
|
1035
|
+
target: 'parameters'
|
|
1036
|
+
};
|
|
1037
|
+
const {
|
|
1038
|
+
parameters
|
|
1039
|
+
} = action;
|
|
1040
|
+
if (!isArrayElement(parameters)) {
|
|
1041
|
+
throw new ResolverError('`parameters` is present but is not a list', {
|
|
1042
|
+
...scope,
|
|
1043
|
+
reason: ResolverError.MalformedParameters
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
const inline = [...parameters].some(parameter => isParameterElement(parameter) && parameter.hasKey('in') && !parameter.meta.hasKey('ref-fields'));
|
|
1047
|
+
if (inline) {
|
|
1048
|
+
throw new ResolverError(`An action parameter of ${owner} declares an \`in\`; action parameters map to the target workflow's inputs by name`, {
|
|
1049
|
+
...scope,
|
|
1050
|
+
reason: ResolverError.ActionParameterLocation
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
965
1055
|
}
|
|
966
1056
|
|
|
967
1057
|
/**
|
|
@@ -12,7 +12,8 @@ var _ResolverError = _interopRequireDefault(require("../errors/ResolverError.cjs
|
|
|
12
12
|
var _StepParameterResolver = _interopRequireDefault(require("./StepParameterResolver.cjs"));
|
|
13
13
|
/**
|
|
14
14
|
* Resolves the `parameters` of a step targeting a `workflowId` into the
|
|
15
|
-
* sub-workflow's inputs
|
|
15
|
+
* sub-workflow's inputs — or those of a `goto` / `retry` action naming a
|
|
16
|
+
* `workflowId` into its target's.
|
|
16
17
|
*
|
|
17
18
|
* Values follow the family-wide literal-vs-expression rule of
|
|
18
19
|
* {@link ArazzoValueResolver}. Keys are bare parameter names: per the
|
|
@@ -5,7 +5,8 @@ import ResolverError from "../errors/ResolverError.mjs";
|
|
|
5
5
|
import StepParameterResolver from "./StepParameterResolver.mjs";
|
|
6
6
|
/**
|
|
7
7
|
* Resolves the `parameters` of a step targeting a `workflowId` into the
|
|
8
|
-
* sub-workflow's inputs
|
|
8
|
+
* sub-workflow's inputs — or those of a `goto` / `retry` action naming a
|
|
9
|
+
* `workflowId` into its target's.
|
|
9
10
|
*
|
|
10
11
|
* Values follow the family-wide literal-vs-expression rule of
|
|
11
12
|
* {@link ArazzoValueResolver}. Keys are bare parameter names: per the
|
|
@@ -37,7 +37,9 @@ class WorkflowExecutionState {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Records the resolved outputs of a completed step, read via
|
|
40
|
-
* `$steps.{stepId}.outputs.{name}`.
|
|
40
|
+
* `$steps.{stepId}.outputs.{name}`. Every run records, so a step run again
|
|
41
|
+
* (a `goto` back, a retry) or a later step sharing its `stepId` replaces
|
|
42
|
+
* the earlier outputs, even with none.
|
|
41
43
|
*/
|
|
42
44
|
setStepOutputs(stepId, outputs) {
|
|
43
45
|
this.#steps.set(stepId, outputs);
|
|
@@ -31,7 +31,9 @@ class WorkflowExecutionState {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Records the resolved outputs of a completed step, read via
|
|
34
|
-
* `$steps.{stepId}.outputs.{name}`.
|
|
34
|
+
* `$steps.{stepId}.outputs.{name}`. Every run records, so a step run again
|
|
35
|
+
* (a `goto` back, a retry) or a later step sharing its `stepId` replaces
|
|
36
|
+
* the earlier outputs, even with none.
|
|
35
37
|
*/
|
|
36
38
|
setStepOutputs(stepId, outputs) {
|
|
37
39
|
this.#steps.set(stepId, outputs);
|
package/types/runner.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ApiDOMReferenceOptions } from '@speclynx/apidom-reference/configuration
|
|
|
3
3
|
import { ApiDOMStructuredError } from '@speclynx/apidom-error';
|
|
4
4
|
import { CriterionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
5
5
|
import { FailureActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
6
|
+
import { FailureActionParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
6
7
|
import { JSONPointer } from '@speclynx/apidom-json-pointer';
|
|
7
8
|
import { OperationElement } from '@speclynx/apidom-ns-openapi-2';
|
|
8
9
|
import { OperationElement as OperationElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
|
|
@@ -20,6 +21,7 @@ import { StepOnSuccessElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
|
20
21
|
import type { StepOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
21
22
|
import { StepParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
22
23
|
import { SuccessActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
24
|
+
import { SuccessActionParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
23
25
|
import { toYAML } from '@speclynx/apidom-core';
|
|
24
26
|
import { WorkflowElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
25
27
|
import type { WorkflowOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
@@ -221,9 +223,14 @@ export declare class ArazzoRunnerError extends ApiDOMStructuredError {
|
|
|
221
223
|
*
|
|
222
224
|
* Every option is a seam of a building block the runner wires: `registry` is
|
|
223
225
|
* the {@link DocumentRegistry} the documents load into (a fresh one with the
|
|
224
|
-
* default providers when omitted), `
|
|
226
|
+
* default providers when omitted), `reference` goes to everything the runner
|
|
227
|
+
* builds that retrieves documents, `httpClient` and `requestInterceptor` go to
|
|
225
228
|
* the {@link OpenAPIOperationExecutor}, and the rest go to the
|
|
226
229
|
* {@link WorkflowExecutor}.
|
|
230
|
+
*
|
|
231
|
+
* Retrieving documents and calling APIs are separate on purpose: `reference`
|
|
232
|
+
* never applies to API calls, and `httpClient` / `requestInterceptor` never
|
|
233
|
+
* apply to document retrieval, so credentials for one do not reach the other.
|
|
227
234
|
* @public
|
|
228
235
|
*/
|
|
229
236
|
export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
|
|
@@ -232,6 +239,20 @@ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationEx
|
|
|
232
239
|
* document: loading a different one into it throws.
|
|
233
240
|
*/
|
|
234
241
|
readonly registry?: DocumentRegistry;
|
|
242
|
+
/**
|
|
243
|
+
* Options of ApiDOM reference, which retrieves the documents: the entry
|
|
244
|
+
* document, its source descriptions and every externally referenced
|
|
245
|
+
* document. Its `resolve` options say how, e.g. `resolverOpts.axiosConfig`
|
|
246
|
+
* for request headers or a TLS agent, or `resolvers` for a resolver list of
|
|
247
|
+
* your own.
|
|
248
|
+
*
|
|
249
|
+
* The runner gives them to the default registry providers and to the
|
|
250
|
+
* normalizers, which fetch external references lazily. A `registry` passed
|
|
251
|
+
* alongside is already configured through its own providers, so `reference`
|
|
252
|
+
* then reaches the normalizers only: give that registry's providers the
|
|
253
|
+
* same options.
|
|
254
|
+
*/
|
|
255
|
+
readonly reference?: ArazzoRunnerReferenceOptions;
|
|
235
256
|
}
|
|
236
257
|
|
|
237
258
|
/**
|
|
@@ -249,6 +270,15 @@ export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOption
|
|
|
249
270
|
readonly registry: DocumentRegistry;
|
|
250
271
|
}
|
|
251
272
|
|
|
273
|
+
/**
|
|
274
|
+
* The options of ApiDOM reference the runner accepts: its `resolve` options,
|
|
275
|
+
* which mean the same for every building block that retrieves documents.
|
|
276
|
+
* `parse` and `dereference` options differ per building block, so the runner
|
|
277
|
+
* passes none of them on; set those on the building blocks themselves.
|
|
278
|
+
* @public
|
|
279
|
+
*/
|
|
280
|
+
export declare type ArazzoRunnerReferenceOptions = Pick<DocumentRegistryProviderOptions, 'resolve'>;
|
|
281
|
+
|
|
252
282
|
/**
|
|
253
283
|
* Index mapping a source description name to its element and canonical URI in
|
|
254
284
|
* an Arazzo document.
|
|
@@ -1716,6 +1746,13 @@ export declare interface ResolvedRequestBody {
|
|
|
1716
1746
|
* @public
|
|
1717
1747
|
*/
|
|
1718
1748
|
export declare class ResolverError extends ArazzoRunnerError {
|
|
1749
|
+
/**
|
|
1750
|
+
* A parameter of a Success / Failure Action declares an `in` inline, which
|
|
1751
|
+
* the Arazzo Specification forbids; one inherited from a
|
|
1752
|
+
* `$components.parameters` Reusable Object maps by name instead. Thrown
|
|
1753
|
+
* before the workflow's first request.
|
|
1754
|
+
*/
|
|
1755
|
+
static readonly ActionParameterLocation: "action-parameter-location";
|
|
1719
1756
|
/** A parameter cannot be delivered unambiguously at its location. */
|
|
1720
1757
|
static readonly AmbiguousDelivery: "ambiguous-delivery";
|
|
1721
1758
|
/** An output or a request body payload holds a value that is not a valid runtime expression. */
|
|
@@ -2169,6 +2206,18 @@ export declare interface StepExecutionResult {
|
|
|
2169
2206
|
* in list order.
|
|
2170
2207
|
*/
|
|
2171
2208
|
readonly actionCriteria: readonly CriterionEvaluationRecord[];
|
|
2209
|
+
/**
|
|
2210
|
+
* The runtime-expression context the step's actions are taken in: the
|
|
2211
|
+
* context its action `criteria` were evaluated against, with
|
|
2212
|
+
* `$steps.{stepId}.outputs` holding the outputs this attempt just resolved.
|
|
2213
|
+
*
|
|
2214
|
+
* An action's `parameters` resolve against it, so a `goto` or `retry` naming
|
|
2215
|
+
* a `workflowId` passes values read from this step's response, request and
|
|
2216
|
+
* fresh outputs. The overlay matters because run state is written only once
|
|
2217
|
+
* a step's retry chain settles, so mid-chain it may still hold an earlier
|
|
2218
|
+
* run's outputs.
|
|
2219
|
+
*/
|
|
2220
|
+
readonly actionContext: RuntimeExpressionContext;
|
|
2172
2221
|
}
|
|
2173
2222
|
|
|
2174
2223
|
/**
|
|
@@ -2279,6 +2328,17 @@ export declare class StepExecutor {
|
|
|
2279
2328
|
* {@link StepExecutor.execute}.
|
|
2280
2329
|
*/
|
|
2281
2330
|
selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>;
|
|
2331
|
+
/**
|
|
2332
|
+
* The context a step's actions are taken in — see
|
|
2333
|
+
* {@link StepExecutionResult.actionContext}: `context` with
|
|
2334
|
+
* `$steps.{stepId}.outputs` replaced by the outputs the attempt just
|
|
2335
|
+
* resolved, as a fresh object, so run state is never written.
|
|
2336
|
+
*
|
|
2337
|
+
* Public for the same reason as {@link StepExecutor.selectActions}: the
|
|
2338
|
+
* workflow executor builds this context for a step targeting a
|
|
2339
|
+
* `workflowId`, which never reaches {@link StepExecutor.execute}.
|
|
2340
|
+
*/
|
|
2341
|
+
actionContext(context: RuntimeExpressionContext, stepId: string, outputs: Record<string, unknown>): RuntimeExpressionContext;
|
|
2282
2342
|
}
|
|
2283
2343
|
|
|
2284
2344
|
/**
|
|
@@ -2588,7 +2648,9 @@ export declare class WorkflowExecutionState {
|
|
|
2588
2648
|
constructor(options?: WorkflowExecutionStateOptions);
|
|
2589
2649
|
/**
|
|
2590
2650
|
* Records the resolved outputs of a completed step, read via
|
|
2591
|
-
* `$steps.{stepId}.outputs.{name}`.
|
|
2651
|
+
* `$steps.{stepId}.outputs.{name}`. Every run records, so a step run again
|
|
2652
|
+
* (a `goto` back, a retry) or a later step sharing its `stepId` replaces
|
|
2653
|
+
* the earlier outputs, even with none.
|
|
2592
2654
|
*/
|
|
2593
2655
|
setStepOutputs(stepId: string, outputs: Record<string, unknown>): void;
|
|
2594
2656
|
/**
|
|
@@ -2720,6 +2782,12 @@ export declare interface WorkflowExecutorOptions {
|
|
|
2720
2782
|
* executor is agnostic to how a step reaches the live API.
|
|
2721
2783
|
*/
|
|
2722
2784
|
readonly stepExecutor: StepExecutor;
|
|
2785
|
+
/**
|
|
2786
|
+
* Normalizes each workflow before it runs: dereferences it, which may fetch
|
|
2787
|
+
* externally referenced documents, and inherits its parameters and actions
|
|
2788
|
+
* into its steps. Defaults to a fresh {@link ArazzoWorkflowNormalizer}.
|
|
2789
|
+
*/
|
|
2790
|
+
readonly workflowNormalizer?: ArazzoWorkflowNormalizer;
|
|
2723
2791
|
/**
|
|
2724
2792
|
* Upper bound on the number of step attempts in a single run — every attempt
|
|
2725
2793
|
* of every step counts, including each `retry` and each entry into a
|
|
@@ -2769,7 +2837,8 @@ export declare type WorkflowId = string;
|
|
|
2769
2837
|
|
|
2770
2838
|
/**
|
|
2771
2839
|
* Resolves the `parameters` of a step targeting a `workflowId` into the
|
|
2772
|
-
* sub-workflow's inputs
|
|
2840
|
+
* sub-workflow's inputs — or those of a `goto` / `retry` action naming a
|
|
2841
|
+
* `workflowId` into its target's.
|
|
2773
2842
|
*
|
|
2774
2843
|
* Values follow the family-wide literal-vs-expression rule of
|
|
2775
2844
|
* {@link ArazzoValueResolver}. Keys are bare parameter names: per the
|
|
@@ -2792,7 +2861,7 @@ export declare class WorkflowParameterResolver extends StepParameterResolver {
|
|
|
2792
2861
|
*
|
|
2793
2862
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
2794
2863
|
*/
|
|
2795
|
-
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
|
|
2864
|
+
resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
|
|
2796
2865
|
}
|
|
2797
2866
|
|
|
2798
2867
|
/**
|