@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,43 @@
|
|
|
1
|
+
import { evaluate as evaluateSimpleCriterion, ArazzoCriterionError } from '@swaggerexpert/arazzo-criterion';
|
|
2
|
+
import CriterionError from "../errors/CriterionError.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Evaluates a `simple` Arazzo criterion condition.
|
|
5
|
+
*
|
|
6
|
+
* A simple condition embeds runtime expressions directly in the condition
|
|
7
|
+
* (e.g. `$statusCode == 200 && $response.body.status == 'available'`), so —
|
|
8
|
+
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
9
|
+
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
10
|
+
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
11
|
+
* resolved through the supplied resolver.
|
|
12
|
+
*
|
|
13
|
+
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
14
|
+
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
15
|
+
* comparisons are false, matching the spec's "null equals only null"), so a
|
|
16
|
+
* negated or disjunctive condition may still pass. A malformed condition throws
|
|
17
|
+
* {@link CriterionError}.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
class SimpleCriterionEvaluator {
|
|
21
|
+
/**
|
|
22
|
+
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
23
|
+
* expression via `resolve`.
|
|
24
|
+
*/
|
|
25
|
+
evaluate(condition, resolve) {
|
|
26
|
+
try {
|
|
27
|
+
return evaluateSimpleCriterion(condition, {
|
|
28
|
+
resolve
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error instanceof ArazzoCriterionError) {
|
|
32
|
+
throw new CriterionError(`Invalid simple criterion condition "${condition}"`, {
|
|
33
|
+
cause: error,
|
|
34
|
+
condition,
|
|
35
|
+
type: 'simple',
|
|
36
|
+
reason: 'invalid-simple'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default SimpleCriterionEvaluator;
|
|
@@ -0,0 +1,117 @@
|
|
|
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 _fontoxpath = _interopRequireDefault(require("fontoxpath"));
|
|
9
|
+
var _xmldom = require("@xmldom/xmldom");
|
|
10
|
+
var _CriterionError = _interopRequireDefault(require("../errors/CriterionError.cjs"));
|
|
11
|
+
// fontoxpath is CommonJS and its named exports are not statically resolvable
|
|
12
|
+
// under ESM, so import the default and destructure.
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
evaluateXPathToBoolean,
|
|
16
|
+
evaluateXPath
|
|
17
|
+
} = _fontoxpath.default;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
|
|
21
|
+
*
|
|
22
|
+
* The condition is an XPath 3.1 query applied to the resolved `context`, which
|
|
23
|
+
* must be XML. A string context is parsed as XML; an already-parsed DOM node is
|
|
24
|
+
* used as-is. The criterion is met by the query's Effective Boolean Value
|
|
25
|
+
* (XPath 3.1 §19.1.2), as the Arazzo specification mandates — so a boolean
|
|
26
|
+
* predicate (`//status = 'ok'`), a non-empty node set, a non-zero number, and a
|
|
27
|
+
* non-empty string all evaluate to `true`.
|
|
28
|
+
*
|
|
29
|
+
* Only XPath 3.1 is supported (`fontoxpath`'s engine); version gating happens in
|
|
30
|
+
* the facade. Per Arazzo 1.1.0, a `null` or `undefined` context fails the
|
|
31
|
+
* condition. An invalid query throws {@link CriterionError}.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
class XPathCriterionEvaluator {
|
|
35
|
+
/**
|
|
36
|
+
* Evaluates the XPath `condition` against the resolved context value, returning
|
|
37
|
+
* its Effective Boolean Value.
|
|
38
|
+
*
|
|
39
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
40
|
+
* {@link CriterionError} when the context is not XML or the query is invalid.
|
|
41
|
+
*/
|
|
42
|
+
evaluate(condition, context) {
|
|
43
|
+
if (context === null || context === undefined) return false;
|
|
44
|
+
const node = this.#toNode(condition, context);
|
|
45
|
+
try {
|
|
46
|
+
return evaluateXPathToBoolean(condition, node, null, null, {
|
|
47
|
+
language: evaluateXPath.XPATH_3_1_LANGUAGE
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new _CriterionError.default(`Invalid xpath criterion condition "${condition}"`, {
|
|
51
|
+
cause: error,
|
|
52
|
+
condition,
|
|
53
|
+
type: 'xpath',
|
|
54
|
+
reason: 'invalid-xpath'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Coerces the resolved context to an XML DOM node: an already-parsed node is
|
|
61
|
+
* used as-is, a string is parsed as XML. Any other value cannot be an XPath
|
|
62
|
+
* context and throws.
|
|
63
|
+
*/
|
|
64
|
+
#toNode(condition, context) {
|
|
65
|
+
if (this.#isNode(context)) return context;
|
|
66
|
+
if (typeof context !== 'string') {
|
|
67
|
+
throw new _CriterionError.default('xpath criterion context is not XML', {
|
|
68
|
+
condition,
|
|
69
|
+
type: 'xpath',
|
|
70
|
+
reason: 'invalid-context'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// capture parse errors via `onError` rather than the default handler: this
|
|
75
|
+
// both suppresses the parser writing to the console and catches *recoverable*
|
|
76
|
+
// errors (e.g. an undefined entity, stray text) that do not throw but would
|
|
77
|
+
// otherwise yield a degraded document evaluated silently.
|
|
78
|
+
let parseError;
|
|
79
|
+
try {
|
|
80
|
+
const document = new _xmldom.DOMParser({
|
|
81
|
+
onError: (_level, message) => {
|
|
82
|
+
parseError ??= message;
|
|
83
|
+
}
|
|
84
|
+
}).parseFromString(context, 'text/xml');
|
|
85
|
+
if (parseError !== undefined) {
|
|
86
|
+
throw new _CriterionError.default('xpath criterion context is not valid XML', {
|
|
87
|
+
cause: parseError,
|
|
88
|
+
condition,
|
|
89
|
+
type: 'xpath',
|
|
90
|
+
reason: 'invalid-context'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return document;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof _CriterionError.default) throw error;
|
|
96
|
+
throw new _CriterionError.default('xpath criterion context is not valid XML', {
|
|
97
|
+
cause: error,
|
|
98
|
+
condition,
|
|
99
|
+
type: 'xpath',
|
|
100
|
+
reason: 'invalid-context'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Duck-types a DOM node, so a caller may pass an already-parsed document
|
|
107
|
+
* instead of an XML string. Requires both a numeric `nodeType` and a string
|
|
108
|
+
* `nodeName` so a plain JSON value that happens to carry a `nodeType` property
|
|
109
|
+
* is not mistaken for a node (and is instead rejected as a non-XML context).
|
|
110
|
+
*/
|
|
111
|
+
#isNode(value) {
|
|
112
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
113
|
+
const node = value;
|
|
114
|
+
return typeof node.nodeType === 'number' && typeof node.nodeName === 'string';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var _default = exports.default = XPathCriterionEvaluator;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// fontoxpath is CommonJS and its named exports are not statically resolvable
|
|
2
|
+
// under ESM, so import the default and destructure.
|
|
3
|
+
import fontoxpath from 'fontoxpath';
|
|
4
|
+
import { DOMParser } from '@xmldom/xmldom';
|
|
5
|
+
import CriterionError from "../errors/CriterionError.mjs";
|
|
6
|
+
const {
|
|
7
|
+
evaluateXPathToBoolean,
|
|
8
|
+
evaluateXPath
|
|
9
|
+
} = fontoxpath;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
|
|
13
|
+
*
|
|
14
|
+
* The condition is an XPath 3.1 query applied to the resolved `context`, which
|
|
15
|
+
* must be XML. A string context is parsed as XML; an already-parsed DOM node is
|
|
16
|
+
* used as-is. The criterion is met by the query's Effective Boolean Value
|
|
17
|
+
* (XPath 3.1 §19.1.2), as the Arazzo specification mandates — so a boolean
|
|
18
|
+
* predicate (`//status = 'ok'`), a non-empty node set, a non-zero number, and a
|
|
19
|
+
* non-empty string all evaluate to `true`.
|
|
20
|
+
*
|
|
21
|
+
* Only XPath 3.1 is supported (`fontoxpath`'s engine); version gating happens in
|
|
22
|
+
* the facade. Per Arazzo 1.1.0, a `null` or `undefined` context fails the
|
|
23
|
+
* condition. An invalid query throws {@link CriterionError}.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
class XPathCriterionEvaluator {
|
|
27
|
+
/**
|
|
28
|
+
* Evaluates the XPath `condition` against the resolved context value, returning
|
|
29
|
+
* its Effective Boolean Value.
|
|
30
|
+
*
|
|
31
|
+
* Returns `false` when the context is `null` or `undefined`. Throws
|
|
32
|
+
* {@link CriterionError} when the context is not XML or the query is invalid.
|
|
33
|
+
*/
|
|
34
|
+
evaluate(condition, context) {
|
|
35
|
+
if (context === null || context === undefined) return false;
|
|
36
|
+
const node = this.#toNode(condition, context);
|
|
37
|
+
try {
|
|
38
|
+
return evaluateXPathToBoolean(condition, node, null, null, {
|
|
39
|
+
language: evaluateXPath.XPATH_3_1_LANGUAGE
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new CriterionError(`Invalid xpath criterion condition "${condition}"`, {
|
|
43
|
+
cause: error,
|
|
44
|
+
condition,
|
|
45
|
+
type: 'xpath',
|
|
46
|
+
reason: 'invalid-xpath'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Coerces the resolved context to an XML DOM node: an already-parsed node is
|
|
53
|
+
* used as-is, a string is parsed as XML. Any other value cannot be an XPath
|
|
54
|
+
* context and throws.
|
|
55
|
+
*/
|
|
56
|
+
#toNode(condition, context) {
|
|
57
|
+
if (this.#isNode(context)) return context;
|
|
58
|
+
if (typeof context !== 'string') {
|
|
59
|
+
throw new CriterionError('xpath criterion context is not XML', {
|
|
60
|
+
condition,
|
|
61
|
+
type: 'xpath',
|
|
62
|
+
reason: 'invalid-context'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// capture parse errors via `onError` rather than the default handler: this
|
|
67
|
+
// both suppresses the parser writing to the console and catches *recoverable*
|
|
68
|
+
// errors (e.g. an undefined entity, stray text) that do not throw but would
|
|
69
|
+
// otherwise yield a degraded document evaluated silently.
|
|
70
|
+
let parseError;
|
|
71
|
+
try {
|
|
72
|
+
const document = new DOMParser({
|
|
73
|
+
onError: (_level, message) => {
|
|
74
|
+
parseError ??= message;
|
|
75
|
+
}
|
|
76
|
+
}).parseFromString(context, 'text/xml');
|
|
77
|
+
if (parseError !== undefined) {
|
|
78
|
+
throw new CriterionError('xpath criterion context is not valid XML', {
|
|
79
|
+
cause: parseError,
|
|
80
|
+
condition,
|
|
81
|
+
type: 'xpath',
|
|
82
|
+
reason: 'invalid-context'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return document;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof CriterionError) throw error;
|
|
88
|
+
throw new CriterionError('xpath criterion context is not valid XML', {
|
|
89
|
+
cause: error,
|
|
90
|
+
condition,
|
|
91
|
+
type: 'xpath',
|
|
92
|
+
reason: 'invalid-context'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Duck-types a DOM node, so a caller may pass an already-parsed document
|
|
99
|
+
* instead of an XML string. Requires both a numeric `nodeType` and a string
|
|
100
|
+
* `nodeName` so a plain JSON value that happens to carry a `nodeType` property
|
|
101
|
+
* is not mistaken for a node (and is instead rejected as a non-XML context).
|
|
102
|
+
*/
|
|
103
|
+
#isNode(value) {
|
|
104
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
105
|
+
const node = value;
|
|
106
|
+
return typeof node.nodeType === 'number' && typeof node.nodeName === 'string';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export default XPathCriterionEvaluator;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
8
|
+
/**
|
|
9
|
+
* Base document held by the document registry.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
class APIDocument {
|
|
13
|
+
uri;
|
|
14
|
+
parseResult;
|
|
15
|
+
constructor(uri, parseResult) {
|
|
16
|
+
this.uri = uri;
|
|
17
|
+
this.parseResult = parseResult;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns a JSON-serializable representation of the document's API element.
|
|
22
|
+
* Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
|
|
23
|
+
*/
|
|
24
|
+
toJSON() {
|
|
25
|
+
return (0, _apidomCore.toValue)(this.parseResult.api);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Serializes the document's API element to a YAML string.
|
|
30
|
+
*/
|
|
31
|
+
toYAML(...args) {
|
|
32
|
+
return (0, _apidomCore.toYAML)(this.parseResult.api, ...args);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var _default = exports.default = APIDocument;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toValue, toYAML } from '@speclynx/apidom-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base document held by the document registry.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
class APIDocument {
|
|
8
|
+
uri;
|
|
9
|
+
parseResult;
|
|
10
|
+
constructor(uri, parseResult) {
|
|
11
|
+
this.uri = uri;
|
|
12
|
+
this.parseResult = parseResult;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns a JSON-serializable representation of the document's API element.
|
|
17
|
+
* Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
|
|
18
|
+
*/
|
|
19
|
+
toJSON() {
|
|
20
|
+
return toValue(this.parseResult.api);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Serializes the document's API element to a YAML string.
|
|
25
|
+
*/
|
|
26
|
+
toYAML(...args) {
|
|
27
|
+
return toYAML(this.parseResult.api, ...args);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export default APIDocument;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 _apidomCore = require("@speclynx/apidom-core");
|
|
9
|
+
var _APIDocument = _interopRequireDefault(require("./APIDocument.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* An Arazzo document held by the document registry: the parse result together
|
|
12
|
+
* with the indexes the provider built over it — a container, not a logic
|
|
13
|
+
* bearer. The methods below are thin reads of the source description index.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class ArazzoDocument extends _APIDocument.default {
|
|
17
|
+
type = 'arazzo';
|
|
18
|
+
isEntry;
|
|
19
|
+
/**
|
|
20
|
+
* WorkflowId → JSON Pointer to the workflow within the parse result.
|
|
21
|
+
*/
|
|
22
|
+
workflowIndex;
|
|
23
|
+
/**
|
|
24
|
+
* WorkflowId → stepId → JSON Pointer to the step within the parse result.
|
|
25
|
+
* Built by the provider, like {@link ArazzoDocument.workflowIndex}.
|
|
26
|
+
*/
|
|
27
|
+
stepIndex;
|
|
28
|
+
/**
|
|
29
|
+
* Name → source description element and canonical URI (already resolved
|
|
30
|
+
* against this document's base URI). Built by the provider, like
|
|
31
|
+
* {@link ArazzoDocument.workflowIndex}.
|
|
32
|
+
*/
|
|
33
|
+
sourceDescriptionIndex;
|
|
34
|
+
constructor(uri, parseResult, workflowIndex, stepIndex, sourceDescriptionIndex, isEntry = false) {
|
|
35
|
+
super(uri, parseResult);
|
|
36
|
+
this.isEntry = isEntry;
|
|
37
|
+
this.workflowIndex = workflowIndex;
|
|
38
|
+
this.stepIndex = stepIndex;
|
|
39
|
+
this.sourceDescriptionIndex = sourceDescriptionIndex;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Type guard for ArazzoDocument.
|
|
44
|
+
*/
|
|
45
|
+
static is(doc) {
|
|
46
|
+
return doc.type === 'arazzo';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolves a source description name to its canonical URI — precomputed by
|
|
51
|
+
* the provider, resolved against this document's base URI.
|
|
52
|
+
*/
|
|
53
|
+
resolveSourceDescriptionURI(sourceDescriptionName) {
|
|
54
|
+
return this.sourceDescriptionIndex.get(sourceDescriptionName)?.uri;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resolves a field of a source description object (e.g. `url`, `type`).
|
|
59
|
+
*
|
|
60
|
+
* The `url` field resolves to the canonical URI (resolved against this
|
|
61
|
+
* document's base URI, as `resolveSourceDescriptionURI` does); every other
|
|
62
|
+
* field resolves to its literal value. Returns `undefined` when the source
|
|
63
|
+
* description or the field is absent.
|
|
64
|
+
*/
|
|
65
|
+
resolveSourceDescriptionField(sourceDescriptionName, field) {
|
|
66
|
+
const sourceDescription = this.sourceDescriptionIndex.get(sourceDescriptionName);
|
|
67
|
+
if (sourceDescription === undefined) return undefined;
|
|
68
|
+
if (field === 'url') return sourceDescription.uri;
|
|
69
|
+
return (0, _apidomCore.toValue)(sourceDescription.element.get(field));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The canonical URIs of this document's source descriptions, resolved against
|
|
74
|
+
* this document's base URI, in declaration order. Sources without a resolvable
|
|
75
|
+
* url are omitted.
|
|
76
|
+
*/
|
|
77
|
+
sourceDescriptionURIs() {
|
|
78
|
+
return [...this.sourceDescriptionIndex.values()].map(entry => entry.uri).filter(uri => uri !== undefined);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
var _default = exports.default = ArazzoDocument;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
2
|
+
import APIDocument from "./APIDocument.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* An Arazzo document held by the document registry: the parse result together
|
|
5
|
+
* with the indexes the provider built over it — a container, not a logic
|
|
6
|
+
* bearer. The methods below are thin reads of the source description index.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
class ArazzoDocument extends APIDocument {
|
|
10
|
+
type = 'arazzo';
|
|
11
|
+
isEntry;
|
|
12
|
+
/**
|
|
13
|
+
* WorkflowId → JSON Pointer to the workflow within the parse result.
|
|
14
|
+
*/
|
|
15
|
+
workflowIndex;
|
|
16
|
+
/**
|
|
17
|
+
* WorkflowId → stepId → JSON Pointer to the step within the parse result.
|
|
18
|
+
* Built by the provider, like {@link ArazzoDocument.workflowIndex}.
|
|
19
|
+
*/
|
|
20
|
+
stepIndex;
|
|
21
|
+
/**
|
|
22
|
+
* Name → source description element and canonical URI (already resolved
|
|
23
|
+
* against this document's base URI). Built by the provider, like
|
|
24
|
+
* {@link ArazzoDocument.workflowIndex}.
|
|
25
|
+
*/
|
|
26
|
+
sourceDescriptionIndex;
|
|
27
|
+
constructor(uri, parseResult, workflowIndex, stepIndex, sourceDescriptionIndex, isEntry = false) {
|
|
28
|
+
super(uri, parseResult);
|
|
29
|
+
this.isEntry = isEntry;
|
|
30
|
+
this.workflowIndex = workflowIndex;
|
|
31
|
+
this.stepIndex = stepIndex;
|
|
32
|
+
this.sourceDescriptionIndex = sourceDescriptionIndex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Type guard for ArazzoDocument.
|
|
37
|
+
*/
|
|
38
|
+
static is(doc) {
|
|
39
|
+
return doc.type === 'arazzo';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolves a source description name to its canonical URI — precomputed by
|
|
44
|
+
* the provider, resolved against this document's base URI.
|
|
45
|
+
*/
|
|
46
|
+
resolveSourceDescriptionURI(sourceDescriptionName) {
|
|
47
|
+
return this.sourceDescriptionIndex.get(sourceDescriptionName)?.uri;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves a field of a source description object (e.g. `url`, `type`).
|
|
52
|
+
*
|
|
53
|
+
* The `url` field resolves to the canonical URI (resolved against this
|
|
54
|
+
* document's base URI, as `resolveSourceDescriptionURI` does); every other
|
|
55
|
+
* field resolves to its literal value. Returns `undefined` when the source
|
|
56
|
+
* description or the field is absent.
|
|
57
|
+
*/
|
|
58
|
+
resolveSourceDescriptionField(sourceDescriptionName, field) {
|
|
59
|
+
const sourceDescription = this.sourceDescriptionIndex.get(sourceDescriptionName);
|
|
60
|
+
if (sourceDescription === undefined) return undefined;
|
|
61
|
+
if (field === 'url') return sourceDescription.uri;
|
|
62
|
+
return toValue(sourceDescription.element.get(field));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The canonical URIs of this document's source descriptions, resolved against
|
|
67
|
+
* this document's base URI, in declaration order. Sources without a resolvable
|
|
68
|
+
* url are omitted.
|
|
69
|
+
*/
|
|
70
|
+
sourceDescriptionURIs() {
|
|
71
|
+
return [...this.sourceDescriptionIndex.values()].map(entry => entry.uri).filter(uri => uri !== undefined);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default ArazzoDocument;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Unique name of a source description within an Arazzo document.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One indexed source description: the parsed element and its canonical URI —
|
|
14
|
+
* already resolved against the owning document's base URI, in the exact form
|
|
15
|
+
* the document registry keys on — or `undefined` for a source with no
|
|
16
|
+
* resolvable `url`.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Index mapping a source description name to its element and canonical URI in
|
|
22
|
+
* an Arazzo document.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
class ArazzoSourceDescriptionIndex extends Map {}
|
|
26
|
+
var _default = exports.default = ArazzoSourceDescriptionIndex;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique name of a source description within an Arazzo document.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One indexed source description: the parsed element and its canonical URI —
|
|
8
|
+
* already resolved against the owning document's base URI, in the exact form
|
|
9
|
+
* the document registry keys on — or `undefined` for a source with no
|
|
10
|
+
* resolvable `url`.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Index mapping a source description name to its element and canonical URI in
|
|
16
|
+
* an Arazzo document.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class ArazzoSourceDescriptionIndex extends Map {}
|
|
20
|
+
export default ArazzoSourceDescriptionIndex;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier of a step within an Arazzo workflow.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Index mapping workflowId → stepId → JSON Pointer to the step in an Arazzo
|
|
14
|
+
* document. Steps are unique only within their workflow, hence the nesting.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class ArazzoStepIndex extends Map {
|
|
18
|
+
/**
|
|
19
|
+
* The JSON Pointer of a step, or `undefined` when the workflow or step is absent.
|
|
20
|
+
*/
|
|
21
|
+
getStep(workflowId, stepId) {
|
|
22
|
+
return this.get(workflowId)?.get(stepId);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var _default = exports.default = ArazzoStepIndex;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique identifier of a step within an Arazzo workflow.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Index mapping workflowId → stepId → JSON Pointer to the step in an Arazzo
|
|
8
|
+
* document. Steps are unique only within their workflow, hence the nesting.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class ArazzoStepIndex extends Map {
|
|
12
|
+
/**
|
|
13
|
+
* The JSON Pointer of a step, or `undefined` when the workflow or step is absent.
|
|
14
|
+
*/
|
|
15
|
+
getStep(workflowId, stepId) {
|
|
16
|
+
return this.get(workflowId)?.get(stepId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default ArazzoStepIndex;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier of an Arazzo workflow.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Index mapping workflowId to its JSON Pointer in an Arazzo document.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class ArazzoWorkflowIndex extends Map {}
|
|
17
|
+
var _default = exports.default = ArazzoWorkflowIndex;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 _APIDocument = _interopRequireDefault(require("./APIDocument.cjs"));
|
|
9
|
+
/**
|
|
10
|
+
* An OpenAPI document held by the document registry.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class OpenAPIDocument extends _APIDocument.default {
|
|
14
|
+
type = 'openapi';
|
|
15
|
+
operationIndex;
|
|
16
|
+
constructor(uri, parseResult, operationIndex) {
|
|
17
|
+
super(uri, parseResult);
|
|
18
|
+
this.operationIndex = operationIndex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for OpenAPIDocument.
|
|
23
|
+
*/
|
|
24
|
+
static is(doc) {
|
|
25
|
+
return doc.type === 'openapi';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
var _default = exports.default = OpenAPIDocument;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import APIDocument from "./APIDocument.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* An OpenAPI document held by the document registry.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class OpenAPIDocument extends APIDocument {
|
|
7
|
+
type = 'openapi';
|
|
8
|
+
operationIndex;
|
|
9
|
+
constructor(uri, parseResult, operationIndex) {
|
|
10
|
+
super(uri, parseResult);
|
|
11
|
+
this.operationIndex = operationIndex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for OpenAPIDocument.
|
|
16
|
+
*/
|
|
17
|
+
static is(doc) {
|
|
18
|
+
return doc.type === 'openapi';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default OpenAPIDocument;
|