@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
|
@@ -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) {
|
|
@@ -12448,7 +12456,7 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
|
|
|
12448
12456
|
document,
|
|
12449
12457
|
registry: this.registry
|
|
12450
12458
|
});
|
|
12451
|
-
const uriReference = evaluator.interpolate(operationPath);
|
|
12459
|
+
const uriReference = await evaluator.interpolate(operationPath);
|
|
12452
12460
|
const documentURI = _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.sanitize(_speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.stripHash(uriReference));
|
|
12453
12461
|
if (documentURI === '') {
|
|
12454
12462
|
throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`operationPath "${operationPath}" does not resolve to a source description URL`, {
|
|
@@ -12850,8 +12858,8 @@ class StepExecutor {
|
|
|
12850
12858
|
// keyed by '{in}.{name}' rather than bare name, so two parameters that
|
|
12851
12859
|
// legally differ only in their location each reach their own place.
|
|
12852
12860
|
const preContext = state.toContext();
|
|
12853
|
-
const parameters = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
|
|
12854
|
-
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);
|
|
12855
12863
|
|
|
12856
12864
|
// checked here rather than on entry: locating the operation and resolving
|
|
12857
12865
|
// the expressions above are awaited, so a run cancelled during them would
|
|
@@ -12887,13 +12895,13 @@ class StepExecutor {
|
|
|
12887
12895
|
// evaluate criteria, outputs, and the next action against the post-request
|
|
12888
12896
|
// context (with $request / $url / $method and $response / $statusCode).
|
|
12889
12897
|
const postContext = state.toContext(this.#requestContext(response), this.#responseContext(response));
|
|
12890
|
-
const successCriteria = this.evaluateCriteria(step, postContext, workflowId);
|
|
12898
|
+
const successCriteria = await this.evaluateCriteria(step, postContext, workflowId);
|
|
12891
12899
|
const successful = successCriteria.every(criterion => criterion.met);
|
|
12892
|
-
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);
|
|
12893
12901
|
const {
|
|
12894
12902
|
matchedActions,
|
|
12895
12903
|
actionCriteria
|
|
12896
|
-
} = this.selectActions(step, successful, postContext, workflowId);
|
|
12904
|
+
} = await this.selectActions(step, successful, postContext, workflowId);
|
|
12897
12905
|
return {
|
|
12898
12906
|
stepId,
|
|
12899
12907
|
response,
|
|
@@ -12990,13 +12998,18 @@ class StepExecutor {
|
|
|
12990
12998
|
* names the step's workflow on a thrown error, as for
|
|
12991
12999
|
* {@link StepExecutor.execute}.
|
|
12992
13000
|
*/
|
|
12993
|
-
evaluateCriteria(step, context, workflowId) {
|
|
13001
|
+
async evaluateCriteria(step, context, workflowId) {
|
|
12994
13002
|
this.assertSuccessCriteria(step, workflowId);
|
|
12995
13003
|
const criteria = step.successCriteria;
|
|
12996
13004
|
if (criteria === undefined) return [];
|
|
12997
13005
|
|
|
12998
|
-
// assertSuccessCriteria above guarantees every entry is a Criterion Object
|
|
12999
|
-
|
|
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;
|
|
13000
13013
|
}
|
|
13001
13014
|
|
|
13002
13015
|
/**
|
|
@@ -13022,11 +13035,11 @@ class StepExecutor {
|
|
|
13022
13035
|
* `workflowId` names the step's workflow on a thrown error, as for
|
|
13023
13036
|
* {@link StepExecutor.execute}.
|
|
13024
13037
|
*/
|
|
13025
|
-
selectActions(step, successful, context, workflowId) {
|
|
13038
|
+
async selectActions(step, successful, context, workflowId) {
|
|
13026
13039
|
const actionCriteria = [];
|
|
13027
|
-
const isCriterionMet = (criterion, action) => {
|
|
13040
|
+
const isCriterionMet = async (criterion, action) => {
|
|
13028
13041
|
const record = {
|
|
13029
|
-
...this.#evaluateCriterion(criterion, context),
|
|
13042
|
+
...(await this.#evaluateCriterion(criterion, context)),
|
|
13030
13043
|
actionName: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.name)
|
|
13031
13044
|
};
|
|
13032
13045
|
actionCriteria.push(record);
|
|
@@ -13038,7 +13051,7 @@ class StepExecutor {
|
|
|
13038
13051
|
}),
|
|
13039
13052
|
stepId: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.stepId)
|
|
13040
13053
|
};
|
|
13041
|
-
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);
|
|
13042
13055
|
return {
|
|
13043
13056
|
matchedActions,
|
|
13044
13057
|
actionCriteria
|
|
@@ -13072,13 +13085,13 @@ class StepExecutor {
|
|
|
13072
13085
|
* condition that cannot be evaluated is unmet and records why; any other
|
|
13073
13086
|
* error propagates.
|
|
13074
13087
|
*/
|
|
13075
|
-
#evaluateCriterion(criterion, context) {
|
|
13088
|
+
async #evaluateCriterion(criterion, context) {
|
|
13076
13089
|
const condition = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(criterion.condition);
|
|
13077
13090
|
try {
|
|
13078
13091
|
const {
|
|
13079
13092
|
met,
|
|
13080
13093
|
error
|
|
13081
|
-
} = this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
13094
|
+
} = await this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
|
|
13082
13095
|
if (error === undefined) return {
|
|
13083
13096
|
condition,
|
|
13084
13097
|
met
|
|
@@ -14158,7 +14171,7 @@ class WorkflowExecutor {
|
|
|
14158
14171
|
stepId,
|
|
14159
14172
|
callStack: nested
|
|
14160
14173
|
});
|
|
14161
|
-
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));
|
|
14162
14175
|
runOutcome = {
|
|
14163
14176
|
kind: 'transferred',
|
|
14164
14177
|
transferredTo
|
|
@@ -14222,7 +14235,7 @@ class WorkflowExecutor {
|
|
|
14222
14235
|
* {@link WorkflowExecutor.#validateWorkflowOutputsShape} already checked
|
|
14223
14236
|
* the shape up front, independent of resolving it.
|
|
14224
14237
|
*/
|
|
14225
|
-
#result(invocation, workflow, steps, outcome, dependencies, startedAt) {
|
|
14238
|
+
async #result(invocation, workflow, steps, outcome, dependencies, startedAt) {
|
|
14226
14239
|
const shared = {
|
|
14227
14240
|
workflowId: invocation.workflowId,
|
|
14228
14241
|
steps,
|
|
@@ -14246,7 +14259,7 @@ class WorkflowExecutor {
|
|
|
14246
14259
|
}
|
|
14247
14260
|
return {
|
|
14248
14261
|
...shared,
|
|
14249
|
-
outputs: this.#resolveWorkflowOutputs(workflow, invocation),
|
|
14262
|
+
outputs: await this.#resolveWorkflowOutputs(workflow, invocation),
|
|
14250
14263
|
status: outcome.status,
|
|
14251
14264
|
settledStatus: outcome.status
|
|
14252
14265
|
};
|
|
@@ -14387,7 +14400,7 @@ class WorkflowExecutor {
|
|
|
14387
14400
|
const reference = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.workflowId);
|
|
14388
14401
|
// resolved before the budget is charged, so an authoring error in them
|
|
14389
14402
|
// costs no budget unit.
|
|
14390
|
-
const inputs = this.#actionInputs(action.parameters, outcome, invocation, stepId);
|
|
14403
|
+
const inputs = await this.#actionInputs(action.parameters, outcome, invocation, stepId);
|
|
14391
14404
|
this.#chargeBudget(scope, invocation, stepId);
|
|
14392
14405
|
const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry', inputs);
|
|
14393
14406
|
// the result's workflowId is the bare id the reference resolved to —
|
|
@@ -14619,7 +14632,7 @@ class WorkflowExecutor {
|
|
|
14619
14632
|
// sees the same (usually absent) value on every attempt, not the
|
|
14620
14633
|
// previous attempt's own result.
|
|
14621
14634
|
const preContext = this.#inputContext(state, subWorkflowId, priorWorkflowEntry);
|
|
14622
|
-
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);
|
|
14623
14636
|
const result = await this.#run(locator, inputs, scope, callStack, 'step');
|
|
14624
14637
|
subWorkflows.push(result);
|
|
14625
14638
|
state.setWorkflow(subWorkflowId, {
|
|
@@ -14642,7 +14655,7 @@ class WorkflowExecutor {
|
|
|
14642
14655
|
workflowId: subWorkflowId
|
|
14643
14656
|
}
|
|
14644
14657
|
};
|
|
14645
|
-
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);
|
|
14646
14659
|
// an `end`ed sub-workflow returned to its caller with outputs, so it took
|
|
14647
14660
|
// the success path like a completed one; only a chain settling `failed` is
|
|
14648
14661
|
// a failure — a sub-workflow that transferred is judged by where its
|
|
@@ -14657,12 +14670,12 @@ class WorkflowExecutor {
|
|
|
14657
14670
|
// evaluated by the parent document's step executor — only the sub-run
|
|
14658
14671
|
// itself switched documents.
|
|
14659
14672
|
const stepExecutor = this.#stepExecutor.forDocument(document);
|
|
14660
|
-
const successCriteria = stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
14673
|
+
const successCriteria = await stepExecutor.evaluateCriteria(step, context, workflowId);
|
|
14661
14674
|
const successful = !this.#settledFailed(result) && successCriteria.every(criterion => criterion.met);
|
|
14662
14675
|
const {
|
|
14663
14676
|
matchedActions,
|
|
14664
14677
|
actionCriteria
|
|
14665
|
-
} = stepExecutor.selectActions(step, successful, context, workflowId);
|
|
14678
|
+
} = await stepExecutor.selectActions(step, successful, context, workflowId);
|
|
14666
14679
|
return {
|
|
14667
14680
|
stepId,
|
|
14668
14681
|
successful,
|
|
@@ -15027,8 +15040,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15027
15040
|
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27554);
|
|
15028
15041
|
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7456);
|
|
15029
15042
|
/* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(48770);
|
|
15030
|
-
/* harmony import */ var
|
|
15031
|
-
/* 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
|
+
|
|
15032
15049
|
|
|
15033
15050
|
|
|
15034
15051
|
|
|
@@ -15080,6 +15097,9 @@ const HTTP_EXCHANGE_NODES = new Set(['UrlExpression', 'MethodExpression', 'Statu
|
|
|
15080
15097
|
* (via the registry) the source name points at. A step reference resolves to
|
|
15081
15098
|
* the Step Object as authored — a locator, not the step's execution result.
|
|
15082
15099
|
*
|
|
15100
|
+
* Evaluation is asynchronous because a `$sourceDescriptions` reference may
|
|
15101
|
+
* have to load the document it points at.
|
|
15102
|
+
*
|
|
15083
15103
|
* A reference resolves to `undefined` when it is absent. Runtime values
|
|
15084
15104
|
* originate from JSON (or ApiDOM), which cannot represent `undefined` — an
|
|
15085
15105
|
* absent value is a missing property and an explicit null is `null` — so
|
|
@@ -15113,11 +15133,19 @@ class RuntimeExpressionEvaluator {
|
|
|
15113
15133
|
* The expression must be the bare form without surrounding braces
|
|
15114
15134
|
* (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
|
|
15115
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
|
|
15116
15144
|
*/
|
|
15117
|
-
evaluate(expression) {
|
|
15145
|
+
async evaluate(expression) {
|
|
15118
15146
|
const node = this.#parse(expression);
|
|
15119
15147
|
this.#assertAvailable(node, expression);
|
|
15120
|
-
const value = this.#evaluateNode(node, expression);
|
|
15148
|
+
const value = await this.#evaluateNode(node, expression);
|
|
15121
15149
|
if (value === undefined && this.#strict) {
|
|
15122
15150
|
throw new _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`Runtime expression "${expression}" could not be resolved against the context`, {
|
|
15123
15151
|
expression,
|
|
@@ -15135,8 +15163,20 @@ class RuntimeExpressionEvaluator {
|
|
|
15135
15163
|
* mode, unresolvable references render as an empty string. A `{…}` that is not
|
|
15136
15164
|
* a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
|
|
15137
15165
|
*/
|
|
15138
|
-
interpolate(template) {
|
|
15139
|
-
|
|
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));
|
|
15140
15180
|
}
|
|
15141
15181
|
|
|
15142
15182
|
/**
|
|
@@ -15150,7 +15190,7 @@ class RuntimeExpressionEvaluator {
|
|
|
15150
15190
|
* yields the string representation of its value, not the typed value. A
|
|
15151
15191
|
* string containing no expressions is returned unchanged.
|
|
15152
15192
|
*/
|
|
15153
|
-
resolve(value) {
|
|
15193
|
+
async resolve(value) {
|
|
15154
15194
|
// `test` returns true only when the entire string is a valid runtime
|
|
15155
15195
|
// expression, so a braced or mixed string falls through to interpolation.
|
|
15156
15196
|
return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? this.evaluate(value) : this.interpolate(value);
|
|
@@ -15270,7 +15310,7 @@ class RuntimeExpressionEvaluator {
|
|
|
15270
15310
|
* the workflow or step is unknown.
|
|
15271
15311
|
*/
|
|
15272
15312
|
#step(document, workflowId, stepId) {
|
|
15273
|
-
if (document === undefined || !
|
|
15313
|
+
if (document === undefined || !_document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__["default"].is(document)) return undefined;
|
|
15274
15314
|
const pointer = document.stepIndex.getStep(workflowId, stepId);
|
|
15275
15315
|
return pointer === undefined ? undefined : this.#drillDocument(document, pointer);
|
|
15276
15316
|
}
|
|
@@ -15288,27 +15328,45 @@ class RuntimeExpressionEvaluator {
|
|
|
15288
15328
|
* `$sourceDescriptions.{name}.url` yields the source's URL. An operationId
|
|
15289
15329
|
* that collides with a field name takes precedence (tier 1 wins).
|
|
15290
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
|
+
*
|
|
15291
15338
|
* Returns `undefined` when nothing matches.
|
|
15292
15339
|
*/
|
|
15293
|
-
#sourceDescription({
|
|
15340
|
+
async #sourceDescription({
|
|
15294
15341
|
sourceName,
|
|
15295
15342
|
reference,
|
|
15296
15343
|
stepsReference
|
|
15297
15344
|
}) {
|
|
15298
|
-
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);
|
|
15299
15349
|
|
|
15300
15350
|
// tier 1: operationId / workflowId / workflow step in the referenced document.
|
|
15301
|
-
|
|
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
|
+
}
|
|
15302
15360
|
if (apiDocument !== undefined) {
|
|
15303
15361
|
if (stepsReference !== undefined) {
|
|
15304
15362
|
return this.#step(apiDocument, stepsReference.workflowId, stepsReference.stepId);
|
|
15305
15363
|
}
|
|
15306
|
-
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;
|
|
15307
15365
|
if (pointer !== undefined) return this.#drillDocument(apiDocument, pointer);
|
|
15308
15366
|
}
|
|
15309
15367
|
|
|
15310
15368
|
// tier 2: a field of the Source Description Object (url, type, ...).
|
|
15311
|
-
return
|
|
15369
|
+
return field;
|
|
15312
15370
|
}
|
|
15313
15371
|
|
|
15314
15372
|
/**
|
|
@@ -16421,6 +16479,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16421
16479
|
*/
|
|
16422
16480
|
class DocumentRegistry {
|
|
16423
16481
|
#documents = new Map();
|
|
16482
|
+
#loading = new Map();
|
|
16424
16483
|
#providers;
|
|
16425
16484
|
constructor(options = {}) {
|
|
16426
16485
|
this.#providers = options.providers ?? [new _providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](), new _providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]()];
|
|
@@ -16443,6 +16502,10 @@ class DocumentRegistry {
|
|
|
16443
16502
|
* otherwise detects the format, loads via the matching provider,
|
|
16444
16503
|
* caches, and returns it.
|
|
16445
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
|
+
*
|
|
16446
16509
|
* @throws DocumentLoadError - When the document cannot be read or loaded
|
|
16447
16510
|
* @throws UnmatchedProviderError - When no provider can load the document
|
|
16448
16511
|
*/
|
|
@@ -16450,6 +16513,21 @@ class DocumentRegistry {
|
|
|
16450
16513
|
const canonicalURI = this.#canonicalize(uri);
|
|
16451
16514
|
const cachedDocument = this.#get(canonicalURI);
|
|
16452
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) {
|
|
16453
16531
|
for (const provider of this.#providers) {
|
|
16454
16532
|
try {
|
|
16455
16533
|
if (await provider.canProvide(canonicalURI)) {
|
|
@@ -16473,16 +16551,17 @@ class DocumentRegistry {
|
|
|
16473
16551
|
}
|
|
16474
16552
|
|
|
16475
16553
|
/**
|
|
16476
|
-
*
|
|
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.
|
|
16477
16557
|
*
|
|
16478
|
-
*
|
|
16479
|
-
*
|
|
16480
|
-
*
|
|
16481
|
-
* (e.g. runtime expression evaluation) use this; the executor is responsible
|
|
16482
|
-
* 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.
|
|
16483
16561
|
*/
|
|
16484
|
-
|
|
16485
|
-
|
|
16562
|
+
canLoad(type) {
|
|
16563
|
+
if (type === undefined) return true;
|
|
16564
|
+
return this.#providers.some(provider => provider.sourceDescriptionType === undefined || provider.sourceDescriptionType === type);
|
|
16486
16565
|
}
|
|
16487
16566
|
|
|
16488
16567
|
/**
|
|
@@ -16518,8 +16597,14 @@ class DocumentRegistry {
|
|
|
16518
16597
|
document.isEntry = true;
|
|
16519
16598
|
return document;
|
|
16520
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
|
+
*/
|
|
16521
16605
|
clear() {
|
|
16522
16606
|
this.#documents.clear();
|
|
16607
|
+
this.#loading.clear();
|
|
16523
16608
|
}
|
|
16524
16609
|
|
|
16525
16610
|
/**
|
|
@@ -16648,6 +16733,7 @@ const providerOptionsOverride = {
|
|
|
16648
16733
|
* @public
|
|
16649
16734
|
*/
|
|
16650
16735
|
class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_12__["default"] {
|
|
16736
|
+
sourceDescriptionType = 'arazzo';
|
|
16651
16737
|
#options;
|
|
16652
16738
|
constructor(options = {}) {
|
|
16653
16739
|
super();
|
|
@@ -16783,7 +16869,25 @@ const circularReplacer = ref => new _speclynx_apidom_datamodel__WEBPACK_IMPORTED
|
|
|
16783
16869
|
* Subclasses implement `canProvide()` for format detection and `provide()` for loading.
|
|
16784
16870
|
* @public
|
|
16785
16871
|
*/
|
|
16786
|
-
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
|
+
}
|
|
16787
16891
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DocumentRegistryProvider);
|
|
16788
16892
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
16789
16893
|
/* harmony export */ "circularReplacer", 0, /* binding */ circularReplacer,
|
|
@@ -16855,6 +16959,7 @@ const providerOptionsOverride = {
|
|
|
16855
16959
|
* @public
|
|
16856
16960
|
*/
|
|
16857
16961
|
class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_11__["default"] {
|
|
16962
|
+
sourceDescriptionType = 'openapi';
|
|
16858
16963
|
#options;
|
|
16859
16964
|
constructor(options = {}) {
|
|
16860
16965
|
super();
|
|
@@ -16948,11 +17053,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16948
17053
|
|
|
16949
17054
|
|
|
16950
17055
|
/**
|
|
16951
|
-
* Resolves a runtime expression to its value.
|
|
17056
|
+
* Resolves a runtime expression to its value, or to a Promise of it.
|
|
16952
17057
|
*
|
|
16953
17058
|
* Bridged to a lenient runtime expression evaluator
|
|
16954
17059
|
* (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
|
|
16955
|
-
* 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.
|
|
16956
17064
|
* @public
|
|
16957
17065
|
*/
|
|
16958
17066
|
|
|
@@ -16975,7 +17083,7 @@ class ArazzoValueResolver {
|
|
|
16975
17083
|
/**
|
|
16976
17084
|
* Resolves one authored value element by the rule above.
|
|
16977
17085
|
*/
|
|
16978
|
-
resolveValue(element, resolve) {
|
|
17086
|
+
async resolveValue(element, resolve) {
|
|
16979
17087
|
const value = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
|
|
16980
17088
|
return typeof value === 'string' && (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? resolve(value) : value;
|
|
16981
17089
|
}
|
|
@@ -17054,7 +17162,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
|
|
|
17054
17162
|
*
|
|
17055
17163
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17056
17164
|
*/
|
|
17057
|
-
resolve(parameters, resolve, scope) {
|
|
17165
|
+
async resolve(parameters, resolve, scope) {
|
|
17058
17166
|
const delivery = new _client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
17059
17167
|
if (parameters === undefined) return delivery.toRecord();
|
|
17060
17168
|
// present but scalar: walking it would fail as a bare
|
|
@@ -17118,7 +17226,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
|
|
|
17118
17226
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_4__["default"].AmbiguousDelivery
|
|
17119
17227
|
});
|
|
17120
17228
|
}
|
|
17121
|
-
delivery.set(key, this.resolveValue(parameter.value, resolve));
|
|
17229
|
+
delivery.set(key, await this.resolveValue(parameter.value, resolve));
|
|
17122
17230
|
}
|
|
17123
17231
|
return delivery.toRecord();
|
|
17124
17232
|
}
|
|
@@ -17168,7 +17276,7 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17168
17276
|
* {@link ResolverError}. An output value that is not a valid runtime
|
|
17169
17277
|
* expression throws with reason `ResolverError.InvalidExpression`.
|
|
17170
17278
|
*/
|
|
17171
|
-
resolve(outputs, resolve, scope) {
|
|
17279
|
+
async resolve(outputs, resolve, scope) {
|
|
17172
17280
|
const result = {};
|
|
17173
17281
|
if (outputs === undefined) return result;
|
|
17174
17282
|
// present but not a map: the walk below would fail as a bare
|
|
@@ -17180,7 +17288,14 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17180
17288
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_3__["default"].MalformedOutputs
|
|
17181
17289
|
});
|
|
17182
17290
|
}
|
|
17291
|
+
|
|
17292
|
+
// collected first: `forEach` takes a synchronous callback, and each output
|
|
17293
|
+
// is awaited in turn below.
|
|
17294
|
+
const entries = [];
|
|
17183
17295
|
outputs.forEach((value, key) => {
|
|
17296
|
+
entries.push([key, value]);
|
|
17297
|
+
});
|
|
17298
|
+
for (const [key, value] of entries) {
|
|
17184
17299
|
const name = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(key);
|
|
17185
17300
|
const expression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(value);
|
|
17186
17301
|
if (typeof expression !== 'string' || !(0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_2__.test)(expression)) {
|
|
@@ -17195,12 +17310,12 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
|
|
|
17195
17310
|
// ever created and the output is silently lost — and an object value
|
|
17196
17311
|
// additionally rewrites the record's prototype
|
|
17197
17312
|
Object.defineProperty(result, name, {
|
|
17198
|
-
value: resolve(expression),
|
|
17313
|
+
value: await resolve(expression),
|
|
17199
17314
|
enumerable: true,
|
|
17200
17315
|
writable: true,
|
|
17201
17316
|
configurable: true
|
|
17202
17317
|
});
|
|
17203
|
-
}
|
|
17318
|
+
}
|
|
17204
17319
|
return result;
|
|
17205
17320
|
}
|
|
17206
17321
|
}
|
|
@@ -17286,7 +17401,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17286
17401
|
*
|
|
17287
17402
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17288
17403
|
*/
|
|
17289
|
-
resolve(requestBody, resolve, scope) {
|
|
17404
|
+
async resolve(requestBody, resolve, scope) {
|
|
17290
17405
|
if (requestBody === undefined) return undefined;
|
|
17291
17406
|
|
|
17292
17407
|
// present but scalar: `.payload`, `.replacements` and `.contentType` are
|
|
@@ -17300,7 +17415,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17300
17415
|
});
|
|
17301
17416
|
}
|
|
17302
17417
|
const authoredPayload = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(requestBody.payload);
|
|
17303
|
-
let payload = this.#requireResolved(authoredPayload, this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
17418
|
+
let payload = this.#requireResolved(authoredPayload, await this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
|
|
17304
17419
|
if (requestBody.replacements !== undefined) {
|
|
17305
17420
|
// present but scalar: walking it would fail as a bare
|
|
17306
17421
|
// `TypeError: requestBody.replacements is not iterable`.
|
|
@@ -17315,7 +17430,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17315
17430
|
if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_6__.isPayloadReplacementElement)(replacement)) continue;
|
|
17316
17431
|
const target = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(replacement.target);
|
|
17317
17432
|
if (typeof target !== 'string') continue;
|
|
17318
|
-
const value = this.resolveValue(replacement.value, resolve);
|
|
17433
|
+
const value = await this.resolveValue(replacement.value, resolve);
|
|
17319
17434
|
if (value === undefined) continue;
|
|
17320
17435
|
payload = this.#applyReplacement(payload, target, value, scope);
|
|
17321
17436
|
}
|
|
@@ -17334,19 +17449,26 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17334
17449
|
* objects and arrays. Returns {@link UNRESOLVED} for a bare expression that
|
|
17335
17450
|
* did not resolve, for its container to handle.
|
|
17336
17451
|
*/
|
|
17337
|
-
#resolvePayloadValue(value, tokens, resolve, scope) {
|
|
17452
|
+
async #resolvePayloadValue(value, tokens, resolve, scope) {
|
|
17338
17453
|
if (typeof value === 'string') return this.#resolvePayloadString(value, tokens, resolve, scope);
|
|
17339
17454
|
if (Array.isArray(value)) {
|
|
17340
|
-
|
|
17455
|
+
const items = [];
|
|
17456
|
+
for (const [index, item] of value.entries()) {
|
|
17341
17457
|
const itemTokens = [...tokens, String(index)];
|
|
17342
|
-
const resolved = this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
17343
|
-
|
|
17344
|
-
}
|
|
17458
|
+
const resolved = await this.#resolvePayloadValue(item, itemTokens, resolve, scope);
|
|
17459
|
+
items.push(this.#requireResolved(item, resolved, itemTokens, scope));
|
|
17460
|
+
}
|
|
17461
|
+
return items;
|
|
17345
17462
|
}
|
|
17346
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
|
+
}
|
|
17347
17469
|
// `fromEntries` defines own properties, so an authored `__proto__` key
|
|
17348
17470
|
// stays a plain member instead of replacing the prototype.
|
|
17349
|
-
return Object.fromEntries(
|
|
17471
|
+
return Object.fromEntries(members);
|
|
17350
17472
|
}
|
|
17351
17473
|
return value;
|
|
17352
17474
|
}
|
|
@@ -17356,16 +17478,12 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17356
17478
|
* typed value (or {@link UNRESOLVED}), anything else by tolerant
|
|
17357
17479
|
* interpolation of its embedded `{expression}` occurrences.
|
|
17358
17480
|
*/
|
|
17359
|
-
#resolvePayloadString(value, tokens, resolve, scope) {
|
|
17481
|
+
async #resolvePayloadString(value, tokens, resolve, scope) {
|
|
17360
17482
|
if ((0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.test)(value)) {
|
|
17361
|
-
const resolved = resolve(value);
|
|
17483
|
+
const resolved = await resolve(value);
|
|
17362
17484
|
return resolved === undefined ? UNRESOLVED : resolved;
|
|
17363
17485
|
}
|
|
17364
|
-
|
|
17365
|
-
const resolved = resolve(expression);
|
|
17366
|
-
if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
|
|
17367
|
-
return resolved;
|
|
17368
|
-
}, {
|
|
17486
|
+
const options = {
|
|
17369
17487
|
strict: false,
|
|
17370
17488
|
onError: ({
|
|
17371
17489
|
text
|
|
@@ -17376,7 +17494,24 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
|
|
|
17376
17494
|
reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_7__["default"].InvalidExpression
|
|
17377
17495
|
});
|
|
17378
17496
|
}
|
|
17379
|
-
}
|
|
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);
|
|
17380
17515
|
}
|
|
17381
17516
|
|
|
17382
17517
|
/**
|
|
@@ -17522,7 +17657,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
|
|
|
17522
17657
|
*
|
|
17523
17658
|
* `scope` names the step in a thrown {@link ResolverError}.
|
|
17524
17659
|
*/
|
|
17525
|
-
resolve(parameters, resolve, scope) {
|
|
17660
|
+
async resolve(parameters, resolve, scope) {
|
|
17526
17661
|
const result = {};
|
|
17527
17662
|
if (parameters === undefined) return result;
|
|
17528
17663
|
// present but scalar: walking it would fail as a bare
|
|
@@ -17548,7 +17683,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
|
|
|
17548
17683
|
// ever created and the input is silently lost — and an object value
|
|
17549
17684
|
// additionally rewrites the record's prototype
|
|
17550
17685
|
Object.defineProperty(result, name, {
|
|
17551
|
-
value: this.resolveValue(parameter.value, resolve),
|
|
17686
|
+
value: await this.resolveValue(parameter.value, resolve),
|
|
17552
17687
|
enumerable: true,
|
|
17553
17688
|
writable: true,
|
|
17554
17689
|
configurable: true
|
|
@@ -68219,6 +68354,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68219
68354
|
* receives the runtime expression string and its parsed sub-AST, and returns the
|
|
68220
68355
|
* concrete value.
|
|
68221
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
|
+
*
|
|
68222
68362
|
* @example
|
|
68223
68363
|
* evaluate('$statusCode == 200', {
|
|
68224
68364
|
* resolve: (expression, ast) => (expression === '$statusCode' ? 200 : undefined),
|
|
@@ -68227,11 +68367,41 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68227
68367
|
const evaluate = (condition, {
|
|
68228
68368
|
resolve
|
|
68229
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) => {
|
|
68230
68400
|
if (typeof condition !== 'string') {
|
|
68231
68401
|
throw new TypeError('Criterion condition must be a string');
|
|
68232
68402
|
}
|
|
68233
68403
|
if (typeof resolve !== 'function') {
|
|
68234
|
-
throw new TypeError(
|
|
68404
|
+
throw new TypeError(`${name} requires a "resolve" function in options`);
|
|
68235
68405
|
}
|
|
68236
68406
|
const {
|
|
68237
68407
|
result,
|
|
@@ -68242,7 +68412,17 @@ const evaluate = (condition, {
|
|
|
68242
68412
|
condition
|
|
68243
68413
|
});
|
|
68244
68414
|
}
|
|
68245
|
-
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;
|
|
68246
68426
|
};
|
|
68247
68427
|
const evaluateNode = (node, resolve) => {
|
|
68248
68428
|
switch (node.type) {
|
|
@@ -68251,13 +68431,13 @@ const evaluateNode = (node, resolve) => {
|
|
|
68251
68431
|
case 'UnaryExpression':
|
|
68252
68432
|
return !toBoolean(evaluateNode(node.argument, resolve));
|
|
68253
68433
|
case 'BinaryExpression':
|
|
68254
|
-
return
|
|
68434
|
+
return compare(node.operator, evaluateNode(node.left, resolve), evaluateNode(node.right, resolve));
|
|
68255
68435
|
case 'Literal':
|
|
68256
68436
|
return node.value;
|
|
68257
68437
|
case 'RuntimeExpression':
|
|
68258
|
-
return resolve
|
|
68438
|
+
return resolveValue(resolve, node.text, node.expression);
|
|
68259
68439
|
case 'RuntimeExpressionNavigation':
|
|
68260
|
-
return
|
|
68440
|
+
return navigate(resolveValue(resolve, node.expression.text, node.expression.expression), node.navigation);
|
|
68261
68441
|
default:
|
|
68262
68442
|
throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown AST node type: ${node.type}`);
|
|
68263
68443
|
}
|
|
@@ -68269,18 +68449,47 @@ const evaluateLogical = (node, resolve) => {
|
|
|
68269
68449
|
// '||'
|
|
68270
68450
|
return toBoolean(evaluateNode(node.left, resolve)) || toBoolean(evaluateNode(node.right, resolve));
|
|
68271
68451
|
};
|
|
68272
|
-
|
|
68273
|
-
|
|
68274
|
-
|
|
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) {
|
|
68275
68484
|
if (value == null) return undefined;
|
|
68276
|
-
|
|
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;
|
|
68277
68488
|
}
|
|
68278
68489
|
return value;
|
|
68279
68490
|
};
|
|
68280
|
-
const
|
|
68281
|
-
|
|
68282
|
-
const right = evaluateNode(node.right, resolve);
|
|
68283
|
-
switch (node.operator) {
|
|
68491
|
+
const compare = (operator, left, right) => {
|
|
68492
|
+
switch (operator) {
|
|
68284
68493
|
case '==':
|
|
68285
68494
|
return looseEquals(left, right);
|
|
68286
68495
|
case '!=':
|
|
@@ -68289,9 +68498,9 @@ const evaluateComparison = (node, resolve) => {
|
|
|
68289
68498
|
case '<=':
|
|
68290
68499
|
case '>':
|
|
68291
68500
|
case '>=':
|
|
68292
|
-
return relational(
|
|
68501
|
+
return relational(operator, left, right);
|
|
68293
68502
|
default:
|
|
68294
|
-
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}`);
|
|
68295
68504
|
}
|
|
68296
68505
|
};
|
|
68297
68506
|
|
|
@@ -68301,6 +68510,10 @@ const looseEquals = (a, b) => {
|
|
|
68301
68510
|
const bNull = b === null || b === undefined;
|
|
68302
68511
|
if (aNull || bNull) return aNull && bNull;
|
|
68303
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
|
+
|
|
68304
68517
|
// string comparisons MUST be case insensitive
|
|
68305
68518
|
if (typeof a === 'string' && typeof b === 'string') {
|
|
68306
68519
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -68323,6 +68536,14 @@ const relational = (operator, a, b) => {
|
|
|
68323
68536
|
left = left.toLowerCase();
|
|
68324
68537
|
right = right.toLowerCase();
|
|
68325
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
|
+
}
|
|
68326
68547
|
switch (operator) {
|
|
68327
68548
|
case '<':
|
|
68328
68549
|
return left < right;
|
|
@@ -68336,14 +68557,23 @@ const relational = (operator, a, b) => {
|
|
|
68336
68557
|
return false;
|
|
68337
68558
|
}
|
|
68338
68559
|
};
|
|
68339
|
-
|
|
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));
|
|
68340
68569
|
|
|
68341
68570
|
// A condition passes (truthy) when it evaluates to a truthy value; it fails (falsy)
|
|
68342
68571
|
// on false, null, or a missing (undefined) value.
|
|
68343
68572
|
const toBoolean = value => Boolean(value);
|
|
68344
68573
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (evaluate);
|
|
68345
68574
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
68346
|
-
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
|
|
68575
|
+
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
|
|
68576
|
+
/* harmony export */ "evaluateAsync", 0, /* binding */ evaluateAsync
|
|
68347
68577
|
/* harmony export */ ]);
|
|
68348
68578
|
|
|
68349
68579
|
|
|
@@ -69480,6 +69710,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
69480
69710
|
/* harmony export */ Trace: () => (/* reexport safe */ _parse_trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]),
|
|
69481
69711
|
/* harmony export */ XMLTranslator: () => (/* reexport safe */ _parse_translators_XMLTranslator_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]),
|
|
69482
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),
|
|
69483
69714
|
/* harmony export */ parse: () => (/* reexport safe */ _parse_index_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
69484
69715
|
/* harmony export */ test: () => (/* reexport safe */ _test_index_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])
|
|
69485
69716
|
/* harmony export */ });
|
|
@@ -69543,6 +69774,36 @@ const cst = nodeType => {
|
|
|
69543
69774
|
/* harmony export */ ]);
|
|
69544
69775
|
|
|
69545
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
|
+
|
|
69546
69807
|
/***/ },
|
|
69547
69808
|
|
|
69548
69809
|
/***/ 23937
|
|
@@ -69556,8 +69817,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
69556
69817
|
/* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
|
|
69557
69818
|
/* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38550);
|
|
69558
69819
|
/* harmony import */ var _translators_ASTTranslator_index_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4586);
|
|
69559
|
-
/* harmony import */ var
|
|
69560
|
-
/* 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
|
+
|
|
69561
69824
|
|
|
69562
69825
|
|
|
69563
69826
|
|
|
@@ -69576,8 +69839,9 @@ const parse = (condition, {
|
|
|
69576
69839
|
try {
|
|
69577
69840
|
const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
|
|
69578
69841
|
if (translator) parser.ast = translator;
|
|
69842
|
+
parser.callbacks['runtime-expression-operand'] = _callbacks_operand_mjs__WEBPACK_IMPORTED_MODULE_3__["default"];
|
|
69579
69843
|
if (stats) parser.stats = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Stats();
|
|
69580
|
-
if (trace) parser.trace = new
|
|
69844
|
+
if (trace) parser.trace = new _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
69581
69845
|
const result = parser.parse(grammar, startRule, condition);
|
|
69582
69846
|
return {
|
|
69583
69847
|
result,
|
|
@@ -69586,7 +69850,7 @@ const parse = (condition, {
|
|
|
69586
69850
|
trace: parser.trace
|
|
69587
69851
|
};
|
|
69588
69852
|
} catch (error) {
|
|
69589
|
-
throw new
|
|
69853
|
+
throw new _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_5__["default"]('Unexpected error during Arazzo Criterion parsing', {
|
|
69590
69854
|
cause: error,
|
|
69591
69855
|
condition
|
|
69592
69856
|
});
|
|
@@ -69687,6 +69951,8 @@ class ASTTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
|
|
|
69687
69951
|
__webpack_require__.r(__webpack_exports__);
|
|
69688
69952
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
69689
69953
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
69954
|
+
/* harmony export */ isValidOperand: () => (/* binding */ isValidOperand),
|
|
69955
|
+
/* harmony export */ parseOperand: () => (/* binding */ parseOperand),
|
|
69690
69956
|
/* harmony export */ transformCSTtoAST: () => (/* binding */ transformCSTtoAST)
|
|
69691
69957
|
/* harmony export */ });
|
|
69692
69958
|
/* harmony import */ var _swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26847);
|
|
@@ -69716,8 +69982,12 @@ const OPERAND_TYPES = new Set(['paren-expr', 'comparison-expr', 'test-expr', 'ru
|
|
|
69716
69982
|
* @swaggerexpert/arazzo-runtime-expression.
|
|
69717
69983
|
*/
|
|
69718
69984
|
const splitAtRuntimeExpression = operand => {
|
|
69719
|
-
|
|
69720
|
-
|
|
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) {
|
|
69721
69991
|
return {
|
|
69722
69992
|
expressionText: operand,
|
|
69723
69993
|
navigationText: ''
|
|
@@ -69726,15 +69996,29 @@ const splitAtRuntimeExpression = operand => {
|
|
|
69726
69996
|
|
|
69727
69997
|
// A failing parse reports how far it matched; walk down from there to the
|
|
69728
69998
|
// longest prefix that parses cleanly (robust against stopping mid-rule).
|
|
69729
|
-
for (let n = full.
|
|
69730
|
-
if ((
|
|
69999
|
+
for (let n = full.maxMatched; n > 0; n -= 1) {
|
|
70000
|
+
if (isRuntimeExpression(operand.slice(0, n)).success) {
|
|
69731
70001
|
return {
|
|
69732
70002
|
expressionText: operand.slice(0, n),
|
|
69733
70003
|
navigationText: operand.slice(n)
|
|
69734
70004
|
};
|
|
69735
70005
|
}
|
|
69736
70006
|
}
|
|
69737
|
-
|
|
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;
|
|
69738
70022
|
};
|
|
69739
70023
|
|
|
69740
70024
|
/**
|
|
@@ -69761,10 +70045,12 @@ const parseNavigation = navigationText => {
|
|
|
69761
70045
|
* both already parsed. `navigation` is an empty array when there are no accessors.
|
|
69762
70046
|
*/
|
|
69763
70047
|
const parseOperand = operand => {
|
|
70048
|
+
const split = splitAtRuntimeExpression(operand);
|
|
70049
|
+
if (!split) throw new Error(`Operand is not a valid runtime expression: "${operand}"`);
|
|
69764
70050
|
const {
|
|
69765
70051
|
expressionText,
|
|
69766
70052
|
navigationText
|
|
69767
|
-
} =
|
|
70053
|
+
} = split;
|
|
69768
70054
|
const runtimeExpression = {
|
|
69769
70055
|
type: 'RuntimeExpression',
|
|
69770
70056
|
text: expressionText,
|
|
@@ -70080,22 +70366,38 @@ const grammar = new _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]();
|
|
|
70080
70366
|
* In strict mode (default) the whole string must parse as an expression-string,
|
|
70081
70367
|
* otherwise an empty array is returned. With `strict: false`, any `{` not followed
|
|
70082
70368
|
* by `$` is treated as literal text and every valid `{$...}` span is extracted;
|
|
70083
|
-
* 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.
|
|
70084
70373
|
*
|
|
70085
70374
|
* @example
|
|
70086
70375
|
*
|
|
70087
70376
|
* extract('{$url}'); // => ['$url']
|
|
70088
70377
|
* extract('id={$inputs.id}&name={$inputs.name}'); // => ['$inputs.id', '$inputs.name']
|
|
70089
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.}'
|
|
70090
70383
|
*/
|
|
70091
70384
|
const extract = (str, {
|
|
70092
|
-
strict = true
|
|
70385
|
+
strict = true,
|
|
70386
|
+
onError
|
|
70093
70387
|
} = {}) => {
|
|
70094
70388
|
if (typeof str !== 'string') {
|
|
70095
70389
|
return [];
|
|
70096
70390
|
}
|
|
70097
70391
|
if (strict === false) {
|
|
70098
|
-
|
|
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;
|
|
70099
70401
|
}
|
|
70100
70402
|
const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
|
|
70101
70403
|
parser.ast = new _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
@@ -71641,8 +71943,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
71641
71943
|
/* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71652);
|
|
71642
71944
|
/* harmony import */ var _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35963);
|
|
71643
71945
|
/* harmony import */ var _scanner_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21425);
|
|
71644
|
-
/* harmony import */ var _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4089);
|
|
71645
|
-
|
|
71646
71946
|
|
|
71647
71947
|
|
|
71648
71948
|
|
|
@@ -71719,31 +72019,7 @@ const interpolate = (template, resolver, {
|
|
|
71719
72019
|
if (token.type === 'expression') {
|
|
71720
72020
|
output += stringify(resolver(token.expression));
|
|
71721
72021
|
} else if (token.type === 'invalid') {
|
|
71722
|
-
const
|
|
71723
|
-
text,
|
|
71724
|
-
expression,
|
|
71725
|
-
start,
|
|
71726
|
-
length,
|
|
71727
|
-
terminated
|
|
71728
|
-
} = token;
|
|
71729
|
-
let error;
|
|
71730
|
-
const replacement = onError({
|
|
71731
|
-
text,
|
|
71732
|
-
start,
|
|
71733
|
-
length,
|
|
71734
|
-
// created lazily - capturing a stack trace for every invalid attempt is costly
|
|
71735
|
-
get error() {
|
|
71736
|
-
if (error === undefined) {
|
|
71737
|
-
const message = terminated ? `Invalid runtime expression "${text}" at position ${start}` : `Unterminated runtime expression "${text}" at position ${start}`;
|
|
71738
|
-
error = new _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__["default"](message, {
|
|
71739
|
-
runtimeExpression: expression,
|
|
71740
|
-
start,
|
|
71741
|
-
length
|
|
71742
|
-
});
|
|
71743
|
-
}
|
|
71744
|
-
return error;
|
|
71745
|
-
}
|
|
71746
|
-
});
|
|
72022
|
+
const replacement = onError((0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__.invalidAttemptInfo)(token));
|
|
71747
72023
|
if (typeof replacement !== 'string') {
|
|
71748
72024
|
throw new TypeError('onError must return a string');
|
|
71749
72025
|
}
|
|
@@ -71880,7 +72156,8 @@ const parse = (runtimeExpression, {
|
|
|
71880
72156
|
__webpack_require__.r(__webpack_exports__);
|
|
71881
72157
|
class Expectations extends Array {
|
|
71882
72158
|
toString() {
|
|
71883
|
-
|
|
72159
|
+
// JSON string syntax, so that entries such as '"' and '\\' stay unambiguous
|
|
72160
|
+
return this.map(c => JSON.stringify(String(c))).join(', ');
|
|
71884
72161
|
}
|
|
71885
72162
|
}
|
|
71886
72163
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Expectations);
|
|
@@ -71897,34 +72174,226 @@ class Expectations extends Array {
|
|
|
71897
72174
|
"use strict";
|
|
71898
72175
|
__webpack_require__.r(__webpack_exports__);
|
|
71899
72176
|
/* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
|
|
71900
|
-
/* 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);
|
|
71901
72179
|
|
|
71902
72180
|
|
|
71903
|
-
|
|
71904
|
-
|
|
71905
|
-
|
|
71906
|
-
|
|
71907
|
-
|
|
71908
|
-
|
|
71909
|
-
|
|
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
|
+
};
|
|
71910
72204
|
|
|
71911
|
-
|
|
71912
|
-
|
|
71913
|
-
|
|
71914
|
-
|
|
71915
|
-
|
|
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
|
+
};
|
|
71916
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
|
+
};
|
|
71917
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;
|
|
71918
72297
|
|
|
71919
|
-
|
|
71920
|
-
|
|
71921
|
-
|
|
71922
|
-
|
|
71923
|
-
|
|
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
|
+
}
|
|
71924
72373
|
}
|
|
71925
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));
|
|
71926
72395
|
}
|
|
71927
|
-
return new
|
|
72396
|
+
return new _Expectations_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](...expectations);
|
|
71928
72397
|
}
|
|
71929
72398
|
}
|
|
71930
72399
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Trace);
|
|
@@ -72328,6 +72797,8 @@ class XMLTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
|
|
|
72328
72797
|
"use strict";
|
|
72329
72798
|
__webpack_require__.r(__webpack_exports__);
|
|
72330
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
|
+
|
|
72331
72802
|
|
|
72332
72803
|
/**
|
|
72333
72804
|
* Tolerantly scan a string containing embedded {expression} patterns.
|
|
@@ -72410,9 +72881,43 @@ const scan = str => {
|
|
|
72410
72881
|
}
|
|
72411
72882
|
return tokens;
|
|
72412
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
|
+
};
|
|
72413
72917
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (scan);
|
|
72414
72918
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
72415
|
-
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
|
|
72919
|
+
/* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
|
|
72920
|
+
/* harmony export */ "invalidAttemptInfo", 0, /* binding */ invalidAttemptInfo
|
|
72416
72921
|
/* harmony export */ ]);
|
|
72417
72922
|
|
|
72418
72923
|
|