@usearazzo/runner 1.0.1-alpha.29 → 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 +7 -0
- package/README.md +27 -73
- package/dist/arazzo-runner.browser.js +161 -78
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +4 -4
- package/src/executor/OpenAPIOperationExecutor.cjs +65 -12
- package/src/executor/OpenAPIOperationExecutor.mjs +63 -12
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +31 -4
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +30 -4
- package/src/executor/StepExecutor.cjs +6 -4
- package/src/executor/StepExecutor.mjs +6 -4
- package/types/runner.d.ts +73 -4
|
@@ -11631,21 +11631,23 @@ class ArazzoWorkflowLocatorNormalizer extends _SourceDescriptionsLocatorNormaliz
|
|
|
11631
11631
|
|
|
11632
11632
|
"use strict";
|
|
11633
11633
|
__webpack_require__.r(__webpack_exports__);
|
|
11634
|
-
/* harmony import */ var
|
|
11635
|
-
/* harmony import */ var
|
|
11636
|
-
/* harmony import */ var
|
|
11637
|
-
/* harmony import */ var
|
|
11638
|
-
/* harmony import */ var
|
|
11639
|
-
/* harmony import */ var
|
|
11640
|
-
/* harmony import */ var
|
|
11641
|
-
/* harmony import */ var
|
|
11642
|
-
/* harmony import */ var
|
|
11643
|
-
/* harmony import */ var
|
|
11644
|
-
/* harmony import */ var
|
|
11645
|
-
/* harmony import */ var
|
|
11646
|
-
/* harmony import */ var
|
|
11647
|
-
/* harmony import */ var
|
|
11648
|
-
/* harmony import */ var
|
|
11634
|
+
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38506);
|
|
11635
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7456);
|
|
11636
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(62823);
|
|
11637
|
+
/* harmony import */ var _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30698);
|
|
11638
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_2__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(29716);
|
|
11639
|
+
/* harmony import */ var _swaggerexpert_cookie__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(36258);
|
|
11640
|
+
/* harmony import */ var _swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(93504);
|
|
11641
|
+
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(34606);
|
|
11642
|
+
/* harmony import */ var _vendor_swagger_client_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(96777);
|
|
11643
|
+
/* harmony import */ var _client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(55995);
|
|
11644
|
+
/* harmony import */ var _client_HTTPClientFetch_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(55549);
|
|
11645
|
+
/* harmony import */ var _client_OpenAPIOperationResponseNormalizer_ts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(63439);
|
|
11646
|
+
/* harmony import */ var _extractor_OpenAPIOperationExtractor_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(57658);
|
|
11647
|
+
/* harmony import */ var _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(87864);
|
|
11648
|
+
/* harmony import */ var _assembler_OpenAPIDocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(6898);
|
|
11649
|
+
/* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(81763);
|
|
11650
|
+
|
|
11649
11651
|
|
|
11650
11652
|
|
|
11651
11653
|
|
|
@@ -11664,12 +11666,42 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
11664
11666
|
|
|
11665
11667
|
|
|
11666
11668
|
|
|
11669
|
+
/**
|
|
11670
|
+
* The Arazzo step a request is issued for: its `stepId`, and the `workflowId`
|
|
11671
|
+
* of the workflow it belongs to when the caller names one (step ids are only
|
|
11672
|
+
* unique within a workflow).
|
|
11673
|
+
* @public
|
|
11674
|
+
*/
|
|
11675
|
+
|
|
11676
|
+
/**
|
|
11677
|
+
* Identifies the request a {@link RequestInterceptor} receives, so an
|
|
11678
|
+
* interceptor can target one operation or one step without matching on the
|
|
11679
|
+
* expanded URL.
|
|
11680
|
+
*
|
|
11681
|
+
* `operation` is always present: it is the operation's locator — its canonical
|
|
11682
|
+
* OpenAPI document URI, the JSON Pointer to it and, when the locator carries
|
|
11683
|
+
* one, the source description it was located through — plus the `operationId`
|
|
11684
|
+
* the document declares, if any. `step` is present only when the request is
|
|
11685
|
+
* issued for an Arazzo step, i.e. through the step executor (and so the runner); an
|
|
11686
|
+
* {@link OpenAPIOperationExecutor} used on its own receives it only when its
|
|
11687
|
+
* caller passes `step` in the execute options. Absent fields are omitted, never
|
|
11688
|
+
* `undefined`.
|
|
11689
|
+
* @public
|
|
11690
|
+
*/
|
|
11691
|
+
|
|
11667
11692
|
/**
|
|
11668
11693
|
* Decorates the built request before it is handed to the {@link HTTPClient}.
|
|
11669
11694
|
*
|
|
11670
11695
|
* Receives the finalized {@link OpenAPIOperationRequest} and may mutate it in
|
|
11671
11696
|
* place or return a replacement; returning nothing keeps the received request.
|
|
11672
|
-
* May be synchronous or asynchronous.
|
|
11697
|
+
* May be synchronous or asynchronous. The second argument identifies what the
|
|
11698
|
+
* request is for (see {@link RequestContext}); an interceptor that has no use
|
|
11699
|
+
* for it may declare only the first.
|
|
11700
|
+
*
|
|
11701
|
+
* Interceptors run after the body is serialized (a plain-object or array body
|
|
11702
|
+
* is already a JSON string, so a signature covers the exact bytes sent) and
|
|
11703
|
+
* after newlines in header values are squashed, and before the request is
|
|
11704
|
+
* captured for `$request.*` and handed to the transport.
|
|
11673
11705
|
* @public
|
|
11674
11706
|
*/
|
|
11675
11707
|
|
|
@@ -11737,12 +11769,12 @@ const IGNORED_HEADERS = new Set(['accept', 'authorization', 'content-type']);
|
|
|
11737
11769
|
* needed a `contextUrl`, so reaching for that here means an edge case: tests
|
|
11738
11770
|
* standing in for a document fetched over HTTP.
|
|
11739
11771
|
*
|
|
11740
|
-
* Two kinds of entry are
|
|
11772
|
+
* Two kinds of entry are dropped rather than honored, since the executor owns
|
|
11741
11773
|
* what they used to control. The operation target always comes from the
|
|
11742
11774
|
* locator, so `operationId`/`operationPath` have no effect; and the options
|
|
11743
11775
|
* only swagger-client's `execute()` ever read — `userFetch` and
|
|
11744
11776
|
* `responseInterceptor`, which the runner replaces with `httpClient` and
|
|
11745
|
-
* `responseNormalizer` — reach `buildRequest
|
|
11777
|
+
* `responseNormalizer` — never reach `buildRequest`.
|
|
11746
11778
|
* @public
|
|
11747
11779
|
*/
|
|
11748
11780
|
|
|
@@ -11781,12 +11813,12 @@ class OpenAPIOperationExecutor {
|
|
|
11781
11813
|
#operationNormalizer;
|
|
11782
11814
|
#documentAssembler;
|
|
11783
11815
|
constructor(options = {}) {
|
|
11784
|
-
this.#httpClient = options.httpClient ??
|
|
11816
|
+
this.#httpClient = options.httpClient ?? _client_HTTPClientFetch_ts__WEBPACK_IMPORTED_MODULE_10__["default"];
|
|
11785
11817
|
this.#requestInterceptor = options.requestInterceptor;
|
|
11786
|
-
this.#responseNormalizer = options.responseNormalizer ?? new
|
|
11787
|
-
this.#operationExtractor = options.operationExtractor ?? new
|
|
11788
|
-
this.#operationNormalizer = options.operationNormalizer ?? new
|
|
11789
|
-
this.#documentAssembler = options.documentAssembler ?? new
|
|
11818
|
+
this.#responseNormalizer = options.responseNormalizer ?? new _client_OpenAPIOperationResponseNormalizer_ts__WEBPACK_IMPORTED_MODULE_11__["default"]();
|
|
11819
|
+
this.#operationExtractor = options.operationExtractor ?? new _extractor_OpenAPIOperationExtractor_ts__WEBPACK_IMPORTED_MODULE_12__["default"]();
|
|
11820
|
+
this.#operationNormalizer = options.operationNormalizer ?? new _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_13__["default"]();
|
|
11821
|
+
this.#documentAssembler = options.documentAssembler ?? new _assembler_OpenAPIDocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_14__["default"]();
|
|
11790
11822
|
}
|
|
11791
11823
|
|
|
11792
11824
|
/**
|
|
@@ -11806,18 +11838,40 @@ class OpenAPIOperationExecutor {
|
|
|
11806
11838
|
const operation = this.#operationExtractor.extractByPointer(locator.document, locator.jsonPointer);
|
|
11807
11839
|
// the legacy id (`{method}-{path}`) matches regardless of an explicit
|
|
11808
11840
|
// `operationId` in the assembled document
|
|
11809
|
-
const operationId = (0,
|
|
11841
|
+
const operationId = (0,_vendor_swagger_client_mjs__WEBPACK_IMPORTED_MODULE_8__.idFromPathMethodLegacy)((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('path')), (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('http-method')));
|
|
11810
11842
|
const normalizedOperation = await this.#operationNormalizer.normalize(operation, locator.document);
|
|
11811
11843
|
const assembled = this.#documentAssembler.assemble(normalizedOperation, locator.document);
|
|
11812
11844
|
|
|
11813
|
-
// the interceptor
|
|
11814
|
-
// locator,
|
|
11845
|
+
// the interceptor and step are consumed here, the target always comes from
|
|
11846
|
+
// the locator, and the transport is the httpClient, so none of these
|
|
11847
|
+
// reach buildRequest
|
|
11815
11848
|
const {
|
|
11816
11849
|
requestInterceptor,
|
|
11817
|
-
|
|
11818
|
-
operationPath: __,
|
|
11819
|
-
...rest
|
|
11850
|
+
step
|
|
11820
11851
|
} = executeOptions;
|
|
11852
|
+
const rest = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['requestInterceptor', 'step', 'operationId', 'operationPath', 'userFetch', 'responseInterceptor'], executeOptions);
|
|
11853
|
+
const declaredOperationId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.operationId);
|
|
11854
|
+
const context = {
|
|
11855
|
+
operation: {
|
|
11856
|
+
documentURI: locator.document.uri,
|
|
11857
|
+
jsonPointer: locator.jsonPointer,
|
|
11858
|
+
...(typeof declaredOperationId === 'string' ? {
|
|
11859
|
+
operationId: declaredOperationId
|
|
11860
|
+
} : {}),
|
|
11861
|
+
...(locator.sourceDescription === undefined ? {} : {
|
|
11862
|
+
sourceDescription: {
|
|
11863
|
+
...locator.sourceDescription
|
|
11864
|
+
}
|
|
11865
|
+
})
|
|
11866
|
+
},
|
|
11867
|
+
// a copy, so an interceptor editing it cannot rewrite the caller's object
|
|
11868
|
+
// (the step executor reuses it to attribute errors)
|
|
11869
|
+
...(step === undefined ? {} : {
|
|
11870
|
+
step: {
|
|
11871
|
+
...step
|
|
11872
|
+
}
|
|
11873
|
+
})
|
|
11874
|
+
};
|
|
11821
11875
|
|
|
11822
11876
|
// each step derives the next options rather than editing in place
|
|
11823
11877
|
const withServer = this.#applyServerOptions(rest, normalizedOperation, locator.document);
|
|
@@ -11825,16 +11879,16 @@ class OpenAPIOperationExecutor {
|
|
|
11825
11879
|
const buildOptions = this.#adaptRequestContentType(withBody, normalizedOperation, locator.document, locator.jsonPointer);
|
|
11826
11880
|
const undeclared = this.#undeclaredParameters(buildOptions.parameters, normalizedOperation);
|
|
11827
11881
|
const spec = assembled.toJSON();
|
|
11828
|
-
this.#declareQueryAndPathParameters(spec, undeclared, (0,
|
|
11882
|
+
this.#declareQueryAndPathParameters(spec, undeclared, (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('path')), (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('http-method')), locator);
|
|
11829
11883
|
let request;
|
|
11830
11884
|
try {
|
|
11831
|
-
request = (0,
|
|
11885
|
+
request = (0,_vendor_swagger_client_mjs__WEBPACK_IMPORTED_MODULE_8__.buildRequest)({
|
|
11832
11886
|
...buildOptions,
|
|
11833
11887
|
spec,
|
|
11834
11888
|
operationId
|
|
11835
11889
|
});
|
|
11836
11890
|
} catch (error) {
|
|
11837
|
-
throw new
|
|
11891
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"]('Failed to build request for OpenAPI operation', {
|
|
11838
11892
|
operationPath: locator.jsonPointer,
|
|
11839
11893
|
cause: error
|
|
11840
11894
|
});
|
|
@@ -11848,7 +11902,7 @@ class OpenAPIOperationExecutor {
|
|
|
11848
11902
|
request.headers['Content-Type'] = authoredContentType;
|
|
11849
11903
|
}
|
|
11850
11904
|
this.#deliverHeadersAndCookies(request, undeclared);
|
|
11851
|
-
request = await this.#finalizeRequest(request, requestInterceptor);
|
|
11905
|
+
request = await this.#finalizeRequest(request, requestInterceptor, context);
|
|
11852
11906
|
|
|
11853
11907
|
// capture the request as sent, so `$url` / `$method` / `$request.*` can be
|
|
11854
11908
|
// evaluated after execution; headers are copied so a transport-side
|
|
@@ -11865,7 +11919,7 @@ class OpenAPIOperationExecutor {
|
|
|
11865
11919
|
try {
|
|
11866
11920
|
rawResponse = await this.#httpClient(request);
|
|
11867
11921
|
} catch (error) {
|
|
11868
|
-
throw new
|
|
11922
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"]('OpenAPI operation request failed', {
|
|
11869
11923
|
operationPath: locator.jsonPointer,
|
|
11870
11924
|
cause: error
|
|
11871
11925
|
});
|
|
@@ -11886,8 +11940,8 @@ class OpenAPIOperationExecutor {
|
|
|
11886
11940
|
* `buildRequest`: they name no location to deliver to.
|
|
11887
11941
|
*/
|
|
11888
11942
|
#undeclaredParameters(parameters, operation) {
|
|
11889
|
-
if (!(0,
|
|
11890
|
-
const declared = new Set(((0,
|
|
11943
|
+
if (!(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_7__["default"])(parameters)) return [];
|
|
11944
|
+
const declared = new Set(((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(operation.parameters) ? [...operation.parameters] : []).filter(_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement).map(parameter => `${(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(parameter.get('in'))}.${(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(parameter.get('name'))}`));
|
|
11891
11945
|
return Object.entries(parameters).flatMap(([key, value]) => {
|
|
11892
11946
|
const separator = key.indexOf('.');
|
|
11893
11947
|
const location = key.slice(0, separator);
|
|
@@ -11916,14 +11970,14 @@ class OpenAPIOperationExecutor {
|
|
|
11916
11970
|
*/
|
|
11917
11971
|
#declareQueryAndPathParameters(spec, undeclared, path, method, locator) {
|
|
11918
11972
|
const operation = spec.paths[path][method];
|
|
11919
|
-
const isSwagger = (0,
|
|
11973
|
+
const isSwagger = (0,_speclynx_apidom_ns_openapi_2__WEBPACK_IMPORTED_MODULE_4__.isSwaggerElement)(locator.document.parseResult.api);
|
|
11920
11974
|
for (const {
|
|
11921
11975
|
location,
|
|
11922
11976
|
name
|
|
11923
11977
|
} of undeclared) {
|
|
11924
11978
|
if (location !== 'query' && location !== 'path') continue;
|
|
11925
11979
|
if (location === 'path' && !path.includes(`{${name}}`)) {
|
|
11926
|
-
throw new
|
|
11980
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`Path parameter "${name}" is not declared by the operation and its path "${path}" ` + `has no "{${name}}" to substitute it into`, {
|
|
11927
11981
|
operationPath: locator.jsonPointer
|
|
11928
11982
|
});
|
|
11929
11983
|
}
|
|
@@ -11970,12 +12024,12 @@ class OpenAPIOperationExecutor {
|
|
|
11970
12024
|
if (cookies.length === 0) return;
|
|
11971
12025
|
// serialized as buildRequest serializes a declared cookie, so a `;` in the
|
|
11972
12026
|
// value is percent-encoded rather than splitting it into further cookies
|
|
11973
|
-
const serialized = (0,
|
|
12027
|
+
const serialized = (0,_swaggerexpert_cookie__WEBPACK_IMPORTED_MODULE_5__.serializeCookie)(cookies, {
|
|
11974
12028
|
encoders: {
|
|
11975
|
-
value:
|
|
12029
|
+
value: _swaggerexpert_cookie__WEBPACK_IMPORTED_MODULE_5__.cookieValueStrictPercentEncoder
|
|
11976
12030
|
},
|
|
11977
12031
|
validators: {
|
|
11978
|
-
name:
|
|
12032
|
+
name: _swaggerexpert_cookie__WEBPACK_IMPORTED_MODULE_5__.cookieNameLenientValidator
|
|
11979
12033
|
}
|
|
11980
12034
|
});
|
|
11981
12035
|
const cookieHeader = present('Cookie') ?? 'Cookie';
|
|
@@ -12019,7 +12073,7 @@ class OpenAPIOperationExecutor {
|
|
|
12019
12073
|
* resolving against somewhere the document did not come from.
|
|
12020
12074
|
*/
|
|
12021
12075
|
#applyServerOptions(buildOptions, operation, document) {
|
|
12022
|
-
const resolved = buildOptions.contextUrl === undefined &&
|
|
12076
|
+
const resolved = buildOptions.contextUrl === undefined && _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_3__.isHttpUrl(document.uri) ? {
|
|
12023
12077
|
...buildOptions,
|
|
12024
12078
|
contextUrl: document.uri
|
|
12025
12079
|
} : buildOptions;
|
|
@@ -12037,10 +12091,10 @@ class OpenAPIOperationExecutor {
|
|
|
12037
12091
|
// path valid for every version: isServerElement is per-namespace, and the
|
|
12038
12092
|
// 3.1 one rejects 3.0 servers
|
|
12039
12093
|
const servers = operation.get('servers');
|
|
12040
|
-
const declared = (0,
|
|
12041
|
-
const isDeclared = declared.some(candidate => (0,
|
|
12094
|
+
const declared = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(servers) ? [...servers] : [];
|
|
12095
|
+
const isDeclared = declared.some(candidate => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(candidate) && (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(candidate.get('url')) === server);
|
|
12042
12096
|
if (isDeclared) return resolved;
|
|
12043
|
-
const baseURL =
|
|
12097
|
+
const baseURL = _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_3__.hasProtocol(server) ? server : _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_3__.resolve(resolved.contextUrl ?? '', server);
|
|
12044
12098
|
|
|
12045
12099
|
// buildRequest concatenates the base and the path verbatim, so a trailing
|
|
12046
12100
|
// slash would double up. swagger-client trims one in its own resolution too
|
|
@@ -12075,11 +12129,11 @@ class OpenAPIOperationExecutor {
|
|
|
12075
12129
|
if (typeof requested !== 'string' || buildOptions.requestBody === undefined) {
|
|
12076
12130
|
return buildOptions;
|
|
12077
12131
|
}
|
|
12078
|
-
if ((0,
|
|
12132
|
+
if ((0,_speclynx_apidom_ns_openapi_2__WEBPACK_IMPORTED_MODULE_4__.isSwaggerElement)(document.parseResult.api)) return buildOptions;
|
|
12079
12133
|
const requestBody = operation.get('requestBody');
|
|
12080
|
-
const content = (0,
|
|
12081
|
-
if (!(0,
|
|
12082
|
-
throw new
|
|
12134
|
+
const content = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(requestBody) ? requestBody.get('content') : undefined;
|
|
12135
|
+
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(content)) {
|
|
12136
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`Request body media type "${requested}" cannot be sent: the operation declares ` + 'no request body content. Omit the content type to send the payload as-is', {
|
|
12083
12137
|
operationPath: jsonPointer
|
|
12084
12138
|
});
|
|
12085
12139
|
}
|
|
@@ -12087,8 +12141,8 @@ class OpenAPIOperationExecutor {
|
|
|
12087
12141
|
if (declared.includes(requested)) return buildOptions;
|
|
12088
12142
|
|
|
12089
12143
|
// a range or a malformed value names no concrete media type to send
|
|
12090
|
-
if ((0,
|
|
12091
|
-
throw new
|
|
12144
|
+
if ((0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.identify)(requested) !== 'media-type') {
|
|
12145
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`Request body media type "${requested}" is not a valid media type`, {
|
|
12092
12146
|
operationPath: jsonPointer
|
|
12093
12147
|
});
|
|
12094
12148
|
}
|
|
@@ -12096,18 +12150,18 @@ class OpenAPIOperationExecutor {
|
|
|
12096
12150
|
// a form media type decides how the body is encoded, and buildRequest applies
|
|
12097
12151
|
// that encoding only for an exactly declared type. matching one against a
|
|
12098
12152
|
// range would put a JSON body behind a form Content-Type
|
|
12099
|
-
const isFormEncoded = (0,
|
|
12153
|
+
const isFormEncoded = (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.matches)('application/x-www-form-urlencoded', requested) || (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.matches)('multipart/form-data', requested);
|
|
12100
12154
|
|
|
12101
12155
|
// otherwise a declared range covers a concrete type, so `*/*` (what several
|
|
12102
12156
|
// generators emit by default) accepts anything; the most specific wins.
|
|
12103
12157
|
// parameters on one side only (a declared `charset=utf-8`) describe the
|
|
12104
12158
|
// content rather than constrain it, while conflicting ones never match
|
|
12105
|
-
const candidates = isFormEncoded ? declared.filter(mediaType => (0,
|
|
12106
|
-
const match = (0,
|
|
12159
|
+
const candidates = isFormEncoded ? declared.filter(mediaType => (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.identify)(mediaType) === 'media-type') : declared;
|
|
12160
|
+
const match = (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.selectBestMatch)(candidates, requested, {
|
|
12107
12161
|
parameterMatching: 'compatible'
|
|
12108
12162
|
});
|
|
12109
12163
|
if (match === null) {
|
|
12110
|
-
throw new
|
|
12164
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](isFormEncoded ? `Request body media type "${requested}" must be declared by the operation exactly, ` + `since it decides how the body is encoded (declared: [${declared.join(', ')}])` : `Request body media type "${requested}" is not declared by the operation ` + `(declared: [${declared.join(', ')}])`, {
|
|
12111
12165
|
operationPath: jsonPointer
|
|
12112
12166
|
});
|
|
12113
12167
|
}
|
|
@@ -12145,7 +12199,7 @@ class OpenAPIOperationExecutor {
|
|
|
12145
12199
|
* `querystring` parameter under its bare name.
|
|
12146
12200
|
*/
|
|
12147
12201
|
#adaptRequestBody(buildOptions, operation, document, jsonPointer) {
|
|
12148
|
-
if (!(0,
|
|
12202
|
+
if (!(0,_speclynx_apidom_ns_openapi_2__WEBPACK_IMPORTED_MODULE_4__.isSwaggerElement)(document.parseResult.api) || buildOptions.requestBody === undefined) {
|
|
12149
12203
|
return buildOptions;
|
|
12150
12204
|
}
|
|
12151
12205
|
const {
|
|
@@ -12157,29 +12211,29 @@ class OpenAPIOperationExecutor {
|
|
|
12157
12211
|
// an operation declaring none leaves `parameters` absent rather than empty,
|
|
12158
12212
|
// and that case still has to reach the throw below
|
|
12159
12213
|
const declared = operation.parameters;
|
|
12160
|
-
const parameters = (0,
|
|
12214
|
+
const parameters = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(declared) ? [...declared.filter(_speclynx_apidom_ns_openapi_2__WEBPACK_IMPORTED_MODULE_4__.isParameterElement)] : [];
|
|
12161
12215
|
|
|
12162
12216
|
// the body parameter's name is arbitrary, so the payload wins over a
|
|
12163
12217
|
// same-keyed entry the caller supplied
|
|
12164
|
-
const body = parameters.find(parameter => (0,
|
|
12218
|
+
const body = parameters.find(parameter => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(parameter.in) === 'body');
|
|
12165
12219
|
if (body !== undefined) {
|
|
12166
|
-
const name = (0,
|
|
12220
|
+
const name = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(body.name);
|
|
12167
12221
|
this.#rejectBarePayloadConflicts(callerParameters, [name], jsonPointer);
|
|
12168
12222
|
return {
|
|
12169
12223
|
...rest,
|
|
12170
12224
|
parameters: {
|
|
12171
12225
|
...callerParameters,
|
|
12172
|
-
[
|
|
12226
|
+
[_client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_9__["default"].keyFor('body', name)]: requestBody
|
|
12173
12227
|
}
|
|
12174
12228
|
};
|
|
12175
12229
|
}
|
|
12176
12230
|
|
|
12177
12231
|
// formData models each field as its own parameter, so the payload's keys
|
|
12178
12232
|
// are the parameter names; buildRequest reports any that do not match
|
|
12179
|
-
const hasForm = parameters.some(parameter => (0,
|
|
12233
|
+
const hasForm = parameters.some(parameter => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(parameter.in) === 'formData');
|
|
12180
12234
|
if (hasForm) {
|
|
12181
|
-
if (!(0,
|
|
12182
|
-
throw new
|
|
12235
|
+
if (!(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_7__["default"])(requestBody)) {
|
|
12236
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"]('Request body cannot be sent: the OpenAPI 2.0 operation carries it in "formData" ' + 'parameters, so the payload must be an object keyed by their names', {
|
|
12183
12237
|
operationPath: jsonPointer
|
|
12184
12238
|
});
|
|
12185
12239
|
}
|
|
@@ -12189,14 +12243,14 @@ class OpenAPIOperationExecutor {
|
|
|
12189
12243
|
...callerParameters
|
|
12190
12244
|
};
|
|
12191
12245
|
for (const [field, value] of Object.entries(payload)) {
|
|
12192
|
-
merged[
|
|
12246
|
+
merged[_client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_9__["default"].keyFor('formData', field)] = value;
|
|
12193
12247
|
}
|
|
12194
12248
|
return {
|
|
12195
12249
|
...rest,
|
|
12196
12250
|
parameters: merged
|
|
12197
12251
|
};
|
|
12198
12252
|
}
|
|
12199
|
-
throw new
|
|
12253
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"]('Request body cannot be sent: the OpenAPI 2.0 operation declares no "body" or ' + '"formData" parameter to carry it', {
|
|
12200
12254
|
operationPath: jsonPointer
|
|
12201
12255
|
});
|
|
12202
12256
|
}
|
|
@@ -12211,7 +12265,7 @@ class OpenAPIOperationExecutor {
|
|
|
12211
12265
|
if (callerParameters === undefined) return;
|
|
12212
12266
|
const conflicts = payloadNames.filter(name => Object.hasOwn(callerParameters, name));
|
|
12213
12267
|
if (conflicts.length === 0) return;
|
|
12214
|
-
throw new
|
|
12268
|
+
throw new _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`Request body cannot be sent: bare parameter ${conflicts.length === 1 ? 'entry' : 'entries'} ` + `[${conflicts.join(', ')}] would displace the payload at delivery. Supply the ` + `parameter under its "{in}.{name}" key, or drop the duplicate`, {
|
|
12215
12269
|
operationPath: jsonPointer
|
|
12216
12270
|
});
|
|
12217
12271
|
}
|
|
@@ -12225,12 +12279,12 @@ class OpenAPIOperationExecutor {
|
|
|
12225
12279
|
* `http()`, which also fetch and throw on a non-2xx. Diff against those two
|
|
12226
12280
|
* when bumping swagger-client.
|
|
12227
12281
|
*/
|
|
12228
|
-
async #finalizeRequest(request, perCallInterceptor) {
|
|
12282
|
+
async #finalizeRequest(request, perCallInterceptor, context) {
|
|
12229
12283
|
let finalized = request;
|
|
12230
12284
|
|
|
12231
12285
|
// JSON-encode plain-object and array bodies, exactly as swagger-client's
|
|
12232
12286
|
// execute() does before handing the request to its transport
|
|
12233
|
-
if (finalized.body && ((0,
|
|
12287
|
+
if (finalized.body && ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_7__["default"])(finalized.body) || Array.isArray(finalized.body))) {
|
|
12234
12288
|
finalized.body = JSON.stringify(finalized.body);
|
|
12235
12289
|
}
|
|
12236
12290
|
|
|
@@ -12244,8 +12298,8 @@ class OpenAPIOperationExecutor {
|
|
|
12244
12298
|
finalized.headers[headerName] = value.replace(/\n+/g, ' ');
|
|
12245
12299
|
}
|
|
12246
12300
|
});
|
|
12247
|
-
finalized = (await this.#requestInterceptor?.(finalized)) ?? finalized;
|
|
12248
|
-
finalized = (await perCallInterceptor?.(finalized)) ?? finalized;
|
|
12301
|
+
finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
|
|
12302
|
+
finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
|
|
12249
12303
|
|
|
12250
12304
|
// for multipart/form-data, remove the built content-type so the transport
|
|
12251
12305
|
// sets one carrying the correct boundary
|
|
@@ -12299,6 +12353,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12299
12353
|
* @public
|
|
12300
12354
|
*/
|
|
12301
12355
|
|
|
12356
|
+
/**
|
|
12357
|
+
* A source description as an Arazzo document declares it: its `name`, and the
|
|
12358
|
+
* URI of the Arazzo document that declares it. Names are local to their
|
|
12359
|
+
* document, so the pair identifies one source description across a run.
|
|
12360
|
+
* @public
|
|
12361
|
+
*/
|
|
12362
|
+
|
|
12302
12363
|
/**
|
|
12303
12364
|
* Normalizes a step's OpenAPI operation locator to a canonical
|
|
12304
12365
|
* {@link OpenAPIOperationLocator} — the OpenAPI document and a JSON Pointer to
|
|
@@ -12363,8 +12424,11 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12363
12424
|
* locate an operation in the acquired OpenAPI document.
|
|
12364
12425
|
*/
|
|
12365
12426
|
async normalizeOperationPath(operationPath, document, scope) {
|
|
12427
|
+
let sourceName;
|
|
12366
12428
|
for (const expression of (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__.extract)(operationPath) ?? []) {
|
|
12367
12429
|
const parsed = this.parseSourceDescriptionsExpression(expression);
|
|
12430
|
+
// only the source whose url the path is built from names its document
|
|
12431
|
+
if (parsed?.reference === 'url') sourceName ??= parsed.sourceName;
|
|
12368
12432
|
if (parsed !== undefined && document.resolveSourceDescriptionURI(parsed.sourceName) === undefined) {
|
|
12369
12433
|
throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`operationPath "${operationPath}" names source description "${parsed.sourceName}", which the Arazzo document at "${document.uri}" does not define`, {
|
|
12370
12434
|
...scope,
|
|
@@ -12413,7 +12477,13 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12413
12477
|
}
|
|
12414
12478
|
return {
|
|
12415
12479
|
document: source,
|
|
12416
|
-
jsonPointer
|
|
12480
|
+
jsonPointer,
|
|
12481
|
+
...(sourceName === undefined ? {} : {
|
|
12482
|
+
sourceDescription: {
|
|
12483
|
+
name: sourceName,
|
|
12484
|
+
documentURI: document.uri
|
|
12485
|
+
}
|
|
12486
|
+
})
|
|
12417
12487
|
};
|
|
12418
12488
|
}
|
|
12419
12489
|
async #resolveSourced(expression, document, scope) {
|
|
@@ -12438,7 +12508,11 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12438
12508
|
}
|
|
12439
12509
|
return {
|
|
12440
12510
|
document: openapiDocument,
|
|
12441
|
-
jsonPointer
|
|
12511
|
+
jsonPointer,
|
|
12512
|
+
sourceDescription: {
|
|
12513
|
+
name: sourceName,
|
|
12514
|
+
documentURI: document.uri
|
|
12515
|
+
}
|
|
12442
12516
|
};
|
|
12443
12517
|
}
|
|
12444
12518
|
|
|
@@ -12455,7 +12529,10 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12455
12529
|
* until the first OpenAPI source is reached.
|
|
12456
12530
|
*/
|
|
12457
12531
|
async #resolvePlainOperationId(operationId, document, scope) {
|
|
12458
|
-
for (const
|
|
12532
|
+
for (const [name, {
|
|
12533
|
+
uri
|
|
12534
|
+
}] of document.sourceDescriptionIndex) {
|
|
12535
|
+
if (uri === undefined) continue;
|
|
12459
12536
|
const source = await this.registry.acquire(uri);
|
|
12460
12537
|
if (!_document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_3__["default"].is(source)) continue;
|
|
12461
12538
|
const jsonPointer = source.operationIndex.get(operationId);
|
|
@@ -12467,7 +12544,11 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12467
12544
|
}
|
|
12468
12545
|
return {
|
|
12469
12546
|
document: source,
|
|
12470
|
-
jsonPointer
|
|
12547
|
+
jsonPointer,
|
|
12548
|
+
sourceDescription: {
|
|
12549
|
+
name,
|
|
12550
|
+
documentURI: document.uri
|
|
12551
|
+
}
|
|
12471
12552
|
};
|
|
12472
12553
|
}
|
|
12473
12554
|
|
|
@@ -12769,15 +12850,17 @@ class StepExecutor {
|
|
|
12769
12850
|
const signal = (0,_abort_ts__WEBPACK_IMPORTED_MODULE_13__.readAbortSignal)(operationOptions);
|
|
12770
12851
|
(0,_abort_ts__WEBPACK_IMPORTED_MODULE_13__.throwIfAborted)(signal, scope);
|
|
12771
12852
|
|
|
12772
|
-
// the Arazzo-derived parameters
|
|
12773
|
-
// executeOptions bag so they take precedence over it. the
|
|
12774
|
-
// then forces the operation target on top of this
|
|
12853
|
+
// the Arazzo-derived parameters, request body and step identity are spread
|
|
12854
|
+
// after the opaque executeOptions bag so they take precedence over it. the
|
|
12855
|
+
// operation executor then forces the operation target on top of this
|
|
12856
|
+
// before executing.
|
|
12775
12857
|
let response;
|
|
12776
12858
|
try {
|
|
12777
12859
|
response = await this.#operationExecutor.execute(locator, {
|
|
12778
12860
|
...operationOptions,
|
|
12779
12861
|
parameters,
|
|
12780
|
-
...this.#requestBodyOptions(requestBody)
|
|
12862
|
+
...this.#requestBodyOptions(requestBody),
|
|
12863
|
+
step: scope
|
|
12781
12864
|
});
|
|
12782
12865
|
} catch (error) {
|
|
12783
12866
|
// a transport that honors the signal rejects the request it was told to
|