@usearazzo/runner 1.0.1-alpha.32 → 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 +21 -0
- package/dist/arazzo-runner.browser.js +678 -173
- 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/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 +83 -36
|
@@ -32,7 +32,7 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
32
32
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
33
33
|
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
34
34
|
*/
|
|
35
|
-
resolve(outputs, resolve, scope) {
|
|
35
|
+
async resolve(outputs, resolve, scope) {
|
|
36
36
|
const result = {};
|
|
37
37
|
if (outputs === undefined) return result;
|
|
38
38
|
// present but not a map: the walk below would fail as a bare
|
|
@@ -44,7 +44,14 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
44
44
|
reason: _ResolverError.default.MalformedOutputs
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
// collected first: `forEach` takes a synchronous callback, and each output
|
|
49
|
+
// is awaited in turn below.
|
|
50
|
+
const entries = [];
|
|
47
51
|
outputs.forEach((value, key) => {
|
|
52
|
+
entries.push([key, value]);
|
|
53
|
+
});
|
|
54
|
+
for (const [key, value] of entries) {
|
|
48
55
|
const name = (0, _apidomCore.toValue)(key);
|
|
49
56
|
const expression = (0, _apidomCore.toValue)(value);
|
|
50
57
|
if (typeof expression !== 'string' || !(0, _arazzoRuntimeExpression.test)(expression)) {
|
|
@@ -59,12 +66,12 @@ class OutputResolver extends _ArazzoValueResolver.default {
|
|
|
59
66
|
// ever created and the output is silently lost — and an object value
|
|
60
67
|
// additionally rewrites the record's prototype
|
|
61
68
|
Object.defineProperty(result, name, {
|
|
62
|
-
value: resolve(expression),
|
|
69
|
+
value: await resolve(expression),
|
|
63
70
|
enumerable: true,
|
|
64
71
|
writable: true,
|
|
65
72
|
configurable: true
|
|
66
73
|
});
|
|
67
|
-
}
|
|
74
|
+
}
|
|
68
75
|
return result;
|
|
69
76
|
}
|
|
70
77
|
}
|
|
@@ -25,7 +25,7 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
25
25
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
26
26
|
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
27
27
|
*/
|
|
28
|
-
resolve(outputs, resolve, scope) {
|
|
28
|
+
async resolve(outputs, resolve, scope) {
|
|
29
29
|
const result = {};
|
|
30
30
|
if (outputs === undefined) return result;
|
|
31
31
|
// present but not a map: the walk below would fail as a bare
|
|
@@ -37,7 +37,14 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
37
37
|
reason: ResolverError.MalformedOutputs
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
// collected first: `forEach` takes a synchronous callback, and each output
|
|
42
|
+
// is awaited in turn below.
|
|
43
|
+
const entries = [];
|
|
40
44
|
outputs.forEach((value, key) => {
|
|
45
|
+
entries.push([key, value]);
|
|
46
|
+
});
|
|
47
|
+
for (const [key, value] of entries) {
|
|
41
48
|
const name = toValue(key);
|
|
42
49
|
const expression = toValue(value);
|
|
43
50
|
if (typeof expression !== 'string' || !isRuntimeExpression(expression)) {
|
|
@@ -52,12 +59,12 @@ class OutputResolver extends ArazzoValueResolver {
|
|
|
52
59
|
// ever created and the output is silently lost — and an object value
|
|
53
60
|
// additionally rewrites the record's prototype
|
|
54
61
|
Object.defineProperty(result, name, {
|
|
55
|
-
value: resolve(expression),
|
|
62
|
+
value: await resolve(expression),
|
|
56
63
|
enumerable: true,
|
|
57
64
|
writable: true,
|
|
58
65
|
configurable: true
|
|
59
66
|
});
|
|
60
|
-
}
|
|
67
|
+
}
|
|
61
68
|
return result;
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -65,7 +65,7 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
65
65
|
*
|
|
66
66
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
67
67
|
*/
|
|
68
|
-
resolve(requestBody, resolve, scope) {
|
|
68
|
+
async resolve(requestBody, resolve, scope) {
|
|
69
69
|
if (requestBody === undefined) return undefined;
|
|
70
70
|
|
|
71
71
|
// present but scalar: `.payload`, `.replacements` and `.contentType` are
|
|
@@ -79,7 +79,7 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const authoredPayload = (0, _apidomCore.toValue)(requestBody.payload);
|
|
82
|
-
let payload = this.#requireResolved(authoredPayload, this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
82
|
+
let payload = this.#requireResolved(authoredPayload, await this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
83
83
|
if (requestBody.replacements !== undefined) {
|
|
84
84
|
// present but scalar: walking it would fail as a bare
|
|
85
85
|
// `TypeError: requestBody.replacements is not iterable`.
|
|
@@ -94,7 +94,7 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
94
94
|
if (!(0, _apidomNsArazzo.isPayloadReplacementElement)(replacement)) continue;
|
|
95
95
|
const target = (0, _apidomCore.toValue)(replacement.target);
|
|
96
96
|
if (typeof target !== 'string') continue;
|
|
97
|
-
const value = this.resolveValue(replacement.value, resolve);
|
|
97
|
+
const value = await this.resolveValue(replacement.value, resolve);
|
|
98
98
|
if (value === undefined) continue;
|
|
99
99
|
payload = this.#applyReplacement(payload, target, value, scope);
|
|
100
100
|
}
|
|
@@ -113,19 +113,26 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
113
113
|
* objects and arrays. Returns {@link UNRESOLVED} for a bare expression that
|
|
114
114
|
* did not resolve, for its container to handle.
|
|
115
115
|
*/
|
|
116
|
-
#resolvePayloadValue(value, tokens, resolve, scope) {
|
|
116
|
+
async #resolvePayloadValue(value, tokens, resolve, scope) {
|
|
117
117
|
if (typeof value === 'string') return this.#resolvePayloadString(value, tokens, resolve, scope);
|
|
118
118
|
if (Array.isArray(value)) {
|
|
119
|
-
|
|
119
|
+
const items = [];
|
|
120
|
+
for (const [index, item] of value.entries()) {
|
|
120
121
|
const itemTokens = [...tokens, String(index)];
|
|
121
|
-
const resolved = this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
122
|
-
|
|
123
|
-
}
|
|
122
|
+
const resolved = await this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
123
|
+
items.push(this.#requireResolved(item, resolved, itemTokens, scope));
|
|
124
|
+
}
|
|
125
|
+
return items;
|
|
124
126
|
}
|
|
125
127
|
if (value !== null && typeof value === 'object') {
|
|
128
|
+
const members = [];
|
|
129
|
+
for (const [key, member] of Object.entries(value)) {
|
|
130
|
+
const resolved = await this.#resolvePayloadValue(member, [...tokens, key], resolve, scope);
|
|
131
|
+
if (resolved !== UNRESOLVED) members.push([key, resolved]);
|
|
132
|
+
}
|
|
126
133
|
// `fromEntries` defines own properties, so an authored `__proto__` key
|
|
127
134
|
// stays a plain member instead of replacing the prototype.
|
|
128
|
-
return Object.fromEntries(
|
|
135
|
+
return Object.fromEntries(members);
|
|
129
136
|
}
|
|
130
137
|
return value;
|
|
131
138
|
}
|
|
@@ -135,16 +142,12 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
135
142
|
* typed value (or {@link UNRESOLVED}), anything else by tolerant
|
|
136
143
|
* interpolation of its embedded `{expression}` occurrences.
|
|
137
144
|
*/
|
|
138
|
-
#resolvePayloadString(value, tokens, resolve, scope) {
|
|
145
|
+
async #resolvePayloadString(value, tokens, resolve, scope) {
|
|
139
146
|
if ((0, _arazzoRuntimeExpression.test)(value)) {
|
|
140
|
-
const resolved = resolve(value);
|
|
147
|
+
const resolved = await resolve(value);
|
|
141
148
|
return resolved === undefined ? UNRESOLVED : resolved;
|
|
142
149
|
}
|
|
143
|
-
|
|
144
|
-
const resolved = resolve(expression);
|
|
145
|
-
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
146
|
-
return resolved;
|
|
147
|
-
}, {
|
|
150
|
+
const options = {
|
|
148
151
|
strict: false,
|
|
149
152
|
onError: ({
|
|
150
153
|
text
|
|
@@ -155,7 +158,24 @@ class RequestBodyResolver extends _ArazzoValueResolver.default {
|
|
|
155
158
|
reason: _ResolverError.default.InvalidExpression
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
|
-
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// `interpolate` takes a synchronous resolver, so the embedded expressions
|
|
164
|
+
// are collected by a first pass, resolved in order, and substituted by a
|
|
165
|
+
// second. Interpolation never skips an expression, so the result is the same.
|
|
166
|
+
const expressions = [];
|
|
167
|
+
(0, _arazzoRuntimeExpression.interpolate)(value, expression => {
|
|
168
|
+
expressions.push(expression);
|
|
169
|
+
return '';
|
|
170
|
+
}, options);
|
|
171
|
+
const values = new Map();
|
|
172
|
+
for (const expression of expressions) {
|
|
173
|
+
if (values.has(expression)) continue;
|
|
174
|
+
const resolved = await resolve(expression);
|
|
175
|
+
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
176
|
+
values.set(expression, resolved);
|
|
177
|
+
}
|
|
178
|
+
return (0, _arazzoRuntimeExpression.interpolate)(value, expression => values.get(expression), options);
|
|
159
179
|
}
|
|
160
180
|
|
|
161
181
|
/**
|
|
@@ -58,7 +58,7 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
58
58
|
*
|
|
59
59
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
60
60
|
*/
|
|
61
|
-
resolve(requestBody, resolve, scope) {
|
|
61
|
+
async resolve(requestBody, resolve, scope) {
|
|
62
62
|
if (requestBody === undefined) return undefined;
|
|
63
63
|
|
|
64
64
|
// present but scalar: `.payload`, `.replacements` and `.contentType` are
|
|
@@ -72,7 +72,7 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
const authoredPayload = toValue(requestBody.payload);
|
|
75
|
-
let payload = this.#requireResolved(authoredPayload, this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
75
|
+
let payload = this.#requireResolved(authoredPayload, await this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
76
76
|
if (requestBody.replacements !== undefined) {
|
|
77
77
|
// present but scalar: walking it would fail as a bare
|
|
78
78
|
// `TypeError: requestBody.replacements is not iterable`.
|
|
@@ -87,7 +87,7 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
87
87
|
if (!isPayloadReplacementElement(replacement)) continue;
|
|
88
88
|
const target = toValue(replacement.target);
|
|
89
89
|
if (typeof target !== 'string') continue;
|
|
90
|
-
const value = this.resolveValue(replacement.value, resolve);
|
|
90
|
+
const value = await this.resolveValue(replacement.value, resolve);
|
|
91
91
|
if (value === undefined) continue;
|
|
92
92
|
payload = this.#applyReplacement(payload, target, value, scope);
|
|
93
93
|
}
|
|
@@ -106,19 +106,26 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
106
106
|
* objects and arrays. Returns {@link UNRESOLVED} for a bare expression that
|
|
107
107
|
* did not resolve, for its container to handle.
|
|
108
108
|
*/
|
|
109
|
-
#resolvePayloadValue(value, tokens, resolve, scope) {
|
|
109
|
+
async #resolvePayloadValue(value, tokens, resolve, scope) {
|
|
110
110
|
if (typeof value === 'string') return this.#resolvePayloadString(value, tokens, resolve, scope);
|
|
111
111
|
if (Array.isArray(value)) {
|
|
112
|
-
|
|
112
|
+
const items = [];
|
|
113
|
+
for (const [index, item] of value.entries()) {
|
|
113
114
|
const itemTokens = [...tokens, String(index)];
|
|
114
|
-
const resolved = this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
115
|
-
|
|
116
|
-
}
|
|
115
|
+
const resolved = await this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
116
|
+
items.push(this.#requireResolved(item, resolved, itemTokens, scope));
|
|
117
|
+
}
|
|
118
|
+
return items;
|
|
117
119
|
}
|
|
118
120
|
if (value !== null && typeof value === 'object') {
|
|
121
|
+
const members = [];
|
|
122
|
+
for (const [key, member] of Object.entries(value)) {
|
|
123
|
+
const resolved = await this.#resolvePayloadValue(member, [...tokens, key], resolve, scope);
|
|
124
|
+
if (resolved !== UNRESOLVED) members.push([key, resolved]);
|
|
125
|
+
}
|
|
119
126
|
// `fromEntries` defines own properties, so an authored `__proto__` key
|
|
120
127
|
// stays a plain member instead of replacing the prototype.
|
|
121
|
-
return Object.fromEntries(
|
|
128
|
+
return Object.fromEntries(members);
|
|
122
129
|
}
|
|
123
130
|
return value;
|
|
124
131
|
}
|
|
@@ -128,16 +135,12 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
128
135
|
* typed value (or {@link UNRESOLVED}), anything else by tolerant
|
|
129
136
|
* interpolation of its embedded `{expression}` occurrences.
|
|
130
137
|
*/
|
|
131
|
-
#resolvePayloadString(value, tokens, resolve, scope) {
|
|
138
|
+
async #resolvePayloadString(value, tokens, resolve, scope) {
|
|
132
139
|
if (isRuntimeExpression(value)) {
|
|
133
|
-
const resolved = resolve(value);
|
|
140
|
+
const resolved = await resolve(value);
|
|
134
141
|
return resolved === undefined ? UNRESOLVED : resolved;
|
|
135
142
|
}
|
|
136
|
-
|
|
137
|
-
const resolved = resolve(expression);
|
|
138
|
-
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
139
|
-
return resolved;
|
|
140
|
-
}, {
|
|
143
|
+
const options = {
|
|
141
144
|
strict: false,
|
|
142
145
|
onError: ({
|
|
143
146
|
text
|
|
@@ -148,7 +151,24 @@ class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
148
151
|
reason: ResolverError.InvalidExpression
|
|
149
152
|
});
|
|
150
153
|
}
|
|
151
|
-
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// `interpolate` takes a synchronous resolver, so the embedded expressions
|
|
157
|
+
// are collected by a first pass, resolved in order, and substituted by a
|
|
158
|
+
// second. Interpolation never skips an expression, so the result is the same.
|
|
159
|
+
const expressions = [];
|
|
160
|
+
interpolate(value, expression => {
|
|
161
|
+
expressions.push(expression);
|
|
162
|
+
return '';
|
|
163
|
+
}, options);
|
|
164
|
+
const values = new Map();
|
|
165
|
+
for (const expression of expressions) {
|
|
166
|
+
if (values.has(expression)) continue;
|
|
167
|
+
const resolved = await resolve(expression);
|
|
168
|
+
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
169
|
+
values.set(expression, resolved);
|
|
170
|
+
}
|
|
171
|
+
return interpolate(value, expression => values.get(expression), options);
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
/**
|
|
@@ -36,7 +36,7 @@ class WorkflowParameterResolver extends _StepParameterResolver.default {
|
|
|
36
36
|
*
|
|
37
37
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
38
38
|
*/
|
|
39
|
-
resolve(parameters, resolve, scope) {
|
|
39
|
+
async resolve(parameters, resolve, scope) {
|
|
40
40
|
const result = {};
|
|
41
41
|
if (parameters === undefined) return result;
|
|
42
42
|
// present but scalar: walking it would fail as a bare
|
|
@@ -62,7 +62,7 @@ class WorkflowParameterResolver extends _StepParameterResolver.default {
|
|
|
62
62
|
// ever created and the input is silently lost — and an object value
|
|
63
63
|
// additionally rewrites the record's prototype
|
|
64
64
|
Object.defineProperty(result, name, {
|
|
65
|
-
value: this.resolveValue(parameter.value, resolve),
|
|
65
|
+
value: await this.resolveValue(parameter.value, resolve),
|
|
66
66
|
enumerable: true,
|
|
67
67
|
writable: true,
|
|
68
68
|
configurable: true
|
|
@@ -29,7 +29,7 @@ class WorkflowParameterResolver extends StepParameterResolver {
|
|
|
29
29
|
*
|
|
30
30
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
31
31
|
*/
|
|
32
|
-
resolve(parameters, resolve, scope) {
|
|
32
|
+
async resolve(parameters, resolve, scope) {
|
|
33
33
|
const result = {};
|
|
34
34
|
if (parameters === undefined) return result;
|
|
35
35
|
// present but scalar: walking it would fail as a bare
|
|
@@ -55,7 +55,7 @@ class WorkflowParameterResolver extends StepParameterResolver {
|
|
|
55
55
|
// ever created and the input is silently lost — and an object value
|
|
56
56
|
// additionally rewrites the record's prototype
|
|
57
57
|
Object.defineProperty(result, name, {
|
|
58
|
-
value: this.resolveValue(parameter.value, resolve),
|
|
58
|
+
value: await this.resolveValue(parameter.value, resolve),
|
|
59
59
|
enumerable: true,
|
|
60
60
|
writable: true,
|
|
61
61
|
configurable: true
|
package/types/runner.d.ts
CHANGED
|
@@ -66,14 +66,14 @@ export declare class ActionResolver {
|
|
|
66
66
|
* `end` its author was reaching for would otherwise never happen without a
|
|
67
67
|
* word said about why.
|
|
68
68
|
*/
|
|
69
|
-
resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): SuccessActionElement[]
|
|
69
|
+
resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<SuccessActionElement[]>;
|
|
70
70
|
/**
|
|
71
71
|
* Returns every `onFailure` action whose criteria are all met, in list order.
|
|
72
72
|
*
|
|
73
73
|
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
74
74
|
* see there for the full rationale — mirrored for the step's other list.
|
|
75
75
|
*/
|
|
76
|
-
resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): FailureActionElement[]
|
|
76
|
+
resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<FailureActionElement[]>;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -163,6 +163,7 @@ export declare class ArazzoDocument extends APIDocument {
|
|
|
163
163
|
*/
|
|
164
164
|
export declare class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
165
165
|
#private;
|
|
166
|
+
readonly sourceDescriptionType = "arazzo";
|
|
166
167
|
constructor(options?: ArazzoDocumentRegistryProviderOptions);
|
|
167
168
|
canProvide(uri: string): Promise<boolean>;
|
|
168
169
|
/**
|
|
@@ -347,7 +348,7 @@ export declare abstract class ArazzoValueResolver {
|
|
|
347
348
|
/**
|
|
348
349
|
* Resolves one authored value element by the rule above.
|
|
349
350
|
*/
|
|
350
|
-
protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): unknown
|
|
351
|
+
protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): Promise<unknown>;
|
|
351
352
|
}
|
|
352
353
|
|
|
353
354
|
/**
|
|
@@ -498,14 +499,19 @@ export declare interface ContextSource {
|
|
|
498
499
|
}
|
|
499
500
|
|
|
500
501
|
/**
|
|
501
|
-
* Resolves a runtime expression to a value
|
|
502
|
+
* Resolves a runtime expression to a value, or to a Promise of it, during
|
|
503
|
+
* criterion evaluation. The result is awaited, so a synchronous resolver works
|
|
504
|
+
* too.
|
|
502
505
|
*
|
|
503
506
|
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
504
507
|
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
505
508
|
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
506
509
|
* than throwing (a common way to drive it is
|
|
507
510
|
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
508
|
-
* lenient evaluator).
|
|
511
|
+
* lenient evaluator). An error it throws or rejects with — such as the load
|
|
512
|
+
* error of a `$sourceDescriptions` document that cannot be loaded — is not a
|
|
513
|
+
* {@link CriterionEvaluationError}, so it propagates instead of failing the
|
|
514
|
+
* criterion.
|
|
509
515
|
* @public
|
|
510
516
|
*/
|
|
511
517
|
export declare type CriterionContextResolver = (expression: string) => unknown;
|
|
@@ -665,7 +671,7 @@ export declare class CriterionEvaluator {
|
|
|
665
671
|
* the expressions embedded in the condition; for the other types it resolves
|
|
666
672
|
* the criterion's `context` expression that the condition is applied to.
|
|
667
673
|
*/
|
|
668
|
-
evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): CriterionOutcome
|
|
674
|
+
evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): Promise<CriterionOutcome>;
|
|
669
675
|
}
|
|
670
676
|
|
|
671
677
|
/**
|
|
@@ -713,15 +719,16 @@ export declare interface CriterionOutcome {
|
|
|
713
719
|
}
|
|
714
720
|
|
|
715
721
|
/**
|
|
716
|
-
* Determines whether a single criterion of an action is met
|
|
717
|
-
* action declaring the criterion, so a caller can
|
|
722
|
+
* Determines whether a single criterion of an action is met, or resolves to
|
|
723
|
+
* whether it is. Receives the action declaring the criterion, so a caller can
|
|
724
|
+
* attribute the outcome to it.
|
|
718
725
|
*
|
|
719
726
|
* Bridged to a criterion evaluator
|
|
720
|
-
* (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`);
|
|
721
|
-
* unresolvable/failing criterion is `false`, not an error.
|
|
727
|
+
* (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
|
|
728
|
+
* an unresolvable/failing criterion is `false`, not an error.
|
|
722
729
|
* @public
|
|
723
730
|
*/
|
|
724
|
-
export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean
|
|
731
|
+
export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean | Promise<boolean>;
|
|
725
732
|
|
|
726
733
|
/** @public */
|
|
727
734
|
export declare class DocumentLoadError extends ArazzoRunnerError {
|
|
@@ -748,20 +755,24 @@ export declare class DocumentRegistry {
|
|
|
748
755
|
* otherwise detects the format, loads via the matching provider,
|
|
749
756
|
* caches, and returns it.
|
|
750
757
|
*
|
|
758
|
+
* Concurrent calls for a document that is still loading share that one
|
|
759
|
+
* load instead of each fetching and parsing it. A failed load is not
|
|
760
|
+
* remembered: the next call tries again.
|
|
761
|
+
*
|
|
751
762
|
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
752
763
|
* @throws UnmatchedProviderError - When no provider can load the document
|
|
753
764
|
*/
|
|
754
765
|
acquire(uri: string): Promise<APIDocument>;
|
|
755
766
|
/**
|
|
756
|
-
*
|
|
767
|
+
* Whether a source description of `type` can be loaded at all: some provider
|
|
768
|
+
* loads that type, or does not say which type it loads. A source with no
|
|
769
|
+
* `type` may be of any type, so it can.
|
|
757
770
|
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* (e.g. runtime expression evaluation) use this; the executor is responsible
|
|
762
|
-
* for having acquired the document beforehand.
|
|
771
|
+
* Answered from the providers alone, without fetching anything — so a
|
|
772
|
+
* caller can skip a load that could only fail, such as an AsyncAPI source
|
|
773
|
+
* while no provider loads AsyncAPI.
|
|
763
774
|
*/
|
|
764
|
-
|
|
775
|
+
canLoad(type: string | undefined): boolean;
|
|
765
776
|
/**
|
|
766
777
|
* Acquires the entry Arazzo document and marks it with `isEntry: true`.
|
|
767
778
|
* Validates that the document is an Arazzo specification.
|
|
@@ -771,6 +782,10 @@ export declare class DocumentRegistry {
|
|
|
771
782
|
* @throws InvalidEntryDocumentError - When the document is not an Arazzo document
|
|
772
783
|
*/
|
|
773
784
|
acquireEntryDocument(uri: string): Promise<ArazzoDocument>;
|
|
785
|
+
/**
|
|
786
|
+
* Drops every cached document. A load still in progress is no longer shared:
|
|
787
|
+
* the next `acquire` of that document starts a fresh load.
|
|
788
|
+
*/
|
|
774
789
|
clear(): void;
|
|
775
790
|
}
|
|
776
791
|
|
|
@@ -789,6 +804,15 @@ export declare interface DocumentRegistryOptions {
|
|
|
789
804
|
* @public
|
|
790
805
|
*/
|
|
791
806
|
export declare abstract class DocumentRegistryProvider {
|
|
807
|
+
/**
|
|
808
|
+
* The Source Description Object `type` this provider loads (`openapi`,
|
|
809
|
+
* `arazzo`, …), or `undefined` when it does not say — then it may load a
|
|
810
|
+
* source of any type.
|
|
811
|
+
*
|
|
812
|
+
* Lets the registry tell, without fetching anything, whether a source of a
|
|
813
|
+
* given type can be loaded at all (`DocumentRegistry.canLoad`).
|
|
814
|
+
*/
|
|
815
|
+
readonly sourceDescriptionType?: string;
|
|
792
816
|
/**
|
|
793
817
|
* Checks if the content at the URI can be handled by this provider.
|
|
794
818
|
*/
|
|
@@ -1127,6 +1151,7 @@ export declare interface OpenAPIDocumentAssemblerOptions {
|
|
|
1127
1151
|
*/
|
|
1128
1152
|
export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
|
|
1129
1153
|
#private;
|
|
1154
|
+
readonly sourceDescriptionType = "openapi";
|
|
1130
1155
|
constructor(options?: OpenAPIDocumentRegistryProviderOptions);
|
|
1131
1156
|
canProvide(uri: string): Promise<boolean>;
|
|
1132
1157
|
/**
|
|
@@ -1517,7 +1542,7 @@ export declare class OpenAPIOperationParameterResolver extends StepParameterReso
|
|
|
1517
1542
|
*
|
|
1518
1543
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
1519
1544
|
*/
|
|
1520
|
-
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown
|
|
1545
|
+
resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
1521
1546
|
}
|
|
1522
1547
|
|
|
1523
1548
|
/**
|
|
@@ -1710,7 +1735,7 @@ export declare class OutputResolver extends ArazzoValueResolver {
|
|
|
1710
1735
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
1711
1736
|
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
1712
1737
|
*/
|
|
1713
|
-
resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Record<string, unknown
|
|
1738
|
+
resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Promise<Record<string, unknown>>;
|
|
1714
1739
|
}
|
|
1715
1740
|
|
|
1716
1741
|
/**
|
|
@@ -1781,7 +1806,7 @@ export declare class RequestBodyResolver extends ArazzoValueResolver {
|
|
|
1781
1806
|
*
|
|
1782
1807
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
1783
1808
|
*/
|
|
1784
|
-
resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): ResolvedRequestBody | undefined
|
|
1809
|
+
resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<ResolvedRequestBody | undefined>;
|
|
1785
1810
|
}
|
|
1786
1811
|
|
|
1787
1812
|
/**
|
|
@@ -2062,6 +2087,9 @@ export declare type RuntimeExpressionErrorReason = (typeof RuntimeExpressionErro
|
|
|
2062
2087
|
* (via the registry) the source name points at. A step reference resolves to
|
|
2063
2088
|
* the Step Object as authored — a locator, not the step's execution result.
|
|
2064
2089
|
*
|
|
2090
|
+
* Evaluation is asynchronous because a `$sourceDescriptions` reference may
|
|
2091
|
+
* have to load the document it points at.
|
|
2092
|
+
*
|
|
2065
2093
|
* A reference resolves to `undefined` when it is absent. Runtime values
|
|
2066
2094
|
* originate from JSON (or ApiDOM), which cannot represent `undefined` — an
|
|
2067
2095
|
* absent value is a missing property and an explicit null is `null` — so
|
|
@@ -2086,8 +2114,16 @@ export declare class RuntimeExpressionEvaluator {
|
|
|
2086
2114
|
* The expression must be the bare form without surrounding braces
|
|
2087
2115
|
* (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
|
|
2088
2116
|
* unresolvable reference throws; otherwise it returns `undefined`.
|
|
2117
|
+
*
|
|
2118
|
+
* A `$sourceDescriptions` reference whose document cannot be loaded is not
|
|
2119
|
+
* merely unresolved: unless it names a field of the Source Description Object,
|
|
2120
|
+
* it rejects with the load error in either mode, since nothing else can
|
|
2121
|
+
* produce its value.
|
|
2122
|
+
*
|
|
2123
|
+
* @throws DocumentLoadError - When a referenced source document cannot be read or loaded
|
|
2124
|
+
* @throws UnmatchedProviderError - When no provider can load a referenced source document
|
|
2089
2125
|
*/
|
|
2090
|
-
evaluate(expression: string): unknown
|
|
2126
|
+
evaluate(expression: string): Promise<unknown>;
|
|
2091
2127
|
/**
|
|
2092
2128
|
* Renders a template string, replacing each embedded `{expression}` with the
|
|
2093
2129
|
* string form of its evaluated value. Returns a string.
|
|
@@ -2096,7 +2132,7 @@ export declare class RuntimeExpressionEvaluator {
|
|
|
2096
2132
|
* mode, unresolvable references render as an empty string. A `{…}` that is not
|
|
2097
2133
|
* a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
|
|
2098
2134
|
*/
|
|
2099
|
-
interpolate(template: string): string
|
|
2135
|
+
interpolate(template: string): Promise<string>;
|
|
2100
2136
|
/**
|
|
2101
2137
|
* Resolves an Arazzo "value" string.
|
|
2102
2138
|
*
|
|
@@ -2108,7 +2144,7 @@ export declare class RuntimeExpressionEvaluator {
|
|
|
2108
2144
|
* yields the string representation of its value, not the typed value. A
|
|
2109
2145
|
* string containing no expressions is returned unchanged.
|
|
2110
2146
|
*/
|
|
2111
|
-
resolve(value: string): unknown
|
|
2147
|
+
resolve(value: string): Promise<unknown>;
|
|
2112
2148
|
}
|
|
2113
2149
|
|
|
2114
2150
|
/**
|
|
@@ -2132,8 +2168,10 @@ export declare interface RuntimeExpressionEvaluatorOptions {
|
|
|
2132
2168
|
readonly document?: ArazzoDocument;
|
|
2133
2169
|
/**
|
|
2134
2170
|
* The document registry, used to reach the external document a
|
|
2135
|
-
* `$sourceDescriptions` reference points at. The
|
|
2136
|
-
*
|
|
2171
|
+
* `$sourceDescriptions` reference points at. The document is acquired from
|
|
2172
|
+
* it — returned from its cache, or loaded — whenever the source's `type` is
|
|
2173
|
+
* one the registry can load. Without a registry, `$sourceDescriptions`
|
|
2174
|
+
* resolves against the Source Description Object's own fields only.
|
|
2137
2175
|
*/
|
|
2138
2176
|
readonly registry?: DocumentRegistry;
|
|
2139
2177
|
}
|
|
@@ -2156,11 +2194,14 @@ export declare interface RuntimeExpressionRequestContext {
|
|
|
2156
2194
|
}
|
|
2157
2195
|
|
|
2158
2196
|
/**
|
|
2159
|
-
* Resolves a runtime expression to its value.
|
|
2197
|
+
* Resolves a runtime expression to its value, or to a Promise of it.
|
|
2160
2198
|
*
|
|
2161
2199
|
* Bridged to a lenient runtime expression evaluator
|
|
2162
2200
|
* (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
|
|
2163
|
-
* unresolvable reference yields `undefined` rather than throwing
|
|
2201
|
+
* unresolvable reference yields `undefined` rather than throwing; a
|
|
2202
|
+
* `$sourceDescriptions` document that cannot be loaded still rejects with the
|
|
2203
|
+
* load error (see `RuntimeExpressionEvaluator.evaluate`). The result
|
|
2204
|
+
* is awaited, so a synchronous resolver works too.
|
|
2164
2205
|
* @public
|
|
2165
2206
|
*/
|
|
2166
2207
|
export declare type RuntimeExpressionResolver = (expression: string) => unknown;
|
|
@@ -2226,7 +2267,9 @@ export declare function settledResult(result: WorkflowExecutionResult): Workflow
|
|
|
2226
2267
|
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
2227
2268
|
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
2228
2269
|
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
2229
|
-
* resolved through the supplied resolver.
|
|
2270
|
+
* resolved through the supplied resolver and awaited in turn. `&&` and `||`
|
|
2271
|
+
* short-circuit, so an operand that cannot change the outcome is never
|
|
2272
|
+
* resolved.
|
|
2230
2273
|
*
|
|
2231
2274
|
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
2232
2275
|
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
@@ -2240,7 +2283,7 @@ export declare class SimpleCriterionEvaluator {
|
|
|
2240
2283
|
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
2241
2284
|
* expression via `resolve`.
|
|
2242
2285
|
*/
|
|
2243
|
-
evaluate(condition: string, resolve: CriterionContextResolver): boolean
|
|
2286
|
+
evaluate(condition: string, resolve: CriterionContextResolver): Promise<boolean>;
|
|
2244
2287
|
}
|
|
2245
2288
|
|
|
2246
2289
|
/**
|
|
@@ -2423,7 +2466,7 @@ export declare class StepExecutor {
|
|
|
2423
2466
|
* names the step's workflow on a thrown error, as for
|
|
2424
2467
|
* {@link StepExecutor.execute}.
|
|
2425
2468
|
*/
|
|
2426
|
-
evaluateCriteria(step: StepElement, context: RuntimeExpressionContext, workflowId?: string): CriterionEvaluationRecord[]
|
|
2469
|
+
evaluateCriteria(step: StepElement, context: RuntimeExpressionContext, workflowId?: string): Promise<CriterionEvaluationRecord[]>;
|
|
2427
2470
|
/**
|
|
2428
2471
|
* Selects every matching `onSuccess` / `onFailure` action for the outcome, in
|
|
2429
2472
|
* list order, gating each action's criteria against the context, and records
|
|
@@ -2447,7 +2490,7 @@ export declare class StepExecutor {
|
|
|
2447
2490
|
* `workflowId` names the step's workflow on a thrown error, as for
|
|
2448
2491
|
* {@link StepExecutor.execute}.
|
|
2449
2492
|
*/
|
|
2450
|
-
selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'
|
|
2493
|
+
selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Promise<Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>>;
|
|
2451
2494
|
/**
|
|
2452
2495
|
* The context a step's actions are taken in — see
|
|
2453
2496
|
* {@link StepExecutionResult.actionContext}: `context` with
|
|
@@ -2475,7 +2518,9 @@ export declare interface StepExecutorOptions {
|
|
|
2475
2518
|
*/
|
|
2476
2519
|
readonly document: ArazzoDocument;
|
|
2477
2520
|
/**
|
|
2478
|
-
* The document registry
|
|
2521
|
+
* The document registry the source documents are acquired from — returned
|
|
2522
|
+
* from its cache, or loaded when an operation, a workflow or a
|
|
2523
|
+
* `$sourceDescriptions` expression first needs them.
|
|
2479
2524
|
*/
|
|
2480
2525
|
readonly registry: DocumentRegistry;
|
|
2481
2526
|
/**
|
|
@@ -2514,7 +2559,7 @@ export declare abstract class StepParameterResolver extends ArazzoValueResolver
|
|
|
2514
2559
|
* has it, the same way {@link ActionResolver.resolveOnSuccess} is handed
|
|
2515
2560
|
* `scope`.
|
|
2516
2561
|
*/
|
|
2517
|
-
abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown
|
|
2562
|
+
abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
2518
2563
|
}
|
|
2519
2564
|
|
|
2520
2565
|
/**
|
|
@@ -2908,7 +2953,9 @@ export declare interface WorkflowExecutorOptions {
|
|
|
2908
2953
|
*/
|
|
2909
2954
|
readonly document: ArazzoDocument;
|
|
2910
2955
|
/**
|
|
2911
|
-
* The document registry
|
|
2956
|
+
* The document registry the source documents are acquired from — returned
|
|
2957
|
+
* from its cache, or loaded when an operation, a workflow or a
|
|
2958
|
+
* `$sourceDescriptions` expression first needs them.
|
|
2912
2959
|
*/
|
|
2913
2960
|
readonly registry: DocumentRegistry;
|
|
2914
2961
|
/**
|
|
@@ -2996,7 +3043,7 @@ export declare class WorkflowParameterResolver extends StepParameterResolver {
|
|
|
2996
3043
|
*
|
|
2997
3044
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
2998
3045
|
*/
|
|
2999
|
-
resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown
|
|
3046
|
+
resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
|
|
3000
3047
|
}
|
|
3001
3048
|
|
|
3002
3049
|
/**
|