@usearazzo/runner 0.0.0-stage → 1.0.1-alpha.11
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 +37 -0
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +163 -2
- package/dist/arazzo-runner.browser.js +113245 -0
- package/dist/arazzo-runner.browser.min.js +1 -0
- package/package.json +95 -4
- package/src/ArazzoRunner.cjs +122 -0
- package/src/ArazzoRunner.mjs +113 -0
- package/src/action/ActionResolver.cjs +160 -0
- package/src/action/ActionResolver.mjs +150 -0
- package/src/assembler/OpenAPI2DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI2DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPI30DocumentAssembler.cjs +110 -0
- package/src/assembler/OpenAPI30DocumentAssembler.mjs +103 -0
- package/src/assembler/OpenAPI31DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI31DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPIDocumentAssembler.cjs +58 -0
- package/src/assembler/OpenAPIDocumentAssembler.mjs +50 -0
- package/src/client/HTTPClient.cjs +5 -0
- package/src/client/HTTPClient.mjs +1 -0
- package/src/client/HTTPClientFetch.cjs +16 -0
- package/src/client/HTTPClientFetch.mjs +10 -0
- package/src/client/OpenAPIOperationRequest.cjs +5 -0
- package/src/client/OpenAPIOperationRequest.mjs +1 -0
- package/src/client/OpenAPIOperationResponse.cjs +42 -0
- package/src/client/OpenAPIOperationResponse.mjs +36 -0
- package/src/client/OpenAPIOperationResponseNormalizer.cjs +48 -0
- package/src/client/OpenAPIOperationResponseNormalizer.mjs +40 -0
- package/src/client/ParameterDelivery.cjs +119 -0
- package/src/client/ParameterDelivery.mjs +113 -0
- package/src/constants.cjs +9 -0
- package/src/constants.mjs +3 -0
- package/src/criterion/CriterionEvaluator.cjs +205 -0
- package/src/criterion/CriterionEvaluator.mjs +196 -0
- package/src/criterion/JSONPathCriterionEvaluator.cjs +47 -0
- package/src/criterion/JSONPathCriterionEvaluator.mjs +40 -0
- package/src/criterion/RegexCriterionEvaluator.cjs +67 -0
- package/src/criterion/RegexCriterionEvaluator.mjs +60 -0
- package/src/criterion/SimpleCriterionEvaluator.cjs +50 -0
- package/src/criterion/SimpleCriterionEvaluator.mjs +43 -0
- package/src/criterion/XPathCriterionEvaluator.cjs +117 -0
- package/src/criterion/XPathCriterionEvaluator.mjs +109 -0
- package/src/document/APIDocument.cjs +35 -0
- package/src/document/APIDocument.mjs +30 -0
- package/src/document/ArazzoDocument.cjs +81 -0
- package/src/document/ArazzoDocument.mjs +74 -0
- package/src/document/ArazzoSourceDescriptionIndex.cjs +26 -0
- package/src/document/ArazzoSourceDescriptionIndex.mjs +20 -0
- package/src/document/ArazzoStepIndex.cjs +25 -0
- package/src/document/ArazzoStepIndex.mjs +19 -0
- package/src/document/ArazzoWorkflowIndex.cjs +17 -0
- package/src/document/ArazzoWorkflowIndex.mjs +11 -0
- package/src/document/OpenAPIDocument.cjs +28 -0
- package/src/document/OpenAPIDocument.mjs +21 -0
- package/src/document/OpenAPIOperationIndex.cjs +24 -0
- package/src/document/OpenAPIOperationIndex.mjs +18 -0
- package/src/document/ParameterIdentity.cjs +93 -0
- package/src/document/ParameterIdentity.mjs +88 -0
- package/src/document/openapi-types.cjs +5 -0
- package/src/document/openapi-types.mjs +1 -0
- package/src/errors/ArazzoRunnerError.cjs +10 -0
- package/src/errors/ArazzoRunnerError.mjs +5 -0
- package/src/errors/AssemblerError.cjs +11 -0
- package/src/errors/AssemblerError.mjs +4 -0
- package/src/errors/ClientError.cjs +11 -0
- package/src/errors/ClientError.mjs +4 -0
- package/src/errors/CriterionError.cjs +11 -0
- package/src/errors/CriterionError.mjs +4 -0
- package/src/errors/ExecutionError.cjs +11 -0
- package/src/errors/ExecutionError.mjs +4 -0
- package/src/errors/ExtractionError.cjs +11 -0
- package/src/errors/ExtractionError.mjs +4 -0
- package/src/errors/InvalidEntryDocumentError.cjs +11 -0
- package/src/errors/InvalidEntryDocumentError.mjs +4 -0
- package/src/errors/NormalizationError.cjs +11 -0
- package/src/errors/NormalizationError.mjs +4 -0
- package/src/errors/ResolverError.cjs +11 -0
- package/src/errors/ResolverError.mjs +4 -0
- package/src/errors/RuntimeExpressionError.cjs +11 -0
- package/src/errors/RuntimeExpressionError.mjs +4 -0
- package/src/errors/UnmatchedProviderError.cjs +11 -0
- package/src/errors/UnmatchedProviderError.mjs +4 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +147 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +137 -0
- package/src/executor/OpenAPIOperationExecutor.cjs +458 -0
- package/src/executor/OpenAPIOperationExecutor.mjs +447 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +197 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +189 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.cjs +44 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.mjs +38 -0
- package/src/executor/StepExecutor.cjs +333 -0
- package/src/executor/StepExecutor.mjs +326 -0
- package/src/executor/StepRetryRunner.cjs +226 -0
- package/src/executor/StepRetryRunner.mjs +215 -0
- package/src/executor/StepTransitionInterpreter.cjs +159 -0
- package/src/executor/StepTransitionInterpreter.mjs +151 -0
- package/src/executor/WorkflowCallStack.cjs +116 -0
- package/src/executor/WorkflowCallStack.mjs +106 -0
- package/src/executor/WorkflowExecutor.cjs +1091 -0
- package/src/executor/WorkflowExecutor.mjs +1077 -0
- package/src/executor/abort.cjs +70 -0
- package/src/executor/abort.mjs +60 -0
- package/src/expression/RuntimeExpressionContext.cjs +5 -0
- package/src/expression/RuntimeExpressionContext.mjs +1 -0
- package/src/expression/RuntimeExpressionEvaluator.cjs +337 -0
- package/src/expression/RuntimeExpressionEvaluator.mjs +328 -0
- package/src/extractor/ArazzoStepExtractor.cjs +48 -0
- package/src/extractor/ArazzoStepExtractor.mjs +41 -0
- package/src/extractor/ArazzoWorkflowExtractor.cjs +50 -0
- package/src/extractor/ArazzoWorkflowExtractor.mjs +43 -0
- package/src/extractor/OpenAPIOperationExtractor.cjs +84 -0
- package/src/extractor/OpenAPIOperationExtractor.mjs +77 -0
- package/src/index.cjs +426 -0
- package/src/index.mjs +75 -0
- package/src/normalizer/ArazzoStepNormalizer.cjs +23 -0
- package/src/normalizer/ArazzoStepNormalizer.mjs +17 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.cjs +214 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.mjs +206 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.cjs +128 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.mjs +120 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.cjs +129 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.mjs +121 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.cjs +131 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.mjs +123 -0
- package/src/normalizer/OpenAPIOperationNormalizer.cjs +58 -0
- package/src/normalizer/OpenAPIOperationNormalizer.mjs +50 -0
- package/src/registry/DocumentRegistry.cjs +160 -0
- package/src/registry/DocumentRegistry.mjs +151 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +154 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +146 -0
- package/src/registry/providers/DocumentRegistryProvider.cjs +31 -0
- package/src/registry/providers/DocumentRegistryProvider.mjs +25 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +122 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +114 -0
- package/src/resolver/ArazzoValueResolver.cjs +42 -0
- package/src/resolver/ArazzoValueResolver.mjs +37 -0
- package/src/resolver/OpenAPIOperationParameterResolver.cjs +117 -0
- package/src/resolver/OpenAPIOperationParameterResolver.mjs +110 -0
- package/src/resolver/OutputResolver.cjs +71 -0
- package/src/resolver/OutputResolver.mjs +64 -0
- package/src/resolver/RequestBodyResolver.cjs +227 -0
- package/src/resolver/RequestBodyResolver.mjs +220 -0
- package/src/resolver/ResolverScope.cjs +5 -0
- package/src/resolver/ResolverScope.mjs +1 -0
- package/src/resolver/StepParameterResolver.cjs +22 -0
- package/src/resolver/StepParameterResolver.mjs +15 -0
- package/src/resolver/WorkflowParameterResolver.cjs +73 -0
- package/src/resolver/WorkflowParameterResolver.mjs +66 -0
- package/src/state/WorkflowExecutionState.cjs +99 -0
- package/src/state/WorkflowExecutionState.mjs +93 -0
- package/src/vendor/swagger-client.cjs +1 -0
- package/src/vendor/swagger-client.mjs +1 -0
- package/types/runner.d.ts +2410 -0
|
@@ -0,0 +1,2410 @@
|
|
|
1
|
+
import { ApiDOMReferenceOptions } from '@speclynx/apidom-reference/configuration/empty';
|
|
2
|
+
import { ApiDOMStructuredError } from '@speclynx/apidom-error';
|
|
3
|
+
import { CriterionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
4
|
+
import { FailureActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
5
|
+
import { JSONPointer } from '@speclynx/apidom-json-pointer';
|
|
6
|
+
import { OperationElement } from '@speclynx/apidom-ns-openapi-2';
|
|
7
|
+
import { OperationElement as OperationElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
|
|
8
|
+
import { OperationElement as OperationElement_3 } from '@speclynx/apidom-ns-openapi-3-1';
|
|
9
|
+
import type { ParseResultElement } from '@usearazzo/parser';
|
|
10
|
+
import type { PartialDeep } from 'type-fest';
|
|
11
|
+
import { PathItemElement } from '@speclynx/apidom-ns-openapi-2';
|
|
12
|
+
import { PathItemElement as PathItemElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
|
|
13
|
+
import { PathItemElement as PathItemElement_3 } from '@speclynx/apidom-ns-openapi-3-1';
|
|
14
|
+
import { RequestBodyElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
15
|
+
import type { SourceDescriptionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
16
|
+
import { StepElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
17
|
+
import { StepOnFailureElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
18
|
+
import { StepOnSuccessElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
19
|
+
import type { StepOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
20
|
+
import { StepParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
21
|
+
import { SuccessActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
22
|
+
import { toYAML } from '@speclynx/apidom-core';
|
|
23
|
+
import { WorkflowElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
24
|
+
import type { WorkflowOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Selects the actions to take for a step outcome from its `onSuccess` /
|
|
28
|
+
* `onFailure` list.
|
|
29
|
+
*
|
|
30
|
+
* Actions are tried in order and every one whose `criteria` all pass is
|
|
31
|
+
* returned (an action with no criteria always matches). Action elements are
|
|
32
|
+
* returned as-is — interpreting them (branching on `type`, reading
|
|
33
|
+
* `stepId`/`workflowId`/`retryAfter`/`retryLimit`) is the caller's concern, and
|
|
34
|
+
* keeping them elements preserves the document provenance. The usual caller
|
|
35
|
+
* acts on the first and takes an empty result as "no action matched", applying
|
|
36
|
+
* the path default — the next sequential step on success, break-and-return on
|
|
37
|
+
* failure.
|
|
38
|
+
*
|
|
39
|
+
* A step's list is the only list there is: Reusable Object entries are already
|
|
40
|
+
* inlined by workflow normalization, and the workflow-level
|
|
41
|
+
* `successActions` / `failureActions` a step falls back to are inherited into
|
|
42
|
+
* `onSuccess` / `onFailure` by the same pass, so a well-formed document reaches
|
|
43
|
+
* this point as the step's own list of concrete action elements.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare class ActionResolver {
|
|
47
|
+
#private;
|
|
48
|
+
/**
|
|
49
|
+
* Returns every `onSuccess` action whose criteria are all met, in list order.
|
|
50
|
+
*
|
|
51
|
+
* The whole matching chain rather than only the first, because the caller
|
|
52
|
+
* needs both: it acts on `[0]`, and the one honoring "retryLimit exhausted
|
|
53
|
+
* prior to subsequent failure actions" walks the rest, falling from an
|
|
54
|
+
* exhausted `retry` to the next matching action without re-evaluating
|
|
55
|
+
* criteria. Empty when the list is absent or nothing matches.
|
|
56
|
+
*
|
|
57
|
+
* `scope` names the step this list belongs to, for a thrown
|
|
58
|
+
* {@link ResolverError}.
|
|
59
|
+
*
|
|
60
|
+
* A well-formed list whose entry is not a Success/Failure Action Object
|
|
61
|
+
* throws rather than being skipped: an unrecognized entry is indistinguishable
|
|
62
|
+
* from a step that deliberately declared no action for it, and the `goto` /
|
|
63
|
+
* `end` its author was reaching for would otherwise never happen without a
|
|
64
|
+
* word said about why.
|
|
65
|
+
*/
|
|
66
|
+
resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): SuccessActionElement[];
|
|
67
|
+
/**
|
|
68
|
+
* Returns every `onFailure` action whose criteria are all met, in list order.
|
|
69
|
+
*
|
|
70
|
+
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
71
|
+
* see there for the full rationale — mirrored for the step's other list.
|
|
72
|
+
*/
|
|
73
|
+
resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): FailureActionElement[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Base document held by the document registry.
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare abstract class APIDocument {
|
|
81
|
+
abstract readonly type: string;
|
|
82
|
+
readonly uri: string;
|
|
83
|
+
readonly parseResult: ParseResultElement;
|
|
84
|
+
protected constructor(uri: string, parseResult: ParseResultElement);
|
|
85
|
+
/**
|
|
86
|
+
* Returns a JSON-serializable representation of the document's API element.
|
|
87
|
+
* Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
|
|
88
|
+
*/
|
|
89
|
+
toJSON(): unknown;
|
|
90
|
+
/**
|
|
91
|
+
* Serializes the document's API element to a YAML string.
|
|
92
|
+
*/
|
|
93
|
+
toYAML(...args: Parameters<typeof toYAML> extends [unknown, ...infer R] ? R : []): string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* An Arazzo document held by the document registry: the parse result together
|
|
98
|
+
* with the indexes the provider built over it — a container, not a logic
|
|
99
|
+
* bearer. The methods below are thin reads of the source description index.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export declare class ArazzoDocument extends APIDocument {
|
|
103
|
+
readonly type: "arazzo";
|
|
104
|
+
isEntry: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* WorkflowId → JSON Pointer to the workflow within the parse result.
|
|
107
|
+
*/
|
|
108
|
+
readonly workflowIndex: ArazzoWorkflowIndex;
|
|
109
|
+
/**
|
|
110
|
+
* WorkflowId → stepId → JSON Pointer to the step within the parse result.
|
|
111
|
+
* Built by the provider, like {@link ArazzoDocument.workflowIndex}.
|
|
112
|
+
*/
|
|
113
|
+
readonly stepIndex: ArazzoStepIndex;
|
|
114
|
+
/**
|
|
115
|
+
* Name → source description element and canonical URI (already resolved
|
|
116
|
+
* against this document's base URI). Built by the provider, like
|
|
117
|
+
* {@link ArazzoDocument.workflowIndex}.
|
|
118
|
+
*/
|
|
119
|
+
readonly sourceDescriptionIndex: ArazzoSourceDescriptionIndex;
|
|
120
|
+
constructor(uri: string, parseResult: ParseResultElement, workflowIndex: ArazzoWorkflowIndex, stepIndex: ArazzoStepIndex, sourceDescriptionIndex: ArazzoSourceDescriptionIndex, isEntry?: boolean);
|
|
121
|
+
/**
|
|
122
|
+
* Type guard for ArazzoDocument.
|
|
123
|
+
*/
|
|
124
|
+
static is(doc: APIDocument): doc is ArazzoDocument;
|
|
125
|
+
/**
|
|
126
|
+
* Resolves a source description name to its canonical URI — precomputed by
|
|
127
|
+
* the provider, resolved against this document's base URI.
|
|
128
|
+
*/
|
|
129
|
+
resolveSourceDescriptionURI(sourceDescriptionName: string): string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Resolves a field of a source description object (e.g. `url`, `type`).
|
|
132
|
+
*
|
|
133
|
+
* The `url` field resolves to the canonical URI (resolved against this
|
|
134
|
+
* document's base URI, as `resolveSourceDescriptionURI` does); every other
|
|
135
|
+
* field resolves to its literal value. Returns `undefined` when the source
|
|
136
|
+
* description or the field is absent.
|
|
137
|
+
*/
|
|
138
|
+
resolveSourceDescriptionField(sourceDescriptionName: string, field: string): unknown;
|
|
139
|
+
/**
|
|
140
|
+
* The canonical URIs of this document's source descriptions, resolved against
|
|
141
|
+
* this document's base URI, in declaration order. Sources without a resolvable
|
|
142
|
+
* url are omitted.
|
|
143
|
+
*/
|
|
144
|
+
sourceDescriptionURIs(): string[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Provides ArazzoDocument instances for the DocumentRegistry.
|
|
149
|
+
*
|
|
150
|
+
* Parses the Arazzo document and builds its workflow and source description
|
|
151
|
+
* indexes — the document itself is a container.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export declare class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
155
|
+
#private;
|
|
156
|
+
constructor(options?: ArazzoDocumentRegistryProviderOptions);
|
|
157
|
+
canProvide(uri: string): Promise<boolean>;
|
|
158
|
+
/**
|
|
159
|
+
* Loads an Arazzo document from a URI and produces an ArazzoDocument.
|
|
160
|
+
*/
|
|
161
|
+
provide(uri: string): Promise<ArazzoDocument>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Options for loading an Arazzo document.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare type ArazzoDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Runs the workflows of one Arazzo document.
|
|
172
|
+
*
|
|
173
|
+
* A thin facade over the building blocks: it wires a {@link DocumentRegistry},
|
|
174
|
+
* an {@link OpenAPIOperationExecutor}, a {@link StepExecutor} and a
|
|
175
|
+
* {@link WorkflowExecutor} with their defaults, so running a workflow takes a
|
|
176
|
+
* `load` and an `execute`. The building blocks stay public for callers that
|
|
177
|
+
* need to compose them differently.
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export declare class ArazzoRunner {
|
|
181
|
+
#private;
|
|
182
|
+
readonly document: ArazzoDocument;
|
|
183
|
+
readonly registry: DocumentRegistry;
|
|
184
|
+
/**
|
|
185
|
+
* Loads the entry Arazzo document at `uri` (a file system path or URL) and
|
|
186
|
+
* returns a runner bound to it.
|
|
187
|
+
*
|
|
188
|
+
* @throws UnmatchedProviderError - When no provider can load the document
|
|
189
|
+
* @throws InvalidEntryDocumentError - When the document is not an Arazzo
|
|
190
|
+
* document, or the given registry already backs another entry document
|
|
191
|
+
*/
|
|
192
|
+
static load(uri: string, options?: ArazzoRunnerLoadOptions): Promise<ArazzoRunner>;
|
|
193
|
+
/**
|
|
194
|
+
* Binds a runner to an entry document the caller already acquired.
|
|
195
|
+
*
|
|
196
|
+
* @throws InvalidEntryDocumentError - When `document` is not the entry document of `registry`
|
|
197
|
+
*/
|
|
198
|
+
constructor(options: ArazzoRunnerOptions);
|
|
199
|
+
/**
|
|
200
|
+
* Runs the named workflow to completion, returning its outcome; see
|
|
201
|
+
* {@link WorkflowExecutor.execute}.
|
|
202
|
+
*/
|
|
203
|
+
execute(workflowId: WorkflowId, options?: WorkflowExecuteOptions): Promise<WorkflowExecutionResult>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** @public */
|
|
207
|
+
export declare class ArazzoRunnerError extends ApiDOMStructuredError {
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Options for {@link ArazzoRunner.load}.
|
|
212
|
+
*
|
|
213
|
+
* Every option is a seam of a building block the runner wires: `registry` is
|
|
214
|
+
* the {@link DocumentRegistry} the documents load into (a fresh one with the
|
|
215
|
+
* default providers when omitted), `httpClient` and `requestInterceptor` go to
|
|
216
|
+
* the {@link OpenAPIOperationExecutor}, and the rest go to the
|
|
217
|
+
* {@link WorkflowExecutor}.
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
|
|
221
|
+
/**
|
|
222
|
+
* The registry to load the documents into. A registry backs one entry
|
|
223
|
+
* document: loading a different one into it throws.
|
|
224
|
+
*/
|
|
225
|
+
readonly registry?: DocumentRegistry;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Options for the ArazzoRunner constructor.
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry'> {
|
|
233
|
+
/**
|
|
234
|
+
* The entry Arazzo document holding the workflows to run.
|
|
235
|
+
*/
|
|
236
|
+
readonly document: ArazzoDocument;
|
|
237
|
+
/**
|
|
238
|
+
* The document registry whose entry document is `document`.
|
|
239
|
+
*/
|
|
240
|
+
readonly registry: DocumentRegistry;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Index mapping a source description name to its element and canonical URI in
|
|
245
|
+
* an Arazzo document.
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
export declare class ArazzoSourceDescriptionIndex extends Map<SourceDescriptionName, SourceDescriptionEntry> {
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Extracts a step from an Arazzo workflow by stepId.
|
|
253
|
+
*
|
|
254
|
+
* Searches the workflow's steps array for the matching stepId.
|
|
255
|
+
* The workflow should be already extracted via ArazzoWorkflowExtractor.
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
export declare class ArazzoStepExtractor {
|
|
259
|
+
/**
|
|
260
|
+
* Extracts a step element by stepId from a workflow.
|
|
261
|
+
*/
|
|
262
|
+
extract(workflow: WorkflowElement, stepId: string): StepElement;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Index mapping workflowId → stepId → JSON Pointer to the step in an Arazzo
|
|
267
|
+
* document. Steps are unique only within their workflow, hence the nesting.
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
export declare class ArazzoStepIndex extends Map<WorkflowId, Map<StepId, JSONPointer>> {
|
|
271
|
+
/**
|
|
272
|
+
* The JSON Pointer of a step, or `undefined` when the workflow or step is absent.
|
|
273
|
+
*/
|
|
274
|
+
getStep(workflowId: WorkflowId, stepId: StepId): JSONPointer | undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Normalizes an extracted Arazzo step.
|
|
279
|
+
*
|
|
280
|
+
* Currently acts as an identity function. Steps are already dereferenced as part
|
|
281
|
+
* of workflow normalization, which also inherits the workflow's `parameters`
|
|
282
|
+
* into them — a step reaching here has no inherited properties left to merge.
|
|
283
|
+
* @public
|
|
284
|
+
*/
|
|
285
|
+
export declare class ArazzoStepNormalizer {
|
|
286
|
+
/**
|
|
287
|
+
* Normalizes a step element against its parent document.
|
|
288
|
+
*/
|
|
289
|
+
normalize(step: StepElement, _document: ArazzoDocument): Promise<StepElement>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Base of every resolver of authored Arazzo values — the single home of the
|
|
294
|
+
* literal-vs-expression rule they all share.
|
|
295
|
+
*
|
|
296
|
+
* Per Arazzo 1.0.1, an authored value (a parameter's `value`, an `outputs`
|
|
297
|
+
* entry, a `requestBody` replacement value) is either a literal or a whole
|
|
298
|
+
* runtime expression — there is no embedded/interpolated expression. So a
|
|
299
|
+
* value that is a string is resolved as an expression only when the entire
|
|
300
|
+
* string is a valid runtime expression; every other value (a non-expression
|
|
301
|
+
* string such as `"{$inputs.x}"`, a number, boolean, object, array, or null)
|
|
302
|
+
* is a literal and is used as-is. This is deliberately not template
|
|
303
|
+
* interpolation. The one exception is a `requestBody` payload, which "can
|
|
304
|
+
* contain" runtime expressions — {@link RequestBodyResolver} walks it instead.
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
export declare abstract class ArazzoValueResolver {
|
|
308
|
+
/**
|
|
309
|
+
* Resolves one authored value element by the rule above.
|
|
310
|
+
*/
|
|
311
|
+
protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): unknown;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Extracts a workflow from an Arazzo document by workflowId.
|
|
316
|
+
*
|
|
317
|
+
* The workflow is already fully dereferenced in the document,
|
|
318
|
+
* so no additional processing is needed.
|
|
319
|
+
* @public
|
|
320
|
+
*/
|
|
321
|
+
export declare class ArazzoWorkflowExtractor {
|
|
322
|
+
/**
|
|
323
|
+
* Extracts a workflow element by workflowId.
|
|
324
|
+
*/
|
|
325
|
+
extract(document: ArazzoDocument, workflowId: WorkflowId): WorkflowElement;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Index mapping workflowId to its JSON Pointer in an Arazzo document.
|
|
330
|
+
* @public
|
|
331
|
+
*/
|
|
332
|
+
export declare class ArazzoWorkflowIndex extends Map<WorkflowId, JSONPointer> {
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* A canonical Arazzo workflow locator: the Arazzo document that owns the
|
|
337
|
+
* workflow and the workflow's id within it.
|
|
338
|
+
*
|
|
339
|
+
* A workflow reference names its target in one of two ways — a plain
|
|
340
|
+
* `workflowId` of the current document, or a
|
|
341
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
342
|
+
* workflow of another Arazzo document. Both are locators for the same thing;
|
|
343
|
+
* the normalizer reduces either to this single canonical form. `workflowId`
|
|
344
|
+
* is the bare id either way — the key run state (`$workflows.{id}`) is
|
|
345
|
+
* recorded under, which the runtime-expression grammar can only express
|
|
346
|
+
* unqualified.
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
export declare interface ArazzoWorkflowLocator {
|
|
350
|
+
readonly document: ArazzoDocument;
|
|
351
|
+
readonly workflowId: string;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Normalizes a workflow reference to a canonical {@link ArazzoWorkflowLocator}
|
|
356
|
+
* — the Arazzo document and the workflow's id within it.
|
|
357
|
+
*
|
|
358
|
+
* A reference appears in four author-facing positions — a sub-workflow step's
|
|
359
|
+
* `workflowId`, a `dependsOn` entry, a `retry` action's `workflowId`
|
|
360
|
+
* reference, and a `goto` action's transfer target — and is either a plain id
|
|
361
|
+
* of the referencing document or a whole
|
|
362
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
363
|
+
* workflow of another Arazzo document. Only that dotted expression form is a
|
|
364
|
+
* workflow reference; the resolver package's
|
|
365
|
+
* `$sourceDescriptions.{name}#/json/pointer` form is a `$ref`-time construct,
|
|
366
|
+
* not a runtime expression, and does not parse here.
|
|
367
|
+
*
|
|
368
|
+
* The `type` declared on a source description is not trusted (it may be
|
|
369
|
+
* absent or wrong); a source is classified by what it actually parses to,
|
|
370
|
+
* the same convention the OpenAPI operation locator follows. Source
|
|
371
|
+
* documents are acquired from the registry on demand. Whether the resolved
|
|
372
|
+
* document *defines* the workflow is deliberately left to the caller, which
|
|
373
|
+
* owns the timing of that check (eager for a `dependsOn` list validated
|
|
374
|
+
* before any prerequisite runs, lazy for a sub-workflow step resolved per
|
|
375
|
+
* attempt).
|
|
376
|
+
* @public
|
|
377
|
+
*/
|
|
378
|
+
export declare class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
|
|
379
|
+
#private;
|
|
380
|
+
/**
|
|
381
|
+
* Resolves a reference — a plain workflowId or a
|
|
382
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
|
|
383
|
+
* canonical locator: the Arazzo document that owns the target workflow,
|
|
384
|
+
* and the bare id within it.
|
|
385
|
+
*/
|
|
386
|
+
normalize(reference: string, document: ArazzoDocument, context: WorkflowReferenceContext): Promise<ArazzoWorkflowLocator>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Normalizes an extracted Arazzo workflow.
|
|
391
|
+
*
|
|
392
|
+
* Dereferences the workflow subtree ($components.* references),
|
|
393
|
+
* producing a self-contained workflow element, then inherits the workflow's
|
|
394
|
+
* "applicable for all steps" defaults — its `parameters`, and its
|
|
395
|
+
* `successActions` / `failureActions` — into each of its steps.
|
|
396
|
+
*
|
|
397
|
+
* All passes mutate, and what they mutate is the document itself: the extractor
|
|
398
|
+
* hands over the live workflow node out of `document.parseResult`, and
|
|
399
|
+
* dereferencing runs `immutable: false`, returning that same instance. Writing
|
|
400
|
+
* through to the document is what lets the registry act as a natural cache —
|
|
401
|
+
* a workflow reached a second time is already dereferenced and already
|
|
402
|
+
* inherited into, so no pass repeats. The inheritance is idempotent for
|
|
403
|
+
* exactly that reason.
|
|
404
|
+
*
|
|
405
|
+
* The writes differ in kind, which is worth knowing before sharing a
|
|
406
|
+
* registry. Dereferencing only *resolves* what the document already says — a
|
|
407
|
+
* `$ref` replaced by its target means the same thing. Inheritance *synthesizes*:
|
|
408
|
+
* afterwards a step carries `parameters` or an `onSuccess` its source never
|
|
409
|
+
* declared, so a consumer that reads the document back (`APIDocument.toJSON()`)
|
|
410
|
+
* sees one that no longer matches the file it was parsed from. The OpenAPI
|
|
411
|
+
* normalizers write inherited servers, parameters and security requirements into
|
|
412
|
+
* their documents the same way, so this is the layer's established contract
|
|
413
|
+
* rather than a property of Arazzo.
|
|
414
|
+
* @public
|
|
415
|
+
*/
|
|
416
|
+
export declare class ArazzoWorkflowNormalizer {
|
|
417
|
+
#private;
|
|
418
|
+
constructor(options?: ArazzoWorkflowNormalizerOptions);
|
|
419
|
+
/**
|
|
420
|
+
* Dereferences the workflow subtree against its parent document, then inherits
|
|
421
|
+
* the workflow's `parameters` and default actions into its steps.
|
|
422
|
+
*/
|
|
423
|
+
normalize(workflow: WorkflowElement, document: ArazzoDocument): Promise<WorkflowElement>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Options for normalizing an Arazzo workflow.
|
|
428
|
+
* @public
|
|
429
|
+
*/
|
|
430
|
+
export declare type ArazzoWorkflowNormalizerOptions = PartialDeep<ApiDOMReferenceOptions>;
|
|
431
|
+
|
|
432
|
+
/** @public */
|
|
433
|
+
export declare class AssemblerError extends ArazzoRunnerError {
|
|
434
|
+
readonly operationId?: string;
|
|
435
|
+
readonly uri?: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** @public */
|
|
439
|
+
export declare class ClientError extends ArazzoRunnerError {
|
|
440
|
+
readonly operationId?: string;
|
|
441
|
+
readonly operationPath?: string;
|
|
442
|
+
readonly uri?: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* A read-only source of the runtime expression context for a step.
|
|
447
|
+
*
|
|
448
|
+
* The step executor only reads accumulated run state — it produces the
|
|
449
|
+
* pre-request context (`toContext()`) and the post-request context
|
|
450
|
+
* (`toContext(request, response)`) — and never mutates it, so it depends on
|
|
451
|
+
* this narrow interface rather than the full execution state.
|
|
452
|
+
* @public
|
|
453
|
+
*/
|
|
454
|
+
export declare interface ContextSource {
|
|
455
|
+
toContext(request?: RuntimeExpressionContext['request'], response?: RuntimeExpressionResponseContext): RuntimeExpressionContext;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Resolves a runtime expression to a value during criterion evaluation.
|
|
460
|
+
*
|
|
461
|
+
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
462
|
+
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
463
|
+
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
464
|
+
* than throwing (a common way to drive it is
|
|
465
|
+
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
466
|
+
* lenient evaluator).
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
export declare type CriterionContextResolver = (expression: string) => unknown;
|
|
470
|
+
|
|
471
|
+
/** @public */
|
|
472
|
+
export declare class CriterionError extends ArazzoRunnerError {
|
|
473
|
+
readonly condition?: string;
|
|
474
|
+
readonly type?: string;
|
|
475
|
+
readonly reason?: string;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Evaluates an Arazzo Criterion Object to a boolean.
|
|
480
|
+
*
|
|
481
|
+
* Dispatches on the criterion's `type` (defaulting to `simple` when omitted):
|
|
482
|
+
* - `simple` — evaluates the condition directly, resolving the runtime
|
|
483
|
+
* expressions embedded in it.
|
|
484
|
+
* - `regex` — resolves the `context` runtime expression, then applies the
|
|
485
|
+
* pattern to the resolved value.
|
|
486
|
+
* - `jsonpath` — resolves the `context` runtime expression, then applies the
|
|
487
|
+
* JSONPath query to the resolved value (met when the query matches). Only the
|
|
488
|
+
* `rfc9535` version is supported (the spec default); an explicit other version
|
|
489
|
+
* throws.
|
|
490
|
+
* - `xpath` — resolves the `context` runtime expression, then applies the XPath
|
|
491
|
+
* 3.1 query to the resolved XML value (met by the Effective Boolean Value).
|
|
492
|
+
* Only the `xpath-31` version is supported (the spec default); an explicit
|
|
493
|
+
* other version throws.
|
|
494
|
+
*
|
|
495
|
+
* The evaluator is agnostic about how runtime expressions are resolved: the
|
|
496
|
+
* caller supplies a {@link CriterionContextResolver} per evaluation, keeping
|
|
497
|
+
* runtime-state, document, and registry concerns in the runtime expression
|
|
498
|
+
* evaluator rather than duplicated here.
|
|
499
|
+
* @public
|
|
500
|
+
*/
|
|
501
|
+
export declare class CriterionEvaluator {
|
|
502
|
+
#private;
|
|
503
|
+
constructor(options?: CriterionEvaluatorOptions);
|
|
504
|
+
/**
|
|
505
|
+
* Evaluates a criterion element, returning whether the condition is met.
|
|
506
|
+
*
|
|
507
|
+
* `resolve` turns a runtime expression into a value: for `simple` it resolves
|
|
508
|
+
* the expressions embedded in the condition; for the other types it resolves
|
|
509
|
+
* the criterion's `context` expression that the condition is applied to.
|
|
510
|
+
*/
|
|
511
|
+
evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): boolean;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Options for the CriterionEvaluator.
|
|
516
|
+
* @public
|
|
517
|
+
*/
|
|
518
|
+
export declare interface CriterionEvaluatorOptions {
|
|
519
|
+
/**
|
|
520
|
+
* Simple condition evaluator. Injectable for testing.
|
|
521
|
+
*/
|
|
522
|
+
readonly simple?: SimpleCriterionEvaluator;
|
|
523
|
+
/**
|
|
524
|
+
* Regex condition evaluator. Injectable for testing.
|
|
525
|
+
*/
|
|
526
|
+
readonly regex?: RegexCriterionEvaluator;
|
|
527
|
+
/**
|
|
528
|
+
* JSONPath condition evaluator. Injectable for testing.
|
|
529
|
+
*/
|
|
530
|
+
readonly jsonpath?: JSONPathCriterionEvaluator;
|
|
531
|
+
/**
|
|
532
|
+
* XPath condition evaluator. Injectable for testing.
|
|
533
|
+
*/
|
|
534
|
+
readonly xpath?: XPathCriterionEvaluator;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Determines whether a single criterion is met.
|
|
539
|
+
*
|
|
540
|
+
* Bridged to a criterion evaluator
|
|
541
|
+
* (`(criterion) => criterionEvaluator.evaluate(criterion, resolve)`); an
|
|
542
|
+
* unresolvable/failing criterion is `false`, not an error.
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
545
|
+
export declare type CriterionPredicate = (criterion: CriterionElement) => boolean;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Registry for API documents keyed by canonical URI.
|
|
549
|
+
*
|
|
550
|
+
* Acts as an LRU cache for parsed documents. The entry Arazzo document
|
|
551
|
+
* is pinned and never evicted. Providers are tried in order to detect
|
|
552
|
+
* and load documents.
|
|
553
|
+
* @public
|
|
554
|
+
*/
|
|
555
|
+
export declare class DocumentRegistry {
|
|
556
|
+
#private;
|
|
557
|
+
constructor(options?: DocumentRegistryOptions);
|
|
558
|
+
/**
|
|
559
|
+
* Returns the entry Arazzo document, or undefined if not yet registered.
|
|
560
|
+
*/
|
|
561
|
+
get entryDocument(): ArazzoDocument | undefined;
|
|
562
|
+
/**
|
|
563
|
+
* Acquires a document by URI. Returns cached document if available,
|
|
564
|
+
* otherwise detects the format, loads via the matching provider,
|
|
565
|
+
* caches, and returns it.
|
|
566
|
+
*/
|
|
567
|
+
acquire(uri: string): Promise<APIDocument>;
|
|
568
|
+
/**
|
|
569
|
+
* Returns an already-loaded document by URI, or undefined if not cached.
|
|
570
|
+
*
|
|
571
|
+
* Synchronous counterpart to `acquire`: it never loads a document, only
|
|
572
|
+
* returns one the registry already holds, marking it most recently used like
|
|
573
|
+
* any other access. Consumers that must resolve a reference without awaiting
|
|
574
|
+
* (e.g. runtime expression evaluation) use this; the executor is responsible
|
|
575
|
+
* for having acquired the document beforehand.
|
|
576
|
+
*/
|
|
577
|
+
get(uri: string): APIDocument | undefined;
|
|
578
|
+
/**
|
|
579
|
+
* Acquires the entry Arazzo document and marks it with `isEntry: true`.
|
|
580
|
+
* Validates that the document is an Arazzo specification.
|
|
581
|
+
*/
|
|
582
|
+
acquireEntryDocument(uri: string): Promise<ArazzoDocument>;
|
|
583
|
+
clear(): void;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Options for the DocumentRegistry.
|
|
588
|
+
* @public
|
|
589
|
+
*/
|
|
590
|
+
export declare interface DocumentRegistryOptions {
|
|
591
|
+
readonly providers?: DocumentRegistryProvider[];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Base class for document registry providers.
|
|
596
|
+
*
|
|
597
|
+
* Subclasses implement `canProvide()` for format detection and `provide()` for loading.
|
|
598
|
+
* @public
|
|
599
|
+
*/
|
|
600
|
+
export declare abstract class DocumentRegistryProvider {
|
|
601
|
+
/**
|
|
602
|
+
* Checks if the content at the URI can be handled by this provider.
|
|
603
|
+
*/
|
|
604
|
+
abstract canProvide(uri: string): Promise<boolean>;
|
|
605
|
+
/**
|
|
606
|
+
* Loads and produces a document from a URI.
|
|
607
|
+
*/
|
|
608
|
+
abstract provide(uri: string): Promise<APIDocument>;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Options for a document registry provider.
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
export declare type DocumentRegistryProviderOptions = PartialDeep<ApiDOMReferenceOptions>;
|
|
616
|
+
|
|
617
|
+
/** @public */
|
|
618
|
+
export declare class ExecutionError extends ArazzoRunnerError {
|
|
619
|
+
readonly stepId?: string;
|
|
620
|
+
readonly workflowId?: string;
|
|
621
|
+
readonly reason?: string;
|
|
622
|
+
/**
|
|
623
|
+
* The chain of workflowIds the error concerns — the loop A → B → A for a
|
|
624
|
+
* cycle, or the call chain in progress when a budget ran out.
|
|
625
|
+
*/
|
|
626
|
+
readonly path?: readonly string[];
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** @public */
|
|
630
|
+
export declare class ExtractionError extends ArazzoRunnerError {
|
|
631
|
+
readonly workflowId?: string;
|
|
632
|
+
readonly stepId?: string;
|
|
633
|
+
readonly operationId?: string;
|
|
634
|
+
readonly pointer?: string;
|
|
635
|
+
readonly uri?: string;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The pluggable HTTP transport seam.
|
|
640
|
+
*
|
|
641
|
+
* Receives the finalized {@link OpenAPIOperationRequest} and resolves with the
|
|
642
|
+
* raw WHATWG `Response`. The contract is deliberately minimal so any HTTP
|
|
643
|
+
* stack (undici, got, a recording stub, …) drops in with a few lines:
|
|
644
|
+
*
|
|
645
|
+
* - resolve with a `Response` for every HTTP status — a non-2xx is a valid
|
|
646
|
+
* Arazzo outcome judged by a step's `successCriteria`, never an error;
|
|
647
|
+
* - throw (or reject) only on transport failure — the executor wraps the
|
|
648
|
+
* error as a `ClientError`;
|
|
649
|
+
* - honor `request.signal` when present.
|
|
650
|
+
*
|
|
651
|
+
* Response normalization (content-type dispatch, header mapping) happens on
|
|
652
|
+
* the executor side for every client, so `$response.body` semantics stay
|
|
653
|
+
* identical no matter which transport is plugged in.
|
|
654
|
+
* @public
|
|
655
|
+
*/
|
|
656
|
+
export declare type HTTPClient = (request: OpenAPIOperationRequest) => Promise<Response>;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* The default {@link HTTPClient}: global fetch.
|
|
660
|
+
*
|
|
661
|
+
* Mirrors swagger-client's own transport line — the request object doubles as
|
|
662
|
+
* fetch init, so `method`, `headers`, `body`, `credentials`, and `signal` are
|
|
663
|
+
* picked up from it directly.
|
|
664
|
+
* @public
|
|
665
|
+
*/
|
|
666
|
+
export declare const httpClientFetch: HTTPClient;
|
|
667
|
+
|
|
668
|
+
/** @public */
|
|
669
|
+
export declare class InvalidEntryDocumentError extends ArazzoRunnerError {
|
|
670
|
+
readonly uri?: string;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Evaluates a `jsonpath` Arazzo criterion condition against a resolved context value.
|
|
675
|
+
*
|
|
676
|
+
* The condition is a JSONPath query (RFC 9535, per the Criterion Expression
|
|
677
|
+
* Type Object's pinned version) applied to the resolved `context`. The criterion
|
|
678
|
+
* is met when the query yields a non-empty node list.
|
|
679
|
+
*
|
|
680
|
+
* Per Arazzo 1.1.0, a `null` or `undefined` context fails the condition. The
|
|
681
|
+
* context is a plain runtime value (the runtime expression evaluator has already
|
|
682
|
+
* converted any ApiDOM element), so the default JSON evaluation realm applies.
|
|
683
|
+
* @public
|
|
684
|
+
*/
|
|
685
|
+
export declare class JSONPathCriterionEvaluator {
|
|
686
|
+
/**
|
|
687
|
+
* Runs the JSONPath `condition` against the resolved context value, returning
|
|
688
|
+
* whether it matched anything.
|
|
689
|
+
*
|
|
690
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
691
|
+
* {@link CriterionError} when the condition is not a valid JSONPath query.
|
|
692
|
+
*/
|
|
693
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** @public */
|
|
697
|
+
export declare class NormalizationError extends ArazzoRunnerError {
|
|
698
|
+
readonly workflowId?: string;
|
|
699
|
+
readonly operationId?: string;
|
|
700
|
+
readonly operationPointer?: string;
|
|
701
|
+
readonly pathItemPointer?: string;
|
|
702
|
+
readonly uri?: string;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Assembles a standalone OpenAPI 2.0 (Swagger) document from a
|
|
707
|
+
* normalized operation element.
|
|
708
|
+
*
|
|
709
|
+
* The assembled document is a valid Swagger 2.0 specification containing
|
|
710
|
+
* only the single operation with its host, basePath, schemes, and
|
|
711
|
+
* referenced security definitions from the source document.
|
|
712
|
+
* @public
|
|
713
|
+
*/
|
|
714
|
+
export declare class OpenAPI2DocumentAssembler {
|
|
715
|
+
#private;
|
|
716
|
+
/**
|
|
717
|
+
* Assembles a standalone Swagger 2.0 document from a normalized operation.
|
|
718
|
+
*/
|
|
719
|
+
assemble(operation: OperationElement, document: OpenAPIDocument): OpenAPIDocument;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Version-specific normalization for OpenAPI 2.0 (Swagger) operations.
|
|
724
|
+
*
|
|
725
|
+
* Dereferences the operation subtree and handles merging of
|
|
726
|
+
* parameters and security from path item and root levels.
|
|
727
|
+
* OpenAPI 2.0 does not support servers at path item or operation level;
|
|
728
|
+
* host/basePath/schemes are root-level only and handled at execution time.
|
|
729
|
+
* @public
|
|
730
|
+
*/
|
|
731
|
+
export declare class OpenAPI2OperationNormalizer {
|
|
732
|
+
#private;
|
|
733
|
+
constructor(options?: OpenAPI2OperationNormalizerOptions);
|
|
734
|
+
normalize(operation: OperationElement, document: OpenAPIDocument): Promise<OperationElement>;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Options for normalizing an OpenAPI 2.0 operation.
|
|
739
|
+
* @public
|
|
740
|
+
*/
|
|
741
|
+
export declare type OpenAPI2OperationNormalizerOptions = PartialDeep<ApiDOMReferenceOptions>;
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Assembles a standalone OpenAPI 3.0 document from a
|
|
745
|
+
* normalized operation element.
|
|
746
|
+
*
|
|
747
|
+
* The assembled document is a valid OpenAPI 3.0 specification containing
|
|
748
|
+
* only the single operation with its servers, and referenced security
|
|
749
|
+
* schemes from the source document's components.
|
|
750
|
+
* @public
|
|
751
|
+
*/
|
|
752
|
+
export declare class OpenAPI30DocumentAssembler {
|
|
753
|
+
#private;
|
|
754
|
+
/**
|
|
755
|
+
* Assembles a standalone OpenAPI 3.0 document from a normalized operation.
|
|
756
|
+
*/
|
|
757
|
+
assemble(operation: OperationElement_2, document: OpenAPIDocument): OpenAPIDocument;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Version-specific normalization for OpenAPI 3.0 operations.
|
|
762
|
+
*
|
|
763
|
+
* Dereferences the operation subtree and handles merging of servers,
|
|
764
|
+
* parameters, and security from path item and root levels.
|
|
765
|
+
* @public
|
|
766
|
+
*/
|
|
767
|
+
export declare class OpenAPI30OperationNormalizer {
|
|
768
|
+
#private;
|
|
769
|
+
constructor(options?: OpenAPI30OperationNormalizerOptions);
|
|
770
|
+
normalize(operation: OperationElement_2, document: OpenAPIDocument): Promise<OperationElement_2>;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Options for normalizing an OpenAPI 3.0 operation.
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
export declare type OpenAPI30OperationNormalizerOptions = PartialDeep<ApiDOMReferenceOptions>;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Assembles a standalone OpenAPI 3.1 document from a
|
|
781
|
+
* normalized operation element.
|
|
782
|
+
*
|
|
783
|
+
* The assembled document is a valid OpenAPI 3.1 specification containing
|
|
784
|
+
* only the single operation with its servers, and referenced security
|
|
785
|
+
* schemes from the source document's components.
|
|
786
|
+
* @public
|
|
787
|
+
*/
|
|
788
|
+
export declare class OpenAPI31DocumentAssembler {
|
|
789
|
+
#private;
|
|
790
|
+
/**
|
|
791
|
+
* Assembles a standalone OpenAPI 3.1 document from a normalized operation.
|
|
792
|
+
*/
|
|
793
|
+
assemble(operation: OperationElement_3, document: OpenAPIDocument): OpenAPIDocument;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Version-specific normalization for OpenAPI 3.1 operations.
|
|
798
|
+
*
|
|
799
|
+
* Dereferences the operation subtree and handles merging of servers,
|
|
800
|
+
* parameters, and security from path item and root levels.
|
|
801
|
+
* Same inheritance rules as 3.0 but with JSON Schema $id semantics
|
|
802
|
+
* for schema resolution.
|
|
803
|
+
* @public
|
|
804
|
+
*/
|
|
805
|
+
export declare class OpenAPI31OperationNormalizer {
|
|
806
|
+
#private;
|
|
807
|
+
constructor(options?: OpenAPI31OperationNormalizerOptions);
|
|
808
|
+
normalize(operation: OperationElement_3, document: OpenAPIDocument): Promise<OperationElement_3>;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Options for normalizing an OpenAPI 3.1 operation.
|
|
813
|
+
* @public
|
|
814
|
+
*/
|
|
815
|
+
export declare type OpenAPI31OperationNormalizerOptions = PartialDeep<ApiDOMReferenceOptions>;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* An OpenAPI document held by the document registry.
|
|
819
|
+
* @public
|
|
820
|
+
*/
|
|
821
|
+
export declare class OpenAPIDocument extends APIDocument {
|
|
822
|
+
readonly type: "openapi";
|
|
823
|
+
readonly operationIndex: OpenAPIOperationIndex;
|
|
824
|
+
constructor(uri: string, parseResult: ParseResultElement, operationIndex: OpenAPIOperationIndex);
|
|
825
|
+
/**
|
|
826
|
+
* Type guard for OpenAPIDocument.
|
|
827
|
+
*/
|
|
828
|
+
static is(doc: APIDocument): doc is OpenAPIDocument;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Facade for assembling standalone OpenAPI documents across all supported versions.
|
|
833
|
+
*
|
|
834
|
+
* Detects the OpenAPI version from the source document and delegates to the
|
|
835
|
+
* appropriate version-specific assembler (2.0, 3.0, or 3.1).
|
|
836
|
+
*
|
|
837
|
+
* Custom assembler instances can be provided via constructor options.
|
|
838
|
+
* @public
|
|
839
|
+
*/
|
|
840
|
+
export declare class OpenAPIDocumentAssembler {
|
|
841
|
+
#private;
|
|
842
|
+
constructor(options?: OpenAPIDocumentAssemblerOptions);
|
|
843
|
+
/**
|
|
844
|
+
* Assembles a standalone OpenAPI document by delegating to the version-specific assembler.
|
|
845
|
+
*/
|
|
846
|
+
assemble(operation: OpenAPIOperationElement, document: OpenAPIDocument): OpenAPIDocument;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Options for the OpenAPI document assembler facade.
|
|
851
|
+
* @public
|
|
852
|
+
*/
|
|
853
|
+
export declare interface OpenAPIDocumentAssemblerOptions {
|
|
854
|
+
readonly openapi2?: OpenAPI2DocumentAssembler;
|
|
855
|
+
readonly openapi30?: OpenAPI30DocumentAssembler;
|
|
856
|
+
readonly openapi31?: OpenAPI31DocumentAssembler;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Provides OpenAPIDocument instances for the DocumentRegistry.
|
|
861
|
+
*
|
|
862
|
+
* Parses, dereferences, and builds an OperationIndex for OpenAPI documents.
|
|
863
|
+
* @public
|
|
864
|
+
*/
|
|
865
|
+
export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
866
|
+
#private;
|
|
867
|
+
constructor(options?: OpenAPIDocumentRegistryProviderOptions);
|
|
868
|
+
canProvide(uri: string): Promise<boolean>;
|
|
869
|
+
/**
|
|
870
|
+
* Loads an OpenAPI document from a URI and produces an OpenAPIDocument.
|
|
871
|
+
*/
|
|
872
|
+
provide(uri: string): Promise<OpenAPIDocument>;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Options for loading an OpenAPI document.
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
export declare type OpenAPIDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Union of OperationElement across all supported OpenAPI versions.
|
|
883
|
+
* @public
|
|
884
|
+
*/
|
|
885
|
+
export declare type OpenAPIOperationElement = OperationElement | OperationElement_2 | OperationElement_3;
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Options for executing an OpenAPI operation.
|
|
889
|
+
*
|
|
890
|
+
* All fields are forwarded to the vendored swagger-client `buildRequest`
|
|
891
|
+
* (which owns parameter serialization, security application, and server URL
|
|
892
|
+
* resolution), except `requestInterceptor`, which the executor runs between
|
|
893
|
+
* building the request and sending it.
|
|
894
|
+
*
|
|
895
|
+
* Typed here are the options the runner itself drives and the ones callers
|
|
896
|
+
* routinely reach for. The rest of `buildRequest`'s surface (`securities`,
|
|
897
|
+
* `scheme`, `parameterBuilders`, `attachContentTypeForEmptyPayload`, …) is
|
|
898
|
+
* deliberately left untyped and passes through the bag's open tail unchanged —
|
|
899
|
+
* see {@link OpenAPIOperationExecuteOptionsBag}. Authentication in particular
|
|
900
|
+
* is not modeled: Arazzo is auth-agnostic, so credentials are applied with a
|
|
901
|
+
* {@link RequestInterceptor}.
|
|
902
|
+
* @public
|
|
903
|
+
*/
|
|
904
|
+
export declare interface OpenAPIOperationExecuteOptions {
|
|
905
|
+
readonly parameters?: Record<string, unknown>;
|
|
906
|
+
readonly requestBody?: unknown;
|
|
907
|
+
/**
|
|
908
|
+
* The media type of the request body, sent as the `Content-Type` header (the
|
|
909
|
+
* Arazzo `requestBody.contentType`). Matched against the media types the
|
|
910
|
+
* operation declares under `requestBody.content`, ignoring case and any
|
|
911
|
+
* parameters it carries, and accepting a declared range (`type/*`, or the
|
|
912
|
+
* all-media-types range) as covering a concrete type. The authored value is
|
|
913
|
+
* sent in full whichever declaration it matched.
|
|
914
|
+
*
|
|
915
|
+
* The form media types are the exception: `application/x-www-form-urlencoded`
|
|
916
|
+
* and `multipart/form-data` decide how the body is encoded, so they must be
|
|
917
|
+
* declared exactly rather than by a range. A media type matching nothing
|
|
918
|
+
* throws rather than sending an empty or wrongly encoded body.
|
|
919
|
+
*/
|
|
920
|
+
readonly requestContentType?: string;
|
|
921
|
+
/**
|
|
922
|
+
* The media type to ask for in the response, sent as the `Accept` header.
|
|
923
|
+
* When omitted, `Accept` is derived from the media types the operation
|
|
924
|
+
* declares for its 2xx responses.
|
|
925
|
+
*/
|
|
926
|
+
readonly responseContentType?: string;
|
|
927
|
+
/**
|
|
928
|
+
* The server to send the request to. A value matching a declared server's
|
|
929
|
+
* `url` selects it and brings that server's variable defaults along; any
|
|
930
|
+
* other value is used as the base URL directly, so pointing a workflow at
|
|
931
|
+
* another environment needs no special option. Relative values resolve
|
|
932
|
+
* against the document's own URL. Works the same for OpenAPI 2.0 and 3.x.
|
|
933
|
+
*
|
|
934
|
+
* Defaults to the first server the operation declares (for 2.0, the
|
|
935
|
+
* document's `schemes`/`host`/`basePath`), resolved against the URL the
|
|
936
|
+
* document was loaded from.
|
|
937
|
+
*/
|
|
938
|
+
readonly server?: string;
|
|
939
|
+
/**
|
|
940
|
+
* Substitutions for a selected server's URL template, layered over the
|
|
941
|
+
* variable defaults declared in the document. OpenAPI 3.x only, and only for
|
|
942
|
+
* a declared server — an override carries no declared variables.
|
|
943
|
+
*/
|
|
944
|
+
readonly serverVariables?: Record<string, string>;
|
|
945
|
+
readonly signal?: AbortSignal;
|
|
946
|
+
readonly requestInterceptor?: RequestInterceptor;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* The execute options forwarded to {@link OpenAPIOperationExecutor.execute}.
|
|
951
|
+
*
|
|
952
|
+
* The {@link OpenAPIOperationExecuteOptions} fields are surfaced for
|
|
953
|
+
* type-checked callers, while the open `Record` tail keeps the bag opaque so
|
|
954
|
+
* the rest of `buildRequest`'s surface (`scheme`, `parameterBuilders`,
|
|
955
|
+
* `attachContentTypeForEmptyPayload`, …) passes through untouched.
|
|
956
|
+
*
|
|
957
|
+
* Nothing routine belongs in the tail. Credentials go through a
|
|
958
|
+
* {@link RequestInterceptor} and `server` covers every case that once needed a
|
|
959
|
+
* `contextUrl`, so reaching for either of those here means an edge case: tests
|
|
960
|
+
* standing in for a document fetched over HTTP, or credentials applied from the
|
|
961
|
+
* document's own security schemes.
|
|
962
|
+
*
|
|
963
|
+
* Two kinds of entry are inert rather than honored, since the executor owns
|
|
964
|
+
* what they used to control. The operation target always comes from the
|
|
965
|
+
* locator, so `operationId`/`operationPath` have no effect; and the options
|
|
966
|
+
* only swagger-client's `execute()` ever read — `userFetch` and
|
|
967
|
+
* `responseInterceptor`, which the runner replaces with `httpClient` and
|
|
968
|
+
* `responseNormalizer` — reach `buildRequest` but nothing acts on them.
|
|
969
|
+
* @public
|
|
970
|
+
*/
|
|
971
|
+
export declare type OpenAPIOperationExecuteOptionsBag = OpenAPIOperationExecuteOptions & Record<string, unknown>;
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Executes a single OpenAPI operation named by a canonical
|
|
975
|
+
* {@link OpenAPIOperationLocator}.
|
|
976
|
+
*
|
|
977
|
+
* The pipeline extracts the operation from its owning document, normalizes it,
|
|
978
|
+
* assembles a minimal standalone OpenAPI document containing just that
|
|
979
|
+
* operation, builds the HTTP request with the vendored swagger-client
|
|
980
|
+
* `buildRequest` (parameter serialization, securities, server resolution),
|
|
981
|
+
* sends it through the pluggable {@link HTTPClient}, and normalizes the raw
|
|
982
|
+
* `Response` into the runner's response model. A non-2xx status is a valid
|
|
983
|
+
* outcome (judged by a step's `successCriteria`) and is returned, never
|
|
984
|
+
* thrown; a transport failure is wrapped as a {@link ClientError}.
|
|
985
|
+
*
|
|
986
|
+
* The executor is Arazzo-agnostic: it neither locates the operation (that is
|
|
987
|
+
* the operation locator normalizer's concern) nor resolves parameters or
|
|
988
|
+
* request bodies from runtime expressions (the step executor's concern). It
|
|
989
|
+
* receives an already-resolved locator and an opaque bag of execute options,
|
|
990
|
+
* and returns the normalized operation response carrying the request that was
|
|
991
|
+
* actually sent, so `$url` / `$method` / `$request.*` can be evaluated after
|
|
992
|
+
* execution.
|
|
993
|
+
* @public
|
|
994
|
+
*/
|
|
995
|
+
export declare class OpenAPIOperationExecutor {
|
|
996
|
+
#private;
|
|
997
|
+
constructor(options?: OpenAPIOperationExecutorOptions);
|
|
998
|
+
/**
|
|
999
|
+
* Executes the located operation, returning the normalized operation
|
|
1000
|
+
* response.
|
|
1001
|
+
*
|
|
1002
|
+
* `executeOptions` is an opaque bag of `buildRequest` options (e.g. resolved
|
|
1003
|
+
* `parameters`, a `requestBody` and its `requestContentType`, or a `server`).
|
|
1004
|
+
* The operation target always takes precedence over it: the
|
|
1005
|
+
* locator's JSON Pointer selects the operation in the assembled document, so
|
|
1006
|
+
* `operationId`/`operationPath` entries in the bag cannot hijack the
|
|
1007
|
+
* operation.
|
|
1008
|
+
*/
|
|
1009
|
+
execute(locator: OpenAPIOperationLocator, executeOptions?: OpenAPIOperationExecuteOptionsBag): Promise<OpenAPIOperationResponse>;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Options for the OpenAPIOperationExecutor.
|
|
1014
|
+
* @public
|
|
1015
|
+
*/
|
|
1016
|
+
export declare interface OpenAPIOperationExecutorOptions {
|
|
1017
|
+
/**
|
|
1018
|
+
* The transport that sends the built request and resolves with the raw
|
|
1019
|
+
* WHATWG `Response`. Defaults to {@link httpClientFetch} (global fetch).
|
|
1020
|
+
*/
|
|
1021
|
+
readonly httpClient?: HTTPClient;
|
|
1022
|
+
/**
|
|
1023
|
+
* Decorates every built request (e.g. an `Authorization` header) before the
|
|
1024
|
+
* per-call interceptor from the execute options bag runs.
|
|
1025
|
+
*/
|
|
1026
|
+
readonly requestInterceptor?: RequestInterceptor;
|
|
1027
|
+
/**
|
|
1028
|
+
* Normalizes the raw `Response` into the runner's response model. Defaults
|
|
1029
|
+
* to a fresh {@link OpenAPIOperationResponseNormalizer}.
|
|
1030
|
+
*/
|
|
1031
|
+
readonly responseNormalizer?: OpenAPIOperationResponseNormalizer;
|
|
1032
|
+
/**
|
|
1033
|
+
* Extracts the operation element from its owning document. Defaults to a
|
|
1034
|
+
* fresh {@link OpenAPIOperationExtractor}.
|
|
1035
|
+
*/
|
|
1036
|
+
readonly operationExtractor?: OpenAPIOperationExtractor;
|
|
1037
|
+
/**
|
|
1038
|
+
* Normalizes the extracted operation (servers, parameters, securities).
|
|
1039
|
+
* Defaults to a fresh {@link OpenAPIOperationNormalizer}.
|
|
1040
|
+
*/
|
|
1041
|
+
readonly operationNormalizer?: OpenAPIOperationNormalizer;
|
|
1042
|
+
/**
|
|
1043
|
+
* Assembles the standalone OpenAPI document for the operation. Defaults to a
|
|
1044
|
+
* fresh {@link OpenAPIDocumentAssembler}.
|
|
1045
|
+
*/
|
|
1046
|
+
readonly documentAssembler?: OpenAPIDocumentAssembler;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Extracts an operation from an OpenAPI document.
|
|
1051
|
+
*
|
|
1052
|
+
* Locates the operation by operationId or operationPath (JSON Pointer)
|
|
1053
|
+
* and attaches metadata (pointer, method, path) to the element.
|
|
1054
|
+
* The extracted operation is not dereferenced or normalized.
|
|
1055
|
+
* @public
|
|
1056
|
+
*/
|
|
1057
|
+
export declare class OpenAPIOperationExtractor {
|
|
1058
|
+
/**
|
|
1059
|
+
* Extracts an operation by operationId.
|
|
1060
|
+
*/
|
|
1061
|
+
extract(document: OpenAPIDocument, operationId: OperationId): OpenAPIOperationElement;
|
|
1062
|
+
/**
|
|
1063
|
+
* Extracts an operation by JSON Pointer (operationPath).
|
|
1064
|
+
*/
|
|
1065
|
+
extractByPointer(document: OpenAPIDocument, pointer: JSONPointer): OpenAPIOperationElement;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Index mapping operationId to its JSON Pointer in an OpenAPI document.
|
|
1070
|
+
*
|
|
1071
|
+
* Only used when an Arazzo step references an operation by `operationId`.
|
|
1072
|
+
* When a step uses `operationPath` (a JSON Pointer), the index is bypassed
|
|
1073
|
+
* and the pointer is used directly to locate the operation.
|
|
1074
|
+
*
|
|
1075
|
+
* Only operations with an operationId are indexed; operations without one
|
|
1076
|
+
* are only reachable via `operationPath`.
|
|
1077
|
+
* @public
|
|
1078
|
+
*/
|
|
1079
|
+
export declare class OpenAPIOperationIndex extends Map<OperationId, JSONPointer> {
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* A canonical OpenAPI operation locator: the OpenAPI document that owns the
|
|
1084
|
+
* operation and a JSON Pointer locating the operation within it
|
|
1085
|
+
* (`/paths/{path}/{method}`).
|
|
1086
|
+
*
|
|
1087
|
+
* A step names its operation in one of several ways — a plain `operationId`, a
|
|
1088
|
+
* `$sourceDescriptions` runtime expression, or an `operationPath` — which are
|
|
1089
|
+
* all locators for the same thing. The normalizer reduces any of them to this
|
|
1090
|
+
* single canonical form.
|
|
1091
|
+
* @public
|
|
1092
|
+
*/
|
|
1093
|
+
export declare interface OpenAPIOperationLocator {
|
|
1094
|
+
readonly document: OpenAPIDocument;
|
|
1095
|
+
readonly jsonPointer: string;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Normalizes a step's OpenAPI operation locator to a canonical
|
|
1100
|
+
* {@link OpenAPIOperationLocator} — the OpenAPI document and a JSON Pointer to
|
|
1101
|
+
* the operation within it.
|
|
1102
|
+
*
|
|
1103
|
+
* A step names its operation with either `operationId` or `operationPath`:
|
|
1104
|
+
* - `operationId` is a plain operation name, or a whole runtime expression
|
|
1105
|
+
* `$sourceDescriptions.{name}.{operationId}`. Per the Arazzo Specification, a
|
|
1106
|
+
* plain name is only valid when a single (non-arazzo) source description is
|
|
1107
|
+
* defined; multiple sources require the expression form. A plain name is
|
|
1108
|
+
* therefore resolved against the first source description that has it.
|
|
1109
|
+
* - `operationPath` embeds a `{$sourceDescriptions.{name}.url}` runtime
|
|
1110
|
+
* expression followed by a JSON Pointer to the operation.
|
|
1111
|
+
*
|
|
1112
|
+
* The `type` declared on a source description is not trusted (it may be absent
|
|
1113
|
+
* or wrong); a source is classified by what it actually parses to. The
|
|
1114
|
+
* normalizer acquires the referenced source documents from the registry on
|
|
1115
|
+
* demand.
|
|
1116
|
+
* @public
|
|
1117
|
+
*/
|
|
1118
|
+
export declare class OpenAPIOperationLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
|
|
1119
|
+
#private;
|
|
1120
|
+
/**
|
|
1121
|
+
* Normalizes a plain or expression `operationId` to a canonical locator.
|
|
1122
|
+
*
|
|
1123
|
+
* A whole runtime expression (`$sourceDescriptions.{name}.{operationId}`) is
|
|
1124
|
+
* resolved against its named source; a plain name is resolved against the
|
|
1125
|
+
* first source description that has it.
|
|
1126
|
+
*/
|
|
1127
|
+
normalizeOperationId(operationId: string, document: ArazzoDocument): Promise<OpenAPIOperationLocator>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Normalizes an `operationPath` —
|
|
1130
|
+
* `{$sourceDescriptions.{name}.url}#/json/pointer` — to a canonical locator.
|
|
1131
|
+
*
|
|
1132
|
+
* The reference is interpolated (resolving
|
|
1133
|
+
* `{$sourceDescriptions.{name}.url}` to the source's URL) into a URI
|
|
1134
|
+
* reference; its fragment is the JSON Pointer to the operation (decoded from
|
|
1135
|
+
* the URI fragment representation) and the part before the fragment is the
|
|
1136
|
+
* source document to acquire.
|
|
1137
|
+
*
|
|
1138
|
+
* The runner only needs a URL and a JSON Pointer, so it does not enforce that
|
|
1139
|
+
* the source description is identified by a runtime expression rather than a
|
|
1140
|
+
* literal URL (a literal URL interpolates to itself and still resolves) — that
|
|
1141
|
+
* is a conformance concern for the validator. It fails only when the URL does
|
|
1142
|
+
* not resolve to an OpenAPI source or the JSON Pointer is invalid.
|
|
1143
|
+
*/
|
|
1144
|
+
normalizeOperationPath(operationPath: string, document: ArazzoDocument): Promise<OpenAPIOperationLocator>;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Facade for normalizing OpenAPI operations across all supported versions.
|
|
1149
|
+
*
|
|
1150
|
+
* Detects the OpenAPI version from the document and delegates to the
|
|
1151
|
+
* appropriate version-specific normalizer (2.0, 3.0, or 3.1).
|
|
1152
|
+
*
|
|
1153
|
+
* Custom normalizer instances can be provided via constructor options.
|
|
1154
|
+
* @public
|
|
1155
|
+
*/
|
|
1156
|
+
export declare class OpenAPIOperationNormalizer {
|
|
1157
|
+
#private;
|
|
1158
|
+
constructor(options?: OpenAPIOperationNormalizerOptions);
|
|
1159
|
+
/**
|
|
1160
|
+
* Normalizes the operation by delegating to the version-specific normalizer.
|
|
1161
|
+
*/
|
|
1162
|
+
normalize(operation: OpenAPIOperationElement, document: OpenAPIDocument): Promise<OpenAPIOperationElement>;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Options for the OpenAPI operation normalizer facade.
|
|
1167
|
+
* @public
|
|
1168
|
+
*/
|
|
1169
|
+
export declare interface OpenAPIOperationNormalizerOptions {
|
|
1170
|
+
readonly openapi2?: OpenAPI2OperationNormalizer;
|
|
1171
|
+
readonly openapi30?: OpenAPI30OperationNormalizer;
|
|
1172
|
+
readonly openapi31?: OpenAPI31OperationNormalizer;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Resolves the `parameters` of a step targeting an OpenAPI operation into the
|
|
1177
|
+
* map the operation is executed with.
|
|
1178
|
+
*
|
|
1179
|
+
* Values follow the family-wide literal-vs-expression rule of
|
|
1180
|
+
* {@link ArazzoValueResolver}. Keys and their first-wins claiming are
|
|
1181
|
+
* `ParameterDelivery`'s: `'{in}.{name}'` for a location the client
|
|
1182
|
+
* can address — a parameter is unique by `(name, in)`, so keying by name
|
|
1183
|
+
* alone would collapse two parameters that differ only in their location into
|
|
1184
|
+
* one entry and silently drop the other, where an operation legally declaring
|
|
1185
|
+
* `token` both as a header and as a query parameter must receive both — and
|
|
1186
|
+
* the bare name for Arazzo's `querystring`, which names no OpenAPI location.
|
|
1187
|
+
* First-wins is the override order the specification requires: the list is
|
|
1188
|
+
* ordered by precedence, most specific first, as `ArazzoWorkflowNormalizer`
|
|
1189
|
+
* leaves it once a step's own parameters have been merged with the ones it
|
|
1190
|
+
* inherits.
|
|
1191
|
+
*
|
|
1192
|
+
* What the map reports, this resolver judges. A parameter without a location
|
|
1193
|
+
* throws {@link ResolverError}: a step targeting an operation requires one
|
|
1194
|
+
* (the normalizer does not inherit input-shaped workflow parameters into such
|
|
1195
|
+
* steps, so this is the step's own authoring error), and delivering it bare
|
|
1196
|
+
* instead would let it capture *every* declared location of that name — see
|
|
1197
|
+
* `ParameterDelivery` for the lookup order that makes it so. A
|
|
1198
|
+
* non-string location throws for the same reason it deduplicates with nothing
|
|
1199
|
+
* in the normalizer: it names no location. And two *different* parameters the
|
|
1200
|
+
* map reports as colliding cannot both be delivered, so a collision throws
|
|
1201
|
+
* rather than silently dropping one — whether they collide on one key (the
|
|
1202
|
+
* scheme is not injective: a `querystring` parameter named `header.token` and
|
|
1203
|
+
* a header parameter named `token` both produce `header.token`) or across a
|
|
1204
|
+
* bare/qualified pair sharing a name (a `querystring` `token` next to a
|
|
1205
|
+
* header `token`), where the client would consult the bare name first and
|
|
1206
|
+
* silently capture the qualified value.
|
|
1207
|
+
* @public
|
|
1208
|
+
*/
|
|
1209
|
+
export declare class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
1210
|
+
/**
|
|
1211
|
+
* Resolves each parameter's `value`, returning a
|
|
1212
|
+
* `ParameterDelivery`-keyed record. Returns an empty object when
|
|
1213
|
+
* there are no parameters.
|
|
1214
|
+
*
|
|
1215
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
1216
|
+
*/
|
|
1217
|
+
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* The HTTP request built for an OpenAPI operation.
|
|
1222
|
+
*
|
|
1223
|
+
* Produced by the vendored swagger-client `buildRequest` from the assembled
|
|
1224
|
+
* single-operation document — the URL is fully resolved (server + path +
|
|
1225
|
+
* serialized query string), parameters are serialized per their style/explode
|
|
1226
|
+
* rules, and securities are already applied to headers/query. The object is
|
|
1227
|
+
* intentionally mutable: request interceptors may edit it (or return a
|
|
1228
|
+
* replacement) before it is handed to the {@link HTTPClient}.
|
|
1229
|
+
*
|
|
1230
|
+
* The open tail carries whatever extra fields a builder attaches; the default
|
|
1231
|
+
* transport passes the whole object as fetch init, so standard `RequestInit`
|
|
1232
|
+
* fields (`credentials`, `signal`, …) take effect on the wire.
|
|
1233
|
+
* @public
|
|
1234
|
+
*/
|
|
1235
|
+
export declare interface OpenAPIOperationRequest {
|
|
1236
|
+
url: string;
|
|
1237
|
+
method: string;
|
|
1238
|
+
headers: Record<string, string>;
|
|
1239
|
+
body?: unknown;
|
|
1240
|
+
credentials?: RequestCredentials;
|
|
1241
|
+
signal?: AbortSignal;
|
|
1242
|
+
[key: string]: unknown;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* The HTTP request an OpenAPI operation was executed with.
|
|
1247
|
+
*
|
|
1248
|
+
* An immutable snapshot of the request as actually sent, recorded by the
|
|
1249
|
+
* executor after the interceptors ran and before the transport was called, so
|
|
1250
|
+
* runtime expressions (`$url`, `$method`, `$request.header.*`, `$request.body`)
|
|
1251
|
+
* can be evaluated against it after execution. `headers` is a copy taken at
|
|
1252
|
+
* capture time; `body` shares its reference with the sent request.
|
|
1253
|
+
* @public
|
|
1254
|
+
*/
|
|
1255
|
+
export declare interface OpenAPIOperationRequestInfo {
|
|
1256
|
+
readonly url: string;
|
|
1257
|
+
readonly method: string;
|
|
1258
|
+
readonly headers: Record<string, string>;
|
|
1259
|
+
readonly body?: unknown;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Response from an OpenAPI operation execution.
|
|
1264
|
+
* @public
|
|
1265
|
+
*/
|
|
1266
|
+
export declare class OpenAPIOperationResponse {
|
|
1267
|
+
readonly ok: boolean;
|
|
1268
|
+
readonly url: string;
|
|
1269
|
+
readonly status: number;
|
|
1270
|
+
readonly statusText: string;
|
|
1271
|
+
readonly headers: Record<string, string>;
|
|
1272
|
+
readonly text: string;
|
|
1273
|
+
readonly body: unknown;
|
|
1274
|
+
readonly request: OpenAPIOperationRequestInfo | undefined;
|
|
1275
|
+
constructor(raw: {
|
|
1276
|
+
ok: boolean;
|
|
1277
|
+
url: string;
|
|
1278
|
+
status: number;
|
|
1279
|
+
statusText: string;
|
|
1280
|
+
headers: Record<string, string>;
|
|
1281
|
+
text: string;
|
|
1282
|
+
body: unknown;
|
|
1283
|
+
request?: OpenAPIOperationRequestInfo;
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Normalizes a raw WHATWG `Response` into an {@link OpenAPIOperationResponse}.
|
|
1289
|
+
*
|
|
1290
|
+
* Wraps the vendored swagger-client response deserializer (upstream
|
|
1291
|
+
* `serializeRes`, aliased at the vendor boundary), whose battle-tested
|
|
1292
|
+
* content-type dispatch (JSON/XML/YAML/text vs binary) means the response
|
|
1293
|
+
* model runtime expressions and criteria see is defined here, on the runner's
|
|
1294
|
+
* side of the {@link HTTPClient} seam, and stays identical across transports.
|
|
1295
|
+
* Headers are taken from the `Response` directly rather than from the
|
|
1296
|
+
* deserializer, which splits every value containing `", "` into an array:
|
|
1297
|
+
* values stay strings as sent, with repeated fields (`Set-Cookie` included)
|
|
1298
|
+
* combined by `Headers.get`.
|
|
1299
|
+
* @public
|
|
1300
|
+
*/
|
|
1301
|
+
export declare class OpenAPIOperationResponseNormalizer {
|
|
1302
|
+
/**
|
|
1303
|
+
* Deserializes the response body by content type and maps the result into the
|
|
1304
|
+
* runner's response model. `request` is the request the operation was
|
|
1305
|
+
* executed with; its `url` doubles as the fallback when the `Response`
|
|
1306
|
+
* carries none (e.g. a stubbed transport).
|
|
1307
|
+
*/
|
|
1308
|
+
normalize(response: Response, request?: OpenAPIOperationRequestInfo): Promise<OpenAPIOperationResponse>;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Union of PathItemElement across all supported OpenAPI versions.
|
|
1313
|
+
* @public
|
|
1314
|
+
*/
|
|
1315
|
+
export declare type OpenAPIPathItemElement = PathItemElement | PathItemElement_2 | PathItemElement_3;
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Unique identifier of an OpenAPI operation.
|
|
1319
|
+
* @public
|
|
1320
|
+
*/
|
|
1321
|
+
export declare type OperationId = string;
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Resolves a step's or workflow's `outputs` to a plain map of name → value.
|
|
1325
|
+
*
|
|
1326
|
+
* The spec types `outputs` as `Map[string, {expression}]`, so a whole runtime
|
|
1327
|
+
* expression is the *only* authored form — unlike a parameter's `value` or a
|
|
1328
|
+
* `requestBody` payload (typed `Any`), where {@link ArazzoValueResolver} lets a
|
|
1329
|
+
* literal through. An output that is not a valid runtime expression is an
|
|
1330
|
+
* authoring error and throws a {@link ResolverError}.
|
|
1331
|
+
*
|
|
1332
|
+
* The result is the map an executor stores into the workflow execution state so
|
|
1333
|
+
* later steps can read `$steps.{id}.outputs.{name}` / `$outputs.{name}`.
|
|
1334
|
+
* @public
|
|
1335
|
+
*/
|
|
1336
|
+
export declare class OutputResolver extends ArazzoValueResolver {
|
|
1337
|
+
/**
|
|
1338
|
+
* Resolves each output value, returning a `name` → value map. Returns an empty
|
|
1339
|
+
* object when there are no outputs.
|
|
1340
|
+
*
|
|
1341
|
+
* `scope` names the step or workflow the outputs belong to, for a thrown
|
|
1342
|
+
* {@link ResolverError}. An output value that is not a valid runtime
|
|
1343
|
+
* expression throws with `reason: 'invalid-expression'`.
|
|
1344
|
+
*/
|
|
1345
|
+
resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Record<string, unknown>;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Evaluates a `regex` Arazzo criterion condition against a resolved context value.
|
|
1350
|
+
*
|
|
1351
|
+
* The Arazzo specification does not pin a regular expression dialect for the
|
|
1352
|
+
* `regex` criterion type. This evaluator uses ECMA-262 (the native `RegExp`
|
|
1353
|
+
* dialect), matching OpenAPI, which pins ECMA-262 for `pattern` via JSON Schema.
|
|
1354
|
+
* The pattern is applied with search (not full-match) semantics — anchoring is
|
|
1355
|
+
* the author's responsibility via `^`/`$`, consistent with the spec's `^200$`
|
|
1356
|
+
* example.
|
|
1357
|
+
*
|
|
1358
|
+
* Per Arazzo 1.1.0, a `null` or `undefined` context fails the condition. A
|
|
1359
|
+
* non-scalar context is serialized with `JSON.stringify` (matching how the
|
|
1360
|
+
* runtime expression evaluator stringifies values for interpolation), so a
|
|
1361
|
+
* pattern can match against an object/array body; scalars are coerced with
|
|
1362
|
+
* `String()`.
|
|
1363
|
+
*
|
|
1364
|
+
* The pattern is a native `RegExp`, which has no execution timeout; a
|
|
1365
|
+
* pathological author pattern (catastrophic backtracking) against a long
|
|
1366
|
+
* context can stall. Patterns originate from the Arazzo document, so this is
|
|
1367
|
+
* treated as trusted input rather than guarded here.
|
|
1368
|
+
* @public
|
|
1369
|
+
*/
|
|
1370
|
+
export declare class RegexCriterionEvaluator {
|
|
1371
|
+
#private;
|
|
1372
|
+
/**
|
|
1373
|
+
* Tests the resolved context value against the regular expression `condition`.
|
|
1374
|
+
*
|
|
1375
|
+
* The context is coerced to a string before matching. Returns `false` when the
|
|
1376
|
+
* context is `null` or `undefined`. Throws {@link CriterionError} when the
|
|
1377
|
+
* condition is not a valid regular expression.
|
|
1378
|
+
*/
|
|
1379
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Resolves a step's `requestBody` to a concrete payload.
|
|
1384
|
+
*
|
|
1385
|
+
* The `payload` is resolved first. Per the specification it "can contain"
|
|
1386
|
+
* runtime expressions, so it is walked: every string in it — the payload
|
|
1387
|
+
* itself, or any value nested in its objects and arrays — that is a whole
|
|
1388
|
+
* runtime expression resolves to its typed value, and every other string has
|
|
1389
|
+
* its embedded `{expression}` occurrences interpolated (tolerantly, so literal
|
|
1390
|
+
* braces such as a JSON template's own are kept). Object keys and resolved
|
|
1391
|
+
* values are never evaluated.
|
|
1392
|
+
*
|
|
1393
|
+
* An unresolved expression reads as "not provided": an object member is
|
|
1394
|
+
* omitted, while a whole-expression payload, an array element or an embedded
|
|
1395
|
+
* expression — none of which can be omitted — throws {@link ResolverError}
|
|
1396
|
+
* (`unresolved-expression`), as does an invalid embedded expression
|
|
1397
|
+
* (`invalid-expression`).
|
|
1398
|
+
*
|
|
1399
|
+
* Then each `replacements` entry is applied — its `value` is resolved by the
|
|
1400
|
+
* family-wide literal-vs-expression rule of {@link ArazzoValueResolver} and set
|
|
1401
|
+
* into the payload at the replacement's `target` JSON Pointer. A replacement
|
|
1402
|
+
* whose value does not resolve is skipped, leaving the payload as authored.
|
|
1403
|
+
*
|
|
1404
|
+
* `target` may be a JSON Pointer or an XPath per the specification; only JSON
|
|
1405
|
+
* Pointer targets are supported — an XPath target throws {@link ResolverError}.
|
|
1406
|
+
* @public
|
|
1407
|
+
*/
|
|
1408
|
+
export declare class RequestBodyResolver extends ArazzoValueResolver {
|
|
1409
|
+
#private;
|
|
1410
|
+
/**
|
|
1411
|
+
* Resolves the request body, returning its payload and content type. Returns
|
|
1412
|
+
* `undefined` when there is no request body.
|
|
1413
|
+
*
|
|
1414
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
1415
|
+
*/
|
|
1416
|
+
resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): ResolvedRequestBody | undefined;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Decorates the built request before it is handed to the {@link HTTPClient}.
|
|
1421
|
+
*
|
|
1422
|
+
* Receives the finalized {@link OpenAPIOperationRequest} and may mutate it in
|
|
1423
|
+
* place or return a replacement; returning nothing keeps the received request.
|
|
1424
|
+
* May be synchronous or asynchronous.
|
|
1425
|
+
* @public
|
|
1426
|
+
*/
|
|
1427
|
+
export declare type RequestInterceptor = (request: OpenAPIOperationRequest) => OpenAPIOperationRequest | void | Promise<OpenAPIOperationRequest | void>;
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* A resolved request body: the payload with all replacements applied, plus the
|
|
1431
|
+
* declared content type when present.
|
|
1432
|
+
* @public
|
|
1433
|
+
*/
|
|
1434
|
+
export declare interface ResolvedRequestBody {
|
|
1435
|
+
readonly payload: unknown;
|
|
1436
|
+
readonly contentType?: string;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/** @public */
|
|
1440
|
+
export declare class ResolverError extends ArazzoRunnerError {
|
|
1441
|
+
readonly stepId?: string;
|
|
1442
|
+
readonly workflowId?: string;
|
|
1443
|
+
readonly target?: string;
|
|
1444
|
+
readonly reason?: string;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Identifies the step or workflow a resolver is resolving for. The wider
|
|
1449
|
+
* union {@link OutputResolver} takes, since it resolves both a step's
|
|
1450
|
+
* `outputs` and a workflow's — the one case with no step to name.
|
|
1451
|
+
* @public
|
|
1452
|
+
*/
|
|
1453
|
+
export declare type ResolverScope = StepScope | {
|
|
1454
|
+
readonly workflowId: string;
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
/**
|
|
1458
|
+
* One run of a `retry` action's `stepId` / `workflowId` reference — "the
|
|
1459
|
+
* reference is executed and the context is returned, after which the current
|
|
1460
|
+
* step is retried". Fires once per firing of its action (i.e. once before every
|
|
1461
|
+
* attempt the action grants, not once for the whole retry chain).
|
|
1462
|
+
* @public
|
|
1463
|
+
*/
|
|
1464
|
+
export declare interface RetryReferenceRecord {
|
|
1465
|
+
/**
|
|
1466
|
+
* Which field the action carried: `stepId` runs one step of the current
|
|
1467
|
+
* workflow; `workflowId` runs another workflow to completion.
|
|
1468
|
+
*/
|
|
1469
|
+
readonly kind: 'step' | 'workflow';
|
|
1470
|
+
/**
|
|
1471
|
+
* The referenced `stepId` or `workflowId`, as written — a cross-document
|
|
1472
|
+
* workflow reference stays in its
|
|
1473
|
+
* `$sourceDescriptions.{name}.{workflowId}` form.
|
|
1474
|
+
*/
|
|
1475
|
+
readonly id: string;
|
|
1476
|
+
/**
|
|
1477
|
+
* Whether the reference completed successfully. For `kind: 'workflow'`, this
|
|
1478
|
+
* is whether the referenced run's transfer chain settled `status !== 'failed'`
|
|
1479
|
+
* — a reference to a workflow that transferred is judged by where control
|
|
1480
|
+
* ended up, not by the intermediate `'transferred'` status. Does not gate the
|
|
1481
|
+
* retry: the retry proceeds either way, since the spec speaks of the
|
|
1482
|
+
* reference's *completion*, not its success.
|
|
1483
|
+
*/
|
|
1484
|
+
readonly successful: boolean;
|
|
1485
|
+
/**
|
|
1486
|
+
* The nested run, when the reference invoked a workflow — either directly
|
|
1487
|
+
* (`kind: 'workflow'`) or because the referenced step itself targets a
|
|
1488
|
+
* `workflowId` (`kind: 'step'`).
|
|
1489
|
+
*/
|
|
1490
|
+
readonly subWorkflow?: WorkflowExecutionResult;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Identifies a step that calls a workflow, for the context its criteria,
|
|
1495
|
+
* outputs and actions are evaluated against.
|
|
1496
|
+
* @public
|
|
1497
|
+
*/
|
|
1498
|
+
export declare interface RuntimeExpressionCalledWorkflowContext {
|
|
1499
|
+
/**
|
|
1500
|
+
* The id of the calling step, the one whose expressions are evaluated.
|
|
1501
|
+
*/
|
|
1502
|
+
readonly stepId: string;
|
|
1503
|
+
/**
|
|
1504
|
+
* The id of the workflow that step called.
|
|
1505
|
+
*/
|
|
1506
|
+
readonly workflowId: string;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* The runtime state an Arazzo runtime expression is evaluated against.
|
|
1511
|
+
*
|
|
1512
|
+
* Each field maps to an AST node produced by the runtime expression parser:
|
|
1513
|
+
* - `request.url` / `request.method` back `$url` / `$method`
|
|
1514
|
+
* - `request.header` / `.query` / `.path` / `.body` back `$request.{source}`
|
|
1515
|
+
* - `response.statusCode` backs `$statusCode`
|
|
1516
|
+
* - `response.header` / `.body` back `$response.{source}`
|
|
1517
|
+
* - `inputs` backs `$inputs.{name}`
|
|
1518
|
+
* - `outputs` backs `$outputs.{name}`
|
|
1519
|
+
* - `steps` backs `$steps.{stepId}.outputs.{name}`
|
|
1520
|
+
* - `workflows` backs `$workflows.{workflowId}.{inputs|outputs}.{name}`
|
|
1521
|
+
* - `calledWorkflow` marks a step that calls a workflow: such a step made no
|
|
1522
|
+
* HTTP call, so `$url`, `$method`, `$statusCode`, `$request.{source}` and
|
|
1523
|
+
* `$response.{source}` are authoring errors there rather than unresolved
|
|
1524
|
+
* references, and `outputs` holds the called workflow's outputs
|
|
1525
|
+
*
|
|
1526
|
+
* The context holds only genuinely runtime state. Static, document-sourced
|
|
1527
|
+
* expressions — `$components.{field}.{name}` and
|
|
1528
|
+
* `$sourceDescriptions.{name}.{reference}` — are resolved on demand by the
|
|
1529
|
+
* evaluator against the document registry, not carried here.
|
|
1530
|
+
*
|
|
1531
|
+
* Payload-bearing values (`request.body`, `response.body`, step/workflow output
|
|
1532
|
+
* values) are drilled through a composed JSON Pointer realm, so they may be
|
|
1533
|
+
* either plain JS values or ApiDOM elements.
|
|
1534
|
+
* @public
|
|
1535
|
+
*/
|
|
1536
|
+
export declare interface RuntimeExpressionContext {
|
|
1537
|
+
readonly request?: RuntimeExpressionRequestContext;
|
|
1538
|
+
readonly response?: RuntimeExpressionResponseContext;
|
|
1539
|
+
readonly inputs?: unknown;
|
|
1540
|
+
readonly outputs?: unknown;
|
|
1541
|
+
readonly steps?: Record<string, RuntimeExpressionStepContext>;
|
|
1542
|
+
readonly workflows?: Record<string, RuntimeExpressionWorkflowContext>;
|
|
1543
|
+
readonly calledWorkflow?: RuntimeExpressionCalledWorkflowContext;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
/** @public */
|
|
1547
|
+
export declare class RuntimeExpressionError extends ArazzoRunnerError {
|
|
1548
|
+
readonly expression?: string;
|
|
1549
|
+
readonly reason?: string;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* Evaluates Arazzo runtime expressions against a context.
|
|
1554
|
+
*
|
|
1555
|
+
* A single evaluator is bound to one context and can evaluate many expressions
|
|
1556
|
+
* against it — matching how a step executor resolves a step's parameters,
|
|
1557
|
+
* success criteria, and outputs from the same state.
|
|
1558
|
+
*
|
|
1559
|
+
* The context holds only runtime state (`$inputs`, `$steps`, `$request`,
|
|
1560
|
+
* `$response`, …). Static, document-sourced expressions are resolved on demand:
|
|
1561
|
+
* `$components` and `$workflows.{workflowId}.steps.{stepId}` from the
|
|
1562
|
+
* evaluator's document, and `$sourceDescriptions` from the external document
|
|
1563
|
+
* (via the registry) the source name points at. A step reference resolves to
|
|
1564
|
+
* the Step Object as authored — a locator, not the step's execution result.
|
|
1565
|
+
*
|
|
1566
|
+
* A reference resolves to `undefined` when it is absent. Runtime values
|
|
1567
|
+
* originate from JSON (or ApiDOM), which cannot represent `undefined` — an
|
|
1568
|
+
* absent value is a missing property and an explicit null is `null` — so
|
|
1569
|
+
* `undefined` unambiguously marks "unresolved".
|
|
1570
|
+
*
|
|
1571
|
+
* Three modes are supported:
|
|
1572
|
+
* - {@link RuntimeExpressionEvaluator.evaluate} resolves a pure expression
|
|
1573
|
+
* (e.g. `$response.body#/id`) to its typed value.
|
|
1574
|
+
* - {@link RuntimeExpressionEvaluator.interpolate} renders a template with
|
|
1575
|
+
* embedded `{expression}` occurrences to a string.
|
|
1576
|
+
* - {@link RuntimeExpressionEvaluator.resolve} applies Arazzo "value" semantics:
|
|
1577
|
+
* a value that is itself a complete expression resolves to a typed value,
|
|
1578
|
+
* otherwise the value is interpolated to a string.
|
|
1579
|
+
* @public
|
|
1580
|
+
*/
|
|
1581
|
+
export declare class RuntimeExpressionEvaluator {
|
|
1582
|
+
#private;
|
|
1583
|
+
constructor(context: RuntimeExpressionContext, options?: RuntimeExpressionEvaluatorOptions);
|
|
1584
|
+
/**
|
|
1585
|
+
* Evaluates a pure runtime expression to its typed value.
|
|
1586
|
+
*
|
|
1587
|
+
* The expression must be the bare form without surrounding braces
|
|
1588
|
+
* (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
|
|
1589
|
+
* unresolvable reference throws; otherwise it returns `undefined`.
|
|
1590
|
+
*/
|
|
1591
|
+
evaluate(expression: string): unknown;
|
|
1592
|
+
/**
|
|
1593
|
+
* Renders a template string, replacing each embedded `{expression}` with the
|
|
1594
|
+
* string form of its evaluated value. Returns a string.
|
|
1595
|
+
*
|
|
1596
|
+
* Object and array values are serialized with `JSON.stringify`. In non-strict
|
|
1597
|
+
* mode, unresolvable references render as an empty string. A `{…}` that is not
|
|
1598
|
+
* a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
|
|
1599
|
+
*/
|
|
1600
|
+
interpolate(template: string): string;
|
|
1601
|
+
/**
|
|
1602
|
+
* Resolves an Arazzo "value" string.
|
|
1603
|
+
*
|
|
1604
|
+
* A value that is itself a complete runtime expression (the unbraced form,
|
|
1605
|
+
* e.g. `$inputs.userId`) resolves to its typed value — "runtime expressions
|
|
1606
|
+
* preserve the type of the referenced value". Any other string is an
|
|
1607
|
+
* expression-string template: embedded `{expression}` occurrences are
|
|
1608
|
+
* interpolated and a string is returned, so a whole-string `{expression}`
|
|
1609
|
+
* yields the string representation of its value, not the typed value. A
|
|
1610
|
+
* string containing no expressions is returned unchanged.
|
|
1611
|
+
*/
|
|
1612
|
+
resolve(value: string): unknown;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* Options for the RuntimeExpressionEvaluator.
|
|
1617
|
+
* @public
|
|
1618
|
+
*/
|
|
1619
|
+
export declare interface RuntimeExpressionEvaluatorOptions {
|
|
1620
|
+
/**
|
|
1621
|
+
* When `true` (default), an unresolvable reference throws a
|
|
1622
|
+
* RuntimeExpressionError. When `false`, unresolvable references evaluate to
|
|
1623
|
+
* `undefined`. Parse failures always throw regardless of this setting.
|
|
1624
|
+
*/
|
|
1625
|
+
readonly strict?: boolean;
|
|
1626
|
+
/**
|
|
1627
|
+
* The Arazzo document the expression is evaluated within. Required to resolve
|
|
1628
|
+
* `$components.{field}.{name}` and `$workflows.{workflowId}.steps.{stepId}`
|
|
1629
|
+
* (both read from this document) and `$sourceDescriptions.{name}.{reference}`
|
|
1630
|
+
* (whose source name is resolved against this document). Absent references
|
|
1631
|
+
* resolve to `undefined`.
|
|
1632
|
+
*/
|
|
1633
|
+
readonly document?: ArazzoDocument;
|
|
1634
|
+
/**
|
|
1635
|
+
* The document registry, used to reach the external document a
|
|
1636
|
+
* `$sourceDescriptions` reference points at. The referenced document must
|
|
1637
|
+
* already be loaded — resolution is synchronous and never triggers a fetch.
|
|
1638
|
+
*/
|
|
1639
|
+
readonly registry?: DocumentRegistry;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* Request-side data available to runtime expressions.
|
|
1644
|
+
*
|
|
1645
|
+
* Populated by the step executor from the HTTP request that was (or will be) sent.
|
|
1646
|
+
* Header lookup is case-insensitive because the runtime expression parser
|
|
1647
|
+
* lowercases header tokens.
|
|
1648
|
+
* @public
|
|
1649
|
+
*/
|
|
1650
|
+
export declare interface RuntimeExpressionRequestContext {
|
|
1651
|
+
readonly url?: string;
|
|
1652
|
+
readonly method?: string;
|
|
1653
|
+
readonly header?: Record<string, unknown>;
|
|
1654
|
+
readonly query?: Record<string, unknown>;
|
|
1655
|
+
readonly path?: Record<string, unknown>;
|
|
1656
|
+
readonly body?: unknown;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Resolves a runtime expression to its value.
|
|
1661
|
+
*
|
|
1662
|
+
* Bridged to a lenient runtime expression evaluator
|
|
1663
|
+
* (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
|
|
1664
|
+
* unresolvable reference yields `undefined` rather than throwing.
|
|
1665
|
+
* @public
|
|
1666
|
+
*/
|
|
1667
|
+
export declare type RuntimeExpressionResolver = (expression: string) => unknown;
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* Response-side data available to runtime expressions.
|
|
1671
|
+
*
|
|
1672
|
+
* Populated by the step executor from the HTTP response that was received.
|
|
1673
|
+
* Header lookup is case-insensitive because the runtime expression parser
|
|
1674
|
+
* lowercases header tokens.
|
|
1675
|
+
* @public
|
|
1676
|
+
*/
|
|
1677
|
+
export declare interface RuntimeExpressionResponseContext {
|
|
1678
|
+
readonly statusCode?: number;
|
|
1679
|
+
readonly header?: Record<string, unknown>;
|
|
1680
|
+
readonly body?: unknown;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Per-step state available to `$steps.{stepId}.outputs.{name}` expressions.
|
|
1685
|
+
* @public
|
|
1686
|
+
*/
|
|
1687
|
+
export declare interface RuntimeExpressionStepContext {
|
|
1688
|
+
readonly outputs?: Record<string, unknown>;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
/**
|
|
1692
|
+
* Per-workflow state available to `$workflows.{workflowId}.{inputs|outputs}.{name}` expressions.
|
|
1693
|
+
* @public
|
|
1694
|
+
*/
|
|
1695
|
+
export declare interface RuntimeExpressionWorkflowContext {
|
|
1696
|
+
readonly inputs?: Record<string, unknown>;
|
|
1697
|
+
readonly outputs?: Record<string, unknown>;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* The action selected for a step outcome — a Success or Failure Action element.
|
|
1702
|
+
* @public
|
|
1703
|
+
*/
|
|
1704
|
+
export declare type SelectedAction = SuccessActionElement | FailureActionElement;
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* The result a transfer chain settled on: `result` itself when its `status`
|
|
1708
|
+
* isn't `'transferred'`, otherwise the terminal, non-`'transferred'` result at
|
|
1709
|
+
* the end of its `transferredTo` chain.
|
|
1710
|
+
*
|
|
1711
|
+
* For the success/failure verdict alone, prefer
|
|
1712
|
+
* {@link WorkflowExecutionResult.settledStatus} — every result already
|
|
1713
|
+
* carries it, computed eagerly, so no call is needed. Reach for this function
|
|
1714
|
+
* when the terminal result *itself* is wanted (its `outputs`, `steps`,
|
|
1715
|
+
* `workflowId`), not just where it landed. Iterative, not recursive: a
|
|
1716
|
+
* chain's length is bounded only by `maxWorkflowDepth`, and this must not add
|
|
1717
|
+
* a matching bound on call-stack depth.
|
|
1718
|
+
* @public
|
|
1719
|
+
*/
|
|
1720
|
+
export declare function settledResult(result: WorkflowExecutionResult): WorkflowExecutionResult;
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Evaluates a `simple` Arazzo criterion condition.
|
|
1724
|
+
*
|
|
1725
|
+
* A simple condition embeds runtime expressions directly in the condition
|
|
1726
|
+
* (e.g. `$statusCode == 200 && $response.body.status == 'available'`), so —
|
|
1727
|
+
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
1728
|
+
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
1729
|
+
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
1730
|
+
* resolved through the supplied resolver.
|
|
1731
|
+
*
|
|
1732
|
+
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
1733
|
+
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
1734
|
+
* comparisons are false, matching the spec's "null equals only null"), so a
|
|
1735
|
+
* negated or disjunctive condition may still pass. A malformed condition throws
|
|
1736
|
+
* {@link CriterionError}.
|
|
1737
|
+
* @public
|
|
1738
|
+
*/
|
|
1739
|
+
export declare class SimpleCriterionEvaluator {
|
|
1740
|
+
/**
|
|
1741
|
+
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
1742
|
+
* expression via `resolve`.
|
|
1743
|
+
*/
|
|
1744
|
+
evaluate(condition: string, resolve: CriterionContextResolver): boolean;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* One indexed source description: the parsed element and its canonical URI —
|
|
1749
|
+
* already resolved against the owning document's base URI, in the exact form
|
|
1750
|
+
* the document registry keys on — or `undefined` for a source with no
|
|
1751
|
+
* resolvable `url`.
|
|
1752
|
+
* @public
|
|
1753
|
+
*/
|
|
1754
|
+
export declare interface SourceDescriptionEntry {
|
|
1755
|
+
readonly element: SourceDescriptionElement;
|
|
1756
|
+
readonly uri: string | undefined;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Unique name of a source description within an Arazzo document.
|
|
1761
|
+
* @public
|
|
1762
|
+
*/
|
|
1763
|
+
export declare type SourceDescriptionName = string;
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Base of the locator normalizers that resolve
|
|
1767
|
+
* `$sourceDescriptions.{name}.{reference}` runtime expressions — the OpenAPI
|
|
1768
|
+
* operation locator and the Arazzo workflow locator. Owns the registry handle
|
|
1769
|
+
* and the one grammar-facing parse, so the expression node's name and field
|
|
1770
|
+
* shape are encoded once rather than per subclass.
|
|
1771
|
+
* @public
|
|
1772
|
+
*/
|
|
1773
|
+
export declare abstract class SourceDescriptionsLocatorNormalizer {
|
|
1774
|
+
protected readonly registry: DocumentRegistry;
|
|
1775
|
+
constructor(registry: DocumentRegistry);
|
|
1776
|
+
/**
|
|
1777
|
+
* Parses a `$sourceDescriptions.{name}.{reference}` expression, or returns
|
|
1778
|
+
* `undefined` when the string is not one (whether it fails to parse or
|
|
1779
|
+
* parses to another expression kind) — each subclass raises its own error
|
|
1780
|
+
* type, message, and context for its own position.
|
|
1781
|
+
*/
|
|
1782
|
+
protected parseSourceDescriptionsExpression(expression: string): {
|
|
1783
|
+
sourceName: string;
|
|
1784
|
+
reference: string;
|
|
1785
|
+
} | undefined;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/**
|
|
1789
|
+
* The outcome of executing a single step.
|
|
1790
|
+
* @public
|
|
1791
|
+
*/
|
|
1792
|
+
export declare interface StepExecutionResult {
|
|
1793
|
+
readonly stepId: string;
|
|
1794
|
+
readonly response: OpenAPIOperationResponse;
|
|
1795
|
+
readonly successful: boolean;
|
|
1796
|
+
readonly outputs: Record<string, unknown>;
|
|
1797
|
+
/**
|
|
1798
|
+
* The action to take for this outcome — the first of {@link StepExecutionResult.matchedActions},
|
|
1799
|
+
* or `undefined` when none matched (the caller then applies the path default).
|
|
1800
|
+
*/
|
|
1801
|
+
readonly action: SelectedAction | undefined;
|
|
1802
|
+
/**
|
|
1803
|
+
* Every `onSuccess` / `onFailure` action whose criteria matched this outcome,
|
|
1804
|
+
* in list order. Usually the caller acts on `action` (the first); the workflow
|
|
1805
|
+
* executor walks the full list to honor "retryLimit exhausted prior to
|
|
1806
|
+
* subsequent failure actions" — falling from an exhausted `retry` to the next
|
|
1807
|
+
* matching action. Empty when none matched.
|
|
1808
|
+
*/
|
|
1809
|
+
readonly matchedActions: readonly SelectedAction[];
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Executes a single Arazzo step that invokes an OpenAPI operation.
|
|
1814
|
+
*
|
|
1815
|
+
* The pipeline locates the step's operation (`operationId` / `operationPath`),
|
|
1816
|
+
* resolves the step's parameters and request body against the pre-request
|
|
1817
|
+
* context, delegates to {@link OpenAPIOperationExecutor} to run the located
|
|
1818
|
+
* operation, then evaluates `successCriteria`, resolves `outputs`, and selects
|
|
1819
|
+
* the `onSuccess`/`onFailure` action against the post-request context.
|
|
1820
|
+
*
|
|
1821
|
+
* It reads run state through a {@link ContextSource} and mutates nothing — the
|
|
1822
|
+
* caller records the returned outputs and interprets the returned action. A step
|
|
1823
|
+
* targeting a `workflowId` (a sub-workflow) is not an operation step and throws
|
|
1824
|
+
* {@link ExecutionError}; running sub-workflows is the workflow executor's
|
|
1825
|
+
* concern. A received response with unmet criteria is a normal
|
|
1826
|
+
* `successful: false` outcome; malformed input (e.g. an invalid criterion or
|
|
1827
|
+
* expression) throws, as does a run the caller has cancelled through an
|
|
1828
|
+
* `AbortSignal` in the execute options.
|
|
1829
|
+
* @public
|
|
1830
|
+
*/
|
|
1831
|
+
export declare class StepExecutor {
|
|
1832
|
+
#private;
|
|
1833
|
+
constructor(options: StepExecutorOptions);
|
|
1834
|
+
/**
|
|
1835
|
+
* A step executor bound to the given document, sharing this one's registry
|
|
1836
|
+
* and operation executor — this instance itself when the document is
|
|
1837
|
+
* already the one it is bound to.
|
|
1838
|
+
*
|
|
1839
|
+
* A step executor's identity includes the document its steps belong to: a
|
|
1840
|
+
* plain `operationId` resolves against *that* document's source
|
|
1841
|
+
* descriptions, and `$components` / `$sourceDescriptions` expressions
|
|
1842
|
+
* resolve against it too. A cross-document workflow run therefore derives
|
|
1843
|
+
* a sibling per foreign document rather than re-pointing this one.
|
|
1844
|
+
*/
|
|
1845
|
+
forDocument(document: ArazzoDocument): StepExecutor;
|
|
1846
|
+
/**
|
|
1847
|
+
* Executes the step against the given run state, returning its outcome.
|
|
1848
|
+
*
|
|
1849
|
+
* `executeOptions` is an opaque bag passed through to the operation executor
|
|
1850
|
+
* (e.g. a `server` to run the step against, or an `AbortSignal`). The
|
|
1851
|
+
* Arazzo-derived options (`operationId`, `parameters`, `requestBody`) always
|
|
1852
|
+
* take precedence over it.
|
|
1853
|
+
*
|
|
1854
|
+
* A `signal` in that bag is honored here and not only at the transport: an
|
|
1855
|
+
* already-aborted signal throws `reason: 'aborted'` instead of issuing a
|
|
1856
|
+
* request nobody is waiting for, whose wire-level cancellation would surface
|
|
1857
|
+
* as a transport {@link ClientError} — a request that failed on its own terms
|
|
1858
|
+
* — rather than as the withdrawal it is.
|
|
1859
|
+
*/
|
|
1860
|
+
execute(step: StepElement, state: ContextSource, executeOptions?: Record<string, unknown>): Promise<StepExecutionResult>;
|
|
1861
|
+
/**
|
|
1862
|
+
* Evaluates the step's `successCriteria`; all criteria must pass. A step with
|
|
1863
|
+
* no criteria succeeds on a received response.
|
|
1864
|
+
*
|
|
1865
|
+
* Public for the same reason as {@link StepExecutor.selectActions}: a step
|
|
1866
|
+
* targeting a `workflowId` is run by the workflow executor and never reaches
|
|
1867
|
+
* {@link StepExecutor.execute}, but its criteria are still the author's
|
|
1868
|
+
* assertion about the step and must be evaluated somewhere.
|
|
1869
|
+
*/
|
|
1870
|
+
evaluateCriteria(step: StepElement, context: RuntimeExpressionContext): boolean;
|
|
1871
|
+
/**
|
|
1872
|
+
* Selects every matching `onSuccess` / `onFailure` action for the outcome, in
|
|
1873
|
+
* list order, gating each action's criteria against the context.
|
|
1874
|
+
*
|
|
1875
|
+
* The step's own list is the whole story here: a step that declares none of
|
|
1876
|
+
* its own already carries the workflow-level defaults, inherited by
|
|
1877
|
+
* {@link ArazzoWorkflowNormalizer} — the same place a step's inherited
|
|
1878
|
+
* `parameters` come from — so there is no fallback left to apply at selection
|
|
1879
|
+
* time.
|
|
1880
|
+
*
|
|
1881
|
+
* The full matching list (not just the first) is returned so the caller can
|
|
1882
|
+
* honor "retryLimit exhausted prior to subsequent failure actions"; the common
|
|
1883
|
+
* caller simply takes the first.
|
|
1884
|
+
*
|
|
1885
|
+
* Public because selecting a step's actions is meaningful beyond running one:
|
|
1886
|
+
* the workflow executor selects them for a step targeting a `workflowId`, which
|
|
1887
|
+
* it runs itself and which therefore never reaches
|
|
1888
|
+
* {@link StepExecutor.execute}. Both callers reach the criteria evaluator and
|
|
1889
|
+
* the expression context through this one method rather than wiring their own.
|
|
1890
|
+
*/
|
|
1891
|
+
selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext): SelectedAction[];
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* Options for the StepExecutor.
|
|
1896
|
+
* @public
|
|
1897
|
+
*/
|
|
1898
|
+
export declare interface StepExecutorOptions {
|
|
1899
|
+
/**
|
|
1900
|
+
* The Arazzo document the steps belong to — typically the entry document;
|
|
1901
|
+
* used to resolve each step's operation locator against its source
|
|
1902
|
+
* descriptions, and to resolve `$components` / `$sourceDescriptions` in
|
|
1903
|
+
* expressions. For a step of a workflow in another document, derive a
|
|
1904
|
+
* sibling executor with {@link StepExecutor.forDocument}.
|
|
1905
|
+
*/
|
|
1906
|
+
readonly document: ArazzoDocument;
|
|
1907
|
+
/**
|
|
1908
|
+
* The document registry holding the already-loaded source documents.
|
|
1909
|
+
*/
|
|
1910
|
+
readonly registry: DocumentRegistry;
|
|
1911
|
+
/**
|
|
1912
|
+
* The operation engine each step's located operation is delegated to. Build it
|
|
1913
|
+
* with the client factory (or a deterministic stub in tests) and pass it in —
|
|
1914
|
+
* the step executor is agnostic to how the operation reaches the live API.
|
|
1915
|
+
*/
|
|
1916
|
+
readonly operationExecutor: OpenAPIOperationExecutor;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Unique identifier of a step within an Arazzo workflow.
|
|
1921
|
+
* @public
|
|
1922
|
+
*/
|
|
1923
|
+
export declare type StepId = string;
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* Resolves a step's `parameters` to a plain map of resolved values.
|
|
1927
|
+
*
|
|
1928
|
+
* What a parameter's `value` means is the family-wide rule of
|
|
1929
|
+
* {@link ArazzoValueResolver}; how the resolved values are *keyed* is the subclass's
|
|
1930
|
+
* policy, one per step target — {@link OpenAPIOperationParameterResolver} keys
|
|
1931
|
+
* request delivery for a step targeting an operation,
|
|
1932
|
+
* {@link WorkflowParameterResolver} keys a sub-workflow's inputs for a step
|
|
1933
|
+
* targeting a `workflowId`. Each executor constructs the one resolver its kind
|
|
1934
|
+
* of step calls for.
|
|
1935
|
+
* @public
|
|
1936
|
+
*/
|
|
1937
|
+
export declare abstract class StepParameterResolver extends ArazzoValueResolver {
|
|
1938
|
+
/**
|
|
1939
|
+
* Resolves each parameter's `value`, returning the map keyed by the
|
|
1940
|
+
* subclass's policy. Returns an empty object when there are no parameters.
|
|
1941
|
+
*
|
|
1942
|
+
* `scope` names the step these parameters belong to, so a thrown
|
|
1943
|
+
* {@link ResolverError} can say which step it came from — the caller always
|
|
1944
|
+
* has it, the same way {@link ActionResolver.resolveOnSuccess} is handed
|
|
1945
|
+
* `scope`.
|
|
1946
|
+
*/
|
|
1947
|
+
abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* The trace of a single step execution within a workflow run.
|
|
1952
|
+
* @public
|
|
1953
|
+
*/
|
|
1954
|
+
export declare interface StepRunRecord {
|
|
1955
|
+
readonly stepId: string;
|
|
1956
|
+
readonly successful: boolean;
|
|
1957
|
+
readonly action: SelectedAction | undefined;
|
|
1958
|
+
/**
|
|
1959
|
+
* How many times the step ran — 1 with no retries, more when a `retry` action
|
|
1960
|
+
* fired. The final `successful` / `action` reflect the last attempt.
|
|
1961
|
+
*/
|
|
1962
|
+
readonly attempts: number;
|
|
1963
|
+
/**
|
|
1964
|
+
* Elapsed time the step took, covering every attempt and the `retryAfter`
|
|
1965
|
+
* waits between them. Measured on a monotonic clock by default, so it may be
|
|
1966
|
+
* fractional and is unaffected by system clock changes.
|
|
1967
|
+
*/
|
|
1968
|
+
readonly durationMs: number;
|
|
1969
|
+
/**
|
|
1970
|
+
* The sub-workflow runs this step produced, in attempt order — present only on
|
|
1971
|
+
* a step targeting a `workflowId`.
|
|
1972
|
+
*
|
|
1973
|
+
* A list rather than a single result because a retried sub-workflow step runs
|
|
1974
|
+
* its sub-workflow once per attempt, and each run is a trace of its own; the
|
|
1975
|
+
* last entry is the run this record's `successful` / `action` describe.
|
|
1976
|
+
*/
|
|
1977
|
+
readonly subWorkflows?: readonly WorkflowExecutionResult[];
|
|
1978
|
+
/**
|
|
1979
|
+
* The `retry` reference runs this step's attempts produced, in firing order —
|
|
1980
|
+
* present only when a `retry` failure action that fired carried a `stepId` /
|
|
1981
|
+
* `workflowId` reference. Kept separate from {@link StepRunRecord.subWorkflows}
|
|
1982
|
+
* because a reference is a repair the *retry* invokes, not the step's own
|
|
1983
|
+
* target.
|
|
1984
|
+
*/
|
|
1985
|
+
readonly retryReferences?: readonly RetryReferenceRecord[];
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
/**
|
|
1989
|
+
* Identifies the step a resolver is resolving for, so a thrown
|
|
1990
|
+
* {@link ResolverError} can say which one it came from. Every resolver that
|
|
1991
|
+
* only ever runs within a step's scope — {@link OpenAPIOperationParameterResolver},
|
|
1992
|
+
* {@link WorkflowParameterResolver}, {@link RequestBodyResolver},
|
|
1993
|
+
* {@link ActionResolver} — takes this.
|
|
1994
|
+
* @public
|
|
1995
|
+
*/
|
|
1996
|
+
export declare interface StepScope {
|
|
1997
|
+
readonly stepId: string;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/** @public */
|
|
2001
|
+
export declare class UnmatchedProviderError extends ArazzoRunnerError {
|
|
2002
|
+
readonly uri?: string;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
* Per-call options for {@link WorkflowExecutor.execute}.
|
|
2007
|
+
* @public
|
|
2008
|
+
*/
|
|
2009
|
+
export declare interface WorkflowExecuteOptions {
|
|
2010
|
+
/**
|
|
2011
|
+
* The workflow's inputs, read via `$inputs`.
|
|
2012
|
+
*/
|
|
2013
|
+
readonly inputs?: Record<string, unknown>;
|
|
2014
|
+
/**
|
|
2015
|
+
* The opaque client-specific bag forwarded verbatim to every
|
|
2016
|
+
* {@link StepExecutor.execute} (e.g. a `server` to run against).
|
|
2017
|
+
*/
|
|
2018
|
+
readonly executeOptions?: Record<string, unknown>;
|
|
2019
|
+
/**
|
|
2020
|
+
* Inputs for the workflows run implicitly to satisfy `dependsOn`, keyed by
|
|
2021
|
+
* the `dependsOn` entry as written — the bare workflowId for a
|
|
2022
|
+
* same-document dependency, the whole
|
|
2023
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression for a
|
|
2024
|
+
* cross-document one; consulted for transitive dependencies too. A
|
|
2025
|
+
* dependency with no entry runs with no inputs.
|
|
2026
|
+
*
|
|
2027
|
+
* The Arazzo Specification gives `dependsOn` no input-mapping mechanism of its
|
|
2028
|
+
* own (unlike a sub-workflow *step*, which maps inputs through its
|
|
2029
|
+
* `parameters`), so this is the only channel by which a dependency that
|
|
2030
|
+
* requires inputs can receive them.
|
|
2031
|
+
*/
|
|
2032
|
+
readonly dependencyInputs?: Record<string, Record<string, unknown>>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Whether to run the workflows named by `dependsOn` before the workflow's own
|
|
2035
|
+
* steps. Defaults to `true`.
|
|
2036
|
+
*
|
|
2037
|
+
* Pass `false` to assert the dependencies were already satisfied out-of-band —
|
|
2038
|
+
* "MUST be completed before" does not mean *completed by this engine in this
|
|
2039
|
+
* run*, and re-running them may duplicate side effects. Opting out records no
|
|
2040
|
+
* `$workflows.{dependencyId}.outputs`, so expressions reading a dependency's
|
|
2041
|
+
* outputs then resolve to `undefined`.
|
|
2042
|
+
*
|
|
2043
|
+
* It applies to **the workflow named in this call only**. A sub-workflow it
|
|
2044
|
+
* calls still runs its own prerequisites: those are an implementation detail
|
|
2045
|
+
* the caller may not know exists, so skipping them on their behalf would run
|
|
2046
|
+
* that workflow against state nobody claimed to have prepared.
|
|
2047
|
+
*/
|
|
2048
|
+
readonly runDependencies?: boolean;
|
|
2049
|
+
/**
|
|
2050
|
+
* Cancels the run. Observed before every step attempt — including each retry,
|
|
2051
|
+
* each sub-workflow step, and each `dependsOn` prerequisite — and during the
|
|
2052
|
+
* `retryAfter` waits between attempts, so an aborted run stops at the next
|
|
2053
|
+
* boundary rather than working its way to the end of the workflow.
|
|
2054
|
+
*
|
|
2055
|
+
* An aborted run throws {@link ExecutionError} with `reason: 'aborted'`,
|
|
2056
|
+
* naming the boundary it stopped at and carrying the signal's own `reason` as
|
|
2057
|
+
* the error's `cause`. It does not resolve as a `failed` result: cancellation
|
|
2058
|
+
* is not something the steps did, and the steps that never ran were not
|
|
2059
|
+
* decided against.
|
|
2060
|
+
*
|
|
2061
|
+
* The signal is also forwarded to the transport (through the same
|
|
2062
|
+
* `executeOptions` bag it may be passed in), so the request in flight when the
|
|
2063
|
+
* abort lands is cancelled rather than merely awaited. A `signal` passed in
|
|
2064
|
+
* that bag instead is observed here too — it cancels the run just as this
|
|
2065
|
+
* option does — and this option wins when both are given.
|
|
2066
|
+
*/
|
|
2067
|
+
readonly signal?: AbortSignal;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* The outcome of executing a workflow.
|
|
2072
|
+
*
|
|
2073
|
+
* `status` is `completed` when the steps ran to the end of the list, `ended`
|
|
2074
|
+
* when an `end` action stopped the run early, `failed` when a step failed and no
|
|
2075
|
+
* matching `onFailure` action redirected it (the break-and-return default) — or
|
|
2076
|
+
* when a `dependsOn` workflow did not complete — and `transferred` when a `goto`
|
|
2077
|
+
* action handed control one-way to another workflow: this run's own steps stop
|
|
2078
|
+
* at that point, and its `outputs` declaration is never evaluated, since the run
|
|
2079
|
+
* never reaches its own end. See {@link WorkflowExecutionResult.settledStatus}
|
|
2080
|
+
* for the success/failure verdict a `'transferred'` result defers to.
|
|
2081
|
+
* @public
|
|
2082
|
+
*/
|
|
2083
|
+
export declare interface WorkflowExecutionResult {
|
|
2084
|
+
readonly workflowId: string;
|
|
2085
|
+
readonly outputs: Record<string, unknown>;
|
|
2086
|
+
readonly steps: readonly StepRunRecord[];
|
|
2087
|
+
readonly status: 'completed' | 'ended' | 'failed' | 'transferred';
|
|
2088
|
+
/**
|
|
2089
|
+
* Where this run's outcome actually settled: `status` itself when it isn't
|
|
2090
|
+
* `'transferred'`, otherwise the terminal, non-`'transferred'` status at the
|
|
2091
|
+
* end of the {@link WorkflowExecutionResult.transferredTo} chain — computed
|
|
2092
|
+
* once, eagerly, when this result is built, so it costs nothing to read and
|
|
2093
|
+
* nothing to forget.
|
|
2094
|
+
*
|
|
2095
|
+
* `status` alone is not a success/failure verdict: `'transferred'` records
|
|
2096
|
+
* *where* control went, not whether the run succeeded, so comparing it
|
|
2097
|
+
* directly against `'failed'` — the natural thing to write — silently
|
|
2098
|
+
* misses a failure buried in the chain. `settledStatus` is that comparison,
|
|
2099
|
+
* already made, always present (even when `status` isn't `'transferred'`,
|
|
2100
|
+
* where it simply repeats `status`): prefer
|
|
2101
|
+
* `result.settledStatus === 'failed'` over `result.status === 'failed'`
|
|
2102
|
+
* for "did this run succeed", including on the top-level result
|
|
2103
|
+
* {@link WorkflowExecutor.execute} itself returns.
|
|
2104
|
+
*/
|
|
2105
|
+
readonly settledStatus: 'completed' | 'ended' | 'failed';
|
|
2106
|
+
/**
|
|
2107
|
+
* Elapsed time the run took, including its dependencies, sub-workflows, and
|
|
2108
|
+
* retry waits — and, for a `'transferred'` run, the whole chain nested
|
|
2109
|
+
* under {@link WorkflowExecutionResult.transferredTo}, since running the
|
|
2110
|
+
* target is what this run's own time was spent on. Measured on a monotonic
|
|
2111
|
+
* clock by default, so it may be fractional and is unaffected by system
|
|
2112
|
+
* clock changes.
|
|
2113
|
+
*/
|
|
2114
|
+
readonly durationMs: number;
|
|
2115
|
+
/**
|
|
2116
|
+
* The runs of the workflows named by `dependsOn`, in declaration order —
|
|
2117
|
+
* present only when the workflow declares dependencies and they were run.
|
|
2118
|
+
*
|
|
2119
|
+
* A dependency already completed earlier in the same run is not run again; its
|
|
2120
|
+
* one result is reported here for each dependent that declares it.
|
|
2121
|
+
*/
|
|
2122
|
+
readonly dependencies?: readonly WorkflowExecutionResult[];
|
|
2123
|
+
/**
|
|
2124
|
+
* The target workflow's own run, present only when `status` is `transferred`.
|
|
2125
|
+
*
|
|
2126
|
+
* Nested rather than spliced in, like {@link WorkflowExecutionResult.dependencies}
|
|
2127
|
+
* — this run's `workflowId` stays the workflow that was called, not the one
|
|
2128
|
+
* control ended up in. If the target itself transfers onward, the chain is
|
|
2129
|
+
* reachable by following `transferredTo.transferredTo`, recursively; its own
|
|
2130
|
+
* `outputs` are the only place the transfer's actual output values live, since
|
|
2131
|
+
* this run's top-level `outputs` is always `{}`.
|
|
2132
|
+
*/
|
|
2133
|
+
readonly transferredTo?: WorkflowExecutionResult;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
/**
|
|
2137
|
+
* Accumulates the runtime state of a workflow run and produces the context a
|
|
2138
|
+
* runtime expression is evaluated against.
|
|
2139
|
+
*
|
|
2140
|
+
* It holds only workflow-scoped state that grows as the run proceeds and is read
|
|
2141
|
+
* back through `$`-expressions: `$inputs`, `$steps.{id}.outputs`,
|
|
2142
|
+
* `$workflows.{id}.{inputs,outputs}`, and the workflow's own `$outputs`. Static,
|
|
2143
|
+
* document-sourced expressions (`$components`, `$sourceDescriptions`) are
|
|
2144
|
+
* resolved on demand by the evaluator and are not stored here; control-flow
|
|
2145
|
+
* position, retries, and traces belong to the executor, not to this state.
|
|
2146
|
+
*
|
|
2147
|
+
* Resolving a step's `outputs` declaration to values is the executor's job; the
|
|
2148
|
+
* resolved values are handed here as plain objects, keeping this state free of
|
|
2149
|
+
* ApiDOM and evaluation concerns. The step-scoped request/response of the
|
|
2150
|
+
* current step are layered on at read time via {@link WorkflowExecutionState.toContext}.
|
|
2151
|
+
* @public
|
|
2152
|
+
*/
|
|
2153
|
+
export declare class WorkflowExecutionState {
|
|
2154
|
+
#private;
|
|
2155
|
+
constructor(options?: WorkflowExecutionStateOptions);
|
|
2156
|
+
/**
|
|
2157
|
+
* Records the resolved outputs of a completed step, read via
|
|
2158
|
+
* `$steps.{stepId}.outputs.{name}`.
|
|
2159
|
+
*/
|
|
2160
|
+
setStepOutputs(stepId: string, outputs: Record<string, unknown>): void;
|
|
2161
|
+
/**
|
|
2162
|
+
* Sets a single workflow output, read via `$outputs.{name}`.
|
|
2163
|
+
*/
|
|
2164
|
+
setOutput(name: string, value: unknown): void;
|
|
2165
|
+
/**
|
|
2166
|
+
* Records the resolved inputs and outputs of a workflow (typically a called
|
|
2167
|
+
* sub-workflow), read via `$workflows.{workflowId}.{inputs,outputs}.{name}`.
|
|
2168
|
+
*/
|
|
2169
|
+
setWorkflow(workflowId: string, workflow: {
|
|
2170
|
+
inputs?: Record<string, unknown>;
|
|
2171
|
+
outputs?: Record<string, unknown>;
|
|
2172
|
+
}): void;
|
|
2173
|
+
/**
|
|
2174
|
+
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
2175
|
+
* context produced by `toContext`; treat the returned object as immutable.
|
|
2176
|
+
*/
|
|
2177
|
+
get outputs(): Readonly<Record<string, unknown>>;
|
|
2178
|
+
/**
|
|
2179
|
+
* The inputs/outputs already recorded for `workflowId`, or `undefined` if
|
|
2180
|
+
* none has been recorded yet. A narrow read of a single entry, for a caller
|
|
2181
|
+
* that needs one without reconstructing the whole context via `toContext`.
|
|
2182
|
+
*/
|
|
2183
|
+
getWorkflow(workflowId: string): Readonly<{
|
|
2184
|
+
inputs?: Record<string, unknown>;
|
|
2185
|
+
outputs?: Record<string, unknown>;
|
|
2186
|
+
}> | undefined;
|
|
2187
|
+
/**
|
|
2188
|
+
* Produces the runtime expression context for the current evaluation site.
|
|
2189
|
+
*
|
|
2190
|
+
* The accumulated workflow-scoped state is combined with the optional
|
|
2191
|
+
* step-scoped `request`/`response` of the step being evaluated. Omit both when
|
|
2192
|
+
* evaluating before a request is made (e.g. resolving parameters), so that
|
|
2193
|
+
* `$request`/`$response`/`$statusCode` correctly resolve to `undefined`.
|
|
2194
|
+
*/
|
|
2195
|
+
toContext(request?: RuntimeExpressionRequestContext, response?: RuntimeExpressionResponseContext): RuntimeExpressionContext;
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
/**
|
|
2199
|
+
* Options for the WorkflowExecutionState.
|
|
2200
|
+
* @public
|
|
2201
|
+
*/
|
|
2202
|
+
export declare interface WorkflowExecutionStateOptions {
|
|
2203
|
+
/**
|
|
2204
|
+
* The workflow inputs, fixed for the run and read via `$inputs`.
|
|
2205
|
+
*/
|
|
2206
|
+
readonly inputs?: Record<string, unknown>;
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
/**
|
|
2210
|
+
* Executes an Arazzo workflow: the stateful loop that turns "run one step" into
|
|
2211
|
+
* "run a workflow".
|
|
2212
|
+
*
|
|
2213
|
+
* It iterates a workflow's steps in list order, delegating each to
|
|
2214
|
+
* {@link StepExecutor}, records the resolved step outputs into a
|
|
2215
|
+
* {@link WorkflowExecutionState} so later steps read `$steps.{id}.outputs.{name}`,
|
|
2216
|
+
* and interprets the {@link SelectedAction} the step executor selects but does
|
|
2217
|
+
* not act on — advancing to the next step, jumping via `goto`, transferring
|
|
2218
|
+
* one-way to another workflow via a `goto` naming a `workflowId`, or stopping on
|
|
2219
|
+
* `end` / the failure break-default. After the loop it resolves the workflow's
|
|
2220
|
+
* `outputs` against the final state — unless the run transferred, in which case
|
|
2221
|
+
* it never reaches its own end and `outputs` stays `{}`.
|
|
2222
|
+
*
|
|
2223
|
+
* A step targeting a `workflowId` is a sub-workflow call the executor runs
|
|
2224
|
+
* itself, recursively; the workflows named by `dependsOn` are run to completion
|
|
2225
|
+
* before the workflow's own steps. Both recurse through one call tree, guarded
|
|
2226
|
+
* by a shared step budget, a nesting-depth ceiling, and cycle detection. A
|
|
2227
|
+
* `goto`'s transfer joins the same call tree, entered via `'goto'`, but is not
|
|
2228
|
+
* charged against the step budget: it fires once per step evaluation, unlike a
|
|
2229
|
+
* retry reference, which can fire repeatedly from the same frame.
|
|
2230
|
+
*
|
|
2231
|
+
* State is created fresh per {@link WorkflowExecutor.execute} call — and per
|
|
2232
|
+
* workflow invocation within it — and owned here; the returned result is
|
|
2233
|
+
* read-only. Authoring errors (missing workflow, unknown `goto` target, a cycle,
|
|
2234
|
+
* budget overflow) throw {@link ExecutionError}, as does a run the caller
|
|
2235
|
+
* cancels through {@link WorkflowExecuteOptions.signal}; a step that
|
|
2236
|
+
* legitimately fails and breaks, or a dependency that fails, is a normal
|
|
2237
|
+
* `status: 'failed'` result, not a throw — the same split {@link StepExecutor}
|
|
2238
|
+
* draws.
|
|
2239
|
+
*
|
|
2240
|
+
* A workflow reference — a sub-workflow step's `workflowId`, a `dependsOn`
|
|
2241
|
+
* entry, a `retry` action's reference, a `goto`'s transfer — may also name a
|
|
2242
|
+
* workflow of another Arazzo document, as
|
|
2243
|
+
* `$sourceDescriptions.{name}.{workflowId}`. The run then follows that
|
|
2244
|
+
* document for the foreign workflow: its id lookups, its steps' operations,
|
|
2245
|
+
* and its expressions all resolve against the document that owns it, while
|
|
2246
|
+
* the `$workflows.{workflowId}` run state stays keyed by the bare id — the
|
|
2247
|
+
* only form the runtime-expression grammar can express.
|
|
2248
|
+
* @public
|
|
2249
|
+
*/
|
|
2250
|
+
export declare class WorkflowExecutor {
|
|
2251
|
+
#private;
|
|
2252
|
+
constructor(options: WorkflowExecutorOptions);
|
|
2253
|
+
/**
|
|
2254
|
+
* Runs the named workflow to completion, returning its outcome.
|
|
2255
|
+
*
|
|
2256
|
+
* The workflows the target names in `dependsOn` are run first (see
|
|
2257
|
+
* {@link WorkflowExecuteOptions.runDependencies}), then its own steps.
|
|
2258
|
+
*
|
|
2259
|
+
* All run-scoped state — the execution state, the step trace, the control-flow
|
|
2260
|
+
* position, the call stack, the step budget, and the completed-dependency
|
|
2261
|
+
* ledger — is local to this call, so concurrent `execute` calls on one executor
|
|
2262
|
+
* do not interfere.
|
|
2263
|
+
*/
|
|
2264
|
+
execute(workflowId: WorkflowId, options?: WorkflowExecuteOptions): Promise<WorkflowExecutionResult>;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
/**
|
|
2268
|
+
* Options for the WorkflowExecutor.
|
|
2269
|
+
* @public
|
|
2270
|
+
*/
|
|
2271
|
+
export declare interface WorkflowExecutorOptions {
|
|
2272
|
+
/**
|
|
2273
|
+
* The entry Arazzo document holding the workflows to run; also the
|
|
2274
|
+
* `$components` / `$sourceDescriptions` base for every entry-document
|
|
2275
|
+
* workflow's expressions. A workflow reached through a cross-document
|
|
2276
|
+
* reference resolves against its own document instead — the document
|
|
2277
|
+
* follows the invocation, not this option.
|
|
2278
|
+
*/
|
|
2279
|
+
readonly document: ArazzoDocument;
|
|
2280
|
+
/**
|
|
2281
|
+
* The document registry holding the already-loaded source documents.
|
|
2282
|
+
*/
|
|
2283
|
+
readonly registry: DocumentRegistry;
|
|
2284
|
+
/**
|
|
2285
|
+
* The per-step engine every step is delegated to. Build it with the client
|
|
2286
|
+
* factory (or a deterministic stub in tests) and pass it in — the workflow
|
|
2287
|
+
* executor is agnostic to how a step reaches the live API.
|
|
2288
|
+
*/
|
|
2289
|
+
readonly stepExecutor: StepExecutor;
|
|
2290
|
+
/**
|
|
2291
|
+
* Upper bound on the number of step attempts in a single run — every attempt
|
|
2292
|
+
* of every step counts, including each `retry` and each entry into a
|
|
2293
|
+
* sub-workflow step. Guards against a runaway `goto` loop, a runaway `retry`,
|
|
2294
|
+
* and a runaway tree of sub-workflow calls alike. Defaults to 1000.
|
|
2295
|
+
*
|
|
2296
|
+
* The budget is shared by the whole call tree, not granted afresh per
|
|
2297
|
+
* workflow: a sub-workflow spinning on its own `goto` must not escape the
|
|
2298
|
+
* ceiling the caller set.
|
|
2299
|
+
*/
|
|
2300
|
+
readonly maxSteps?: number;
|
|
2301
|
+
/**
|
|
2302
|
+
* Upper bound on how deeply workflows may nest — a workflow entered while
|
|
2303
|
+
* this many are already in progress throws `reason: 'workflow-depth'`.
|
|
2304
|
+
* Bounds *legitimate* (acyclic) nesting; a genuine cycle is caught earlier and
|
|
2305
|
+
* separately by `reason: 'workflow-cycle'`. Defaults to 32.
|
|
2306
|
+
*
|
|
2307
|
+
* The count includes the workflow `execute` was called with, so `1` permits
|
|
2308
|
+
* that workflow and forbids all nesting; a value below 1 leaves no room for
|
|
2309
|
+
* even the top-level run.
|
|
2310
|
+
*/
|
|
2311
|
+
readonly maxWorkflowDepth?: number;
|
|
2312
|
+
/**
|
|
2313
|
+
* Delays for the given number of milliseconds — awaited between a step's retry
|
|
2314
|
+
* attempts (`retryAfter`). Injected so tests pass a no-op and real runs delay;
|
|
2315
|
+
* defaults to a real timer.
|
|
2316
|
+
*
|
|
2317
|
+
* The run's {@link WorkflowExecuteOptions.signal} is forwarded to it, so the
|
|
2318
|
+
* default timer stops waiting when the run is cancelled; an injected sleep
|
|
2319
|
+
* that ignores it merely postpones the cancellation until its wait ends.
|
|
2320
|
+
*/
|
|
2321
|
+
readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
2322
|
+
/**
|
|
2323
|
+
* Reads the current time in milliseconds, used for the `durationMs` of each
|
|
2324
|
+
* run and step. Injected so tests assert exact durations; defaults to
|
|
2325
|
+
* `performance.now`, which is monotonic — `Date.now` would yield a wrong or
|
|
2326
|
+
* negative duration if the system clock were adjusted mid-run.
|
|
2327
|
+
*/
|
|
2328
|
+
readonly now?: () => number;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
/**
|
|
2332
|
+
* Unique identifier of an Arazzo workflow.
|
|
2333
|
+
* @public
|
|
2334
|
+
*/
|
|
2335
|
+
export declare type WorkflowId = string;
|
|
2336
|
+
|
|
2337
|
+
/**
|
|
2338
|
+
* Resolves the `parameters` of a step targeting a `workflowId` into the
|
|
2339
|
+
* sub-workflow's inputs.
|
|
2340
|
+
*
|
|
2341
|
+
* Values follow the family-wide literal-vs-expression rule of
|
|
2342
|
+
* {@link ArazzoValueResolver}. Keys are bare parameter names: per the
|
|
2343
|
+
* specification, "when the step in context specifies a `workflowId`, then all
|
|
2344
|
+
* parameters map to workflow inputs" — which are keyed by name alone, even
|
|
2345
|
+
* for an inherited parameter that carries an `in`. Locations are not
|
|
2346
|
+
* consulted, so two parameters differing only in `in` collapse by name here,
|
|
2347
|
+
* which for inputs is the override mechanism, not a loss.
|
|
2348
|
+
*
|
|
2349
|
+
* The first parameter to claim a name wins: the list is ordered by
|
|
2350
|
+
* precedence, most specific first, as `ArazzoWorkflowNormalizer` leaves it
|
|
2351
|
+
* once a step's own parameters have been merged with the ones it inherits —
|
|
2352
|
+
* the override order the specification requires.
|
|
2353
|
+
* @public
|
|
2354
|
+
*/
|
|
2355
|
+
export declare class WorkflowParameterResolver extends StepParameterResolver {
|
|
2356
|
+
/**
|
|
2357
|
+
* Resolves each parameter's `value`, returning a `name` → value map.
|
|
2358
|
+
* Returns an empty object when there are no parameters.
|
|
2359
|
+
*
|
|
2360
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
2361
|
+
*/
|
|
2362
|
+
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* The referencing context a reference is resolved in: the workflow (and step,
|
|
2367
|
+
* when the reference sits on one) making the reference, stamped onto every
|
|
2368
|
+
* error.
|
|
2369
|
+
* @public
|
|
2370
|
+
*/
|
|
2371
|
+
export declare interface WorkflowReferenceContext {
|
|
2372
|
+
/**
|
|
2373
|
+
* The workflow the reference appears in.
|
|
2374
|
+
*/
|
|
2375
|
+
readonly workflowId: string;
|
|
2376
|
+
/**
|
|
2377
|
+
* The step the reference appears on, when it sits on one (a sub-workflow
|
|
2378
|
+
* step's `workflowId`, or a `retry` / `goto` action's reference).
|
|
2379
|
+
*/
|
|
2380
|
+
readonly stepId?: string;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
/**
|
|
2384
|
+
* Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
|
|
2385
|
+
*
|
|
2386
|
+
* The condition is an XPath 3.1 query applied to the resolved `context`, which
|
|
2387
|
+
* must be XML. A string context is parsed as XML; an already-parsed DOM node is
|
|
2388
|
+
* used as-is. The criterion is met by the query's Effective Boolean Value
|
|
2389
|
+
* (XPath 3.1 §19.1.2), as the Arazzo specification mandates — so a boolean
|
|
2390
|
+
* predicate (`//status = 'ok'`), a non-empty node set, a non-zero number, and a
|
|
2391
|
+
* non-empty string all evaluate to `true`.
|
|
2392
|
+
*
|
|
2393
|
+
* Only XPath 3.1 is supported (`fontoxpath`'s engine); version gating happens in
|
|
2394
|
+
* the facade. Per Arazzo 1.1.0, a `null` or `undefined` context fails the
|
|
2395
|
+
* condition. An invalid query throws {@link CriterionError}.
|
|
2396
|
+
* @public
|
|
2397
|
+
*/
|
|
2398
|
+
export declare class XPathCriterionEvaluator {
|
|
2399
|
+
#private;
|
|
2400
|
+
/**
|
|
2401
|
+
* Evaluates the XPath `condition` against the resolved context value, returning
|
|
2402
|
+
* its Effective Boolean Value.
|
|
2403
|
+
*
|
|
2404
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
2405
|
+
* {@link CriterionError} when the context is not XML or the query is invalid.
|
|
2406
|
+
*/
|
|
2407
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
export { }
|