@usearazzo/runner 1.0.1-alpha.28 → 1.0.1-alpha.30
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 +18 -0
- package/README.md +29 -54
- package/dist/arazzo-runner.browser.js +328 -181
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +4 -4
- package/src/errors/ExecutionError.cjs +3 -1
- package/src/errors/ExecutionError.mjs +3 -1
- package/src/executor/OpenAPIOperationExecutor.cjs +92 -22
- package/src/executor/OpenAPIOperationExecutor.mjs +90 -22
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +31 -4
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +30 -4
- package/src/executor/StepExecutor.cjs +19 -7
- package/src/executor/StepExecutor.mjs +19 -7
- package/src/executor/WorkflowExecutor.cjs +50 -16
- package/src/executor/WorkflowExecutor.mjs +51 -17
- package/types/runner.d.ts +153 -25
|
@@ -58,6 +58,13 @@ export const STEP_TARGET_FIELDS = ['operationId', 'operationPath', 'workflowId']
|
|
|
58
58
|
* @internal
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The execute options of a step: the opaque bag forwarded to the operation
|
|
63
|
+
* executor, or a function returning it for the operation the step was located
|
|
64
|
+
* to.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* Executes a single Arazzo step that invokes an OpenAPI operation.
|
|
63
70
|
*
|
|
@@ -120,7 +127,9 @@ class StepExecutor {
|
|
|
120
127
|
* `executeOptions` is an opaque bag passed through to the operation executor
|
|
121
128
|
* (e.g. a `server` to run the step against, or an `AbortSignal`). The
|
|
122
129
|
* Arazzo-derived options (`operationId`, `parameters`, `requestBody`) always
|
|
123
|
-
* take precedence over it.
|
|
130
|
+
* take precedence over it. A function is called with the operation the step
|
|
131
|
+
* was located to and returns the bag, for options that depend on which API
|
|
132
|
+
* the step calls.
|
|
124
133
|
*
|
|
125
134
|
* A `signal` in that bag is honored here and not only at the transport: an
|
|
126
135
|
* already-aborted signal throws with reason `ExecutionError.Aborted` instead of issuing a
|
|
@@ -162,6 +171,7 @@ class StepExecutor {
|
|
|
162
171
|
// Pointer) locator that the operation executor extracts, normalizes,
|
|
163
172
|
// assembles into a standalone doc, and runs.
|
|
164
173
|
const locator = await this.#locateOperation(step, scope);
|
|
174
|
+
const operationOptions = typeof executeOptions === 'function' ? executeOptions(locator) : executeOptions;
|
|
165
175
|
|
|
166
176
|
// resolve parameters and request body against the pre-request context.
|
|
167
177
|
// keyed by '{in}.{name}' rather than bare name, so two parameters that
|
|
@@ -175,18 +185,20 @@ class StepExecutor {
|
|
|
175
185
|
// still reach this line — and this is the last moment before the step has a
|
|
176
186
|
// live side effect. The signal stays in the bag, so a request already in
|
|
177
187
|
// flight is aborted by the transport as before.
|
|
178
|
-
const signal = readAbortSignal(
|
|
188
|
+
const signal = readAbortSignal(operationOptions);
|
|
179
189
|
throwIfAborted(signal, scope);
|
|
180
190
|
|
|
181
|
-
// the Arazzo-derived parameters
|
|
182
|
-
// executeOptions bag so they take precedence over it. the
|
|
183
|
-
// then forces the operation target on top of this
|
|
191
|
+
// the Arazzo-derived parameters, request body and step identity are spread
|
|
192
|
+
// after the opaque executeOptions bag so they take precedence over it. the
|
|
193
|
+
// operation executor then forces the operation target on top of this
|
|
194
|
+
// before executing.
|
|
184
195
|
let response;
|
|
185
196
|
try {
|
|
186
197
|
response = await this.#operationExecutor.execute(locator, {
|
|
187
|
-
...
|
|
198
|
+
...operationOptions,
|
|
188
199
|
parameters,
|
|
189
|
-
...this.#requestBodyOptions(requestBody)
|
|
200
|
+
...this.#requestBodyOptions(requestBody),
|
|
201
|
+
step: scope
|
|
190
202
|
});
|
|
191
203
|
} catch (error) {
|
|
192
204
|
// a transport that honors the signal rejects the request it was told to
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
exports.settledResult = settledResult;
|
|
10
10
|
var _apidomCore = require("@speclynx/apidom-core");
|
|
11
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
11
12
|
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
12
13
|
var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
|
|
13
14
|
var _RuntimeExpressionEvaluator = _interopRequireDefault(require("../expression/RuntimeExpressionEvaluator.cjs"));
|
|
@@ -197,23 +198,21 @@ class WorkflowExecutor {
|
|
|
197
198
|
*/
|
|
198
199
|
async execute(workflowId, options = {}) {
|
|
199
200
|
this.#rejectUnknownOptions(options);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// abort requests while the loop walked on through the remaining steps.
|
|
205
|
-
const signal = options.signal ?? (0, _abort.readAbortSignal)(options.executeOptions ?? {});
|
|
201
|
+
const {
|
|
202
|
+
signal
|
|
203
|
+
} = options;
|
|
204
|
+
const executeOptions = this.#executeOptionsByDocument(options.executeOptions ?? {});
|
|
206
205
|
const scope = {
|
|
207
|
-
// the
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
},
|
|
206
|
+
// the signal is put into every step's opaque bag, because that bag is
|
|
207
|
+
// how anything reaches the transport: the executor's own checks stop the
|
|
208
|
+
// run at the next boundary, and this is what cancels the request already
|
|
209
|
+
// in flight. Set even when absent, so a `signal` in an entry never
|
|
210
|
+
// stands in for it: that one would cancel the steps of a single API and
|
|
211
|
+
// leave the run walking on.
|
|
212
|
+
executeOptions: locator => ({
|
|
213
|
+
...executeOptions.get(locator.document.uri),
|
|
214
|
+
signal
|
|
215
|
+
}),
|
|
217
216
|
dependencyInputs: options.dependencyInputs ?? {},
|
|
218
217
|
runDependencies: options.runDependencies ?? true,
|
|
219
218
|
signal,
|
|
@@ -232,6 +231,41 @@ class WorkflowExecutor {
|
|
|
232
231
|
}), 'root');
|
|
233
232
|
}
|
|
234
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Resolves the `executeOptions` entries to the documents they configure,
|
|
236
|
+
* keyed by canonical document URI.
|
|
237
|
+
*
|
|
238
|
+
* Every way an entry can fail to name exactly one OpenAPI document throws
|
|
239
|
+
* here, before the run starts: sent to no API or to two, its options would
|
|
240
|
+
* be missing or misdirected with nothing to show for it until a request
|
|
241
|
+
* failed.
|
|
242
|
+
*/
|
|
243
|
+
#executeOptionsByDocument(executeOptions) {
|
|
244
|
+
const byDocument = new Map();
|
|
245
|
+
const fail = (name, problem, reason) => {
|
|
246
|
+
throw new _ExecutionError.default(`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
|
|
247
|
+
reason
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
for (const [name, options] of Object.entries(executeOptions)) {
|
|
251
|
+
const uri = this.#document.resolveSourceDescriptionURI(name);
|
|
252
|
+
if (uri === undefined) {
|
|
253
|
+
return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, _ExecutionError.default.SourceDescriptionNotFound);
|
|
254
|
+
}
|
|
255
|
+
if (this.#document.resolveSourceDescriptionField(name, 'type') === 'arazzo') {
|
|
256
|
+
fail(name, 'names an Arazzo document', _ExecutionError.default.SourceDescriptionNotOpenAPI);
|
|
257
|
+
}
|
|
258
|
+
if (!(0, _ramdaAdjunct.isPlainObject)(options)) {
|
|
259
|
+
fail(name, 'is not given an object of options', _ExecutionError.default.UnknownExecuteOption);
|
|
260
|
+
}
|
|
261
|
+
if (byDocument.has(uri)) {
|
|
262
|
+
fail(name, `points at "${uri}", which another entry already configures`, _ExecutionError.default.AmbiguousExecuteOptions);
|
|
263
|
+
}
|
|
264
|
+
byDocument.set(uri, options);
|
|
265
|
+
}
|
|
266
|
+
return byDocument;
|
|
267
|
+
}
|
|
268
|
+
|
|
235
269
|
/**
|
|
236
270
|
* Rejects an options bag carrying keys this method does not recognize.
|
|
237
271
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toValue } from '@speclynx/apidom-core';
|
|
2
|
+
import { isPlainObject } from 'ramda-adjunct';
|
|
2
3
|
import { isArrayElement, isObjectElement, isStringElement } from '@speclynx/apidom-datamodel';
|
|
3
4
|
import { isFailureActionElement, isParameterElement, isStepElement, isSuccessActionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
4
5
|
import RuntimeExpressionEvaluator from "../expression/RuntimeExpressionEvaluator.mjs";
|
|
@@ -14,7 +15,7 @@ import WorkflowCallStack from "./WorkflowCallStack.mjs";
|
|
|
14
15
|
import StepTransitionInterpreter, { actionTargets } from "./StepTransitionInterpreter.mjs";
|
|
15
16
|
import ExecutionError from "../errors/ExecutionError.mjs";
|
|
16
17
|
import ResolverError from "../errors/ResolverError.mjs";
|
|
17
|
-
import {
|
|
18
|
+
import { throwIfAborted } from "./abort.mjs";
|
|
18
19
|
/**
|
|
19
20
|
* Options for the WorkflowExecutor.
|
|
20
21
|
* @public
|
|
@@ -183,23 +184,21 @@ class WorkflowExecutor {
|
|
|
183
184
|
*/
|
|
184
185
|
async execute(workflowId, options = {}) {
|
|
185
186
|
this.#rejectUnknownOptions(options);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// abort requests while the loop walked on through the remaining steps.
|
|
191
|
-
const signal = options.signal ?? readAbortSignal(options.executeOptions ?? {});
|
|
187
|
+
const {
|
|
188
|
+
signal
|
|
189
|
+
} = options;
|
|
190
|
+
const executeOptions = this.#executeOptionsByDocument(options.executeOptions ?? {});
|
|
192
191
|
const scope = {
|
|
193
|
-
// the
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
},
|
|
192
|
+
// the signal is put into every step's opaque bag, because that bag is
|
|
193
|
+
// how anything reaches the transport: the executor's own checks stop the
|
|
194
|
+
// run at the next boundary, and this is what cancels the request already
|
|
195
|
+
// in flight. Set even when absent, so a `signal` in an entry never
|
|
196
|
+
// stands in for it: that one would cancel the steps of a single API and
|
|
197
|
+
// leave the run walking on.
|
|
198
|
+
executeOptions: locator => ({
|
|
199
|
+
...executeOptions.get(locator.document.uri),
|
|
200
|
+
signal
|
|
201
|
+
}),
|
|
203
202
|
dependencyInputs: options.dependencyInputs ?? {},
|
|
204
203
|
runDependencies: options.runDependencies ?? true,
|
|
205
204
|
signal,
|
|
@@ -218,6 +217,41 @@ class WorkflowExecutor {
|
|
|
218
217
|
}), 'root');
|
|
219
218
|
}
|
|
220
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Resolves the `executeOptions` entries to the documents they configure,
|
|
222
|
+
* keyed by canonical document URI.
|
|
223
|
+
*
|
|
224
|
+
* Every way an entry can fail to name exactly one OpenAPI document throws
|
|
225
|
+
* here, before the run starts: sent to no API or to two, its options would
|
|
226
|
+
* be missing or misdirected with nothing to show for it until a request
|
|
227
|
+
* failed.
|
|
228
|
+
*/
|
|
229
|
+
#executeOptionsByDocument(executeOptions) {
|
|
230
|
+
const byDocument = new Map();
|
|
231
|
+
const fail = (name, problem, reason) => {
|
|
232
|
+
throw new ExecutionError(`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
|
|
233
|
+
reason
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
for (const [name, options] of Object.entries(executeOptions)) {
|
|
237
|
+
const uri = this.#document.resolveSourceDescriptionURI(name);
|
|
238
|
+
if (uri === undefined) {
|
|
239
|
+
return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, ExecutionError.SourceDescriptionNotFound);
|
|
240
|
+
}
|
|
241
|
+
if (this.#document.resolveSourceDescriptionField(name, 'type') === 'arazzo') {
|
|
242
|
+
fail(name, 'names an Arazzo document', ExecutionError.SourceDescriptionNotOpenAPI);
|
|
243
|
+
}
|
|
244
|
+
if (!isPlainObject(options)) {
|
|
245
|
+
fail(name, 'is not given an object of options', ExecutionError.UnknownExecuteOption);
|
|
246
|
+
}
|
|
247
|
+
if (byDocument.has(uri)) {
|
|
248
|
+
fail(name, `points at "${uri}", which another entry already configures`, ExecutionError.AmbiguousExecuteOptions);
|
|
249
|
+
}
|
|
250
|
+
byDocument.set(uri, options);
|
|
251
|
+
}
|
|
252
|
+
return byDocument;
|
|
253
|
+
}
|
|
254
|
+
|
|
221
255
|
/**
|
|
222
256
|
* Rejects an options bag carrying keys this method does not recognize.
|
|
223
257
|
*
|
package/types/runner.d.ts
CHANGED
|
@@ -816,6 +816,8 @@ export declare type DocumentRegistryProviderOptions = PartialDeep<ApiDOMReferenc
|
|
|
816
816
|
export declare class ExecutionError extends ArazzoRunnerError {
|
|
817
817
|
/** The run was cancelled through its `AbortSignal`; the signal's reason is the `cause`. */
|
|
818
818
|
static readonly Aborted: "aborted";
|
|
819
|
+
/** Two `executeOptions` entries name source descriptions that point at the same document. */
|
|
820
|
+
static readonly AmbiguousExecuteOptions: "ambiguous-execute-options";
|
|
819
821
|
/** A step or a `goto`/`retry` action declares more than one mutually exclusive target. */
|
|
820
822
|
static readonly AmbiguousTarget: "ambiguous-target";
|
|
821
823
|
/** The `dependsOn` edges alone form a cycle between workflows. */
|
|
@@ -850,7 +852,7 @@ export declare class ExecutionError extends ArazzoRunnerError {
|
|
|
850
852
|
static readonly StepBudget: "step-budget";
|
|
851
853
|
/** An action declares a `type` other than `end`, `goto` or `retry`. */
|
|
852
854
|
static readonly UnknownActionType: "unknown-action-type";
|
|
853
|
-
/** `execute` received an option it does not know. */
|
|
855
|
+
/** `execute` received an option it does not know, or an `executeOptions` entry that is not an object. */
|
|
854
856
|
static readonly UnknownExecuteOption: "unknown-execute-option";
|
|
855
857
|
/** A step produced a transition the workflow executor does not recognize. */
|
|
856
858
|
static readonly UnknownTransitionKind: "unknown-transition-kind";
|
|
@@ -1150,11 +1152,14 @@ export declare type OpenAPIOperationElement = OperationElement | OperationElemen
|
|
|
1150
1152
|
* building the request and sending it.
|
|
1151
1153
|
*
|
|
1152
1154
|
* Typed here are the options the runner itself drives and the ones callers
|
|
1153
|
-
* routinely reach for. The rest of `buildRequest`'s surface (`
|
|
1154
|
-
* `
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1155
|
+
* routinely reach for. The rest of `buildRequest`'s surface (`scheme`,
|
|
1156
|
+
* `parameterBuilders`, `attachContentTypeForEmptyPayload`, …) is deliberately
|
|
1157
|
+
* left untyped and passes through the bag's open tail unchanged — see
|
|
1158
|
+
* {@link OpenAPIOperationExecuteOptionsBag}.
|
|
1159
|
+
*
|
|
1160
|
+
* Arazzo is auth-agnostic, so credentials come from outside the workflow:
|
|
1161
|
+
* static ones for the security schemes the OpenAPI document declares go in
|
|
1162
|
+
* `securities`, and anything computed per request is applied with a
|
|
1158
1163
|
* {@link RequestInterceptor}.
|
|
1159
1164
|
* @public
|
|
1160
1165
|
*/
|
|
@@ -1199,8 +1204,24 @@ export declare interface OpenAPIOperationExecuteOptions {
|
|
|
1199
1204
|
* a declared server — an override carries no declared variables.
|
|
1200
1205
|
*/
|
|
1201
1206
|
readonly serverVariables?: Record<string, string>;
|
|
1207
|
+
/**
|
|
1208
|
+
* Credentials for the security schemes of the operation's OpenAPI document.
|
|
1209
|
+
* Only the schemes the operation requires are applied, each where its
|
|
1210
|
+
* scheme says (header, query or cookie); an operation with an empty
|
|
1211
|
+
* `security` gets none.
|
|
1212
|
+
*/
|
|
1213
|
+
readonly securities?: OpenAPIOperationSecurities;
|
|
1202
1214
|
readonly signal?: AbortSignal;
|
|
1215
|
+
/**
|
|
1216
|
+
* Runs after the executor-level interceptor, for this call only.
|
|
1217
|
+
*/
|
|
1203
1218
|
readonly requestInterceptor?: RequestInterceptor;
|
|
1219
|
+
/**
|
|
1220
|
+
* The Arazzo step this call is issued for, handed to both interceptors as
|
|
1221
|
+
* {@link RequestContext.step}. The step executor sets it; it is not
|
|
1222
|
+
* forwarded to `buildRequest`.
|
|
1223
|
+
*/
|
|
1224
|
+
readonly step?: RequestContextStep;
|
|
1204
1225
|
}
|
|
1205
1226
|
|
|
1206
1227
|
/**
|
|
@@ -1211,18 +1232,16 @@ export declare interface OpenAPIOperationExecuteOptions {
|
|
|
1211
1232
|
* the rest of `buildRequest`'s surface (`scheme`, `parameterBuilders`,
|
|
1212
1233
|
* `attachContentTypeForEmptyPayload`, …) passes through untouched.
|
|
1213
1234
|
*
|
|
1214
|
-
* Nothing routine belongs in the tail.
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1217
|
-
* standing in for a document fetched over HTTP, or credentials applied from the
|
|
1218
|
-
* document's own security schemes.
|
|
1235
|
+
* Nothing routine belongs in the tail. `server` covers every case that once
|
|
1236
|
+
* needed a `contextUrl`, so reaching for that here means an edge case: tests
|
|
1237
|
+
* standing in for a document fetched over HTTP.
|
|
1219
1238
|
*
|
|
1220
|
-
* Two kinds of entry are
|
|
1239
|
+
* Two kinds of entry are dropped rather than honored, since the executor owns
|
|
1221
1240
|
* what they used to control. The operation target always comes from the
|
|
1222
1241
|
* locator, so `operationId`/`operationPath` have no effect; and the options
|
|
1223
1242
|
* only swagger-client's `execute()` ever read — `userFetch` and
|
|
1224
1243
|
* `responseInterceptor`, which the runner replaces with `httpClient` and
|
|
1225
|
-
* `responseNormalizer` — reach `buildRequest
|
|
1244
|
+
* `responseNormalizer` — never reach `buildRequest`.
|
|
1226
1245
|
* @public
|
|
1227
1246
|
*/
|
|
1228
1247
|
export declare type OpenAPIOperationExecuteOptionsBag = OpenAPIOperationExecuteOptions & Record<string, unknown>;
|
|
@@ -1350,6 +1369,12 @@ export declare class OpenAPIOperationIndex extends Map<OperationId, JSONPointer>
|
|
|
1350
1369
|
export declare interface OpenAPIOperationLocator {
|
|
1351
1370
|
readonly document: OpenAPIDocument;
|
|
1352
1371
|
readonly jsonPointer: string;
|
|
1372
|
+
/**
|
|
1373
|
+
* The source description the step reached the operation through. Absent when
|
|
1374
|
+
* the reference names none (an `operationPath` with a literal URL) and on a
|
|
1375
|
+
* locator built by hand.
|
|
1376
|
+
*/
|
|
1377
|
+
readonly sourceDescription?: OpenAPIOperationSourceDescription;
|
|
1353
1378
|
}
|
|
1354
1379
|
|
|
1355
1380
|
/**
|
|
@@ -1609,6 +1634,44 @@ export declare class OpenAPIOperationResponseNormalizer {
|
|
|
1609
1634
|
normalize(response: Response, request?: OpenAPIOperationRequestInfo): Promise<OpenAPIOperationResponse>;
|
|
1610
1635
|
}
|
|
1611
1636
|
|
|
1637
|
+
/**
|
|
1638
|
+
* Credentials for the security schemes of an OpenAPI document, keyed by the
|
|
1639
|
+
* scheme name under `components.securitySchemes` (`securityDefinitions` in
|
|
1640
|
+
* OpenAPI 2.0).
|
|
1641
|
+
* @public
|
|
1642
|
+
*/
|
|
1643
|
+
export declare interface OpenAPIOperationSecurities {
|
|
1644
|
+
readonly authorized: Readonly<Record<string, OpenAPIOperationSecurityCredential>>;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* The credential for one security scheme, in the form the vendored
|
|
1649
|
+
* swagger-client applies it: the key or token itself (or `{ value }`) for an
|
|
1650
|
+
* `apiKey` or an `http` bearer scheme, `{ username, password }` for an `http`
|
|
1651
|
+
* basic scheme, and `{ token: { access_token, token_type } }` for an `oauth2`
|
|
1652
|
+
* or `openIdConnect` scheme.
|
|
1653
|
+
* @public
|
|
1654
|
+
*/
|
|
1655
|
+
export declare type OpenAPIOperationSecurityCredential = string | {
|
|
1656
|
+
readonly value: string;
|
|
1657
|
+
} | {
|
|
1658
|
+
readonly username: string;
|
|
1659
|
+
readonly password: string;
|
|
1660
|
+
} | {
|
|
1661
|
+
readonly token: Readonly<Record<string, string>>;
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* A source description as an Arazzo document declares it: its `name`, and the
|
|
1666
|
+
* URI of the Arazzo document that declares it. Names are local to their
|
|
1667
|
+
* document, so the pair identifies one source description across a run.
|
|
1668
|
+
* @public
|
|
1669
|
+
*/
|
|
1670
|
+
export declare interface OpenAPIOperationSourceDescription {
|
|
1671
|
+
readonly name: string;
|
|
1672
|
+
readonly documentURI: string;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1612
1675
|
/**
|
|
1613
1676
|
* Union of PathItemElement across all supported OpenAPI versions.
|
|
1614
1677
|
* @public
|
|
@@ -1717,15 +1780,58 @@ export declare class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
1717
1780
|
resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): ResolvedRequestBody | undefined;
|
|
1718
1781
|
}
|
|
1719
1782
|
|
|
1783
|
+
/**
|
|
1784
|
+
* Identifies the request a {@link RequestInterceptor} receives, so an
|
|
1785
|
+
* interceptor can target one operation or one step without matching on the
|
|
1786
|
+
* expanded URL.
|
|
1787
|
+
*
|
|
1788
|
+
* `operation` is always present: it is the operation's locator — its canonical
|
|
1789
|
+
* OpenAPI document URI, the JSON Pointer to it and, when the locator carries
|
|
1790
|
+
* one, the source description it was located through — plus the `operationId`
|
|
1791
|
+
* the document declares, if any. `step` is present only when the request is
|
|
1792
|
+
* issued for an Arazzo step, i.e. through the step executor (and so the runner); an
|
|
1793
|
+
* {@link OpenAPIOperationExecutor} used on its own receives it only when its
|
|
1794
|
+
* caller passes `step` in the execute options. Absent fields are omitted, never
|
|
1795
|
+
* `undefined`.
|
|
1796
|
+
* @public
|
|
1797
|
+
*/
|
|
1798
|
+
export declare interface RequestContext {
|
|
1799
|
+
readonly operation: {
|
|
1800
|
+
readonly documentURI: string;
|
|
1801
|
+
readonly jsonPointer: string;
|
|
1802
|
+
readonly operationId?: string;
|
|
1803
|
+
readonly sourceDescription?: OpenAPIOperationSourceDescription;
|
|
1804
|
+
};
|
|
1805
|
+
readonly step?: RequestContextStep;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* The Arazzo step a request is issued for: its `stepId`, and the `workflowId`
|
|
1810
|
+
* of the workflow it belongs to when the caller names one (step ids are only
|
|
1811
|
+
* unique within a workflow).
|
|
1812
|
+
* @public
|
|
1813
|
+
*/
|
|
1814
|
+
export declare interface RequestContextStep {
|
|
1815
|
+
readonly stepId: string;
|
|
1816
|
+
readonly workflowId?: string;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1720
1819
|
/**
|
|
1721
1820
|
* Decorates the built request before it is handed to the {@link HTTPClient}.
|
|
1722
1821
|
*
|
|
1723
1822
|
* Receives the finalized {@link OpenAPIOperationRequest} and may mutate it in
|
|
1724
1823
|
* place or return a replacement; returning nothing keeps the received request.
|
|
1725
|
-
* May be synchronous or asynchronous.
|
|
1824
|
+
* May be synchronous or asynchronous. The second argument identifies what the
|
|
1825
|
+
* request is for (see {@link RequestContext}); an interceptor that has no use
|
|
1826
|
+
* for it may declare only the first.
|
|
1827
|
+
*
|
|
1828
|
+
* Interceptors run after the body is serialized (a plain-object or array body
|
|
1829
|
+
* is already a JSON string, so a signature covers the exact bytes sent) and
|
|
1830
|
+
* after newlines in header values are squashed, and before the request is
|
|
1831
|
+
* captured for `$request.*` and handed to the transport.
|
|
1726
1832
|
* @public
|
|
1727
1833
|
*/
|
|
1728
|
-
export declare type RequestInterceptor = (request: OpenAPIOperationRequest) => OpenAPIOperationRequest | void | Promise<OpenAPIOperationRequest | void>;
|
|
1834
|
+
export declare type RequestInterceptor = (request: OpenAPIOperationRequest, context: RequestContext) => OpenAPIOperationRequest | void | Promise<OpenAPIOperationRequest | void>;
|
|
1729
1835
|
|
|
1730
1836
|
/**
|
|
1731
1837
|
* A resolved request body: the payload with all replacements applied, plus the
|
|
@@ -2174,6 +2280,14 @@ export declare abstract class SourceDescriptionsLocatorNormalizer {
|
|
|
2174
2280
|
} | undefined;
|
|
2175
2281
|
}
|
|
2176
2282
|
|
|
2283
|
+
/**
|
|
2284
|
+
* The execute options of a step: the opaque bag forwarded to the operation
|
|
2285
|
+
* executor, or a function returning it for the operation the step was located
|
|
2286
|
+
* to.
|
|
2287
|
+
* @public
|
|
2288
|
+
*/
|
|
2289
|
+
export declare type StepExecuteOptions = Record<string, unknown> | ((locator: OpenAPIOperationLocator) => Record<string, unknown>);
|
|
2290
|
+
|
|
2177
2291
|
/**
|
|
2178
2292
|
* The outcome of executing a single step.
|
|
2179
2293
|
* @public
|
|
@@ -2260,7 +2374,9 @@ export declare class StepExecutor {
|
|
|
2260
2374
|
* `executeOptions` is an opaque bag passed through to the operation executor
|
|
2261
2375
|
* (e.g. a `server` to run the step against, or an `AbortSignal`). The
|
|
2262
2376
|
* Arazzo-derived options (`operationId`, `parameters`, `requestBody`) always
|
|
2263
|
-
* take precedence over it.
|
|
2377
|
+
* take precedence over it. A function is called with the operation the step
|
|
2378
|
+
* was located to and returns the bag, for options that depend on which API
|
|
2379
|
+
* the step calls.
|
|
2264
2380
|
*
|
|
2265
2381
|
* A `signal` in that bag is honored here and not only at the transport: an
|
|
2266
2382
|
* already-aborted signal throws with reason `ExecutionError.Aborted` instead of issuing a
|
|
@@ -2272,7 +2388,7 @@ export declare class StepExecutor {
|
|
|
2272
2388
|
* here then carries it alongside the `stepId`, since step ids are only
|
|
2273
2389
|
* unique within a workflow. The workflow executor always passes it.
|
|
2274
2390
|
*/
|
|
2275
|
-
execute(step: StepElement, state: ContextSource, executeOptions?:
|
|
2391
|
+
execute(step: StepElement, state: ContextSource, executeOptions?: StepExecuteOptions, workflowId?: string): Promise<StepExecutionResult>;
|
|
2276
2392
|
/**
|
|
2277
2393
|
* Throws {@link ResolverError} unless the step's `successCriteria` is absent
|
|
2278
2394
|
* or a list of Criterion Objects: `malformed-criteria` for one that is
|
|
@@ -2505,10 +2621,23 @@ export declare interface WorkflowExecuteOptions {
|
|
|
2505
2621
|
*/
|
|
2506
2622
|
readonly inputs?: Record<string, unknown>;
|
|
2507
2623
|
/**
|
|
2508
|
-
*
|
|
2509
|
-
*
|
|
2624
|
+
* Execute options addressed to an API: keyed by the `name` of a source
|
|
2625
|
+
* description of the entry document, each entry the opaque client-specific
|
|
2626
|
+
* bag forwarded verbatim to {@link StepExecutor.execute} for the steps that
|
|
2627
|
+
* call an operation of the OpenAPI document that name points at (e.g. a
|
|
2628
|
+
* `server` to run against, or the credentials of its security schemes).
|
|
2629
|
+
*
|
|
2630
|
+
* An entry configures a document, not a name: a step of another Arazzo
|
|
2631
|
+
* document calling the same OpenAPI document gets the entry whatever name it
|
|
2632
|
+
* knows the document by, and one calling a different document under the same
|
|
2633
|
+
* name gets nothing. Steps of an API without an entry get no options.
|
|
2634
|
+
*
|
|
2635
|
+
* A key naming no source description, one naming a source description that
|
|
2636
|
+
* has no `url` or is not an OpenAPI document, two keys pointing at the same
|
|
2637
|
+
* document, and an entry that is not an object all throw before the first
|
|
2638
|
+
* request.
|
|
2510
2639
|
*/
|
|
2511
|
-
readonly executeOptions?: Record<string, unknown
|
|
2640
|
+
readonly executeOptions?: Record<string, Record<string, unknown>>;
|
|
2512
2641
|
/**
|
|
2513
2642
|
* Inputs for the workflows run implicitly to satisfy `dependsOn`, keyed by
|
|
2514
2643
|
* the `dependsOn` entry as written — the bare workflowId for a
|
|
@@ -2551,11 +2680,10 @@ export declare interface WorkflowExecuteOptions {
|
|
|
2551
2680
|
* is not something the steps did, and the steps that never ran were not
|
|
2552
2681
|
* decided against.
|
|
2553
2682
|
*
|
|
2554
|
-
* The signal is also forwarded to the transport
|
|
2555
|
-
*
|
|
2556
|
-
*
|
|
2557
|
-
*
|
|
2558
|
-
* option does — and this option wins when both are given.
|
|
2683
|
+
* The signal is also forwarded to the transport with every step's execute
|
|
2684
|
+
* options, so the request in flight when the abort lands is cancelled rather
|
|
2685
|
+
* than merely awaited. This option is the only way to cancel a run: a
|
|
2686
|
+
* `signal` in an `executeOptions` entry is dropped.
|
|
2559
2687
|
*/
|
|
2560
2688
|
readonly signal?: AbortSignal;
|
|
2561
2689
|
}
|