@usearazzo/runner 1.0.1-alpha.31 → 1.0.1-alpha.33
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 +27 -0
- package/dist/arazzo-runner.browser.js +691 -179
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +6 -6
- package/src/action/ActionResolver.cjs +13 -12
- package/src/action/ActionResolver.mjs +13 -12
- package/src/criterion/CriterionEvaluator.cjs +13 -8
- package/src/criterion/CriterionEvaluator.mjs +13 -8
- package/src/criterion/SimpleCriterionEvaluator.cjs +5 -3
- package/src/criterion/SimpleCriterionEvaluator.mjs +6 -4
- package/src/executor/OpenAPIOperationExecutor.cjs +13 -6
- package/src/executor/OpenAPIOperationExecutor.mjs +14 -7
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +1 -1
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +1 -1
- package/src/executor/StepExecutor.cjs +19 -14
- package/src/executor/StepExecutor.mjs +19 -14
- package/src/executor/WorkflowExecutor.cjs +8 -8
- package/src/executor/WorkflowExecutor.mjs +8 -8
- package/src/expression/RuntimeExpressionEvaluator.cjs +52 -9
- package/src/expression/RuntimeExpressionEvaluator.mjs +52 -9
- package/src/registry/DocumentRegistry.cjs +35 -8
- package/src/registry/DocumentRegistry.mjs +35 -8
- package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +1 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +1 -0
- package/src/registry/providers/DocumentRegistryProvider.cjs +19 -1
- package/src/registry/providers/DocumentRegistryProvider.mjs +19 -1
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +1 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +1 -0
- package/src/resolver/ArazzoValueResolver.cjs +6 -3
- package/src/resolver/ArazzoValueResolver.mjs +6 -3
- package/src/resolver/OpenAPIOperationParameterResolver.cjs +2 -2
- package/src/resolver/OpenAPIOperationParameterResolver.mjs +2 -2
- package/src/resolver/OutputResolver.cjs +10 -3
- package/src/resolver/OutputResolver.mjs +10 -3
- package/src/resolver/RequestBodyResolver.cjs +37 -17
- package/src/resolver/RequestBodyResolver.mjs +37 -17
- package/src/resolver/WorkflowParameterResolver.cjs +2 -2
- package/src/resolver/WorkflowParameterResolver.mjs +2 -2
- package/types/runner.d.ts +88 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usearazzo/runner",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.33",
|
|
4
4
|
"description": "Runner for Arazzo Workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arazzo",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"@speclynx/apidom-ns-openapi-3-1": "^7.0.2",
|
|
68
68
|
"@speclynx/apidom-reference": "^7.0.2",
|
|
69
69
|
"@speclynx/apidom-traverse": "^7.0.2",
|
|
70
|
-
"@swaggerexpert/arazzo-criterion": "^1.0
|
|
71
|
-
"@swaggerexpert/arazzo-runtime-expression": "^3.
|
|
70
|
+
"@swaggerexpert/arazzo-criterion": "^1.2.0",
|
|
71
|
+
"@swaggerexpert/arazzo-runtime-expression": "^3.4.0",
|
|
72
72
|
"@swaggerexpert/cookie": "^2.1.1",
|
|
73
73
|
"@swaggerexpert/json-pointer": "^3.0.2",
|
|
74
74
|
"@swaggerexpert/jsonpath": "^4.0.5",
|
|
75
75
|
"@swaggerexpert/media-types": "^1.0.2",
|
|
76
|
-
"@usearazzo/parser": "1.0.1-alpha.
|
|
77
|
-
"@usearazzo/resolver": "1.0.1-alpha.
|
|
76
|
+
"@usearazzo/parser": "1.0.1-alpha.33",
|
|
77
|
+
"@usearazzo/resolver": "1.0.1-alpha.33",
|
|
78
78
|
"@xmldom/xmldom": "^0.9.12",
|
|
79
79
|
"fontoxpath": "^3.34.0",
|
|
80
80
|
"ramda": "^0.32.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"swagger-client": "^3.39.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "a41d6c5821d21691caa11160e125f89f860f5511"
|
|
98
98
|
}
|
|
@@ -9,12 +9,13 @@ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
|
9
9
|
var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
|
|
10
10
|
var _ResolverError = _interopRequireDefault(require("../errors/ResolverError.cjs"));
|
|
11
11
|
/**
|
|
12
|
-
* Determines whether a single criterion of an action is met
|
|
13
|
-
* action declaring the criterion, so a caller can
|
|
12
|
+
* Determines whether a single criterion of an action is met, or resolves to
|
|
13
|
+
* whether it is. Receives the action declaring the criterion, so a caller can
|
|
14
|
+
* attribute the outcome to it.
|
|
14
15
|
*
|
|
15
16
|
* Bridged to a criterion evaluator
|
|
16
|
-
* (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`);
|
|
17
|
-
* unresolvable/failing criterion is `false`, not an error.
|
|
17
|
+
* (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
|
|
18
|
+
* an unresolvable/failing criterion is `false`, not an error.
|
|
18
19
|
* @public
|
|
19
20
|
*/
|
|
20
21
|
|
|
@@ -69,12 +70,12 @@ class ActionResolver {
|
|
|
69
70
|
* `end` its author was reaching for would otherwise never happen without a
|
|
70
71
|
* word said about why.
|
|
71
72
|
*/
|
|
72
|
-
resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
73
|
+
async resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
73
74
|
// safe: `#resolveAll` validates every entry as *a* Success/Failure Action
|
|
74
75
|
// Object, not one matching this list's own field, but a well-formed
|
|
75
76
|
// `StepOnSuccessElement` only ever refracts Success Action entries — the
|
|
76
77
|
// apidom refractor types list entries positionally at parse time.
|
|
77
|
-
return this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
78
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -83,9 +84,9 @@ class ActionResolver {
|
|
|
83
84
|
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
84
85
|
* see there for the full rationale — mirrored for the step's other list.
|
|
85
86
|
*/
|
|
86
|
-
resolveOnFailure(actions, isCriterionMet, scope) {
|
|
87
|
+
async resolveOnFailure(actions, isCriterionMet, scope) {
|
|
87
88
|
// safe: see the same-named comment in `resolveOnSuccess` above.
|
|
88
|
-
return this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
89
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
@@ -98,7 +99,7 @@ class ActionResolver {
|
|
|
98
99
|
* element's own type no longer distinguishes them. Baked in by the public
|
|
99
100
|
* method rather than taken from the caller.
|
|
100
101
|
*/
|
|
101
|
-
#resolveAll(actions, isCriterionMet, field, scope) {
|
|
102
|
+
async #resolveAll(actions, isCriterionMet, field, scope) {
|
|
102
103
|
if (actions === undefined) return [];
|
|
103
104
|
// present but scalar: walking it would fail as a bare
|
|
104
105
|
// `TypeError: actions is not iterable`.
|
|
@@ -118,7 +119,7 @@ class ActionResolver {
|
|
|
118
119
|
reason: _ResolverError.default.MalformedActionEntry
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
|
-
if (this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
122
|
+
if (await this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
122
123
|
matched.push(action);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
@@ -135,7 +136,7 @@ class ActionResolver {
|
|
|
135
136
|
* not say what its author meant, the same as an unrecognized entry in the
|
|
136
137
|
* action list itself.
|
|
137
138
|
*/
|
|
138
|
-
#criteriaMet(action, isCriterionMet, scope) {
|
|
139
|
+
async #criteriaMet(action, isCriterionMet, scope) {
|
|
139
140
|
const criteria = action.criteria;
|
|
140
141
|
if (criteria === undefined) return true;
|
|
141
142
|
if (!(0, _apidomDatamodel.isArrayElement)(criteria)) {
|
|
@@ -156,7 +157,7 @@ class ActionResolver {
|
|
|
156
157
|
}
|
|
157
158
|
// every criterion is evaluated, not only up to the first unmet one, so
|
|
158
159
|
// a predicate that records outcomes sees the whole list.
|
|
159
|
-
if (!isCriterionMet(criterion, action)) met = false;
|
|
160
|
+
if (!(await isCriterionMet(criterion, action))) met = false;
|
|
160
161
|
}
|
|
161
162
|
return met;
|
|
162
163
|
}
|
|
@@ -2,12 +2,13 @@ import { isArrayElement } from '@speclynx/apidom-datamodel';
|
|
|
2
2
|
import { isSuccessActionElement, isFailureActionElement, isCriterionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
3
3
|
import ResolverError from "../errors/ResolverError.mjs";
|
|
4
4
|
/**
|
|
5
|
-
* Determines whether a single criterion of an action is met
|
|
6
|
-
* action declaring the criterion, so a caller can
|
|
5
|
+
* Determines whether a single criterion of an action is met, or resolves to
|
|
6
|
+
* whether it is. Receives the action declaring the criterion, so a caller can
|
|
7
|
+
* attribute the outcome to it.
|
|
7
8
|
*
|
|
8
9
|
* Bridged to a criterion evaluator
|
|
9
|
-
* (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`);
|
|
10
|
-
* unresolvable/failing criterion is `false`, not an error.
|
|
10
|
+
* (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
|
|
11
|
+
* an unresolvable/failing criterion is `false`, not an error.
|
|
11
12
|
* @public
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
@@ -59,12 +60,12 @@ class ActionResolver {
|
|
|
59
60
|
* `end` its author was reaching for would otherwise never happen without a
|
|
60
61
|
* word said about why.
|
|
61
62
|
*/
|
|
62
|
-
resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
63
|
+
async resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
63
64
|
// safe: `#resolveAll` validates every entry as *a* Success/Failure Action
|
|
64
65
|
// Object, not one matching this list's own field, but a well-formed
|
|
65
66
|
// `StepOnSuccessElement` only ever refracts Success Action entries — the
|
|
66
67
|
// apidom refractor types list entries positionally at parse time.
|
|
67
|
-
return this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
68
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
|
@@ -73,9 +74,9 @@ class ActionResolver {
|
|
|
73
74
|
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
74
75
|
* see there for the full rationale — mirrored for the step's other list.
|
|
75
76
|
*/
|
|
76
|
-
resolveOnFailure(actions, isCriterionMet, scope) {
|
|
77
|
+
async resolveOnFailure(actions, isCriterionMet, scope) {
|
|
77
78
|
// safe: see the same-named comment in `resolveOnSuccess` above.
|
|
78
|
-
return this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
79
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
/**
|
|
@@ -88,7 +89,7 @@ class ActionResolver {
|
|
|
88
89
|
* element's own type no longer distinguishes them. Baked in by the public
|
|
89
90
|
* method rather than taken from the caller.
|
|
90
91
|
*/
|
|
91
|
-
#resolveAll(actions, isCriterionMet, field, scope) {
|
|
92
|
+
async #resolveAll(actions, isCriterionMet, field, scope) {
|
|
92
93
|
if (actions === undefined) return [];
|
|
93
94
|
// present but scalar: walking it would fail as a bare
|
|
94
95
|
// `TypeError: actions is not iterable`.
|
|
@@ -108,7 +109,7 @@ class ActionResolver {
|
|
|
108
109
|
reason: ResolverError.MalformedActionEntry
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
if (this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
112
|
+
if (await this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
112
113
|
matched.push(action);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -125,7 +126,7 @@ class ActionResolver {
|
|
|
125
126
|
* not say what its author meant, the same as an unrecognized entry in the
|
|
126
127
|
* action list itself.
|
|
127
128
|
*/
|
|
128
|
-
#criteriaMet(action, isCriterionMet, scope) {
|
|
129
|
+
async #criteriaMet(action, isCriterionMet, scope) {
|
|
129
130
|
const criteria = action.criteria;
|
|
130
131
|
if (criteria === undefined) return true;
|
|
131
132
|
if (!isArrayElement(criteria)) {
|
|
@@ -146,7 +147,7 @@ class ActionResolver {
|
|
|
146
147
|
}
|
|
147
148
|
// every criterion is evaluated, not only up to the first unmet one, so
|
|
148
149
|
// a predicate that records outcomes sees the whole list.
|
|
149
|
-
if (!isCriterionMet(criterion, action)) met = false;
|
|
150
|
+
if (!(await isCriterionMet(criterion, action))) met = false;
|
|
150
151
|
}
|
|
151
152
|
return met;
|
|
152
153
|
}
|
|
@@ -16,14 +16,19 @@ var _SimpleCriterionEvaluator = _interopRequireDefault(require("./SimpleCriterio
|
|
|
16
16
|
var _JSONPathCriterionEvaluator = _interopRequireDefault(require("./JSONPathCriterionEvaluator.cjs"));
|
|
17
17
|
var _XPathCriterionEvaluator = _interopRequireDefault(require("./XPathCriterionEvaluator.cjs"));
|
|
18
18
|
/**
|
|
19
|
-
* Resolves a runtime expression to a value
|
|
19
|
+
* Resolves a runtime expression to a value, or to a Promise of it, during
|
|
20
|
+
* criterion evaluation. The result is awaited, so a synchronous resolver works
|
|
21
|
+
* too.
|
|
20
22
|
*
|
|
21
23
|
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
22
24
|
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
23
25
|
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
24
26
|
* than throwing (a common way to drive it is
|
|
25
27
|
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
26
|
-
* lenient evaluator).
|
|
28
|
+
* lenient evaluator). An error it throws or rejects with — such as the load
|
|
29
|
+
* error of a `$sourceDescriptions` document that cannot be loaded — is not a
|
|
30
|
+
* {@link CriterionEvaluationError}, so it propagates instead of failing the
|
|
31
|
+
* criterion.
|
|
27
32
|
* @public
|
|
28
33
|
*/
|
|
29
34
|
|
|
@@ -99,7 +104,7 @@ class CriterionEvaluator {
|
|
|
99
104
|
* the expressions embedded in the condition; for the other types it resolves
|
|
100
105
|
* the criterion's `context` expression that the condition is applied to.
|
|
101
106
|
*/
|
|
102
|
-
evaluate(criterion, resolve) {
|
|
107
|
+
async evaluate(criterion, resolve) {
|
|
103
108
|
if (!(0, _apidomNsArazzo.isCriterionElement)(criterion)) {
|
|
104
109
|
throw new _CriterionError.default('Element is not a Criterion Object', {
|
|
105
110
|
reason: _CriterionError.default.InvalidCriterion
|
|
@@ -119,23 +124,23 @@ class CriterionEvaluator {
|
|
|
119
124
|
try {
|
|
120
125
|
switch (type) {
|
|
121
126
|
case 'simple':
|
|
122
|
-
met = this.#simple.evaluate(condition, resolve);
|
|
127
|
+
met = await this.#simple.evaluate(condition, resolve);
|
|
123
128
|
break;
|
|
124
129
|
case 'regex':
|
|
125
|
-
met = this.#regex.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
130
|
+
met = this.#regex.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
126
131
|
break;
|
|
127
132
|
case 'jsonpath':
|
|
128
133
|
// only rfc9535 is supported, Arazzo 1.1.0's default, so an omitted
|
|
129
134
|
// version is accepted. draft-goessner has different semantics and is
|
|
130
135
|
// rejected rather than mis-evaluated.
|
|
131
136
|
this.#requireVersion(criterion, type, condition, 'rfc9535');
|
|
132
|
-
met = this.#jsonpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
137
|
+
met = this.#jsonpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
133
138
|
break;
|
|
134
139
|
case 'xpath':
|
|
135
140
|
// only XPath 3.1 is supported; xpath-31 is Arazzo 1.1.0's default, so
|
|
136
141
|
// an omitted version is accepted. Older versions are rejected.
|
|
137
142
|
this.#requireVersion(criterion, type, condition, 'xpath-31');
|
|
138
|
-
met = this.#xpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
143
|
+
met = this.#xpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
139
144
|
break;
|
|
140
145
|
default:
|
|
141
146
|
throw new _CriterionError.default(`Unknown criterion type "${type}"`, {
|
|
@@ -236,7 +241,7 @@ class CriterionEvaluator {
|
|
|
236
241
|
* `jsonpath`, `xpath`) must declare one; a criterion of such a type without a
|
|
237
242
|
* `context` throws a {@link CriterionError}.
|
|
238
243
|
*/
|
|
239
|
-
#resolveContext(criterion, type, resolve) {
|
|
244
|
+
async #resolveContext(criterion, type, resolve) {
|
|
240
245
|
if (!(0, _apidomDatamodel.isStringElement)(criterion.context)) {
|
|
241
246
|
throw new _CriterionError.default(`Criterion type "${type}" requires a "context"`, {
|
|
242
247
|
type,
|
|
@@ -9,14 +9,19 @@ import SimpleCriterionEvaluator from "./SimpleCriterionEvaluator.mjs";
|
|
|
9
9
|
import JSONPathCriterionEvaluator from "./JSONPathCriterionEvaluator.mjs";
|
|
10
10
|
import XPathCriterionEvaluator from "./XPathCriterionEvaluator.mjs";
|
|
11
11
|
/**
|
|
12
|
-
* Resolves a runtime expression to a value
|
|
12
|
+
* Resolves a runtime expression to a value, or to a Promise of it, during
|
|
13
|
+
* criterion evaluation. The result is awaited, so a synchronous resolver works
|
|
14
|
+
* too.
|
|
13
15
|
*
|
|
14
16
|
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
15
17
|
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
16
18
|
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
17
19
|
* than throwing (a common way to drive it is
|
|
18
20
|
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
19
|
-
* lenient evaluator).
|
|
21
|
+
* lenient evaluator). An error it throws or rejects with — such as the load
|
|
22
|
+
* error of a `$sourceDescriptions` document that cannot be loaded — is not a
|
|
23
|
+
* {@link CriterionEvaluationError}, so it propagates instead of failing the
|
|
24
|
+
* criterion.
|
|
20
25
|
* @public
|
|
21
26
|
*/
|
|
22
27
|
/**
|
|
@@ -89,7 +94,7 @@ class CriterionEvaluator {
|
|
|
89
94
|
* the expressions embedded in the condition; for the other types it resolves
|
|
90
95
|
* the criterion's `context` expression that the condition is applied to.
|
|
91
96
|
*/
|
|
92
|
-
evaluate(criterion, resolve) {
|
|
97
|
+
async evaluate(criterion, resolve) {
|
|
93
98
|
if (!isCriterionElement(criterion)) {
|
|
94
99
|
throw new CriterionError('Element is not a Criterion Object', {
|
|
95
100
|
reason: CriterionError.InvalidCriterion
|
|
@@ -109,23 +114,23 @@ class CriterionEvaluator {
|
|
|
109
114
|
try {
|
|
110
115
|
switch (type) {
|
|
111
116
|
case 'simple':
|
|
112
|
-
met = this.#simple.evaluate(condition, resolve);
|
|
117
|
+
met = await this.#simple.evaluate(condition, resolve);
|
|
113
118
|
break;
|
|
114
119
|
case 'regex':
|
|
115
|
-
met = this.#regex.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
120
|
+
met = this.#regex.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
116
121
|
break;
|
|
117
122
|
case 'jsonpath':
|
|
118
123
|
// only rfc9535 is supported, Arazzo 1.1.0's default, so an omitted
|
|
119
124
|
// version is accepted. draft-goessner has different semantics and is
|
|
120
125
|
// rejected rather than mis-evaluated.
|
|
121
126
|
this.#requireVersion(criterion, type, condition, 'rfc9535');
|
|
122
|
-
met = this.#jsonpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
127
|
+
met = this.#jsonpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
123
128
|
break;
|
|
124
129
|
case 'xpath':
|
|
125
130
|
// only XPath 3.1 is supported; xpath-31 is Arazzo 1.1.0's default, so
|
|
126
131
|
// an omitted version is accepted. Older versions are rejected.
|
|
127
132
|
this.#requireVersion(criterion, type, condition, 'xpath-31');
|
|
128
|
-
met = this.#xpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
133
|
+
met = this.#xpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
129
134
|
break;
|
|
130
135
|
default:
|
|
131
136
|
throw new CriterionError(`Unknown criterion type "${type}"`, {
|
|
@@ -226,7 +231,7 @@ class CriterionEvaluator {
|
|
|
226
231
|
* `jsonpath`, `xpath`) must declare one; a criterion of such a type without a
|
|
227
232
|
* `context` throws a {@link CriterionError}.
|
|
228
233
|
*/
|
|
229
|
-
#resolveContext(criterion, type, resolve) {
|
|
234
|
+
async #resolveContext(criterion, type, resolve) {
|
|
230
235
|
if (!isStringElement(criterion.context)) {
|
|
231
236
|
throw new CriterionError(`Criterion type "${type}" requires a "context"`, {
|
|
232
237
|
type,
|
|
@@ -15,7 +15,9 @@ var _CriterionEvaluationError = _interopRequireDefault(require("../errors/Criter
|
|
|
15
15
|
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
16
16
|
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
17
17
|
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
18
|
-
* resolved through the supplied resolver.
|
|
18
|
+
* resolved through the supplied resolver and awaited in turn. `&&` and `||`
|
|
19
|
+
* short-circuit, so an operand that cannot change the outcome is never
|
|
20
|
+
* resolved.
|
|
19
21
|
*
|
|
20
22
|
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
21
23
|
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
@@ -29,9 +31,9 @@ class SimpleCriterionEvaluator {
|
|
|
29
31
|
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
30
32
|
* expression via `resolve`.
|
|
31
33
|
*/
|
|
32
|
-
evaluate(condition, resolve) {
|
|
34
|
+
async evaluate(condition, resolve) {
|
|
33
35
|
try {
|
|
34
|
-
return (0, _arazzoCriterion.
|
|
36
|
+
return await (0, _arazzoCriterion.evaluateAsync)(condition, {
|
|
35
37
|
resolve
|
|
36
38
|
});
|
|
37
39
|
} catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { evaluateAsync as evaluateSimpleCriterion, ArazzoCriterionError } from '@swaggerexpert/arazzo-criterion';
|
|
2
2
|
import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Evaluates a `simple` Arazzo criterion condition.
|
|
@@ -8,7 +8,9 @@ import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
|
|
|
8
8
|
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
9
9
|
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
10
10
|
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
11
|
-
* resolved through the supplied resolver.
|
|
11
|
+
* resolved through the supplied resolver and awaited in turn. `&&` and `||`
|
|
12
|
+
* short-circuit, so an operand that cannot change the outcome is never
|
|
13
|
+
* resolved.
|
|
12
14
|
*
|
|
13
15
|
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
14
16
|
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
@@ -22,9 +24,9 @@ class SimpleCriterionEvaluator {
|
|
|
22
24
|
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
23
25
|
* expression via `resolve`.
|
|
24
26
|
*/
|
|
25
|
-
evaluate(condition, resolve) {
|
|
27
|
+
async evaluate(condition, resolve) {
|
|
26
28
|
try {
|
|
27
|
-
return evaluateSimpleCriterion(condition, {
|
|
29
|
+
return await evaluateSimpleCriterion(condition, {
|
|
28
30
|
resolve
|
|
29
31
|
});
|
|
30
32
|
} catch (error) {
|
|
@@ -658,12 +658,19 @@ class OpenAPIOperationExecutor {
|
|
|
658
658
|
finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
|
|
659
659
|
finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
|
|
660
660
|
|
|
661
|
-
// for multipart/form-data, remove the
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
661
|
+
// for multipart/form-data, remove the content-type so the transport sets
|
|
662
|
+
// one carrying the boundary of the FormData it encodes. one that names a
|
|
663
|
+
// boundary is kept when the body is not a FormData: whoever built that
|
|
664
|
+
// body chose the boundary
|
|
665
|
+
const encodedByTransport = finalized.body instanceof FormData;
|
|
666
|
+
for (const name of Object.keys(finalized.headers)) {
|
|
667
|
+
const contentType = finalized.headers[name];
|
|
668
|
+
if (name.toLowerCase() !== 'content-type' || typeof contentType !== 'string') continue;
|
|
669
|
+
if (!/multipart\/form-data/i.test(contentType)) continue;
|
|
670
|
+
const boundary = (0, _mediaTypes.parse)(contentType, {
|
|
671
|
+
type: 'media-type'
|
|
672
|
+
}).tree?.parameters.boundary;
|
|
673
|
+
if (encodedByTransport || !boundary?.trim()) delete finalized.headers[name];
|
|
667
674
|
}
|
|
668
675
|
return finalized;
|
|
669
676
|
}
|
|
@@ -4,7 +4,7 @@ import { isArrayElement, isObjectElement } from '@speclynx/apidom-datamodel';
|
|
|
4
4
|
import { url as urlUtils } from '@speclynx/apidom-reference/configuration/empty';
|
|
5
5
|
import { isSwaggerElement, isParameterElement } from '@speclynx/apidom-ns-openapi-2';
|
|
6
6
|
import { serializeCookie, cookieNameLenientValidator, cookieValueStrictPercentEncoder } from '@swaggerexpert/cookie';
|
|
7
|
-
import { identify, matches, selectBestMatch } from '@swaggerexpert/media-types';
|
|
7
|
+
import { identify, matches, parse, selectBestMatch } from '@swaggerexpert/media-types';
|
|
8
8
|
import { isPlainObject } from 'ramda-adjunct';
|
|
9
9
|
|
|
10
10
|
// @ts-expect-error vendored swagger-client bundle has no type declarations
|
|
@@ -646,12 +646,19 @@ class OpenAPIOperationExecutor {
|
|
|
646
646
|
finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
|
|
647
647
|
finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
|
|
648
648
|
|
|
649
|
-
// for multipart/form-data, remove the
|
|
650
|
-
//
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
649
|
+
// for multipart/form-data, remove the content-type so the transport sets
|
|
650
|
+
// one carrying the boundary of the FormData it encodes. one that names a
|
|
651
|
+
// boundary is kept when the body is not a FormData: whoever built that
|
|
652
|
+
// body chose the boundary
|
|
653
|
+
const encodedByTransport = finalized.body instanceof FormData;
|
|
654
|
+
for (const name of Object.keys(finalized.headers)) {
|
|
655
|
+
const contentType = finalized.headers[name];
|
|
656
|
+
if (name.toLowerCase() !== 'content-type' || typeof contentType !== 'string') continue;
|
|
657
|
+
if (!/multipart\/form-data/i.test(contentType)) continue;
|
|
658
|
+
const boundary = parse(contentType, {
|
|
659
|
+
type: 'media-type'
|
|
660
|
+
}).tree?.parameters.boundary;
|
|
661
|
+
if (encodedByTransport || !boundary?.trim()) delete finalized.headers[name];
|
|
655
662
|
}
|
|
656
663
|
return finalized;
|
|
657
664
|
}
|
|
@@ -113,7 +113,7 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
113
113
|
document,
|
|
114
114
|
registry: this.registry
|
|
115
115
|
});
|
|
116
|
-
const uriReference = evaluator.interpolate(operationPath);
|
|
116
|
+
const uriReference = await evaluator.interpolate(operationPath);
|
|
117
117
|
const documentURI = _empty.url.sanitize(_empty.url.stripHash(uriReference));
|
|
118
118
|
if (documentURI === '') {
|
|
119
119
|
throw new _ExecutionError.default(`operationPath "${operationPath}" does not resolve to a source description URL`, {
|
|
@@ -104,7 +104,7 @@ class OpenAPIOperationLocatorNormalizer extends SourceDescriptionsLocatorNormali
|
|
|
104
104
|
document,
|
|
105
105
|
registry: this.registry
|
|
106
106
|
});
|
|
107
|
-
const uriReference = evaluator.interpolate(operationPath);
|
|
107
|
+
const uriReference = await evaluator.interpolate(operationPath);
|
|
108
108
|
const documentURI = url.sanitize(url.stripHash(uriReference));
|
|
109
109
|
if (documentURI === '') {
|
|
110
110
|
throw new ExecutionError(`operationPath "${operationPath}" does not resolve to a source description URL`, {
|
|
@@ -188,8 +188,8 @@ class StepExecutor {
|
|
|
188
188
|
// keyed by '{in}.{name}' rather than bare name, so two parameters that
|
|
189
189
|
// legally differ only in their location each reach their own place.
|
|
190
190
|
const preContext = state.toContext();
|
|
191
|
-
const parameters = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
192
|
-
const requestBody = this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
191
|
+
const parameters = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
192
|
+
const requestBody = await this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
193
193
|
|
|
194
194
|
// checked here rather than on entry: locating the operation and resolving
|
|
195
195
|
// the expressions above are awaited, so a run cancelled during them would
|
|
@@ -225,13 +225,13 @@ class StepExecutor {
|
|
|
225
225
|
// evaluate criteria, outputs, and the next action against the post-request
|
|
226
226
|
// context (with $request / $url / $method and $response / $statusCode).
|
|
227
227
|
const postContext = state.toContext(this.#requestContext(response), this.#responseContext(response));
|
|
228
|
-
const successCriteria = this.evaluateCriteria(step, postContext, workflowId);
|
|
228
|
+
const successCriteria = await this.evaluateCriteria(step, postContext, workflowId);
|
|
229
229
|
const successful = successCriteria.every(criterion => criterion.met);
|
|
230
|
-
const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
230
|
+
const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
231
231
|
const {
|
|
232
232
|
matchedActions,
|
|
233
233
|
actionCriteria
|
|
234
|
-
} = this.selectActions(step, successful, postContext, workflowId);
|
|
234
|
+
} = await this.selectActions(step, successful, postContext, workflowId);
|
|
235
235
|
return {
|
|
236
236
|
stepId,
|
|
237
237
|
response,
|
|
@@ -328,13 +328,18 @@ class StepExecutor {
|
|
|
328
328
|
* names the step's workflow on a thrown error, as for
|
|
329
329
|
* {@link StepExecutor.execute}.
|
|
330
330
|
*/
|
|
331
|
-
evaluateCriteria(step, context, workflowId) {
|
|
331
|
+
async evaluateCriteria(step, context, workflowId) {
|
|
332
332
|
this.assertSuccessCriteria(step, workflowId);
|
|
333
333
|
const criteria = step.successCriteria;
|
|
334
334
|
if (criteria === undefined) return [];
|
|
335
335
|
|
|
336
|
-
// assertSuccessCriteria above guarantees every entry is a Criterion Object
|
|
337
|
-
|
|
336
|
+
// assertSuccessCriteria above guarantees every entry is a Criterion Object.
|
|
337
|
+
// evaluated one after another, in list order, like the actions' criteria.
|
|
338
|
+
const records = [];
|
|
339
|
+
for (const criterion of [...criteria]) {
|
|
340
|
+
records.push(await this.#evaluateCriterion(criterion, context));
|
|
341
|
+
}
|
|
342
|
+
return records;
|
|
338
343
|
}
|
|
339
344
|
|
|
340
345
|
/**
|
|
@@ -360,11 +365,11 @@ class StepExecutor {
|
|
|
360
365
|
* `workflowId` names the step's workflow on a thrown error, as for
|
|
361
366
|
* {@link StepExecutor.execute}.
|
|
362
367
|
*/
|
|
363
|
-
selectActions(step, successful, context, workflowId) {
|
|
368
|
+
async selectActions(step, successful, context, workflowId) {
|
|
364
369
|
const actionCriteria = [];
|
|
365
|
-
const isCriterionMet = (criterion, action) => {
|
|
370
|
+
const isCriterionMet = async (criterion, action) => {
|
|
366
371
|
const record = {
|
|
367
|
-
...this.#evaluateCriterion(criterion, context),
|
|
372
|
+
...(await this.#evaluateCriterion(criterion, context)),
|
|
368
373
|
actionName: (0, _apidomCore.toValue)(action.name)
|
|
369
374
|
};
|
|
370
375
|
actionCriteria.push(record);
|
|
@@ -376,7 +381,7 @@ class StepExecutor {
|
|
|
376
381
|
}),
|
|
377
382
|
stepId: (0, _apidomCore.toValue)(step.stepId)
|
|
378
383
|
};
|
|
379
|
-
const matchedActions = successful ? this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
384
|
+
const matchedActions = successful ? await this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : await this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
380
385
|
return {
|
|
381
386
|
matchedActions,
|
|
382
387
|
actionCriteria
|
|
@@ -410,13 +415,13 @@ class StepExecutor {
|
|
|
410
415
|
* condition that cannot be evaluated is unmet and records why; any other
|
|
411
416
|
* error propagates.
|
|
412
417
|
*/
|
|
413
|
-
#evaluateCriterion(criterion, context) {
|
|
418
|
+
async #evaluateCriterion(criterion, context) {
|
|
414
419
|
const condition = (0, _apidomCore.toValue)(criterion.condition);
|
|
415
420
|
try {
|
|
416
421
|
const {
|
|
417
422
|
met,
|
|
418
423
|
error
|
|
419
|
-
} = this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
424
|
+
} = await this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
420
425
|
if (error === undefined) return {
|
|
421
426
|
condition,
|
|
422
427
|
met
|
|
@@ -181,8 +181,8 @@ class StepExecutor {
|
|
|
181
181
|
// keyed by '{in}.{name}' rather than bare name, so two parameters that
|
|
182
182
|
// legally differ only in their location each reach their own place.
|
|
183
183
|
const preContext = state.toContext();
|
|
184
|
-
const parameters = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
185
|
-
const requestBody = this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
184
|
+
const parameters = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
185
|
+
const requestBody = await this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
186
186
|
|
|
187
187
|
// checked here rather than on entry: locating the operation and resolving
|
|
188
188
|
// the expressions above are awaited, so a run cancelled during them would
|
|
@@ -218,13 +218,13 @@ class StepExecutor {
|
|
|
218
218
|
// evaluate criteria, outputs, and the next action against the post-request
|
|
219
219
|
// context (with $request / $url / $method and $response / $statusCode).
|
|
220
220
|
const postContext = state.toContext(this.#requestContext(response), this.#responseContext(response));
|
|
221
|
-
const successCriteria = this.evaluateCriteria(step, postContext, workflowId);
|
|
221
|
+
const successCriteria = await this.evaluateCriteria(step, postContext, workflowId);
|
|
222
222
|
const successful = successCriteria.every(criterion => criterion.met);
|
|
223
|
-
const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
223
|
+
const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
224
224
|
const {
|
|
225
225
|
matchedActions,
|
|
226
226
|
actionCriteria
|
|
227
|
-
} = this.selectActions(step, successful, postContext, workflowId);
|
|
227
|
+
} = await this.selectActions(step, successful, postContext, workflowId);
|
|
228
228
|
return {
|
|
229
229
|
stepId,
|
|
230
230
|
response,
|
|
@@ -321,13 +321,18 @@ class StepExecutor {
|
|
|
321
321
|
* names the step's workflow on a thrown error, as for
|
|
322
322
|
* {@link StepExecutor.execute}.
|
|
323
323
|
*/
|
|
324
|
-
evaluateCriteria(step, context, workflowId) {
|
|
324
|
+
async evaluateCriteria(step, context, workflowId) {
|
|
325
325
|
this.assertSuccessCriteria(step, workflowId);
|
|
326
326
|
const criteria = step.successCriteria;
|
|
327
327
|
if (criteria === undefined) return [];
|
|
328
328
|
|
|
329
|
-
// assertSuccessCriteria above guarantees every entry is a Criterion Object
|
|
330
|
-
|
|
329
|
+
// assertSuccessCriteria above guarantees every entry is a Criterion Object.
|
|
330
|
+
// evaluated one after another, in list order, like the actions' criteria.
|
|
331
|
+
const records = [];
|
|
332
|
+
for (const criterion of [...criteria]) {
|
|
333
|
+
records.push(await this.#evaluateCriterion(criterion, context));
|
|
334
|
+
}
|
|
335
|
+
return records;
|
|
331
336
|
}
|
|
332
337
|
|
|
333
338
|
/**
|
|
@@ -353,11 +358,11 @@ class StepExecutor {
|
|
|
353
358
|
* `workflowId` names the step's workflow on a thrown error, as for
|
|
354
359
|
* {@link StepExecutor.execute}.
|
|
355
360
|
*/
|
|
356
|
-
selectActions(step, successful, context, workflowId) {
|
|
361
|
+
async selectActions(step, successful, context, workflowId) {
|
|
357
362
|
const actionCriteria = [];
|
|
358
|
-
const isCriterionMet = (criterion, action) => {
|
|
363
|
+
const isCriterionMet = async (criterion, action) => {
|
|
359
364
|
const record = {
|
|
360
|
-
...this.#evaluateCriterion(criterion, context),
|
|
365
|
+
...(await this.#evaluateCriterion(criterion, context)),
|
|
361
366
|
actionName: toValue(action.name)
|
|
362
367
|
};
|
|
363
368
|
actionCriteria.push(record);
|
|
@@ -369,7 +374,7 @@ class StepExecutor {
|
|
|
369
374
|
}),
|
|
370
375
|
stepId: toValue(step.stepId)
|
|
371
376
|
};
|
|
372
|
-
const matchedActions = successful ? this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
377
|
+
const matchedActions = successful ? await this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : await this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
373
378
|
return {
|
|
374
379
|
matchedActions,
|
|
375
380
|
actionCriteria
|
|
@@ -403,13 +408,13 @@ class StepExecutor {
|
|
|
403
408
|
* condition that cannot be evaluated is unmet and records why; any other
|
|
404
409
|
* error propagates.
|
|
405
410
|
*/
|
|
406
|
-
#evaluateCriterion(criterion, context) {
|
|
411
|
+
async #evaluateCriterion(criterion, context) {
|
|
407
412
|
const condition = toValue(criterion.condition);
|
|
408
413
|
try {
|
|
409
414
|
const {
|
|
410
415
|
met,
|
|
411
416
|
error
|
|
412
|
-
} = this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
417
|
+
} = await this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
413
418
|
if (error === undefined) return {
|
|
414
419
|
condition,
|
|
415
420
|
met
|