@usearazzo/runner 0.0.0-stage → 1.0.1-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +163 -2
- package/dist/arazzo-runner.browser.js +113245 -0
- package/dist/arazzo-runner.browser.min.js +1 -0
- package/package.json +95 -4
- package/src/ArazzoRunner.cjs +122 -0
- package/src/ArazzoRunner.mjs +113 -0
- package/src/action/ActionResolver.cjs +160 -0
- package/src/action/ActionResolver.mjs +150 -0
- package/src/assembler/OpenAPI2DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI2DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPI30DocumentAssembler.cjs +110 -0
- package/src/assembler/OpenAPI30DocumentAssembler.mjs +103 -0
- package/src/assembler/OpenAPI31DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI31DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPIDocumentAssembler.cjs +58 -0
- package/src/assembler/OpenAPIDocumentAssembler.mjs +50 -0
- package/src/client/HTTPClient.cjs +5 -0
- package/src/client/HTTPClient.mjs +1 -0
- package/src/client/HTTPClientFetch.cjs +16 -0
- package/src/client/HTTPClientFetch.mjs +10 -0
- package/src/client/OpenAPIOperationRequest.cjs +5 -0
- package/src/client/OpenAPIOperationRequest.mjs +1 -0
- package/src/client/OpenAPIOperationResponse.cjs +42 -0
- package/src/client/OpenAPIOperationResponse.mjs +36 -0
- package/src/client/OpenAPIOperationResponseNormalizer.cjs +48 -0
- package/src/client/OpenAPIOperationResponseNormalizer.mjs +40 -0
- package/src/client/ParameterDelivery.cjs +119 -0
- package/src/client/ParameterDelivery.mjs +113 -0
- package/src/constants.cjs +9 -0
- package/src/constants.mjs +3 -0
- package/src/criterion/CriterionEvaluator.cjs +205 -0
- package/src/criterion/CriterionEvaluator.mjs +196 -0
- package/src/criterion/JSONPathCriterionEvaluator.cjs +47 -0
- package/src/criterion/JSONPathCriterionEvaluator.mjs +40 -0
- package/src/criterion/RegexCriterionEvaluator.cjs +67 -0
- package/src/criterion/RegexCriterionEvaluator.mjs +60 -0
- package/src/criterion/SimpleCriterionEvaluator.cjs +50 -0
- package/src/criterion/SimpleCriterionEvaluator.mjs +43 -0
- package/src/criterion/XPathCriterionEvaluator.cjs +117 -0
- package/src/criterion/XPathCriterionEvaluator.mjs +109 -0
- package/src/document/APIDocument.cjs +35 -0
- package/src/document/APIDocument.mjs +30 -0
- package/src/document/ArazzoDocument.cjs +81 -0
- package/src/document/ArazzoDocument.mjs +74 -0
- package/src/document/ArazzoSourceDescriptionIndex.cjs +26 -0
- package/src/document/ArazzoSourceDescriptionIndex.mjs +20 -0
- package/src/document/ArazzoStepIndex.cjs +25 -0
- package/src/document/ArazzoStepIndex.mjs +19 -0
- package/src/document/ArazzoWorkflowIndex.cjs +17 -0
- package/src/document/ArazzoWorkflowIndex.mjs +11 -0
- package/src/document/OpenAPIDocument.cjs +28 -0
- package/src/document/OpenAPIDocument.mjs +21 -0
- package/src/document/OpenAPIOperationIndex.cjs +24 -0
- package/src/document/OpenAPIOperationIndex.mjs +18 -0
- package/src/document/ParameterIdentity.cjs +93 -0
- package/src/document/ParameterIdentity.mjs +88 -0
- package/src/document/openapi-types.cjs +5 -0
- package/src/document/openapi-types.mjs +1 -0
- package/src/errors/ArazzoRunnerError.cjs +10 -0
- package/src/errors/ArazzoRunnerError.mjs +5 -0
- package/src/errors/AssemblerError.cjs +11 -0
- package/src/errors/AssemblerError.mjs +4 -0
- package/src/errors/ClientError.cjs +11 -0
- package/src/errors/ClientError.mjs +4 -0
- package/src/errors/CriterionError.cjs +11 -0
- package/src/errors/CriterionError.mjs +4 -0
- package/src/errors/ExecutionError.cjs +11 -0
- package/src/errors/ExecutionError.mjs +4 -0
- package/src/errors/ExtractionError.cjs +11 -0
- package/src/errors/ExtractionError.mjs +4 -0
- package/src/errors/InvalidEntryDocumentError.cjs +11 -0
- package/src/errors/InvalidEntryDocumentError.mjs +4 -0
- package/src/errors/NormalizationError.cjs +11 -0
- package/src/errors/NormalizationError.mjs +4 -0
- package/src/errors/ResolverError.cjs +11 -0
- package/src/errors/ResolverError.mjs +4 -0
- package/src/errors/RuntimeExpressionError.cjs +11 -0
- package/src/errors/RuntimeExpressionError.mjs +4 -0
- package/src/errors/UnmatchedProviderError.cjs +11 -0
- package/src/errors/UnmatchedProviderError.mjs +4 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +147 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +137 -0
- package/src/executor/OpenAPIOperationExecutor.cjs +458 -0
- package/src/executor/OpenAPIOperationExecutor.mjs +447 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +197 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +189 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.cjs +44 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.mjs +38 -0
- package/src/executor/StepExecutor.cjs +333 -0
- package/src/executor/StepExecutor.mjs +326 -0
- package/src/executor/StepRetryRunner.cjs +226 -0
- package/src/executor/StepRetryRunner.mjs +215 -0
- package/src/executor/StepTransitionInterpreter.cjs +159 -0
- package/src/executor/StepTransitionInterpreter.mjs +151 -0
- package/src/executor/WorkflowCallStack.cjs +116 -0
- package/src/executor/WorkflowCallStack.mjs +106 -0
- package/src/executor/WorkflowExecutor.cjs +1091 -0
- package/src/executor/WorkflowExecutor.mjs +1077 -0
- package/src/executor/abort.cjs +70 -0
- package/src/executor/abort.mjs +60 -0
- package/src/expression/RuntimeExpressionContext.cjs +5 -0
- package/src/expression/RuntimeExpressionContext.mjs +1 -0
- package/src/expression/RuntimeExpressionEvaluator.cjs +337 -0
- package/src/expression/RuntimeExpressionEvaluator.mjs +328 -0
- package/src/extractor/ArazzoStepExtractor.cjs +48 -0
- package/src/extractor/ArazzoStepExtractor.mjs +41 -0
- package/src/extractor/ArazzoWorkflowExtractor.cjs +50 -0
- package/src/extractor/ArazzoWorkflowExtractor.mjs +43 -0
- package/src/extractor/OpenAPIOperationExtractor.cjs +84 -0
- package/src/extractor/OpenAPIOperationExtractor.mjs +77 -0
- package/src/index.cjs +426 -0
- package/src/index.mjs +75 -0
- package/src/normalizer/ArazzoStepNormalizer.cjs +23 -0
- package/src/normalizer/ArazzoStepNormalizer.mjs +17 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.cjs +214 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.mjs +206 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.cjs +128 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.mjs +120 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.cjs +129 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.mjs +121 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.cjs +131 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.mjs +123 -0
- package/src/normalizer/OpenAPIOperationNormalizer.cjs +58 -0
- package/src/normalizer/OpenAPIOperationNormalizer.mjs +50 -0
- package/src/registry/DocumentRegistry.cjs +160 -0
- package/src/registry/DocumentRegistry.mjs +151 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +154 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +146 -0
- package/src/registry/providers/DocumentRegistryProvider.cjs +31 -0
- package/src/registry/providers/DocumentRegistryProvider.mjs +25 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +122 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +114 -0
- package/src/resolver/ArazzoValueResolver.cjs +42 -0
- package/src/resolver/ArazzoValueResolver.mjs +37 -0
- package/src/resolver/OpenAPIOperationParameterResolver.cjs +117 -0
- package/src/resolver/OpenAPIOperationParameterResolver.mjs +110 -0
- package/src/resolver/OutputResolver.cjs +71 -0
- package/src/resolver/OutputResolver.mjs +64 -0
- package/src/resolver/RequestBodyResolver.cjs +227 -0
- package/src/resolver/RequestBodyResolver.mjs +220 -0
- package/src/resolver/ResolverScope.cjs +5 -0
- package/src/resolver/ResolverScope.mjs +1 -0
- package/src/resolver/StepParameterResolver.cjs +22 -0
- package/src/resolver/StepParameterResolver.mjs +15 -0
- package/src/resolver/WorkflowParameterResolver.cjs +73 -0
- package/src/resolver/WorkflowParameterResolver.mjs +66 -0
- package/src/state/WorkflowExecutionState.cjs +99 -0
- package/src/state/WorkflowExecutionState.mjs +93 -0
- package/src/vendor/swagger-client.cjs +1 -0
- package/src/vendor/swagger-client.mjs +1 -0
- package/types/runner.d.ts +2410 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-2");
|
|
9
|
+
var _apidomNsOpenapi2 = require("@speclynx/apidom-ns-openapi-3-0");
|
|
10
|
+
var _apidomNsOpenapi3 = require("@speclynx/apidom-ns-openapi-3-1");
|
|
11
|
+
var _AssemblerError = _interopRequireDefault(require("../errors/AssemblerError.cjs"));
|
|
12
|
+
var _OpenAPI2DocumentAssembler = _interopRequireDefault(require("./OpenAPI2DocumentAssembler.cjs"));
|
|
13
|
+
var _OpenAPI30DocumentAssembler = _interopRequireDefault(require("./OpenAPI30DocumentAssembler.cjs"));
|
|
14
|
+
var _OpenAPI31DocumentAssembler = _interopRequireDefault(require("./OpenAPI31DocumentAssembler.cjs"));
|
|
15
|
+
/**
|
|
16
|
+
* Options for the OpenAPI document assembler facade.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Facade for assembling standalone OpenAPI documents across all supported versions.
|
|
22
|
+
*
|
|
23
|
+
* Detects the OpenAPI version from the source document and delegates to the
|
|
24
|
+
* appropriate version-specific assembler (2.0, 3.0, or 3.1).
|
|
25
|
+
*
|
|
26
|
+
* Custom assembler instances can be provided via constructor options.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
class OpenAPIDocumentAssembler {
|
|
30
|
+
#openapi2;
|
|
31
|
+
#openapi30;
|
|
32
|
+
#openapi31;
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
this.#openapi2 = options.openapi2 ?? new _OpenAPI2DocumentAssembler.default();
|
|
35
|
+
this.#openapi30 = options.openapi30 ?? new _OpenAPI30DocumentAssembler.default();
|
|
36
|
+
this.#openapi31 = options.openapi31 ?? new _OpenAPI31DocumentAssembler.default();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Assembles a standalone OpenAPI document by delegating to the version-specific assembler.
|
|
41
|
+
*/
|
|
42
|
+
assemble(operation, document) {
|
|
43
|
+
const root = document.parseResult.api;
|
|
44
|
+
if ((0, _apidomNsOpenapi.isSwaggerElement)(root)) {
|
|
45
|
+
return this.#openapi2.assemble(operation, document);
|
|
46
|
+
}
|
|
47
|
+
if ((0, _apidomNsOpenapi2.isOpenApi3_0Element)(root)) {
|
|
48
|
+
return this.#openapi30.assemble(operation, document);
|
|
49
|
+
}
|
|
50
|
+
if ((0, _apidomNsOpenapi3.isOpenApi3_1Element)(root)) {
|
|
51
|
+
return this.#openapi31.assemble(operation, document);
|
|
52
|
+
}
|
|
53
|
+
throw new _AssemblerError.default(`Unsupported OpenAPI version in document at "${document.uri}"`, {
|
|
54
|
+
uri: document.uri
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var _default = exports.default = OpenAPIDocumentAssembler;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isSwaggerElement } from '@speclynx/apidom-ns-openapi-2';
|
|
2
|
+
import { isOpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
|
|
3
|
+
import { isOpenApi3_1Element } from '@speclynx/apidom-ns-openapi-3-1';
|
|
4
|
+
import AssemblerError from "../errors/AssemblerError.mjs";
|
|
5
|
+
import OpenAPI2DocumentAssembler from "./OpenAPI2DocumentAssembler.mjs";
|
|
6
|
+
import OpenAPI30DocumentAssembler from "./OpenAPI30DocumentAssembler.mjs";
|
|
7
|
+
import OpenAPI31DocumentAssembler from "./OpenAPI31DocumentAssembler.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* Options for the OpenAPI document assembler facade.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Facade for assembling standalone OpenAPI documents across all supported versions.
|
|
14
|
+
*
|
|
15
|
+
* Detects the OpenAPI version from the source document and delegates to the
|
|
16
|
+
* appropriate version-specific assembler (2.0, 3.0, or 3.1).
|
|
17
|
+
*
|
|
18
|
+
* Custom assembler instances can be provided via constructor options.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
class OpenAPIDocumentAssembler {
|
|
22
|
+
#openapi2;
|
|
23
|
+
#openapi30;
|
|
24
|
+
#openapi31;
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
this.#openapi2 = options.openapi2 ?? new OpenAPI2DocumentAssembler();
|
|
27
|
+
this.#openapi30 = options.openapi30 ?? new OpenAPI30DocumentAssembler();
|
|
28
|
+
this.#openapi31 = options.openapi31 ?? new OpenAPI31DocumentAssembler();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Assembles a standalone OpenAPI document by delegating to the version-specific assembler.
|
|
33
|
+
*/
|
|
34
|
+
assemble(operation, document) {
|
|
35
|
+
const root = document.parseResult.api;
|
|
36
|
+
if (isSwaggerElement(root)) {
|
|
37
|
+
return this.#openapi2.assemble(operation, document);
|
|
38
|
+
}
|
|
39
|
+
if (isOpenApi3_0Element(root)) {
|
|
40
|
+
return this.#openapi30.assemble(operation, document);
|
|
41
|
+
}
|
|
42
|
+
if (isOpenApi3_1Element(root)) {
|
|
43
|
+
return this.#openapi31.assemble(operation, document);
|
|
44
|
+
}
|
|
45
|
+
throw new AssemblerError(`Unsupported OpenAPI version in document at "${document.uri}"`, {
|
|
46
|
+
uri: document.uri
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export default OpenAPIDocumentAssembler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The default {@link HTTPClient}: global fetch.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors swagger-client's own transport line — the request object doubles as
|
|
11
|
+
* fetch init, so `method`, `headers`, `body`, `credentials`, and `signal` are
|
|
12
|
+
* picked up from it directly.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
const httpClientFetch = request => fetch(request.url, request);
|
|
16
|
+
var _default = exports.default = httpClientFetch;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default {@link HTTPClient}: global fetch.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors swagger-client's own transport line — the request object doubles as
|
|
5
|
+
* fetch init, so `method`, `headers`, `body`, `credentials`, and `signal` are
|
|
6
|
+
* picked up from it directly.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
const httpClientFetch = request => fetch(request.url, request);
|
|
10
|
+
export default httpClientFetch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The HTTP request an OpenAPI operation was executed with.
|
|
9
|
+
*
|
|
10
|
+
* An immutable snapshot of the request as actually sent, recorded by the
|
|
11
|
+
* executor after the interceptors ran and before the transport was called, so
|
|
12
|
+
* runtime expressions (`$url`, `$method`, `$request.header.*`, `$request.body`)
|
|
13
|
+
* can be evaluated against it after execution. `headers` is a copy taken at
|
|
14
|
+
* capture time; `body` shares its reference with the sent request.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Response from an OpenAPI operation execution.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
class OpenAPIOperationResponse {
|
|
23
|
+
ok;
|
|
24
|
+
url;
|
|
25
|
+
status;
|
|
26
|
+
statusText;
|
|
27
|
+
headers;
|
|
28
|
+
text;
|
|
29
|
+
body;
|
|
30
|
+
request;
|
|
31
|
+
constructor(raw) {
|
|
32
|
+
this.ok = raw.ok;
|
|
33
|
+
this.url = raw.url;
|
|
34
|
+
this.status = raw.status;
|
|
35
|
+
this.statusText = raw.statusText;
|
|
36
|
+
this.headers = raw.headers;
|
|
37
|
+
this.text = raw.text;
|
|
38
|
+
this.body = raw.body;
|
|
39
|
+
this.request = raw.request;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var _default = exports.default = OpenAPIOperationResponse;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP request an OpenAPI operation was executed with.
|
|
3
|
+
*
|
|
4
|
+
* An immutable snapshot of the request as actually sent, recorded by the
|
|
5
|
+
* executor after the interceptors ran and before the transport was called, so
|
|
6
|
+
* runtime expressions (`$url`, `$method`, `$request.header.*`, `$request.body`)
|
|
7
|
+
* can be evaluated against it after execution. `headers` is a copy taken at
|
|
8
|
+
* capture time; `body` shares its reference with the sent request.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Response from an OpenAPI operation execution.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class OpenAPIOperationResponse {
|
|
17
|
+
ok;
|
|
18
|
+
url;
|
|
19
|
+
status;
|
|
20
|
+
statusText;
|
|
21
|
+
headers;
|
|
22
|
+
text;
|
|
23
|
+
body;
|
|
24
|
+
request;
|
|
25
|
+
constructor(raw) {
|
|
26
|
+
this.ok = raw.ok;
|
|
27
|
+
this.url = raw.url;
|
|
28
|
+
this.status = raw.status;
|
|
29
|
+
this.statusText = raw.statusText;
|
|
30
|
+
this.headers = raw.headers;
|
|
31
|
+
this.text = raw.text;
|
|
32
|
+
this.body = raw.body;
|
|
33
|
+
this.request = raw.request;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export default OpenAPIOperationResponse;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _swaggerClient = require("../vendor/swagger-client.cjs");
|
|
9
|
+
var _OpenAPIOperationResponse = _interopRequireDefault(require("./OpenAPIOperationResponse.cjs"));
|
|
10
|
+
// @ts-expect-error vendored swagger-client bundle has no type declarations
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Normalizes a raw WHATWG `Response` into an {@link OpenAPIOperationResponse}.
|
|
14
|
+
*
|
|
15
|
+
* Wraps the vendored swagger-client response deserializer (upstream
|
|
16
|
+
* `serializeRes`, aliased at the vendor boundary), whose battle-tested
|
|
17
|
+
* content-type dispatch (JSON/XML/YAML/text vs binary) means the response
|
|
18
|
+
* model runtime expressions and criteria see is defined here, on the runner's
|
|
19
|
+
* side of the {@link HTTPClient} seam, and stays identical across transports.
|
|
20
|
+
* Headers are taken from the `Response` directly rather than from the
|
|
21
|
+
* deserializer, which splits every value containing `", "` into an array:
|
|
22
|
+
* values stay strings as sent, with repeated fields (`Set-Cookie` included)
|
|
23
|
+
* combined by `Headers.get`.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
class OpenAPIOperationResponseNormalizer {
|
|
27
|
+
/**
|
|
28
|
+
* Deserializes the response body by content type and maps the result into the
|
|
29
|
+
* runner's response model. `request` is the request the operation was
|
|
30
|
+
* executed with; its `url` doubles as the fallback when the `Response`
|
|
31
|
+
* carries none (e.g. a stubbed transport).
|
|
32
|
+
*/
|
|
33
|
+
async normalize(response, request) {
|
|
34
|
+
const deserialized = await (0, _swaggerClient.deserializeResponse)(response, request?.url);
|
|
35
|
+
const headers = Object.fromEntries(Array.from(response.headers.keys(), name => [name, response.headers.get(name)]));
|
|
36
|
+
return new _OpenAPIOperationResponse.default({
|
|
37
|
+
ok: deserialized.ok,
|
|
38
|
+
url: deserialized.url,
|
|
39
|
+
status: deserialized.status,
|
|
40
|
+
statusText: deserialized.statusText,
|
|
41
|
+
headers,
|
|
42
|
+
text: deserialized.text,
|
|
43
|
+
body: deserialized.body,
|
|
44
|
+
request
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var _default = exports.default = OpenAPIOperationResponseNormalizer;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-expect-error vendored swagger-client bundle has no type declarations
|
|
2
|
+
import { deserializeResponse } from '../vendor/swagger-client.mjs';
|
|
3
|
+
import OpenAPIOperationResponse from "./OpenAPIOperationResponse.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes a raw WHATWG `Response` into an {@link OpenAPIOperationResponse}.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the vendored swagger-client response deserializer (upstream
|
|
8
|
+
* `serializeRes`, aliased at the vendor boundary), whose battle-tested
|
|
9
|
+
* content-type dispatch (JSON/XML/YAML/text vs binary) means the response
|
|
10
|
+
* model runtime expressions and criteria see is defined here, on the runner's
|
|
11
|
+
* side of the {@link HTTPClient} seam, and stays identical across transports.
|
|
12
|
+
* Headers are taken from the `Response` directly rather than from the
|
|
13
|
+
* deserializer, which splits every value containing `", "` into an array:
|
|
14
|
+
* values stay strings as sent, with repeated fields (`Set-Cookie` included)
|
|
15
|
+
* combined by `Headers.get`.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class OpenAPIOperationResponseNormalizer {
|
|
19
|
+
/**
|
|
20
|
+
* Deserializes the response body by content type and maps the result into the
|
|
21
|
+
* runner's response model. `request` is the request the operation was
|
|
22
|
+
* executed with; its `url` doubles as the fallback when the `Response`
|
|
23
|
+
* carries none (e.g. a stubbed transport).
|
|
24
|
+
*/
|
|
25
|
+
async normalize(response, request) {
|
|
26
|
+
const deserialized = await deserializeResponse(response, request?.url);
|
|
27
|
+
const headers = Object.fromEntries(Array.from(response.headers.keys(), name => [name, response.headers.get(name)]));
|
|
28
|
+
return new OpenAPIOperationResponse({
|
|
29
|
+
ok: deserialized.ok,
|
|
30
|
+
url: deserialized.url,
|
|
31
|
+
status: deserialized.status,
|
|
32
|
+
statusText: deserialized.statusText,
|
|
33
|
+
headers,
|
|
34
|
+
text: deserialized.text,
|
|
35
|
+
body: deserialized.body,
|
|
36
|
+
request
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default OpenAPIOperationResponseNormalizer;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The outcome of claiming a delivery key: `claimed` for a first claim,
|
|
9
|
+
* `duplicate` when the same `(name, in)` parameter claims its key again, and
|
|
10
|
+
* `collision` when a *different* parameter produces an already-claimed key.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A parameter claim: the delivery key the `(location, name)` pair encodes to,
|
|
16
|
+
* and how the claim resolved against the map's earlier entries.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The parameters map an OpenAPI operation is executed with — the single owner
|
|
22
|
+
* of the vendored swagger-client's parameter-addressing scheme.
|
|
23
|
+
*
|
|
24
|
+
* The client accepts two key shapes in its `parameters` map and, for each
|
|
25
|
+
* parameter the operation declares, consults the bare `name` *before* the
|
|
26
|
+
* qualified `'{in}.{name}'` key (deminified from the vendored bundle:
|
|
27
|
+
* `r = m[e.name]; if (r === undefined) r = m[`${e.in}.${e.name}`]`). Two
|
|
28
|
+
* consequences shape everything that feeds the map:
|
|
29
|
+
*
|
|
30
|
+
* - qualified keys are what let parameters differing only in their location
|
|
31
|
+
* coexist — the client builds the same key from the declared parameter and
|
|
32
|
+
* matches it verbatim, never splitting it, so dots in a name are safe;
|
|
33
|
+
* - a bare key silently outranks the qualified keys of every declared
|
|
34
|
+
* parameter bearing that name, so nothing may emit one for a location the
|
|
35
|
+
* client can address.
|
|
36
|
+
*
|
|
37
|
+
* Arazzo's `querystring` is the one location the client cannot address — it
|
|
38
|
+
* names no OpenAPI location — so it keeps the bare name, which can still
|
|
39
|
+
* reach a same-named declared parameter. Every other location is qualified,
|
|
40
|
+
* including an unrecognized one: an unmatched qualified key is inert, where a
|
|
41
|
+
* bare one would capture.
|
|
42
|
+
*
|
|
43
|
+
* Keys are claimed first-wins. The scheme is not injective, so the map also
|
|
44
|
+
* discriminates a genuine duplicate from a collision of two different
|
|
45
|
+
* parameters on one key: given a key, the claimant's name is determined by
|
|
46
|
+
* its location (the key embeds the name, or is the name), so the location
|
|
47
|
+
* alone identifies the claimant. A bare key and a qualified key sharing one
|
|
48
|
+
* name are a collision too, even though the keys differ — the client consults
|
|
49
|
+
* the bare name first for every declared parameter bearing it, so the bare
|
|
50
|
+
* entry would silently capture the qualified one. What to do about a
|
|
51
|
+
* collision is the caller's policy — the map only reports it.
|
|
52
|
+
*
|
|
53
|
+
* Diff this against the vendored bundle's lookup when bumping swagger-client.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
class ParameterDelivery {
|
|
57
|
+
/**
|
|
58
|
+
* The key a `(location, name)` pair is delivered under — `'{in}.{name}'`,
|
|
59
|
+
* or the bare name for `querystring`. See the class doc for why.
|
|
60
|
+
*/
|
|
61
|
+
static keyFor(location, name) {
|
|
62
|
+
return location === 'querystring' ? name : `${location}.${name}`;
|
|
63
|
+
}
|
|
64
|
+
#values = {};
|
|
65
|
+
#claimedBy = new Map();
|
|
66
|
+
#bareNames = new Set();
|
|
67
|
+
#qualifiedNames = new Set();
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Claims the delivery key for a `(location, name)` pair, first-wins.
|
|
71
|
+
* Only a `claimed` outcome entitles the caller to {@link ParameterDelivery.set}
|
|
72
|
+
* the key; a `duplicate` means the same parameter already holds it, and a
|
|
73
|
+
* `collision` means a different parameter does — on the same key, or across
|
|
74
|
+
* a bare/qualified pair sharing the name (see the class doc).
|
|
75
|
+
*/
|
|
76
|
+
claim(location, name) {
|
|
77
|
+
const key = ParameterDelivery.keyFor(location, name);
|
|
78
|
+
const claimant = this.#claimedBy.get(key);
|
|
79
|
+
if (claimant !== undefined) {
|
|
80
|
+
return {
|
|
81
|
+
key,
|
|
82
|
+
outcome: claimant === location ? 'duplicate' : 'collision'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const bare = key === name;
|
|
86
|
+
if (bare ? this.#qualifiedNames.has(name) : this.#bareNames.has(name)) {
|
|
87
|
+
return {
|
|
88
|
+
key,
|
|
89
|
+
outcome: 'collision'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
(bare ? this.#bareNames : this.#qualifiedNames).add(name);
|
|
93
|
+
this.#claimedBy.set(key, location);
|
|
94
|
+
return {
|
|
95
|
+
key,
|
|
96
|
+
outcome: 'claimed'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
set(key, value) {
|
|
100
|
+
// defined rather than assigned: a key like `__proto__` hits the
|
|
101
|
+
// Object.prototype accessor on bracket assignment, so no own property is
|
|
102
|
+
// ever created and the parameter is silently lost — and an object value
|
|
103
|
+
// additionally rewrites the record's prototype
|
|
104
|
+
Object.defineProperty(this.#values, key, {
|
|
105
|
+
value,
|
|
106
|
+
enumerable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The accumulated record, in the shape `buildRequest` consumes.
|
|
114
|
+
*/
|
|
115
|
+
toRecord() {
|
|
116
|
+
return this.#values;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
var _default = exports.default = ParameterDelivery;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The outcome of claiming a delivery key: `claimed` for a first claim,
|
|
3
|
+
* `duplicate` when the same `(name, in)` parameter claims its key again, and
|
|
4
|
+
* `collision` when a *different* parameter produces an already-claimed key.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A parameter claim: the delivery key the `(location, name)` pair encodes to,
|
|
10
|
+
* and how the claim resolved against the map's earlier entries.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The parameters map an OpenAPI operation is executed with — the single owner
|
|
16
|
+
* of the vendored swagger-client's parameter-addressing scheme.
|
|
17
|
+
*
|
|
18
|
+
* The client accepts two key shapes in its `parameters` map and, for each
|
|
19
|
+
* parameter the operation declares, consults the bare `name` *before* the
|
|
20
|
+
* qualified `'{in}.{name}'` key (deminified from the vendored bundle:
|
|
21
|
+
* `r = m[e.name]; if (r === undefined) r = m[`${e.in}.${e.name}`]`). Two
|
|
22
|
+
* consequences shape everything that feeds the map:
|
|
23
|
+
*
|
|
24
|
+
* - qualified keys are what let parameters differing only in their location
|
|
25
|
+
* coexist — the client builds the same key from the declared parameter and
|
|
26
|
+
* matches it verbatim, never splitting it, so dots in a name are safe;
|
|
27
|
+
* - a bare key silently outranks the qualified keys of every declared
|
|
28
|
+
* parameter bearing that name, so nothing may emit one for a location the
|
|
29
|
+
* client can address.
|
|
30
|
+
*
|
|
31
|
+
* Arazzo's `querystring` is the one location the client cannot address — it
|
|
32
|
+
* names no OpenAPI location — so it keeps the bare name, which can still
|
|
33
|
+
* reach a same-named declared parameter. Every other location is qualified,
|
|
34
|
+
* including an unrecognized one: an unmatched qualified key is inert, where a
|
|
35
|
+
* bare one would capture.
|
|
36
|
+
*
|
|
37
|
+
* Keys are claimed first-wins. The scheme is not injective, so the map also
|
|
38
|
+
* discriminates a genuine duplicate from a collision of two different
|
|
39
|
+
* parameters on one key: given a key, the claimant's name is determined by
|
|
40
|
+
* its location (the key embeds the name, or is the name), so the location
|
|
41
|
+
* alone identifies the claimant. A bare key and a qualified key sharing one
|
|
42
|
+
* name are a collision too, even though the keys differ — the client consults
|
|
43
|
+
* the bare name first for every declared parameter bearing it, so the bare
|
|
44
|
+
* entry would silently capture the qualified one. What to do about a
|
|
45
|
+
* collision is the caller's policy — the map only reports it.
|
|
46
|
+
*
|
|
47
|
+
* Diff this against the vendored bundle's lookup when bumping swagger-client.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
class ParameterDelivery {
|
|
51
|
+
/**
|
|
52
|
+
* The key a `(location, name)` pair is delivered under — `'{in}.{name}'`,
|
|
53
|
+
* or the bare name for `querystring`. See the class doc for why.
|
|
54
|
+
*/
|
|
55
|
+
static keyFor(location, name) {
|
|
56
|
+
return location === 'querystring' ? name : `${location}.${name}`;
|
|
57
|
+
}
|
|
58
|
+
#values = {};
|
|
59
|
+
#claimedBy = new Map();
|
|
60
|
+
#bareNames = new Set();
|
|
61
|
+
#qualifiedNames = new Set();
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Claims the delivery key for a `(location, name)` pair, first-wins.
|
|
65
|
+
* Only a `claimed` outcome entitles the caller to {@link ParameterDelivery.set}
|
|
66
|
+
* the key; a `duplicate` means the same parameter already holds it, and a
|
|
67
|
+
* `collision` means a different parameter does — on the same key, or across
|
|
68
|
+
* a bare/qualified pair sharing the name (see the class doc).
|
|
69
|
+
*/
|
|
70
|
+
claim(location, name) {
|
|
71
|
+
const key = ParameterDelivery.keyFor(location, name);
|
|
72
|
+
const claimant = this.#claimedBy.get(key);
|
|
73
|
+
if (claimant !== undefined) {
|
|
74
|
+
return {
|
|
75
|
+
key,
|
|
76
|
+
outcome: claimant === location ? 'duplicate' : 'collision'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const bare = key === name;
|
|
80
|
+
if (bare ? this.#qualifiedNames.has(name) : this.#bareNames.has(name)) {
|
|
81
|
+
return {
|
|
82
|
+
key,
|
|
83
|
+
outcome: 'collision'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
(bare ? this.#bareNames : this.#qualifiedNames).add(name);
|
|
87
|
+
this.#claimedBy.set(key, location);
|
|
88
|
+
return {
|
|
89
|
+
key,
|
|
90
|
+
outcome: 'claimed'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
set(key, value) {
|
|
94
|
+
// defined rather than assigned: a key like `__proto__` hits the
|
|
95
|
+
// Object.prototype accessor on bracket assignment, so no own property is
|
|
96
|
+
// ever created and the parameter is silently lost — and an object value
|
|
97
|
+
// additionally rewrites the record's prototype
|
|
98
|
+
Object.defineProperty(this.#values, key, {
|
|
99
|
+
value,
|
|
100
|
+
enumerable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The accumulated record, in the shape `buildRequest` consumes.
|
|
108
|
+
*/
|
|
109
|
+
toRecord() {
|
|
110
|
+
return this.#values;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export default ParameterDelivery;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MAX_HTTP_CACHE_STALE_AGE = exports.MAX_HTTP_CACHE_ENTRIES = exports.MAX_DOCUMENT_REGISTRY_SIZE = void 0;
|
|
7
|
+
const MAX_HTTP_CACHE_ENTRIES = exports.MAX_HTTP_CACHE_ENTRIES = 6;
|
|
8
|
+
const MAX_HTTP_CACHE_STALE_AGE = exports.MAX_HTTP_CACHE_STALE_AGE = 120_000; // 2 minutes in milliseconds
|
|
9
|
+
const MAX_DOCUMENT_REGISTRY_SIZE = exports.MAX_DOCUMENT_REGISTRY_SIZE = 4;
|