@usearazzo/runner 1.0.1-alpha.35 → 1.0.1-alpha.36
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 +6 -0
- package/dist/arazzo-runner.browser.js +1525 -799
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +56 -48
- package/src/vendor/swagger-client.cjs +1 -1
- package/src/vendor/swagger-client.mjs +1 -1
- package/src/version.cjs +1 -1
- package/src/version.mjs +1 -1
- package/types/observability/logging/LoggingObserver.d.cts +82 -0
- package/types/observability/logging/index.d.cts +2 -0
- package/types/observability/opentelemetry/ArazzoRunnerInstrumentation.d.cts +84 -0
- package/types/observability/opentelemetry/index.d.cts +2 -0
- package/types/observability/stream/EventStream.d.cts +68 -0
- package/types/observability/stream/index.d.cts +2 -0
- package/types/runner.d.cts +3891 -0
- package/types/runner.d.ts +6 -6
|
@@ -0,0 +1,3891 @@
|
|
|
1
|
+
import type { ApiDOMErrorOptions } from '@speclynx/apidom-error';
|
|
2
|
+
import { ApiDOMReferenceOptions } from '@speclynx/apidom-reference/configuration/empty';
|
|
3
|
+
import { ApiDOMStructuredError } from '@speclynx/apidom-error';
|
|
4
|
+
import { CriterionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
5
|
+
import type { Element as Element_2 } from '@speclynx/apidom-datamodel';
|
|
6
|
+
import { FailureActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
7
|
+
import { FailureActionParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
8
|
+
import { JSONPointer } from '@speclynx/apidom-json-pointer';
|
|
9
|
+
import { OperationElement } from '@speclynx/apidom-ns-openapi-2';
|
|
10
|
+
import { OperationElement as OperationElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
|
|
11
|
+
import { OperationElement as OperationElement_3 } from '@speclynx/apidom-ns-openapi-3-1';
|
|
12
|
+
import { ParseResultElement } from '@usearazzo/parser';
|
|
13
|
+
import type { PartialOptions } from '@usearazzo/parser';
|
|
14
|
+
import { PathItemElement } from '@speclynx/apidom-ns-openapi-2';
|
|
15
|
+
import { PathItemElement as PathItemElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
|
|
16
|
+
import { PathItemElement as PathItemElement_3 } from '@speclynx/apidom-ns-openapi-3-1';
|
|
17
|
+
import { RequestBodyElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
18
|
+
import type { SourceDescriptionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
19
|
+
import { StepElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
20
|
+
import { StepOnFailureElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
21
|
+
import { StepOnSuccessElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
22
|
+
import type { StepOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
23
|
+
import { StepParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
24
|
+
import { SuccessActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
25
|
+
import { SuccessActionParametersElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
26
|
+
import { toYAML } from '@speclynx/apidom-core';
|
|
27
|
+
import { WorkflowElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
28
|
+
import type { WorkflowOutputsElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Selects the actions to take for a step outcome from its `onSuccess` /
|
|
32
|
+
* `onFailure` list.
|
|
33
|
+
*
|
|
34
|
+
* Actions are tried in order and every one whose `criteria` all pass is
|
|
35
|
+
* returned (an action with no criteria always matches). Action elements are
|
|
36
|
+
* returned as-is — interpreting them (branching on `type`, reading
|
|
37
|
+
* `stepId`/`workflowId`/`retryAfter`/`retryLimit`) is the caller's concern, and
|
|
38
|
+
* keeping them elements preserves the document provenance. The usual caller
|
|
39
|
+
* acts on the first and takes an empty result as "no action matched", applying
|
|
40
|
+
* the path default — the next sequential step on success, break-and-return on
|
|
41
|
+
* failure.
|
|
42
|
+
*
|
|
43
|
+
* A step's list is the only list there is: Reusable Object entries are already
|
|
44
|
+
* inlined by workflow normalization, and the workflow-level
|
|
45
|
+
* `successActions` / `failureActions` a step falls back to are inherited into
|
|
46
|
+
* `onSuccess` / `onFailure` by the same pass, so a well-formed document reaches
|
|
47
|
+
* this point as the step's own list of concrete action elements.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare class ActionResolver {
|
|
51
|
+
#private;
|
|
52
|
+
/**
|
|
53
|
+
* Returns every `onSuccess` action whose criteria are all met, in list order.
|
|
54
|
+
*
|
|
55
|
+
* The whole matching chain rather than only the first, because the caller
|
|
56
|
+
* needs both: it acts on `[0]`, and the one honoring "retryLimit exhausted
|
|
57
|
+
* prior to subsequent failure actions" walks the rest, falling from an
|
|
58
|
+
* exhausted `retry` to the next matching action without re-evaluating
|
|
59
|
+
* criteria. Empty when the list is absent or nothing matches.
|
|
60
|
+
*
|
|
61
|
+
* `scope` names the step this list belongs to, for a thrown
|
|
62
|
+
* {@link ResolverError}.
|
|
63
|
+
*
|
|
64
|
+
* A well-formed list whose entry is not a Success/Failure Action Object
|
|
65
|
+
* throws rather than being skipped: an unrecognized entry is indistinguishable
|
|
66
|
+
* from a step that deliberately declared no action for it, and the `goto` /
|
|
67
|
+
* `end` its author was reaching for would otherwise never happen without a
|
|
68
|
+
* word said about why.
|
|
69
|
+
*/
|
|
70
|
+
resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<SuccessActionElement[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns every `onFailure` action whose criteria are all met, in list order.
|
|
73
|
+
*
|
|
74
|
+
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
75
|
+
* see there for the full rationale — mirrored for the step's other list.
|
|
76
|
+
*/
|
|
77
|
+
resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<FailureActionElement[]>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The action an attempt resolved to: the `retry` that re-runs the step, or,
|
|
82
|
+
* for its last attempt, the step's terminal action. The attempt a `retry`
|
|
83
|
+
* reference makes at another step selects none.
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export declare interface ActionSelectedEvent extends WorkflowExecutionStepEventBase {
|
|
87
|
+
readonly type: 'action:selected';
|
|
88
|
+
/**
|
|
89
|
+
* Where the selected action is written; absent when no action was
|
|
90
|
+
* selected.
|
|
91
|
+
*/
|
|
92
|
+
readonly location?: DocumentLocation;
|
|
93
|
+
readonly attempt: number;
|
|
94
|
+
/**
|
|
95
|
+
* The selected action. Absent when none matched, so the step takes the
|
|
96
|
+
* default path: the next step on success, a break on failure. It is the
|
|
97
|
+
* document's own element, shared with the trace: read it, never change it.
|
|
98
|
+
*/
|
|
99
|
+
readonly action?: SelectedAction;
|
|
100
|
+
/**
|
|
101
|
+
* What the run does next because of it, as plain data: `retry` re-runs the
|
|
102
|
+
* step, and the rest are the step's terminal transition — `next`, `goto` a
|
|
103
|
+
* step, `transfer` to a workflow, `end`, or `break`. With no `action`, it is
|
|
104
|
+
* the default path: `next` on success, `break` on failure.
|
|
105
|
+
*/
|
|
106
|
+
readonly transition: StepTransition | {
|
|
107
|
+
readonly kind: 'retry';
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Base document held by the document registry.
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare abstract class APIDocument {
|
|
116
|
+
abstract readonly type: string;
|
|
117
|
+
readonly uri: string;
|
|
118
|
+
readonly parseResult: ParseResultElement;
|
|
119
|
+
protected constructor(uri: string, parseResult: ParseResultElement);
|
|
120
|
+
/**
|
|
121
|
+
* Where an element of this document, or one it references, is written, as
|
|
122
|
+
* the registry provider recorded it when it loaded the document: the
|
|
123
|
+
* document it came from (its `ref-origin`) when it came through a
|
|
124
|
+
* reference, and its JSON Pointer there.
|
|
125
|
+
*/
|
|
126
|
+
locationOf(element: Element_2): DocumentLocation;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a JSON-serializable representation of the document's API element.
|
|
129
|
+
* Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
|
|
130
|
+
*/
|
|
131
|
+
toJSON(): unknown;
|
|
132
|
+
/**
|
|
133
|
+
* Serializes the document's API element to a YAML string.
|
|
134
|
+
*/
|
|
135
|
+
toYAML(...args: Parameters<typeof toYAML> extends [unknown, ...infer R] ? R : []): string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* An Arazzo document held by the document registry: the parse result together
|
|
140
|
+
* with the indexes the provider built over it — a container, not a logic
|
|
141
|
+
* bearer. The methods below are thin reads of those indexes.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare class ArazzoDocument extends APIDocument {
|
|
145
|
+
readonly type: "arazzo";
|
|
146
|
+
isEntry: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* WorkflowId → JSON Pointer to the workflow within the parse result.
|
|
149
|
+
*/
|
|
150
|
+
readonly workflowIndex: ArazzoWorkflowIndex;
|
|
151
|
+
/**
|
|
152
|
+
* WorkflowId → stepId → JSON Pointer to the step within the parse result.
|
|
153
|
+
* Built by the provider, like {@link ArazzoDocument.workflowIndex}.
|
|
154
|
+
*/
|
|
155
|
+
readonly stepIndex: ArazzoStepIndex;
|
|
156
|
+
/**
|
|
157
|
+
* Name → source description element and canonical URI (already resolved
|
|
158
|
+
* against this document's base URI). Built by the provider, like
|
|
159
|
+
* {@link ArazzoDocument.workflowIndex}.
|
|
160
|
+
*/
|
|
161
|
+
readonly sourceDescriptionIndex: ArazzoSourceDescriptionIndex;
|
|
162
|
+
constructor(uri: string, parseResult: ParseResultElement, workflowIndex: ArazzoWorkflowIndex, stepIndex: ArazzoStepIndex, sourceDescriptionIndex: ArazzoSourceDescriptionIndex, isEntry?: boolean);
|
|
163
|
+
/**
|
|
164
|
+
* Type guard for ArazzoDocument.
|
|
165
|
+
*/
|
|
166
|
+
static is(doc: APIDocument): doc is ArazzoDocument;
|
|
167
|
+
/**
|
|
168
|
+
* The workflows of this document that can be addressed by `workflowId`, in
|
|
169
|
+
* document order. A duplicated `workflowId` is listed once, for its first
|
|
170
|
+
* workflow. Reads this document only: source descriptions are neither loaded
|
|
171
|
+
* nor listed.
|
|
172
|
+
*/
|
|
173
|
+
listWorkflows(): WorkflowDescriptor[];
|
|
174
|
+
/**
|
|
175
|
+
* Resolves a source description name to its canonical URI — precomputed by
|
|
176
|
+
* the provider, resolved against this document's base URI.
|
|
177
|
+
*/
|
|
178
|
+
resolveSourceDescriptionURI(sourceDescriptionName: string): string | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Resolves a field of a source description object (e.g. `url`, `type`).
|
|
181
|
+
*
|
|
182
|
+
* The `url` field resolves to the canonical URI (resolved against this
|
|
183
|
+
* document's base URI, as `resolveSourceDescriptionURI` does); every other
|
|
184
|
+
* field resolves to its literal value. Returns `undefined` when the source
|
|
185
|
+
* description or the field is absent.
|
|
186
|
+
*/
|
|
187
|
+
resolveSourceDescriptionField(sourceDescriptionName: string, field: string): unknown;
|
|
188
|
+
/**
|
|
189
|
+
* The canonical URIs of this document's source descriptions, resolved against
|
|
190
|
+
* this document's base URI, in declaration order. Sources without a resolvable
|
|
191
|
+
* url are omitted.
|
|
192
|
+
*/
|
|
193
|
+
sourceDescriptionURIs(): string[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Provides ArazzoDocument instances for the DocumentRegistry.
|
|
198
|
+
*
|
|
199
|
+
* Parses the Arazzo document and builds its workflow and source description
|
|
200
|
+
* indexes — the document itself is a container.
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
203
|
+
export declare class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
204
|
+
#private;
|
|
205
|
+
readonly sourceDescriptionType = "arazzo";
|
|
206
|
+
constructor(options?: ArazzoDocumentRegistryProviderOptions);
|
|
207
|
+
canProvide(uri: string): Promise<boolean>;
|
|
208
|
+
/**
|
|
209
|
+
* Loads an Arazzo document from a URI and produces an ArazzoDocument.
|
|
210
|
+
*/
|
|
211
|
+
provide(uri: string): Promise<ArazzoDocument>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Options for loading an Arazzo document.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
export declare type ArazzoDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Runs the workflows of one Arazzo document.
|
|
222
|
+
*
|
|
223
|
+
* A thin facade over the building blocks: it wires a {@link DocumentRegistry},
|
|
224
|
+
* an {@link OpenAPIOperationExecutor}, a {@link StepExecutor} and a
|
|
225
|
+
* {@link WorkflowExecutor} with their defaults, so running a workflow takes a
|
|
226
|
+
* `load` and an `execute`. The building blocks stay public for callers that
|
|
227
|
+
* need to compose them differently.
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare class ArazzoRunner {
|
|
231
|
+
#private;
|
|
232
|
+
readonly document: ArazzoDocument;
|
|
233
|
+
readonly registry: DocumentRegistry;
|
|
234
|
+
/**
|
|
235
|
+
* Loads the entry Arazzo document at `uri` (a file system path or URL) and
|
|
236
|
+
* returns a runner bound to it.
|
|
237
|
+
*
|
|
238
|
+
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
239
|
+
* @throws UnmatchedProviderError - When no provider can load the document
|
|
240
|
+
* @throws InvalidEntryDocumentError - When the document is not an Arazzo
|
|
241
|
+
* document, or the given registry already backs another entry document
|
|
242
|
+
*/
|
|
243
|
+
static load(uri: string, options?: ArazzoRunnerLoadOptions): Promise<ArazzoRunner>;
|
|
244
|
+
/**
|
|
245
|
+
* Binds a runner to an entry document the caller already acquired.
|
|
246
|
+
*
|
|
247
|
+
* @throws InvalidEntryDocumentError - When `document` is not the entry document of `registry`
|
|
248
|
+
*/
|
|
249
|
+
constructor(options: ArazzoRunnerOptions);
|
|
250
|
+
/**
|
|
251
|
+
* Runs the named workflow to completion, returning its outcome; see
|
|
252
|
+
* {@link WorkflowExecutor.execute}.
|
|
253
|
+
*/
|
|
254
|
+
execute(workflowId: WorkflowId, options?: WorkflowExecuteOptions): Promise<WorkflowExecutionResult>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** @public */
|
|
258
|
+
export declare class ArazzoRunnerError extends ApiDOMStructuredError {
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Every event the runner's building blocks emit, discriminated by `type`.
|
|
263
|
+
*
|
|
264
|
+
* Events carry no level or severity, like Node's `diagnostics_channel`
|
|
265
|
+
* messages: how to log an event is the logging consumer's decision. The
|
|
266
|
+
* `document:*`, `workflow:normalize:*` and `openapi:operation:*` events describe the
|
|
267
|
+
* machinery under a run, the detail a debug log would show.
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
export declare type ArazzoRunnerEvent = WorkflowExecutionEvent | DocumentRegistryEvent | OpenAPIOperationEvent;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The fields every {@link ArazzoRunnerEvent} carries.
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
export declare interface ArazzoRunnerEventBase {
|
|
277
|
+
/**
|
|
278
|
+
* When the event happened, read from the emitting block's injected `now`
|
|
279
|
+
* clock (`performance.now` by default). Timestamps of different blocks
|
|
280
|
+
* compare only when the blocks share a clock, as the ones
|
|
281
|
+
* {@link ArazzoRunner} wires do.
|
|
282
|
+
*/
|
|
283
|
+
readonly timestamp: number;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Options for {@link ArazzoRunner.load}.
|
|
288
|
+
*
|
|
289
|
+
* Every option is a seam of a building block the runner wires: `registry` is
|
|
290
|
+
* the {@link DocumentRegistry} the documents load into (a fresh one with the
|
|
291
|
+
* default providers when omitted), `reference` goes to everything the runner
|
|
292
|
+
* builds that retrieves documents, `httpClient`, `requestInterceptor` and
|
|
293
|
+
* `captureBodies` go to the {@link OpenAPIOperationExecutor}, and the rest go
|
|
294
|
+
* to the
|
|
295
|
+
* {@link WorkflowExecutor}.
|
|
296
|
+
*
|
|
297
|
+
* Retrieving documents and calling APIs are separate on purpose: `reference`
|
|
298
|
+
* never applies to API calls, and `httpClient` / `requestInterceptor` never
|
|
299
|
+
* apply to document retrieval, so credentials for one do not reach the other.
|
|
300
|
+
* @public
|
|
301
|
+
*/
|
|
302
|
+
export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor' | 'captureBodies'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
|
|
303
|
+
/**
|
|
304
|
+
* The registry to load the documents into. A registry backs one entry
|
|
305
|
+
* document: loading a different one into it throws.
|
|
306
|
+
*/
|
|
307
|
+
readonly registry?: DocumentRegistry;
|
|
308
|
+
/**
|
|
309
|
+
* Options of ApiDOM reference, which retrieves the documents: the entry
|
|
310
|
+
* document, its source descriptions and every externally referenced
|
|
311
|
+
* document. Its `resolve` options say how, e.g. `resolverOpts.axiosConfig`
|
|
312
|
+
* for request headers or a TLS agent, or `resolvers` for a resolver list of
|
|
313
|
+
* your own.
|
|
314
|
+
*
|
|
315
|
+
* The runner gives them to the default registry providers and to the
|
|
316
|
+
* normalizers, which fetch external references lazily. A `registry` passed
|
|
317
|
+
* alongside is already configured through its own providers, so `reference`
|
|
318
|
+
* then reaches the normalizers only: give that registry's providers the
|
|
319
|
+
* same options.
|
|
320
|
+
*/
|
|
321
|
+
readonly reference?: ArazzoRunnerReferenceOptions;
|
|
322
|
+
/**
|
|
323
|
+
* Parses the documents with source maps, so every `location` (on events,
|
|
324
|
+
* and on the result's steps and criteria) carries the element's range. Off by
|
|
325
|
+
* default: source-mapped parsing is slower and keeps more in memory. It
|
|
326
|
+
* changes no other behaviour: a document that fails to parse without it
|
|
327
|
+
* fails with it. A `registry` passed alongside parses as its own providers
|
|
328
|
+
* say.
|
|
329
|
+
*/
|
|
330
|
+
readonly sourceMap?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Receives the events of every building block the runner wires, stamped
|
|
333
|
+
* with `now`: the run's workflows, steps and the decisions behind them, and
|
|
334
|
+
* the machinery under them (document loads, workflow and operation
|
|
335
|
+
* normalization, request assembly). See {@link ArazzoRunnerEvent}.
|
|
336
|
+
*
|
|
337
|
+
* Loads into a `registry` passed alongside are reported only if that
|
|
338
|
+
* registry was given an observer of its own.
|
|
339
|
+
*/
|
|
340
|
+
readonly observer?: ArazzoRunnerObserver;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Receives events as they happen. Each building block takes one as its
|
|
345
|
+
* `observer` option, typed to the events it emits; an observer of every
|
|
346
|
+
* {@link ArazzoRunnerEvent} fits them all.
|
|
347
|
+
*
|
|
348
|
+
* It is called synchronously and never awaited, so it cannot slow down or
|
|
349
|
+
* reorder a run. A handler that throws aborts the run with that error. A
|
|
350
|
+
* returned promise is ignored, rejection included: an async observer handles
|
|
351
|
+
* its own errors.
|
|
352
|
+
*
|
|
353
|
+
* Each event is a frozen copy of its plain data, so changing it cannot reach
|
|
354
|
+
* the run. Anything else is shared and must be treated as read-only: the
|
|
355
|
+
* ApiDOM element in {@link ActionSelectedEvent.action}, or a `Map` or class
|
|
356
|
+
* instance a custom HTTP client put into a response body.
|
|
357
|
+
*
|
|
358
|
+
* Events carry what the run saw, credentials included, like the request a
|
|
359
|
+
* request interceptor receives. Pass them through {@link Redactor.event}
|
|
360
|
+
* before they leave the process.
|
|
361
|
+
*
|
|
362
|
+
* A building block without an observer builds no events.
|
|
363
|
+
* @public
|
|
364
|
+
*/
|
|
365
|
+
export declare type ArazzoRunnerObserver<E extends ArazzoRunnerEvent = ArazzoRunnerEvent> = (event: E) => void;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Options for the ArazzoRunner constructor.
|
|
369
|
+
* @public
|
|
370
|
+
*/
|
|
371
|
+
export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry' | 'sourceMap'> {
|
|
372
|
+
/**
|
|
373
|
+
* The entry Arazzo document holding the workflows to run.
|
|
374
|
+
*/
|
|
375
|
+
readonly document: ArazzoDocument;
|
|
376
|
+
/**
|
|
377
|
+
* The document registry whose entry document is `document`.
|
|
378
|
+
*/
|
|
379
|
+
readonly registry: DocumentRegistry;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* The options of ApiDOM reference the runner accepts: its `resolve` options,
|
|
384
|
+
* which mean the same for every building block that retrieves documents.
|
|
385
|
+
* `parse` and `dereference` options differ per building block, so the runner
|
|
386
|
+
* passes none of them on; set those on the building blocks themselves.
|
|
387
|
+
* @public
|
|
388
|
+
*/
|
|
389
|
+
export declare type ArazzoRunnerReferenceOptions = Pick<DocumentRegistryProviderOptions, 'resolve'>;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Index mapping a source description name to its element and canonical URI in
|
|
393
|
+
* an Arazzo document.
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
export declare class ArazzoSourceDescriptionIndex extends Map<SourceDescriptionName, SourceDescriptionEntry> {
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Extracts a step from an Arazzo workflow by stepId.
|
|
401
|
+
*
|
|
402
|
+
* Searches the workflow's steps array for the matching stepId.
|
|
403
|
+
* The workflow should be already extracted via ArazzoWorkflowExtractor.
|
|
404
|
+
* @public
|
|
405
|
+
*/
|
|
406
|
+
export declare class ArazzoStepExtractor {
|
|
407
|
+
/**
|
|
408
|
+
* Extracts a step element by stepId from a workflow.
|
|
409
|
+
*/
|
|
410
|
+
extract(workflow: WorkflowElement, stepId: string): StepElement;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Index mapping workflowId → stepId → JSON Pointer to the step in an Arazzo
|
|
415
|
+
* document. Steps are unique only within their workflow, hence the nesting.
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
export declare class ArazzoStepIndex extends Map<WorkflowId, Map<StepId, JSONPointer>> {
|
|
419
|
+
/**
|
|
420
|
+
* The JSON Pointer of a step, or `undefined` when the workflow or step is absent.
|
|
421
|
+
*/
|
|
422
|
+
getStep(workflowId: WorkflowId, stepId: StepId): JSONPointer | undefined;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Normalizes an extracted Arazzo step.
|
|
427
|
+
*
|
|
428
|
+
* Currently acts as an identity function. Steps are already dereferenced as part
|
|
429
|
+
* of workflow normalization, which also inherits the workflow's `parameters`
|
|
430
|
+
* into them — a step reaching here has no inherited properties left to merge.
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
export declare class ArazzoStepNormalizer {
|
|
434
|
+
/**
|
|
435
|
+
* Normalizes a step element against its parent document.
|
|
436
|
+
*/
|
|
437
|
+
normalize(step: StepElement, _document: ArazzoDocument): Promise<StepElement>;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Base of every resolver of authored Arazzo values — the single home of the
|
|
442
|
+
* literal-vs-expression rule they all share.
|
|
443
|
+
*
|
|
444
|
+
* Per Arazzo 1.0.1, an authored value (a parameter's `value`, an `outputs`
|
|
445
|
+
* entry, a `requestBody` replacement value) is either a literal or a whole
|
|
446
|
+
* runtime expression — there is no embedded/interpolated expression. So a
|
|
447
|
+
* value that is a string is resolved as an expression only when the entire
|
|
448
|
+
* string is a valid runtime expression; every other value (a non-expression
|
|
449
|
+
* string such as `"{$inputs.x}"`, a number, boolean, object, array, or null)
|
|
450
|
+
* is a literal and is used as-is. This is deliberately not template
|
|
451
|
+
* interpolation. The one exception is a `requestBody` payload, which "can
|
|
452
|
+
* contain" runtime expressions — {@link RequestBodyResolver} walks it instead.
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
export declare abstract class ArazzoValueResolver {
|
|
456
|
+
/**
|
|
457
|
+
* Resolves one authored value element by the rule above.
|
|
458
|
+
*/
|
|
459
|
+
protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): Promise<unknown>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Extracts a workflow from an Arazzo document by workflowId.
|
|
464
|
+
*
|
|
465
|
+
* The workflow is already fully dereferenced in the document,
|
|
466
|
+
* so no additional processing is needed.
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
export declare class ArazzoWorkflowExtractor {
|
|
470
|
+
/**
|
|
471
|
+
* Extracts a workflow element by workflowId.
|
|
472
|
+
*/
|
|
473
|
+
extract(document: ArazzoDocument, workflowId: WorkflowId): WorkflowElement;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Index mapping workflowId to its JSON Pointer in an Arazzo document.
|
|
478
|
+
* @public
|
|
479
|
+
*/
|
|
480
|
+
export declare class ArazzoWorkflowIndex extends Map<WorkflowId, JSONPointer> {
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* A canonical Arazzo workflow locator: the Arazzo document that owns the
|
|
485
|
+
* workflow and the workflow's id within it.
|
|
486
|
+
*
|
|
487
|
+
* A workflow reference names its target in one of two ways — a plain
|
|
488
|
+
* `workflowId` of the current document, or a
|
|
489
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
490
|
+
* workflow of another Arazzo document. Both are locators for the same thing;
|
|
491
|
+
* the normalizer reduces either to this single canonical form. `workflowId`
|
|
492
|
+
* is the bare id either way — the key run state (`$workflows.{id}`) is
|
|
493
|
+
* recorded under, which the runtime-expression grammar can only express
|
|
494
|
+
* unqualified.
|
|
495
|
+
* @public
|
|
496
|
+
*/
|
|
497
|
+
export declare interface ArazzoWorkflowLocator {
|
|
498
|
+
readonly document: ArazzoDocument;
|
|
499
|
+
readonly workflowId: string;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Normalizes a workflow reference to a canonical {@link ArazzoWorkflowLocator}
|
|
504
|
+
* — the Arazzo document and the workflow's id within it.
|
|
505
|
+
*
|
|
506
|
+
* A reference appears in four author-facing positions — a sub-workflow step's
|
|
507
|
+
* `workflowId`, a `dependsOn` entry, a `retry` action's `workflowId`
|
|
508
|
+
* reference, and a `goto` action's transfer target — and is either a plain id
|
|
509
|
+
* of the referencing document or a whole
|
|
510
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
511
|
+
* workflow of another Arazzo document. Only that dotted expression form is a
|
|
512
|
+
* workflow reference; the resolver package's
|
|
513
|
+
* `$sourceDescriptions.{name}#/json/pointer` form is a `$ref`-time construct,
|
|
514
|
+
* not a runtime expression, and does not parse here.
|
|
515
|
+
*
|
|
516
|
+
* The `type` declared on a source description is not trusted (it may be
|
|
517
|
+
* absent or wrong); a source is classified by what it actually parses to,
|
|
518
|
+
* the same convention the OpenAPI operation locator follows. Source
|
|
519
|
+
* documents are acquired from the registry on demand. A reference to a
|
|
520
|
+
* workflow the resolved document does not define is rejected here, so every
|
|
521
|
+
* returned locator names an existing workflow; a caller controls when that
|
|
522
|
+
* check happens by when it normalizes (eagerly for a `dependsOn` list
|
|
523
|
+
* validated before any prerequisite runs, lazily for a sub-workflow step
|
|
524
|
+
* resolved on its first attempt).
|
|
525
|
+
* @public
|
|
526
|
+
*/
|
|
527
|
+
export declare class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
|
|
528
|
+
#private;
|
|
529
|
+
/**
|
|
530
|
+
* Resolves a reference — a plain workflowId or a
|
|
531
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
|
|
532
|
+
* canonical locator: the Arazzo document that owns the target workflow,
|
|
533
|
+
* and the bare id within it. Rejects a workflow that document does not
|
|
534
|
+
* define as `workflow-not-found`, attributed to the referencing context
|
|
535
|
+
* like every other error raised here.
|
|
536
|
+
*/
|
|
537
|
+
normalize(reference: string, document: ArazzoDocument, context: WorkflowReferenceContext): Promise<ArazzoWorkflowLocator>;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Normalizes an extracted Arazzo workflow.
|
|
542
|
+
*
|
|
543
|
+
* Dereferences the workflow subtree ($components.* references),
|
|
544
|
+
* producing a self-contained workflow element, then inherits the workflow's
|
|
545
|
+
* "applicable for all steps" defaults — its `parameters`, and its
|
|
546
|
+
* `successActions` / `failureActions` — into each of its steps.
|
|
547
|
+
*
|
|
548
|
+
* All passes mutate, and what they mutate is the document itself: the extractor
|
|
549
|
+
* hands over the live workflow node out of `document.parseResult`, and
|
|
550
|
+
* dereferencing runs `immutable: false`, returning that same instance. Writing
|
|
551
|
+
* through to the document is what lets the registry act as a natural cache —
|
|
552
|
+
* a workflow reached a second time is already dereferenced and already
|
|
553
|
+
* inherited into, so no pass repeats. The inheritance is idempotent for
|
|
554
|
+
* exactly that reason.
|
|
555
|
+
*
|
|
556
|
+
* The writes differ in kind, which is worth knowing before sharing a
|
|
557
|
+
* registry. Dereferencing only *resolves* what the document already says — a
|
|
558
|
+
* `$ref` replaced by its target means the same thing. Inheritance *synthesizes*:
|
|
559
|
+
* afterwards a step carries `parameters` or an `onSuccess` its source never
|
|
560
|
+
* declared, so a consumer that reads the document back (`APIDocument.toJSON()`)
|
|
561
|
+
* sees one that no longer matches the file it was parsed from. The OpenAPI
|
|
562
|
+
* normalizers write inherited servers, parameters and security requirements into
|
|
563
|
+
* their documents the same way, so this is the layer's established contract
|
|
564
|
+
* rather than a property of Arazzo.
|
|
565
|
+
* @public
|
|
566
|
+
*/
|
|
567
|
+
export declare class ArazzoWorkflowNormalizer {
|
|
568
|
+
#private;
|
|
569
|
+
constructor(options?: ArazzoWorkflowNormalizerOptions);
|
|
570
|
+
/**
|
|
571
|
+
* Dereferences the workflow subtree against its parent document, then inherits
|
|
572
|
+
* the workflow's `parameters` and default actions into its steps.
|
|
573
|
+
*/
|
|
574
|
+
normalize(workflow: WorkflowElement, document: ArazzoDocument): Promise<WorkflowElement>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Options for normalizing an Arazzo workflow.
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
581
|
+
export declare type ArazzoWorkflowNormalizerOptions = PartialOptions<ApiDOMReferenceOptions>;
|
|
582
|
+
|
|
583
|
+
/** @public */
|
|
584
|
+
export declare class AssemblerError extends ArazzoRunnerError {
|
|
585
|
+
readonly operationId?: string;
|
|
586
|
+
readonly uri?: string;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** @public */
|
|
590
|
+
export declare class ClientError extends ArazzoRunnerError {
|
|
591
|
+
readonly operationId?: string;
|
|
592
|
+
readonly operationPath?: string;
|
|
593
|
+
readonly uri?: string;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* One observer that hands each event to every observer given, in order, so
|
|
598
|
+
* several consumers (a log, a trace, a stream) can watch the same run.
|
|
599
|
+
*
|
|
600
|
+
* Delivery stays synchronous. An observer that throws aborts the run with its
|
|
601
|
+
* error, as any observer does, and the observers after it miss that event.
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
export declare const combineObservers: <E extends ArazzoRunnerEvent = ArazzoRunnerEvent>(...observers: readonly ArazzoRunnerObserver<E>[]) => ArazzoRunnerObserver<E>;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* A read-only source of the runtime expression context for a step.
|
|
608
|
+
*
|
|
609
|
+
* The step executor only reads accumulated run state — it produces the
|
|
610
|
+
* pre-request context (`toContext()`) and the post-request context
|
|
611
|
+
* (`toContext(request, response)`) — and never mutates it, so it depends on
|
|
612
|
+
* this narrow interface rather than the full execution state.
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
export declare interface ContextSource {
|
|
616
|
+
toContext(request?: RuntimeExpressionContext['request'], response?: RuntimeExpressionResponseContext): RuntimeExpressionContext;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Resolves a runtime expression to a value, or to a Promise of it, during
|
|
621
|
+
* criterion evaluation. The result is awaited, so a synchronous resolver works
|
|
622
|
+
* too.
|
|
623
|
+
*
|
|
624
|
+
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
625
|
+
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
626
|
+
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
627
|
+
* than throwing (a common way to drive it is
|
|
628
|
+
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
629
|
+
* lenient evaluator). An error it throws or rejects with — such as the load
|
|
630
|
+
* error of a `$sourceDescriptions` document that cannot be loaded — is not a
|
|
631
|
+
* {@link CriterionEvaluationError}, so it propagates instead of failing the
|
|
632
|
+
* criterion.
|
|
633
|
+
* @public
|
|
634
|
+
*/
|
|
635
|
+
export declare type CriterionContextResolver = (expression: string) => unknown;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Carries a `reason`, one of the class's static reason fields.
|
|
639
|
+
*
|
|
640
|
+
* Every static on this class is a reason: {@link CriterionErrorReason} is
|
|
641
|
+
* derived from the class's own statics, so a non-reason static would join the
|
|
642
|
+
* union.
|
|
643
|
+
* @public
|
|
644
|
+
*/
|
|
645
|
+
export declare class CriterionError extends ArazzoRunnerError {
|
|
646
|
+
/** The element is not a Criterion Object. */
|
|
647
|
+
static readonly InvalidCriterion: "invalid-criterion";
|
|
648
|
+
/** The `condition` is missing or empty. */
|
|
649
|
+
static readonly MissingCondition: "missing-condition";
|
|
650
|
+
/** The `type` is present but unreadable. */
|
|
651
|
+
static readonly InvalidType: "invalid-type";
|
|
652
|
+
/** The `type` names no known criterion type. */
|
|
653
|
+
static readonly UnknownType: "unknown-type";
|
|
654
|
+
/** The expression type `version` is present but not a string. */
|
|
655
|
+
static readonly InvalidVersion: "invalid-version";
|
|
656
|
+
/** The expression type `version` is not the one this runner supports. */
|
|
657
|
+
static readonly UnsupportedVersion: "unsupported-version";
|
|
658
|
+
/** The `context` is not a runtime expression. */
|
|
659
|
+
static readonly InvalidContext: "invalid-context";
|
|
660
|
+
/** A `regex`, `jsonpath` or `xpath` criterion has no `context`. */
|
|
661
|
+
static readonly MissingContext: "missing-context";
|
|
662
|
+
/** The `simple` condition cannot be parsed. */
|
|
663
|
+
static readonly InvalidSimple: "invalid-simple";
|
|
664
|
+
/** The `regex` condition is not a valid regular expression. */
|
|
665
|
+
static readonly InvalidRegex: "invalid-regex";
|
|
666
|
+
/** The `jsonpath` condition is not a valid JSONPath query. */
|
|
667
|
+
static readonly InvalidJSONPath: "invalid-jsonpath";
|
|
668
|
+
/** The `xpath` condition is invalid or fails to evaluate. */
|
|
669
|
+
static readonly InvalidXPath: "invalid-xpath";
|
|
670
|
+
/** The resolved `xpath` context is not XML. */
|
|
671
|
+
static readonly InvalidXPathContext: "invalid-xpath-context";
|
|
672
|
+
readonly condition?: string;
|
|
673
|
+
readonly type?: string;
|
|
674
|
+
readonly reason?: CriterionErrorReason;
|
|
675
|
+
constructor(message?: string, options?: ApiDOMErrorOptions & {
|
|
676
|
+
readonly reason?: CriterionErrorReason;
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* One of the reasons a {@link CriterionError} carries: a `CriterionError`
|
|
682
|
+
* static such as `CriterionError.InvalidRegex`.
|
|
683
|
+
*
|
|
684
|
+
* Structural reasons mark a criterion that is malformed as written; they are
|
|
685
|
+
* thrown as a plain `CriterionError`. Evaluation reasons (`InvalidSimple`,
|
|
686
|
+
* `InvalidRegex`, `InvalidJSONPath`, `InvalidXPath`, `InvalidXPathContext`) mark
|
|
687
|
+
* a condition that cannot be evaluated; they are thrown as a
|
|
688
|
+
* {@link CriterionEvaluationError}, which `CriterionEvaluator` turns into an
|
|
689
|
+
* unmet criterion.
|
|
690
|
+
* @public
|
|
691
|
+
*/
|
|
692
|
+
export declare type CriterionErrorReason = (typeof CriterionError)[Exclude<keyof typeof CriterionError, keyof typeof ArazzoRunnerError | 'prototype'>];
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* One criterion was evaluated during an attempt. Fired after the attempt's
|
|
696
|
+
* request (or sub-workflow run), in list order, success criteria first.
|
|
697
|
+
* @public
|
|
698
|
+
*/
|
|
699
|
+
export declare interface CriterionEvaluatedEvent extends WorkflowExecutionStepEventBase {
|
|
700
|
+
readonly type: 'criterion:evaluated';
|
|
701
|
+
/**
|
|
702
|
+
* Where the criterion is written.
|
|
703
|
+
*/
|
|
704
|
+
readonly location: DocumentLocation;
|
|
705
|
+
readonly attempt: number;
|
|
706
|
+
/**
|
|
707
|
+
* `success` for one of the step's `successCriteria`, `action` for a
|
|
708
|
+
* criterion of an `onSuccess` / `onFailure` action the attempt considered.
|
|
709
|
+
*/
|
|
710
|
+
readonly kind: 'success' | 'action';
|
|
711
|
+
readonly criterion: CriterionEvaluationRecord;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* A criterion condition that cannot be evaluated: a syntax error in the
|
|
716
|
+
* condition, a context the condition cannot apply to, or an error raised while
|
|
717
|
+
* evaluating it. The type-specific criterion evaluators throw it;
|
|
718
|
+
* `CriterionEvaluator` turns it into an unmet criterion, as Arazzo 1.1.0
|
|
719
|
+
* requires.
|
|
720
|
+
* @public
|
|
721
|
+
*/
|
|
722
|
+
export declare class CriterionEvaluationError extends CriterionError {
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* The outcome of one criterion a step evaluated: one of its `successCriteria`,
|
|
727
|
+
* or one of the `criteria` of an action it considered.
|
|
728
|
+
* @public
|
|
729
|
+
*/
|
|
730
|
+
export declare interface CriterionEvaluationRecord {
|
|
731
|
+
/**
|
|
732
|
+
* The criterion's `condition`, as written.
|
|
733
|
+
*/
|
|
734
|
+
readonly condition: string;
|
|
735
|
+
/**
|
|
736
|
+
* Whether the condition is met.
|
|
737
|
+
*/
|
|
738
|
+
readonly met: boolean;
|
|
739
|
+
/**
|
|
740
|
+
* The `name` of the action declaring the criterion — present only on an
|
|
741
|
+
* action criterion.
|
|
742
|
+
*/
|
|
743
|
+
readonly actionName?: string;
|
|
744
|
+
/**
|
|
745
|
+
* Every runtime expression the evaluation resolved, keyed by the expression
|
|
746
|
+
* as written, with the value it resolved to: the expressions embedded in a
|
|
747
|
+
* `simple` condition, or the `context` of a `regex`, `jsonpath` or `xpath`
|
|
748
|
+
* one. What the criterion actually saw, e.g. `{ "$statusCode": 404 }`.
|
|
749
|
+
*
|
|
750
|
+
* A whole body (`$response.body`, `$request.body`) is recorded as the
|
|
751
|
+
* placeholder `[body]`, so the trace never holds a body; the body and its
|
|
752
|
+
* size are in the attempt's `openapi:operation:request:settled` event.
|
|
753
|
+
*/
|
|
754
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
755
|
+
/**
|
|
756
|
+
* Where the criterion is written.
|
|
757
|
+
*/
|
|
758
|
+
readonly location: DocumentLocation;
|
|
759
|
+
/**
|
|
760
|
+
* Why the condition could not be evaluated — present only then, with `met`
|
|
761
|
+
* `false`.
|
|
762
|
+
*/
|
|
763
|
+
readonly diagnostic?: {
|
|
764
|
+
/**
|
|
765
|
+
* Machine-readable: the `reason` of the error that failed the criterion, a
|
|
766
|
+
* `CriterionErrorReason` or `RuntimeExpressionError.UnavailableExpression`
|
|
767
|
+
* for an HTTP-exchange expression in a step that calls a workflow.
|
|
768
|
+
*/
|
|
769
|
+
readonly code?: CriterionErrorReason | typeof RuntimeExpressionError.UnavailableExpression;
|
|
770
|
+
/**
|
|
771
|
+
* Human-readable: names the condition or expression and, for a syntax
|
|
772
|
+
* error, what is wrong with it; never request or response data.
|
|
773
|
+
*/
|
|
774
|
+
readonly message: string;
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Evaluates an Arazzo Criterion Object to a {@link CriterionOutcome}.
|
|
780
|
+
*
|
|
781
|
+
* Dispatches on the criterion's `type` (defaulting to `simple` when omitted):
|
|
782
|
+
* - `simple` — evaluates the condition directly, resolving the runtime
|
|
783
|
+
* expressions embedded in it.
|
|
784
|
+
* - `regex` — resolves the `context` runtime expression, then applies the
|
|
785
|
+
* pattern to the resolved value.
|
|
786
|
+
* - `jsonpath` — resolves the `context` runtime expression, then applies the
|
|
787
|
+
* JSONPath query to the resolved value (met when the query matches). Only the
|
|
788
|
+
* `rfc9535` version is supported; an explicit other version throws.
|
|
789
|
+
* - `xpath` — resolves the `context` runtime expression, then applies the XPath
|
|
790
|
+
* 3.1 query to the resolved XML value (met by the Effective Boolean Value).
|
|
791
|
+
* Only the `xpath-31` version is supported; an explicit other version throws.
|
|
792
|
+
*
|
|
793
|
+
* Versions follow Arazzo 1.1.0's Expression Type Object: `rfc9535` and
|
|
794
|
+
* `xpath-31` are allowed values, and an omitted `version` defaults to them.
|
|
795
|
+
* Arazzo 1.0.x lists neither and requires `version`; this evaluator applies
|
|
796
|
+
* the 1.1.0 rule to every document, which accepts more but never evaluates a
|
|
797
|
+
* query under the wrong dialect.
|
|
798
|
+
*
|
|
799
|
+
* A condition that cannot be evaluated fails the criterion (`met: false`), as
|
|
800
|
+
* Arazzo 1.1.0 requires: a syntax error in the condition, a context the
|
|
801
|
+
* condition cannot apply to (non-XML data for `xpath`), or an XPath evaluation
|
|
802
|
+
* error. The type-specific evaluators report these as a
|
|
803
|
+
* {@link CriterionEvaluationError}, which this facade returns as the
|
|
804
|
+
* outcome's `error` so the caller can report it; any other error they raise
|
|
805
|
+
* propagates. A criterion that is malformed as written still throws: a
|
|
806
|
+
* missing `condition`, an unknown or unreadable `type`, an unsupported
|
|
807
|
+
* expression `version`, or a `context` that is missing or not a runtime
|
|
808
|
+
* expression.
|
|
809
|
+
*
|
|
810
|
+
* The evaluator is agnostic about how runtime expressions are resolved: the
|
|
811
|
+
* caller supplies a {@link CriterionContextResolver} per evaluation, keeping
|
|
812
|
+
* runtime-state, document, and registry concerns in the runtime expression
|
|
813
|
+
* evaluator rather than duplicated here.
|
|
814
|
+
* @public
|
|
815
|
+
*/
|
|
816
|
+
export declare class CriterionEvaluator {
|
|
817
|
+
#private;
|
|
818
|
+
constructor(options?: CriterionEvaluatorOptions);
|
|
819
|
+
/**
|
|
820
|
+
* Evaluates a criterion element, returning whether the condition is met and,
|
|
821
|
+
* when it cannot be evaluated, why.
|
|
822
|
+
*
|
|
823
|
+
* `resolve` turns a runtime expression into a value: for `simple` it resolves
|
|
824
|
+
* the expressions embedded in the condition; for the other types it resolves
|
|
825
|
+
* the criterion's `context` expression that the condition is applied to.
|
|
826
|
+
*/
|
|
827
|
+
evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): Promise<CriterionOutcome>;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Options for the CriterionEvaluator.
|
|
832
|
+
*
|
|
833
|
+
* An injected evaluator signals a condition it cannot evaluate by throwing a
|
|
834
|
+
* {@link CriterionEvaluationError}, which fails the criterion; any other error
|
|
835
|
+
* it throws, a plain {@link CriterionError} included, propagates.
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
export declare interface CriterionEvaluatorOptions {
|
|
839
|
+
/**
|
|
840
|
+
* Simple condition evaluator. Injectable for testing.
|
|
841
|
+
*/
|
|
842
|
+
readonly simple?: SimpleCriterionEvaluator;
|
|
843
|
+
/**
|
|
844
|
+
* Regex condition evaluator. Injectable for testing.
|
|
845
|
+
*/
|
|
846
|
+
readonly regex?: RegexCriterionEvaluator;
|
|
847
|
+
/**
|
|
848
|
+
* JSONPath condition evaluator. Injectable for testing.
|
|
849
|
+
*/
|
|
850
|
+
readonly jsonpath?: JSONPathCriterionEvaluator;
|
|
851
|
+
/**
|
|
852
|
+
* XPath condition evaluator. Injectable for testing.
|
|
853
|
+
*/
|
|
854
|
+
readonly xpath?: XPathCriterionEvaluator;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* The outcome of evaluating one criterion.
|
|
859
|
+
* @public
|
|
860
|
+
*/
|
|
861
|
+
export declare interface CriterionOutcome {
|
|
862
|
+
/**
|
|
863
|
+
* Whether the condition is met. `false` when it evaluates to false or cannot
|
|
864
|
+
* be evaluated; only in the latter case is {@link CriterionOutcome.error}
|
|
865
|
+
* present, saying why.
|
|
866
|
+
*/
|
|
867
|
+
readonly met: boolean;
|
|
868
|
+
/**
|
|
869
|
+
* Why the condition could not be evaluated: present only when it was not.
|
|
870
|
+
*/
|
|
871
|
+
readonly error?: CriterionEvaluationError;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Determines whether a single criterion of an action is met, or resolves to
|
|
876
|
+
* whether it is. Receives the action declaring the criterion, so a caller can
|
|
877
|
+
* attribute the outcome to it.
|
|
878
|
+
*
|
|
879
|
+
* Bridged to a criterion evaluator
|
|
880
|
+
* (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
|
|
881
|
+
* an unresolvable/failing criterion is `false`, not an error.
|
|
882
|
+
* @public
|
|
883
|
+
*/
|
|
884
|
+
export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean | Promise<boolean>;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* A `dependsOn` prerequisite was satisfied, or failed.
|
|
888
|
+
* @public
|
|
889
|
+
*/
|
|
890
|
+
export declare interface DependencySettledEvent extends WorkflowExecutionEventBase {
|
|
891
|
+
readonly type: 'dependency:settled';
|
|
892
|
+
readonly dependency: WorkflowExecutionDependency;
|
|
893
|
+
/**
|
|
894
|
+
* Whether the prerequisite had already completed earlier in this run and was
|
|
895
|
+
* not run again. When it is `true`, no workflow events of its own precede
|
|
896
|
+
* this event.
|
|
897
|
+
*/
|
|
898
|
+
readonly memoized: boolean;
|
|
899
|
+
readonly settledStatus: WorkflowExecutionResult['settledStatus'];
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* A `dependsOn` prerequisite is about to be satisfied: either run, or found
|
|
904
|
+
* already completed earlier in the same run.
|
|
905
|
+
* @public
|
|
906
|
+
*/
|
|
907
|
+
export declare interface DependencyStartEvent extends WorkflowExecutionEventBase {
|
|
908
|
+
readonly type: 'dependency:start';
|
|
909
|
+
/**
|
|
910
|
+
* Where the `dependsOn` entry is written.
|
|
911
|
+
*/
|
|
912
|
+
readonly location: DocumentLocation;
|
|
913
|
+
readonly dependency: WorkflowExecutionDependency;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** @public */
|
|
917
|
+
export declare class DocumentLoadError extends ArazzoRunnerError {
|
|
918
|
+
readonly uri?: string;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* The registry loaded a document, which it caches right after. A load that
|
|
923
|
+
* fails throws and emits no settled event; an observer that throws here
|
|
924
|
+
* leaves the document uncached.
|
|
925
|
+
* @public
|
|
926
|
+
*/
|
|
927
|
+
export declare interface DocumentLoadSettledEvent extends ArazzoRunnerEventBase {
|
|
928
|
+
readonly type: 'document:load:settled';
|
|
929
|
+
readonly uri: string;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* The registry started loading a document it had neither cached nor already
|
|
934
|
+
* loading. Cache hits emit nothing.
|
|
935
|
+
*
|
|
936
|
+
* Registry events carry no `runId`: the registry is shared, and one load can
|
|
937
|
+
* serve several runs at once.
|
|
938
|
+
* @public
|
|
939
|
+
*/
|
|
940
|
+
export declare interface DocumentLoadStartEvent extends ArazzoRunnerEventBase {
|
|
941
|
+
readonly type: 'document:load:start';
|
|
942
|
+
/**
|
|
943
|
+
* The canonical URI of the document.
|
|
944
|
+
*/
|
|
945
|
+
readonly uri: string;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Where an element is written.
|
|
950
|
+
* @public
|
|
951
|
+
*/
|
|
952
|
+
export declare interface DocumentLocation {
|
|
953
|
+
/**
|
|
954
|
+
* The document that defines the element: the one it came from when it was
|
|
955
|
+
* reached through a reference (a workflow of another Arazzo document, an
|
|
956
|
+
* operation of a Path Item Object written as a `$ref`), not necessarily the
|
|
957
|
+
* entry document.
|
|
958
|
+
*/
|
|
959
|
+
readonly uri: string;
|
|
960
|
+
/**
|
|
961
|
+
* The element's JSON Pointer in that document. Absent only for an element
|
|
962
|
+
* whose pointer no one recorded: the runner records one for every element
|
|
963
|
+
* an event locates.
|
|
964
|
+
*/
|
|
965
|
+
readonly jsonPointer?: string;
|
|
966
|
+
/**
|
|
967
|
+
* The element's range in that document, present only when the document was
|
|
968
|
+
* parsed with source maps (`sourceMap` on `ArazzoRunner.load`).
|
|
969
|
+
*/
|
|
970
|
+
readonly range?: DocumentRange;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* A position in a document, as in the Language Server Protocol: a 0-based
|
|
975
|
+
* line, and a 0-based character offset within it in UTF-16 code units.
|
|
976
|
+
* @public
|
|
977
|
+
*/
|
|
978
|
+
export declare interface DocumentPosition {
|
|
979
|
+
readonly line: number;
|
|
980
|
+
readonly character: number;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* A range in a document, as in the Language Server Protocol: from `start` to
|
|
985
|
+
* `end`, the shape the validator's diagnostics use.
|
|
986
|
+
* @public
|
|
987
|
+
*/
|
|
988
|
+
export declare interface DocumentRange {
|
|
989
|
+
readonly start: DocumentPosition;
|
|
990
|
+
readonly end: DocumentPosition;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Registry for API documents keyed by canonical URI.
|
|
995
|
+
*
|
|
996
|
+
* Acts as an LRU cache for parsed documents. The entry Arazzo document
|
|
997
|
+
* is pinned and never evicted. Providers are tried in order to detect
|
|
998
|
+
* and load documents.
|
|
999
|
+
* @public
|
|
1000
|
+
*/
|
|
1001
|
+
export declare class DocumentRegistry {
|
|
1002
|
+
#private;
|
|
1003
|
+
constructor(options?: DocumentRegistryOptions);
|
|
1004
|
+
/**
|
|
1005
|
+
* Returns the entry Arazzo document, or undefined if not yet registered.
|
|
1006
|
+
*/
|
|
1007
|
+
get entryDocument(): ArazzoDocument | undefined;
|
|
1008
|
+
/**
|
|
1009
|
+
* Acquires a document by URI. Returns cached document if available,
|
|
1010
|
+
* otherwise detects the format, loads via the matching provider,
|
|
1011
|
+
* caches, and returns it.
|
|
1012
|
+
*
|
|
1013
|
+
* Concurrent calls for a document that is still loading share that one
|
|
1014
|
+
* load instead of each fetching and parsing it. A failed load is not
|
|
1015
|
+
* remembered: the next call tries again.
|
|
1016
|
+
*
|
|
1017
|
+
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
1018
|
+
* @throws UnmatchedProviderError - When no provider can load the document
|
|
1019
|
+
*/
|
|
1020
|
+
acquire(uri: string): Promise<APIDocument>;
|
|
1021
|
+
/**
|
|
1022
|
+
* Whether a source description of `type` can be loaded at all: some provider
|
|
1023
|
+
* loads that type, or does not say which type it loads. A source with no
|
|
1024
|
+
* `type` may be of any type, so it can.
|
|
1025
|
+
*
|
|
1026
|
+
* Answered from the providers alone, without fetching anything — so a
|
|
1027
|
+
* caller can skip a load that could only fail, such as an AsyncAPI source
|
|
1028
|
+
* while no provider loads AsyncAPI.
|
|
1029
|
+
*/
|
|
1030
|
+
canLoad(type: string | undefined): boolean;
|
|
1031
|
+
/**
|
|
1032
|
+
* Acquires the entry Arazzo document and marks it with `isEntry: true`.
|
|
1033
|
+
* Validates that the document is an Arazzo specification.
|
|
1034
|
+
*
|
|
1035
|
+
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
1036
|
+
* @throws UnmatchedProviderError - When no provider can load the document
|
|
1037
|
+
* @throws InvalidEntryDocumentError - When the document is not an Arazzo document
|
|
1038
|
+
*/
|
|
1039
|
+
acquireEntryDocument(uri: string): Promise<ArazzoDocument>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Drops every cached document. A load still in progress is no longer shared:
|
|
1042
|
+
* the next `acquire` of that document starts a fresh load.
|
|
1043
|
+
*/
|
|
1044
|
+
clear(): void;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* An event the {@link DocumentRegistry} emits.
|
|
1049
|
+
* @public
|
|
1050
|
+
*/
|
|
1051
|
+
export declare type DocumentRegistryEvent = DocumentLoadStartEvent | DocumentLoadSettledEvent;
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Options for the DocumentRegistry.
|
|
1055
|
+
* @public
|
|
1056
|
+
*/
|
|
1057
|
+
export declare interface DocumentRegistryOptions {
|
|
1058
|
+
readonly providers?: DocumentRegistryProvider[];
|
|
1059
|
+
/**
|
|
1060
|
+
* Receives the registry's events: the start and end of every document
|
|
1061
|
+
* load. Cache hits emit nothing. See {@link DocumentRegistryEvent}.
|
|
1062
|
+
*/
|
|
1063
|
+
readonly observer?: ArazzoRunnerObserver<DocumentRegistryEvent>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Reads the current time in milliseconds, stamped on each event. Defaults to
|
|
1066
|
+
* `performance.now`.
|
|
1067
|
+
*/
|
|
1068
|
+
readonly now?: () => number;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Base class for document registry providers.
|
|
1073
|
+
*
|
|
1074
|
+
* Subclasses implement `canProvide()` for format detection and `provide()` for loading.
|
|
1075
|
+
* @public
|
|
1076
|
+
*/
|
|
1077
|
+
export declare abstract class DocumentRegistryProvider {
|
|
1078
|
+
/**
|
|
1079
|
+
* The Source Description Object `type` this provider loads (`openapi`,
|
|
1080
|
+
* `arazzo`, …), or `undefined` when it does not say — then it may load a
|
|
1081
|
+
* source of any type.
|
|
1082
|
+
*
|
|
1083
|
+
* Lets the registry tell, without fetching anything, whether a source of a
|
|
1084
|
+
* given type can be loaded at all (`DocumentRegistry.canLoad`).
|
|
1085
|
+
*/
|
|
1086
|
+
readonly sourceDescriptionType?: string;
|
|
1087
|
+
/**
|
|
1088
|
+
* Checks if the content at the URI can be handled by this provider.
|
|
1089
|
+
*/
|
|
1090
|
+
abstract canProvide(uri: string): Promise<boolean>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Loads and produces a document from a URI.
|
|
1093
|
+
*/
|
|
1094
|
+
abstract provide(uri: string): Promise<APIDocument>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Rejects a document the parser could only partly read. The strict parsers
|
|
1097
|
+
* throw on a syntax error; the lenient ones that source maps need record it
|
|
1098
|
+
* and parse what they can instead, so a document must load with source maps
|
|
1099
|
+
* exactly when it loads without.
|
|
1100
|
+
*/
|
|
1101
|
+
protected assertParsed(uri: string, parseResult: ParseResultElement): void;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Options for a document registry provider.
|
|
1106
|
+
* @public
|
|
1107
|
+
*/
|
|
1108
|
+
export declare type DocumentRegistryProviderOptions = PartialOptions<ApiDOMReferenceOptions>;
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Carries a `reason`, one of the class's static reason fields.
|
|
1112
|
+
*
|
|
1113
|
+
* Every static on this class is a reason: {@link ExecutionErrorReason} is
|
|
1114
|
+
* derived from the class's own statics, so a non-reason static would join the
|
|
1115
|
+
* union.
|
|
1116
|
+
* @public
|
|
1117
|
+
*/
|
|
1118
|
+
export declare class ExecutionError extends ArazzoRunnerError {
|
|
1119
|
+
/** The run was cancelled through its `AbortSignal`; the signal's reason is the `cause`. */
|
|
1120
|
+
static readonly Aborted: "aborted";
|
|
1121
|
+
/** A step without an `executeOptions` entry of its own reaches a document that several entries configure. */
|
|
1122
|
+
static readonly AmbiguousExecuteOptions: "ambiguous-execute-options";
|
|
1123
|
+
/** A step or a `goto`/`retry` action declares more than one mutually exclusive target. */
|
|
1124
|
+
static readonly AmbiguousTarget: "ambiguous-target";
|
|
1125
|
+
/** The `dependsOn` edges alone form a cycle between workflows. */
|
|
1126
|
+
static readonly DependsOnCycle: "dependsOn-cycle";
|
|
1127
|
+
/** A `goto` action declares neither a `stepId` nor a `workflowId`. */
|
|
1128
|
+
static readonly GotoTargetMissing: "goto-target-missing";
|
|
1129
|
+
/** A `goto` action's `stepId` names no step in the workflow. */
|
|
1130
|
+
static readonly GotoTargetNotFound: "goto-target-not-found";
|
|
1131
|
+
/** A process-wide instrumentation wrap (see `instrument`) settled without running its workflow or step. */
|
|
1132
|
+
static readonly InstrumentationWrap: "instrumentation-wrap";
|
|
1133
|
+
/** An `operationId` or `operationPath` is not a valid operation reference. */
|
|
1134
|
+
static readonly InvalidOperationReference: "invalid-operation-reference";
|
|
1135
|
+
/** A `workflowId` is not a valid `$sourceDescriptions.{name}.{workflowId}` expression. */
|
|
1136
|
+
static readonly InvalidWorkflowReference: "invalid-workflow-reference";
|
|
1137
|
+
/** A workflow's `dependsOn` is not a list or holds a non-string entry. */
|
|
1138
|
+
static readonly MalformedDependsOn: "malformed-dependsOn";
|
|
1139
|
+
/** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
|
|
1140
|
+
static readonly MalformedSteps: "malformed-steps";
|
|
1141
|
+
/** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
|
|
1142
|
+
static readonly MissingOperation: "missing-operation";
|
|
1143
|
+
/** An operation reference locates no operation in its OpenAPI source description. */
|
|
1144
|
+
static readonly OperationNotFound: "operation-not-found";
|
|
1145
|
+
/** A `retry` action references a step or workflow, but no run reference was given to run it. */
|
|
1146
|
+
static readonly RetryReferenceUnsupported: "retry-reference-unsupported";
|
|
1147
|
+
/** A `retry` action's `stepId` names no step in the workflow. */
|
|
1148
|
+
static readonly RetryTargetNotFound: "retry-target-not-found";
|
|
1149
|
+
/** A workflow reference names a source description that is not an Arazzo document. */
|
|
1150
|
+
static readonly SourceDescriptionNotArazzo: "source-description-not-arazzo";
|
|
1151
|
+
/** A reference names a source description the Arazzo document does not define. */
|
|
1152
|
+
static readonly SourceDescriptionNotFound: "source-description-not-found";
|
|
1153
|
+
/** An operation reference names a source description that is not an OpenAPI document. */
|
|
1154
|
+
static readonly SourceDescriptionNotOpenAPI: "source-description-not-openapi";
|
|
1155
|
+
/** A workflow exceeded its budget of step attempts. */
|
|
1156
|
+
static readonly StepBudget: "step-budget";
|
|
1157
|
+
/** An action declares a `type` other than `end`, `goto` or `retry`. */
|
|
1158
|
+
static readonly UnknownActionType: "unknown-action-type";
|
|
1159
|
+
/** `execute` received an option it does not know, or an `executeOptions` entry that is not an object. */
|
|
1160
|
+
static readonly UnknownExecuteOption: "unknown-execute-option";
|
|
1161
|
+
/** A step produced a transition the workflow executor does not recognize. */
|
|
1162
|
+
static readonly UnknownTransitionKind: "unknown-transition-kind";
|
|
1163
|
+
/** A sub-workflow call (alone or together with `dependsOn`) forms a cycle between workflows. */
|
|
1164
|
+
static readonly WorkflowCycle: "workflow-cycle";
|
|
1165
|
+
/** Workflows nest deeper than the configured limit. */
|
|
1166
|
+
static readonly WorkflowDepth: "workflow-depth";
|
|
1167
|
+
/** A workflow reference names a workflow the Arazzo document does not define. */
|
|
1168
|
+
static readonly WorkflowNotFound: "workflow-not-found";
|
|
1169
|
+
/** A step that targets a workflow was handed to the step executor, which runs operations only. */
|
|
1170
|
+
static readonly WorkflowStep: "workflow-step";
|
|
1171
|
+
readonly stepId?: string;
|
|
1172
|
+
readonly workflowId?: string;
|
|
1173
|
+
readonly reason?: ExecutionErrorReason;
|
|
1174
|
+
/**
|
|
1175
|
+
* The chain of workflowIds the error concerns — the loop A → B → A for a
|
|
1176
|
+
* cycle, or the call chain in progress when a budget ran out.
|
|
1177
|
+
*/
|
|
1178
|
+
readonly path?: readonly string[];
|
|
1179
|
+
constructor(message?: string, options?: ApiDOMErrorOptions & {
|
|
1180
|
+
readonly reason?: ExecutionErrorReason;
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* One of the reasons an {@link ExecutionError} carries: an `ExecutionError`
|
|
1186
|
+
* static such as `ExecutionError.OperationNotFound`.
|
|
1187
|
+
* @public
|
|
1188
|
+
*/
|
|
1189
|
+
export declare type ExecutionErrorReason = (typeof ExecutionError)[Exclude<keyof typeof ExecutionError, keyof typeof ArazzoRunnerError | 'prototype'>];
|
|
1190
|
+
|
|
1191
|
+
/** @public */
|
|
1192
|
+
export declare class ExtractionError extends ArazzoRunnerError {
|
|
1193
|
+
readonly workflowId?: string;
|
|
1194
|
+
readonly stepId?: string;
|
|
1195
|
+
readonly operationId?: string;
|
|
1196
|
+
readonly pointer?: string;
|
|
1197
|
+
readonly uri?: string;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* The pluggable HTTP transport seam.
|
|
1202
|
+
*
|
|
1203
|
+
* Receives the finalized {@link OpenAPIOperationRequest} and resolves with the
|
|
1204
|
+
* raw WHATWG `Response`. The contract is deliberately minimal so any HTTP
|
|
1205
|
+
* stack (undici, got, a recording stub, …) drops in with a few lines:
|
|
1206
|
+
*
|
|
1207
|
+
* - resolve with a `Response` for every HTTP status — a non-2xx is a valid
|
|
1208
|
+
* Arazzo outcome judged by a step's `successCriteria`, never an error;
|
|
1209
|
+
* - throw (or reject) only on transport failure — the executor wraps the
|
|
1210
|
+
* error as a `ClientError`;
|
|
1211
|
+
* - honor `request.signal` when present;
|
|
1212
|
+
* - encode a `FormData` body as `multipart/form-data` and set the
|
|
1213
|
+
* `Content-Type` with its boundary, as `fetch` does — the executor removes
|
|
1214
|
+
* the request's own multipart `Content-Type` for such a body, since only the
|
|
1215
|
+
* encoder knows the boundary.
|
|
1216
|
+
*
|
|
1217
|
+
* Response normalization (content-type dispatch, header mapping) happens on
|
|
1218
|
+
* the executor side for every client, so `$response.body` semantics stay
|
|
1219
|
+
* identical no matter which transport is plugged in.
|
|
1220
|
+
* @public
|
|
1221
|
+
*/
|
|
1222
|
+
export declare type HTTPClient = (request: OpenAPIOperationRequest) => Promise<Response>;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* The default {@link HTTPClient}: global fetch.
|
|
1226
|
+
*
|
|
1227
|
+
* Mirrors swagger-client's own transport line — the request object doubles as
|
|
1228
|
+
* fetch init, so `method`, `headers`, `body`, `credentials`, and `signal` are
|
|
1229
|
+
* picked up from it directly.
|
|
1230
|
+
* @public
|
|
1231
|
+
*/
|
|
1232
|
+
export declare const httpClientFetch: HTTPClient;
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* Applies `hooks` to every runner in the process, until the returned
|
|
1236
|
+
* function removes them: the seam process-wide tooling, such as the
|
|
1237
|
+
* OpenTelemetry instrumentation, is built on. A run already in progress
|
|
1238
|
+
* picks hooks up at its next event or operation, and drops removed ones the
|
|
1239
|
+
* same way: a removed hook misses the settled events of what it saw start.
|
|
1240
|
+
* Hooks apply in the order they were added, the first wrap outermost.
|
|
1241
|
+
* @public
|
|
1242
|
+
*/
|
|
1243
|
+
export declare const instrument: (hooks: InstrumentationHooks) => (() => void);
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Hooks that apply to every runner in the process, on top of the observer
|
|
1247
|
+
* each was given.
|
|
1248
|
+
* @public
|
|
1249
|
+
*/
|
|
1250
|
+
export declare interface InstrumentationHooks {
|
|
1251
|
+
/**
|
|
1252
|
+
* Receives every event of every building block, after the block's own
|
|
1253
|
+
* observer, under the same rules: synchronously, never awaited, and a throw
|
|
1254
|
+
* aborts what emitted it. Events carry what the run saw, credentials
|
|
1255
|
+
* included.
|
|
1256
|
+
*/
|
|
1257
|
+
readonly observer?: ArazzoRunnerObserver;
|
|
1258
|
+
/** Runs around each workflow invocation and each step. */
|
|
1259
|
+
readonly wrap?: InstrumentationWrap;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Runs around each workflow invocation and each step, so what `run` does
|
|
1264
|
+
* happens inside it: in the active context of a span it opened, for one. It
|
|
1265
|
+
* must call `run`, and should settle once `run` settles; a second call runs
|
|
1266
|
+
* nothing again. What it resolves or rejects with does not change the run:
|
|
1267
|
+
* the run's own outcome stands, once the run settled, and the operation's
|
|
1268
|
+
* settled event says what it was.
|
|
1269
|
+
* @public
|
|
1270
|
+
*/
|
|
1271
|
+
export declare type InstrumentationWrap = (operation: InstrumentedOperation, run: () => Promise<void>) => Promise<void>;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* What an {@link InstrumentationWrap} runs around.
|
|
1275
|
+
* @public
|
|
1276
|
+
*/
|
|
1277
|
+
export declare type InstrumentedOperation = InstrumentedWorkflow | InstrumentedStep;
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* A step an {@link InstrumentationWrap} runs around: its `step:start`, its
|
|
1281
|
+
* attempts and requests, and its `step:settled`.
|
|
1282
|
+
* @public
|
|
1283
|
+
*/
|
|
1284
|
+
export declare interface InstrumentedStep {
|
|
1285
|
+
readonly kind: 'step';
|
|
1286
|
+
readonly runId: string;
|
|
1287
|
+
readonly workflowId: string;
|
|
1288
|
+
readonly path: readonly string[];
|
|
1289
|
+
readonly stepId: string;
|
|
1290
|
+
readonly location: DocumentLocation;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* A workflow invocation an {@link InstrumentationWrap} runs around: its
|
|
1295
|
+
* `workflow:start`, its steps and its `workflow:settled`.
|
|
1296
|
+
* @public
|
|
1297
|
+
*/
|
|
1298
|
+
export declare interface InstrumentedWorkflow {
|
|
1299
|
+
readonly kind: 'workflow';
|
|
1300
|
+
readonly runId: string;
|
|
1301
|
+
readonly workflowId: string;
|
|
1302
|
+
readonly path: readonly string[];
|
|
1303
|
+
readonly via: WorkflowCallVia;
|
|
1304
|
+
readonly location: DocumentLocation;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/** @public */
|
|
1308
|
+
export declare class InvalidEntryDocumentError extends ArazzoRunnerError {
|
|
1309
|
+
readonly uri?: string;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Evaluates a `jsonpath` Arazzo criterion condition against a resolved context value.
|
|
1314
|
+
*
|
|
1315
|
+
* The condition is a JSONPath query (RFC 9535, per the Criterion Expression
|
|
1316
|
+
* Type Object's pinned version) applied to the resolved `context`. The criterion
|
|
1317
|
+
* is met when the query yields a non-empty node list.
|
|
1318
|
+
*
|
|
1319
|
+
* Per Arazzo 1.1.0, a `null` or `undefined` context fails the condition. The
|
|
1320
|
+
* context is a plain runtime value (the runtime expression evaluator has already
|
|
1321
|
+
* converted any ApiDOM element), so the default JSON evaluation realm applies.
|
|
1322
|
+
* @public
|
|
1323
|
+
*/
|
|
1324
|
+
export declare class JSONPathCriterionEvaluator {
|
|
1325
|
+
/**
|
|
1326
|
+
* Runs the JSONPath `condition` against the resolved context value, returning
|
|
1327
|
+
* whether it matched anything.
|
|
1328
|
+
*
|
|
1329
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
1330
|
+
* {@link CriterionEvaluationError} when the condition is not a valid JSONPath query.
|
|
1331
|
+
*/
|
|
1332
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
/** @public */
|
|
1336
|
+
export declare class NormalizationError extends ArazzoRunnerError {
|
|
1337
|
+
readonly workflowId?: string;
|
|
1338
|
+
readonly operationId?: string;
|
|
1339
|
+
readonly operationPointer?: string;
|
|
1340
|
+
readonly pathItemPointer?: string;
|
|
1341
|
+
readonly uri?: string;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Assembles a standalone OpenAPI 2.0 (Swagger) document from a
|
|
1346
|
+
* normalized operation element.
|
|
1347
|
+
*
|
|
1348
|
+
* The assembled document is a valid Swagger 2.0 specification containing
|
|
1349
|
+
* only the single operation with its host, basePath, schemes, and
|
|
1350
|
+
* referenced security definitions from the source document.
|
|
1351
|
+
* @public
|
|
1352
|
+
*/
|
|
1353
|
+
export declare class OpenAPI2DocumentAssembler {
|
|
1354
|
+
#private;
|
|
1355
|
+
/**
|
|
1356
|
+
* Assembles a standalone Swagger 2.0 document from a normalized operation.
|
|
1357
|
+
*/
|
|
1358
|
+
assemble(operation: OperationElement, document: OpenAPIDocument): OpenAPIDocument;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Version-specific normalization for OpenAPI 2.0 (Swagger) operations.
|
|
1363
|
+
*
|
|
1364
|
+
* Dereferences the operation subtree and handles merging of
|
|
1365
|
+
* parameters and security from path item and root levels.
|
|
1366
|
+
* OpenAPI 2.0 does not support servers at path item or operation level;
|
|
1367
|
+
* host/basePath/schemes are root-level only and handled at execution time.
|
|
1368
|
+
* @public
|
|
1369
|
+
*/
|
|
1370
|
+
export declare class OpenAPI2OperationNormalizer {
|
|
1371
|
+
#private;
|
|
1372
|
+
constructor(options?: OpenAPI2OperationNormalizerOptions);
|
|
1373
|
+
normalize(operation: OperationElement, document: OpenAPIDocument): Promise<OperationElement>;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Options for normalizing an OpenAPI 2.0 operation.
|
|
1378
|
+
* @public
|
|
1379
|
+
*/
|
|
1380
|
+
export declare type OpenAPI2OperationNormalizerOptions = PartialOptions<ApiDOMReferenceOptions>;
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Assembles a standalone OpenAPI 3.0 document from a
|
|
1384
|
+
* normalized operation element.
|
|
1385
|
+
*
|
|
1386
|
+
* The assembled document is a valid OpenAPI 3.0 specification containing
|
|
1387
|
+
* only the single operation with its servers, and referenced security
|
|
1388
|
+
* schemes from the source document's components.
|
|
1389
|
+
* @public
|
|
1390
|
+
*/
|
|
1391
|
+
export declare class OpenAPI30DocumentAssembler {
|
|
1392
|
+
#private;
|
|
1393
|
+
/**
|
|
1394
|
+
* Assembles a standalone OpenAPI 3.0 document from a normalized operation.
|
|
1395
|
+
*/
|
|
1396
|
+
assemble(operation: OperationElement_2, document: OpenAPIDocument): OpenAPIDocument;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Version-specific normalization for OpenAPI 3.0 operations.
|
|
1401
|
+
*
|
|
1402
|
+
* Dereferences the operation subtree and handles merging of servers,
|
|
1403
|
+
* parameters, and security from path item and root levels.
|
|
1404
|
+
* @public
|
|
1405
|
+
*/
|
|
1406
|
+
export declare class OpenAPI30OperationNormalizer {
|
|
1407
|
+
#private;
|
|
1408
|
+
constructor(options?: OpenAPI30OperationNormalizerOptions);
|
|
1409
|
+
normalize(operation: OperationElement_2, document: OpenAPIDocument): Promise<OperationElement_2>;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Options for normalizing an OpenAPI 3.0 operation.
|
|
1414
|
+
* @public
|
|
1415
|
+
*/
|
|
1416
|
+
export declare type OpenAPI30OperationNormalizerOptions = PartialOptions<ApiDOMReferenceOptions>;
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Assembles a standalone OpenAPI 3.1 document from a
|
|
1420
|
+
* normalized operation element.
|
|
1421
|
+
*
|
|
1422
|
+
* The assembled document is a valid OpenAPI 3.1 specification containing
|
|
1423
|
+
* only the single operation with its servers, and referenced security
|
|
1424
|
+
* schemes from the source document's components.
|
|
1425
|
+
* @public
|
|
1426
|
+
*/
|
|
1427
|
+
export declare class OpenAPI31DocumentAssembler {
|
|
1428
|
+
#private;
|
|
1429
|
+
/**
|
|
1430
|
+
* Assembles a standalone OpenAPI 3.1 document from a normalized operation.
|
|
1431
|
+
*/
|
|
1432
|
+
assemble(operation: OperationElement_3, document: OpenAPIDocument): OpenAPIDocument;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Version-specific normalization for OpenAPI 3.1 operations.
|
|
1437
|
+
*
|
|
1438
|
+
* Dereferences the operation subtree and handles merging of servers,
|
|
1439
|
+
* parameters, and security from path item and root levels.
|
|
1440
|
+
* Same inheritance rules as 3.0 but with JSON Schema $id semantics
|
|
1441
|
+
* for schema resolution.
|
|
1442
|
+
* @public
|
|
1443
|
+
*/
|
|
1444
|
+
export declare class OpenAPI31OperationNormalizer {
|
|
1445
|
+
#private;
|
|
1446
|
+
constructor(options?: OpenAPI31OperationNormalizerOptions);
|
|
1447
|
+
normalize(operation: OperationElement_3, document: OpenAPIDocument): Promise<OperationElement_3>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Options for normalizing an OpenAPI 3.1 operation.
|
|
1452
|
+
* @public
|
|
1453
|
+
*/
|
|
1454
|
+
export declare type OpenAPI31OperationNormalizerOptions = PartialOptions<ApiDOMReferenceOptions>;
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* An OpenAPI document held by the document registry.
|
|
1458
|
+
* @public
|
|
1459
|
+
*/
|
|
1460
|
+
export declare class OpenAPIDocument extends APIDocument {
|
|
1461
|
+
readonly type: "openapi";
|
|
1462
|
+
readonly operationIndex: OpenAPIOperationIndex;
|
|
1463
|
+
constructor(uri: string, parseResult: ParseResultElement, operationIndex: OpenAPIOperationIndex);
|
|
1464
|
+
/**
|
|
1465
|
+
* Type guard for OpenAPIDocument.
|
|
1466
|
+
*/
|
|
1467
|
+
static is(doc: APIDocument): doc is OpenAPIDocument;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* Facade for assembling standalone OpenAPI documents across all supported versions.
|
|
1472
|
+
*
|
|
1473
|
+
* Detects the OpenAPI version from the source document and delegates to the
|
|
1474
|
+
* appropriate version-specific assembler (2.0, 3.0, or 3.1).
|
|
1475
|
+
*
|
|
1476
|
+
* Custom assembler instances can be provided via constructor options.
|
|
1477
|
+
* @public
|
|
1478
|
+
*/
|
|
1479
|
+
export declare class OpenAPIDocumentAssembler {
|
|
1480
|
+
#private;
|
|
1481
|
+
constructor(options?: OpenAPIDocumentAssemblerOptions);
|
|
1482
|
+
/**
|
|
1483
|
+
* Assembles a standalone OpenAPI document by delegating to the version-specific assembler.
|
|
1484
|
+
*/
|
|
1485
|
+
assemble(operation: OpenAPIOperationElement, document: OpenAPIDocument): OpenAPIDocument;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Options for the OpenAPI document assembler facade.
|
|
1490
|
+
* @public
|
|
1491
|
+
*/
|
|
1492
|
+
export declare interface OpenAPIDocumentAssemblerOptions {
|
|
1493
|
+
readonly openapi2?: OpenAPI2DocumentAssembler;
|
|
1494
|
+
readonly openapi30?: OpenAPI30DocumentAssembler;
|
|
1495
|
+
readonly openapi31?: OpenAPI31DocumentAssembler;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Provides OpenAPIDocument instances for the DocumentRegistry.
|
|
1500
|
+
*
|
|
1501
|
+
* Parses, dereferences, and builds an OperationIndex for OpenAPI documents.
|
|
1502
|
+
* The first operation of a duplicated operationId wins.
|
|
1503
|
+
* @public
|
|
1504
|
+
*/
|
|
1505
|
+
export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
1506
|
+
#private;
|
|
1507
|
+
readonly sourceDescriptionType = "openapi";
|
|
1508
|
+
constructor(options?: OpenAPIDocumentRegistryProviderOptions);
|
|
1509
|
+
canProvide(uri: string): Promise<boolean>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Loads an OpenAPI document from a URI and produces an OpenAPIDocument.
|
|
1512
|
+
*/
|
|
1513
|
+
provide(uri: string): Promise<OpenAPIDocument>;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Options for loading an OpenAPI document.
|
|
1518
|
+
* @public
|
|
1519
|
+
*/
|
|
1520
|
+
export declare type OpenAPIDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* The normalized operation was assembled into the OpenAPI document the
|
|
1524
|
+
* request is built from.
|
|
1525
|
+
* @public
|
|
1526
|
+
*/
|
|
1527
|
+
export declare interface OpenAPIOperationAssembledEvent extends OpenAPIOperationEventBase {
|
|
1528
|
+
readonly type: 'openapi:operation:assembled';
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Union of OperationElement across all supported OpenAPI versions.
|
|
1533
|
+
* @public
|
|
1534
|
+
*/
|
|
1535
|
+
export declare type OpenAPIOperationElement = OperationElement | OperationElement_2 | OperationElement_3;
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* An event the {@link OpenAPIOperationExecutor} emits.
|
|
1539
|
+
* @public
|
|
1540
|
+
*/
|
|
1541
|
+
export declare type OpenAPIOperationEvent = OpenAPIOperationNormalizeStartEvent | OpenAPIOperationNormalizeSettledEvent | OpenAPIOperationAssembledEvent | OpenAPIOperationRequestStartEvent | OpenAPIOperationRequestSettledEvent;
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* The fields every {@link OpenAPIOperationEvent} carries: the operation, and
|
|
1545
|
+
* the step it runs for, in the same shape a {@link RequestInterceptor}
|
|
1546
|
+
* receives them.
|
|
1547
|
+
* @public
|
|
1548
|
+
*/
|
|
1549
|
+
export declare interface OpenAPIOperationEventBase extends ArazzoRunnerEventBase, RequestContext {
|
|
1550
|
+
/**
|
|
1551
|
+
* Where the operation is written. It differs from `operation` (where the
|
|
1552
|
+
* operation was looked up) for an operation of a Path Item Object written
|
|
1553
|
+
* as a `$ref`, which is written in the document the reference names.
|
|
1554
|
+
*/
|
|
1555
|
+
readonly location: DocumentLocation;
|
|
1556
|
+
/**
|
|
1557
|
+
* The `runId` of the {@link WorkflowExecutor.execute} call the operation
|
|
1558
|
+
* runs for, from the execute options. Absent when the executor is used
|
|
1559
|
+
* without one.
|
|
1560
|
+
*/
|
|
1561
|
+
readonly runId?: string;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Options for executing an OpenAPI operation.
|
|
1566
|
+
*
|
|
1567
|
+
* All fields are forwarded to the vendored swagger-client `buildRequest`
|
|
1568
|
+
* (which owns parameter serialization, security application, and server URL
|
|
1569
|
+
* resolution), except `requestInterceptor`, which the executor runs between
|
|
1570
|
+
* building the request and sending it.
|
|
1571
|
+
*
|
|
1572
|
+
* Typed here are the options the runner itself drives and the ones callers
|
|
1573
|
+
* routinely reach for. The rest of `buildRequest`'s surface (`scheme`,
|
|
1574
|
+
* `parameterBuilders`, `attachContentTypeForEmptyPayload`, …) is deliberately
|
|
1575
|
+
* left untyped and passes through the bag's open tail unchanged — see
|
|
1576
|
+
* {@link OpenAPIOperationExecuteOptionsBag}.
|
|
1577
|
+
*
|
|
1578
|
+
* Arazzo is auth-agnostic, so credentials come from outside the workflow:
|
|
1579
|
+
* static ones for the security schemes the OpenAPI document declares go in
|
|
1580
|
+
* `securities`, and anything computed per request is applied with a
|
|
1581
|
+
* {@link RequestInterceptor}.
|
|
1582
|
+
* @public
|
|
1583
|
+
*/
|
|
1584
|
+
export declare interface OpenAPIOperationExecuteOptions {
|
|
1585
|
+
readonly parameters?: Record<string, unknown>;
|
|
1586
|
+
readonly requestBody?: unknown;
|
|
1587
|
+
/**
|
|
1588
|
+
* The media type of the request body, sent as the `Content-Type` header (the
|
|
1589
|
+
* Arazzo `requestBody.contentType`). Matched against the media types the
|
|
1590
|
+
* operation declares under `requestBody.content`, ignoring case and any
|
|
1591
|
+
* parameters it carries, and accepting a declared range (`type/*`, or the
|
|
1592
|
+
* all-media-types range) as covering a concrete type. The authored value is
|
|
1593
|
+
* sent in full whichever declaration it matched.
|
|
1594
|
+
*
|
|
1595
|
+
* The form media types are the exception: `application/x-www-form-urlencoded`
|
|
1596
|
+
* and `multipart/form-data` decide how the body is encoded, so they must be
|
|
1597
|
+
* declared exactly rather than by a range. A media type matching nothing
|
|
1598
|
+
* throws rather than sending an empty or wrongly encoded body.
|
|
1599
|
+
*/
|
|
1600
|
+
readonly requestContentType?: string;
|
|
1601
|
+
/**
|
|
1602
|
+
* The media type to ask for in the response, sent as the `Accept` header.
|
|
1603
|
+
* When omitted, `Accept` is derived from the media types the operation
|
|
1604
|
+
* declares for its 2xx responses.
|
|
1605
|
+
*/
|
|
1606
|
+
readonly responseContentType?: string;
|
|
1607
|
+
/**
|
|
1608
|
+
* The server to send the request to. A value matching a declared server's
|
|
1609
|
+
* `url` selects it and brings that server's variable defaults along; any
|
|
1610
|
+
* other value is used as the base URL directly, so pointing a workflow at
|
|
1611
|
+
* another environment needs no special option. Relative values resolve
|
|
1612
|
+
* against the document's own URL. Works the same for OpenAPI 2.0 and 3.x.
|
|
1613
|
+
*
|
|
1614
|
+
* Defaults to the first server the operation declares (for 2.0, the
|
|
1615
|
+
* document's `schemes`/`host`/`basePath`), resolved against the URL the
|
|
1616
|
+
* document was loaded from.
|
|
1617
|
+
*/
|
|
1618
|
+
readonly server?: string;
|
|
1619
|
+
/**
|
|
1620
|
+
* Substitutions for a selected server's URL template, layered over the
|
|
1621
|
+
* variable defaults declared in the document. OpenAPI 3.x only, and only for
|
|
1622
|
+
* a declared server — an override carries no declared variables.
|
|
1623
|
+
*/
|
|
1624
|
+
readonly serverVariables?: Record<string, string>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Credentials for the security schemes of the operation's OpenAPI document.
|
|
1627
|
+
* Only the schemes the operation requires are applied, each where its
|
|
1628
|
+
* scheme says (header, query or cookie); an operation with an empty
|
|
1629
|
+
* `security` gets none.
|
|
1630
|
+
*/
|
|
1631
|
+
readonly securities?: OpenAPIOperationSecurities;
|
|
1632
|
+
readonly signal?: AbortSignal;
|
|
1633
|
+
/**
|
|
1634
|
+
* Identifies the run this call belongs to, stamped on the executor's events
|
|
1635
|
+
* (see {@link OpenAPIOperationEventBase.runId}). Consumed by the executor,
|
|
1636
|
+
* never sent. The workflow executor sets it for every step.
|
|
1637
|
+
*/
|
|
1638
|
+
readonly runId?: string;
|
|
1639
|
+
/**
|
|
1640
|
+
* Runs after the executor-level interceptor, for this call only.
|
|
1641
|
+
*/
|
|
1642
|
+
readonly requestInterceptor?: RequestInterceptor;
|
|
1643
|
+
/**
|
|
1644
|
+
* The Arazzo step this call is issued for, handed to both interceptors as
|
|
1645
|
+
* {@link RequestContext.step}. The step executor sets it; it is not
|
|
1646
|
+
* forwarded to `buildRequest`.
|
|
1647
|
+
*/
|
|
1648
|
+
readonly step?: RequestContextStep;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* The execute options forwarded to {@link OpenAPIOperationExecutor.execute}.
|
|
1653
|
+
*
|
|
1654
|
+
* The {@link OpenAPIOperationExecuteOptions} fields are surfaced for
|
|
1655
|
+
* type-checked callers, while the open `Record` tail keeps the bag opaque so
|
|
1656
|
+
* the rest of `buildRequest`'s surface (`scheme`, `parameterBuilders`,
|
|
1657
|
+
* `attachContentTypeForEmptyPayload`, …) passes through untouched.
|
|
1658
|
+
*
|
|
1659
|
+
* Nothing routine belongs in the tail. `server` covers every case that once
|
|
1660
|
+
* needed a `contextUrl`, so reaching for that here means an edge case: tests
|
|
1661
|
+
* standing in for a document fetched over HTTP.
|
|
1662
|
+
*
|
|
1663
|
+
* Two kinds of entry are dropped rather than honored, since the executor owns
|
|
1664
|
+
* what they used to control. The operation target always comes from the
|
|
1665
|
+
* locator, so `operationId`/`operationPath` have no effect; and the options
|
|
1666
|
+
* only swagger-client's `execute()` ever read — `userFetch` and
|
|
1667
|
+
* `responseInterceptor`, which the runner replaces with `httpClient` and
|
|
1668
|
+
* `responseNormalizer` — never reach `buildRequest`.
|
|
1669
|
+
* @public
|
|
1670
|
+
*/
|
|
1671
|
+
export declare type OpenAPIOperationExecuteOptionsBag = OpenAPIOperationExecuteOptions & Record<string, unknown>;
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1674
|
+
* Executes a single OpenAPI operation named by a canonical
|
|
1675
|
+
* {@link OpenAPIOperationLocator}.
|
|
1676
|
+
*
|
|
1677
|
+
* The pipeline extracts the operation from its owning document, normalizes it,
|
|
1678
|
+
* assembles a minimal standalone OpenAPI document containing just that
|
|
1679
|
+
* operation, builds the HTTP request with the vendored swagger-client
|
|
1680
|
+
* `buildRequest` (parameter serialization, securities, server resolution),
|
|
1681
|
+
* sends it through the pluggable {@link HTTPClient}, and normalizes the raw
|
|
1682
|
+
* `Response` into the runner's response model. A non-2xx status is a valid
|
|
1683
|
+
* outcome (judged by a step's `successCriteria`) and is returned, never
|
|
1684
|
+
* thrown; a transport failure is wrapped as a {@link ClientError}.
|
|
1685
|
+
*
|
|
1686
|
+
* The executor is Arazzo-agnostic: it neither locates the operation (that is
|
|
1687
|
+
* the operation locator normalizer's concern) nor resolves parameters or
|
|
1688
|
+
* request bodies from runtime expressions (the step executor's concern). It
|
|
1689
|
+
* receives an already-resolved locator and an opaque bag of execute options,
|
|
1690
|
+
* and returns the normalized operation response carrying the request that was
|
|
1691
|
+
* actually sent, so `$url` / `$method` / `$request.*` can be evaluated after
|
|
1692
|
+
* execution.
|
|
1693
|
+
* @public
|
|
1694
|
+
*/
|
|
1695
|
+
export declare class OpenAPIOperationExecutor {
|
|
1696
|
+
#private;
|
|
1697
|
+
constructor(options?: OpenAPIOperationExecutorOptions);
|
|
1698
|
+
/**
|
|
1699
|
+
* Executes the located operation, returning the normalized operation
|
|
1700
|
+
* response.
|
|
1701
|
+
*
|
|
1702
|
+
* `executeOptions` is an opaque bag of `buildRequest` options (e.g. resolved
|
|
1703
|
+
* `parameters`, a `requestBody` and its `requestContentType`, or a `server`).
|
|
1704
|
+
* The operation target always takes precedence over it: the
|
|
1705
|
+
* locator's JSON Pointer selects the operation in the assembled document, so
|
|
1706
|
+
* `operationId`/`operationPath` entries in the bag cannot hijack the
|
|
1707
|
+
* operation.
|
|
1708
|
+
*/
|
|
1709
|
+
execute(locator: OpenAPIOperationLocator, executeOptions?: OpenAPIOperationExecuteOptionsBag): Promise<OpenAPIOperationResponse>;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* Options for the OpenAPIOperationExecutor.
|
|
1714
|
+
* @public
|
|
1715
|
+
*/
|
|
1716
|
+
export declare interface OpenAPIOperationExecutorOptions {
|
|
1717
|
+
/**
|
|
1718
|
+
* The transport that sends the built request and resolves with the raw
|
|
1719
|
+
* WHATWG `Response`. Defaults to {@link httpClientFetch} (global fetch).
|
|
1720
|
+
*/
|
|
1721
|
+
readonly httpClient?: HTTPClient;
|
|
1722
|
+
/**
|
|
1723
|
+
* Decorates every built request (e.g. an `Authorization` header) before the
|
|
1724
|
+
* per-call interceptor from the execute options bag runs.
|
|
1725
|
+
*/
|
|
1726
|
+
readonly requestInterceptor?: RequestInterceptor;
|
|
1727
|
+
/**
|
|
1728
|
+
* Normalizes the raw `Response` into the runner's response model. Defaults
|
|
1729
|
+
* to a fresh {@link OpenAPIOperationResponseNormalizer}.
|
|
1730
|
+
*/
|
|
1731
|
+
readonly responseNormalizer?: OpenAPIOperationResponseNormalizer;
|
|
1732
|
+
/**
|
|
1733
|
+
* Extracts the operation element from its owning document. Defaults to a
|
|
1734
|
+
* fresh {@link OpenAPIOperationExtractor}.
|
|
1735
|
+
*/
|
|
1736
|
+
readonly operationExtractor?: OpenAPIOperationExtractor;
|
|
1737
|
+
/**
|
|
1738
|
+
* Normalizes the extracted operation (servers, parameters, securities).
|
|
1739
|
+
* Defaults to a fresh {@link OpenAPIOperationNormalizer}.
|
|
1740
|
+
*/
|
|
1741
|
+
readonly operationNormalizer?: OpenAPIOperationNormalizer;
|
|
1742
|
+
/**
|
|
1743
|
+
* Assembles the standalone OpenAPI document for the operation. Defaults to a
|
|
1744
|
+
* fresh {@link OpenAPIDocumentAssembler}.
|
|
1745
|
+
*/
|
|
1746
|
+
readonly documentAssembler?: OpenAPIDocumentAssembler;
|
|
1747
|
+
/**
|
|
1748
|
+
* Receives the executor's events: the start and end of each operation's
|
|
1749
|
+
* normalization, its assembly, and the request sent and its response. See
|
|
1750
|
+
* {@link OpenAPIOperationEvent}.
|
|
1751
|
+
*/
|
|
1752
|
+
readonly observer?: ArazzoRunnerObserver<OpenAPIOperationEvent>;
|
|
1753
|
+
/**
|
|
1754
|
+
* Reads the current time in milliseconds, stamped on each event. Defaults to
|
|
1755
|
+
* `performance.now`.
|
|
1756
|
+
*/
|
|
1757
|
+
readonly now?: () => number;
|
|
1758
|
+
/**
|
|
1759
|
+
* Whether the `openapi:operation:request:*` events carry the request and
|
|
1760
|
+
* response bodies. Off by default.
|
|
1761
|
+
*/
|
|
1762
|
+
readonly captureBodies?: boolean;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Extracts an operation from an OpenAPI document.
|
|
1767
|
+
*
|
|
1768
|
+
* Locates the operation by operationId or operationPath (JSON Pointer)
|
|
1769
|
+
* and attaches metadata (pointer, method, path) to the element.
|
|
1770
|
+
* The extracted operation is not dereferenced or normalized.
|
|
1771
|
+
* @public
|
|
1772
|
+
*/
|
|
1773
|
+
export declare class OpenAPIOperationExtractor {
|
|
1774
|
+
/**
|
|
1775
|
+
* Extracts an operation by operationId.
|
|
1776
|
+
*/
|
|
1777
|
+
extract(document: OpenAPIDocument, operationId: OperationId): OpenAPIOperationElement;
|
|
1778
|
+
/**
|
|
1779
|
+
* Extracts an operation by JSON Pointer (operationPath).
|
|
1780
|
+
*/
|
|
1781
|
+
extractByPointer(document: OpenAPIDocument, pointer: JSONPointer): OpenAPIOperationElement;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Index mapping operationId to its JSON Pointer in an OpenAPI document.
|
|
1786
|
+
*
|
|
1787
|
+
* Only used when an Arazzo step references an operation by `operationId`.
|
|
1788
|
+
* When a step uses `operationPath` (a JSON Pointer), the index is bypassed
|
|
1789
|
+
* and the pointer is used directly to locate the operation.
|
|
1790
|
+
*
|
|
1791
|
+
* Only operations with an operationId are indexed; operations without one
|
|
1792
|
+
* are only reachable via `operationPath`.
|
|
1793
|
+
* @public
|
|
1794
|
+
*/
|
|
1795
|
+
export declare class OpenAPIOperationIndex extends Map<OperationId, JSONPointer> {
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
/**
|
|
1799
|
+
* A canonical OpenAPI operation locator: the OpenAPI document that owns the
|
|
1800
|
+
* operation and a JSON Pointer locating the operation within it
|
|
1801
|
+
* (`/paths/{path}/{method}`).
|
|
1802
|
+
*
|
|
1803
|
+
* A step names its operation in one of several ways — a plain `operationId`, a
|
|
1804
|
+
* `$sourceDescriptions` runtime expression, or an `operationPath` — which are
|
|
1805
|
+
* all locators for the same thing. The normalizer reduces any of them to this
|
|
1806
|
+
* single canonical form.
|
|
1807
|
+
* @public
|
|
1808
|
+
*/
|
|
1809
|
+
export declare interface OpenAPIOperationLocator {
|
|
1810
|
+
readonly document: OpenAPIDocument;
|
|
1811
|
+
readonly jsonPointer: string;
|
|
1812
|
+
/**
|
|
1813
|
+
* The source description the step reached the operation through. Absent when
|
|
1814
|
+
* the reference names none (an `operationPath` with a literal URL) and on a
|
|
1815
|
+
* locator built by hand.
|
|
1816
|
+
*/
|
|
1817
|
+
readonly sourceDescription?: OpenAPIOperationSourceDescription;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Normalizes a step's OpenAPI operation locator to a canonical
|
|
1822
|
+
* {@link OpenAPIOperationLocator} — the OpenAPI document and a JSON Pointer to
|
|
1823
|
+
* the operation within it.
|
|
1824
|
+
*
|
|
1825
|
+
* A step names its operation with either `operationId` or `operationPath`:
|
|
1826
|
+
* - `operationId` is a plain operation name, or a whole runtime expression
|
|
1827
|
+
* `$sourceDescriptions.{name}.{operationId}`. Per the Arazzo Specification, a
|
|
1828
|
+
* plain name is only valid when a single (non-arazzo) source description is
|
|
1829
|
+
* defined; multiple sources require the expression form. A plain name is
|
|
1830
|
+
* therefore looked up in the first OpenAPI source description only.
|
|
1831
|
+
* - `operationPath` embeds a `{$sourceDescriptions.{name}.url}` runtime
|
|
1832
|
+
* expression followed by a JSON Pointer to the operation.
|
|
1833
|
+
*
|
|
1834
|
+
* The `type` declared on a source description is not trusted (it may be absent
|
|
1835
|
+
* or wrong); a source is classified by what it actually parses to. The
|
|
1836
|
+
* normalizer acquires the referenced source documents from the registry on
|
|
1837
|
+
* demand.
|
|
1838
|
+
*
|
|
1839
|
+
* A reference that cannot be resolved throws {@link ExecutionError}, attributed
|
|
1840
|
+
* to the referencing step when a {@link StepScope} is given:
|
|
1841
|
+
* `operation-not-found` when no operation answers it,
|
|
1842
|
+
* `source-description-not-found` for a source name the document does not
|
|
1843
|
+
* define, `source-description-not-openapi` for a source that is not an OpenAPI
|
|
1844
|
+
* document, and `invalid-operation-reference` for a reference malformed as
|
|
1845
|
+
* written. Every returned locator names an existing operation.
|
|
1846
|
+
* @public
|
|
1847
|
+
*/
|
|
1848
|
+
export declare class OpenAPIOperationLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
|
|
1849
|
+
#private;
|
|
1850
|
+
/**
|
|
1851
|
+
* Normalizes a plain or expression `operationId` to a canonical locator.
|
|
1852
|
+
*
|
|
1853
|
+
* A whole runtime expression (`$sourceDescriptions.{name}.{operationId}`) is
|
|
1854
|
+
* resolved against its named source; a plain name is looked up in the first
|
|
1855
|
+
* OpenAPI source description only.
|
|
1856
|
+
*/
|
|
1857
|
+
normalizeOperationId(operationId: string, document: ArazzoDocument, scope?: StepScope): Promise<OpenAPIOperationLocator>;
|
|
1858
|
+
/**
|
|
1859
|
+
* Normalizes an `operationPath` —
|
|
1860
|
+
* `{$sourceDescriptions.{name}.url}#/json/pointer` — to a canonical locator.
|
|
1861
|
+
*
|
|
1862
|
+
* The reference is interpolated (resolving
|
|
1863
|
+
* `{$sourceDescriptions.{name}.url}` to the source's URL) into a URI
|
|
1864
|
+
* reference; its fragment is the JSON Pointer to the operation (decoded from
|
|
1865
|
+
* the URI fragment representation) and the part before the fragment is the
|
|
1866
|
+
* source document to acquire.
|
|
1867
|
+
*
|
|
1868
|
+
* The runner only needs a URL and a JSON Pointer, so it does not enforce that
|
|
1869
|
+
* the source description is identified by a runtime expression rather than a
|
|
1870
|
+
* literal URL (a literal URL interpolates to itself and still resolves) — that
|
|
1871
|
+
* is a conformance concern for the validator. A source name the document does
|
|
1872
|
+
* not define is detected before interpolation, so it is reported as such
|
|
1873
|
+
* rather than as the empty URL it would interpolate to; the JSON Pointer must
|
|
1874
|
+
* locate an operation in the acquired OpenAPI document.
|
|
1875
|
+
*/
|
|
1876
|
+
normalizeOperationPath(operationPath: string, document: ArazzoDocument, scope?: StepScope): Promise<OpenAPIOperationLocator>;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Facade for normalizing OpenAPI operations across all supported versions.
|
|
1881
|
+
*
|
|
1882
|
+
* Detects the OpenAPI version from the document and delegates to the
|
|
1883
|
+
* appropriate version-specific normalizer (2.0, 3.0, or 3.1).
|
|
1884
|
+
*
|
|
1885
|
+
* Custom normalizer instances can be provided via constructor options.
|
|
1886
|
+
* @public
|
|
1887
|
+
*/
|
|
1888
|
+
export declare class OpenAPIOperationNormalizer {
|
|
1889
|
+
#private;
|
|
1890
|
+
constructor(options?: OpenAPIOperationNormalizerOptions);
|
|
1891
|
+
/**
|
|
1892
|
+
* Normalizes the operation by delegating to the version-specific normalizer.
|
|
1893
|
+
*/
|
|
1894
|
+
normalize(operation: OpenAPIOperationElement, document: OpenAPIDocument): Promise<OpenAPIOperationElement>;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Options for the OpenAPI operation normalizer facade.
|
|
1899
|
+
* @public
|
|
1900
|
+
*/
|
|
1901
|
+
export declare interface OpenAPIOperationNormalizerOptions {
|
|
1902
|
+
readonly openapi2?: OpenAPI2OperationNormalizer;
|
|
1903
|
+
readonly openapi30?: OpenAPI30OperationNormalizer;
|
|
1904
|
+
readonly openapi31?: OpenAPI31OperationNormalizer;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* The operation was normalized.
|
|
1909
|
+
* @public
|
|
1910
|
+
*/
|
|
1911
|
+
export declare interface OpenAPIOperationNormalizeSettledEvent extends OpenAPIOperationEventBase {
|
|
1912
|
+
readonly type: 'openapi:operation:normalize:settled';
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Normalization of the operation began: dereferencing it (which may fetch
|
|
1917
|
+
* externally referenced documents) and inheriting its path-level fields.
|
|
1918
|
+
* @public
|
|
1919
|
+
*/
|
|
1920
|
+
export declare interface OpenAPIOperationNormalizeStartEvent extends OpenAPIOperationEventBase {
|
|
1921
|
+
readonly type: 'openapi:operation:normalize:start';
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Resolves the `parameters` of a step targeting an OpenAPI operation into the
|
|
1926
|
+
* map the operation is executed with.
|
|
1927
|
+
*
|
|
1928
|
+
* Values follow the family-wide literal-vs-expression rule of
|
|
1929
|
+
* {@link ArazzoValueResolver}. Keys and their first-wins claiming are
|
|
1930
|
+
* `ParameterDelivery`'s: `'{in}.{name}'` for a location the client
|
|
1931
|
+
* can address — a parameter is unique by `(name, in)`, so keying by name
|
|
1932
|
+
* alone would collapse two parameters that differ only in their location into
|
|
1933
|
+
* one entry and silently drop the other, where an operation legally declaring
|
|
1934
|
+
* `token` both as a header and as a query parameter must receive both — and
|
|
1935
|
+
* the bare name for Arazzo's `querystring`, which names no OpenAPI location.
|
|
1936
|
+
* First-wins is the override order the specification requires: the list is
|
|
1937
|
+
* ordered by precedence, most specific first, as `ArazzoWorkflowNormalizer`
|
|
1938
|
+
* leaves it once a step's own parameters have been merged with the ones it
|
|
1939
|
+
* inherits.
|
|
1940
|
+
*
|
|
1941
|
+
* What the map reports, this resolver judges. A parameter without a location
|
|
1942
|
+
* throws {@link ResolverError}: a step targeting an operation requires one
|
|
1943
|
+
* (the normalizer does not inherit input-shaped workflow parameters into such
|
|
1944
|
+
* steps, so this is the step's own authoring error), and delivering it bare
|
|
1945
|
+
* instead would let it capture *every* declared location of that name — see
|
|
1946
|
+
* `ParameterDelivery` for the lookup order that makes it so. A
|
|
1947
|
+
* non-string location throws for the same reason it deduplicates with nothing
|
|
1948
|
+
* in the normalizer: it names no location. So does a location outside
|
|
1949
|
+
* `path`, `query`, `header`, `cookie` and `querystring`: Arazzo 1.0.1 removed
|
|
1950
|
+
* `in: body`, and forwarding one would let it still deliver a request body
|
|
1951
|
+
* against an OpenAPI 2.0 operation, bypassing the step's `requestBody`, while
|
|
1952
|
+
* an unknown location reaches nothing at all. And two *different* parameters the
|
|
1953
|
+
* map reports as colliding cannot both be delivered, so a collision throws
|
|
1954
|
+
* rather than silently dropping one — a bare/qualified pair sharing a name (a
|
|
1955
|
+
* `querystring` `token` next to a header `token`), where the client would
|
|
1956
|
+
* consult the bare name first and silently capture the qualified value. A
|
|
1957
|
+
* `querystring` parameter whose name starts with a location the client
|
|
1958
|
+
* qualifies keys with (`header.X-Foo`) throws even alone: the client would
|
|
1959
|
+
* match its bare key as the qualified key of a declared header `X-Foo` and
|
|
1960
|
+
* deliver it there. The same check rejects it, in either order, next to a
|
|
1961
|
+
* header parameter `X-Foo` producing that very key — the scheme is not
|
|
1962
|
+
* injective, so the two could otherwise collide on one key.
|
|
1963
|
+
* @public
|
|
1964
|
+
*/
|
|
1965
|
+
export declare class OpenAPIOperationParameterResolver extends StepParameterResolver {
|
|
1966
|
+
/**
|
|
1967
|
+
* Resolves each parameter's `value`, returning a
|
|
1968
|
+
* `ParameterDelivery`-keyed record. Returns an empty object when
|
|
1969
|
+
* there are no parameters.
|
|
1970
|
+
*
|
|
1971
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
1972
|
+
*/
|
|
1973
|
+
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
/**
|
|
1977
|
+
* The HTTP request built for an OpenAPI operation.
|
|
1978
|
+
*
|
|
1979
|
+
* Produced by the vendored swagger-client `buildRequest` from the assembled
|
|
1980
|
+
* single-operation document — the URL is fully resolved (server + path +
|
|
1981
|
+
* serialized query string), parameters are serialized per their style/explode
|
|
1982
|
+
* rules, and securities are already applied to headers/query. The object is
|
|
1983
|
+
* intentionally mutable: request interceptors may edit it (or return a
|
|
1984
|
+
* replacement) before it is handed to the {@link HTTPClient}.
|
|
1985
|
+
*
|
|
1986
|
+
* The open tail carries whatever extra fields a builder attaches; the default
|
|
1987
|
+
* transport passes the whole object as fetch init, so standard `RequestInit`
|
|
1988
|
+
* fields (`credentials`, `signal`, …) take effect on the wire.
|
|
1989
|
+
* @public
|
|
1990
|
+
*/
|
|
1991
|
+
export declare interface OpenAPIOperationRequest {
|
|
1992
|
+
url: string;
|
|
1993
|
+
method: string;
|
|
1994
|
+
headers: Record<string, string>;
|
|
1995
|
+
body?: unknown;
|
|
1996
|
+
credentials?: RequestCredentials;
|
|
1997
|
+
signal?: AbortSignal;
|
|
1998
|
+
[key: string]: unknown;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* The HTTP request an OpenAPI operation was executed with.
|
|
2003
|
+
*
|
|
2004
|
+
* An immutable snapshot of the request as actually sent, recorded by the
|
|
2005
|
+
* executor after the interceptors ran and before the transport was called, so
|
|
2006
|
+
* runtime expressions (`$url`, `$method`, `$request.header.*`, `$request.body`)
|
|
2007
|
+
* can be evaluated against it after execution. `headers` is a copy taken at
|
|
2008
|
+
* capture time; `body` shares its reference with the sent request.
|
|
2009
|
+
* @public
|
|
2010
|
+
*/
|
|
2011
|
+
export declare interface OpenAPIOperationRequestInfo {
|
|
2012
|
+
readonly url: string;
|
|
2013
|
+
readonly method: string;
|
|
2014
|
+
readonly headers: Record<string, string>;
|
|
2015
|
+
readonly body?: unknown;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* The response was received and its body read, as it came: mask it with
|
|
2020
|
+
* {@link Redactor} before it leaves the process. A request that fails in the
|
|
2021
|
+
* transport throws and emits no settled event.
|
|
2022
|
+
* @public
|
|
2023
|
+
*/
|
|
2024
|
+
export declare interface OpenAPIOperationRequestSettledEvent extends OpenAPIOperationEventBase {
|
|
2025
|
+
readonly type: 'openapi:operation:request:settled';
|
|
2026
|
+
readonly response: {
|
|
2027
|
+
readonly status: number;
|
|
2028
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
2029
|
+
/**
|
|
2030
|
+
* The body's size in bytes: {@link OpenAPIOperationResponse.size}.
|
|
2031
|
+
*/
|
|
2032
|
+
readonly size: number;
|
|
2033
|
+
/**
|
|
2034
|
+
* The body parsed by its content type, as `$response.body` reads it. Only
|
|
2035
|
+
* with {@link OpenAPIOperationExecutorOptions.captureBodies}.
|
|
2036
|
+
*/
|
|
2037
|
+
readonly body?: unknown;
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
/**
|
|
2042
|
+
* The request about to be handed to the {@link HTTPClient}, after every
|
|
2043
|
+
* request interceptor ran, as it is sent: credentials included, like the
|
|
2044
|
+
* request an interceptor receives. Mask it with {@link Redactor} before it
|
|
2045
|
+
* leaves the process.
|
|
2046
|
+
* @public
|
|
2047
|
+
*/
|
|
2048
|
+
export declare interface OpenAPIOperationRequestStartEvent extends OpenAPIOperationEventBase {
|
|
2049
|
+
readonly type: 'openapi:operation:request:start';
|
|
2050
|
+
readonly request: {
|
|
2051
|
+
readonly method: string;
|
|
2052
|
+
readonly url: string;
|
|
2053
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
2054
|
+
/**
|
|
2055
|
+
* The body as handed to the {@link HTTPClient}: JSON or form text, or a
|
|
2056
|
+
* `FormData`, `Blob` or stream. Only with
|
|
2057
|
+
* {@link OpenAPIOperationExecutorOptions.captureBodies}.
|
|
2058
|
+
*/
|
|
2059
|
+
readonly body?: unknown;
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Response from an OpenAPI operation execution.
|
|
2065
|
+
*
|
|
2066
|
+
* `body` is the payload parsed by its content type, what `$response.body`
|
|
2067
|
+
* reads. The body as received is read through `text()`, `blob()` and
|
|
2068
|
+
* `bytes()`, named after the WHATWG `Response` methods but synchronous, and
|
|
2069
|
+
* empty when the response carried no body (e.g. `204`, `304`). `bytes()` and
|
|
2070
|
+
* `blob()` always return the bytes received. A body that is valid UTF-8 is held
|
|
2071
|
+
* as its decoded string, which a plain-text or XML `body` shares rather than
|
|
2072
|
+
* duplicates, and is encoded back on read; any other body is held as bytes.
|
|
2073
|
+
* @public
|
|
2074
|
+
*/
|
|
2075
|
+
export declare class OpenAPIOperationResponse {
|
|
2076
|
+
#private;
|
|
2077
|
+
readonly ok: boolean;
|
|
2078
|
+
readonly url: string;
|
|
2079
|
+
readonly status: number;
|
|
2080
|
+
readonly statusText: string;
|
|
2081
|
+
readonly headers: Record<string, string>;
|
|
2082
|
+
readonly body: unknown;
|
|
2083
|
+
readonly request: OpenAPIOperationRequestInfo | undefined;
|
|
2084
|
+
constructor(raw: {
|
|
2085
|
+
ok: boolean;
|
|
2086
|
+
url: string;
|
|
2087
|
+
status: number;
|
|
2088
|
+
statusText: string;
|
|
2089
|
+
headers: Record<string, string>;
|
|
2090
|
+
body: unknown;
|
|
2091
|
+
content: string | Uint8Array;
|
|
2092
|
+
request?: OpenAPIOperationRequestInfo;
|
|
2093
|
+
});
|
|
2094
|
+
/**
|
|
2095
|
+
* The body's size in bytes, as read: after the transport decoded any
|
|
2096
|
+
* `Content-Encoding`, so a compressed body counts at its decoded size.
|
|
2097
|
+
*/
|
|
2098
|
+
get size(): number;
|
|
2099
|
+
/**
|
|
2100
|
+
* The body as text, like `Response.text()`; `''` when there is none.
|
|
2101
|
+
*/
|
|
2102
|
+
text(): string;
|
|
2103
|
+
/**
|
|
2104
|
+
* The body as a `Blob` typed by the response's `Content-Type`, like
|
|
2105
|
+
* `Response.blob()`.
|
|
2106
|
+
*/
|
|
2107
|
+
blob(): Blob;
|
|
2108
|
+
/**
|
|
2109
|
+
* The body as bytes, like `Response.bytes()`; a fresh copy on every call, so
|
|
2110
|
+
* the response stays immutable.
|
|
2111
|
+
*/
|
|
2112
|
+
bytes(): Uint8Array;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* Normalizes a raw WHATWG `Response` into an {@link OpenAPIOperationResponse}.
|
|
2117
|
+
*
|
|
2118
|
+
* Wraps the vendored swagger-client response deserializer (upstream
|
|
2119
|
+
* `serializeRes`, aliased at the vendor boundary), whose battle-tested
|
|
2120
|
+
* content-type dispatch (JSON/XML/YAML/text vs binary) means the response
|
|
2121
|
+
* model runtime expressions and criteria see is defined here, on the runner's
|
|
2122
|
+
* side of the {@link HTTPClient} seam, and stays identical across transports.
|
|
2123
|
+
* Headers are taken from the `Response` directly rather than from the
|
|
2124
|
+
* deserializer, which splits every value containing `", "` into an array:
|
|
2125
|
+
* values stay strings as sent, with repeated fields (`Set-Cookie` included)
|
|
2126
|
+
* combined by `Headers.get`. The body is read once, as bytes, and handed to the
|
|
2127
|
+
* deserializer from memory. A body that decodes as UTF-8 without loss is kept
|
|
2128
|
+
* as that one string, the same one the deserializer parses, so a plain-text or
|
|
2129
|
+
* XML `body` shares it; any other body (binary, another charset, a leading
|
|
2130
|
+
* byte-order mark) is kept as the bytes, so they are never re-encoded lossily.
|
|
2131
|
+
* @public
|
|
2132
|
+
*/
|
|
2133
|
+
export declare class OpenAPIOperationResponseNormalizer {
|
|
2134
|
+
#private;
|
|
2135
|
+
/**
|
|
2136
|
+
* Deserializes the response body by content type and maps the result into the
|
|
2137
|
+
* runner's response model. `request` is the request the operation was
|
|
2138
|
+
* executed with; its `url` doubles as the fallback when the `Response`
|
|
2139
|
+
* carries none (e.g. a stubbed transport).
|
|
2140
|
+
*/
|
|
2141
|
+
normalize(response: Response, request?: OpenAPIOperationRequestInfo): Promise<OpenAPIOperationResponse>;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* Credentials for the security schemes of an OpenAPI document, keyed by the
|
|
2146
|
+
* scheme name under `components.securitySchemes` (`securityDefinitions` in
|
|
2147
|
+
* OpenAPI 2.0).
|
|
2148
|
+
* @public
|
|
2149
|
+
*/
|
|
2150
|
+
export declare interface OpenAPIOperationSecurities {
|
|
2151
|
+
readonly authorized: Readonly<Record<string, OpenAPIOperationSecurityCredential>>;
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* The credential for one security scheme, in the form the vendored
|
|
2156
|
+
* swagger-client applies it: the key or token itself (or `{ value }`) for an
|
|
2157
|
+
* `apiKey` or an `http` bearer scheme, `{ username, password }` for an `http`
|
|
2158
|
+
* basic scheme, and `{ token: { access_token, token_type } }` for an `oauth2`
|
|
2159
|
+
* or `openIdConnect` scheme.
|
|
2160
|
+
* @public
|
|
2161
|
+
*/
|
|
2162
|
+
export declare type OpenAPIOperationSecurityCredential = string | {
|
|
2163
|
+
readonly value: string;
|
|
2164
|
+
} | {
|
|
2165
|
+
readonly username: string;
|
|
2166
|
+
readonly password: string;
|
|
2167
|
+
} | {
|
|
2168
|
+
readonly token: Readonly<Record<string, string>>;
|
|
2169
|
+
};
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* A source description as an Arazzo document declares it: its `name`, and the
|
|
2173
|
+
* URI of the Arazzo document that declares it. Names are local to their
|
|
2174
|
+
* document, so the pair identifies one source description across a run.
|
|
2175
|
+
* @public
|
|
2176
|
+
*/
|
|
2177
|
+
export declare interface OpenAPIOperationSourceDescription {
|
|
2178
|
+
readonly name: string;
|
|
2179
|
+
readonly documentURI: string;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
/**
|
|
2183
|
+
* Union of PathItemElement across all supported OpenAPI versions.
|
|
2184
|
+
* @public
|
|
2185
|
+
*/
|
|
2186
|
+
export declare type OpenAPIPathItemElement = PathItemElement | PathItemElement_2 | PathItemElement_3;
|
|
2187
|
+
|
|
2188
|
+
/**
|
|
2189
|
+
* Unique identifier of an OpenAPI operation.
|
|
2190
|
+
* @public
|
|
2191
|
+
*/
|
|
2192
|
+
export declare type OperationId = string;
|
|
2193
|
+
|
|
2194
|
+
/**
|
|
2195
|
+
* Resolves a step's or workflow's `outputs` to a plain map of name → value.
|
|
2196
|
+
*
|
|
2197
|
+
* The spec types `outputs` as `Map[string, {expression}]`, so a whole runtime
|
|
2198
|
+
* expression is the *only* authored form — unlike a parameter's `value` or a
|
|
2199
|
+
* `requestBody` payload (typed `Any`), where {@link ArazzoValueResolver} lets a
|
|
2200
|
+
* literal through. An output that is not a valid runtime expression is an
|
|
2201
|
+
* authoring error and throws a {@link ResolverError}.
|
|
2202
|
+
*
|
|
2203
|
+
* The result is the map an executor stores into the workflow execution state so
|
|
2204
|
+
* later steps can read `$steps.{id}.outputs.{name}` / `$outputs.{name}`.
|
|
2205
|
+
* @public
|
|
2206
|
+
*/
|
|
2207
|
+
export declare class OutputResolver extends ArazzoValueResolver {
|
|
2208
|
+
/**
|
|
2209
|
+
* Resolves each output value, returning a `name` → value map. Returns an empty
|
|
2210
|
+
* object when there are no outputs.
|
|
2211
|
+
*
|
|
2212
|
+
* `scope` names the step or workflow the outputs belong to, for a thrown
|
|
2213
|
+
* {@link ResolverError}. An output value that is not a valid runtime
|
|
2214
|
+
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
2215
|
+
*/
|
|
2216
|
+
resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Promise<Record<string, unknown>>;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* Masks credentials in events before they leave the process.
|
|
2221
|
+
*
|
|
2222
|
+
* Events carry what the run saw, credentials included, like the request a
|
|
2223
|
+
* request interceptor receives. Pass every event through
|
|
2224
|
+
* {@link Redactor.event} before logging, exporting or writing it.
|
|
2225
|
+
*
|
|
2226
|
+
* It masks by name, whatever the event:
|
|
2227
|
+
*
|
|
2228
|
+
* - the value of any field whose name matches a pattern: headers, query
|
|
2229
|
+
* parameters, body and output fields, at any depth;
|
|
2230
|
+
* - a criterion value whose runtime expression reads a matching name, in its
|
|
2231
|
+
* base or in any token of its JSON Pointer (`$inputs.password`,
|
|
2232
|
+
* `$steps.login.outputs.token#/value`);
|
|
2233
|
+
* - in every absolute URL, as `URL` parses it, the userinfo and the matching
|
|
2234
|
+
* query and fragment parameters;
|
|
2235
|
+
* - a request or response body that is JSON or a URL-encoded form, field by
|
|
2236
|
+
* field, and any other body, or any object that is not plain data, whole.
|
|
2237
|
+
*
|
|
2238
|
+
* A settled event's `error` is carried as it is, the error `execute` rejects
|
|
2239
|
+
* with. A credential under a name no pattern matches is carried as it is. The
|
|
2240
|
+
* masked value is `REDACTED`.
|
|
2241
|
+
* @public
|
|
2242
|
+
*/
|
|
2243
|
+
export declare class Redactor {
|
|
2244
|
+
#private;
|
|
2245
|
+
static readonly CENSOR = "REDACTED";
|
|
2246
|
+
/**
|
|
2247
|
+
* Elastic APM's `sanitizeFieldNames` defaults, with `*secret*` for its exact
|
|
2248
|
+
* `secret` (which misses OAuth's `client_secret`), plus the signed-URL query
|
|
2249
|
+
* parameters OpenTelemetry's HTTP conventions mask.
|
|
2250
|
+
*/
|
|
2251
|
+
static readonly defaultFields: readonly string[];
|
|
2252
|
+
constructor(options?: RedactorOptions);
|
|
2253
|
+
/**
|
|
2254
|
+
* A masked copy of the event.
|
|
2255
|
+
*/
|
|
2256
|
+
event<E extends ArazzoRunnerEvent>(event: E): E;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
/**
|
|
2260
|
+
* Options for the Redactor.
|
|
2261
|
+
* @public
|
|
2262
|
+
*/
|
|
2263
|
+
export declare interface RedactorOptions {
|
|
2264
|
+
/**
|
|
2265
|
+
* Wildcard patterns of the names whose values are masked. `*` matches any
|
|
2266
|
+
* run of characters; matching is case-insensitive and against the whole
|
|
2267
|
+
* name, so `*token*` matches `access_token` and `X-Auth-Token`. The list
|
|
2268
|
+
* replaces {@link Redactor.defaultFields}; spread it to extend it.
|
|
2269
|
+
*/
|
|
2270
|
+
readonly fields?: readonly string[];
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Evaluates a `regex` Arazzo criterion condition against a resolved context value.
|
|
2275
|
+
*
|
|
2276
|
+
* The Arazzo specification does not pin a regular expression dialect for the
|
|
2277
|
+
* `regex` criterion type. This evaluator uses ECMA-262 (the native `RegExp`
|
|
2278
|
+
* dialect), matching OpenAPI, which pins ECMA-262 for `pattern` via JSON Schema.
|
|
2279
|
+
* The pattern is applied with search (not full-match) semantics — anchoring is
|
|
2280
|
+
* the author's responsibility via `^`/`$`, consistent with the spec's `^200$`
|
|
2281
|
+
* example.
|
|
2282
|
+
*
|
|
2283
|
+
* Per Arazzo 1.1.0, a `null` or `undefined` context fails the condition. A
|
|
2284
|
+
* non-scalar context is serialized with `JSON.stringify` (matching how the
|
|
2285
|
+
* runtime expression evaluator stringifies values for interpolation), so a
|
|
2286
|
+
* pattern can match against an object/array body; scalars are coerced with
|
|
2287
|
+
* `String()`.
|
|
2288
|
+
*
|
|
2289
|
+
* The pattern is a native `RegExp`, which has no execution timeout; a
|
|
2290
|
+
* pathological author pattern (catastrophic backtracking) against a long
|
|
2291
|
+
* context can stall. Patterns originate from the Arazzo document, so this is
|
|
2292
|
+
* treated as trusted input rather than guarded here.
|
|
2293
|
+
* @public
|
|
2294
|
+
*/
|
|
2295
|
+
export declare class RegexCriterionEvaluator {
|
|
2296
|
+
#private;
|
|
2297
|
+
/**
|
|
2298
|
+
* Tests the resolved context value against the regular expression `condition`.
|
|
2299
|
+
*
|
|
2300
|
+
* The context is coerced to a string before matching. Returns `false` when the
|
|
2301
|
+
* context is `null` or `undefined`. Throws {@link CriterionEvaluationError} when the
|
|
2302
|
+
* condition is not a valid regular expression.
|
|
2303
|
+
*/
|
|
2304
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* Resolves a step's `requestBody` to a concrete payload.
|
|
2309
|
+
*
|
|
2310
|
+
* The `payload` is resolved first. Per the specification it "can contain"
|
|
2311
|
+
* runtime expressions, so it is walked: every string in it — the payload
|
|
2312
|
+
* itself, or any value nested in its objects and arrays — that is a whole
|
|
2313
|
+
* runtime expression resolves to its typed value, and every other string has
|
|
2314
|
+
* its embedded `{expression}` occurrences interpolated (tolerantly, so literal
|
|
2315
|
+
* braces such as a JSON template's own are kept). Object keys and resolved
|
|
2316
|
+
* values are never evaluated.
|
|
2317
|
+
*
|
|
2318
|
+
* An unresolved expression reads as "not provided": an object member is
|
|
2319
|
+
* omitted, while a whole-expression payload, an array element or an embedded
|
|
2320
|
+
* expression — none of which can be omitted — throws {@link ResolverError}
|
|
2321
|
+
* (`unresolved-expression`), as does an invalid embedded expression
|
|
2322
|
+
* (`invalid-expression`).
|
|
2323
|
+
*
|
|
2324
|
+
* Then each `replacements` entry is applied — its `value` is resolved by the
|
|
2325
|
+
* family-wide literal-vs-expression rule of {@link ArazzoValueResolver} and set
|
|
2326
|
+
* into the payload at the replacement's `target` JSON Pointer. A replacement
|
|
2327
|
+
* whose value does not resolve is skipped, leaving the payload as authored.
|
|
2328
|
+
*
|
|
2329
|
+
* `target` may be a JSON Pointer or an XPath per the specification; only JSON
|
|
2330
|
+
* Pointer targets are supported — an XPath target throws {@link ResolverError}.
|
|
2331
|
+
* @public
|
|
2332
|
+
*/
|
|
2333
|
+
export declare class RequestBodyResolver extends ArazzoValueResolver {
|
|
2334
|
+
#private;
|
|
2335
|
+
/**
|
|
2336
|
+
* Resolves the request body, returning its payload and content type. Returns
|
|
2337
|
+
* `undefined` when there is no request body.
|
|
2338
|
+
*
|
|
2339
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
2340
|
+
*/
|
|
2341
|
+
resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<ResolvedRequestBody | undefined>;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
/**
|
|
2345
|
+
* Identifies the request a {@link RequestInterceptor} receives, so an
|
|
2346
|
+
* interceptor can target one operation or one step without matching on the
|
|
2347
|
+
* expanded URL.
|
|
2348
|
+
*
|
|
2349
|
+
* `operation` is always present: it is the operation's locator — its canonical
|
|
2350
|
+
* OpenAPI document URI, the JSON Pointer to it and, when the locator carries
|
|
2351
|
+
* one, the source description it was located through — plus the `operationId`
|
|
2352
|
+
* the document declares, if any. `step` is present only when the request is
|
|
2353
|
+
* issued for an Arazzo step, i.e. through the step executor (and so the runner); an
|
|
2354
|
+
* {@link OpenAPIOperationExecutor} used on its own receives it only when its
|
|
2355
|
+
* caller passes `step` in the execute options. Absent fields are omitted, never
|
|
2356
|
+
* `undefined`.
|
|
2357
|
+
* @public
|
|
2358
|
+
*/
|
|
2359
|
+
export declare interface RequestContext {
|
|
2360
|
+
readonly operation: {
|
|
2361
|
+
readonly documentURI: string;
|
|
2362
|
+
readonly jsonPointer: string;
|
|
2363
|
+
readonly operationId?: string;
|
|
2364
|
+
readonly sourceDescription?: OpenAPIOperationSourceDescription;
|
|
2365
|
+
};
|
|
2366
|
+
readonly step?: RequestContextStep;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
/**
|
|
2370
|
+
* The Arazzo step a request is issued for: its `stepId`, and the `workflowId`
|
|
2371
|
+
* of the workflow it belongs to when the caller names one (step ids are only
|
|
2372
|
+
* unique within a workflow).
|
|
2373
|
+
* @public
|
|
2374
|
+
*/
|
|
2375
|
+
export declare interface RequestContextStep {
|
|
2376
|
+
readonly stepId: string;
|
|
2377
|
+
readonly workflowId?: string;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
/**
|
|
2381
|
+
* Decorates the built request before it is handed to the {@link HTTPClient}.
|
|
2382
|
+
*
|
|
2383
|
+
* Receives the finalized {@link OpenAPIOperationRequest} and may mutate it in
|
|
2384
|
+
* place or return a replacement; returning nothing keeps the received request.
|
|
2385
|
+
* May be synchronous or asynchronous. The second argument identifies what the
|
|
2386
|
+
* request is for (see {@link RequestContext}); an interceptor that has no use
|
|
2387
|
+
* for it may declare only the first.
|
|
2388
|
+
*
|
|
2389
|
+
* Interceptors run after the body is serialized (a plain-object or array body
|
|
2390
|
+
* is already a JSON string, so a signature covers the exact bytes sent) and
|
|
2391
|
+
* after newlines in header values are squashed, and before the request is
|
|
2392
|
+
* captured for `$request.*` and handed to the transport.
|
|
2393
|
+
* @public
|
|
2394
|
+
*/
|
|
2395
|
+
export declare type RequestInterceptor = (request: OpenAPIOperationRequest, context: RequestContext) => OpenAPIOperationRequest | void | Promise<OpenAPIOperationRequest | void>;
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* A resolved request body: the payload with all replacements applied, plus the
|
|
2399
|
+
* declared content type when present.
|
|
2400
|
+
* @public
|
|
2401
|
+
*/
|
|
2402
|
+
export declare interface ResolvedRequestBody {
|
|
2403
|
+
readonly payload: unknown;
|
|
2404
|
+
readonly contentType?: string;
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
/**
|
|
2408
|
+
* Carries a `reason`, one of the class's static reason fields.
|
|
2409
|
+
*
|
|
2410
|
+
* Every static on this class is a reason: {@link ResolverErrorReason} is
|
|
2411
|
+
* derived from the class's own statics, so a non-reason static would join the
|
|
2412
|
+
* union.
|
|
2413
|
+
* @public
|
|
2414
|
+
*/
|
|
2415
|
+
export declare class ResolverError extends ArazzoRunnerError {
|
|
2416
|
+
/**
|
|
2417
|
+
* A parameter of a Success / Failure Action declares an `in` inline, which
|
|
2418
|
+
* the Arazzo Specification forbids; one inherited from a
|
|
2419
|
+
* `$components.parameters` Reusable Object maps by name instead. Thrown
|
|
2420
|
+
* before the workflow's first request.
|
|
2421
|
+
*/
|
|
2422
|
+
static readonly ActionParameterLocation: "action-parameter-location";
|
|
2423
|
+
/** A parameter cannot be delivered unambiguously at its location. */
|
|
2424
|
+
static readonly AmbiguousDelivery: "ambiguous-delivery";
|
|
2425
|
+
/** An output or a request body payload holds a value that is not a valid runtime expression. */
|
|
2426
|
+
static readonly InvalidExpression: "invalid-expression";
|
|
2427
|
+
/** A parameter's location (`in`) is not one of the known locations. */
|
|
2428
|
+
static readonly InvalidLocation: "invalid-location";
|
|
2429
|
+
/** An `onSuccess`/`onFailure` list holds an entry that is not a Success/Failure Action Object. */
|
|
2430
|
+
static readonly MalformedActionEntry: "malformed-action-entry";
|
|
2431
|
+
/** A step's `onSuccess` or `onFailure` is present but is not a list. */
|
|
2432
|
+
static readonly MalformedActions: "malformed-actions";
|
|
2433
|
+
/** A step's `successCriteria` or an action's `criteria` is present but is not a list. */
|
|
2434
|
+
static readonly MalformedCriteria: "malformed-criteria";
|
|
2435
|
+
/** A criteria list holds an entry that is not a Criterion Object. */
|
|
2436
|
+
static readonly MalformedCriterion: "malformed-criterion";
|
|
2437
|
+
/** A parameter's location (`in`) is not a string. */
|
|
2438
|
+
static readonly MalformedLocation: "malformed-location";
|
|
2439
|
+
/** A step's or workflow's `outputs` is present but is not a map. */
|
|
2440
|
+
static readonly MalformedOutputs: "malformed-outputs";
|
|
2441
|
+
/** `parameters` is present but is not a list. */
|
|
2442
|
+
static readonly MalformedParameters: "malformed-parameters";
|
|
2443
|
+
/** `requestBody.replacements` is present but is not a list. */
|
|
2444
|
+
static readonly MalformedReplacements: "malformed-replacements";
|
|
2445
|
+
/** `requestBody` is present but is not a map. */
|
|
2446
|
+
static readonly MalformedRequestBody: "malformed-request-body";
|
|
2447
|
+
/** A parameter of a step that targets an operation declares no location (`in`). */
|
|
2448
|
+
static readonly MissingLocation: "missing-location";
|
|
2449
|
+
/** A parameter has a missing or non-string `name`. */
|
|
2450
|
+
static readonly MissingName: "missing-name";
|
|
2451
|
+
/** A runtime expression in the request body did not resolve. */
|
|
2452
|
+
static readonly UnresolvedExpression: "unresolved-expression";
|
|
2453
|
+
/** A `requestBody` replacement target does not resolve in the payload. */
|
|
2454
|
+
static readonly UnresolvedTarget: "unresolved-target";
|
|
2455
|
+
/** A `requestBody` replacement target is not a JSON Pointer. */
|
|
2456
|
+
static readonly UnsupportedTarget: "unsupported-target";
|
|
2457
|
+
readonly stepId?: string;
|
|
2458
|
+
readonly workflowId?: string;
|
|
2459
|
+
readonly target?: string;
|
|
2460
|
+
readonly reason?: ResolverErrorReason;
|
|
2461
|
+
constructor(message?: string, options?: ApiDOMErrorOptions & {
|
|
2462
|
+
readonly reason?: ResolverErrorReason;
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* One of the reasons a {@link ResolverError} carries: a `ResolverError`
|
|
2468
|
+
* static such as `ResolverError.MalformedParameters`.
|
|
2469
|
+
* @public
|
|
2470
|
+
*/
|
|
2471
|
+
export declare type ResolverErrorReason = (typeof ResolverError)[Exclude<keyof typeof ResolverError, keyof typeof ArazzoRunnerError | 'prototype'>];
|
|
2472
|
+
|
|
2473
|
+
/**
|
|
2474
|
+
* Identifies the step or workflow a resolver is resolving for. The wider
|
|
2475
|
+
* union {@link OutputResolver} takes, since it resolves both a step's
|
|
2476
|
+
* `outputs` and a workflow's — the one case with no step to name.
|
|
2477
|
+
* @public
|
|
2478
|
+
*/
|
|
2479
|
+
export declare type ResolverScope = StepScope | {
|
|
2480
|
+
readonly workflowId: string;
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* One run of a `retry` action's `stepId` / `workflowId` reference — "the
|
|
2485
|
+
* reference is executed and the context is returned, after which the current
|
|
2486
|
+
* step is retried". Fires once per firing of its action (i.e. once before every
|
|
2487
|
+
* attempt the action grants, not once for the whole retry chain).
|
|
2488
|
+
* @public
|
|
2489
|
+
*/
|
|
2490
|
+
export declare interface RetryReferenceRecord {
|
|
2491
|
+
/**
|
|
2492
|
+
* Which field the action carried: `stepId` runs one step of the current
|
|
2493
|
+
* workflow; `workflowId` runs another workflow to completion.
|
|
2494
|
+
*/
|
|
2495
|
+
readonly kind: 'step' | 'workflow';
|
|
2496
|
+
/**
|
|
2497
|
+
* The referenced `stepId` or `workflowId`, as written — a cross-document
|
|
2498
|
+
* workflow reference stays in its
|
|
2499
|
+
* `$sourceDescriptions.{name}.{workflowId}` form.
|
|
2500
|
+
*/
|
|
2501
|
+
readonly id: string;
|
|
2502
|
+
/**
|
|
2503
|
+
* Whether the reference completed successfully. For `kind: 'workflow'`, this
|
|
2504
|
+
* is whether the referenced run's transfer chain settled `status !== 'failed'`
|
|
2505
|
+
* — a reference to a workflow that transferred is judged by where control
|
|
2506
|
+
* ended up, not by the intermediate `'transferred'` status. Does not gate the
|
|
2507
|
+
* retry: the retry proceeds either way, since the spec speaks of the
|
|
2508
|
+
* reference's *completion*, not its success.
|
|
2509
|
+
*/
|
|
2510
|
+
readonly successful: boolean;
|
|
2511
|
+
/**
|
|
2512
|
+
* The nested run, when the reference invoked a workflow — either directly
|
|
2513
|
+
* (`kind: 'workflow'`) or because the referenced step itself targets a
|
|
2514
|
+
* `workflowId` (`kind: 'step'`).
|
|
2515
|
+
*/
|
|
2516
|
+
readonly subWorkflow?: WorkflowExecutionResult;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* A `retry` action's reference completed.
|
|
2521
|
+
* @public
|
|
2522
|
+
*/
|
|
2523
|
+
export declare interface RetryReferenceSettledEvent extends WorkflowExecutionStepEventBase {
|
|
2524
|
+
readonly type: 'retry:reference:settled';
|
|
2525
|
+
readonly attempt: number;
|
|
2526
|
+
readonly kind: RetryReferenceRecord['kind'];
|
|
2527
|
+
readonly id: RetryReferenceRecord['id'];
|
|
2528
|
+
readonly successful: RetryReferenceRecord['successful'];
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* A `retry` action's `stepId` / `workflowId` reference is about to run.
|
|
2533
|
+
* @public
|
|
2534
|
+
*/
|
|
2535
|
+
export declare interface RetryReferenceStartEvent extends WorkflowExecutionStepEventBase {
|
|
2536
|
+
readonly type: 'retry:reference:start';
|
|
2537
|
+
/**
|
|
2538
|
+
* Where the `retry` action that names the reference is written.
|
|
2539
|
+
*/
|
|
2540
|
+
readonly location: DocumentLocation;
|
|
2541
|
+
readonly attempt: number;
|
|
2542
|
+
readonly kind: RetryReferenceRecord['kind'];
|
|
2543
|
+
readonly id: RetryReferenceRecord['id'];
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
/**
|
|
2547
|
+
* The run is about to wait out a `retry` action's `retryAfter` before the
|
|
2548
|
+
* step's next attempt. Fired only for a positive delay.
|
|
2549
|
+
* @public
|
|
2550
|
+
*/
|
|
2551
|
+
export declare interface RetryWaitEvent extends WorkflowExecutionStepEventBase {
|
|
2552
|
+
readonly type: 'retry:wait';
|
|
2553
|
+
readonly attempt: number;
|
|
2554
|
+
readonly delayMs: number;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
/**
|
|
2558
|
+
* Identifies a step that calls a workflow, for the context its criteria,
|
|
2559
|
+
* outputs and actions are evaluated against.
|
|
2560
|
+
* @public
|
|
2561
|
+
*/
|
|
2562
|
+
export declare interface RuntimeExpressionCalledWorkflowContext {
|
|
2563
|
+
/**
|
|
2564
|
+
* The id of the calling step, the one whose expressions are evaluated.
|
|
2565
|
+
*/
|
|
2566
|
+
readonly stepId: string;
|
|
2567
|
+
/**
|
|
2568
|
+
* The id of the workflow that step called.
|
|
2569
|
+
*/
|
|
2570
|
+
readonly workflowId: string;
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
/**
|
|
2574
|
+
* The runtime state an Arazzo runtime expression is evaluated against.
|
|
2575
|
+
*
|
|
2576
|
+
* Each field maps to an AST node produced by the runtime expression parser:
|
|
2577
|
+
* - `request.url` / `request.method` back `$url` / `$method`
|
|
2578
|
+
* - `request.header` / `.query` / `.path` / `.body` back `$request.{source}`
|
|
2579
|
+
* - `response.statusCode` backs `$statusCode`
|
|
2580
|
+
* - `response.header` / `.body` back `$response.{source}`
|
|
2581
|
+
* - `inputs` backs `$inputs.{name}`
|
|
2582
|
+
* - `outputs` backs `$outputs.{name}`
|
|
2583
|
+
* - `steps` backs `$steps.{stepId}.outputs.{name}`
|
|
2584
|
+
* - `workflows` backs `$workflows.{workflowId}.{inputs|outputs}.{name}`
|
|
2585
|
+
* - `calledWorkflow` marks a step that calls a workflow: such a step made no
|
|
2586
|
+
* HTTP call, so `$url`, `$method`, `$statusCode`, `$request.{source}` and
|
|
2587
|
+
* `$response.{source}` are authoring errors there rather than unresolved
|
|
2588
|
+
* references, and `outputs` holds the called workflow's outputs
|
|
2589
|
+
*
|
|
2590
|
+
* The context holds only genuinely runtime state. Static, document-sourced
|
|
2591
|
+
* expressions — `$components.{field}.{name}` and
|
|
2592
|
+
* `$sourceDescriptions.{name}.{reference}` — are resolved on demand by the
|
|
2593
|
+
* evaluator against the document registry, not carried here.
|
|
2594
|
+
*
|
|
2595
|
+
* Payload-bearing values (`request.body`, `response.body`, step/workflow output
|
|
2596
|
+
* values) are drilled through a composed JSON Pointer realm, so they may be
|
|
2597
|
+
* either plain JS values or ApiDOM elements.
|
|
2598
|
+
* @public
|
|
2599
|
+
*/
|
|
2600
|
+
export declare interface RuntimeExpressionContext {
|
|
2601
|
+
readonly request?: RuntimeExpressionRequestContext;
|
|
2602
|
+
readonly response?: RuntimeExpressionResponseContext;
|
|
2603
|
+
readonly inputs?: unknown;
|
|
2604
|
+
readonly outputs?: unknown;
|
|
2605
|
+
readonly steps?: Record<string, RuntimeExpressionStepContext>;
|
|
2606
|
+
readonly workflows?: Record<string, RuntimeExpressionWorkflowContext>;
|
|
2607
|
+
readonly calledWorkflow?: RuntimeExpressionCalledWorkflowContext;
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* Carries a `reason`, one of the class's static reason fields.
|
|
2612
|
+
*
|
|
2613
|
+
* Every static on this class is a reason: {@link RuntimeExpressionErrorReason}
|
|
2614
|
+
* is derived from the class's own statics, so a non-reason static would join
|
|
2615
|
+
* the union.
|
|
2616
|
+
* @public
|
|
2617
|
+
*/
|
|
2618
|
+
export declare class RuntimeExpressionError extends ArazzoRunnerError {
|
|
2619
|
+
/** The expression is not a valid runtime expression. */
|
|
2620
|
+
static readonly InvalidExpression: "invalid-expression";
|
|
2621
|
+
/** The runtime expression parser failed on the expression. */
|
|
2622
|
+
static readonly ParseError: "parse-error";
|
|
2623
|
+
/**
|
|
2624
|
+
* The expression reads HTTP data (`$statusCode`, `$url`, `$method`, `$request`,
|
|
2625
|
+
* `$response`) in a step that calls a workflow and so made no HTTP call.
|
|
2626
|
+
*/
|
|
2627
|
+
static readonly UnavailableExpression: "unavailable-expression";
|
|
2628
|
+
/** The expression could not be resolved against the evaluation context. */
|
|
2629
|
+
static readonly UnresolvedReference: "unresolved-reference";
|
|
2630
|
+
/** The parsed expression contains a node the evaluator does not support. */
|
|
2631
|
+
static readonly UnsupportedNode: "unsupported-node";
|
|
2632
|
+
readonly expression?: string;
|
|
2633
|
+
readonly reason?: RuntimeExpressionErrorReason;
|
|
2634
|
+
constructor(message?: string, options?: ApiDOMErrorOptions & {
|
|
2635
|
+
readonly reason?: RuntimeExpressionErrorReason;
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
/**
|
|
2640
|
+
* One of the reasons a {@link RuntimeExpressionError} carries: a
|
|
2641
|
+
* `RuntimeExpressionError` static such as `RuntimeExpressionError.ParseError`.
|
|
2642
|
+
* @public
|
|
2643
|
+
*/
|
|
2644
|
+
export declare type RuntimeExpressionErrorReason = (typeof RuntimeExpressionError)[Exclude<keyof typeof RuntimeExpressionError, keyof typeof ArazzoRunnerError | 'prototype'>];
|
|
2645
|
+
|
|
2646
|
+
/**
|
|
2647
|
+
* Evaluates Arazzo runtime expressions against a context.
|
|
2648
|
+
*
|
|
2649
|
+
* A single evaluator is bound to one context and can evaluate many expressions
|
|
2650
|
+
* against it — matching how a step executor resolves a step's parameters,
|
|
2651
|
+
* success criteria, and outputs from the same state.
|
|
2652
|
+
*
|
|
2653
|
+
* The context holds only runtime state (`$inputs`, `$steps`, `$request`,
|
|
2654
|
+
* `$response`, …). Static, document-sourced expressions are resolved on demand:
|
|
2655
|
+
* `$components` and `$workflows.{workflowId}.steps.{stepId}` from the
|
|
2656
|
+
* evaluator's document, and `$sourceDescriptions` from the external document
|
|
2657
|
+
* (via the registry) the source name points at. A step reference resolves to
|
|
2658
|
+
* the Step Object as authored — a locator, not the step's execution result.
|
|
2659
|
+
*
|
|
2660
|
+
* Evaluation is asynchronous because a `$sourceDescriptions` reference may
|
|
2661
|
+
* have to load the document it points at.
|
|
2662
|
+
*
|
|
2663
|
+
* A reference resolves to `undefined` when it is absent. Runtime values
|
|
2664
|
+
* originate from JSON (or ApiDOM), which cannot represent `undefined` — an
|
|
2665
|
+
* absent value is a missing property and an explicit null is `null` — so
|
|
2666
|
+
* `undefined` unambiguously marks "unresolved".
|
|
2667
|
+
*
|
|
2668
|
+
* Three modes are supported:
|
|
2669
|
+
* - {@link RuntimeExpressionEvaluator.evaluate} resolves a pure expression
|
|
2670
|
+
* (e.g. `$response.body#/id`) to its typed value.
|
|
2671
|
+
* - {@link RuntimeExpressionEvaluator.interpolate} renders a template with
|
|
2672
|
+
* embedded `{expression}` occurrences to a string.
|
|
2673
|
+
* - {@link RuntimeExpressionEvaluator.resolve} applies Arazzo "value" semantics:
|
|
2674
|
+
* a value that is itself a complete expression resolves to a typed value,
|
|
2675
|
+
* otherwise the value is interpolated to a string.
|
|
2676
|
+
* @public
|
|
2677
|
+
*/
|
|
2678
|
+
export declare class RuntimeExpressionEvaluator {
|
|
2679
|
+
#private;
|
|
2680
|
+
constructor(context: RuntimeExpressionContext, options?: RuntimeExpressionEvaluatorOptions);
|
|
2681
|
+
/**
|
|
2682
|
+
* Evaluates a pure runtime expression to its typed value.
|
|
2683
|
+
*
|
|
2684
|
+
* The expression must be the bare form without surrounding braces
|
|
2685
|
+
* (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
|
|
2686
|
+
* unresolvable reference throws; otherwise it returns `undefined`.
|
|
2687
|
+
*
|
|
2688
|
+
* A `$sourceDescriptions` reference whose document cannot be loaded is not
|
|
2689
|
+
* merely unresolved: unless it names a field of the Source Description Object,
|
|
2690
|
+
* it rejects with the load error in either mode, since nothing else can
|
|
2691
|
+
* produce its value.
|
|
2692
|
+
*
|
|
2693
|
+
* @throws DocumentLoadError - When a referenced source document cannot be read or loaded
|
|
2694
|
+
* @throws UnmatchedProviderError - When no provider can load a referenced source document
|
|
2695
|
+
*/
|
|
2696
|
+
evaluate(expression: string): Promise<unknown>;
|
|
2697
|
+
/**
|
|
2698
|
+
* Renders a template string, replacing each embedded `{expression}` with the
|
|
2699
|
+
* string form of its evaluated value. Returns a string.
|
|
2700
|
+
*
|
|
2701
|
+
* Object and array values are serialized with `JSON.stringify`. In non-strict
|
|
2702
|
+
* mode, unresolvable references render as an empty string. A `{…}` that is not
|
|
2703
|
+
* a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
|
|
2704
|
+
*/
|
|
2705
|
+
interpolate(template: string): Promise<string>;
|
|
2706
|
+
/**
|
|
2707
|
+
* Resolves an Arazzo "value" string.
|
|
2708
|
+
*
|
|
2709
|
+
* A value that is itself a complete runtime expression (the unbraced form,
|
|
2710
|
+
* e.g. `$inputs.userId`) resolves to its typed value — "runtime expressions
|
|
2711
|
+
* preserve the type of the referenced value". Any other string is an
|
|
2712
|
+
* expression-string template: embedded `{expression}` occurrences are
|
|
2713
|
+
* interpolated and a string is returned, so a whole-string `{expression}`
|
|
2714
|
+
* yields the string representation of its value, not the typed value. A
|
|
2715
|
+
* string containing no expressions is returned unchanged.
|
|
2716
|
+
*/
|
|
2717
|
+
resolve(value: string): Promise<unknown>;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
/**
|
|
2721
|
+
* Options for the RuntimeExpressionEvaluator.
|
|
2722
|
+
* @public
|
|
2723
|
+
*/
|
|
2724
|
+
export declare interface RuntimeExpressionEvaluatorOptions {
|
|
2725
|
+
/**
|
|
2726
|
+
* When `true` (default), an unresolvable reference throws a
|
|
2727
|
+
* RuntimeExpressionError. When `false`, unresolvable references evaluate to
|
|
2728
|
+
* `undefined`. Parse failures always throw regardless of this setting.
|
|
2729
|
+
*/
|
|
2730
|
+
readonly strict?: boolean;
|
|
2731
|
+
/**
|
|
2732
|
+
* The Arazzo document the expression is evaluated within. Required to resolve
|
|
2733
|
+
* `$components.{field}.{name}` and `$workflows.{workflowId}.steps.{stepId}`
|
|
2734
|
+
* (both read from this document) and `$sourceDescriptions.{name}.{reference}`
|
|
2735
|
+
* (whose source name is resolved against this document). Absent references
|
|
2736
|
+
* resolve to `undefined`.
|
|
2737
|
+
*/
|
|
2738
|
+
readonly document?: ArazzoDocument;
|
|
2739
|
+
/**
|
|
2740
|
+
* The document registry, used to reach the external document a
|
|
2741
|
+
* `$sourceDescriptions` reference points at. The document is acquired from
|
|
2742
|
+
* it — returned from its cache, or loaded — whenever the source's `type` is
|
|
2743
|
+
* one the registry can load. Without a registry, `$sourceDescriptions`
|
|
2744
|
+
* resolves against the Source Description Object's own fields only.
|
|
2745
|
+
*/
|
|
2746
|
+
readonly registry?: DocumentRegistry;
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
/**
|
|
2750
|
+
* Request-side data available to runtime expressions.
|
|
2751
|
+
*
|
|
2752
|
+
* Populated by the step executor from the HTTP request that was (or will be) sent.
|
|
2753
|
+
* Header lookup is case-insensitive because the runtime expression parser
|
|
2754
|
+
* lowercases header tokens.
|
|
2755
|
+
* @public
|
|
2756
|
+
*/
|
|
2757
|
+
export declare interface RuntimeExpressionRequestContext {
|
|
2758
|
+
readonly url?: string;
|
|
2759
|
+
readonly method?: string;
|
|
2760
|
+
readonly header?: Record<string, unknown>;
|
|
2761
|
+
readonly query?: Record<string, unknown>;
|
|
2762
|
+
readonly path?: Record<string, unknown>;
|
|
2763
|
+
readonly body?: unknown;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
/**
|
|
2767
|
+
* Resolves a runtime expression to its value, or to a Promise of it.
|
|
2768
|
+
*
|
|
2769
|
+
* Bridged to a lenient runtime expression evaluator
|
|
2770
|
+
* (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
|
|
2771
|
+
* unresolvable reference yields `undefined` rather than throwing; a
|
|
2772
|
+
* `$sourceDescriptions` document that cannot be loaded still rejects with the
|
|
2773
|
+
* load error (see `RuntimeExpressionEvaluator.evaluate`). The result
|
|
2774
|
+
* is awaited, so a synchronous resolver works too.
|
|
2775
|
+
* @public
|
|
2776
|
+
*/
|
|
2777
|
+
export declare type RuntimeExpressionResolver = (expression: string) => unknown;
|
|
2778
|
+
|
|
2779
|
+
/**
|
|
2780
|
+
* Response-side data available to runtime expressions.
|
|
2781
|
+
*
|
|
2782
|
+
* Populated by the step executor from the HTTP response that was received.
|
|
2783
|
+
* Header lookup is case-insensitive because the runtime expression parser
|
|
2784
|
+
* lowercases header tokens.
|
|
2785
|
+
* @public
|
|
2786
|
+
*/
|
|
2787
|
+
export declare interface RuntimeExpressionResponseContext {
|
|
2788
|
+
readonly statusCode?: number;
|
|
2789
|
+
readonly header?: Record<string, unknown>;
|
|
2790
|
+
readonly body?: unknown;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/**
|
|
2794
|
+
* Per-step state available to `$steps.{stepId}.outputs.{name}` expressions.
|
|
2795
|
+
* @public
|
|
2796
|
+
*/
|
|
2797
|
+
export declare interface RuntimeExpressionStepContext {
|
|
2798
|
+
readonly outputs?: Record<string, unknown>;
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
/**
|
|
2802
|
+
* Per-workflow state available to `$workflows.{workflowId}.{inputs|outputs}.{name}` expressions.
|
|
2803
|
+
* @public
|
|
2804
|
+
*/
|
|
2805
|
+
export declare interface RuntimeExpressionWorkflowContext {
|
|
2806
|
+
readonly inputs?: Record<string, unknown>;
|
|
2807
|
+
readonly outputs?: Record<string, unknown>;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
/**
|
|
2811
|
+
* The action selected for a step outcome — a Success or Failure Action element.
|
|
2812
|
+
* @public
|
|
2813
|
+
*/
|
|
2814
|
+
export declare type SelectedAction = SuccessActionElement | FailureActionElement;
|
|
2815
|
+
|
|
2816
|
+
/**
|
|
2817
|
+
* The result a transfer chain settled on: `result` itself when its `status`
|
|
2818
|
+
* isn't `'transferred'`, otherwise the terminal, non-`'transferred'` result at
|
|
2819
|
+
* the end of its `transferredTo` chain.
|
|
2820
|
+
*
|
|
2821
|
+
* For the success/failure verdict alone, prefer
|
|
2822
|
+
* {@link WorkflowExecutionResult.settledStatus} — every result already
|
|
2823
|
+
* carries it, computed eagerly, so no call is needed. Reach for this function
|
|
2824
|
+
* when the terminal result *itself* is wanted (its `outputs`, `steps`,
|
|
2825
|
+
* `workflowId`), not just where it landed. Iterative, not recursive: a
|
|
2826
|
+
* chain's length is bounded only by `maxWorkflowDepth`, and this must not add
|
|
2827
|
+
* a matching bound on call-stack depth.
|
|
2828
|
+
* @public
|
|
2829
|
+
*/
|
|
2830
|
+
export declare function settledResult(result: WorkflowExecutionResult): WorkflowExecutionResult;
|
|
2831
|
+
|
|
2832
|
+
/**
|
|
2833
|
+
* Evaluates a `simple` Arazzo criterion condition.
|
|
2834
|
+
*
|
|
2835
|
+
* A simple condition embeds runtime expressions directly in the condition
|
|
2836
|
+
* (e.g. `$statusCode == 200 && $response.body.status == 'available'`), so —
|
|
2837
|
+
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
2838
|
+
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
2839
|
+
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
2840
|
+
* resolved through the supplied resolver and awaited in turn. `&&` and `||`
|
|
2841
|
+
* short-circuit, so an operand that cannot change the outcome is never
|
|
2842
|
+
* resolved.
|
|
2843
|
+
*
|
|
2844
|
+
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
2845
|
+
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
2846
|
+
* comparisons are false, matching the spec's "null equals only null"), so a
|
|
2847
|
+
* negated or disjunctive condition may still pass. A malformed condition throws
|
|
2848
|
+
* {@link CriterionEvaluationError}.
|
|
2849
|
+
* @public
|
|
2850
|
+
*/
|
|
2851
|
+
export declare class SimpleCriterionEvaluator {
|
|
2852
|
+
/**
|
|
2853
|
+
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
2854
|
+
* expression via `resolve`.
|
|
2855
|
+
*/
|
|
2856
|
+
evaluate(condition: string, resolve: CriterionContextResolver): Promise<boolean>;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
/**
|
|
2860
|
+
* One indexed source description: the parsed element and its canonical URI —
|
|
2861
|
+
* already resolved against the owning document's base URI, in the exact form
|
|
2862
|
+
* the document registry keys on — or `undefined` for a source with no
|
|
2863
|
+
* resolvable `url`.
|
|
2864
|
+
* @public
|
|
2865
|
+
*/
|
|
2866
|
+
export declare interface SourceDescriptionEntry {
|
|
2867
|
+
readonly element: SourceDescriptionElement;
|
|
2868
|
+
readonly uri: string | undefined;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* Unique name of a source description within an Arazzo document.
|
|
2873
|
+
* @public
|
|
2874
|
+
*/
|
|
2875
|
+
export declare type SourceDescriptionName = string;
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* Base of the locator normalizers that resolve
|
|
2879
|
+
* `$sourceDescriptions.{name}.{reference}` runtime expressions — the OpenAPI
|
|
2880
|
+
* operation locator and the Arazzo workflow locator. Owns the registry handle
|
|
2881
|
+
* and the one grammar-facing parse, so the expression node's name and field
|
|
2882
|
+
* shape are encoded once rather than per subclass.
|
|
2883
|
+
* @public
|
|
2884
|
+
*/
|
|
2885
|
+
export declare abstract class SourceDescriptionsLocatorNormalizer {
|
|
2886
|
+
protected readonly registry: DocumentRegistry;
|
|
2887
|
+
constructor(registry: DocumentRegistry);
|
|
2888
|
+
/**
|
|
2889
|
+
* Parses a `$sourceDescriptions.{name}.{reference}` expression, or returns
|
|
2890
|
+
* `undefined` when the string is not one (whether it fails to parse or
|
|
2891
|
+
* parses to another expression kind) — each subclass raises its own error
|
|
2892
|
+
* type, message, and context for its own position.
|
|
2893
|
+
*/
|
|
2894
|
+
protected parseSourceDescriptionsExpression(expression: string): {
|
|
2895
|
+
sourceName: string;
|
|
2896
|
+
reference: string;
|
|
2897
|
+
} | undefined;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
/**
|
|
2901
|
+
* One attempt at a step began, after it was charged to the step budget.
|
|
2902
|
+
* @public
|
|
2903
|
+
*/
|
|
2904
|
+
export declare interface StepAttemptEvent extends WorkflowExecutionStepEventBase {
|
|
2905
|
+
readonly type: 'step:attempt';
|
|
2906
|
+
/**
|
|
2907
|
+
* The attempt number, starting at 1. Each `retry` increments it. The
|
|
2908
|
+
* attempt a `retry` reference makes at another step is that reference's
|
|
2909
|
+
* own, so it is always 1, under the referenced step's `stepId`.
|
|
2910
|
+
*/
|
|
2911
|
+
readonly attempt: number;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
/**
|
|
2915
|
+
* The execute options of a step: the opaque bag forwarded to the operation
|
|
2916
|
+
* executor, or a function returning it for the operation the step was located
|
|
2917
|
+
* to, called with the step it is located for.
|
|
2918
|
+
* @public
|
|
2919
|
+
*/
|
|
2920
|
+
export declare type StepExecuteOptions = Record<string, unknown> | ((locator: OpenAPIOperationLocator, step: RequestContextStep) => Record<string, unknown>);
|
|
2921
|
+
|
|
2922
|
+
/**
|
|
2923
|
+
* The outcome of executing a single step.
|
|
2924
|
+
* @public
|
|
2925
|
+
*/
|
|
2926
|
+
export declare interface StepExecutionResult {
|
|
2927
|
+
readonly stepId: string;
|
|
2928
|
+
readonly response: OpenAPIOperationResponse;
|
|
2929
|
+
readonly successful: boolean;
|
|
2930
|
+
readonly outputs: Record<string, unknown>;
|
|
2931
|
+
/**
|
|
2932
|
+
* The action to take for this outcome — the first of {@link StepExecutionResult.matchedActions},
|
|
2933
|
+
* or `undefined` when none matched (the caller then applies the path default).
|
|
2934
|
+
*/
|
|
2935
|
+
readonly action: SelectedAction | undefined;
|
|
2936
|
+
/**
|
|
2937
|
+
* Every `onSuccess` / `onFailure` action whose criteria matched this outcome,
|
|
2938
|
+
* in list order. Usually the caller acts on `action` (the first); the workflow
|
|
2939
|
+
* executor walks the full list to honor "retryLimit exhausted prior to
|
|
2940
|
+
* subsequent failure actions" — falling from an exhausted `retry` to the next
|
|
2941
|
+
* matching action. Empty when none matched.
|
|
2942
|
+
*/
|
|
2943
|
+
readonly matchedActions: readonly SelectedAction[];
|
|
2944
|
+
/**
|
|
2945
|
+
* The outcome of each of the step's `successCriteria`, in list order.
|
|
2946
|
+
*/
|
|
2947
|
+
readonly successCriteria: readonly CriterionEvaluationRecord[];
|
|
2948
|
+
/**
|
|
2949
|
+
* The outcome of each criterion of the actions the step considered — its
|
|
2950
|
+
* `onSuccess` actions when it succeeded, its `onFailure` actions otherwise —
|
|
2951
|
+
* in list order.
|
|
2952
|
+
*/
|
|
2953
|
+
readonly actionCriteria: readonly CriterionEvaluationRecord[];
|
|
2954
|
+
/**
|
|
2955
|
+
* The runtime-expression context the step's actions are taken in: the
|
|
2956
|
+
* context its action `criteria` were evaluated against, with
|
|
2957
|
+
* `$steps.{stepId}.outputs` holding the outputs this attempt just resolved.
|
|
2958
|
+
*
|
|
2959
|
+
* An action's `parameters` resolve against it, so a `goto` or `retry` naming
|
|
2960
|
+
* a `workflowId` passes values read from this step's response, request and
|
|
2961
|
+
* fresh outputs. The overlay matters because run state is written only once
|
|
2962
|
+
* a step's retry chain settles, so mid-chain it may still hold an earlier
|
|
2963
|
+
* run's outputs.
|
|
2964
|
+
*/
|
|
2965
|
+
readonly actionContext: RuntimeExpressionContext;
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* Executes a single Arazzo step that invokes an OpenAPI operation.
|
|
2970
|
+
*
|
|
2971
|
+
* The pipeline locates the step's operation (`operationId` / `operationPath`),
|
|
2972
|
+
* resolves the step's parameters and request body against the pre-request
|
|
2973
|
+
* context, delegates to {@link OpenAPIOperationExecutor} to run the located
|
|
2974
|
+
* operation, then evaluates `successCriteria`, resolves `outputs`, and selects
|
|
2975
|
+
* the `onSuccess`/`onFailure` action against the post-request context.
|
|
2976
|
+
*
|
|
2977
|
+
* It reads run state through a {@link ContextSource} and mutates nothing — the
|
|
2978
|
+
* caller records the returned outputs and interprets the returned action. A step
|
|
2979
|
+
* targeting a `workflowId` (a sub-workflow) is not an operation step and throws
|
|
2980
|
+
* {@link ExecutionError}; running sub-workflows is the workflow executor's
|
|
2981
|
+
* concern. A received response with unmet criteria is a normal
|
|
2982
|
+
* `successful: false` outcome; malformed input (e.g. an invalid criterion or
|
|
2983
|
+
* expression) throws, as does a run the caller has cancelled through an
|
|
2984
|
+
* `AbortSignal` in the execute options.
|
|
2985
|
+
* @public
|
|
2986
|
+
*/
|
|
2987
|
+
export declare class StepExecutor {
|
|
2988
|
+
#private;
|
|
2989
|
+
constructor(options: StepExecutorOptions);
|
|
2990
|
+
/**
|
|
2991
|
+
* A step executor bound to the given document, sharing this one's registry
|
|
2992
|
+
* and operation executor — this instance itself when the document is
|
|
2993
|
+
* already the one it is bound to.
|
|
2994
|
+
*
|
|
2995
|
+
* A step executor's identity includes the document its steps belong to: a
|
|
2996
|
+
* plain `operationId` resolves against *that* document's source
|
|
2997
|
+
* descriptions, and `$components` / `$sourceDescriptions` expressions
|
|
2998
|
+
* resolve against it too. A cross-document workflow run therefore derives
|
|
2999
|
+
* a sibling per foreign document rather than re-pointing this one.
|
|
3000
|
+
*/
|
|
3001
|
+
forDocument(document: ArazzoDocument): StepExecutor;
|
|
3002
|
+
/**
|
|
3003
|
+
* Executes the step against the given run state, returning its outcome.
|
|
3004
|
+
*
|
|
3005
|
+
* `executeOptions` is an opaque bag passed through to the operation executor
|
|
3006
|
+
* (e.g. a `server` to run the step against, or an `AbortSignal`). The
|
|
3007
|
+
* Arazzo-derived options (`operationId`, `parameters`, `requestBody`) always
|
|
3008
|
+
* take precedence over it. A function is called with the operation the step
|
|
3009
|
+
* was located to and the step's `stepId` / `workflowId`, and returns the bag,
|
|
3010
|
+
* for options that depend on which API the step calls.
|
|
3011
|
+
*
|
|
3012
|
+
* A `signal` in that bag is honored here and not only at the transport: an
|
|
3013
|
+
* already-aborted signal throws with reason `ExecutionError.Aborted` instead of issuing a
|
|
3014
|
+
* request nobody is waiting for, whose wire-level cancellation would surface
|
|
3015
|
+
* as a transport {@link ClientError} — a request that failed on its own terms
|
|
3016
|
+
* — rather than as the withdrawal it is.
|
|
3017
|
+
*
|
|
3018
|
+
* `workflowId` names the workflow the step belongs to; every error raised
|
|
3019
|
+
* here then carries it alongside the `stepId`, since step ids are only
|
|
3020
|
+
* unique within a workflow. The workflow executor always passes it.
|
|
3021
|
+
*/
|
|
3022
|
+
execute(step: StepElement, state: ContextSource, executeOptions?: StepExecuteOptions, workflowId?: string): Promise<StepExecutionResult>;
|
|
3023
|
+
/**
|
|
3024
|
+
* Throws {@link ResolverError} unless the step's `successCriteria` is absent
|
|
3025
|
+
* or a list of Criterion Objects: `malformed-criteria` for one that is
|
|
3026
|
+
* present but not a list, `malformed-criterion` for an entry that is not a
|
|
3027
|
+
* Criterion Object. Skipping an unreadable entry would turn the author's
|
|
3028
|
+
* assertion into a vacuous pass, so it is an authoring error, as an action's
|
|
3029
|
+
* unreadable `criteria` is in {@link ActionResolver}.
|
|
3030
|
+
*
|
|
3031
|
+
* Called before the step's request is sent, so no live side effect precedes
|
|
3032
|
+
* the error. Public because the workflow executor checks every step of a
|
|
3033
|
+
* workflow with it before any of them runs, a step targeting a `workflowId`
|
|
3034
|
+
* included. It passes `workflowId`, which the error then carries: step ids
|
|
3035
|
+
* are only unique within a workflow.
|
|
3036
|
+
*/
|
|
3037
|
+
assertSuccessCriteria(step: StepElement, workflowId?: string): void;
|
|
3038
|
+
/**
|
|
3039
|
+
* Evaluates the step's `successCriteria`, returning one record per criterion
|
|
3040
|
+
* in list order; the step succeeds when every record is met. Every criterion
|
|
3041
|
+
* is evaluated, so the records explain each unmet one, not only the first. A
|
|
3042
|
+
* step with no criteria returns no records and succeeds on a received
|
|
3043
|
+
* response. An unreadable `successCriteria` throws, see
|
|
3044
|
+
* {@link StepExecutor.assertSuccessCriteria}.
|
|
3045
|
+
*
|
|
3046
|
+
* Public for the same reason as {@link StepExecutor.selectActions}: a step
|
|
3047
|
+
* targeting a `workflowId` is run by the workflow executor and never reaches
|
|
3048
|
+
* {@link StepExecutor.execute}, but its criteria are still the author's
|
|
3049
|
+
* assertion about the step and must be evaluated somewhere. `workflowId`
|
|
3050
|
+
* names the step's workflow on a thrown error, as for
|
|
3051
|
+
* {@link StepExecutor.execute}.
|
|
3052
|
+
*/
|
|
3053
|
+
evaluateCriteria(step: StepElement, context: RuntimeExpressionContext, workflowId?: string): Promise<CriterionEvaluationRecord[]>;
|
|
3054
|
+
/**
|
|
3055
|
+
* Selects every matching `onSuccess` / `onFailure` action for the outcome, in
|
|
3056
|
+
* list order, gating each action's criteria against the context, and records
|
|
3057
|
+
* the outcome of every action criterion evaluated.
|
|
3058
|
+
*
|
|
3059
|
+
* The step's own list is the whole story here: a step that declares none of
|
|
3060
|
+
* its own already carries the workflow-level defaults, inherited by
|
|
3061
|
+
* {@link ArazzoWorkflowNormalizer} — the same place a step's inherited
|
|
3062
|
+
* `parameters` come from — so there is no fallback left to apply at selection
|
|
3063
|
+
* time.
|
|
3064
|
+
*
|
|
3065
|
+
* The full matching list (not just the first) is returned so the caller can
|
|
3066
|
+
* honor "retryLimit exhausted prior to subsequent failure actions"; the common
|
|
3067
|
+
* caller simply takes the first.
|
|
3068
|
+
*
|
|
3069
|
+
* Public because selecting a step's actions is meaningful beyond running one:
|
|
3070
|
+
* the workflow executor selects them for a step targeting a `workflowId`, which
|
|
3071
|
+
* it runs itself and which therefore never reaches
|
|
3072
|
+
* {@link StepExecutor.execute}. Both callers reach the criteria evaluator and
|
|
3073
|
+
* the expression context through this one method rather than wiring their own.
|
|
3074
|
+
* `workflowId` names the step's workflow on a thrown error, as for
|
|
3075
|
+
* {@link StepExecutor.execute}.
|
|
3076
|
+
*/
|
|
3077
|
+
selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Promise<Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>>;
|
|
3078
|
+
/**
|
|
3079
|
+
* The context a step's actions are taken in — see
|
|
3080
|
+
* {@link StepExecutionResult.actionContext}: `context` with
|
|
3081
|
+
* `$steps.{stepId}.outputs` replaced by the outputs the attempt just
|
|
3082
|
+
* resolved, as a fresh object, so run state is never written.
|
|
3083
|
+
*
|
|
3084
|
+
* Public for the same reason as {@link StepExecutor.selectActions}: the
|
|
3085
|
+
* workflow executor builds this context for a step targeting a
|
|
3086
|
+
* `workflowId`, which never reaches {@link StepExecutor.execute}.
|
|
3087
|
+
*/
|
|
3088
|
+
actionContext(context: RuntimeExpressionContext, stepId: string, outputs: Record<string, unknown>): RuntimeExpressionContext;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
/**
|
|
3092
|
+
* Options for the StepExecutor.
|
|
3093
|
+
* @public
|
|
3094
|
+
*/
|
|
3095
|
+
export declare interface StepExecutorOptions {
|
|
3096
|
+
/**
|
|
3097
|
+
* The Arazzo document the steps belong to — typically the entry document;
|
|
3098
|
+
* used to resolve each step's operation locator against its source
|
|
3099
|
+
* descriptions, and to resolve `$components` / `$sourceDescriptions` in
|
|
3100
|
+
* expressions. For a step of a workflow in another document, derive a
|
|
3101
|
+
* sibling executor with {@link StepExecutor.forDocument}.
|
|
3102
|
+
*/
|
|
3103
|
+
readonly document: ArazzoDocument;
|
|
3104
|
+
/**
|
|
3105
|
+
* The document registry the source documents are acquired from — returned
|
|
3106
|
+
* from its cache, or loaded when an operation, a workflow or a
|
|
3107
|
+
* `$sourceDescriptions` expression first needs them.
|
|
3108
|
+
*/
|
|
3109
|
+
readonly registry: DocumentRegistry;
|
|
3110
|
+
/**
|
|
3111
|
+
* The operation engine each step's located operation is delegated to. Build it
|
|
3112
|
+
* with the client factory (or a deterministic stub in tests) and pass it in —
|
|
3113
|
+
* the step executor is agnostic to how the operation reaches the live API.
|
|
3114
|
+
*/
|
|
3115
|
+
readonly operationExecutor: OpenAPIOperationExecutor;
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
/**
|
|
3119
|
+
* Unique identifier of a step within an Arazzo workflow.
|
|
3120
|
+
* @public
|
|
3121
|
+
*/
|
|
3122
|
+
export declare type StepId = string;
|
|
3123
|
+
|
|
3124
|
+
/**
|
|
3125
|
+
* Resolves a step's `parameters` to a plain map of resolved values.
|
|
3126
|
+
*
|
|
3127
|
+
* What a parameter's `value` means is the family-wide rule of
|
|
3128
|
+
* {@link ArazzoValueResolver}; how the resolved values are *keyed* is the subclass's
|
|
3129
|
+
* policy, one per step target — {@link OpenAPIOperationParameterResolver} keys
|
|
3130
|
+
* request delivery for a step targeting an operation,
|
|
3131
|
+
* {@link WorkflowParameterResolver} keys a sub-workflow's inputs for a step
|
|
3132
|
+
* targeting a `workflowId`. Each executor constructs the one resolver its kind
|
|
3133
|
+
* of step calls for.
|
|
3134
|
+
* @public
|
|
3135
|
+
*/
|
|
3136
|
+
export declare abstract class StepParameterResolver extends ArazzoValueResolver {
|
|
3137
|
+
/**
|
|
3138
|
+
* Resolves each parameter's `value`, returning the map keyed by the
|
|
3139
|
+
* subclass's policy. Returns an empty object when there are no parameters.
|
|
3140
|
+
*
|
|
3141
|
+
* `scope` names the step these parameters belong to, so a thrown
|
|
3142
|
+
* {@link ResolverError} can say which step it came from — the caller always
|
|
3143
|
+
* has it, the same way {@link ActionResolver.resolveOnSuccess} is handed
|
|
3144
|
+
* `scope`.
|
|
3145
|
+
*/
|
|
3146
|
+
abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* The trace of a single step execution within a workflow run.
|
|
3151
|
+
* @public
|
|
3152
|
+
*/
|
|
3153
|
+
export declare interface StepRunRecord {
|
|
3154
|
+
readonly stepId: string;
|
|
3155
|
+
/**
|
|
3156
|
+
* Where the step is written.
|
|
3157
|
+
*/
|
|
3158
|
+
readonly location: DocumentLocation;
|
|
3159
|
+
readonly successful: boolean;
|
|
3160
|
+
readonly action: SelectedAction | undefined;
|
|
3161
|
+
/**
|
|
3162
|
+
* How many times the step ran — 1 with no retries, more when a `retry` action
|
|
3163
|
+
* fired. The final `successful` / `action` reflect the last attempt.
|
|
3164
|
+
*/
|
|
3165
|
+
readonly attempts: number;
|
|
3166
|
+
/**
|
|
3167
|
+
* Elapsed time the step took, covering every attempt and the `retryAfter`
|
|
3168
|
+
* waits between them. Measured on a monotonic clock by default, so it may be
|
|
3169
|
+
* fractional and is unaffected by system clock changes.
|
|
3170
|
+
*/
|
|
3171
|
+
readonly durationMs: number;
|
|
3172
|
+
/**
|
|
3173
|
+
* The outcome of each of the step's `successCriteria` in its last attempt, in
|
|
3174
|
+
* list order — why the step succeeded or failed.
|
|
3175
|
+
*/
|
|
3176
|
+
readonly successCriteria: readonly CriterionEvaluationRecord[];
|
|
3177
|
+
/**
|
|
3178
|
+
* The outcome of each criterion of the actions the last attempt considered —
|
|
3179
|
+
* its `onSuccess` actions when it succeeded, its `onFailure` actions
|
|
3180
|
+
* otherwise — in list order: why an action matched or did not.
|
|
3181
|
+
*/
|
|
3182
|
+
readonly actionCriteria: readonly CriterionEvaluationRecord[];
|
|
3183
|
+
/**
|
|
3184
|
+
* The sub-workflow runs this step produced, in attempt order — present only on
|
|
3185
|
+
* a step targeting a `workflowId`.
|
|
3186
|
+
*
|
|
3187
|
+
* A list rather than a single result because a retried sub-workflow step runs
|
|
3188
|
+
* its sub-workflow once per attempt, and each run is a trace of its own; the
|
|
3189
|
+
* last entry is the run this record's `successful` / `action` describe.
|
|
3190
|
+
*/
|
|
3191
|
+
readonly subWorkflows?: readonly WorkflowExecutionResult[];
|
|
3192
|
+
/**
|
|
3193
|
+
* The `retry` reference runs this step's attempts produced, in firing order —
|
|
3194
|
+
* present only when a `retry` failure action that fired carried a `stepId` /
|
|
3195
|
+
* `workflowId` reference. Kept separate from {@link StepRunRecord.subWorkflows}
|
|
3196
|
+
* because a reference is a repair the *retry* invokes, not the step's own
|
|
3197
|
+
* target.
|
|
3198
|
+
*/
|
|
3199
|
+
readonly retryReferences?: readonly RetryReferenceRecord[];
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
/**
|
|
3203
|
+
* Identifies the step something is being resolved or located for, so a thrown
|
|
3204
|
+
* error can say which one it came from. Every resolver that only ever runs
|
|
3205
|
+
* within a step's scope — {@link OpenAPIOperationParameterResolver},
|
|
3206
|
+
* {@link WorkflowParameterResolver}, {@link RequestBodyResolver},
|
|
3207
|
+
* {@link ActionResolver} — takes this, as does
|
|
3208
|
+
* {@link OpenAPIOperationLocatorNormalizer} for the step whose operation it
|
|
3209
|
+
* locates.
|
|
3210
|
+
* @public
|
|
3211
|
+
*/
|
|
3212
|
+
export declare interface StepScope {
|
|
3213
|
+
/**
|
|
3214
|
+
* The workflow the step belongs to, when the caller knows it: step ids are
|
|
3215
|
+
* only unique within a workflow.
|
|
3216
|
+
*/
|
|
3217
|
+
readonly workflowId?: string;
|
|
3218
|
+
readonly stepId: string;
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
/**
|
|
3222
|
+
* A step settled: its retries are done and its terminal action is selected,
|
|
3223
|
+
* or it threw. A step that threw is not `successful` and carries the `error`.
|
|
3224
|
+
* @public
|
|
3225
|
+
*/
|
|
3226
|
+
export declare interface StepSettledEvent extends WorkflowExecutionStepEventBase {
|
|
3227
|
+
readonly type: 'step:settled';
|
|
3228
|
+
readonly successful: boolean;
|
|
3229
|
+
/** The attempts made, the one that threw included. */
|
|
3230
|
+
readonly attempts: number;
|
|
3231
|
+
/** What the step threw, as for {@link WorkflowSettledEvent.error}. */
|
|
3232
|
+
readonly error?: unknown;
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
/**
|
|
3236
|
+
* A step began. Its attempts follow it, and its `step:settled` always does.
|
|
3237
|
+
* @public
|
|
3238
|
+
*/
|
|
3239
|
+
export declare interface StepStartEvent extends WorkflowExecutionStepEventBase {
|
|
3240
|
+
readonly type: 'step:start';
|
|
3241
|
+
/**
|
|
3242
|
+
* Where the step is written.
|
|
3243
|
+
*/
|
|
3244
|
+
readonly location: DocumentLocation;
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
/**
|
|
3248
|
+
* What a workflow does after a step, once the step's action has been
|
|
3249
|
+
* interpreted.
|
|
3250
|
+
*
|
|
3251
|
+
* `next` runs the following step (the success default, or a matched `goto` that
|
|
3252
|
+
* targets the next step); `goto` jumps to a step by id within the current
|
|
3253
|
+
* workflow; `transfer` hands control one-way to another workflow, which the
|
|
3254
|
+
* caller's run then ends on; `end` stops the run with `status: ended`; `break`
|
|
3255
|
+
* stops with `status: failed` (the failure default).
|
|
3256
|
+
* @public
|
|
3257
|
+
*/
|
|
3258
|
+
export declare type StepTransition = {
|
|
3259
|
+
readonly kind: 'next';
|
|
3260
|
+
} | {
|
|
3261
|
+
readonly kind: 'goto';
|
|
3262
|
+
readonly stepId: string;
|
|
3263
|
+
} | {
|
|
3264
|
+
readonly kind: 'transfer';
|
|
3265
|
+
readonly workflowId: string;
|
|
3266
|
+
} | {
|
|
3267
|
+
readonly kind: 'end';
|
|
3268
|
+
} | {
|
|
3269
|
+
readonly kind: 'break';
|
|
3270
|
+
};
|
|
3271
|
+
|
|
3272
|
+
/** @public */
|
|
3273
|
+
export declare class UnmatchedProviderError extends ArazzoRunnerError {
|
|
3274
|
+
readonly uri?: string;
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
/**
|
|
3278
|
+
* How a workflow invocation was entered.
|
|
3279
|
+
*
|
|
3280
|
+
* Recorded per call so a detected loop can be named for the mechanism that formed
|
|
3281
|
+
* it: a repeat reached purely through `dependsOn` edges is a dependency cycle,
|
|
3282
|
+
* one involving a sub-workflow step call — a `retry` action's `workflowId`
|
|
3283
|
+
* reference — or a `goto`'s one-way transfer to a `workflowId` — is a call
|
|
3284
|
+
* cycle. `retry` and `goto` are grouped with `step` for that classification, not
|
|
3285
|
+
* `dependsOn`: each is a call the current step makes, not a stated precondition.
|
|
3286
|
+
* @public
|
|
3287
|
+
*/
|
|
3288
|
+
export declare type WorkflowCallVia = 'root' | 'step' | 'dependsOn' | 'retry' | 'goto';
|
|
3289
|
+
|
|
3290
|
+
/**
|
|
3291
|
+
* A workflow of an Arazzo document, as listed by
|
|
3292
|
+
* {@link ArazzoDocument.listWorkflows}.
|
|
3293
|
+
* @public
|
|
3294
|
+
*/
|
|
3295
|
+
export declare interface WorkflowDescriptor {
|
|
3296
|
+
/**
|
|
3297
|
+
* The id `ArazzoRunner.execute` takes to run the workflow.
|
|
3298
|
+
*/
|
|
3299
|
+
workflowId: WorkflowId;
|
|
3300
|
+
/**
|
|
3301
|
+
* JSON Pointer to the workflow within the document.
|
|
3302
|
+
*/
|
|
3303
|
+
jsonPointer: JSONPointer;
|
|
3304
|
+
/**
|
|
3305
|
+
* Present only when the workflow has a string `summary`.
|
|
3306
|
+
*/
|
|
3307
|
+
summary?: string;
|
|
3308
|
+
/**
|
|
3309
|
+
* Present only when the workflow has a string `description`, as written
|
|
3310
|
+
* (CommonMark).
|
|
3311
|
+
*/
|
|
3312
|
+
description?: string;
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
/**
|
|
3316
|
+
* Per-call options for {@link WorkflowExecutor.execute}.
|
|
3317
|
+
* @public
|
|
3318
|
+
*/
|
|
3319
|
+
export declare interface WorkflowExecuteOptions {
|
|
3320
|
+
/**
|
|
3321
|
+
* The workflow's inputs, read via `$inputs`.
|
|
3322
|
+
*/
|
|
3323
|
+
readonly inputs?: Record<string, unknown>;
|
|
3324
|
+
/**
|
|
3325
|
+
* Execute options addressed to an API: keyed by the `name` of a source
|
|
3326
|
+
* description of the entry document, each entry the opaque client-specific
|
|
3327
|
+
* bag forwarded verbatim to {@link StepExecutor.execute} for the steps that
|
|
3328
|
+
* call an operation through that source description (e.g. a `server` to run
|
|
3329
|
+
* against, or the credentials of its security schemes).
|
|
3330
|
+
*
|
|
3331
|
+
* An entry configures a name, so two source descriptions pointing at the
|
|
3332
|
+
* same OpenAPI document can be configured apart. A step reaching its document
|
|
3333
|
+
* any other way — through a name without an entry, through a name of
|
|
3334
|
+
* another Arazzo document, or through a literal URL — gets the one entry
|
|
3335
|
+
* configuring that document; it gets nothing when no entry does, and throws
|
|
3336
|
+
* when several do, since nothing says which applies. That throw comes at the
|
|
3337
|
+
* step, so the steps before it have already run. Steps of an API without
|
|
3338
|
+
* an entry get no options.
|
|
3339
|
+
*
|
|
3340
|
+
* A key naming no source description, one naming a source description that
|
|
3341
|
+
* has no `url` or is not an OpenAPI document, and an entry that is not an
|
|
3342
|
+
* object all throw before the first request.
|
|
3343
|
+
*/
|
|
3344
|
+
readonly executeOptions?: Record<string, Record<string, unknown>>;
|
|
3345
|
+
/**
|
|
3346
|
+
* Inputs for the workflows run implicitly to satisfy `dependsOn`, keyed by
|
|
3347
|
+
* the `dependsOn` entry as written — the bare workflowId for a
|
|
3348
|
+
* same-document dependency, the whole
|
|
3349
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression for a
|
|
3350
|
+
* cross-document one; consulted for transitive dependencies too. A
|
|
3351
|
+
* dependency with no entry runs with no inputs.
|
|
3352
|
+
*
|
|
3353
|
+
* The Arazzo Specification gives `dependsOn` no input-mapping mechanism of its
|
|
3354
|
+
* own (unlike a sub-workflow *step*, which maps inputs through its
|
|
3355
|
+
* `parameters`), so this is the only channel by which a dependency that
|
|
3356
|
+
* requires inputs can receive them.
|
|
3357
|
+
*/
|
|
3358
|
+
readonly dependencyInputs?: Record<string, Record<string, unknown>>;
|
|
3359
|
+
/**
|
|
3360
|
+
* Whether to run the workflows named by `dependsOn` before the workflow's own
|
|
3361
|
+
* steps. Defaults to `true`.
|
|
3362
|
+
*
|
|
3363
|
+
* Pass `false` to assert the dependencies were already satisfied out-of-band —
|
|
3364
|
+
* "MUST be completed before" does not mean *completed by this engine in this
|
|
3365
|
+
* run*, and re-running them may duplicate side effects. Opting out records no
|
|
3366
|
+
* `$workflows.{dependencyId}.outputs`, so expressions reading a dependency's
|
|
3367
|
+
* outputs then resolve to `undefined`.
|
|
3368
|
+
*
|
|
3369
|
+
* It applies to **the workflow named in this call only**. A sub-workflow it
|
|
3370
|
+
* calls still runs its own prerequisites: those are an implementation detail
|
|
3371
|
+
* the caller may not know exists, so skipping them on their behalf would run
|
|
3372
|
+
* that workflow against state nobody claimed to have prepared.
|
|
3373
|
+
*/
|
|
3374
|
+
readonly runDependencies?: boolean;
|
|
3375
|
+
/**
|
|
3376
|
+
* Cancels the run. Observed before every step attempt — including each retry,
|
|
3377
|
+
* each sub-workflow step, and each `dependsOn` prerequisite — and during the
|
|
3378
|
+
* `retryAfter` waits between attempts, so an aborted run stops at the next
|
|
3379
|
+
* boundary rather than working its way to the end of the workflow.
|
|
3380
|
+
*
|
|
3381
|
+
* An aborted run throws {@link ExecutionError} with reason `ExecutionError.Aborted`,
|
|
3382
|
+
* naming the boundary it stopped at and carrying the signal's own `reason` as
|
|
3383
|
+
* the error's `cause`. It does not resolve as a `failed` result: cancellation
|
|
3384
|
+
* is not something the steps did, and the steps that never ran were not
|
|
3385
|
+
* decided against.
|
|
3386
|
+
*
|
|
3387
|
+
* The signal is also forwarded to the transport with every step's execute
|
|
3388
|
+
* options, so the request in flight when the abort lands is cancelled rather
|
|
3389
|
+
* than merely awaited. This option is the only way to cancel a run: a
|
|
3390
|
+
* `signal` in an `executeOptions` entry is dropped.
|
|
3391
|
+
*/
|
|
3392
|
+
readonly signal?: AbortSignal;
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
/**
|
|
3396
|
+
* The workflow a `dependency:*` event is about.
|
|
3397
|
+
* @public
|
|
3398
|
+
*/
|
|
3399
|
+
export declare interface WorkflowExecutionDependency {
|
|
3400
|
+
/**
|
|
3401
|
+
* The `dependsOn` entry as written: a bare workflowId, or a
|
|
3402
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression.
|
|
3403
|
+
*/
|
|
3404
|
+
readonly reference: string;
|
|
3405
|
+
/**
|
|
3406
|
+
* The bare id of the workflow the entry resolved to.
|
|
3407
|
+
*/
|
|
3408
|
+
readonly workflowId: string;
|
|
3409
|
+
/**
|
|
3410
|
+
* The canonical URI of the Arazzo document that defines it.
|
|
3411
|
+
*/
|
|
3412
|
+
readonly documentURI: string;
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
/**
|
|
3416
|
+
* An event the {@link WorkflowExecutor} emits, discriminated by `type`.
|
|
3417
|
+
*
|
|
3418
|
+
* The events other than `workflow:normalize:*` mark the boundaries the
|
|
3419
|
+
* {@link WorkflowExecutionResult} trace records, plus the criterion and
|
|
3420
|
+
* action decisions behind each step, so folding a run's events rebuilds its
|
|
3421
|
+
* trace. A workflow's or step's start and settled events are stamped with the
|
|
3422
|
+
* readings its `durationMs` comes from, so their timestamps differ by exactly
|
|
3423
|
+
* that.
|
|
3424
|
+
*
|
|
3425
|
+
* A run that throws (an authoring error, a cancellation, a throwing observer)
|
|
3426
|
+
* leaves the workflows and steps it unwinds through unsettled; the rejection
|
|
3427
|
+
* of `execute` is the signal.
|
|
3428
|
+
* @public
|
|
3429
|
+
*/
|
|
3430
|
+
export declare type WorkflowExecutionEvent = WorkflowStartEvent | WorkflowSettledEvent | WorkflowNormalizeStartEvent | WorkflowNormalizeSettledEvent | DependencyStartEvent | DependencySettledEvent | StepStartEvent | StepAttemptEvent | CriterionEvaluatedEvent | ActionSelectedEvent | RetryWaitEvent | RetryReferenceStartEvent | RetryReferenceSettledEvent | StepSettledEvent;
|
|
3431
|
+
|
|
3432
|
+
/**
|
|
3433
|
+
* The fields every {@link WorkflowExecutionEvent} carries.
|
|
3434
|
+
* @public
|
|
3435
|
+
*/
|
|
3436
|
+
export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBase {
|
|
3437
|
+
/**
|
|
3438
|
+
* A random id of the {@link WorkflowExecutor.execute} call the event
|
|
3439
|
+
* belongs to. Every workflow, dependency and step of one call shares it, so
|
|
3440
|
+
* the events of concurrent calls, or of runs in different processes, can be
|
|
3441
|
+
* told apart. The operation events of the call carry it too.
|
|
3442
|
+
*/
|
|
3443
|
+
readonly runId: string;
|
|
3444
|
+
/**
|
|
3445
|
+
* The bare id of the workflow in progress when the event fired. For a
|
|
3446
|
+
* `dependency:*` event, this is the dependent workflow, not the dependency.
|
|
3447
|
+
*/
|
|
3448
|
+
readonly workflowId: string;
|
|
3449
|
+
/**
|
|
3450
|
+
* The chain of workflows in progress, outermost first, this one included.
|
|
3451
|
+
* Uses the same form as `ExecutionError.path`: bare ids for workflows of
|
|
3452
|
+
* the entry document, `{documentURI}#{workflowId}` for workflows of other
|
|
3453
|
+
* documents.
|
|
3454
|
+
*/
|
|
3455
|
+
readonly path: readonly string[];
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
/**
|
|
3459
|
+
* The outcome of executing a workflow.
|
|
3460
|
+
*
|
|
3461
|
+
* `status` is `completed` when the steps ran to the end of the list, `ended`
|
|
3462
|
+
* when an `end` action stopped the run early, `failed` when a step failed and no
|
|
3463
|
+
* matching `onFailure` action redirected it (the break-and-return default) — or
|
|
3464
|
+
* when a `dependsOn` workflow did not complete — and `transferred` when a `goto`
|
|
3465
|
+
* action handed control one-way to another workflow: this run's own steps stop
|
|
3466
|
+
* at that point, and its `outputs` declaration is never evaluated, since the run
|
|
3467
|
+
* never reaches its own end. See {@link WorkflowExecutionResult.settledStatus}
|
|
3468
|
+
* for the success/failure verdict a `'transferred'` result defers to.
|
|
3469
|
+
* @public
|
|
3470
|
+
*/
|
|
3471
|
+
export declare interface WorkflowExecutionResult {
|
|
3472
|
+
readonly workflowId: string;
|
|
3473
|
+
readonly outputs: Record<string, unknown>;
|
|
3474
|
+
readonly steps: readonly StepRunRecord[];
|
|
3475
|
+
readonly status: 'completed' | 'ended' | 'failed' | 'transferred';
|
|
3476
|
+
/**
|
|
3477
|
+
* Where this run's outcome actually settled: `status` itself when it isn't
|
|
3478
|
+
* `'transferred'`, otherwise the terminal, non-`'transferred'` status at the
|
|
3479
|
+
* end of the {@link WorkflowExecutionResult.transferredTo} chain — computed
|
|
3480
|
+
* once, eagerly, when this result is built, so it costs nothing to read and
|
|
3481
|
+
* nothing to forget.
|
|
3482
|
+
*
|
|
3483
|
+
* `status` alone is not a success/failure verdict: `'transferred'` records
|
|
3484
|
+
* *where* control went, not whether the run succeeded, so comparing it
|
|
3485
|
+
* directly against `'failed'` — the natural thing to write — silently
|
|
3486
|
+
* misses a failure buried in the chain. `settledStatus` is that comparison,
|
|
3487
|
+
* already made, always present (even when `status` isn't `'transferred'`,
|
|
3488
|
+
* where it simply repeats `status`): prefer
|
|
3489
|
+
* `result.settledStatus === 'failed'` over `result.status === 'failed'`
|
|
3490
|
+
* for "did this run succeed", including on the top-level result
|
|
3491
|
+
* {@link WorkflowExecutor.execute} itself returns.
|
|
3492
|
+
*/
|
|
3493
|
+
readonly settledStatus: 'completed' | 'ended' | 'failed';
|
|
3494
|
+
/**
|
|
3495
|
+
* Elapsed time the run took, including its dependencies, sub-workflows, and
|
|
3496
|
+
* retry waits — and, for a `'transferred'` run, the whole chain nested
|
|
3497
|
+
* under {@link WorkflowExecutionResult.transferredTo}, since running the
|
|
3498
|
+
* target is what this run's own time was spent on. Measured on a monotonic
|
|
3499
|
+
* clock by default, so it may be fractional and is unaffected by system
|
|
3500
|
+
* clock changes.
|
|
3501
|
+
*/
|
|
3502
|
+
readonly durationMs: number;
|
|
3503
|
+
/**
|
|
3504
|
+
* The runs of the workflows named by `dependsOn`, in declaration order —
|
|
3505
|
+
* present only when the workflow declares dependencies and they were run.
|
|
3506
|
+
*
|
|
3507
|
+
* A dependency already completed earlier in the same run is not run again; its
|
|
3508
|
+
* one result is reported here for each dependent that declares it.
|
|
3509
|
+
*/
|
|
3510
|
+
readonly dependencies?: readonly WorkflowExecutionResult[];
|
|
3511
|
+
/**
|
|
3512
|
+
* The target workflow's own run, present only when `status` is `transferred`.
|
|
3513
|
+
*
|
|
3514
|
+
* Nested rather than spliced in, like {@link WorkflowExecutionResult.dependencies}
|
|
3515
|
+
* — this run's `workflowId` stays the workflow that was called, not the one
|
|
3516
|
+
* control ended up in. If the target itself transfers onward, the chain is
|
|
3517
|
+
* reachable by following `transferredTo.transferredTo`, recursively; its own
|
|
3518
|
+
* `outputs` are the only place the transfer's actual output values live, since
|
|
3519
|
+
* this run's top-level `outputs` is always `{}`.
|
|
3520
|
+
*/
|
|
3521
|
+
readonly transferredTo?: WorkflowExecutionResult;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
/**
|
|
3525
|
+
* Accumulates the runtime state of a workflow run and produces the context a
|
|
3526
|
+
* runtime expression is evaluated against.
|
|
3527
|
+
*
|
|
3528
|
+
* It holds only workflow-scoped state that grows as the run proceeds and is read
|
|
3529
|
+
* back through `$`-expressions: `$inputs`, `$steps.{id}.outputs`,
|
|
3530
|
+
* `$workflows.{id}.{inputs,outputs}`, and the workflow's own `$outputs`. Static,
|
|
3531
|
+
* document-sourced expressions (`$components`, `$sourceDescriptions`) are
|
|
3532
|
+
* resolved on demand by the evaluator and are not stored here; control-flow
|
|
3533
|
+
* position, retries, and traces belong to the executor, not to this state.
|
|
3534
|
+
*
|
|
3535
|
+
* Resolving a step's `outputs` declaration to values is the executor's job; the
|
|
3536
|
+
* resolved values are handed here as plain objects, keeping this state free of
|
|
3537
|
+
* ApiDOM and evaluation concerns. The step-scoped request/response of the
|
|
3538
|
+
* current step are layered on at read time via {@link WorkflowExecutionState.toContext}.
|
|
3539
|
+
* @public
|
|
3540
|
+
*/
|
|
3541
|
+
export declare class WorkflowExecutionState {
|
|
3542
|
+
#private;
|
|
3543
|
+
constructor(options?: WorkflowExecutionStateOptions);
|
|
3544
|
+
/**
|
|
3545
|
+
* Records the resolved outputs of a completed step, read via
|
|
3546
|
+
* `$steps.{stepId}.outputs.{name}`. Every run records, so a step run again
|
|
3547
|
+
* (a `goto` back, a retry) or a later step sharing its `stepId` replaces
|
|
3548
|
+
* the earlier outputs, even with none.
|
|
3549
|
+
*/
|
|
3550
|
+
setStepOutputs(stepId: string, outputs: Record<string, unknown>): void;
|
|
3551
|
+
/**
|
|
3552
|
+
* Sets a single workflow output, read via `$outputs.{name}`.
|
|
3553
|
+
*/
|
|
3554
|
+
setOutput(name: string, value: unknown): void;
|
|
3555
|
+
/**
|
|
3556
|
+
* Records the resolved inputs and outputs of a workflow (typically a called
|
|
3557
|
+
* sub-workflow), read via `$workflows.{workflowId}.{inputs,outputs}.{name}`.
|
|
3558
|
+
*/
|
|
3559
|
+
setWorkflow(workflowId: string, workflow: {
|
|
3560
|
+
inputs?: Record<string, unknown>;
|
|
3561
|
+
outputs?: Record<string, unknown>;
|
|
3562
|
+
}): void;
|
|
3563
|
+
/**
|
|
3564
|
+
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
3565
|
+
* context produced by `toContext`; treat the returned object as immutable.
|
|
3566
|
+
*/
|
|
3567
|
+
get outputs(): Readonly<Record<string, unknown>>;
|
|
3568
|
+
/**
|
|
3569
|
+
* The inputs/outputs already recorded for `workflowId`, or `undefined` if
|
|
3570
|
+
* none has been recorded yet. A narrow read of a single entry, for a caller
|
|
3571
|
+
* that needs one without reconstructing the whole context via `toContext`.
|
|
3572
|
+
*/
|
|
3573
|
+
getWorkflow(workflowId: string): Readonly<{
|
|
3574
|
+
inputs?: Record<string, unknown>;
|
|
3575
|
+
outputs?: Record<string, unknown>;
|
|
3576
|
+
}> | undefined;
|
|
3577
|
+
/**
|
|
3578
|
+
* Produces the runtime expression context for the current evaluation site.
|
|
3579
|
+
*
|
|
3580
|
+
* The accumulated workflow-scoped state is combined with the optional
|
|
3581
|
+
* step-scoped `request`/`response` of the step being evaluated. Omit both when
|
|
3582
|
+
* evaluating before a request is made (e.g. resolving parameters), so that
|
|
3583
|
+
* `$request`/`$response`/`$statusCode` correctly resolve to `undefined`.
|
|
3584
|
+
*/
|
|
3585
|
+
toContext(request?: RuntimeExpressionRequestContext, response?: RuntimeExpressionResponseContext): RuntimeExpressionContext;
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
/**
|
|
3589
|
+
* Options for the WorkflowExecutionState.
|
|
3590
|
+
* @public
|
|
3591
|
+
*/
|
|
3592
|
+
export declare interface WorkflowExecutionStateOptions {
|
|
3593
|
+
/**
|
|
3594
|
+
* The workflow inputs, fixed for the run and read via `$inputs`.
|
|
3595
|
+
*/
|
|
3596
|
+
readonly inputs?: Record<string, unknown>;
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
/**
|
|
3600
|
+
* The fields every step-scoped {@link WorkflowExecutionEvent} carries.
|
|
3601
|
+
* @public
|
|
3602
|
+
*/
|
|
3603
|
+
export declare interface WorkflowExecutionStepEventBase extends WorkflowExecutionEventBase {
|
|
3604
|
+
readonly stepId: string;
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3607
|
+
/**
|
|
3608
|
+
* Executes an Arazzo workflow: the stateful loop that turns "run one step" into
|
|
3609
|
+
* "run a workflow".
|
|
3610
|
+
*
|
|
3611
|
+
* It iterates a workflow's steps in list order, delegating each to
|
|
3612
|
+
* {@link StepExecutor}, records the resolved step outputs into a
|
|
3613
|
+
* {@link WorkflowExecutionState} so later steps read `$steps.{id}.outputs.{name}`,
|
|
3614
|
+
* and interprets the {@link SelectedAction} the step executor selects but does
|
|
3615
|
+
* not act on — advancing to the next step, jumping via `goto`, transferring
|
|
3616
|
+
* one-way to another workflow via a `goto` naming a `workflowId`, or stopping on
|
|
3617
|
+
* `end` / the failure break-default. After the loop it resolves the workflow's
|
|
3618
|
+
* `outputs` against the final state — unless the run transferred, in which case
|
|
3619
|
+
* it never reaches its own end and `outputs` stays `{}`.
|
|
3620
|
+
*
|
|
3621
|
+
* A step targeting a `workflowId` is a sub-workflow call the executor runs
|
|
3622
|
+
* itself, recursively; the workflows named by `dependsOn` are run to completion
|
|
3623
|
+
* before the workflow's own steps. Both recurse through one call tree, guarded
|
|
3624
|
+
* by a shared step budget, a nesting-depth ceiling, and cycle detection. A
|
|
3625
|
+
* `goto`'s transfer joins the same call tree, entered via `'goto'`, but is not
|
|
3626
|
+
* charged against the step budget: it fires once per step evaluation, unlike a
|
|
3627
|
+
* retry reference, which can fire repeatedly from the same frame.
|
|
3628
|
+
*
|
|
3629
|
+
* State is created fresh per {@link WorkflowExecutor.execute} call — and per
|
|
3630
|
+
* workflow invocation within it — and owned here; the returned result is
|
|
3631
|
+
* read-only. Authoring errors (missing workflow, unknown `goto` target, a cycle,
|
|
3632
|
+
* budget overflow) throw {@link ExecutionError}, as does a run the caller
|
|
3633
|
+
* cancels through {@link WorkflowExecuteOptions.signal}; a step that
|
|
3634
|
+
* legitimately fails and breaks, or a dependency that fails, is a normal
|
|
3635
|
+
* `status: 'failed'` result, not a throw — the same split {@link StepExecutor}
|
|
3636
|
+
* draws.
|
|
3637
|
+
*
|
|
3638
|
+
* A workflow reference — a sub-workflow step's `workflowId`, a `dependsOn`
|
|
3639
|
+
* entry, a `retry` action's reference, a `goto`'s transfer — may also name a
|
|
3640
|
+
* workflow of another Arazzo document, as
|
|
3641
|
+
* `$sourceDescriptions.{name}.{workflowId}`. The run then follows that
|
|
3642
|
+
* document for the foreign workflow: its id lookups, its steps' operations,
|
|
3643
|
+
* and its expressions all resolve against the document that owns it, while
|
|
3644
|
+
* the `$workflows.{workflowId}` run state stays keyed by the bare id — the
|
|
3645
|
+
* only form the runtime-expression grammar can express.
|
|
3646
|
+
* @public
|
|
3647
|
+
*/
|
|
3648
|
+
export declare class WorkflowExecutor {
|
|
3649
|
+
#private;
|
|
3650
|
+
constructor(options: WorkflowExecutorOptions);
|
|
3651
|
+
/**
|
|
3652
|
+
* Runs the named workflow to completion, returning its outcome.
|
|
3653
|
+
*
|
|
3654
|
+
* The workflows the target names in `dependsOn` are run first (see
|
|
3655
|
+
* {@link WorkflowExecuteOptions.runDependencies}), then its own steps.
|
|
3656
|
+
*
|
|
3657
|
+
* All run-scoped state — the execution state, the step trace, the control-flow
|
|
3658
|
+
* position, the call stack, the step budget, and the completed-dependency
|
|
3659
|
+
* ledger — is local to this call, so concurrent `execute` calls on one executor
|
|
3660
|
+
* do not interfere.
|
|
3661
|
+
*/
|
|
3662
|
+
execute(workflowId: WorkflowId, options?: WorkflowExecuteOptions): Promise<WorkflowExecutionResult>;
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
/**
|
|
3666
|
+
* Options for the WorkflowExecutor.
|
|
3667
|
+
* @public
|
|
3668
|
+
*/
|
|
3669
|
+
export declare interface WorkflowExecutorOptions {
|
|
3670
|
+
/**
|
|
3671
|
+
* The entry Arazzo document holding the workflows to run; also the
|
|
3672
|
+
* `$components` / `$sourceDescriptions` base for every entry-document
|
|
3673
|
+
* workflow's expressions. A workflow reached through a cross-document
|
|
3674
|
+
* reference resolves against its own document instead — the document
|
|
3675
|
+
* follows the invocation, not this option.
|
|
3676
|
+
*/
|
|
3677
|
+
readonly document: ArazzoDocument;
|
|
3678
|
+
/**
|
|
3679
|
+
* The document registry the source documents are acquired from — returned
|
|
3680
|
+
* from its cache, or loaded when an operation, a workflow or a
|
|
3681
|
+
* `$sourceDescriptions` expression first needs them.
|
|
3682
|
+
*/
|
|
3683
|
+
readonly registry: DocumentRegistry;
|
|
3684
|
+
/**
|
|
3685
|
+
* The per-step engine every step is delegated to. Build it with the client
|
|
3686
|
+
* factory (or a deterministic stub in tests) and pass it in — the workflow
|
|
3687
|
+
* executor is agnostic to how a step reaches the live API.
|
|
3688
|
+
*/
|
|
3689
|
+
readonly stepExecutor: StepExecutor;
|
|
3690
|
+
/**
|
|
3691
|
+
* Normalizes each workflow before it runs: dereferences it, which may fetch
|
|
3692
|
+
* externally referenced documents, and inherits its parameters and actions
|
|
3693
|
+
* into its steps. Defaults to a fresh {@link ArazzoWorkflowNormalizer}.
|
|
3694
|
+
*/
|
|
3695
|
+
readonly workflowNormalizer?: ArazzoWorkflowNormalizer;
|
|
3696
|
+
/**
|
|
3697
|
+
* Upper bound on the number of step attempts in a single run — every attempt
|
|
3698
|
+
* of every step counts, including each `retry` and each entry into a
|
|
3699
|
+
* sub-workflow step. Guards against a runaway `goto` loop, a runaway `retry`,
|
|
3700
|
+
* and a runaway tree of sub-workflow calls alike. Defaults to 1000.
|
|
3701
|
+
*
|
|
3702
|
+
* The budget is shared by the whole call tree, not granted afresh per
|
|
3703
|
+
* workflow: a sub-workflow spinning on its own `goto` must not escape the
|
|
3704
|
+
* ceiling the caller set.
|
|
3705
|
+
*/
|
|
3706
|
+
readonly maxSteps?: number;
|
|
3707
|
+
/**
|
|
3708
|
+
* Upper bound on how deeply workflows may nest — a workflow entered while
|
|
3709
|
+
* this many are already in progress throws with reason `ExecutionError.WorkflowDepth`.
|
|
3710
|
+
* Bounds *legitimate* (acyclic) nesting; a genuine cycle is caught earlier and
|
|
3711
|
+
* separately by reason `ExecutionError.WorkflowCycle`. Defaults to 32.
|
|
3712
|
+
*
|
|
3713
|
+
* The count includes the workflow `execute` was called with, so `1` permits
|
|
3714
|
+
* that workflow and forbids all nesting; a value below 1 leaves no room for
|
|
3715
|
+
* even the top-level run.
|
|
3716
|
+
*/
|
|
3717
|
+
readonly maxWorkflowDepth?: number;
|
|
3718
|
+
/**
|
|
3719
|
+
* Delays for the given number of milliseconds — awaited between a step's retry
|
|
3720
|
+
* attempts (`retryAfter`). Injected so tests pass a no-op and real runs delay;
|
|
3721
|
+
* defaults to a real timer.
|
|
3722
|
+
*
|
|
3723
|
+
* The run's {@link WorkflowExecuteOptions.signal} is forwarded to it, so the
|
|
3724
|
+
* default timer stops waiting when the run is cancelled; an injected sleep
|
|
3725
|
+
* that ignores it merely postpones the cancellation until its wait ends.
|
|
3726
|
+
*/
|
|
3727
|
+
readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
3728
|
+
/**
|
|
3729
|
+
* Reads the current time in milliseconds, used for the `durationMs` of each
|
|
3730
|
+
* run and step. Injected so tests assert exact durations; defaults to
|
|
3731
|
+
* `performance.now`, which is monotonic — `Date.now` would yield a wrong or
|
|
3732
|
+
* negative duration if the system clock were adjusted mid-run.
|
|
3733
|
+
*/
|
|
3734
|
+
readonly now?: () => number;
|
|
3735
|
+
/**
|
|
3736
|
+
* Receives the run's events, stamped with
|
|
3737
|
+
* {@link WorkflowExecutorOptions.now}: workflows, dependencies, steps,
|
|
3738
|
+
* attempts, criterion outcomes, selected actions, retry waits and retry
|
|
3739
|
+
* references, plus each workflow's normalization. See
|
|
3740
|
+
* {@link WorkflowExecutionEvent}, and {@link ArazzoRunnerObserver} for how
|
|
3741
|
+
* events are delivered.
|
|
3742
|
+
*/
|
|
3743
|
+
readonly observer?: ArazzoRunnerObserver<WorkflowExecutionEvent>;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
/**
|
|
3747
|
+
* Unique identifier of an Arazzo workflow.
|
|
3748
|
+
* @public
|
|
3749
|
+
*/
|
|
3750
|
+
export declare type WorkflowId = string;
|
|
3751
|
+
|
|
3752
|
+
/**
|
|
3753
|
+
* The workflow was normalized.
|
|
3754
|
+
* @public
|
|
3755
|
+
*/
|
|
3756
|
+
export declare interface WorkflowNormalizeSettledEvent extends WorkflowExecutionEventBase {
|
|
3757
|
+
readonly type: 'workflow:normalize:settled';
|
|
3758
|
+
/**
|
|
3759
|
+
* Where the workflow is written.
|
|
3760
|
+
*/
|
|
3761
|
+
readonly location: DocumentLocation;
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
/**
|
|
3765
|
+
* The workflow is being normalized before its first run in this `execute`
|
|
3766
|
+
* call: dereferenced (which may fetch externally referenced documents), with
|
|
3767
|
+
* its parameters and actions inherited into its steps. A workflow already
|
|
3768
|
+
* normalized earlier in the same call emits nothing.
|
|
3769
|
+
* @public
|
|
3770
|
+
*/
|
|
3771
|
+
export declare interface WorkflowNormalizeStartEvent extends WorkflowExecutionEventBase {
|
|
3772
|
+
readonly type: 'workflow:normalize:start';
|
|
3773
|
+
/**
|
|
3774
|
+
* Where the workflow is written.
|
|
3775
|
+
*/
|
|
3776
|
+
readonly location: DocumentLocation;
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
/**
|
|
3780
|
+
* Resolves the `parameters` of a step targeting a `workflowId` into the
|
|
3781
|
+
* sub-workflow's inputs — or those of a `goto` / `retry` action naming a
|
|
3782
|
+
* `workflowId` into its target's.
|
|
3783
|
+
*
|
|
3784
|
+
* Values follow the family-wide literal-vs-expression rule of
|
|
3785
|
+
* {@link ArazzoValueResolver}. Keys are bare parameter names: per the
|
|
3786
|
+
* specification, "when the step in context specifies a `workflowId`, then all
|
|
3787
|
+
* parameters map to workflow inputs" — which are keyed by name alone, even
|
|
3788
|
+
* for an inherited parameter that carries an `in`. Locations are not
|
|
3789
|
+
* consulted, so two parameters differing only in `in` collapse by name here,
|
|
3790
|
+
* which for inputs is the override mechanism, not a loss.
|
|
3791
|
+
*
|
|
3792
|
+
* The first parameter to claim a name wins: the list is ordered by
|
|
3793
|
+
* precedence, most specific first, as `ArazzoWorkflowNormalizer` leaves it
|
|
3794
|
+
* once a step's own parameters have been merged with the ones it inherits —
|
|
3795
|
+
* the override order the specification requires.
|
|
3796
|
+
* @public
|
|
3797
|
+
*/
|
|
3798
|
+
export declare class WorkflowParameterResolver extends StepParameterResolver {
|
|
3799
|
+
/**
|
|
3800
|
+
* Resolves each parameter's `value`, returning a `name` → value map.
|
|
3801
|
+
* Returns an empty object when there are no parameters.
|
|
3802
|
+
*
|
|
3803
|
+
* `scope` names the step in a thrown {@link ResolverError}.
|
|
3804
|
+
*/
|
|
3805
|
+
resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
/**
|
|
3809
|
+
* The referencing context a reference is resolved in: the workflow (and step,
|
|
3810
|
+
* when the reference sits on one) making the reference, stamped onto every
|
|
3811
|
+
* error.
|
|
3812
|
+
* @public
|
|
3813
|
+
*/
|
|
3814
|
+
export declare interface WorkflowReferenceContext {
|
|
3815
|
+
/**
|
|
3816
|
+
* The workflow the reference appears in.
|
|
3817
|
+
*/
|
|
3818
|
+
readonly workflowId: string;
|
|
3819
|
+
/**
|
|
3820
|
+
* The step the reference appears on, when it sits on one (a sub-workflow
|
|
3821
|
+
* step's `workflowId`, or a `retry` / `goto` action's reference).
|
|
3822
|
+
*/
|
|
3823
|
+
readonly stepId?: string;
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
/**
|
|
3827
|
+
* A workflow invocation produced its result, or threw. The fields repeat
|
|
3828
|
+
* the {@link WorkflowExecutionResult} fields of the same name; an invocation
|
|
3829
|
+
* that threw settles as `failed`, with no outputs, and carries the `error`.
|
|
3830
|
+
* @public
|
|
3831
|
+
*/
|
|
3832
|
+
export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase {
|
|
3833
|
+
readonly type: 'workflow:settled';
|
|
3834
|
+
readonly status: WorkflowExecutionResult['status'];
|
|
3835
|
+
readonly settledStatus: WorkflowExecutionResult['settledStatus'];
|
|
3836
|
+
readonly outputs: WorkflowExecutionResult['outputs'];
|
|
3837
|
+
/**
|
|
3838
|
+
* What the invocation threw, as `execute` rejects with it: an
|
|
3839
|
+
* {@link ArazzoRunnerError} for an error in the document, an abort, or the
|
|
3840
|
+
* transport's own error. Only when it threw.
|
|
3841
|
+
*/
|
|
3842
|
+
readonly error?: unknown;
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
/**
|
|
3846
|
+
* A workflow invocation began: it entered the call stack, before it is
|
|
3847
|
+
* normalized and its definition checked. Its `workflow:settled` always
|
|
3848
|
+
* follows, carrying the `error` when the invocation throws.
|
|
3849
|
+
* @public
|
|
3850
|
+
*/
|
|
3851
|
+
export declare interface WorkflowStartEvent extends WorkflowExecutionEventBase {
|
|
3852
|
+
readonly type: 'workflow:start';
|
|
3853
|
+
/** Where the workflow is written. */
|
|
3854
|
+
readonly location: DocumentLocation;
|
|
3855
|
+
/**
|
|
3856
|
+
* How the workflow was reached. `root` is the workflow named in `execute`,
|
|
3857
|
+
* `step` is a sub-workflow step, `dependsOn` is a prerequisite, `retry` is
|
|
3858
|
+
* a `retry` action's `workflowId` reference, and `goto` is a one-way
|
|
3859
|
+
* transfer.
|
|
3860
|
+
*/
|
|
3861
|
+
readonly via: WorkflowCallVia;
|
|
3862
|
+
}
|
|
3863
|
+
|
|
3864
|
+
/**
|
|
3865
|
+
* Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
|
|
3866
|
+
*
|
|
3867
|
+
* The condition is an XPath 3.1 query applied to the resolved `context`, which
|
|
3868
|
+
* must be XML. A string context is parsed as XML; an already-parsed DOM node is
|
|
3869
|
+
* used as-is. The criterion is met by the query's Effective Boolean Value
|
|
3870
|
+
* (XPath 3.1 §19.1.2), as the Arazzo specification mandates — so a boolean
|
|
3871
|
+
* predicate (`//status = 'ok'`), a non-empty node set, a non-zero number, and a
|
|
3872
|
+
* non-empty string all evaluate to `true`.
|
|
3873
|
+
*
|
|
3874
|
+
* Only XPath 3.1 is supported (`fontoxpath`'s engine); version gating happens in
|
|
3875
|
+
* the facade. Per Arazzo 1.1.0, a `null` or `undefined` context fails the
|
|
3876
|
+
* condition. An invalid query throws {@link CriterionEvaluationError}.
|
|
3877
|
+
* @public
|
|
3878
|
+
*/
|
|
3879
|
+
export declare class XPathCriterionEvaluator {
|
|
3880
|
+
#private;
|
|
3881
|
+
/**
|
|
3882
|
+
* Evaluates the XPath `condition` against the resolved context value, returning
|
|
3883
|
+
* its Effective Boolean Value.
|
|
3884
|
+
*
|
|
3885
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
3886
|
+
* {@link CriterionEvaluationError} when the context is not XML or the query is invalid.
|
|
3887
|
+
*/
|
|
3888
|
+
evaluate(condition: string, context: unknown): boolean;
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
export { }
|