@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
|
@@ -9003,12 +9003,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
9003
9003
|
|
|
9004
9004
|
|
|
9005
9005
|
/**
|
|
9006
|
-
* Determines whether a single criterion of an action is met
|
|
9007
|
-
* action declaring the criterion, so a caller can
|
|
9006
|
+
* Determines whether a single criterion of an action is met, or resolves to
|
|
9007
|
+
* whether it is. Receives the action declaring the criterion, so a caller can
|
|
9008
|
+
* attribute the outcome to it.
|
|
9008
9009
|
*
|
|
9009
9010
|
* Bridged to a criterion evaluator
|
|
9010
|
-
* (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`);
|
|
9011
|
-
* unresolvable/failing criterion is `false`, not an error.
|
|
9011
|
+
* (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
|
|
9012
|
+
* an unresolvable/failing criterion is `false`, not an error.
|
|
9012
9013
|
* @public
|
|
9013
9014
|
*/
|
|
9014
9015
|
|
|
@@ -9063,12 +9064,12 @@ class ActionResolver {
|
|
|
9063
9064
|
* `end` its author was reaching for would otherwise never happen without a
|
|
9064
9065
|
* word said about why.
|
|
9065
9066
|
*/
|
|
9066
|
-
resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
9067
|
+
async resolveOnSuccess(actions, isCriterionMet, scope) {
|
|
9067
9068
|
// safe: `#resolveAll` validates every entry as *a* Success/Failure Action
|
|
9068
9069
|
// Object, not one matching this list's own field, but a well-formed
|
|
9069
9070
|
// `StepOnSuccessElement` only ever refracts Success Action entries — the
|
|
9070
9071
|
// apidom refractor types list entries positionally at parse time.
|
|
9071
|
-
return this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
9072
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
|
|
9072
9073
|
}
|
|
9073
9074
|
|
|
9074
9075
|
/**
|
|
@@ -9077,9 +9078,9 @@ class ActionResolver {
|
|
|
9077
9078
|
* Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
|
|
9078
9079
|
* see there for the full rationale — mirrored for the step's other list.
|
|
9079
9080
|
*/
|
|
9080
|
-
resolveOnFailure(actions, isCriterionMet, scope) {
|
|
9081
|
+
async resolveOnFailure(actions, isCriterionMet, scope) {
|
|
9081
9082
|
// safe: see the same-named comment in `resolveOnSuccess` above.
|
|
9082
|
-
return this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
9083
|
+
return await this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
|
|
9083
9084
|
}
|
|
9084
9085
|
|
|
9085
9086
|
/**
|
|
@@ -9092,7 +9093,7 @@ class ActionResolver {
|
|
|
9092
9093
|
* element's own type no longer distinguishes them. Baked in by the public
|
|
9093
9094
|
* method rather than taken from the caller.
|
|
9094
9095
|
*/
|
|
9095
|
-
#resolveAll(actions, isCriterionMet, field, scope) {
|
|
9096
|
+
async #resolveAll(actions, isCriterionMet, field, scope) {
|
|
9096
9097
|
if (actions === undefined) return [];
|
|
9097
9098
|
// present but scalar: walking it would fail as a bare
|
|
9098
9099
|
// `TypeError: actions is not iterable`.
|
|
@@ -9112,7 +9113,7 @@ class ActionResolver {
|
|
|
9112
9113
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_2__["default"].MalformedActionEntry
|
|
9113
9114
|
});
|
|
9114
9115
|
}
|
|
9115
|
-
if (this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
9116
|
+
if (await this.#criteriaMet(action, isCriterionMet, scope)) {
|
|
9116
9117
|
matched.push(action);
|
|
9117
9118
|
}
|
|
9118
9119
|
}
|
|
@@ -9129,7 +9130,7 @@ class ActionResolver {
|
|
|
9129
9130
|
* not say what its author meant, the same as an unrecognized entry in the
|
|
9130
9131
|
* action list itself.
|
|
9131
9132
|
*/
|
|
9132
|
-
#criteriaMet(action, isCriterionMet, scope) {
|
|
9133
|
+
async #criteriaMet(action, isCriterionMet, scope) {
|
|
9133
9134
|
const criteria = action.criteria;
|
|
9134
9135
|
if (criteria === undefined) return true;
|
|
9135
9136
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isArrayElement)(criteria)) {
|
|
@@ -9150,7 +9151,7 @@ class ActionResolver {
|
|
|
9150
9151
|
}
|
|
9151
9152
|
// every criterion is evaluated, not only up to the first unmet one, so
|
|
9152
9153
|
// a predicate that records outcomes sees the whole list.
|
|
9153
|
-
if (!isCriterionMet(criterion, action)) met = false;
|
|
9154
|
+
if (!(await isCriterionMet(criterion, action))) met = false;
|
|
9154
9155
|
}
|
|
9155
9156
|
return met;
|
|
9156
9157
|
}
|
|
@@ -10010,14 +10011,19 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10010
10011
|
|
|
10011
10012
|
|
|
10012
10013
|
/**
|
|
10013
|
-
* Resolves a runtime expression to a value
|
|
10014
|
+
* Resolves a runtime expression to a value, or to a Promise of it, during
|
|
10015
|
+
* criterion evaluation. The result is awaited, so a synchronous resolver works
|
|
10016
|
+
* too.
|
|
10014
10017
|
*
|
|
10015
10018
|
* Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
|
|
10016
10019
|
* expressions embedded in a `simple` condition. It should resolve leniently —
|
|
10017
10020
|
* an unresolvable reference returning `undefined` fails the criterion rather
|
|
10018
10021
|
* than throwing (a common way to drive it is
|
|
10019
10022
|
* `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
|
|
10020
|
-
* lenient evaluator).
|
|
10023
|
+
* lenient evaluator). An error it throws or rejects with — such as the load
|
|
10024
|
+
* error of a `$sourceDescriptions` document that cannot be loaded — is not a
|
|
10025
|
+
* {@link CriterionEvaluationError}, so it propagates instead of failing the
|
|
10026
|
+
* criterion.
|
|
10021
10027
|
* @public
|
|
10022
10028
|
*/
|
|
10023
10029
|
|
|
@@ -10093,7 +10099,7 @@ class CriterionEvaluator {
|
|
|
10093
10099
|
* the expressions embedded in the condition; for the other types it resolves
|
|
10094
10100
|
* the criterion's `context` expression that the condition is applied to.
|
|
10095
10101
|
*/
|
|
10096
|
-
evaluate(criterion, resolve) {
|
|
10102
|
+
async evaluate(criterion, resolve) {
|
|
10097
10103
|
if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_2__.isCriterionElement)(criterion)) {
|
|
10098
10104
|
throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"]('Element is not a Criterion Object', {
|
|
10099
10105
|
reason: _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"].InvalidCriterion
|
|
@@ -10113,23 +10119,23 @@ class CriterionEvaluator {
|
|
|
10113
10119
|
try {
|
|
10114
10120
|
switch (type) {
|
|
10115
10121
|
case 'simple':
|
|
10116
|
-
met = this.#simple.evaluate(condition, resolve);
|
|
10122
|
+
met = await this.#simple.evaluate(condition, resolve);
|
|
10117
10123
|
break;
|
|
10118
10124
|
case 'regex':
|
|
10119
|
-
met = this.#regex.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
10125
|
+
met = this.#regex.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
10120
10126
|
break;
|
|
10121
10127
|
case 'jsonpath':
|
|
10122
10128
|
// only rfc9535 is supported, Arazzo 1.1.0's default, so an omitted
|
|
10123
10129
|
// version is accepted. draft-goessner has different semantics and is
|
|
10124
10130
|
// rejected rather than mis-evaluated.
|
|
10125
10131
|
this.#requireVersion(criterion, type, condition, 'rfc9535');
|
|
10126
|
-
met = this.#jsonpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
10132
|
+
met = this.#jsonpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
10127
10133
|
break;
|
|
10128
10134
|
case 'xpath':
|
|
10129
10135
|
// only XPath 3.1 is supported; xpath-31 is Arazzo 1.1.0's default, so
|
|
10130
10136
|
// an omitted version is accepted. Older versions are rejected.
|
|
10131
10137
|
this.#requireVersion(criterion, type, condition, 'xpath-31');
|
|
10132
|
-
met = this.#xpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
|
|
10138
|
+
met = this.#xpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
|
|
10133
10139
|
break;
|
|
10134
10140
|
default:
|
|
10135
10141
|
throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Unknown criterion type "${type}"`, {
|
|
@@ -10230,7 +10236,7 @@ class CriterionEvaluator {
|
|
|
10230
10236
|
* `jsonpath`, `xpath`) must declare one; a criterion of such a type without a
|
|
10231
10237
|
* `context` throws a {@link CriterionError}.
|
|
10232
10238
|
*/
|
|
10233
|
-
#resolveContext(criterion, type, resolve) {
|
|
10239
|
+
async #resolveContext(criterion, type, resolve) {
|
|
10234
10240
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isStringElement)(criterion.context)) {
|
|
10235
10241
|
throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Criterion type "${type}" requires a "context"`, {
|
|
10236
10242
|
type,
|
|
@@ -10399,7 +10405,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10399
10405
|
* unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
|
|
10400
10406
|
* loose/case-insensitive comparison, and member/index navigation are delegated
|
|
10401
10407
|
* to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
|
|
10402
|
-
* resolved through the supplied resolver.
|
|
10408
|
+
* resolved through the supplied resolver and awaited in turn. `&&` and `||`
|
|
10409
|
+
* short-circuit, so an operand that cannot change the outcome is never
|
|
10410
|
+
* resolved.
|
|
10403
10411
|
*
|
|
10404
10412
|
* An operand that resolves to `undefined` (a lenient miss) does not throw; it is
|
|
10405
10413
|
* compared per the library's rules (e.g. `undefined == x` and relational
|
|
@@ -10413,9 +10421,9 @@ class SimpleCriterionEvaluator {
|
|
|
10413
10421
|
* Evaluates the simple `condition`, resolving each embedded runtime
|
|
10414
10422
|
* expression via `resolve`.
|
|
10415
10423
|
*/
|
|
10416
|
-
evaluate(condition, resolve) {
|
|
10424
|
+
async evaluate(condition, resolve) {
|
|
10417
10425
|
try {
|
|
10418
|
-
return (0,_swaggerexpert_arazzo_criterion__WEBPACK_IMPORTED_MODULE_0__.
|
|
10426
|
+
return await (0,_swaggerexpert_arazzo_criterion__WEBPACK_IMPORTED_MODULE_0__.evaluateAsync)(condition, {
|
|
10419
10427
|
resolve
|
|
10420
10428
|
});
|
|
10421
10429
|
} catch (error) {
|
|
@@ -12301,12 +12309,19 @@ class OpenAPIOperationExecutor {
|
|
|
12301
12309
|
finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
|
|
12302
12310
|
finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
|
|
12303
12311
|
|
|
12304
|
-
// for multipart/form-data, remove the
|
|
12305
|
-
//
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12312
|
+
// for multipart/form-data, remove the content-type so the transport sets
|
|
12313
|
+
// one carrying the boundary of the FormData it encodes. one that names a
|
|
12314
|
+
// boundary is kept when the body is not a FormData: whoever built that
|
|
12315
|
+
// body chose the boundary
|
|
12316
|
+
const encodedByTransport = finalized.body instanceof FormData;
|
|
12317
|
+
for (const name of Object.keys(finalized.headers)) {
|
|
12318
|
+
const contentType = finalized.headers[name];
|
|
12319
|
+
if (name.toLowerCase() !== 'content-type' || typeof contentType !== 'string') continue;
|
|
12320
|
+
if (!/multipart\/form-data/i.test(contentType)) continue;
|
|
12321
|
+
const boundary = (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_6__.parse)(contentType, {
|
|
12322
|
+
type: 'media-type'
|
|
12323
|
+
}).tree?.parameters.boundary;
|
|
12324
|
+
if (encodedByTransport || !boundary?.trim()) delete finalized.headers[name];
|
|
12310
12325
|
}
|
|
12311
12326
|
return finalized;
|
|
12312
12327
|
}
|
|
@@ -12441,7 +12456,7 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12441
12456
|
document,
|
|
12442
12457
|
registry: this.registry
|
|
12443
12458
|
});
|
|
12444
|
-
const uriReference = evaluator.interpolate(operationPath);
|
|
12459
|
+
const uriReference = await evaluator.interpolate(operationPath);
|
|
12445
12460
|
const documentURI = _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.sanitize(_speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.stripHash(uriReference));
|
|
12446
12461
|
if (documentURI === '') {
|
|
12447
12462
|
throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`operationPath "${operationPath}" does not resolve to a source description URL`, {
|
|
@@ -12843,8 +12858,8 @@ class StepExecutor {
|
|
|
12843
12858
|
// keyed by '{in}.{name}' rather than bare name, so two parameters that
|
|
12844
12859
|
// legally differ only in their location each reach their own place.
|
|
12845
12860
|
const preContext = state.toContext();
|
|
12846
|
-
const parameters = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
12847
|
-
const requestBody = this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
12861
|
+
const parameters = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
12862
|
+
const requestBody = await this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
|
|
12848
12863
|
|
|
12849
12864
|
// checked here rather than on entry: locating the operation and resolving
|
|
12850
12865
|
// the expressions above are awaited, so a run cancelled during them would
|
|
@@ -12880,13 +12895,13 @@ class StepExecutor {
|
|
|
12880
12895
|
// evaluate criteria, outputs, and the next action against the post-request
|
|
12881
12896
|
// context (with $request / $url / $method and $response / $statusCode).
|
|
12882
12897
|
const postContext = state.toContext(this.#requestContext(response), this.#responseContext(response));
|
|
12883
|
-
const successCriteria = this.evaluateCriteria(step, postContext, workflowId);
|
|
12898
|
+
const successCriteria = await this.evaluateCriteria(step, postContext, workflowId);
|
|
12884
12899
|
const successful = successCriteria.every(criterion => criterion.met);
|
|
12885
|
-
const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
12900
|
+
const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
|
|
12886
12901
|
const {
|
|
12887
12902
|
matchedActions,
|
|
12888
12903
|
actionCriteria
|
|
12889
|
-
} = this.selectActions(step, successful, postContext, workflowId);
|
|
12904
|
+
} = await this.selectActions(step, successful, postContext, workflowId);
|
|
12890
12905
|
return {
|
|
12891
12906
|
stepId,
|
|
12892
12907
|
response,
|
|
@@ -12983,13 +12998,18 @@ class StepExecutor {
|
|
|
12983
12998
|
* names the step's workflow on a thrown error, as for
|
|
12984
12999
|
* {@link StepExecutor.execute}.
|
|
12985
13000
|
*/
|
|
12986
|
-
evaluateCriteria(step, context, workflowId) {
|
|
13001
|
+
async evaluateCriteria(step, context, workflowId) {
|
|
12987
13002
|
this.assertSuccessCriteria(step, workflowId);
|
|
12988
13003
|
const criteria = step.successCriteria;
|
|
12989
13004
|
if (criteria === undefined) return [];
|
|
12990
13005
|
|
|
12991
|
-
// assertSuccessCriteria above guarantees every entry is a Criterion Object
|
|
12992
|
-
|
|
13006
|
+
// assertSuccessCriteria above guarantees every entry is a Criterion Object.
|
|
13007
|
+
// evaluated one after another, in list order, like the actions' criteria.
|
|
13008
|
+
const records = [];
|
|
13009
|
+
for (const criterion of [...criteria]) {
|
|
13010
|
+
records.push(await this.#evaluateCriterion(criterion, context));
|
|
13011
|
+
}
|
|
13012
|
+
return records;
|
|
12993
13013
|
}
|
|
12994
13014
|
|
|
12995
13015
|
/**
|
|
@@ -13015,11 +13035,11 @@ class StepExecutor {
|
|
|
13015
13035
|
* `workflowId` names the step's workflow on a thrown error, as for
|
|
13016
13036
|
* {@link StepExecutor.execute}.
|
|
13017
13037
|
*/
|
|
13018
|
-
selectActions(step, successful, context, workflowId) {
|
|
13038
|
+
async selectActions(step, successful, context, workflowId) {
|
|
13019
13039
|
const actionCriteria = [];
|
|
13020
|
-
const isCriterionMet = (criterion, action) => {
|
|
13040
|
+
const isCriterionMet = async (criterion, action) => {
|
|
13021
13041
|
const record = {
|
|
13022
|
-
...this.#evaluateCriterion(criterion, context),
|
|
13042
|
+
...(await this.#evaluateCriterion(criterion, context)),
|
|
13023
13043
|
actionName: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.name)
|
|
13024
13044
|
};
|
|
13025
13045
|
actionCriteria.push(record);
|
|
@@ -13031,7 +13051,7 @@ class StepExecutor {
|
|
|
13031
13051
|
}),
|
|
13032
13052
|
stepId: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.stepId)
|
|
13033
13053
|
};
|
|
13034
|
-
const matchedActions = successful ? this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
13054
|
+
const matchedActions = successful ? await this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : await this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
|
|
13035
13055
|
return {
|
|
13036
13056
|
matchedActions,
|
|
13037
13057
|
actionCriteria
|
|
@@ -13065,13 +13085,13 @@ class StepExecutor {
|
|
|
13065
13085
|
* condition that cannot be evaluated is unmet and records why; any other
|
|
13066
13086
|
* error propagates.
|
|
13067
13087
|
*/
|
|
13068
|
-
#evaluateCriterion(criterion, context) {
|
|
13088
|
+
async #evaluateCriterion(criterion, context) {
|
|
13069
13089
|
const condition = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(criterion.condition);
|
|
13070
13090
|
try {
|
|
13071
13091
|
const {
|
|
13072
13092
|
met,
|
|
13073
13093
|
error
|
|
13074
|
-
} = this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
13094
|
+
} = await this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
13075
13095
|
if (error === undefined) return {
|
|
13076
13096
|
condition,
|
|
13077
13097
|
met
|
|
@@ -14151,7 +14171,7 @@ class WorkflowExecutor {
|
|
|
14151
14171
|
stepId,
|
|
14152
14172
|
callStack: nested
|
|
14153
14173
|
});
|
|
14154
|
-
const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto', this.#actionInputs(action?.parameters, outcome, invocation, stepId));
|
|
14174
|
+
const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto', await this.#actionInputs(action?.parameters, outcome, invocation, stepId));
|
|
14155
14175
|
runOutcome = {
|
|
14156
14176
|
kind: 'transferred',
|
|
14157
14177
|
transferredTo
|
|
@@ -14215,7 +14235,7 @@ class WorkflowExecutor {
|
|
|
14215
14235
|
* {@link WorkflowExecutor.#validateWorkflowOutputsShape} already checked
|
|
14216
14236
|
* the shape up front, independent of resolving it.
|
|
14217
14237
|
*/
|
|
14218
|
-
#result(invocation, workflow, steps, outcome, dependencies, startedAt) {
|
|
14238
|
+
async #result(invocation, workflow, steps, outcome, dependencies, startedAt) {
|
|
14219
14239
|
const shared = {
|
|
14220
14240
|
workflowId: invocation.workflowId,
|
|
14221
14241
|
steps,
|
|
@@ -14239,7 +14259,7 @@ class WorkflowExecutor {
|
|
|
14239
14259
|
}
|
|
14240
14260
|
return {
|
|
14241
14261
|
...shared,
|
|
14242
|
-
outputs: this.#resolveWorkflowOutputs(workflow, invocation),
|
|
14262
|
+
outputs: await this.#resolveWorkflowOutputs(workflow, invocation),
|
|
14243
14263
|
status: outcome.status,
|
|
14244
14264
|
settledStatus: outcome.status
|
|
14245
14265
|
};
|
|
@@ -14380,7 +14400,7 @@ class WorkflowExecutor {
|
|
|
14380
14400
|
const reference = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.workflowId);
|
|
14381
14401
|
// resolved before the budget is charged, so an authoring error in them
|
|
14382
14402
|
// costs no budget unit.
|
|
14383
|
-
const inputs = this.#actionInputs(action.parameters, outcome, invocation, stepId);
|
|
14403
|
+
const inputs = await this.#actionInputs(action.parameters, outcome, invocation, stepId);
|
|
14384
14404
|
this.#chargeBudget(scope, invocation, stepId);
|
|
14385
14405
|
const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry', inputs);
|
|
14386
14406
|
// the result's workflowId is the bare id the reference resolved to —
|
|
@@ -14612,7 +14632,7 @@ class WorkflowExecutor {
|
|
|
14612
14632
|
// sees the same (usually absent) value on every attempt, not the
|
|
14613
14633
|
// previous attempt's own result.
|
|
14614
14634
|
const preContext = this.#inputContext(state, subWorkflowId, priorWorkflowEntry);
|
|
14615
|
-
const inputs = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression, document), stepScope);
|
|
14635
|
+
const inputs = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression, document), stepScope);
|
|
14616
14636
|
const result = await this.#run(locator, inputs, scope, callStack, 'step');
|
|
14617
14637
|
subWorkflows.push(result);
|
|
14618
14638
|
state.setWorkflow(subWorkflowId, {
|
|
@@ -14635,7 +14655,7 @@ class WorkflowExecutor {
|
|
|
14635
14655
|
workflowId: subWorkflowId
|
|
14636
14656
|
}
|
|
14637
14657
|
};
|
|
14638
|
-
const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(context, expression, document), stepScope);
|
|
14658
|
+
const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(context, expression, document), stepScope);
|
|
14639
14659
|
// an `end`ed sub-workflow returned to its caller with outputs, so it took
|
|
14640
14660
|
// the success path like a completed one; only a chain settling `failed` is
|
|
14641
14661
|
// a failure — a sub-workflow that transferred is judged by where its
|
|
@@ -14650,12 +14670,12 @@ class WorkflowExecutor {
|
|
|
14650
14670
|
// evaluated by the parent document's step executor — only the sub-run
|
|
14651
14671
|
// itself switched documents.
|
|
14652
14672
|
const stepExecutor = this.#stepExecutor.forDocument(document);
|
|
14653
|
-
const successCriteria = stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
14673
|
+
const successCriteria = await stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
14654
14674
|
const successful = !this.#settledFailed(result) && successCriteria.every(criterion => criterion.met);
|
|
14655
14675
|
const {
|
|
14656
14676
|
matchedActions,
|
|
14657
14677
|
actionCriteria
|
|
14658
|
-
} = stepExecutor.selectActions(step, successful, context, workflowId);
|
|
14678
|
+
} = await stepExecutor.selectActions(step, successful, context, workflowId);
|
|
14659
14679
|
return {
|
|
14660
14680
|
stepId,
|
|
14661
14681
|
successful,
|
|
@@ -15020,8 +15040,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15020
15040
|
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27554);
|
|
15021
15041
|
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7456);
|
|
15022
15042
|
/* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(48770);
|
|
15023
|
-
/* harmony import */ var
|
|
15024
|
-
/* harmony import */ var
|
|
15043
|
+
/* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(24089);
|
|
15044
|
+
/* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(46132);
|
|
15045
|
+
/* harmony import */ var _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(20250);
|
|
15046
|
+
/* harmony import */ var _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(35043);
|
|
15047
|
+
|
|
15048
|
+
|
|
15025
15049
|
|
|
15026
15050
|
|
|
15027
15051
|
|
|
@@ -15073,6 +15097,9 @@ const HTTP_EXCHANGE_NODES = new Set(['UrlExpression', 'MethodExpression', 'Statu
|
|
|
15073
15097
|
* (via the registry) the source name points at. A step reference resolves to
|
|
15074
15098
|
* the Step Object as authored — a locator, not the step's execution result.
|
|
15075
15099
|
*
|
|
15100
|
+
* Evaluation is asynchronous because a `$sourceDescriptions` reference may
|
|
15101
|
+
* have to load the document it points at.
|
|
15102
|
+
*
|
|
15076
15103
|
* A reference resolves to `undefined` when it is absent. Runtime values
|
|
15077
15104
|
* originate from JSON (or ApiDOM), which cannot represent `undefined` — an
|
|
15078
15105
|
* absent value is a missing property and an explicit null is `null` — so
|
|
@@ -15106,11 +15133,19 @@ class RuntimeExpressionEvaluator {
|
|
|
15106
15133
|
* The expression must be the bare form without surrounding braces
|
|
15107
15134
|
* (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
|
|
15108
15135
|
* unresolvable reference throws; otherwise it returns `undefined`.
|
|
15136
|
+
*
|
|
15137
|
+
* A `$sourceDescriptions` reference whose document cannot be loaded is not
|
|
15138
|
+
* merely unresolved: unless it names a field of the Source Description Object,
|
|
15139
|
+
* it rejects with the load error in either mode, since nothing else can
|
|
15140
|
+
* produce its value.
|
|
15141
|
+
*
|
|
15142
|
+
* @throws DocumentLoadError - When a referenced source document cannot be read or loaded
|
|
15143
|
+
* @throws UnmatchedProviderError - When no provider can load a referenced source document
|
|
15109
15144
|
*/
|
|
15110
|
-
evaluate(expression) {
|
|
15145
|
+
async evaluate(expression) {
|
|
15111
15146
|
const node = this.#parse(expression);
|
|
15112
15147
|
this.#assertAvailable(node, expression);
|
|
15113
|
-
const value = this.#evaluateNode(node, expression);
|
|
15148
|
+
const value = await this.#evaluateNode(node, expression);
|
|
15114
15149
|
if (value === undefined && this.#strict) {
|
|
15115
15150
|
throw new _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`Runtime expression "${expression}" could not be resolved against the context`, {
|
|
15116
15151
|
expression,
|
|
@@ -15128,8 +15163,20 @@ class RuntimeExpressionEvaluator {
|
|
|
15128
15163
|
* mode, unresolvable references render as an empty string. A `{…}` that is not
|
|
15129
15164
|
* a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
|
|
15130
15165
|
*/
|
|
15131
|
-
interpolate(template) {
|
|
15132
|
-
|
|
15166
|
+
async interpolate(template) {
|
|
15167
|
+
// `interpolate` takes a synchronous resolver, so the embedded expressions are
|
|
15168
|
+
// collected by a first pass, evaluated in order, and substituted by a second.
|
|
15169
|
+
// Interpolation never skips an expression, so the result is the same.
|
|
15170
|
+
const expressions = [];
|
|
15171
|
+
(0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.interpolate)(template, expression => {
|
|
15172
|
+
expressions.push(expression);
|
|
15173
|
+
return '';
|
|
15174
|
+
});
|
|
15175
|
+
const values = new Map();
|
|
15176
|
+
for (const expression of expressions) {
|
|
15177
|
+
if (!values.has(expression)) values.set(expression, await this.evaluate(expression));
|
|
15178
|
+
}
|
|
15179
|
+
return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.interpolate)(template, expression => values.get(expression));
|
|
15133
15180
|
}
|
|
15134
15181
|
|
|
15135
15182
|
/**
|
|
@@ -15143,7 +15190,7 @@ class RuntimeExpressionEvaluator {
|
|
|
15143
15190
|
* yields the string representation of its value, not the typed value. A
|
|
15144
15191
|
* string containing no expressions is returned unchanged.
|
|
15145
15192
|
*/
|
|
15146
|
-
resolve(value) {
|
|
15193
|
+
async resolve(value) {
|
|
15147
15194
|
// `test` returns true only when the entire string is a valid runtime
|
|
15148
15195
|
// expression, so a braced or mixed string falls through to interpolation.
|
|
15149
15196
|
return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? this.evaluate(value) : this.interpolate(value);
|
|
@@ -15263,7 +15310,7 @@ class RuntimeExpressionEvaluator {
|
|
|
15263
15310
|
* the workflow or step is unknown.
|
|
15264
15311
|
*/
|
|
15265
15312
|
#step(document, workflowId, stepId) {
|
|
15266
|
-
if (document === undefined || !
|
|
15313
|
+
if (document === undefined || !_document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__["default"].is(document)) return undefined;
|
|
15267
15314
|
const pointer = document.stepIndex.getStep(workflowId, stepId);
|
|
15268
15315
|
return pointer === undefined ? undefined : this.#drillDocument(document, pointer);
|
|
15269
15316
|
}
|
|
@@ -15281,27 +15328,45 @@ class RuntimeExpressionEvaluator {
|
|
|
15281
15328
|
* `$sourceDescriptions.{name}.url` yields the source's URL. An operationId
|
|
15282
15329
|
* that collides with a field name takes precedence (tier 1 wins).
|
|
15283
15330
|
*
|
|
15331
|
+
* The referenced document is acquired only when the registry can load the
|
|
15332
|
+
* source's `type`; a source no provider loads (e.g. AsyncAPI) resolves by
|
|
15333
|
+
* tier 2 alone. When acquiring fails, a `{reference}` naming a field present
|
|
15334
|
+
* on the Source Description Object still resolves to that field — it does
|
|
15335
|
+
* not depend on the document — and any other reference rethrows the load
|
|
15336
|
+
* error, since nothing else can produce its value.
|
|
15337
|
+
*
|
|
15284
15338
|
* Returns `undefined` when nothing matches.
|
|
15285
15339
|
*/
|
|
15286
|
-
#sourceDescription({
|
|
15340
|
+
async #sourceDescription({
|
|
15287
15341
|
sourceName,
|
|
15288
15342
|
reference,
|
|
15289
15343
|
stepsReference
|
|
15290
15344
|
}) {
|
|
15291
|
-
const
|
|
15345
|
+
const document = this.#document;
|
|
15346
|
+
const uri = document?.resolveSourceDescriptionURI(sourceName);
|
|
15347
|
+
const type = document?.resolveSourceDescriptionField(sourceName, 'type');
|
|
15348
|
+
const field = document?.resolveSourceDescriptionField(sourceName, reference);
|
|
15292
15349
|
|
|
15293
15350
|
// tier 1: operationId / workflowId / workflow step in the referenced document.
|
|
15294
|
-
|
|
15351
|
+
let apiDocument;
|
|
15352
|
+
if (uri !== undefined && this.#registry !== undefined && this.#registry.canLoad(typeof type === 'string' ? type : undefined)) {
|
|
15353
|
+
try {
|
|
15354
|
+
apiDocument = await this.#registry.acquire(uri);
|
|
15355
|
+
} catch (error) {
|
|
15356
|
+
const unloadable = error instanceof _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_7__["default"] || error instanceof _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_8__["default"];
|
|
15357
|
+
if (!unloadable || field === undefined) throw error;
|
|
15358
|
+
}
|
|
15359
|
+
}
|
|
15295
15360
|
if (apiDocument !== undefined) {
|
|
15296
15361
|
if (stepsReference !== undefined) {
|
|
15297
15362
|
return this.#step(apiDocument, stepsReference.workflowId, stepsReference.stepId);
|
|
15298
15363
|
}
|
|
15299
|
-
const pointer =
|
|
15364
|
+
const pointer = _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_10__["default"].is(apiDocument) ? apiDocument.operationIndex.get(reference) : _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__["default"].is(apiDocument) ? apiDocument.workflowIndex.get(reference) : undefined;
|
|
15300
15365
|
if (pointer !== undefined) return this.#drillDocument(apiDocument, pointer);
|
|
15301
15366
|
}
|
|
15302
15367
|
|
|
15303
15368
|
// tier 2: a field of the Source Description Object (url, type, ...).
|
|
15304
|
-
return
|
|
15369
|
+
return field;
|
|
15305
15370
|
}
|
|
15306
15371
|
|
|
15307
15372
|
/**
|
|
@@ -16414,6 +16479,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16414
16479
|
*/
|
|
16415
16480
|
class DocumentRegistry {
|
|
16416
16481
|
#documents = new Map();
|
|
16482
|
+
#loading = new Map();
|
|
16417
16483
|
#providers;
|
|
16418
16484
|
constructor(options = {}) {
|
|
16419
16485
|
this.#providers = options.providers ?? [new _providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](), new _providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]()];
|
|
@@ -16436,6 +16502,10 @@ class DocumentRegistry {
|
|
|
16436
16502
|
* otherwise detects the format, loads via the matching provider,
|
|
16437
16503
|
* caches, and returns it.
|
|
16438
16504
|
*
|
|
16505
|
+
* Concurrent calls for a document that is still loading share that one
|
|
16506
|
+
* load instead of each fetching and parsing it. A failed load is not
|
|
16507
|
+
* remembered: the next call tries again.
|
|
16508
|
+
*
|
|
16439
16509
|
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
16440
16510
|
* @throws UnmatchedProviderError - When no provider can load the document
|
|
16441
16511
|
*/
|
|
@@ -16443,6 +16513,21 @@ class DocumentRegistry {
|
|
|
16443
16513
|
const canonicalURI = this.#canonicalize(uri);
|
|
16444
16514
|
const cachedDocument = this.#get(canonicalURI);
|
|
16445
16515
|
if (cachedDocument) return cachedDocument;
|
|
16516
|
+
const loading = this.#loading.get(canonicalURI);
|
|
16517
|
+
if (loading) return loading;
|
|
16518
|
+
const load = this.#load(canonicalURI).finally(() => {
|
|
16519
|
+
// only its own entry: after clear(), a newer load may hold the key
|
|
16520
|
+
if (this.#loading.get(canonicalURI) === load) this.#loading.delete(canonicalURI);
|
|
16521
|
+
});
|
|
16522
|
+
this.#loading.set(canonicalURI, load);
|
|
16523
|
+
return load;
|
|
16524
|
+
}
|
|
16525
|
+
|
|
16526
|
+
/**
|
|
16527
|
+
* Loads a document through the first provider that can provide it, and
|
|
16528
|
+
* caches it.
|
|
16529
|
+
*/
|
|
16530
|
+
async #load(canonicalURI) {
|
|
16446
16531
|
for (const provider of this.#providers) {
|
|
16447
16532
|
try {
|
|
16448
16533
|
if (await provider.canProvide(canonicalURI)) {
|
|
@@ -16466,16 +16551,17 @@ class DocumentRegistry {
|
|
|
16466
16551
|
}
|
|
16467
16552
|
|
|
16468
16553
|
/**
|
|
16469
|
-
*
|
|
16554
|
+
* Whether a source description of `type` can be loaded at all: some provider
|
|
16555
|
+
* loads that type, or does not say which type it loads. A source with no
|
|
16556
|
+
* `type` may be of any type, so it can.
|
|
16470
16557
|
*
|
|
16471
|
-
*
|
|
16472
|
-
*
|
|
16473
|
-
*
|
|
16474
|
-
* (e.g. runtime expression evaluation) use this; the executor is responsible
|
|
16475
|
-
* for having acquired the document beforehand.
|
|
16558
|
+
* Answered from the providers alone, without fetching anything — so a
|
|
16559
|
+
* caller can skip a load that could only fail, such as an AsyncAPI source
|
|
16560
|
+
* while no provider loads AsyncAPI.
|
|
16476
16561
|
*/
|
|
16477
|
-
|
|
16478
|
-
|
|
16562
|
+
canLoad(type) {
|
|
16563
|
+
if (type === undefined) return true;
|
|
16564
|
+
return this.#providers.some(provider => provider.sourceDescriptionType === undefined || provider.sourceDescriptionType === type);
|
|
16479
16565
|
}
|
|
16480
16566
|
|
|
16481
16567
|
/**
|
|
@@ -16511,8 +16597,14 @@ class DocumentRegistry {
|
|
|
16511
16597
|
document.isEntry = true;
|
|
16512
16598
|
return document;
|
|
16513
16599
|
}
|
|
16600
|
+
|
|
16601
|
+
/**
|
|
16602
|
+
* Drops every cached document. A load still in progress is no longer shared:
|
|
16603
|
+
* the next `acquire` of that document starts a fresh load.
|
|
16604
|
+
*/
|
|
16514
16605
|
clear() {
|
|
16515
16606
|
this.#documents.clear();
|
|
16607
|
+
this.#loading.clear();
|
|
16516
16608
|
}
|
|
16517
16609
|
|
|
16518
16610
|
/**
|
|
@@ -16641,6 +16733,7 @@ const providerOptionsOverride = {
|
|
|
16641
16733
|
* @public
|
|
16642
16734
|
*/
|
|
16643
16735
|
class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_12__["default"] {
|
|
16736
|
+
sourceDescriptionType = 'arazzo';
|
|
16644
16737
|
#options;
|
|
16645
16738
|
constructor(options = {}) {
|
|
16646
16739
|
super();
|
|
@@ -16776,7 +16869,25 @@ const circularReplacer = ref => new _speclynx_apidom_datamodel__WEBPACK_IMPORTED
|
|
|
16776
16869
|
* Subclasses implement `canProvide()` for format detection and `provide()` for loading.
|
|
16777
16870
|
* @public
|
|
16778
16871
|
*/
|
|
16779
|
-
class DocumentRegistryProvider {
|
|
16872
|
+
class DocumentRegistryProvider {
|
|
16873
|
+
/**
|
|
16874
|
+
* The Source Description Object `type` this provider loads (`openapi`,
|
|
16875
|
+
* `arazzo`, …), or `undefined` when it does not say — then it may load a
|
|
16876
|
+
* source of any type.
|
|
16877
|
+
*
|
|
16878
|
+
* Lets the registry tell, without fetching anything, whether a source of a
|
|
16879
|
+
* given type can be loaded at all (`DocumentRegistry.canLoad`).
|
|
16880
|
+
*/
|
|
16881
|
+
sourceDescriptionType;
|
|
16882
|
+
|
|
16883
|
+
/**
|
|
16884
|
+
* Checks if the content at the URI can be handled by this provider.
|
|
16885
|
+
*/
|
|
16886
|
+
|
|
16887
|
+
/**
|
|
16888
|
+
* Loads and produces a document from a URI.
|
|
16889
|
+
*/
|
|
16890
|
+
}
|
|
16780
16891
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DocumentRegistryProvider);
|
|
16781
16892
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
16782
16893
|
/* harmony export */ "circularReplacer", 0, /* binding */ circularReplacer,
|
|
@@ -16848,6 +16959,7 @@ const providerOptionsOverride = {
|
|
|
16848
16959
|
* @public
|
|
16849
16960
|
*/
|
|
16850
16961
|
class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_11__["default"] {
|
|
16962
|
+
sourceDescriptionType = 'openapi';
|
|
16851
16963
|
#options;
|
|
16852
16964
|
constructor(options = {}) {
|
|
16853
16965
|
super();
|
|
@@ -16941,11 +17053,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16941
17053
|
|
|
16942
17054
|
|
|
16943
17055
|
/**
|
|
16944
|
-
* Resolves a runtime expression to its value.
|
|
17056
|
+
* Resolves a runtime expression to its value, or to a Promise of it.
|
|
16945
17057
|
*
|
|
16946
17058
|
* Bridged to a lenient runtime expression evaluator
|
|
16947
17059
|
* (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
|
|
16948
|
-
* unresolvable reference yields `undefined` rather than throwing
|
|
17060
|
+
* unresolvable reference yields `undefined` rather than throwing; a
|
|
17061
|
+
* `$sourceDescriptions` document that cannot be loaded still rejects with the
|
|
17062
|
+
* load error (see `RuntimeExpressionEvaluator.evaluate`). The result
|
|
17063
|
+
* is awaited, so a synchronous resolver works too.
|
|
16949
17064
|
* @public
|
|
16950
17065
|
*/
|
|
16951
17066
|
|
|
@@ -16968,7 +17083,7 @@ class ArazzoValueResolver {
|
|
|
16968
17083
|
/**
|
|
16969
17084
|
* Resolves one authored value element by the rule above.
|
|
16970
17085
|
*/
|
|
16971
|
-
resolveValue(element, resolve) {
|
|
17086
|
+
async resolveValue(element, resolve) {
|
|
16972
17087
|
const value = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
|
|
16973
17088
|
return typeof value === 'string' && (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? resolve(value) : value;
|
|
16974
17089
|
}
|
|
@@ -17047,7 +17162,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
|
|
|
17047
17162
|
*
|
|
17048
17163
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17049
17164
|
*/
|
|
17050
|
-
resolve(parameters, resolve, scope) {
|
|
17165
|
+
async resolve(parameters, resolve, scope) {
|
|
17051
17166
|
const delivery = new _client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
17052
17167
|
if (parameters === undefined) return delivery.toRecord();
|
|
17053
17168
|
// present but scalar: walking it would fail as a bare
|
|
@@ -17111,7 +17226,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
|
|
|
17111
17226
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_4__["default"].AmbiguousDelivery
|
|
17112
17227
|
});
|
|
17113
17228
|
}
|
|
17114
|
-
delivery.set(key, this.resolveValue(parameter.value, resolve));
|
|
17229
|
+
delivery.set(key, await this.resolveValue(parameter.value, resolve));
|
|
17115
17230
|
}
|
|
17116
17231
|
return delivery.toRecord();
|
|
17117
17232
|
}
|
|
@@ -17161,7 +17276,7 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17161
17276
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
17162
17277
|
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
17163
17278
|
*/
|
|
17164
|
-
resolve(outputs, resolve, scope) {
|
|
17279
|
+
async resolve(outputs, resolve, scope) {
|
|
17165
17280
|
const result = {};
|
|
17166
17281
|
if (outputs === undefined) return result;
|
|
17167
17282
|
// present but not a map: the walk below would fail as a bare
|
|
@@ -17173,7 +17288,14 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17173
17288
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_3__["default"].MalformedOutputs
|
|
17174
17289
|
});
|
|
17175
17290
|
}
|
|
17291
|
+
|
|
17292
|
+
// collected first: `forEach` takes a synchronous callback, and each output
|
|
17293
|
+
// is awaited in turn below.
|
|
17294
|
+
const entries = [];
|
|
17176
17295
|
outputs.forEach((value, key) => {
|
|
17296
|
+
entries.push([key, value]);
|
|
17297
|
+
});
|
|
17298
|
+
for (const [key, value] of entries) {
|
|
17177
17299
|
const name = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(key);
|
|
17178
17300
|
const expression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(value);
|
|
17179
17301
|
if (typeof expression !== 'string' || !(0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_2__.test)(expression)) {
|
|
@@ -17188,12 +17310,12 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17188
17310
|
// ever created and the output is silently lost — and an object value
|
|
17189
17311
|
// additionally rewrites the record's prototype
|
|
17190
17312
|
Object.defineProperty(result, name, {
|
|
17191
|
-
value: resolve(expression),
|
|
17313
|
+
value: await resolve(expression),
|
|
17192
17314
|
enumerable: true,
|
|
17193
17315
|
writable: true,
|
|
17194
17316
|
configurable: true
|
|
17195
17317
|
});
|
|
17196
|
-
}
|
|
17318
|
+
}
|
|
17197
17319
|
return result;
|
|
17198
17320
|
}
|
|
17199
17321
|
}
|
|
@@ -17279,7 +17401,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17279
17401
|
*
|
|
17280
17402
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17281
17403
|
*/
|
|
17282
|
-
resolve(requestBody, resolve, scope) {
|
|
17404
|
+
async resolve(requestBody, resolve, scope) {
|
|
17283
17405
|
if (requestBody === undefined) return undefined;
|
|
17284
17406
|
|
|
17285
17407
|
// present but scalar: `.payload`, `.replacements` and `.contentType` are
|
|
@@ -17293,7 +17415,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17293
17415
|
});
|
|
17294
17416
|
}
|
|
17295
17417
|
const authoredPayload = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(requestBody.payload);
|
|
17296
|
-
let payload = this.#requireResolved(authoredPayload, this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
17418
|
+
let payload = this.#requireResolved(authoredPayload, await this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
17297
17419
|
if (requestBody.replacements !== undefined) {
|
|
17298
17420
|
// present but scalar: walking it would fail as a bare
|
|
17299
17421
|
// `TypeError: requestBody.replacements is not iterable`.
|
|
@@ -17308,7 +17430,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17308
17430
|
if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_6__.isPayloadReplacementElement)(replacement)) continue;
|
|
17309
17431
|
const target = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(replacement.target);
|
|
17310
17432
|
if (typeof target !== 'string') continue;
|
|
17311
|
-
const value = this.resolveValue(replacement.value, resolve);
|
|
17433
|
+
const value = await this.resolveValue(replacement.value, resolve);
|
|
17312
17434
|
if (value === undefined) continue;
|
|
17313
17435
|
payload = this.#applyReplacement(payload, target, value, scope);
|
|
17314
17436
|
}
|
|
@@ -17327,19 +17449,26 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17327
17449
|
* objects and arrays. Returns {@link UNRESOLVED} for a bare expression that
|
|
17328
17450
|
* did not resolve, for its container to handle.
|
|
17329
17451
|
*/
|
|
17330
|
-
#resolvePayloadValue(value, tokens, resolve, scope) {
|
|
17452
|
+
async #resolvePayloadValue(value, tokens, resolve, scope) {
|
|
17331
17453
|
if (typeof value === 'string') return this.#resolvePayloadString(value, tokens, resolve, scope);
|
|
17332
17454
|
if (Array.isArray(value)) {
|
|
17333
|
-
|
|
17455
|
+
const items = [];
|
|
17456
|
+
for (const [index, item] of value.entries()) {
|
|
17334
17457
|
const itemTokens = [...tokens, String(index)];
|
|
17335
|
-
const resolved = this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
17336
|
-
|
|
17337
|
-
}
|
|
17458
|
+
const resolved = await this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
17459
|
+
items.push(this.#requireResolved(item, resolved, itemTokens, scope));
|
|
17460
|
+
}
|
|
17461
|
+
return items;
|
|
17338
17462
|
}
|
|
17339
17463
|
if (value !== null && typeof value === 'object') {
|
|
17464
|
+
const members = [];
|
|
17465
|
+
for (const [key, member] of Object.entries(value)) {
|
|
17466
|
+
const resolved = await this.#resolvePayloadValue(member, [...tokens, key], resolve, scope);
|
|
17467
|
+
if (resolved !== UNRESOLVED) members.push([key, resolved]);
|
|
17468
|
+
}
|
|
17340
17469
|
// `fromEntries` defines own properties, so an authored `__proto__` key
|
|
17341
17470
|
// stays a plain member instead of replacing the prototype.
|
|
17342
|
-
return Object.fromEntries(
|
|
17471
|
+
return Object.fromEntries(members);
|
|
17343
17472
|
}
|
|
17344
17473
|
return value;
|
|
17345
17474
|
}
|
|
@@ -17349,16 +17478,12 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17349
17478
|
* typed value (or {@link UNRESOLVED}), anything else by tolerant
|
|
17350
17479
|
* interpolation of its embedded `{expression}` occurrences.
|
|
17351
17480
|
*/
|
|
17352
|
-
#resolvePayloadString(value, tokens, resolve, scope) {
|
|
17481
|
+
async #resolvePayloadString(value, tokens, resolve, scope) {
|
|
17353
17482
|
if ((0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.test)(value)) {
|
|
17354
|
-
const resolved = resolve(value);
|
|
17483
|
+
const resolved = await resolve(value);
|
|
17355
17484
|
return resolved === undefined ? UNRESOLVED : resolved;
|
|
17356
17485
|
}
|
|
17357
|
-
|
|
17358
|
-
const resolved = resolve(expression);
|
|
17359
|
-
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
17360
|
-
return resolved;
|
|
17361
|
-
}, {
|
|
17486
|
+
const options = {
|
|
17362
17487
|
strict: false,
|
|
17363
17488
|
onError: ({
|
|
17364
17489
|
text
|
|
@@ -17369,7 +17494,24 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17369
17494
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_7__["default"].InvalidExpression
|
|
17370
17495
|
});
|
|
17371
17496
|
}
|
|
17372
|
-
}
|
|
17497
|
+
};
|
|
17498
|
+
|
|
17499
|
+
// `interpolate` takes a synchronous resolver, so the embedded expressions
|
|
17500
|
+
// are collected by a first pass, resolved in order, and substituted by a
|
|
17501
|
+
// second. Interpolation never skips an expression, so the result is the same.
|
|
17502
|
+
const expressions = [];
|
|
17503
|
+
(0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.interpolate)(value, expression => {
|
|
17504
|
+
expressions.push(expression);
|
|
17505
|
+
return '';
|
|
17506
|
+
}, options);
|
|
17507
|
+
const values = new Map();
|
|
17508
|
+
for (const expression of expressions) {
|
|
17509
|
+
if (values.has(expression)) continue;
|
|
17510
|
+
const resolved = await resolve(expression);
|
|
17511
|
+
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
17512
|
+
values.set(expression, resolved);
|
|
17513
|
+
}
|
|
17514
|
+
return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.interpolate)(value, expression => values.get(expression), options);
|
|
17373
17515
|
}
|
|
17374
17516
|
|
|
17375
17517
|
/**
|
|
@@ -17515,7 +17657,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
|
|
|
17515
17657
|
*
|
|
17516
17658
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17517
17659
|
*/
|
|
17518
|
-
resolve(parameters, resolve, scope) {
|
|
17660
|
+
async resolve(parameters, resolve, scope) {
|
|
17519
17661
|
const result = {};
|
|
17520
17662
|
if (parameters === undefined) return result;
|
|
17521
17663
|
// present but scalar: walking it would fail as a bare
|
|
@@ -17541,7 +17683,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
|
|
|
17541
17683
|
// ever created and the input is silently lost — and an object value
|
|
17542
17684
|
// additionally rewrites the record's prototype
|
|
17543
17685
|
Object.defineProperty(result, name, {
|
|
17544
|
-
value: this.resolveValue(parameter.value, resolve),
|
|
17686
|
+
value: await this.resolveValue(parameter.value, resolve),
|
|
17545
17687
|
enumerable: true,
|
|
17546
17688
|
writable: true,
|
|
17547
17689
|
configurable: true
|
|
@@ -68212,6 +68354,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68212
68354
|
* receives the runtime expression string and its parsed sub-AST, and returns the
|
|
68213
68355
|
* concrete value.
|
|
68214
68356
|
*
|
|
68357
|
+
* `resolve` must return the value itself: a `resolve` returning a native Promise
|
|
68358
|
+
* (e.g. an `async` function) makes `evaluate` throw a `TypeError` rather than
|
|
68359
|
+
* compare the Promise object. Use `evaluateAsync` when values are only available
|
|
68360
|
+
* asynchronously.
|
|
68361
|
+
*
|
|
68215
68362
|
* @example
|
|
68216
68363
|
* evaluate('$statusCode == 200', {
|
|
68217
68364
|
* resolve: (expression, ast) => (expression === '$statusCode' ? 200 : undefined),
|
|
@@ -68220,11 +68367,41 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68220
68367
|
const evaluate = (condition, {
|
|
68221
68368
|
resolve
|
|
68222
68369
|
} = {}) => {
|
|
68370
|
+
const tree = prepare(condition, resolve, 'evaluate');
|
|
68371
|
+
return toBoolean(evaluateNode(tree, resolve));
|
|
68372
|
+
};
|
|
68373
|
+
|
|
68374
|
+
/**
|
|
68375
|
+
* Evaluate a "simple" Arazzo criterion condition whose runtime expression values
|
|
68376
|
+
* may only be available asynchronously.
|
|
68377
|
+
*
|
|
68378
|
+
* Same semantics as `evaluate`, except that `resolve` may return the value or a
|
|
68379
|
+
* Promise of it, which is awaited, and the result is always a Promise of a
|
|
68380
|
+
* boolean. Every failure (invalid input, an unparseable condition, a `resolve`
|
|
68381
|
+
* that throws or rejects) rejects the returned Promise. `&&` and `||` still
|
|
68382
|
+
* short-circuit: the right operand is resolved only after the left one has
|
|
68383
|
+
* settled without deciding the result.
|
|
68384
|
+
*
|
|
68385
|
+
* @example
|
|
68386
|
+
* await evaluateAsync('$statusCode == 200', {
|
|
68387
|
+
* resolve: async (expression, ast) => (expression === '$statusCode' ? 200 : undefined),
|
|
68388
|
+
* }); // => true
|
|
68389
|
+
*/
|
|
68390
|
+
const evaluateAsync = async (condition, {
|
|
68391
|
+
resolve
|
|
68392
|
+
} = {}) => {
|
|
68393
|
+
const tree = prepare(condition, resolve, 'evaluateAsync');
|
|
68394
|
+
return toBoolean(await evaluateNodeAsync(tree, resolve));
|
|
68395
|
+
};
|
|
68396
|
+
|
|
68397
|
+
// util.promisify(evaluate) returns evaluateAsync; Symbol.for keeps this free of node:util.
|
|
68398
|
+
evaluate[Symbol.for('nodejs.util.promisify.custom')] = evaluateAsync;
|
|
68399
|
+
const prepare = (condition, resolve, name) => {
|
|
68223
68400
|
if (typeof condition !== 'string') {
|
|
68224
68401
|
throw new TypeError('Criterion condition must be a string');
|
|
68225
68402
|
}
|
|
68226
68403
|
if (typeof resolve !== 'function') {
|
|
68227
|
-
throw new TypeError(
|
|
68404
|
+
throw new TypeError(`${name} requires a "resolve" function in options`);
|
|
68228
68405
|
}
|
|
68229
68406
|
const {
|
|
68230
68407
|
result,
|
|
@@ -68235,7 +68412,17 @@ const evaluate = (condition, {
|
|
|
68235
68412
|
condition
|
|
68236
68413
|
});
|
|
68237
68414
|
}
|
|
68238
|
-
return
|
|
68415
|
+
return tree;
|
|
68416
|
+
};
|
|
68417
|
+
|
|
68418
|
+
// a native Promise means an async resolver, whose Promise would otherwise be
|
|
68419
|
+
// compared as a plain object.
|
|
68420
|
+
const resolveValue = (resolve, expression, ast) => {
|
|
68421
|
+
const value = resolve(expression, ast);
|
|
68422
|
+
if (value instanceof Promise) {
|
|
68423
|
+
throw new TypeError('resolve returned a Promise; use evaluateAsync to await resolved values');
|
|
68424
|
+
}
|
|
68425
|
+
return value;
|
|
68239
68426
|
};
|
|
68240
68427
|
const evaluateNode = (node, resolve) => {
|
|
68241
68428
|
switch (node.type) {
|
|
@@ -68244,13 +68431,13 @@ const evaluateNode = (node, resolve) => {
|
|
|
68244
68431
|
case 'UnaryExpression':
|
|
68245
68432
|
return !toBoolean(evaluateNode(node.argument, resolve));
|
|
68246
68433
|
case 'BinaryExpression':
|
|
68247
|
-
return
|
|
68434
|
+
return compare(node.operator, evaluateNode(node.left, resolve), evaluateNode(node.right, resolve));
|
|
68248
68435
|
case 'Literal':
|
|
68249
68436
|
return node.value;
|
|
68250
68437
|
case 'RuntimeExpression':
|
|
68251
|
-
return resolve
|
|
68438
|
+
return resolveValue(resolve, node.text, node.expression);
|
|
68252
68439
|
case 'RuntimeExpressionNavigation':
|
|
68253
|
-
return
|
|
68440
|
+
return navigate(resolveValue(resolve, node.expression.text, node.expression.expression), node.navigation);
|
|
68254
68441
|
default:
|
|
68255
68442
|
throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown AST node type: ${node.type}`);
|
|
68256
68443
|
}
|
|
@@ -68262,18 +68449,47 @@ const evaluateLogical = (node, resolve) => {
|
|
|
68262
68449
|
// '||'
|
|
68263
68450
|
return toBoolean(evaluateNode(node.left, resolve)) || toBoolean(evaluateNode(node.right, resolve));
|
|
68264
68451
|
};
|
|
68265
|
-
|
|
68266
|
-
|
|
68267
|
-
|
|
68452
|
+
|
|
68453
|
+
// the async counterpart of evaluateNode: same cases, each operand awaited in turn
|
|
68454
|
+
const evaluateNodeAsync = async (node, resolve) => {
|
|
68455
|
+
switch (node.type) {
|
|
68456
|
+
case 'LogicalExpression':
|
|
68457
|
+
return evaluateLogicalAsync(node, resolve);
|
|
68458
|
+
case 'UnaryExpression':
|
|
68459
|
+
return !toBoolean(await evaluateNodeAsync(node.argument, resolve));
|
|
68460
|
+
case 'BinaryExpression':
|
|
68461
|
+
{
|
|
68462
|
+
const left = await evaluateNodeAsync(node.left, resolve);
|
|
68463
|
+
return compare(node.operator, left, await evaluateNodeAsync(node.right, resolve));
|
|
68464
|
+
}
|
|
68465
|
+
case 'Literal':
|
|
68466
|
+
return node.value;
|
|
68467
|
+
case 'RuntimeExpression':
|
|
68468
|
+
return resolve(node.text, node.expression);
|
|
68469
|
+
case 'RuntimeExpressionNavigation':
|
|
68470
|
+
return navigate(await resolve(node.expression.text, node.expression.expression), node.navigation);
|
|
68471
|
+
default:
|
|
68472
|
+
throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown AST node type: ${node.type}`);
|
|
68473
|
+
}
|
|
68474
|
+
};
|
|
68475
|
+
const evaluateLogicalAsync = async (node, resolve) => {
|
|
68476
|
+
const left = toBoolean(await evaluateNodeAsync(node.left, resolve));
|
|
68477
|
+
// the right operand is evaluated only when the left one does not decide the result
|
|
68478
|
+
if (node.operator === '&&' ? !left : left) return left;
|
|
68479
|
+
return toBoolean(await evaluateNodeAsync(node.right, resolve));
|
|
68480
|
+
};
|
|
68481
|
+
const navigate = (resolved, navigation) => {
|
|
68482
|
+
let value = resolved;
|
|
68483
|
+
for (const step of navigation) {
|
|
68268
68484
|
if (value == null) return undefined;
|
|
68269
|
-
|
|
68485
|
+
const key = step.type === 'MemberAccess' ? step.name : step.value;
|
|
68486
|
+
// only the value's own members: `.constructor` or `.toString` must not reach the prototype
|
|
68487
|
+
value = Object.prototype.hasOwnProperty.call(value, key) ? value[key] : undefined;
|
|
68270
68488
|
}
|
|
68271
68489
|
return value;
|
|
68272
68490
|
};
|
|
68273
|
-
const
|
|
68274
|
-
|
|
68275
|
-
const right = evaluateNode(node.right, resolve);
|
|
68276
|
-
switch (node.operator) {
|
|
68491
|
+
const compare = (operator, left, right) => {
|
|
68492
|
+
switch (operator) {
|
|
68277
68493
|
case '==':
|
|
68278
68494
|
return looseEquals(left, right);
|
|
68279
68495
|
case '!=':
|
|
@@ -68282,9 +68498,9 @@ const evaluateComparison = (node, resolve) => {
|
|
|
68282
68498
|
case '<=':
|
|
68283
68499
|
case '>':
|
|
68284
68500
|
case '>=':
|
|
68285
|
-
return relational(
|
|
68501
|
+
return relational(operator, left, right);
|
|
68286
68502
|
default:
|
|
68287
|
-
throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown comparison operator: ${
|
|
68503
|
+
throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown comparison operator: ${operator}`);
|
|
68288
68504
|
}
|
|
68289
68505
|
};
|
|
68290
68506
|
|
|
@@ -68294,6 +68510,10 @@ const looseEquals = (a, b) => {
|
|
|
68294
68510
|
const bNull = b === null || b === undefined;
|
|
68295
68511
|
if (aNull || bNull) return aNull && bNull;
|
|
68296
68512
|
|
|
68513
|
+
// only JSON scalars are compared: arrays, objects and non-JSON values are never equal,
|
|
68514
|
+
// whatever their identity (compare structured values with a jsonpath criterion)
|
|
68515
|
+
if (!isJSONScalar(a) || !isJSONScalar(b)) return false;
|
|
68516
|
+
|
|
68297
68517
|
// string comparisons MUST be case insensitive
|
|
68298
68518
|
if (typeof a === 'string' && typeof b === 'string') {
|
|
68299
68519
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -68316,6 +68536,14 @@ const relational = (operator, a, b) => {
|
|
|
68316
68536
|
left = left.toLowerCase();
|
|
68317
68537
|
right = right.toLowerCase();
|
|
68318
68538
|
}
|
|
68539
|
+
|
|
68540
|
+
// only two numbers or two strings are ordered; any other pair is unordered rather than
|
|
68541
|
+
// left to host-language coercion, and, as in RFC 9535, `<=` / `>=` hold if it is equal
|
|
68542
|
+
const bothNumbers = typeof left === 'number' && typeof right === 'number';
|
|
68543
|
+
const bothStrings = typeof left === 'string' && typeof right === 'string';
|
|
68544
|
+
if (!bothNumbers && !bothStrings) {
|
|
68545
|
+
return (operator === '<=' || operator === '>=') && looseEquals(a, b);
|
|
68546
|
+
}
|
|
68319
68547
|
switch (operator) {
|
|
68320
68548
|
case '<':
|
|
68321
68549
|
return left < right;
|
|
@@ -68329,14 +68557,23 @@ const relational = (operator, a, b) => {
|
|
|
68329
68557
|
return false;
|
|
68330
68558
|
}
|
|
68331
68559
|
};
|
|
68332
|
-
|
|
68560
|
+
|
|
68561
|
+
// evaluation is defined on the JSON value model, independent of the host language
|
|
68562
|
+
// (null is handled separately; BigInt, Date, Map, functions, ... are not JSON values)
|
|
68563
|
+
const isJSONScalar = value => typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean';
|
|
68564
|
+
|
|
68565
|
+
// a numeric string is one matching the grammar's own `number` rule (the JSON number
|
|
68566
|
+
// format): no hex/binary/octal prefixes, leading zeros, '+' sign or surrounding whitespace
|
|
68567
|
+
const NUMERIC = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
68568
|
+
const isNumeric = str => NUMERIC.test(str) && Number.isFinite(Number(str));
|
|
68333
68569
|
|
|
68334
68570
|
// A condition passes (truthy) when it evaluates to a truthy value; it fails (falsy)
|
|
68335
68571
|
// on false, null, or a missing (undefined) value.
|
|
68336
68572
|
const toBoolean = value => Boolean(value);
|
|
68337
68573
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (evaluate);
|
|
68338
68574
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
68339
|
-
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
|
|
68575
|
+
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
|
|
68576
|
+
/* harmony export */ "evaluateAsync", 0, /* binding */ evaluateAsync
|
|
68340
68577
|
/* harmony export */ ]);
|
|
68341
68578
|
|
|
68342
68579
|
|
|
@@ -69473,6 +69710,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
69473
69710
|
/* harmony export */ Trace: () => (/* reexport safe */ _parse_trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]),
|
|
69474
69711
|
/* harmony export */ XMLTranslator: () => (/* reexport safe */ _parse_translators_XMLTranslator_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]),
|
|
69475
69712
|
/* harmony export */ evaluate: () => (/* reexport safe */ _evaluate_index_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]),
|
|
69713
|
+
/* harmony export */ evaluateAsync: () => (/* reexport safe */ _evaluate_index_mjs__WEBPACK_IMPORTED_MODULE_3__.evaluateAsync),
|
|
69476
69714
|
/* harmony export */ parse: () => (/* reexport safe */ _parse_index_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
69477
69715
|
/* harmony export */ test: () => (/* reexport safe */ _test_index_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])
|
|
69478
69716
|
/* harmony export */ });
|
|
@@ -69536,6 +69774,36 @@ const cst = nodeType => {
|
|
|
69536
69774
|
/* harmony export */ ]);
|
|
69537
69775
|
|
|
69538
69776
|
|
|
69777
|
+
/***/ },
|
|
69778
|
+
|
|
69779
|
+
/***/ 94771
|
|
69780
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
69781
|
+
|
|
69782
|
+
"use strict";
|
|
69783
|
+
__webpack_require__.r(__webpack_exports__);
|
|
69784
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
69785
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
69786
|
+
/* harmony export */ });
|
|
69787
|
+
/* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
|
|
69788
|
+
/* harmony import */ var _translators_ASTTranslator_transformers_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56286);
|
|
69789
|
+
|
|
69790
|
+
|
|
69791
|
+
/**
|
|
69792
|
+
* Parser rule callback for `runtime-expression-operand`.
|
|
69793
|
+
*
|
|
69794
|
+
* The grammar matches an operand as one bounded token ("$" 1*operand-char); whether the token is
|
|
69795
|
+
* a runtime expression with valid criterion accessors is decided here, during parsing, so that an
|
|
69796
|
+
* invalid operand fails the parse like any other syntax error, whatever the translator.
|
|
69797
|
+
*/
|
|
69798
|
+
const operand = (sys, chars, phraseIndex) => {
|
|
69799
|
+
if (sys.state !== apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH) return;
|
|
69800
|
+
if (!(0,_translators_ASTTranslator_transformers_mjs__WEBPACK_IMPORTED_MODULE_1__.isValidOperand)(apg_lite__WEBPACK_IMPORTED_MODULE_0__.utilities.charsToString(chars, phraseIndex, sys.phraseLength))) {
|
|
69801
|
+
sys.state = apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOMATCH;
|
|
69802
|
+
sys.phraseLength = 0;
|
|
69803
|
+
}
|
|
69804
|
+
};
|
|
69805
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (operand);
|
|
69806
|
+
|
|
69539
69807
|
/***/ },
|
|
69540
69808
|
|
|
69541
69809
|
/***/ 23937
|
|
@@ -69549,8 +69817,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
69549
69817
|
/* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
|
|
69550
69818
|
/* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38550);
|
|
69551
69819
|
/* harmony import */ var _translators_ASTTranslator_index_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4586);
|
|
69552
|
-
/* harmony import */ var
|
|
69553
|
-
/* harmony import */ var
|
|
69820
|
+
/* harmony import */ var _callbacks_operand_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(94771);
|
|
69821
|
+
/* harmony import */ var _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9080);
|
|
69822
|
+
/* harmony import */ var _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(17624);
|
|
69823
|
+
|
|
69554
69824
|
|
|
69555
69825
|
|
|
69556
69826
|
|
|
@@ -69569,8 +69839,9 @@ const parse = (condition, {
|
|
|
69569
69839
|
try {
|
|
69570
69840
|
const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
|
|
69571
69841
|
if (translator) parser.ast = translator;
|
|
69842
|
+
parser.callbacks['runtime-expression-operand'] = _callbacks_operand_mjs__WEBPACK_IMPORTED_MODULE_3__["default"];
|
|
69572
69843
|
if (stats) parser.stats = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Stats();
|
|
69573
|
-
if (trace) parser.trace = new
|
|
69844
|
+
if (trace) parser.trace = new _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
69574
69845
|
const result = parser.parse(grammar, startRule, condition);
|
|
69575
69846
|
return {
|
|
69576
69847
|
result,
|
|
@@ -69579,7 +69850,7 @@ const parse = (condition, {
|
|
|
69579
69850
|
trace: parser.trace
|
|
69580
69851
|
};
|
|
69581
69852
|
} catch (error) {
|
|
69582
|
-
throw new
|
|
69853
|
+
throw new _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_5__["default"]('Unexpected error during Arazzo Criterion parsing', {
|
|
69583
69854
|
cause: error,
|
|
69584
69855
|
condition
|
|
69585
69856
|
});
|
|
@@ -69680,6 +69951,8 @@ class ASTTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
|
|
|
69680
69951
|
__webpack_require__.r(__webpack_exports__);
|
|
69681
69952
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
69682
69953
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
69954
|
+
/* harmony export */ isValidOperand: () => (/* binding */ isValidOperand),
|
|
69955
|
+
/* harmony export */ parseOperand: () => (/* binding */ parseOperand),
|
|
69683
69956
|
/* harmony export */ transformCSTtoAST: () => (/* binding */ transformCSTtoAST)
|
|
69684
69957
|
/* harmony export */ });
|
|
69685
69958
|
/* harmony import */ var _swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26847);
|
|
@@ -69709,8 +69982,12 @@ const OPERAND_TYPES = new Set(['paren-expr', 'comparison-expr', 'test-expr', 'ru
|
|
|
69709
69982
|
* @swaggerexpert/arazzo-runtime-expression.
|
|
69710
69983
|
*/
|
|
69711
69984
|
const splitAtRuntimeExpression = operand => {
|
|
69712
|
-
|
|
69713
|
-
|
|
69985
|
+
// only validity is needed here, so the runtime expression parses build no tree
|
|
69986
|
+
const isRuntimeExpression = text => (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__.parse)(text, {
|
|
69987
|
+
translator: null
|
|
69988
|
+
}).result;
|
|
69989
|
+
const full = isRuntimeExpression(operand);
|
|
69990
|
+
if (full.success) {
|
|
69714
69991
|
return {
|
|
69715
69992
|
expressionText: operand,
|
|
69716
69993
|
navigationText: ''
|
|
@@ -69719,15 +69996,29 @@ const splitAtRuntimeExpression = operand => {
|
|
|
69719
69996
|
|
|
69720
69997
|
// A failing parse reports how far it matched; walk down from there to the
|
|
69721
69998
|
// longest prefix that parses cleanly (robust against stopping mid-rule).
|
|
69722
|
-
for (let n = full.
|
|
69723
|
-
if ((
|
|
69999
|
+
for (let n = full.maxMatched; n > 0; n -= 1) {
|
|
70000
|
+
if (isRuntimeExpression(operand.slice(0, n)).success) {
|
|
69724
70001
|
return {
|
|
69725
70002
|
expressionText: operand.slice(0, n),
|
|
69726
70003
|
navigationText: operand.slice(n)
|
|
69727
70004
|
};
|
|
69728
70005
|
}
|
|
69729
70006
|
}
|
|
69730
|
-
|
|
70007
|
+
return undefined;
|
|
70008
|
+
};
|
|
70009
|
+
|
|
70010
|
+
/**
|
|
70011
|
+
* Whether an operand token is a runtime expression followed by valid criterion accessors.
|
|
70012
|
+
* Builds no trees; used by the parser to reject an invalid operand while parsing.
|
|
70013
|
+
*/
|
|
70014
|
+
const isValidOperand = operand => {
|
|
70015
|
+
const split = splitAtRuntimeExpression(operand);
|
|
70016
|
+
if (!split) return false;
|
|
70017
|
+
if (split.navigationText === '') return true;
|
|
70018
|
+
return (0,_index_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(split.navigationText, {
|
|
70019
|
+
startRule: 'runtime-expression-navigation',
|
|
70020
|
+
translator: null
|
|
70021
|
+
}).result.success;
|
|
69731
70022
|
};
|
|
69732
70023
|
|
|
69733
70024
|
/**
|
|
@@ -69754,10 +70045,12 @@ const parseNavigation = navigationText => {
|
|
|
69754
70045
|
* both already parsed. `navigation` is an empty array when there are no accessors.
|
|
69755
70046
|
*/
|
|
69756
70047
|
const parseOperand = operand => {
|
|
70048
|
+
const split = splitAtRuntimeExpression(operand);
|
|
70049
|
+
if (!split) throw new Error(`Operand is not a valid runtime expression: "${operand}"`);
|
|
69757
70050
|
const {
|
|
69758
70051
|
expressionText,
|
|
69759
70052
|
navigationText
|
|
69760
|
-
} =
|
|
70053
|
+
} = split;
|
|
69761
70054
|
const runtimeExpression = {
|
|
69762
70055
|
type: 'RuntimeExpression',
|
|
69763
70056
|
text: expressionText,
|
|
@@ -70073,22 +70366,38 @@ const grammar = new _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]();
|
|
|
70073
70366
|
* In strict mode (default) the whole string must parse as an expression-string,
|
|
70074
70367
|
* otherwise an empty array is returned. With `strict: false`, any `{` not followed
|
|
70075
70368
|
* by `$` is treated as literal text and every valid `{$...}` span is extracted;
|
|
70076
|
-
* invalid expression attempts are skipped.
|
|
70369
|
+
* invalid expression attempts are skipped. Each of them is reported to `onError`,
|
|
70370
|
+
* when given, with the same information `interpolate` passes to its `onError`;
|
|
70371
|
+
* its return value is ignored, as there is nothing to replace. `onError` is
|
|
70372
|
+
* ignored in strict mode.
|
|
70077
70373
|
*
|
|
70078
70374
|
* @example
|
|
70079
70375
|
*
|
|
70080
70376
|
* extract('{$url}'); // => ['$url']
|
|
70081
70377
|
* extract('id={$inputs.id}&name={$inputs.name}'); // => ['$inputs.id', '$inputs.name']
|
|
70082
70378
|
* extract('{"id": "{$inputs.id}"}', { strict: false }); // => ['$inputs.id']
|
|
70379
|
+
*
|
|
70380
|
+
* const errors = [];
|
|
70381
|
+
* extract('x={$inputs.}&y={$inputs.ok}', { strict: false, onError: (info) => errors.push(info) });
|
|
70382
|
+
* // => ['$inputs.ok'], errors[0].text === '{$inputs.}'
|
|
70083
70383
|
*/
|
|
70084
70384
|
const extract = (str, {
|
|
70085
|
-
strict = true
|
|
70385
|
+
strict = true,
|
|
70386
|
+
onError
|
|
70086
70387
|
} = {}) => {
|
|
70087
70388
|
if (typeof str !== 'string') {
|
|
70088
70389
|
return [];
|
|
70089
70390
|
}
|
|
70090
70391
|
if (strict === false) {
|
|
70091
|
-
|
|
70392
|
+
const expressions = [];
|
|
70393
|
+
for (const token of (0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(str)) {
|
|
70394
|
+
if (token.type === 'expression') {
|
|
70395
|
+
expressions.push(token.expression);
|
|
70396
|
+
} else if (token.type === 'invalid' && typeof onError === 'function') {
|
|
70397
|
+
onError((0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__.invalidAttemptInfo)(token));
|
|
70398
|
+
}
|
|
70399
|
+
}
|
|
70400
|
+
return expressions;
|
|
70092
70401
|
}
|
|
70093
70402
|
const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
|
|
70094
70403
|
parser.ast = new _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
@@ -71634,8 +71943,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
71634
71943
|
/* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71652);
|
|
71635
71944
|
/* harmony import */ var _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35963);
|
|
71636
71945
|
/* harmony import */ var _scanner_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21425);
|
|
71637
|
-
/* harmony import */ var _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4089);
|
|
71638
|
-
|
|
71639
71946
|
|
|
71640
71947
|
|
|
71641
71948
|
|
|
@@ -71712,31 +72019,7 @@ const interpolate = (template, resolver, {
|
|
|
71712
72019
|
if (token.type === 'expression') {
|
|
71713
72020
|
output += stringify(resolver(token.expression));
|
|
71714
72021
|
} else if (token.type === 'invalid') {
|
|
71715
|
-
const
|
|
71716
|
-
text,
|
|
71717
|
-
expression,
|
|
71718
|
-
start,
|
|
71719
|
-
length,
|
|
71720
|
-
terminated
|
|
71721
|
-
} = token;
|
|
71722
|
-
let error;
|
|
71723
|
-
const replacement = onError({
|
|
71724
|
-
text,
|
|
71725
|
-
start,
|
|
71726
|
-
length,
|
|
71727
|
-
// created lazily - capturing a stack trace for every invalid attempt is costly
|
|
71728
|
-
get error() {
|
|
71729
|
-
if (error === undefined) {
|
|
71730
|
-
const message = terminated ? `Invalid runtime expression "${text}" at position ${start}` : `Unterminated runtime expression "${text}" at position ${start}`;
|
|
71731
|
-
error = new _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__["default"](message, {
|
|
71732
|
-
runtimeExpression: expression,
|
|
71733
|
-
start,
|
|
71734
|
-
length
|
|
71735
|
-
});
|
|
71736
|
-
}
|
|
71737
|
-
return error;
|
|
71738
|
-
}
|
|
71739
|
-
});
|
|
72022
|
+
const replacement = onError((0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__.invalidAttemptInfo)(token));
|
|
71740
72023
|
if (typeof replacement !== 'string') {
|
|
71741
72024
|
throw new TypeError('onError must return a string');
|
|
71742
72025
|
}
|
|
@@ -71873,7 +72156,8 @@ const parse = (runtimeExpression, {
|
|
|
71873
72156
|
__webpack_require__.r(__webpack_exports__);
|
|
71874
72157
|
class Expectations extends Array {
|
|
71875
72158
|
toString() {
|
|
71876
|
-
|
|
72159
|
+
// JSON string syntax, so that entries such as '"' and '\\' stay unambiguous
|
|
72160
|
+
return this.map(c => JSON.stringify(String(c))).join(', ');
|
|
71877
72161
|
}
|
|
71878
72162
|
}
|
|
71879
72163
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Expectations);
|
|
@@ -71890,34 +72174,226 @@ class Expectations extends Array {
|
|
|
71890
72174
|
"use strict";
|
|
71891
72175
|
__webpack_require__.r(__webpack_exports__);
|
|
71892
72176
|
/* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
|
|
71893
|
-
/* harmony import */ var
|
|
72177
|
+
/* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71652);
|
|
72178
|
+
/* harmony import */ var _Expectations_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3770);
|
|
71894
72179
|
|
|
71895
72180
|
|
|
71896
|
-
|
|
71897
|
-
|
|
71898
|
-
|
|
71899
|
-
|
|
71900
|
-
|
|
71901
|
-
|
|
71902
|
-
|
|
72181
|
+
// TLS (case-insensitive literal) opcodes store the string lowercased; the grammar source
|
|
72182
|
+
// keeps the spelling it is written with (e.g. "$statusCode"), so expectations use that.
|
|
72183
|
+
const literalSpellings = new Map();
|
|
72184
|
+
for (const [, literal] of String(new _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]()).matchAll(/"([^"\n]*)"/g)) {
|
|
72185
|
+
const key = literal.toLowerCase();
|
|
72186
|
+
if (!literalSpellings.has(key)) literalSpellings.set(key, literal);
|
|
72187
|
+
}
|
|
72188
|
+
const hex = code => code.toString(16).toUpperCase().padStart(2, '0');
|
|
72189
|
+
const describeTerminal = op => {
|
|
72190
|
+
switch (op.type) {
|
|
72191
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TLS:
|
|
72192
|
+
{
|
|
72193
|
+
const literal = String.fromCodePoint(...op.string);
|
|
72194
|
+
return literalSpellings.get(literal) ?? literal;
|
|
72195
|
+
}
|
|
72196
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TBS:
|
|
72197
|
+
return String.fromCodePoint(...op.string);
|
|
72198
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TRG:
|
|
72199
|
+
return op.min === op.max ? `%x${hex(op.min)}` : `%x${hex(op.min)}-${hex(op.max)}`;
|
|
72200
|
+
default:
|
|
72201
|
+
return undefined;
|
|
72202
|
+
}
|
|
72203
|
+
};
|
|
71903
72204
|
|
|
71904
|
-
|
|
71905
|
-
|
|
71906
|
-
|
|
71907
|
-
|
|
71908
|
-
|
|
72205
|
+
// FIRST set of an opcode: the terminals a match of it can start with, and whether it can
|
|
72206
|
+
// match the empty phrase (in which case what follows it can start the match as well)
|
|
72207
|
+
const first = (rules, opcodes, index, visiting = new Set()) => {
|
|
72208
|
+
const op = opcodes[index];
|
|
72209
|
+
switch (op.type) {
|
|
72210
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.ALT:
|
|
72211
|
+
{
|
|
72212
|
+
const terminals = [];
|
|
72213
|
+
let nullable = false;
|
|
72214
|
+
for (const child of op.children) {
|
|
72215
|
+
const result = first(rules, opcodes, child, visiting);
|
|
72216
|
+
terminals.push(...result.terminals);
|
|
72217
|
+
nullable = nullable || result.nullable;
|
|
72218
|
+
}
|
|
72219
|
+
return {
|
|
72220
|
+
terminals,
|
|
72221
|
+
nullable
|
|
72222
|
+
};
|
|
72223
|
+
}
|
|
72224
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.CAT:
|
|
72225
|
+
{
|
|
72226
|
+
const terminals = [];
|
|
72227
|
+
for (const child of op.children) {
|
|
72228
|
+
const result = first(rules, opcodes, child, visiting);
|
|
72229
|
+
terminals.push(...result.terminals);
|
|
72230
|
+
if (!result.nullable) return {
|
|
72231
|
+
terminals,
|
|
72232
|
+
nullable: false
|
|
72233
|
+
};
|
|
71909
72234
|
}
|
|
72235
|
+
return {
|
|
72236
|
+
terminals,
|
|
72237
|
+
nullable: true
|
|
72238
|
+
};
|
|
72239
|
+
}
|
|
72240
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP:
|
|
72241
|
+
{
|
|
72242
|
+
const result = first(rules, opcodes, index + 1, visiting);
|
|
72243
|
+
return {
|
|
72244
|
+
terminals: result.terminals,
|
|
72245
|
+
nullable: op.min === 0 || result.nullable
|
|
72246
|
+
};
|
|
71910
72247
|
}
|
|
72248
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.RNM:
|
|
72249
|
+
{
|
|
72250
|
+
// a left-recursive reference adds nothing the outer visit does not already add
|
|
72251
|
+
if (visiting.has(op.index)) return {
|
|
72252
|
+
terminals: [],
|
|
72253
|
+
nullable: false
|
|
72254
|
+
};
|
|
72255
|
+
visiting.add(op.index);
|
|
72256
|
+
const result = first(rules, rules[op.index].opcodes, 0, visiting);
|
|
72257
|
+
visiting.delete(op.index);
|
|
72258
|
+
return result;
|
|
72259
|
+
}
|
|
72260
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TLS:
|
|
72261
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TBS:
|
|
72262
|
+
return {
|
|
72263
|
+
terminals: op.string.length > 0 ? [op] : [],
|
|
72264
|
+
nullable: op.string.length === 0
|
|
72265
|
+
};
|
|
72266
|
+
case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TRG:
|
|
72267
|
+
return {
|
|
72268
|
+
terminals: [op],
|
|
72269
|
+
nullable: false
|
|
72270
|
+
};
|
|
72271
|
+
default:
|
|
72272
|
+
// AND, NOT (look-ahead) and UDT do not consume input that can be described as a terminal
|
|
72273
|
+
return {
|
|
72274
|
+
terminals: [],
|
|
72275
|
+
nullable: true
|
|
72276
|
+
};
|
|
72277
|
+
}
|
|
72278
|
+
};
|
|
72279
|
+
const stateSymbol = Symbol('trace state');
|
|
72280
|
+
class Trace extends apg_lite__WEBPACK_IMPORTED_MODULE_0__.Trace {
|
|
72281
|
+
constructor() {
|
|
72282
|
+
super();
|
|
72283
|
+
const baseInit = this.init;
|
|
72284
|
+
const baseDown = this.down;
|
|
72285
|
+
const baseUp = this.up;
|
|
72286
|
+
let rules = [];
|
|
72287
|
+
let inputLength = 0;
|
|
72288
|
+
let repetitions = new Map();
|
|
72289
|
+
let lookAhead = 0;
|
|
72290
|
+
// repetitions in progress: where each one has got to and how many times its child matched
|
|
72291
|
+
let progress = [];
|
|
72292
|
+
const state = {
|
|
72293
|
+
maxMatched: 0,
|
|
72294
|
+
failures: []
|
|
72295
|
+
};
|
|
72296
|
+
this[stateSymbol] = state;
|
|
71911
72297
|
|
|
71912
|
-
|
|
71913
|
-
|
|
71914
|
-
|
|
71915
|
-
|
|
71916
|
-
|
|
72298
|
+
// only failures at the furthest offset are ever reported, so only those are kept
|
|
72299
|
+
const recordFailure = (op, offset) => {
|
|
72300
|
+
if (offset === state.maxMatched) state.failures.push({
|
|
72301
|
+
op,
|
|
72302
|
+
offset
|
|
72303
|
+
});
|
|
72304
|
+
};
|
|
72305
|
+
this.init = (r, u, c) => {
|
|
72306
|
+
rules = r;
|
|
72307
|
+
inputLength = c.length;
|
|
72308
|
+
// the opcodes of a repetition's rule, and its position there, to find its child
|
|
72309
|
+
repetitions = new Map();
|
|
72310
|
+
for (const rule of r) {
|
|
72311
|
+
rule.opcodes.forEach((op, index) => {
|
|
72312
|
+
if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) repetitions.set(op, {
|
|
72313
|
+
opcodes: rule.opcodes,
|
|
72314
|
+
index
|
|
72315
|
+
});
|
|
72316
|
+
});
|
|
72317
|
+
}
|
|
72318
|
+
// a Trace instance may be reused for another parse
|
|
72319
|
+
lookAhead = 0;
|
|
72320
|
+
progress = [];
|
|
72321
|
+
state.maxMatched = 0;
|
|
72322
|
+
state.failures = [];
|
|
72323
|
+
baseInit(r, u, c);
|
|
72324
|
+
};
|
|
72325
|
+
this.down = (op, offset) => {
|
|
72326
|
+
if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.AND || op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOT) lookAhead += 1;
|
|
72327
|
+
if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) {
|
|
72328
|
+
const {
|
|
72329
|
+
opcodes,
|
|
72330
|
+
index
|
|
72331
|
+
} = repetitions.get(op);
|
|
72332
|
+
progress.push({
|
|
72333
|
+
child: opcodes[index + 1],
|
|
72334
|
+
opcodes,
|
|
72335
|
+
index,
|
|
72336
|
+
position: offset,
|
|
72337
|
+
count: 0
|
|
72338
|
+
});
|
|
72339
|
+
}
|
|
72340
|
+
baseDown(op, offset);
|
|
72341
|
+
};
|
|
72342
|
+
this.up = (op, opState, offset, phraseLength) => {
|
|
72343
|
+
if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.AND || op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOT) lookAhead -= 1;
|
|
72344
|
+
|
|
72345
|
+
// look-ahead operators test the input without consuming it, so neither their
|
|
72346
|
+
// matches nor their failures say anything about what the input should contain
|
|
72347
|
+
if (lookAhead === 0) {
|
|
72348
|
+
if (opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH && offset + phraseLength > state.maxMatched) {
|
|
72349
|
+
state.maxMatched = offset + phraseLength;
|
|
72350
|
+
state.failures = [];
|
|
72351
|
+
}
|
|
72352
|
+
if (opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOMATCH && describeTerminal(op) !== undefined) {
|
|
72353
|
+
recordFailure(op, offset);
|
|
72354
|
+
}
|
|
72355
|
+
}
|
|
72356
|
+
const repetition = progress[progress.length - 1];
|
|
72357
|
+
if (repetition && op === repetition.child && opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH) {
|
|
72358
|
+
repetition.position = offset + phraseLength;
|
|
72359
|
+
repetition.count += 1;
|
|
72360
|
+
}
|
|
72361
|
+
if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) {
|
|
72362
|
+
progress.pop();
|
|
72363
|
+
// at the end of the input a repetition stops without trying its child again, so the
|
|
72364
|
+
// terminals that could have continued it are never tried; add them from its FIRST set
|
|
72365
|
+
if (lookAhead === 0 && repetition.position === inputLength && repetition.count < op.max) {
|
|
72366
|
+
const {
|
|
72367
|
+
opcodes,
|
|
72368
|
+
index
|
|
72369
|
+
} = repetition;
|
|
72370
|
+
for (const terminal of first(rules, opcodes, index + 1).terminals) {
|
|
72371
|
+
recordFailure(terminal, inputLength);
|
|
72372
|
+
}
|
|
71917
72373
|
}
|
|
71918
72374
|
}
|
|
72375
|
+
baseUp(op, opState, offset, phraseLength);
|
|
72376
|
+
};
|
|
72377
|
+
}
|
|
72378
|
+
|
|
72379
|
+
/**
|
|
72380
|
+
* Terminals the grammar could have accepted at the offset where parsing stopped
|
|
72381
|
+
* (`result.maxMatched`), in the order the parser tried them, unabbreviated.
|
|
72382
|
+
* Character ranges are given in ABNF notation (e.g. `%x30-39`).
|
|
72383
|
+
*/
|
|
72384
|
+
inferExpectations() {
|
|
72385
|
+
const {
|
|
72386
|
+
maxMatched,
|
|
72387
|
+
failures
|
|
72388
|
+
} = this[stateSymbol];
|
|
72389
|
+
const expectations = new Set();
|
|
72390
|
+
for (const {
|
|
72391
|
+
op,
|
|
72392
|
+
offset
|
|
72393
|
+
} of failures) {
|
|
72394
|
+
if (offset === maxMatched) expectations.add(describeTerminal(op));
|
|
71919
72395
|
}
|
|
71920
|
-
return new
|
|
72396
|
+
return new _Expectations_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](...expectations);
|
|
71921
72397
|
}
|
|
71922
72398
|
}
|
|
71923
72399
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Trace);
|
|
@@ -72321,6 +72797,8 @@ class XMLTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
|
|
|
72321
72797
|
"use strict";
|
|
72322
72798
|
__webpack_require__.r(__webpack_exports__);
|
|
72323
72799
|
/* harmony import */ var _test_index_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34976);
|
|
72800
|
+
/* harmony import */ var _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4089);
|
|
72801
|
+
|
|
72324
72802
|
|
|
72325
72803
|
/**
|
|
72326
72804
|
* Tolerantly scan a string containing embedded {expression} patterns.
|
|
@@ -72403,9 +72881,43 @@ const scan = str => {
|
|
|
72403
72881
|
}
|
|
72404
72882
|
return tokens;
|
|
72405
72883
|
};
|
|
72884
|
+
|
|
72885
|
+
/**
|
|
72886
|
+
* Information about an invalid expression attempt, as passed to `onError`
|
|
72887
|
+
* of `interpolate` and `extract`: { text, start, length, error }.
|
|
72888
|
+
*
|
|
72889
|
+
* @private
|
|
72890
|
+
*/
|
|
72891
|
+
const invalidAttemptInfo = ({
|
|
72892
|
+
text,
|
|
72893
|
+
expression,
|
|
72894
|
+
start,
|
|
72895
|
+
length,
|
|
72896
|
+
terminated
|
|
72897
|
+
}) => {
|
|
72898
|
+
let error;
|
|
72899
|
+
return {
|
|
72900
|
+
text,
|
|
72901
|
+
start,
|
|
72902
|
+
length,
|
|
72903
|
+
// created lazily - capturing a stack trace for every invalid attempt is costly
|
|
72904
|
+
get error() {
|
|
72905
|
+
if (error === undefined) {
|
|
72906
|
+
const message = terminated ? `Invalid runtime expression "${text}" at position ${start}` : `Unterminated runtime expression "${text}" at position ${start}`;
|
|
72907
|
+
error = new _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](message, {
|
|
72908
|
+
runtimeExpression: expression,
|
|
72909
|
+
start,
|
|
72910
|
+
length
|
|
72911
|
+
});
|
|
72912
|
+
}
|
|
72913
|
+
return error;
|
|
72914
|
+
}
|
|
72915
|
+
};
|
|
72916
|
+
};
|
|
72406
72917
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (scan);
|
|
72407
72918
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
72408
|
-
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
|
|
72919
|
+
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
|
|
72920
|
+
/* harmony export */ "invalidAttemptInfo", 0, /* binding */ invalidAttemptInfo
|
|
72409
72921
|
/* harmony export */ ]);
|
|
72410
72922
|
|
|
72411
72923
|
|