@usearazzo/runner 0.0.0-stage → 1.0.1-alpha.7
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/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +784 -2
- package/dist/arazzo-runner.browser.js +111247 -0
- package/dist/arazzo-runner.browser.min.js +1 -0
- package/package.json +88 -4
- 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 +457 -0
- package/src/executor/OpenAPIOperationExecutor.mjs +446 -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 +419 -0
- package/src/index.mjs +73 -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 +2341 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
2
|
+
import { isNullElement, isStringElement } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { isParameterElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The `(name, in)` identity of an Arazzo Parameter Object — the one encoding
|
|
7
|
+
* of what makes two parameters "the same parameter", shared by
|
|
8
|
+
* `ArazzoWorkflowNormalizer` (which merges a workflow's parameters into its
|
|
9
|
+
* steps by it) and `OpenAPIOperationParameterResolver` (which keys delivery by
|
|
10
|
+
* it), so the two cannot drift apart.
|
|
11
|
+
*
|
|
12
|
+
* Identity is the pair — the rule ApiDOM's OpenAPI `normalize-parameters`
|
|
13
|
+
* plugin applies when inheriting a Path Item's parameters into an Operation
|
|
14
|
+
* ("a unique parameter is defined by a combination of a name and location").
|
|
15
|
+
* Arazzo's `in` is optional where OpenAPI's is required, and an absent one
|
|
16
|
+
* compares equal only to another absent one: that is a step naming a
|
|
17
|
+
* `workflowId`, where "all parameters map to workflow inputs" and there is no
|
|
18
|
+
* location to pair the name with. Names are case-sensitive per the
|
|
19
|
+
* specification, so nothing is case-folded.
|
|
20
|
+
*
|
|
21
|
+
* The location side is read three-way:
|
|
22
|
+
*
|
|
23
|
+
* - a string — the declared location, e.g. `'query'`;
|
|
24
|
+
* - `undefined` — no location: the shape of a workflow-input mapping,
|
|
25
|
+
* meaningful for a step targeting a `workflowId` but naming no place in a
|
|
26
|
+
* request. An explicitly empty `in:` (a YAML null) reads the same as an
|
|
27
|
+
* omitted one — both say "no location", and treating the explicit spelling
|
|
28
|
+
* as malformed would fail a run its `in`-omitted twin completes;
|
|
29
|
+
* - `null` — a location is declared but is not a string (`in: 1`), which
|
|
30
|
+
* names no location and equals no other, its own duplicate included.
|
|
31
|
+
*
|
|
32
|
+
* An element without a well-formed identity has none at all
|
|
33
|
+
* ({@link ParameterIdentity.of} yields `undefined`) and is equal to nothing —
|
|
34
|
+
* an unresolved Reusable Object, a scalar someone put in the list, or a
|
|
35
|
+
* parameter whose `name` is missing or not a string. Such an entry has
|
|
36
|
+
* nothing to deduplicate on, and the normalizer's merge rebuilds the step's
|
|
37
|
+
* list, so calling it equal to another would delete authored content from the
|
|
38
|
+
* document. The OpenAPI plugin guards the same way and for the same reason.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
class ParameterIdentity {
|
|
42
|
+
/**
|
|
43
|
+
* The identity of an element, or `undefined` when it has none — the element
|
|
44
|
+
* is not a Parameter Object, or its `name` is not a string.
|
|
45
|
+
*/
|
|
46
|
+
static of(element) {
|
|
47
|
+
if (!isParameterElement(element)) return undefined;
|
|
48
|
+
const name = toValue(element.name);
|
|
49
|
+
if (typeof name !== 'string') return undefined;
|
|
50
|
+
return new ParameterIdentity(name, ParameterIdentity.locationOf(element));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether two elements are the same parameter: both have an identity, and
|
|
55
|
+
* the identities are equal. The shape `uniqWith` consumes.
|
|
56
|
+
*/
|
|
57
|
+
static equal(element1, element2) {
|
|
58
|
+
const identity1 = ParameterIdentity.of(element1);
|
|
59
|
+
const identity2 = ParameterIdentity.of(element2);
|
|
60
|
+
return identity1 !== undefined && identity2 !== undefined && identity1.equals(identity2);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The three-way location read alone, for callers that need it without a
|
|
65
|
+
* full identity — the inheritance filter must keep a nameless-but-located
|
|
66
|
+
* entry, which has a location but no identity.
|
|
67
|
+
*/
|
|
68
|
+
static locationOf(parameter) {
|
|
69
|
+
const location = parameter.in;
|
|
70
|
+
if (location === undefined || isNullElement(location)) return undefined;
|
|
71
|
+
return isStringElement(location) ? toValue(location) : null;
|
|
72
|
+
}
|
|
73
|
+
name;
|
|
74
|
+
location;
|
|
75
|
+
constructor(name, location) {
|
|
76
|
+
this.name = name;
|
|
77
|
+
this.location = location;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Whether this and the other identity name the same parameter. A malformed
|
|
82
|
+
* location equals nothing, its own duplicate included.
|
|
83
|
+
*/
|
|
84
|
+
equals(other) {
|
|
85
|
+
return this.location !== null && other.location !== null && this.name === other.name && this.location === other.location;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export default ParameterIdentity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _apidomError = require("@speclynx/apidom-error");
|
|
8
|
+
/** @public */
|
|
9
|
+
class ArazzoRunnerError extends _apidomError.ApiDOMStructuredError {}
|
|
10
|
+
var _default = exports.default = ArazzoRunnerError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class AssemblerError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = AssemblerError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class ClientError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = ClientError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class CriterionError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = CriterionError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class ExecutionError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = ExecutionError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class ExtractionError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = ExtractionError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class InvalidEntryDocumentError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = InvalidEntryDocumentError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class NormalizationError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = NormalizationError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class ResolverError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = ResolverError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class RuntimeExpressionError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = RuntimeExpressionError;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
|
|
9
|
+
/** @public */
|
|
10
|
+
class UnmatchedProviderError extends _ArazzoRunnerError.default {}
|
|
11
|
+
var _default = exports.default = UnmatchedProviderError;
|
|
@@ -0,0 +1,147 @@
|
|
|
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 _ArazzoDocument = _interopRequireDefault(require("../document/ArazzoDocument.cjs"));
|
|
9
|
+
var _ExecutionError = _interopRequireDefault(require("../errors/ExecutionError.cjs"));
|
|
10
|
+
var _SourceDescriptionsLocatorNormalizer = _interopRequireDefault(require("./SourceDescriptionsLocatorNormalizer.cjs"));
|
|
11
|
+
/**
|
|
12
|
+
* A canonical Arazzo workflow locator: the Arazzo document that owns the
|
|
13
|
+
* workflow and the workflow's id within it.
|
|
14
|
+
*
|
|
15
|
+
* A workflow reference names its target in one of two ways — a plain
|
|
16
|
+
* `workflowId` of the current document, or a
|
|
17
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
18
|
+
* workflow of another Arazzo document. Both are locators for the same thing;
|
|
19
|
+
* the normalizer reduces either to this single canonical form. `workflowId`
|
|
20
|
+
* is the bare id either way — the key run state (`$workflows.{id}`) is
|
|
21
|
+
* recorded under, which the runtime-expression grammar can only express
|
|
22
|
+
* unqualified.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A workflow reference, parsed but not yet resolved — the intermediate form
|
|
28
|
+
* between {@link ArazzoWorkflowLocatorNormalizer.normalize}'s two halves.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The referencing context a reference is resolved in: the workflow (and step,
|
|
33
|
+
* when the reference sits on one) making the reference, stamped onto every
|
|
34
|
+
* error.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Normalizes a workflow reference to a canonical {@link ArazzoWorkflowLocator}
|
|
40
|
+
* — the Arazzo document and the workflow's id within it.
|
|
41
|
+
*
|
|
42
|
+
* A reference appears in four author-facing positions — a sub-workflow step's
|
|
43
|
+
* `workflowId`, a `dependsOn` entry, a `retry` action's `workflowId`
|
|
44
|
+
* reference, and a `goto` action's transfer target — and is either a plain id
|
|
45
|
+
* of the referencing document or a whole
|
|
46
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
47
|
+
* workflow of another Arazzo document. Only that dotted expression form is a
|
|
48
|
+
* workflow reference; the resolver package's
|
|
49
|
+
* `$sourceDescriptions.{name}#/json/pointer` form is a `$ref`-time construct,
|
|
50
|
+
* not a runtime expression, and does not parse here.
|
|
51
|
+
*
|
|
52
|
+
* The `type` declared on a source description is not trusted (it may be
|
|
53
|
+
* absent or wrong); a source is classified by what it actually parses to,
|
|
54
|
+
* the same convention the OpenAPI operation locator follows. Source
|
|
55
|
+
* documents are acquired from the registry on demand. Whether the resolved
|
|
56
|
+
* document *defines* the workflow is deliberately left to the caller, which
|
|
57
|
+
* owns the timing of that check (eager for a `dependsOn` list validated
|
|
58
|
+
* before any prerequisite runs, lazy for a sub-workflow step resolved per
|
|
59
|
+
* attempt).
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
class ArazzoWorkflowLocatorNormalizer extends _SourceDescriptionsLocatorNormalizer.default {
|
|
63
|
+
/**
|
|
64
|
+
* Resolves a reference — a plain workflowId or a
|
|
65
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
|
|
66
|
+
* canonical locator: the Arazzo document that owns the target workflow,
|
|
67
|
+
* and the bare id within it.
|
|
68
|
+
*/
|
|
69
|
+
async normalize(reference, document, context) {
|
|
70
|
+
return this.#resolve(this.#parseReference(reference, context), document, context);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parses a reference to its target. A reference starting with `$` must be
|
|
75
|
+
* a whole `$sourceDescriptions.{name}.{workflowId}` expression; anything
|
|
76
|
+
* else `$`-prefixed (another expression kind, or one that does not parse)
|
|
77
|
+
* is a malformed reference, rejected here rather than looked up as a
|
|
78
|
+
* literal id that cannot exist.
|
|
79
|
+
*/
|
|
80
|
+
#parseReference(reference, {
|
|
81
|
+
workflowId,
|
|
82
|
+
stepId
|
|
83
|
+
}) {
|
|
84
|
+
if (!reference.startsWith('$')) {
|
|
85
|
+
return {
|
|
86
|
+
kind: 'local',
|
|
87
|
+
reference,
|
|
88
|
+
workflowId: reference
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const parsed = this.parseSourceDescriptionsExpression(reference);
|
|
92
|
+
if (parsed === undefined) {
|
|
93
|
+
throw new _ExecutionError.default(`workflow reference "${reference}" in workflow "${workflowId}" is not a $sourceDescriptions.{name}.{workflowId} expression`, {
|
|
94
|
+
workflowId,
|
|
95
|
+
stepId,
|
|
96
|
+
reason: 'invalid-workflow-reference'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
kind: 'sourced',
|
|
101
|
+
reference,
|
|
102
|
+
sourceName: parsed.sourceName,
|
|
103
|
+
workflowId: parsed.reference
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Resolves a parsed reference to the Arazzo document that owns the target
|
|
109
|
+
* workflow. A plain id resolves to the referencing document itself; an
|
|
110
|
+
* expression resolves its named source description to a URI, acquires that
|
|
111
|
+
* document from the registry, and requires it to actually be an Arazzo
|
|
112
|
+
* document.
|
|
113
|
+
*/
|
|
114
|
+
async #resolve(parsed, document, context) {
|
|
115
|
+
if (parsed.kind === 'local') {
|
|
116
|
+
return {
|
|
117
|
+
document,
|
|
118
|
+
workflowId: parsed.workflowId
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const {
|
|
122
|
+
workflowId,
|
|
123
|
+
stepId
|
|
124
|
+
} = context;
|
|
125
|
+
const uri = document.resolveSourceDescriptionURI(parsed.sourceName);
|
|
126
|
+
if (uri === undefined) {
|
|
127
|
+
throw new _ExecutionError.default(`workflow reference "${parsed.reference}" in workflow "${workflowId}" names source description "${parsed.sourceName}", which the Arazzo document at "${document.uri}" does not define`, {
|
|
128
|
+
workflowId,
|
|
129
|
+
stepId,
|
|
130
|
+
reason: 'source-description-not-found'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const source = await this.registry.acquire(uri);
|
|
134
|
+
if (!_ArazzoDocument.default.is(source)) {
|
|
135
|
+
throw new _ExecutionError.default(`workflow reference "${parsed.reference}" in workflow "${workflowId}" names source description "${parsed.sourceName}" at "${uri}", which is not an Arazzo document`, {
|
|
136
|
+
workflowId,
|
|
137
|
+
stepId,
|
|
138
|
+
reason: 'source-description-not-arazzo'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
document: source,
|
|
143
|
+
workflowId: parsed.workflowId
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
var _default = exports.default = ArazzoWorkflowLocatorNormalizer;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import ArazzoDocument from "../document/ArazzoDocument.mjs";
|
|
2
|
+
import ExecutionError from "../errors/ExecutionError.mjs";
|
|
3
|
+
import SourceDescriptionsLocatorNormalizer from "./SourceDescriptionsLocatorNormalizer.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* A canonical Arazzo workflow locator: the Arazzo document that owns the
|
|
6
|
+
* workflow and the workflow's id within it.
|
|
7
|
+
*
|
|
8
|
+
* A workflow reference names its target in one of two ways — a plain
|
|
9
|
+
* `workflowId` of the current document, or a
|
|
10
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
11
|
+
* workflow of another Arazzo document. Both are locators for the same thing;
|
|
12
|
+
* the normalizer reduces either to this single canonical form. `workflowId`
|
|
13
|
+
* is the bare id either way — the key run state (`$workflows.{id}`) is
|
|
14
|
+
* recorded under, which the runtime-expression grammar can only express
|
|
15
|
+
* unqualified.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A workflow reference, parsed but not yet resolved — the intermediate form
|
|
20
|
+
* between {@link ArazzoWorkflowLocatorNormalizer.normalize}'s two halves.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The referencing context a reference is resolved in: the workflow (and step,
|
|
24
|
+
* when the reference sits on one) making the reference, stamped onto every
|
|
25
|
+
* error.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a workflow reference to a canonical {@link ArazzoWorkflowLocator}
|
|
30
|
+
* — the Arazzo document and the workflow's id within it.
|
|
31
|
+
*
|
|
32
|
+
* A reference appears in four author-facing positions — a sub-workflow step's
|
|
33
|
+
* `workflowId`, a `dependsOn` entry, a `retry` action's `workflowId`
|
|
34
|
+
* reference, and a `goto` action's transfer target — and is either a plain id
|
|
35
|
+
* of the referencing document or a whole
|
|
36
|
+
* `$sourceDescriptions.{name}.{workflowId}` runtime expression naming a
|
|
37
|
+
* workflow of another Arazzo document. Only that dotted expression form is a
|
|
38
|
+
* workflow reference; the resolver package's
|
|
39
|
+
* `$sourceDescriptions.{name}#/json/pointer` form is a `$ref`-time construct,
|
|
40
|
+
* not a runtime expression, and does not parse here.
|
|
41
|
+
*
|
|
42
|
+
* The `type` declared on a source description is not trusted (it may be
|
|
43
|
+
* absent or wrong); a source is classified by what it actually parses to,
|
|
44
|
+
* the same convention the OpenAPI operation locator follows. Source
|
|
45
|
+
* documents are acquired from the registry on demand. Whether the resolved
|
|
46
|
+
* document *defines* the workflow is deliberately left to the caller, which
|
|
47
|
+
* owns the timing of that check (eager for a `dependsOn` list validated
|
|
48
|
+
* before any prerequisite runs, lazy for a sub-workflow step resolved per
|
|
49
|
+
* attempt).
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
|
|
53
|
+
/**
|
|
54
|
+
* Resolves a reference — a plain workflowId or a
|
|
55
|
+
* `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
|
|
56
|
+
* canonical locator: the Arazzo document that owns the target workflow,
|
|
57
|
+
* and the bare id within it.
|
|
58
|
+
*/
|
|
59
|
+
async normalize(reference, document, context) {
|
|
60
|
+
return this.#resolve(this.#parseReference(reference, context), document, context);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Parses a reference to its target. A reference starting with `$` must be
|
|
65
|
+
* a whole `$sourceDescriptions.{name}.{workflowId}` expression; anything
|
|
66
|
+
* else `$`-prefixed (another expression kind, or one that does not parse)
|
|
67
|
+
* is a malformed reference, rejected here rather than looked up as a
|
|
68
|
+
* literal id that cannot exist.
|
|
69
|
+
*/
|
|
70
|
+
#parseReference(reference, {
|
|
71
|
+
workflowId,
|
|
72
|
+
stepId
|
|
73
|
+
}) {
|
|
74
|
+
if (!reference.startsWith('$')) {
|
|
75
|
+
return {
|
|
76
|
+
kind: 'local',
|
|
77
|
+
reference,
|
|
78
|
+
workflowId: reference
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const parsed = this.parseSourceDescriptionsExpression(reference);
|
|
82
|
+
if (parsed === undefined) {
|
|
83
|
+
throw new ExecutionError(`workflow reference "${reference}" in workflow "${workflowId}" is not a $sourceDescriptions.{name}.{workflowId} expression`, {
|
|
84
|
+
workflowId,
|
|
85
|
+
stepId,
|
|
86
|
+
reason: 'invalid-workflow-reference'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
kind: 'sourced',
|
|
91
|
+
reference,
|
|
92
|
+
sourceName: parsed.sourceName,
|
|
93
|
+
workflowId: parsed.reference
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resolves a parsed reference to the Arazzo document that owns the target
|
|
99
|
+
* workflow. A plain id resolves to the referencing document itself; an
|
|
100
|
+
* expression resolves its named source description to a URI, acquires that
|
|
101
|
+
* document from the registry, and requires it to actually be an Arazzo
|
|
102
|
+
* document.
|
|
103
|
+
*/
|
|
104
|
+
async #resolve(parsed, document, context) {
|
|
105
|
+
if (parsed.kind === 'local') {
|
|
106
|
+
return {
|
|
107
|
+
document,
|
|
108
|
+
workflowId: parsed.workflowId
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const {
|
|
112
|
+
workflowId,
|
|
113
|
+
stepId
|
|
114
|
+
} = context;
|
|
115
|
+
const uri = document.resolveSourceDescriptionURI(parsed.sourceName);
|
|
116
|
+
if (uri === undefined) {
|
|
117
|
+
throw new ExecutionError(`workflow reference "${parsed.reference}" in workflow "${workflowId}" names source description "${parsed.sourceName}", which the Arazzo document at "${document.uri}" does not define`, {
|
|
118
|
+
workflowId,
|
|
119
|
+
stepId,
|
|
120
|
+
reason: 'source-description-not-found'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const source = await this.registry.acquire(uri);
|
|
124
|
+
if (!ArazzoDocument.is(source)) {
|
|
125
|
+
throw new ExecutionError(`workflow reference "${parsed.reference}" in workflow "${workflowId}" names source description "${parsed.sourceName}" at "${uri}", which is not an Arazzo document`, {
|
|
126
|
+
workflowId,
|
|
127
|
+
stepId,
|
|
128
|
+
reason: 'source-description-not-arazzo'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
document: source,
|
|
133
|
+
workflowId: parsed.workflowId
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export default ArazzoWorkflowLocatorNormalizer;
|