@usearazzo/runner 1.0.1-alpha.32 → 1.0.1-alpha.34

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +10 -1
  3. package/dist/arazzo-runner.browser.js +1789 -403
  4. package/dist/arazzo-runner.browser.min.js +1 -1
  5. package/package.json +18 -17
  6. package/src/ArazzoRunner.cjs +26 -3
  7. package/src/ArazzoRunner.mjs +26 -3
  8. package/src/action/ActionResolver.cjs +13 -12
  9. package/src/action/ActionResolver.mjs +13 -12
  10. package/src/client/OpenAPIOperationResponse.cjs +9 -0
  11. package/src/client/OpenAPIOperationResponse.mjs +9 -0
  12. package/src/criterion/CriterionEvaluator.cjs +13 -8
  13. package/src/criterion/CriterionEvaluator.mjs +13 -8
  14. package/src/criterion/SimpleCriterionEvaluator.cjs +5 -3
  15. package/src/criterion/SimpleCriterionEvaluator.mjs +6 -4
  16. package/src/document/APIDocument.cjs +53 -0
  17. package/src/document/APIDocument.mjs +53 -0
  18. package/src/executor/OpenAPIOperationExecutor.cjs +66 -6
  19. package/src/executor/OpenAPIOperationExecutor.mjs +66 -6
  20. package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +1 -1
  21. package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +1 -1
  22. package/src/executor/StepExecutor.cjs +34 -15
  23. package/src/executor/StepExecutor.mjs +34 -15
  24. package/src/executor/StepRetryRunner.cjs +5 -3
  25. package/src/executor/StepRetryRunner.mjs +5 -3
  26. package/src/executor/StepTransitionInterpreter.cjs +1 -1
  27. package/src/executor/StepTransitionInterpreter.mjs +1 -1
  28. package/src/executor/WorkflowCallStack.cjs +1 -1
  29. package/src/executor/WorkflowCallStack.mjs +1 -1
  30. package/src/executor/WorkflowExecutor.cjs +277 -61
  31. package/src/executor/WorkflowExecutor.mjs +277 -61
  32. package/src/expression/RuntimeExpressionEvaluator.cjs +52 -9
  33. package/src/expression/RuntimeExpressionEvaluator.mjs +52 -9
  34. package/src/index.cjs +7 -0
  35. package/src/index.mjs +2 -0
  36. package/src/observability/ArazzoRunnerEvent.cjs +5 -0
  37. package/src/observability/ArazzoRunnerEvent.mjs +1 -0
  38. package/src/observability/DocumentRegistryEvent.cjs +5 -0
  39. package/src/observability/DocumentRegistryEvent.mjs +1 -0
  40. package/src/observability/EventChannel.cjs +96 -0
  41. package/src/observability/EventChannel.mjs +91 -0
  42. package/src/observability/OpenAPIOperationEvent.cjs +5 -0
  43. package/src/observability/OpenAPIOperationEvent.mjs +1 -0
  44. package/src/observability/Redactor.cjs +213 -0
  45. package/src/observability/Redactor.mjs +208 -0
  46. package/src/observability/WorkflowExecutionEvent.cjs +5 -0
  47. package/src/observability/WorkflowExecutionEvent.mjs +1 -0
  48. package/src/registry/DocumentRegistry.cjs +57 -11
  49. package/src/registry/DocumentRegistry.mjs +57 -11
  50. package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +21 -0
  51. package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +22 -1
  52. package/src/registry/providers/DocumentRegistryProvider.cjs +33 -1
  53. package/src/registry/providers/DocumentRegistryProvider.mjs +33 -1
  54. package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +28 -5
  55. package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +28 -5
  56. package/src/resolver/ArazzoValueResolver.cjs +6 -3
  57. package/src/resolver/ArazzoValueResolver.mjs +6 -3
  58. package/src/resolver/OpenAPIOperationParameterResolver.cjs +2 -2
  59. package/src/resolver/OpenAPIOperationParameterResolver.mjs +2 -2
  60. package/src/resolver/OutputResolver.cjs +10 -3
  61. package/src/resolver/OutputResolver.mjs +10 -3
  62. package/src/resolver/RequestBodyResolver.cjs +37 -17
  63. package/src/resolver/RequestBodyResolver.mjs +37 -17
  64. package/src/resolver/WorkflowParameterResolver.cjs +2 -2
  65. package/src/resolver/WorkflowParameterResolver.mjs +2 -2
  66. package/types/runner.d.ts +788 -41
@@ -8859,8 +8859,9 @@ __webpack_require__.r(__webpack_exports__);
8859
8859
  * Every option is a seam of a building block the runner wires: `registry` is
8860
8860
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
8861
8861
  * default providers when omitted), `reference` goes to everything the runner
8862
- * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
8863
- * the {@link OpenAPIOperationExecutor}, and the rest go to the
8862
+ * builds that retrieves documents, `httpClient`, `requestInterceptor` and
8863
+ * `captureBodies` go to the {@link OpenAPIOperationExecutor}, and the rest go
8864
+ * to the
8864
8865
  * {@link WorkflowExecutor}.
8865
8866
  *
8866
8867
  * Retrieving documents and calling APIs are separate on purpose: `reference`
@@ -8901,10 +8902,24 @@ class ArazzoRunner {
8901
8902
  static async load(uri, options = {}) {
8902
8903
  // `resolve` only, whatever else the given object carries
8903
8904
  const referenceOptions = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['resolve'], options.reference ?? {});
8905
+ // source maps need the non-strict parsers, which are the ones that keep
8906
+ // positions
8907
+ const providerOptions = options.sourceMap ? {
8908
+ ...referenceOptions,
8909
+ parse: {
8910
+ parserOpts: {
8911
+ sourceMap: true,
8912
+ strict: false
8913
+ }
8914
+ }
8915
+ } : referenceOptions;
8904
8916
  const {
8905
8917
  registry = new _registry_DocumentRegistry_ts__WEBPACK_IMPORTED_MODULE_1__["default"]({
8906
- providers: [new _registry_providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](referenceOptions), new _registry_providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"](referenceOptions)]
8918
+ providers: [new _registry_providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](providerOptions), new _registry_providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"](providerOptions)],
8919
+ observer: options.observer,
8920
+ now: options.now
8907
8921
  }),
8922
+ sourceMap: _sourceMap,
8908
8923
  ...rest
8909
8924
  } = options;
8910
8925
  // acquiring a second entry would pin it for good and, through the LRU
@@ -8936,6 +8951,7 @@ class ArazzoRunner {
8936
8951
  reference,
8937
8952
  httpClient,
8938
8953
  requestInterceptor,
8954
+ captureBodies,
8939
8955
  ...workflowExecutorOptions
8940
8956
  } = options;
8941
8957
 
@@ -8949,9 +8965,16 @@ class ArazzoRunner {
8949
8965
 
8950
8966
  // `resolve` only, whatever else the given object carries
8951
8967
  const referenceOptions = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['resolve'], reference ?? {});
8968
+ const {
8969
+ observer,
8970
+ now
8971
+ } = workflowExecutorOptions;
8952
8972
  const operationExecutor = new _executor_OpenAPIOperationExecutor_ts__WEBPACK_IMPORTED_MODULE_9__["default"]({
8953
8973
  httpClient,
8954
8974
  requestInterceptor,
8975
+ captureBodies,
8976
+ observer,
8977
+ now,
8955
8978
  operationNormalizer: new _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_5__["default"]({
8956
8979
  openapi2: new _normalizer_OpenAPI2OperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_6__["default"](referenceOptions),
8957
8980
  openapi30: new _normalizer_OpenAPI30OperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_7__["default"](referenceOptions),
@@ -9003,12 +9026,13 @@ __webpack_require__.r(__webpack_exports__);
9003
9026
 
9004
9027
 
9005
9028
  /**
9006
- * Determines whether a single criterion of an action is met. Receives the
9007
- * action declaring the criterion, so a caller can attribute the outcome to it.
9029
+ * Determines whether a single criterion of an action is met, or resolves to
9030
+ * whether it is. Receives the action declaring the criterion, so a caller can
9031
+ * attribute the outcome to it.
9008
9032
  *
9009
9033
  * Bridged to a criterion evaluator
9010
- * (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`); an
9011
- * unresolvable/failing criterion is `false`, not an error.
9034
+ * (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
9035
+ * an unresolvable/failing criterion is `false`, not an error.
9012
9036
  * @public
9013
9037
  */
9014
9038
 
@@ -9063,12 +9087,12 @@ class ActionResolver {
9063
9087
  * `end` its author was reaching for would otherwise never happen without a
9064
9088
  * word said about why.
9065
9089
  */
9066
- resolveOnSuccess(actions, isCriterionMet, scope) {
9090
+ async resolveOnSuccess(actions, isCriterionMet, scope) {
9067
9091
  // safe: `#resolveAll` validates every entry as *a* Success/Failure Action
9068
9092
  // Object, not one matching this list's own field, but a well-formed
9069
9093
  // `StepOnSuccessElement` only ever refracts Success Action entries — the
9070
9094
  // apidom refractor types list entries positionally at parse time.
9071
- return this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
9095
+ return await this.#resolveAll(actions, isCriterionMet, 'onSuccess', scope);
9072
9096
  }
9073
9097
 
9074
9098
  /**
@@ -9077,9 +9101,9 @@ class ActionResolver {
9077
9101
  * Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
9078
9102
  * see there for the full rationale — mirrored for the step's other list.
9079
9103
  */
9080
- resolveOnFailure(actions, isCriterionMet, scope) {
9104
+ async resolveOnFailure(actions, isCriterionMet, scope) {
9081
9105
  // safe: see the same-named comment in `resolveOnSuccess` above.
9082
- return this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
9106
+ return await this.#resolveAll(actions, isCriterionMet, 'onFailure', scope);
9083
9107
  }
9084
9108
 
9085
9109
  /**
@@ -9092,7 +9116,7 @@ class ActionResolver {
9092
9116
  * element's own type no longer distinguishes them. Baked in by the public
9093
9117
  * method rather than taken from the caller.
9094
9118
  */
9095
- #resolveAll(actions, isCriterionMet, field, scope) {
9119
+ async #resolveAll(actions, isCriterionMet, field, scope) {
9096
9120
  if (actions === undefined) return [];
9097
9121
  // present but scalar: walking it would fail as a bare
9098
9122
  // `TypeError: actions is not iterable`.
@@ -9112,7 +9136,7 @@ class ActionResolver {
9112
9136
  reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_2__["default"].MalformedActionEntry
9113
9137
  });
9114
9138
  }
9115
- if (this.#criteriaMet(action, isCriterionMet, scope)) {
9139
+ if (await this.#criteriaMet(action, isCriterionMet, scope)) {
9116
9140
  matched.push(action);
9117
9141
  }
9118
9142
  }
@@ -9129,7 +9153,7 @@ class ActionResolver {
9129
9153
  * not say what its author meant, the same as an unrecognized entry in the
9130
9154
  * action list itself.
9131
9155
  */
9132
- #criteriaMet(action, isCriterionMet, scope) {
9156
+ async #criteriaMet(action, isCriterionMet, scope) {
9133
9157
  const criteria = action.criteria;
9134
9158
  if (criteria === undefined) return true;
9135
9159
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isArrayElement)(criteria)) {
@@ -9150,7 +9174,7 @@ class ActionResolver {
9150
9174
  }
9151
9175
  // every criterion is evaluated, not only up to the first unmet one, so
9152
9176
  // a predicate that records outcomes sees the whole list.
9153
- if (!isCriterionMet(criterion, action)) met = false;
9177
+ if (!(await isCriterionMet(criterion, action))) met = false;
9154
9178
  }
9155
9179
  return met;
9156
9180
  }
@@ -9683,6 +9707,15 @@ class OpenAPIOperationResponse {
9683
9707
  this.request = raw.request;
9684
9708
  }
9685
9709
 
9710
+ /**
9711
+ * The body's size in bytes, as read: after the transport decoded any
9712
+ * `Content-Encoding`, so a compressed body counts at its decoded size.
9713
+ */
9714
+ get size() {
9715
+ // a string content encodes back to exactly the bytes received
9716
+ return typeof this.#content === 'string' ? new TextEncoder().encode(this.#content).length : this.#content.length;
9717
+ }
9718
+
9686
9719
  /**
9687
9720
  * The body as text, like `Response.text()`; `''` when there is none.
9688
9721
  */
@@ -10010,14 +10043,19 @@ __webpack_require__.r(__webpack_exports__);
10010
10043
 
10011
10044
 
10012
10045
  /**
10013
- * Resolves a runtime expression to a value during criterion evaluation.
10046
+ * Resolves a runtime expression to a value, or to a Promise of it, during
10047
+ * criterion evaluation. The result is awaited, so a synchronous resolver works
10048
+ * too.
10014
10049
  *
10015
10050
  * Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
10016
10051
  * expressions embedded in a `simple` condition. It should resolve leniently —
10017
10052
  * an unresolvable reference returning `undefined` fails the criterion rather
10018
10053
  * than throwing (a common way to drive it is
10019
10054
  * `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
10020
- * lenient evaluator).
10055
+ * lenient evaluator). An error it throws or rejects with — such as the load
10056
+ * error of a `$sourceDescriptions` document that cannot be loaded — is not a
10057
+ * {@link CriterionEvaluationError}, so it propagates instead of failing the
10058
+ * criterion.
10021
10059
  * @public
10022
10060
  */
10023
10061
 
@@ -10093,7 +10131,7 @@ class CriterionEvaluator {
10093
10131
  * the expressions embedded in the condition; for the other types it resolves
10094
10132
  * the criterion's `context` expression that the condition is applied to.
10095
10133
  */
10096
- evaluate(criterion, resolve) {
10134
+ async evaluate(criterion, resolve) {
10097
10135
  if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_2__.isCriterionElement)(criterion)) {
10098
10136
  throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"]('Element is not a Criterion Object', {
10099
10137
  reason: _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"].InvalidCriterion
@@ -10113,23 +10151,23 @@ class CriterionEvaluator {
10113
10151
  try {
10114
10152
  switch (type) {
10115
10153
  case 'simple':
10116
- met = this.#simple.evaluate(condition, resolve);
10154
+ met = await this.#simple.evaluate(condition, resolve);
10117
10155
  break;
10118
10156
  case 'regex':
10119
- met = this.#regex.evaluate(condition, this.#resolveContext(criterion, type, resolve));
10157
+ met = this.#regex.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
10120
10158
  break;
10121
10159
  case 'jsonpath':
10122
10160
  // only rfc9535 is supported, Arazzo 1.1.0's default, so an omitted
10123
10161
  // version is accepted. draft-goessner has different semantics and is
10124
10162
  // rejected rather than mis-evaluated.
10125
10163
  this.#requireVersion(criterion, type, condition, 'rfc9535');
10126
- met = this.#jsonpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
10164
+ met = this.#jsonpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
10127
10165
  break;
10128
10166
  case 'xpath':
10129
10167
  // only XPath 3.1 is supported; xpath-31 is Arazzo 1.1.0's default, so
10130
10168
  // an omitted version is accepted. Older versions are rejected.
10131
10169
  this.#requireVersion(criterion, type, condition, 'xpath-31');
10132
- met = this.#xpath.evaluate(condition, this.#resolveContext(criterion, type, resolve));
10170
+ met = this.#xpath.evaluate(condition, await this.#resolveContext(criterion, type, resolve));
10133
10171
  break;
10134
10172
  default:
10135
10173
  throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Unknown criterion type "${type}"`, {
@@ -10230,7 +10268,7 @@ class CriterionEvaluator {
10230
10268
  * `jsonpath`, `xpath`) must declare one; a criterion of such a type without a
10231
10269
  * `context` throws a {@link CriterionError}.
10232
10270
  */
10233
- #resolveContext(criterion, type, resolve) {
10271
+ async #resolveContext(criterion, type, resolve) {
10234
10272
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isStringElement)(criterion.context)) {
10235
10273
  throw new _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Criterion type "${type}" requires a "context"`, {
10236
10274
  type,
@@ -10399,7 +10437,9 @@ __webpack_require__.r(__webpack_exports__);
10399
10437
  * unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
10400
10438
  * loose/case-insensitive comparison, and member/index navigation are delegated
10401
10439
  * to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
10402
- * resolved through the supplied resolver.
10440
+ * resolved through the supplied resolver and awaited in turn. `&&` and `||`
10441
+ * short-circuit, so an operand that cannot change the outcome is never
10442
+ * resolved.
10403
10443
  *
10404
10444
  * An operand that resolves to `undefined` (a lenient miss) does not throw; it is
10405
10445
  * compared per the library's rules (e.g. `undefined == x` and relational
@@ -10413,9 +10453,9 @@ class SimpleCriterionEvaluator {
10413
10453
  * Evaluates the simple `condition`, resolving each embedded runtime
10414
10454
  * expression via `resolve`.
10415
10455
  */
10416
- evaluate(condition, resolve) {
10456
+ async evaluate(condition, resolve) {
10417
10457
  try {
10418
- return (0,_swaggerexpert_arazzo_criterion__WEBPACK_IMPORTED_MODULE_0__.evaluate)(condition, {
10458
+ return await (0,_swaggerexpert_arazzo_criterion__WEBPACK_IMPORTED_MODULE_0__.evaluateAsync)(condition, {
10419
10459
  resolve
10420
10460
  });
10421
10461
  } catch (error) {
@@ -10575,6 +10615,23 @@ __webpack_require__.r(__webpack_exports__);
10575
10615
  /* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(87659);
10576
10616
 
10577
10617
 
10618
+ /**
10619
+ * A position in a document, as in the Language Server Protocol: a 0-based
10620
+ * line, and a 0-based character offset within it in UTF-16 code units.
10621
+ * @public
10622
+ */
10623
+
10624
+ /**
10625
+ * A range in a document, as in the Language Server Protocol: from `start` to
10626
+ * `end`, the shape the validator's diagnostics use.
10627
+ * @public
10628
+ */
10629
+
10630
+ /**
10631
+ * Where an element is written.
10632
+ * @public
10633
+ */
10634
+
10578
10635
  /**
10579
10636
  * Base document held by the document registry.
10580
10637
  * @public
@@ -10587,6 +10644,42 @@ class APIDocument {
10587
10644
  this.parseResult = parseResult;
10588
10645
  }
10589
10646
 
10647
+ /**
10648
+ * Where an element of this document, or one it references, is written, as
10649
+ * the registry provider recorded it when it loaded the document: the
10650
+ * document it came from (its `ref-origin`) when it came through a
10651
+ * reference, and its JSON Pointer there.
10652
+ */
10653
+ locationOf(element) {
10654
+ const origin = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(element.meta.get('ref-origin'));
10655
+ const jsonPointer = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(element.meta.get('json-pointer'));
10656
+ const {
10657
+ startLine,
10658
+ startCharacter,
10659
+ endLine,
10660
+ endCharacter
10661
+ } = element;
10662
+ return {
10663
+ uri: typeof origin === 'string' ? origin : this.uri,
10664
+ ...(typeof jsonPointer === 'string' && {
10665
+ jsonPointer
10666
+ }),
10667
+ // a source-mapped parse positions every element fully, any other none
10668
+ ...(startLine !== undefined && {
10669
+ range: {
10670
+ start: {
10671
+ line: startLine,
10672
+ character: startCharacter
10673
+ },
10674
+ end: {
10675
+ line: endLine,
10676
+ character: endCharacter
10677
+ }
10678
+ }
10679
+ })
10680
+ };
10681
+ }
10682
+
10590
10683
  /**
10591
10684
  * Returns a JSON-serializable representation of the document's API element.
10592
10685
  * Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
@@ -11647,6 +11740,7 @@ __webpack_require__.r(__webpack_exports__);
11647
11740
  /* harmony import */ var _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(87864);
11648
11741
  /* harmony import */ var _assembler_OpenAPIDocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(6898);
11649
11742
  /* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(81763);
11743
+ /* harmony import */ var _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(12993);
11650
11744
 
11651
11745
 
11652
11746
 
@@ -11666,6 +11760,7 @@ __webpack_require__.r(__webpack_exports__);
11666
11760
 
11667
11761
 
11668
11762
 
11763
+
11669
11764
  /**
11670
11765
  * The Arazzo step a request is issued for: its `stepId`, and the `workflowId`
11671
11766
  * of the workflow it belongs to when the caller names one (step ids are only
@@ -11812,6 +11907,8 @@ class OpenAPIOperationExecutor {
11812
11907
  #operationExtractor;
11813
11908
  #operationNormalizer;
11814
11909
  #documentAssembler;
11910
+ #captureBodies;
11911
+ #events;
11815
11912
  constructor(options = {}) {
11816
11913
  this.#httpClient = options.httpClient ?? _client_HTTPClientFetch_ts__WEBPACK_IMPORTED_MODULE_10__["default"];
11817
11914
  this.#requestInterceptor = options.requestInterceptor;
@@ -11819,6 +11916,11 @@ class OpenAPIOperationExecutor {
11819
11916
  this.#operationExtractor = options.operationExtractor ?? new _extractor_OpenAPIOperationExtractor_ts__WEBPACK_IMPORTED_MODULE_12__["default"]();
11820
11917
  this.#operationNormalizer = options.operationNormalizer ?? new _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_13__["default"]();
11821
11918
  this.#documentAssembler = options.documentAssembler ?? new _assembler_OpenAPIDocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_14__["default"]();
11919
+ this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_16__["default"].open({
11920
+ observer: options.observer,
11921
+ now: options.now
11922
+ });
11923
+ this.#captureBodies = options.captureBodies ?? false;
11822
11924
  }
11823
11925
 
11824
11926
  /**
@@ -11839,17 +11941,19 @@ class OpenAPIOperationExecutor {
11839
11941
  // the legacy id (`{method}-{path}`) matches regardless of an explicit
11840
11942
  // `operationId` in the assembled document
11841
11943
  const operationId = (0,_vendor_swagger_client_mjs__WEBPACK_IMPORTED_MODULE_8__.idFromPathMethodLegacy)((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('path')), (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.meta.get('http-method')));
11842
- const normalizedOperation = await this.#operationNormalizer.normalize(operation, locator.document);
11843
- const assembled = this.#documentAssembler.assemble(normalizedOperation, locator.document);
11844
-
11845
11944
  // the interceptor and step are consumed here, the target always comes from
11846
11945
  // the locator, and the transport is the httpClient, so none of these
11847
11946
  // reach buildRequest
11848
11947
  const {
11849
11948
  requestInterceptor,
11850
- step
11949
+ step,
11950
+ runId
11851
11951
  } = executeOptions;
11852
- const rest = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['requestInterceptor', 'step', 'operationId', 'operationPath', 'userFetch', 'responseInterceptor'], executeOptions);
11952
+ // the operation as extracted from its own document, before normalizing
11953
+ // copies it, carries where it is written; located once, and only for an
11954
+ // observer.
11955
+ let located;
11956
+ const location = () => located ??= locator.document.locationOf(operation);
11853
11957
  const declaredOperationId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(operation.operationId);
11854
11958
  const context = {
11855
11959
  operation: {
@@ -11872,6 +11976,27 @@ class OpenAPIOperationExecutor {
11872
11976
  }
11873
11977
  })
11874
11978
  };
11979
+ this.#events?.emit({
11980
+ type: 'openapi-operation-normalize-start',
11981
+ ...context,
11982
+ runId,
11983
+ location: location()
11984
+ });
11985
+ const normalizedOperation = await this.#operationNormalizer.normalize(operation, locator.document);
11986
+ this.#events?.emit({
11987
+ type: 'openapi-operation-normalize-settled',
11988
+ ...context,
11989
+ runId,
11990
+ location: location()
11991
+ });
11992
+ const assembled = this.#documentAssembler.assemble(normalizedOperation, locator.document);
11993
+ this.#events?.emit({
11994
+ type: 'openapi-operation-assembled',
11995
+ ...context,
11996
+ runId,
11997
+ location: location()
11998
+ });
11999
+ const rest = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['requestInterceptor', 'step', 'runId', 'operationId', 'operationPath', 'userFetch', 'responseInterceptor'], executeOptions);
11875
12000
 
11876
12001
  // each step derives the next options rather than editing in place
11877
12002
  const withServer = this.#applyServerOptions(rest, normalizedOperation, locator.document);
@@ -11915,6 +12040,20 @@ class OpenAPIOperationExecutor {
11915
12040
  },
11916
12041
  body: request.body
11917
12042
  };
12043
+ this.#events?.emit({
12044
+ type: 'openapi-operation-request-start',
12045
+ ...context,
12046
+ runId,
12047
+ location: location(),
12048
+ request: {
12049
+ method: request.method,
12050
+ url: request.url,
12051
+ headers: request.headers,
12052
+ ...(this.#captureBodies ? {
12053
+ body: request.body
12054
+ } : {})
12055
+ }
12056
+ });
11918
12057
  let rawResponse;
11919
12058
  try {
11920
12059
  rawResponse = await this.#httpClient(request);
@@ -11924,7 +12063,22 @@ class OpenAPIOperationExecutor {
11924
12063
  cause: error
11925
12064
  });
11926
12065
  }
11927
- return this.#responseNormalizer.normalize(rawResponse, requestInfo);
12066
+ const response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
12067
+ this.#events?.emit({
12068
+ type: 'openapi-operation-request-settled',
12069
+ ...context,
12070
+ runId,
12071
+ location: location(),
12072
+ response: {
12073
+ status: response.status,
12074
+ headers: response.headers,
12075
+ size: response.size,
12076
+ ...(this.#captureBodies ? {
12077
+ body: response.body
12078
+ } : {})
12079
+ }
12080
+ });
12081
+ return response;
11928
12082
  }
11929
12083
 
11930
12084
  /**
@@ -12448,7 +12602,7 @@ class OpenAPIOperationLocatorNormalizer extends _SourceDescriptionsLocatorNormal
12448
12602
  document,
12449
12603
  registry: this.registry
12450
12604
  });
12451
- const uriReference = evaluator.interpolate(operationPath);
12605
+ const uriReference = await evaluator.interpolate(operationPath);
12452
12606
  const documentURI = _speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.sanitize(_speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_2__.stripHash(uriReference));
12453
12607
  if (documentURI === '') {
12454
12608
  throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`operationPath "${operationPath}" does not resolve to a source description URL`, {
@@ -12850,8 +13004,8 @@ class StepExecutor {
12850
13004
  // keyed by '{in}.{name}' rather than bare name, so two parameters that
12851
13005
  // legally differ only in their location each reach their own place.
12852
13006
  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);
13007
+ const parameters = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression), scope);
13008
+ const requestBody = await this.#requestBodyResolver.resolve(step.requestBody, expression => this.#evaluate(preContext, expression), scope);
12855
13009
 
12856
13010
  // checked here rather than on entry: locating the operation and resolving
12857
13011
  // the expressions above are awaited, so a run cancelled during them would
@@ -12887,13 +13041,13 @@ class StepExecutor {
12887
13041
  // evaluate criteria, outputs, and the next action against the post-request
12888
13042
  // context (with $request / $url / $method and $response / $statusCode).
12889
13043
  const postContext = state.toContext(this.#requestContext(response), this.#responseContext(response));
12890
- const successCriteria = this.evaluateCriteria(step, postContext, workflowId);
13044
+ const successCriteria = await this.evaluateCriteria(step, postContext, workflowId);
12891
13045
  const successful = successCriteria.every(criterion => criterion.met);
12892
- const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
13046
+ const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(postContext, expression), scope);
12893
13047
  const {
12894
13048
  matchedActions,
12895
13049
  actionCriteria
12896
- } = this.selectActions(step, successful, postContext, workflowId);
13050
+ } = await this.selectActions(step, successful, postContext, workflowId);
12897
13051
  return {
12898
13052
  stepId,
12899
13053
  response,
@@ -12990,13 +13144,18 @@ class StepExecutor {
12990
13144
  * names the step's workflow on a thrown error, as for
12991
13145
  * {@link StepExecutor.execute}.
12992
13146
  */
12993
- evaluateCriteria(step, context, workflowId) {
13147
+ async evaluateCriteria(step, context, workflowId) {
12994
13148
  this.assertSuccessCriteria(step, workflowId);
12995
13149
  const criteria = step.successCriteria;
12996
13150
  if (criteria === undefined) return [];
12997
13151
 
12998
- // assertSuccessCriteria above guarantees every entry is a Criterion Object
12999
- return [...criteria].map(criterion => this.#evaluateCriterion(criterion, context));
13152
+ // assertSuccessCriteria above guarantees every entry is a Criterion Object.
13153
+ // evaluated one after another, in list order, like the actions' criteria.
13154
+ const records = [];
13155
+ for (const criterion of [...criteria]) {
13156
+ records.push(await this.#evaluateCriterion(criterion, context));
13157
+ }
13158
+ return records;
13000
13159
  }
13001
13160
 
13002
13161
  /**
@@ -13022,11 +13181,11 @@ class StepExecutor {
13022
13181
  * `workflowId` names the step's workflow on a thrown error, as for
13023
13182
  * {@link StepExecutor.execute}.
13024
13183
  */
13025
- selectActions(step, successful, context, workflowId) {
13184
+ async selectActions(step, successful, context, workflowId) {
13026
13185
  const actionCriteria = [];
13027
- const isCriterionMet = (criterion, action) => {
13186
+ const isCriterionMet = async (criterion, action) => {
13028
13187
  const record = {
13029
- ...this.#evaluateCriterion(criterion, context),
13188
+ ...(await this.#evaluateCriterion(criterion, context)),
13030
13189
  actionName: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.name)
13031
13190
  };
13032
13191
  actionCriteria.push(record);
@@ -13038,7 +13197,7 @@ class StepExecutor {
13038
13197
  }),
13039
13198
  stepId: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.stepId)
13040
13199
  };
13041
- const matchedActions = successful ? this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
13200
+ const matchedActions = successful ? await this.#actionResolver.resolveOnSuccess(step.onSuccess, isCriterionMet, scope) : await this.#actionResolver.resolveOnFailure(step.onFailure, isCriterionMet, scope);
13042
13201
  return {
13043
13202
  matchedActions,
13044
13203
  actionCriteria
@@ -13072,20 +13231,32 @@ class StepExecutor {
13072
13231
  * condition that cannot be evaluated is unmet and records why; any other
13073
13232
  * error propagates.
13074
13233
  */
13075
- #evaluateCriterion(criterion, context) {
13234
+ async #evaluateCriterion(criterion, context) {
13076
13235
  const condition = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(criterion.condition);
13236
+ const location = this.#document.locationOf(criterion);
13237
+ const values = {};
13238
+ const resolve = async expression => {
13239
+ const value = await this.#evaluate(context, expression);
13240
+ const wholeBody = expression === '$response.body' || expression === '$request.body';
13241
+ values[expression] = wholeBody ? '[body]' : value;
13242
+ return value;
13243
+ };
13077
13244
  try {
13078
13245
  const {
13079
13246
  met,
13080
13247
  error
13081
- } = this.#criterionEvaluator.evaluate(criterion, expression => this.#evaluate(context, expression));
13248
+ } = await this.#criterionEvaluator.evaluate(criterion, resolve);
13082
13249
  if (error === undefined) return {
13083
13250
  condition,
13084
- met
13251
+ met,
13252
+ values,
13253
+ location
13085
13254
  };
13086
13255
  return {
13087
13256
  condition,
13088
13257
  met,
13258
+ values,
13259
+ location,
13089
13260
  diagnostic: {
13090
13261
  code: error.reason,
13091
13262
  message: error.message
@@ -13099,6 +13270,8 @@ class StepExecutor {
13099
13270
  return {
13100
13271
  condition,
13101
13272
  met: false,
13273
+ values,
13274
+ location,
13102
13275
  diagnostic: {
13103
13276
  code: error.reason,
13104
13277
  message: error.message
@@ -13259,7 +13432,8 @@ class StepRetryRunner {
13259
13432
 
13260
13433
  /**
13261
13434
  * Runs `attempt` until the step succeeds, a terminal failure action is reached,
13262
- * or its retries are exhausted.
13435
+ * or its retries are exhausted. Each call is given its attempt number,
13436
+ * starting at 1.
13263
13437
  */
13264
13438
  async run(attempt, context) {
13265
13439
  // attempts already spent on each retry action, keyed by the action element.
@@ -13273,7 +13447,7 @@ class StepRetryRunner {
13273
13447
  const retriesSpent = new Map();
13274
13448
  let attempts = 0;
13275
13449
  for (;;) {
13276
- const outcome = await attempt();
13450
+ const outcome = await attempt(attempts + 1);
13277
13451
  attempts += 1;
13278
13452
  if (outcome.successful) {
13279
13453
  return {
@@ -13307,8 +13481,9 @@ class StepRetryRunner {
13307
13481
  // sleep(0) for immediate retries, and never hand a custom sleep a
13308
13482
  // zero/negative/NaN value.
13309
13483
  const delayMs = this.#retryAfterMs(action);
13484
+ context.onRetry?.(action, delayMs, attempts);
13310
13485
  if (delayMs > 0) await this.#sleep(delayMs, context.signal);
13311
- if (runReference !== undefined) await runReference(action, outcome);
13486
+ if (runReference !== undefined) await runReference(action, outcome, attempts);
13312
13487
  fired = true;
13313
13488
  break;
13314
13489
  }
@@ -13422,7 +13597,7 @@ function actionTargets(action) {
13422
13597
  * workflow; `transfer` hands control one-way to another workflow, which the
13423
13598
  * caller's run then ends on; `end` stops the run with `status: ended`; `break`
13424
13599
  * stops with `status: failed` (the failure default).
13425
- * @internal
13600
+ * @public
13426
13601
  */
13427
13602
 
13428
13603
  /**
@@ -13567,7 +13742,7 @@ __webpack_require__.r(__webpack_exports__);
13567
13742
  * reference — or a `goto`'s one-way transfer to a `workflowId` — is a call
13568
13743
  * cycle. `retry` and `goto` are grouped with `step` for that classification, not
13569
13744
  * `dependsOn`: each is a call the current step makes, not a stated precondition.
13570
- * @internal
13745
+ * @public
13571
13746
  */
13572
13747
 
13573
13748
  /**
@@ -13683,22 +13858,27 @@ __webpack_require__.r(__webpack_exports__);
13683
13858
  /* harmony export */ });
13684
13859
  /* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7456);
13685
13860
  /* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34606);
13686
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(62823);
13687
- /* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(75728);
13688
- /* harmony import */ var _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(77370);
13689
- /* harmony import */ var _extractor_ArazzoWorkflowExtractor_ts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(77447);
13690
- /* harmony import */ var _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(75055);
13691
- /* harmony import */ var _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(99494);
13692
- /* harmony import */ var _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(95839);
13693
- /* harmony import */ var _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(61596);
13694
- /* harmony import */ var _StepExecutor_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(96007);
13695
- /* harmony import */ var _ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(98885);
13696
- /* harmony import */ var _StepRetryRunner_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(18760);
13697
- /* harmony import */ var _WorkflowCallStack_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(64661);
13698
- /* harmony import */ var _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(2835);
13699
- /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(17658);
13700
- /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(8696);
13701
- /* harmony import */ var _abort_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(99628);
13861
+ /* harmony import */ var short_unique_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24279);
13862
+ /* harmony import */ var short_unique_id__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(short_unique_id__WEBPACK_IMPORTED_MODULE_2__);
13863
+ /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(62823);
13864
+ /* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(75728);
13865
+ /* harmony import */ var _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(77370);
13866
+ /* harmony import */ var _extractor_ArazzoWorkflowExtractor_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(77447);
13867
+ /* harmony import */ var _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(75055);
13868
+ /* harmony import */ var _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(99494);
13869
+ /* harmony import */ var _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(95839);
13870
+ /* harmony import */ var _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(61596);
13871
+ /* harmony import */ var _StepExecutor_ts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(96007);
13872
+ /* harmony import */ var _ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(98885);
13873
+ /* harmony import */ var _StepRetryRunner_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(18760);
13874
+ /* harmony import */ var _WorkflowCallStack_ts__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(64661);
13875
+ /* harmony import */ var _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(2835);
13876
+ /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(17658);
13877
+ /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(8696);
13878
+ /* harmony import */ var _abort_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(99628);
13879
+ /* harmony import */ var _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(12993);
13880
+
13881
+
13702
13882
 
13703
13883
 
13704
13884
 
@@ -13810,6 +13990,14 @@ function settledResult(result) {
13810
13990
  * travel together into everything it delegates to.
13811
13991
  */
13812
13992
 
13993
+ /**
13994
+ * What every event of one workflow invocation shares.
13995
+ */
13996
+
13997
+ /**
13998
+ * What every step-scoped event of one step shares.
13999
+ */
14000
+
13813
14001
  /**
13814
14002
  * Executes an Arazzo workflow: the stateful loop that turns "run one step" into
13815
14003
  * "run a workflow".
@@ -13855,30 +14043,43 @@ class WorkflowExecutor {
13855
14043
  static #DEFAULT_MAX_STEPS = 1000;
13856
14044
  static #DEFAULT_MAX_WORKFLOW_DEPTH = 32;
13857
14045
  static #DEFAULT_NOW = () => performance.now();
14046
+ /**
14047
+ * Generates each run's `runId`: random rather than counted, so the events
14048
+ * of runs in different processes stay apart once collected in one place.
14049
+ * It needs no Web Crypto, which browsers offer only on secure pages.
14050
+ */
14051
+ static #RUN_IDS = new (short_unique_id__WEBPACK_IMPORTED_MODULE_2___default())({
14052
+ length: 12
14053
+ });
13858
14054
  static #EXECUTE_OPTION_KEYS = new Set(['inputs', 'executeOptions', 'dependencyInputs', 'runDependencies', 'signal']);
13859
14055
  #document;
13860
14056
  #registry;
13861
14057
  #maxSteps;
13862
14058
  #maxWorkflowDepth;
13863
14059
  #now;
13864
- #extractor = new _extractor_ArazzoWorkflowExtractor_ts__WEBPACK_IMPORTED_MODULE_5__["default"]();
14060
+ #extractor = new _extractor_ArazzoWorkflowExtractor_ts__WEBPACK_IMPORTED_MODULE_6__["default"]();
13865
14061
  #normalizer;
13866
- #outputResolver = new _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_7__["default"]();
13867
- #parameterResolver = new _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_8__["default"]();
14062
+ #outputResolver = new _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_8__["default"]();
14063
+ #parameterResolver = new _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_9__["default"]();
13868
14064
  #stepExecutor;
13869
14065
  #retryRunner;
13870
- #interpreter = new _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_14__["default"]();
14066
+ #interpreter = new _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__["default"]();
13871
14067
  #workflowLocatorNormalizer;
14068
+ #events;
13872
14069
  constructor(options) {
13873
14070
  this.#document = options.document;
13874
14071
  this.#registry = options.registry;
13875
- this.#workflowLocatorNormalizer = new _ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_11__["default"](options.registry);
13876
- this.#normalizer = options.workflowNormalizer ?? new _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_6__["default"]();
14072
+ this.#workflowLocatorNormalizer = new _ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_12__["default"](options.registry);
14073
+ this.#normalizer = options.workflowNormalizer ?? new _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_7__["default"]();
13877
14074
  this.#maxSteps = options.maxSteps ?? WorkflowExecutor.#DEFAULT_MAX_STEPS;
13878
14075
  this.#maxWorkflowDepth = options.maxWorkflowDepth ?? WorkflowExecutor.#DEFAULT_MAX_WORKFLOW_DEPTH;
13879
14076
  this.#now = options.now ?? WorkflowExecutor.#DEFAULT_NOW;
14077
+ this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_19__["default"].open({
14078
+ observer: options.observer,
14079
+ now: this.#now
14080
+ });
13880
14081
  this.#stepExecutor = options.stepExecutor;
13881
- this.#retryRunner = new _StepRetryRunner_ts__WEBPACK_IMPORTED_MODULE_12__["default"]({
14082
+ this.#retryRunner = new _StepRetryRunner_ts__WEBPACK_IMPORTED_MODULE_13__["default"]({
13882
14083
  sleep: options.sleep
13883
14084
  });
13884
14085
  }
@@ -13900,7 +14101,9 @@ class WorkflowExecutor {
13900
14101
  signal
13901
14102
  } = options;
13902
14103
  const executeOptions = this.#executeOptionsByName(options.executeOptions ?? {});
14104
+ const runId = `run-${WorkflowExecutor.#RUN_IDS.randomUUID()}`;
13903
14105
  const scope = {
14106
+ runId,
13904
14107
  // the signal is put into every step's opaque bag, because that bag is
13905
14108
  // how anything reaches the transport: the executor's own checks stop the
13906
14109
  // run at the next boundary, and this is what cancels the request already
@@ -13909,7 +14112,9 @@ class WorkflowExecutor {
13909
14112
  // leave the run walking on.
13910
14113
  executeOptions: (locator, step) => ({
13911
14114
  ...this.#executeOptionsFor(executeOptions, locator, step),
13912
- signal
14115
+ signal,
14116
+ // set over any entry's own, like the signal: it names this run.
14117
+ runId
13913
14118
  }),
13914
14119
  dependencyInputs: options.dependencyInputs ?? {},
13915
14120
  runDependencies: options.runDependencies ?? true,
@@ -13923,7 +14128,7 @@ class WorkflowExecutor {
13923
14128
  return this.#run({
13924
14129
  document: this.#document,
13925
14130
  workflowId
13926
- }, options.inputs ?? {}, scope, new _WorkflowCallStack_ts__WEBPACK_IMPORTED_MODULE_13__["default"]({
14131
+ }, options.inputs ?? {}, scope, new _WorkflowCallStack_ts__WEBPACK_IMPORTED_MODULE_14__["default"]({
13927
14132
  maxDepth: this.#maxWorkflowDepth,
13928
14133
  entryDocumentURI: this.#document.uri
13929
14134
  }), 'root');
@@ -13940,20 +14145,20 @@ class WorkflowExecutor {
13940
14145
  #executeOptionsByName(executeOptions) {
13941
14146
  const byName = new Map();
13942
14147
  const fail = (name, problem, reason) => {
13943
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
14148
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
13944
14149
  reason
13945
14150
  });
13946
14151
  };
13947
14152
  for (const [name, options] of Object.entries(executeOptions)) {
13948
14153
  const uri = this.#document.resolveSourceDescriptionURI(name);
13949
14154
  if (uri === undefined) {
13950
- return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].SourceDescriptionNotFound);
14155
+ return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].SourceDescriptionNotFound);
13951
14156
  }
13952
14157
  if (this.#document.resolveSourceDescriptionField(name, 'type') === 'arazzo') {
13953
- fail(name, 'names an Arazzo document', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].SourceDescriptionNotOpenAPI);
14158
+ fail(name, 'names an Arazzo document', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].SourceDescriptionNotOpenAPI);
13954
14159
  }
13955
14160
  if (!(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__["default"])(options)) {
13956
- fail(name, 'is not given an object of options', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].UnknownExecuteOption);
14161
+ fail(name, 'is not given an object of options', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownExecuteOption);
13957
14162
  }
13958
14163
  byName.set(name, {
13959
14164
  uri,
@@ -13975,9 +14180,9 @@ class WorkflowExecutor {
13975
14180
  const configuring = [...entries].filter(([, entry]) => entry.uri === locator.document.uri);
13976
14181
  if (configuring.length > 1) {
13977
14182
  const names = configuring.map(([name]) => `"${name}"`).join(', ');
13978
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`Step "${step.stepId}" has no executeOptions entry of its own, and ${names} all configure "${locator.document.uri}", the document it calls`, {
14183
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`Step "${step.stepId}" has no executeOptions entry of its own, and ${names} all configure "${locator.document.uri}", the document it calls`, {
13979
14184
  ...step,
13980
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].AmbiguousExecuteOptions
14185
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousExecuteOptions
13981
14186
  });
13982
14187
  }
13983
14188
  return configuring[0]?.[1].options;
@@ -13996,8 +14201,8 @@ class WorkflowExecutor {
13996
14201
  #rejectUnknownOptions(options) {
13997
14202
  const unknown = Object.keys(options).filter(key => !WorkflowExecutor.#EXECUTE_OPTION_KEYS.has(key));
13998
14203
  if (unknown.length === 0) return;
13999
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
14000
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].UnknownExecuteOption
14204
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
14205
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownExecuteOption
14001
14206
  });
14002
14207
  }
14003
14208
 
@@ -14023,12 +14228,27 @@ class WorkflowExecutor {
14023
14228
  // run cancelled before any step — or between a prerequisite and the workflow
14024
14229
  // that needed it — must not go on to normalize and enter a workflow nobody
14025
14230
  // is waiting for.
14026
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14231
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14027
14232
  workflowId,
14028
14233
  callStack: nested
14029
14234
  });
14030
- const workflow = await this.#resolveWorkflow(locator, scope);
14031
- const state = new _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_9__["default"]({
14235
+ const frame = {
14236
+ runId: scope.runId,
14237
+ workflowId,
14238
+ path: nested.path
14239
+ };
14240
+ // extracted before `workflow-start`: a workflow its document does not
14241
+ // define never starts, and the event can say where the one it runs is.
14242
+ const extracted = this.#extractWorkflow(locator);
14243
+ // emitted before normalization, so its events nest inside this workflow's.
14244
+ this.#events?.emit({
14245
+ type: 'workflow-start',
14246
+ ...frame,
14247
+ via,
14248
+ location: locator.document.locationOf(extracted)
14249
+ }, startedAt);
14250
+ const workflow = await this.#resolveWorkflow(locator, extracted, scope, frame);
14251
+ const state = new _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_10__["default"]({
14032
14252
  inputs
14033
14253
  });
14034
14254
  const invocation = {
@@ -14036,7 +14256,8 @@ class WorkflowExecutor {
14036
14256
  document: locator.document,
14037
14257
  state,
14038
14258
  callStack: nested,
14039
- via
14259
+ via,
14260
+ frame
14040
14261
  };
14041
14262
 
14042
14263
  // validated before any prerequisite runs: a malformed `steps` is an
@@ -14070,7 +14291,7 @@ class WorkflowExecutor {
14070
14291
  // result carrying the dependency trace, not a throw — and none of its own
14071
14292
  // steps run. Unless the run was cancelled, in which case the prerequisite
14072
14293
  // did not fail on its own terms either.
14073
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14294
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14074
14295
  workflowId,
14075
14296
  callStack: nested
14076
14297
  });
@@ -14099,7 +14320,16 @@ class WorkflowExecutor {
14099
14320
  // separate from `subWorkflows` because a reference belongs to the retry
14100
14321
  // that invoked it, not to the step's own target.
14101
14322
  const retryReferences = [];
14102
- const attempt = this.#chargedAttempt(this.#stepAttempt(step, stepId, invocation, scope, subWorkflows), invocation, scope, stepId);
14323
+ const stepFrame = {
14324
+ ...frame,
14325
+ stepId
14326
+ };
14327
+ this.#events?.emit({
14328
+ type: 'step-start',
14329
+ ...stepFrame,
14330
+ location: invocation.document.locationOf(step)
14331
+ }, stepStartedAt);
14332
+ const attempt = this.#chargedAttempt(this.#observedAttempt(this.#stepAttempt(step, stepId, invocation, scope, subWorkflows), stepFrame), invocation, scope, stepId);
14103
14333
 
14104
14334
  // the retry runner settles any `retry` actions, so `action` is the terminal
14105
14335
  // action a retry chain resolved to and `attempts` is how many times the step
@@ -14112,15 +14342,51 @@ class WorkflowExecutor {
14112
14342
  stepId,
14113
14343
  workflowId,
14114
14344
  signal: scope.signal,
14115
- runReference: this.#retryReference(steps, stepId, invocation, scope, retryReferences)
14345
+ runReference: this.#retryReference(steps, stepFrame, invocation, scope, retryReferences),
14346
+ onRetry: (retry, delayMs, attempt) => {
14347
+ const decided = {
14348
+ ...stepFrame,
14349
+ attempt
14350
+ };
14351
+ this.#events?.emit({
14352
+ type: 'action-selected',
14353
+ ...decided,
14354
+ action: retry,
14355
+ transition: {
14356
+ kind: 'retry'
14357
+ },
14358
+ location: invocation.document.locationOf(retry)
14359
+ });
14360
+ if (delayMs > 0) {
14361
+ this.#events?.emit({
14362
+ type: 'retry-wait',
14363
+ ...decided,
14364
+ delayMs
14365
+ });
14366
+ }
14367
+ }
14368
+ });
14369
+ const transition = this.#interpreter.interpret(action, outcome.successful, {
14370
+ workflowId,
14371
+ stepId
14372
+ });
14373
+ this.#events?.emit({
14374
+ type: 'action-selected',
14375
+ ...stepFrame,
14376
+ attempt: attempts,
14377
+ action,
14378
+ transition,
14379
+ location: action === undefined ? undefined : invocation.document.locationOf(action)
14116
14380
  });
14117
14381
  state.setStepOutputs(outcome.stepId, outcome.outputs);
14382
+ const stepSettledAt = this.#now();
14118
14383
  trace.push({
14119
14384
  stepId: outcome.stepId,
14385
+ location: invocation.document.locationOf(step),
14120
14386
  successful: outcome.successful,
14121
14387
  action,
14122
14388
  attempts,
14123
- durationMs: this.#now() - stepStartedAt,
14389
+ durationMs: stepSettledAt - stepStartedAt,
14124
14390
  successCriteria: outcome.successCriteria,
14125
14391
  actionCriteria: outcome.actionCriteria,
14126
14392
  ...(subWorkflows.length > 0 ? {
@@ -14130,17 +14396,19 @@ class WorkflowExecutor {
14130
14396
  retryReferences
14131
14397
  } : {})
14132
14398
  });
14133
- const transition = this.#interpreter.interpret(action, outcome.successful, {
14134
- workflowId,
14135
- stepId
14136
- });
14399
+ this.#events?.emit({
14400
+ type: 'step-settled',
14401
+ ...stepFrame,
14402
+ successful: outcome.successful,
14403
+ attempts
14404
+ }, stepSettledAt);
14137
14405
  switch (transition.kind) {
14138
14406
  case 'next':
14139
14407
  index += 1;
14140
14408
  break;
14141
14409
  case 'goto':
14142
14410
  index = this.#interpreter.indexOfStep(steps, transition.stepId, workflowId, {
14143
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].GotoTargetNotFound,
14411
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].GotoTargetNotFound,
14144
14412
  label: 'goto target'
14145
14413
  });
14146
14414
  break;
@@ -14153,12 +14421,12 @@ class WorkflowExecutor {
14153
14421
  // resolution, so an aborted run reports `aborted` rather than
14154
14422
  // whatever resolving the target (a malformed reference, a missing
14155
14423
  // source) would have thrown.
14156
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14424
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14157
14425
  workflowId,
14158
14426
  stepId,
14159
14427
  callStack: nested
14160
14428
  });
14161
- const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto', this.#actionInputs(action?.parameters, outcome, invocation, stepId));
14429
+ const transferredTo = await this.#runReferencedWorkflow(transition.workflowId, stepId, invocation, scope, 'goto', await this.#actionInputs(action?.parameters, outcome, invocation, stepId));
14162
14430
  runOutcome = {
14163
14431
  kind: 'transferred',
14164
14432
  transferredTo
@@ -14179,15 +14447,15 @@ class WorkflowExecutor {
14179
14447
  break stepLoop;
14180
14448
  default:
14181
14449
  {
14182
- // exhaustiveness guard: a Transition kind added above without a case
14450
+ // exhaustiveness guard: a StepTransition kind added above without a case
14183
14451
  // here would otherwise fall through silently instead of failing
14184
14452
  // loudly — `transition` is provably `never` once every kind above
14185
14453
  // has its own case, which TypeScript checks at compile time.
14186
14454
  const unreachable = transition;
14187
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
14455
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
14188
14456
  workflowId,
14189
14457
  stepId,
14190
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].UnknownTransitionKind
14458
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownTransitionKind
14191
14459
  });
14192
14460
  }
14193
14461
  }
@@ -14199,7 +14467,7 @@ class WorkflowExecutor {
14199
14467
  // transport, since one honoring the signal fails the request instead.
14200
14468
  // Cancellation must not be the one outcome that reads differently for the
14201
14469
  // last step than for every step before it.
14202
- ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14470
+ ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14203
14471
  workflowId,
14204
14472
  callStack: nested
14205
14473
  });
@@ -14222,34 +14490,40 @@ class WorkflowExecutor {
14222
14490
  * {@link WorkflowExecutor.#validateWorkflowOutputsShape} already checked
14223
14491
  * the shape up front, independent of resolving it.
14224
14492
  */
14225
- #result(invocation, workflow, steps, outcome, dependencies, startedAt) {
14493
+ async #result(invocation, workflow, steps, outcome, dependencies, startedAt) {
14494
+ const settledAt = this.#now();
14226
14495
  const shared = {
14227
14496
  workflowId: invocation.workflowId,
14228
14497
  steps,
14229
- durationMs: this.#now() - startedAt,
14498
+ durationMs: settledAt - startedAt,
14230
14499
  ...(dependencies.length > 0 ? {
14231
14500
  dependencies
14232
14501
  } : {})
14233
14502
  };
14234
- if (outcome.kind === 'transferred') {
14235
- return {
14236
- ...shared,
14237
- outputs: {},
14238
- status: 'transferred',
14239
- // computed once, here, rather than left for a caller to chase via
14240
- // `settledResult` — `transferredTo` already carries its own
14241
- // `settledStatus`, itself computed the same way when it was built,
14242
- // so this is O(1) per hop rather than a walk of the whole chain.
14243
- settledStatus: outcome.transferredTo.settledStatus,
14244
- transferredTo: outcome.transferredTo
14245
- };
14246
- }
14247
- return {
14503
+ const result = outcome.kind === 'transferred' ? {
14248
14504
  ...shared,
14249
- outputs: this.#resolveWorkflowOutputs(workflow, invocation),
14505
+ outputs: {},
14506
+ status: 'transferred',
14507
+ // computed once, here, rather than left for a caller to chase via
14508
+ // `settledResult` — `transferredTo` already carries its own
14509
+ // `settledStatus`, itself computed the same way when it was built,
14510
+ // so this is O(1) per hop rather than a walk of the whole chain.
14511
+ settledStatus: outcome.transferredTo.settledStatus,
14512
+ transferredTo: outcome.transferredTo
14513
+ } : {
14514
+ ...shared,
14515
+ outputs: await this.#resolveWorkflowOutputs(workflow, invocation),
14250
14516
  status: outcome.status,
14251
14517
  settledStatus: outcome.status
14252
14518
  };
14519
+ this.#events?.emit({
14520
+ type: 'workflow-settled',
14521
+ ...invocation.frame,
14522
+ status: result.status,
14523
+ settledStatus: result.settledStatus,
14524
+ outputs: result.outputs
14525
+ }, settledAt);
14526
+ return result;
14253
14527
  }
14254
14528
 
14255
14529
  /**
@@ -14272,10 +14546,10 @@ class WorkflowExecutor {
14272
14546
  */
14273
14547
  #chargeBudget(scope, invocation, stepId) {
14274
14548
  if (++scope.budget.spent <= this.#maxSteps) return;
14275
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
14549
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
14276
14550
  workflowId: invocation.workflowId,
14277
14551
  stepId,
14278
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].StepBudget,
14552
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].StepBudget,
14279
14553
  path: invocation.callStack.path
14280
14554
  });
14281
14555
  }
@@ -14297,17 +14571,17 @@ class WorkflowExecutor {
14297
14571
  workflowId,
14298
14572
  callStack
14299
14573
  } = invocation;
14300
- return async () => {
14301
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14574
+ return async attempt => {
14575
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14302
14576
  workflowId,
14303
14577
  stepId,
14304
14578
  callStack
14305
14579
  });
14306
14580
  this.#chargeBudget(scope, invocation, stepId);
14307
14581
  try {
14308
- return await runAttempt();
14582
+ return await runAttempt(attempt);
14309
14583
  } catch (error) {
14310
- ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14584
+ ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14311
14585
  workflowId,
14312
14586
  stepId,
14313
14587
  callStack
@@ -14317,6 +14591,46 @@ class WorkflowExecutor {
14317
14591
  };
14318
14592
  }
14319
14593
 
14594
+ /**
14595
+ * Wraps a step-attempt thunk with the events of an attempt: `step-attempt`
14596
+ * as it begins, then a `criterion-evaluated` for each criterion it
14597
+ * evaluated, success criteria first.
14598
+ */
14599
+ #observedAttempt(runAttempt, stepFrame) {
14600
+ const events = this.#events;
14601
+ if (events === undefined) return runAttempt;
14602
+ return async attempt => {
14603
+ const attemptFrame = {
14604
+ ...stepFrame,
14605
+ attempt
14606
+ };
14607
+ events.emit({
14608
+ type: 'step-attempt',
14609
+ ...attemptFrame
14610
+ });
14611
+ const outcome = await runAttempt();
14612
+ for (const criterion of outcome.successCriteria) {
14613
+ events.emit({
14614
+ type: 'criterion-evaluated',
14615
+ ...attemptFrame,
14616
+ kind: 'success',
14617
+ criterion,
14618
+ location: criterion.location
14619
+ });
14620
+ }
14621
+ for (const criterion of outcome.actionCriteria) {
14622
+ events.emit({
14623
+ type: 'criterion-evaluated',
14624
+ ...attemptFrame,
14625
+ kind: 'action',
14626
+ criterion,
14627
+ location: criterion.location
14628
+ });
14629
+ }
14630
+ return outcome;
14631
+ };
14632
+ }
14633
+
14320
14634
  /**
14321
14635
  * Builds the {@link StepRetryRunContext.runReference} callback a `retry`
14322
14636
  * action's `stepId` / `workflowId` reference is run through.
@@ -14360,14 +14674,17 @@ class WorkflowExecutor {
14360
14674
  * reference's *completion*, not its success, and a retry that turns out
14361
14675
  * futile is bounded by `retryLimit` regardless.
14362
14676
  */
14363
- #retryReference(steps, stepId, invocation, scope, retryReferences) {
14677
+ #retryReference(steps, stepFrame, invocation, scope, retryReferences) {
14364
14678
  const {
14365
14679
  workflowId,
14366
14680
  state,
14367
14681
  callStack
14368
14682
  } = invocation;
14369
- return async (action, outcome) => {
14370
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_17__.throwIfAborted)(scope.signal, {
14683
+ const {
14684
+ stepId
14685
+ } = stepFrame;
14686
+ return async (action, outcome, attempt) => {
14687
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14371
14688
  workflowId,
14372
14689
  stepId,
14373
14690
  callStack
@@ -14375,20 +14692,31 @@ class WorkflowExecutor {
14375
14692
  const {
14376
14693
  hasStepId,
14377
14694
  hasWorkflowId
14378
- } = (0,_StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_14__.actionTargets)(action);
14695
+ } = (0,_StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__.actionTargets)(action);
14379
14696
  if (hasWorkflowId && hasStepId) {
14380
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
14697
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
14381
14698
  stepId,
14382
14699
  workflowId,
14383
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].AmbiguousTarget
14700
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousTarget
14384
14701
  });
14385
14702
  }
14386
14703
  if (hasWorkflowId) {
14387
14704
  const reference = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.workflowId);
14388
14705
  // resolved before the budget is charged, so an authoring error in them
14389
14706
  // costs no budget unit.
14390
- const inputs = this.#actionInputs(action.parameters, outcome, invocation, stepId);
14707
+ const inputs = await this.#actionInputs(action.parameters, outcome, invocation, stepId);
14391
14708
  this.#chargeBudget(scope, invocation, stepId);
14709
+ const referenceFrame = {
14710
+ ...stepFrame,
14711
+ attempt,
14712
+ kind: 'workflow',
14713
+ id: reference
14714
+ };
14715
+ this.#events?.emit({
14716
+ type: 'retry-reference-start',
14717
+ ...referenceFrame,
14718
+ location: invocation.document.locationOf(action)
14719
+ });
14392
14720
  const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry', inputs);
14393
14721
  // the result's workflowId is the bare id the reference resolved to —
14394
14722
  // the key run state is recorded under, whichever document owns it.
@@ -14397,22 +14725,44 @@ class WorkflowExecutor {
14397
14725
  inputs: action.hasKey('parameters') ? inputs : state.getWorkflow(refId)?.inputs ?? {},
14398
14726
  outputs: result.outputs
14399
14727
  });
14728
+ const successful = !this.#settledFailed(result);
14400
14729
  retryReferences.push({
14401
14730
  kind: 'workflow',
14402
14731
  id: reference,
14403
- successful: !this.#settledFailed(result),
14732
+ successful,
14404
14733
  subWorkflow: result
14405
14734
  });
14735
+ this.#events?.emit({
14736
+ type: 'retry-reference-settled',
14737
+ ...referenceFrame,
14738
+ successful
14739
+ });
14406
14740
  return;
14407
14741
  }
14408
14742
  const refStepId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.stepId);
14409
14743
  const refIndex = this.#interpreter.indexOfStep(steps, refStepId, workflowId, {
14410
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].RetryTargetNotFound,
14744
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].RetryTargetNotFound,
14411
14745
  label: 'retry reference'
14412
14746
  });
14413
14747
  const refStep = steps[refIndex];
14414
14748
  const refSubWorkflows = [];
14415
- const refOutcome = await this.#chargedAttempt(this.#stepAttempt(refStep, refStepId, invocation, scope, refSubWorkflows), invocation, scope, refStepId)();
14749
+ const referenceFrame = {
14750
+ ...stepFrame,
14751
+ attempt,
14752
+ kind: 'step',
14753
+ id: refStepId
14754
+ };
14755
+ this.#events?.emit({
14756
+ type: 'retry-reference-start',
14757
+ ...referenceFrame,
14758
+ location: invocation.document.locationOf(action)
14759
+ });
14760
+ // the referenced step's attempt is observed like any other, under its
14761
+ // own stepId and with a count of its own.
14762
+ const refOutcome = await this.#chargedAttempt(this.#observedAttempt(this.#stepAttempt(refStep, refStepId, invocation, scope, refSubWorkflows), {
14763
+ ...stepFrame,
14764
+ stepId: refStepId
14765
+ }), invocation, scope, refStepId)(1);
14416
14766
  state.setStepOutputs(refOutcome.stepId, refOutcome.outputs);
14417
14767
  retryReferences.push({
14418
14768
  kind: 'step',
@@ -14422,6 +14772,11 @@ class WorkflowExecutor {
14422
14772
  subWorkflow: refSubWorkflows[0]
14423
14773
  } : {})
14424
14774
  });
14775
+ this.#events?.emit({
14776
+ type: 'retry-reference-settled',
14777
+ ...referenceFrame,
14778
+ successful: refOutcome.successful
14779
+ });
14425
14780
  };
14426
14781
  }
14427
14782
 
@@ -14463,9 +14818,23 @@ class WorkflowExecutor {
14463
14818
  // found halfway down the list would otherwise be raised only after earlier
14464
14819
  // prerequisites had already fired live requests.
14465
14820
  const dependencyRefs = await this.#dependencyRefs(workflow, invocation);
14821
+ const {
14822
+ frame
14823
+ } = invocation;
14466
14824
  const results = [];
14467
14825
  for (const dependency of dependencyRefs) {
14468
14826
  const qualifiedId = this.#qualifiedId(dependency.locator);
14827
+ const target = {
14828
+ reference: dependency.inputsKey,
14829
+ workflowId: dependency.locator.workflowId,
14830
+ documentURI: dependency.locator.document.uri
14831
+ };
14832
+ this.#events?.emit({
14833
+ type: 'dependency-start',
14834
+ ...frame,
14835
+ dependency: target,
14836
+ location: invocation.document.locationOf(dependency.entry)
14837
+ });
14469
14838
  // a dependency already completed in this run is satisfied, not repeated: a
14470
14839
  // precondition holds once met, and a diamond (two dependents sharing one
14471
14840
  // dependency) must not duplicate its live side effects. Every dependent
@@ -14488,6 +14857,13 @@ class WorkflowExecutor {
14488
14857
  inputs,
14489
14858
  outputs: result.outputs
14490
14859
  });
14860
+ this.#events?.emit({
14861
+ type: 'dependency-settled',
14862
+ ...frame,
14863
+ dependency: target,
14864
+ memoized: memoized !== undefined,
14865
+ settledStatus: result.settledStatus
14866
+ });
14491
14867
  if (this.#settledFailed(result)) return results;
14492
14868
 
14493
14869
  // only a dependency whose chain settled non-`failed` is remembered as
@@ -14523,29 +14899,31 @@ class WorkflowExecutor {
14523
14899
  document
14524
14900
  } = invocation;
14525
14901
  const dependsOn = workflow.dependsOn;
14526
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(dependsOn)) {
14527
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${workflowId}" has a non-list "dependsOn"`, {
14902
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(dependsOn)) {
14903
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-list "dependsOn"`, {
14528
14904
  workflowId,
14529
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].MalformedDependsOn
14905
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedDependsOn
14530
14906
  });
14531
14907
  }
14532
- const references = [...dependsOn].map((entry, index) => {
14533
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(entry)) {
14534
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
14908
+ const entries = [...dependsOn].map((entry, index) => {
14909
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(entry)) {
14910
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
14535
14911
  workflowId,
14536
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].MalformedDependsOn
14912
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedDependsOn
14537
14913
  });
14538
14914
  }
14539
- return (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(entry);
14915
+ return entry;
14540
14916
  });
14541
14917
  const refs = [];
14542
- for (const reference of references) {
14918
+ for (const entry of entries) {
14919
+ const reference = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(entry);
14543
14920
  const locator = await this.#workflowLocatorNormalizer.normalize(reference, document, {
14544
14921
  workflowId
14545
14922
  });
14546
14923
  refs.push({
14547
14924
  locator,
14548
- inputsKey: reference
14925
+ inputsKey: reference,
14926
+ entry
14549
14927
  });
14550
14928
  }
14551
14929
  return refs;
@@ -14574,7 +14952,7 @@ class WorkflowExecutor {
14574
14952
  state,
14575
14953
  callStack
14576
14954
  } = invocation;
14577
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(step.workflowId)) {
14955
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(step.workflowId)) {
14578
14956
  return () => this.#stepExecutor.forDocument(document).execute(step, state, scope.executeOptions, workflowId);
14579
14957
  }
14580
14958
  const reference = this.#subWorkflowReference(step, stepId, workflowId);
@@ -14619,7 +14997,7 @@ class WorkflowExecutor {
14619
14997
  // sees the same (usually absent) value on every attempt, not the
14620
14998
  // previous attempt's own result.
14621
14999
  const preContext = this.#inputContext(state, subWorkflowId, priorWorkflowEntry);
14622
- const inputs = this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression, document), stepScope);
15000
+ const inputs = await this.#parameterResolver.resolve(step.parameters, expression => this.#evaluate(preContext, expression, document), stepScope);
14623
15001
  const result = await this.#run(locator, inputs, scope, callStack, 'step');
14624
15002
  subWorkflows.push(result);
14625
15003
  state.setWorkflow(subWorkflowId, {
@@ -14642,7 +15020,7 @@ class WorkflowExecutor {
14642
15020
  workflowId: subWorkflowId
14643
15021
  }
14644
15022
  };
14645
- const outputs = this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(context, expression, document), stepScope);
15023
+ const outputs = await this.#outputResolver.resolve(step.outputs, expression => this.#evaluate(context, expression, document), stepScope);
14646
15024
  // an `end`ed sub-workflow returned to its caller with outputs, so it took
14647
15025
  // the success path like a completed one; only a chain settling `failed` is
14648
15026
  // a failure — a sub-workflow that transferred is judged by where its
@@ -14657,12 +15035,12 @@ class WorkflowExecutor {
14657
15035
  // evaluated by the parent document's step executor — only the sub-run
14658
15036
  // itself switched documents.
14659
15037
  const stepExecutor = this.#stepExecutor.forDocument(document);
14660
- const successCriteria = stepExecutor.evaluateCriteria(step, context, workflowId);
15038
+ const successCriteria = await stepExecutor.evaluateCriteria(step, context, workflowId);
14661
15039
  const successful = !this.#settledFailed(result) && successCriteria.every(criterion => criterion.met);
14662
15040
  const {
14663
15041
  matchedActions,
14664
15042
  actionCriteria
14665
- } = stepExecutor.selectActions(step, successful, context, workflowId);
15043
+ } = await stepExecutor.selectActions(step, successful, context, workflowId);
14666
15044
  return {
14667
15045
  stepId,
14668
15046
  successful,
@@ -14714,12 +15092,12 @@ class WorkflowExecutor {
14714
15092
  // the same check, but a sub-workflow step never reaches it — so both read
14715
15093
  // the one list of target fields, and a target added to the specification
14716
15094
  // cannot be rejected by one and silently accepted by the other.
14717
- const conflicting = _StepExecutor_ts__WEBPACK_IMPORTED_MODULE_10__.STEP_TARGET_FIELDS.filter(field => field !== 'workflowId' && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(step[field]));
15095
+ const conflicting = _StepExecutor_ts__WEBPACK_IMPORTED_MODULE_11__.STEP_TARGET_FIELDS.filter(field => field !== 'workflowId' && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(step[field]));
14718
15096
  if (conflicting.length > 0) {
14719
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
15097
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
14720
15098
  stepId,
14721
15099
  workflowId,
14722
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].AmbiguousTarget
15100
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousTarget
14723
15101
  });
14724
15102
  }
14725
15103
  return (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.workflowId);
@@ -14788,9 +15166,9 @@ class WorkflowExecutor {
14788
15166
  #assertActionParameters(lists, workflowId, stepId) {
14789
15167
  const owner = stepId === undefined ? `workflow "${workflowId}"` : `step "${stepId}" in workflow "${workflowId}"`;
14790
15168
  for (const actions of lists) {
14791
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(actions)) continue;
15169
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(actions)) continue;
14792
15170
  for (const action of actions) {
14793
- if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__.isSuccessActionElement)(action) && !(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__.isFailureActionElement)(action)) continue;
15171
+ if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isSuccessActionElement)(action) && !(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isFailureActionElement)(action)) continue;
14794
15172
  if (!action.hasKey('parameters')) continue;
14795
15173
  const scope = {
14796
15174
  workflowId,
@@ -14802,17 +15180,17 @@ class WorkflowExecutor {
14802
15180
  const {
14803
15181
  parameters
14804
15182
  } = action;
14805
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(parameters)) {
14806
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"]('`parameters` is present but is not a list', {
15183
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(parameters)) {
15184
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"]('`parameters` is present but is not a list', {
14807
15185
  ...scope,
14808
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedParameters
15186
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedParameters
14809
15187
  });
14810
15188
  }
14811
- const inline = [...parameters].some(parameter => (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__.isParameterElement)(parameter) && parameter.hasKey('in') && !parameter.meta.hasKey('ref-fields'));
15189
+ const inline = [...parameters].some(parameter => (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isParameterElement)(parameter) && parameter.hasKey('in') && !parameter.meta.hasKey('ref-fields'));
14812
15190
  if (inline) {
14813
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`An action parameter of ${owner} declares an \`in\`; action parameters map to the target workflow's inputs by name`, {
15191
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`An action parameter of ${owner} declares an \`in\`; action parameters map to the target workflow's inputs by name`, {
14814
15192
  ...scope,
14815
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].ActionParameterLocation
15193
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].ActionParameterLocation
14816
15194
  });
14817
15195
  }
14818
15196
  }
@@ -14820,30 +15198,46 @@ class WorkflowExecutor {
14820
15198
  }
14821
15199
 
14822
15200
  /**
14823
- * Extracts and normalizes the workflow a locator names. A workflow its
14824
- * document does not define is the executor-level `workflow-not-found`
14825
- * authoring error, raised here rather than leaking the extractor's
14826
- * `ExtractionError`. Only the root {@link WorkflowExecutor.execute} id
14827
- * reaches this check unvalidated — every reference position goes through
14828
- * the locator normalizer, which already rejects a missing workflow with
14829
- * the referencing context attached — so the error's `workflowId` is the
14830
- * missing id itself.
15201
+ * Extracts the workflow a locator names. A workflow its document does not
15202
+ * define is the executor-level `workflow-not-found` authoring error, raised
15203
+ * here rather than leaking the extractor's `ExtractionError`. Only the root
15204
+ * {@link WorkflowExecutor.execute} id reaches this check unvalidated — every
15205
+ * reference position goes through the locator normalizer, which already
15206
+ * rejects a missing workflow with the referencing context attached — so the
15207
+ * error's `workflowId` is the missing id itself.
14831
15208
  */
14832
- async #resolveWorkflow(locator, scope) {
14833
- const {
14834
- document,
14835
- workflowId
14836
- } = locator;
14837
- const qualifiedId = this.#qualifiedId(locator);
14838
- const cached = scope.workflows.get(qualifiedId);
14839
- if (cached !== undefined) return cached;
15209
+ #extractWorkflow({
15210
+ document,
15211
+ workflowId
15212
+ }) {
14840
15213
  if (!document.workflowIndex.has(workflowId)) {
14841
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
15214
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
14842
15215
  workflowId,
14843
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].WorkflowNotFound
15216
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].WorkflowNotFound
14844
15217
  });
14845
15218
  }
14846
- const workflow = await this.#normalizer.normalize(this.#extractor.extract(document, workflowId), document);
15219
+ return this.#extractor.extract(document, workflowId);
15220
+ }
15221
+
15222
+ /**
15223
+ * Normalizes an extracted workflow, once per run for each workflow.
15224
+ */
15225
+ async #resolveWorkflow(locator, extracted, scope, frame) {
15226
+ const qualifiedId = this.#qualifiedId(locator);
15227
+ const cached = scope.workflows.get(qualifiedId);
15228
+ if (cached !== undefined) return cached;
15229
+ const location = locator.document.locationOf(extracted);
15230
+ this.#events?.emit({
15231
+ type: 'workflow-normalize-start',
15232
+ ...frame,
15233
+ location
15234
+ });
15235
+ const workflow = await this.#normalizer.normalize(extracted, locator.document);
15236
+ this.#events?.emit({
15237
+ type: 'workflow-normalize-settled',
15238
+ ...frame,
15239
+ location
15240
+ });
14847
15241
  scope.workflows.set(qualifiedId, workflow);
14848
15242
  return workflow;
14849
15243
  }
@@ -14868,17 +15262,17 @@ class WorkflowExecutor {
14868
15262
  #orderedSteps(workflow, workflowId) {
14869
15263
  if (!workflow.hasKey('steps')) return [];
14870
15264
  const steps = workflow.steps;
14871
- if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isArrayElement)(steps)) {
14872
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${workflowId}" has a non-list "steps"`, {
15265
+ if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(steps)) {
15266
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-list "steps"`, {
14873
15267
  workflowId,
14874
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].MalformedSteps
15268
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedSteps
14875
15269
  });
14876
15270
  }
14877
15271
  return [...steps].map((step, index) => {
14878
- if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__.isStepElement)(step)) {
14879
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"](`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
15272
+ if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isStepElement)(step)) {
15273
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
14880
15274
  workflowId,
14881
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_15__["default"].MalformedSteps
15275
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedSteps
14882
15276
  });
14883
15277
  }
14884
15278
  return step;
@@ -14897,11 +15291,11 @@ class WorkflowExecutor {
14897
15291
  #validateWorkflowOutputsShape(workflow, workflowId) {
14898
15292
  if (!workflow.hasKey('outputs')) return;
14899
15293
  const outputs = workflow.outputs;
14900
- if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(outputs)) return;
14901
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"]('`outputs` is present but is not a map', {
15294
+ if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isObjectElement)(outputs)) return;
15295
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"]('`outputs` is present but is not a map', {
14902
15296
  workflowId,
14903
15297
  target: 'outputs',
14904
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedOutputs
15298
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedOutputs
14905
15299
  });
14906
15300
  }
14907
15301
 
@@ -14924,7 +15318,7 @@ class WorkflowExecutor {
14924
15318
  * counterpart of {@link StepExecutor}'s bridge.
14925
15319
  */
14926
15320
  #evaluate(context, expression, document) {
14927
- return new _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_4__["default"](context, {
15321
+ return new _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_5__["default"](context, {
14928
15322
  strict: false,
14929
15323
  document,
14930
15324
  registry: this.#registry
@@ -15027,8 +15421,12 @@ __webpack_require__.r(__webpack_exports__);
15027
15421
  /* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27554);
15028
15422
  /* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7456);
15029
15423
  /* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(48770);
15030
- /* harmony import */ var _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(20250);
15031
- /* harmony import */ var _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(35043);
15424
+ /* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(24089);
15425
+ /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(46132);
15426
+ /* harmony import */ var _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(20250);
15427
+ /* harmony import */ var _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(35043);
15428
+
15429
+
15032
15430
 
15033
15431
 
15034
15432
 
@@ -15080,6 +15478,9 @@ const HTTP_EXCHANGE_NODES = new Set(['UrlExpression', 'MethodExpression', 'Statu
15080
15478
  * (via the registry) the source name points at. A step reference resolves to
15081
15479
  * the Step Object as authored — a locator, not the step's execution result.
15082
15480
  *
15481
+ * Evaluation is asynchronous because a `$sourceDescriptions` reference may
15482
+ * have to load the document it points at.
15483
+ *
15083
15484
  * A reference resolves to `undefined` when it is absent. Runtime values
15084
15485
  * originate from JSON (or ApiDOM), which cannot represent `undefined` — an
15085
15486
  * absent value is a missing property and an explicit null is `null` — so
@@ -15113,11 +15514,19 @@ class RuntimeExpressionEvaluator {
15113
15514
  * The expression must be the bare form without surrounding braces
15114
15515
  * (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
15115
15516
  * unresolvable reference throws; otherwise it returns `undefined`.
15517
+ *
15518
+ * A `$sourceDescriptions` reference whose document cannot be loaded is not
15519
+ * merely unresolved: unless it names a field of the Source Description Object,
15520
+ * it rejects with the load error in either mode, since nothing else can
15521
+ * produce its value.
15522
+ *
15523
+ * @throws DocumentLoadError - When a referenced source document cannot be read or loaded
15524
+ * @throws UnmatchedProviderError - When no provider can load a referenced source document
15116
15525
  */
15117
- evaluate(expression) {
15526
+ async evaluate(expression) {
15118
15527
  const node = this.#parse(expression);
15119
15528
  this.#assertAvailable(node, expression);
15120
- const value = this.#evaluateNode(node, expression);
15529
+ const value = await this.#evaluateNode(node, expression);
15121
15530
  if (value === undefined && this.#strict) {
15122
15531
  throw new _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_6__["default"](`Runtime expression "${expression}" could not be resolved against the context`, {
15123
15532
  expression,
@@ -15135,8 +15544,20 @@ class RuntimeExpressionEvaluator {
15135
15544
  * mode, unresolvable references render as an empty string. A `{…}` that is not
15136
15545
  * a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
15137
15546
  */
15138
- interpolate(template) {
15139
- return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.interpolate)(template, expression => this.evaluate(expression));
15547
+ async interpolate(template) {
15548
+ // `interpolate` takes a synchronous resolver, so the embedded expressions are
15549
+ // collected by a first pass, evaluated in order, and substituted by a second.
15550
+ // Interpolation never skips an expression, so the result is the same.
15551
+ const expressions = [];
15552
+ (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.interpolate)(template, expression => {
15553
+ expressions.push(expression);
15554
+ return '';
15555
+ });
15556
+ const values = new Map();
15557
+ for (const expression of expressions) {
15558
+ if (!values.has(expression)) values.set(expression, await this.evaluate(expression));
15559
+ }
15560
+ return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.interpolate)(template, expression => values.get(expression));
15140
15561
  }
15141
15562
 
15142
15563
  /**
@@ -15150,7 +15571,7 @@ class RuntimeExpressionEvaluator {
15150
15571
  * yields the string representation of its value, not the typed value. A
15151
15572
  * string containing no expressions is returned unchanged.
15152
15573
  */
15153
- resolve(value) {
15574
+ async resolve(value) {
15154
15575
  // `test` returns true only when the entire string is a valid runtime
15155
15576
  // expression, so a braced or mixed string falls through to interpolation.
15156
15577
  return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? this.evaluate(value) : this.interpolate(value);
@@ -15270,7 +15691,7 @@ class RuntimeExpressionEvaluator {
15270
15691
  * the workflow or step is unknown.
15271
15692
  */
15272
15693
  #step(document, workflowId, stepId) {
15273
- if (document === undefined || !_document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_7__["default"].is(document)) return undefined;
15694
+ if (document === undefined || !_document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_9__["default"].is(document)) return undefined;
15274
15695
  const pointer = document.stepIndex.getStep(workflowId, stepId);
15275
15696
  return pointer === undefined ? undefined : this.#drillDocument(document, pointer);
15276
15697
  }
@@ -15288,27 +15709,45 @@ class RuntimeExpressionEvaluator {
15288
15709
  * `$sourceDescriptions.{name}.url` yields the source's URL. An operationId
15289
15710
  * that collides with a field name takes precedence (tier 1 wins).
15290
15711
  *
15712
+ * The referenced document is acquired only when the registry can load the
15713
+ * source's `type`; a source no provider loads (e.g. AsyncAPI) resolves by
15714
+ * tier 2 alone. When acquiring fails, a `{reference}` naming a field present
15715
+ * on the Source Description Object still resolves to that field — it does
15716
+ * not depend on the document — and any other reference rethrows the load
15717
+ * error, since nothing else can produce its value.
15718
+ *
15291
15719
  * Returns `undefined` when nothing matches.
15292
15720
  */
15293
- #sourceDescription({
15721
+ async #sourceDescription({
15294
15722
  sourceName,
15295
15723
  reference,
15296
15724
  stepsReference
15297
15725
  }) {
15298
- const uri = this.#document?.resolveSourceDescriptionURI(sourceName);
15726
+ const document = this.#document;
15727
+ const uri = document?.resolveSourceDescriptionURI(sourceName);
15728
+ const type = document?.resolveSourceDescriptionField(sourceName, 'type');
15729
+ const field = document?.resolveSourceDescriptionField(sourceName, reference);
15299
15730
 
15300
15731
  // tier 1: operationId / workflowId / workflow step in the referenced document.
15301
- const apiDocument = uri === undefined ? undefined : this.#registry?.get(uri);
15732
+ let apiDocument;
15733
+ if (uri !== undefined && this.#registry !== undefined && this.#registry.canLoad(typeof type === 'string' ? type : undefined)) {
15734
+ try {
15735
+ apiDocument = await this.#registry.acquire(uri);
15736
+ } catch (error) {
15737
+ const unloadable = error instanceof _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_7__["default"] || error instanceof _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_8__["default"];
15738
+ if (!unloadable || field === undefined) throw error;
15739
+ }
15740
+ }
15302
15741
  if (apiDocument !== undefined) {
15303
15742
  if (stepsReference !== undefined) {
15304
15743
  return this.#step(apiDocument, stepsReference.workflowId, stepsReference.stepId);
15305
15744
  }
15306
- const pointer = _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_8__["default"].is(apiDocument) ? apiDocument.operationIndex.get(reference) : _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_7__["default"].is(apiDocument) ? apiDocument.workflowIndex.get(reference) : undefined;
15745
+ 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
15746
  if (pointer !== undefined) return this.#drillDocument(apiDocument, pointer);
15308
15747
  }
15309
15748
 
15310
15749
  // tier 2: a field of the Source Description Object (url, type, ...).
15311
- return this.#document?.resolveSourceDescriptionField(sourceName, reference);
15750
+ return field;
15312
15751
  }
15313
15752
 
15314
15753
  /**
@@ -16380,6 +16819,335 @@ class OpenAPIOperationNormalizer {
16380
16819
  /* harmony export */ ]);
16381
16820
 
16382
16821
 
16822
+ /***/ },
16823
+
16824
+ /***/ 12993
16825
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
16826
+
16827
+ "use strict";
16828
+ __webpack_require__.r(__webpack_exports__);
16829
+ /* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34606);
16830
+
16831
+
16832
+ /**
16833
+ * An event without its `timestamp`, which the channel stamps. Distributes over
16834
+ * a union, so each member keeps its own discriminated shape.
16835
+ * @internal
16836
+ */
16837
+
16838
+ /**
16839
+ * Options for the EventChannel.
16840
+ * @internal
16841
+ */
16842
+
16843
+ /**
16844
+ * Delivers a building block's events to its observer: stamps each with the
16845
+ * block's clock, snapshots it, and hands it over synchronously, without
16846
+ * awaiting anything.
16847
+ *
16848
+ * A block holds a channel only when it was given an observer (see
16849
+ * {@link EventChannel.open}), and emits through `this.#events?.emit(...)`: with
16850
+ * no channel, optional chaining skips evaluating the event too, so an
16851
+ * unobserved run builds no events at all.
16852
+ * @internal
16853
+ */
16854
+ class EventChannel {
16855
+ static #DEFAULT_NOW = () => performance.now();
16856
+
16857
+ /**
16858
+ * A channel to `options.observer`, or `undefined` when there is none.
16859
+ */
16860
+ static open(options) {
16861
+ const {
16862
+ observer,
16863
+ now
16864
+ } = options;
16865
+ return observer === undefined ? undefined : new EventChannel({
16866
+ observer,
16867
+ now
16868
+ });
16869
+ }
16870
+
16871
+ /**
16872
+ * A frozen deep copy of the plain objects and arrays in `value`; anything
16873
+ * else, an ApiDOM element above all, is shared as it is. The run keeps
16874
+ * using the objects an event describes (the trace's records, the outputs,
16875
+ * the context a request interceptor receives, the transition it acts on),
16876
+ * so handing out the originals would let an observer change the run.
16877
+ */
16878
+ static #snapshot(value, copies) {
16879
+ if (!Array.isArray(value) && !(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(value)) return value;
16880
+ const seen = copies.get(value);
16881
+ if (seen !== undefined) return seen;
16882
+ const copy = Array.isArray(value) ? [] : {};
16883
+ copies.set(value, copy);
16884
+ for (const [key, item] of Object.entries(value)) {
16885
+ // defined, not assigned: assigning an own `__proto__` key (JSON.parse
16886
+ // makes one) would set the copy's prototype instead of copying it.
16887
+ Object.defineProperty(copy, key, {
16888
+ value: EventChannel.#snapshot(item, copies),
16889
+ enumerable: true,
16890
+ writable: true,
16891
+ configurable: true
16892
+ });
16893
+ }
16894
+ return Object.freeze(copy);
16895
+ }
16896
+ #observer;
16897
+ #now;
16898
+ constructor(options) {
16899
+ this.#observer = options.observer;
16900
+ this.#now = options.now ?? EventChannel.#DEFAULT_NOW;
16901
+ }
16902
+
16903
+ /**
16904
+ * Emits the event. `timestamp` is the clock reading the event describes,
16905
+ * when the caller already took one (so a start/settled pair matches a
16906
+ * recorded duration exactly); otherwise the clock is read now.
16907
+ */
16908
+ emit(event, timestamp) {
16909
+ // an absent optional field of the event itself is omitted, never present as
16910
+ // undefined; undefined values inside its data (an output that resolved to
16911
+ // undefined) are kept.
16912
+ const fields = Object.entries(event).filter(([, value]) => value !== undefined);
16913
+ const stamped = {
16914
+ ...Object.fromEntries(fields),
16915
+ timestamp: timestamp ?? this.#now()
16916
+ };
16917
+ this.#observer(EventChannel.#snapshot(stamped, new WeakMap()));
16918
+ }
16919
+ }
16920
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EventChannel);
16921
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
16922
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
16923
+ /* harmony export */ ]);
16924
+
16925
+
16926
+ /***/ },
16927
+
16928
+ /***/ 4050
16929
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
16930
+
16931
+ "use strict";
16932
+ __webpack_require__.r(__webpack_exports__);
16933
+ /* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34606);
16934
+ /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(62823);
16935
+ /* harmony import */ var _swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(26847);
16936
+ /* harmony import */ var _swaggerexpert_json_pointer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(61198);
16937
+ /* harmony import */ var _swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(93504);
16938
+
16939
+
16940
+
16941
+
16942
+
16943
+
16944
+ /**
16945
+ * The parts of a parsed runtime expression that name what it reads.
16946
+ */
16947
+
16948
+ /**
16949
+ * A parsed media type, lowercased by the parser.
16950
+ */
16951
+
16952
+ /**
16953
+ * Options for the Redactor.
16954
+ * @public
16955
+ */
16956
+
16957
+ /**
16958
+ * Masks credentials in events before they leave the process.
16959
+ *
16960
+ * Events carry what the run saw, credentials included, like the request a
16961
+ * request interceptor receives. Pass every event through
16962
+ * {@link Redactor.event} before logging, exporting or writing it.
16963
+ *
16964
+ * It masks by name, whatever the event:
16965
+ *
16966
+ * - the value of any field whose name matches a pattern: headers, query
16967
+ * parameters, body and output fields, at any depth;
16968
+ * - a criterion value whose runtime expression reads a matching name, in its
16969
+ * base or in any token of its JSON Pointer (`$inputs.password`,
16970
+ * `$steps.login.outputs.token#/value`);
16971
+ * - in every absolute URL, as `URL` parses it, the userinfo and the matching
16972
+ * query and fragment parameters;
16973
+ * - a request or response body that is JSON or a URL-encoded form, field by
16974
+ * field, and any other body, or any object that is not plain data, whole.
16975
+ *
16976
+ * A credential under a name no pattern matches is carried as it is. The
16977
+ * masked value is `REDACTED`.
16978
+ * @public
16979
+ */
16980
+ class Redactor {
16981
+ static CENSOR = 'REDACTED';
16982
+
16983
+ /**
16984
+ * Elastic APM's `sanitizeFieldNames` defaults, with `*secret*` for its exact
16985
+ * `secret` (which misses OAuth's `client_secret`), plus the signed-URL query
16986
+ * parameters OpenTelemetry's HTTP conventions mask.
16987
+ */
16988
+ static defaultFields = Object.freeze(['password', 'passwd', 'pwd', '*secret*', '*key', '*token*', '*session*', '*credit*', '*card*', '*auth*', 'set-cookie', '*principal*', 'pw', 'pass', 'connect.sid', 'cookie', 'AWSAccessKeyId', 'Signature', 'sig', 'X-Goog-Signature']);
16989
+ #patterns;
16990
+ #matches = new Map();
16991
+ constructor(options = {}) {
16992
+ this.#patterns = (options.fields ?? Redactor.defaultFields).map(Redactor.#compile);
16993
+ }
16994
+
16995
+ /**
16996
+ * A masked copy of the event.
16997
+ */
16998
+ event(event) {
16999
+ return this.#walk(event, new WeakSet());
17000
+ }
17001
+ #walk(value, seen) {
17002
+ if (typeof value === 'string') return URL.canParse(value) ? this.#url(value) : value;
17003
+ if (typeof value !== 'object' || value === null) return value;
17004
+ // an ApiDOM element (a selected action) is the document's own, and a date
17005
+ // holds no credential; any other object that is not plain data cannot be
17006
+ // walked field by field.
17007
+ if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isElement)(value) || value instanceof Date) return value;
17008
+ if (!Array.isArray(value) && !(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(value)) return Redactor.CENSOR;
17009
+ // only the objects on the current path: a shared, acyclic one is walked
17010
+ // again where it reappears, a cycle is cut.
17011
+ if (seen.has(value)) return Redactor.CENSOR;
17012
+ seen.add(value);
17013
+ try {
17014
+ return Array.isArray(value) ? value.map(item => this.#walk(item, seen)) : this.#fields(value, seen);
17015
+ } finally {
17016
+ seen.delete(value);
17017
+ }
17018
+ }
17019
+ #fields(object, seen) {
17020
+ const redacted = {};
17021
+ for (const [name, item] of Object.entries(object)) {
17022
+ let masked;
17023
+ if (this.#masks(name)) masked = Redactor.CENSOR;else if (name === 'body' && (0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(object.headers)) {
17024
+ masked = this.#body(item, object.headers, seen);
17025
+ } else masked = this.#walk(item, seen);
17026
+ // defined, not assigned, so an own `__proto__` key stays data
17027
+ Object.defineProperty(redacted, name, {
17028
+ value: masked,
17029
+ enumerable: true,
17030
+ writable: true,
17031
+ configurable: true
17032
+ });
17033
+ }
17034
+ return redacted;
17035
+ }
17036
+
17037
+ /**
17038
+ * Whether a name matches a pattern. A runtime expression matches when any
17039
+ * name it reads does.
17040
+ */
17041
+ #masks(name) {
17042
+ let matches = this.#matches.get(name);
17043
+ if (matches === undefined) {
17044
+ const names = name.startsWith('$') ? Redactor.#namesRead(name) : [name];
17045
+ matches = names.some(candidate => this.#patterns.some(pattern => pattern.test(candidate)));
17046
+ this.#matches.set(name, matches);
17047
+ }
17048
+ return matches;
17049
+ }
17050
+
17051
+ /**
17052
+ * The absolute URL with its userinfo and matching query and fragment
17053
+ * parameters masked. A URL with nothing to mask comes back exactly as it
17054
+ * was, not normalized.
17055
+ */
17056
+ #url(value) {
17057
+ const url = new URL(value);
17058
+ let masked = false;
17059
+ if (url.username !== '' || url.password !== '') {
17060
+ url.username = Redactor.CENSOR;
17061
+ url.password = Redactor.CENSOR;
17062
+ masked = true;
17063
+ }
17064
+ const query = this.#params(url.search.slice(1));
17065
+ if (query !== undefined) {
17066
+ url.search = query;
17067
+ masked = true;
17068
+ }
17069
+ const fragment = this.#params(url.hash.slice(1));
17070
+ if (fragment !== undefined) {
17071
+ url.hash = fragment;
17072
+ masked = true;
17073
+ }
17074
+ return masked ? url.href : value;
17075
+ }
17076
+
17077
+ /**
17078
+ * A body masked by what its `Content-Type` says it is.
17079
+ */
17080
+ #body(body, headers, seen) {
17081
+ if (typeof body !== 'string' || body === '') return this.#walk(body, seen);
17082
+ const mediaType = Redactor.#contentType(headers);
17083
+ if (mediaType?.subtype === 'json' || mediaType?.suffix === 'json') {
17084
+ try {
17085
+ return JSON.stringify(this.#walk(JSON.parse(body), seen));
17086
+ } catch {
17087
+ return Redactor.CENSOR;
17088
+ }
17089
+ }
17090
+ if (mediaType?.type === 'application' && mediaType.subtype === 'x-www-form-urlencoded') {
17091
+ return this.#params(body) ?? body;
17092
+ }
17093
+ return Redactor.CENSOR;
17094
+ }
17095
+
17096
+ /**
17097
+ * URL-encoded `name=value` pairs with matching values masked, or
17098
+ * `undefined` when none matches, so the caller keeps the text as it was.
17099
+ */
17100
+ #params(text) {
17101
+ let masked = false;
17102
+ const params = [...new URLSearchParams(text)].map(([name, value]) => {
17103
+ if (!this.#masks(name)) return [name, value];
17104
+ masked = true;
17105
+ return [name, Redactor.CENSOR];
17106
+ });
17107
+ return masked ? new URLSearchParams(params).toString() : undefined;
17108
+ }
17109
+ static #contentType(headers) {
17110
+ const name = Object.keys(headers).find(key => key.toLowerCase() === 'content-type');
17111
+ if (name === undefined) return undefined;
17112
+ try {
17113
+ return (0,_swaggerexpert_media_types__WEBPACK_IMPORTED_MODULE_4__.parse)(headers[name], {
17114
+ type: 'media-type'
17115
+ }).tree;
17116
+ } catch {
17117
+ return undefined;
17118
+ }
17119
+ }
17120
+
17121
+ /**
17122
+ * Every name a runtime expression reads: the header, query, path, input,
17123
+ * output or component name, and each token of its JSON Pointer, e.g.
17124
+ * `token` and `value` for `$steps.login.outputs.token#/value`. A string
17125
+ * that does not parse as an expression is its own name.
17126
+ */
17127
+ static #namesRead(expression) {
17128
+ let tree;
17129
+ try {
17130
+ tree = (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_2__.parse)(expression).tree;
17131
+ } catch {
17132
+ return [expression];
17133
+ }
17134
+ if (tree === undefined) return [expression];
17135
+ const reference = tree.source?.reference;
17136
+ const tokens = (tree.jsonPointer ?? reference?.jsonPointer)?.referenceTokens ?? [];
17137
+ const names = [reference?.token, reference?.name, tree.name, tree.outputName, tree.fieldName, tree.componentName, ...tokens.map(token => (0,_swaggerexpert_json_pointer__WEBPACK_IMPORTED_MODULE_3__.unescape)(token.value))];
17138
+ return names.filter(name => name !== undefined);
17139
+ }
17140
+ static #compile(pattern) {
17141
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
17142
+ return new RegExp(`^${escaped}$`, 'i');
17143
+ }
17144
+ }
17145
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Redactor);
17146
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
17147
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
17148
+ /* harmony export */ ]);
17149
+
17150
+
16383
17151
  /***/ },
16384
17152
 
16385
17153
  /***/ 4044
@@ -16396,6 +17164,8 @@ __webpack_require__.r(__webpack_exports__);
16396
17164
  /* harmony import */ var _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(40198);
16397
17165
  /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(46132);
16398
17166
  /* harmony import */ var _constants_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(89307);
17167
+ /* harmony import */ var _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(12993);
17168
+
16399
17169
 
16400
17170
 
16401
17171
 
@@ -16421,9 +17191,15 @@ __webpack_require__.r(__webpack_exports__);
16421
17191
  */
16422
17192
  class DocumentRegistry {
16423
17193
  #documents = new Map();
17194
+ #loading = new Map();
16424
17195
  #providers;
17196
+ #events;
16425
17197
  constructor(options = {}) {
16426
17198
  this.#providers = options.providers ?? [new _providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](), new _providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]()];
17199
+ this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_9__["default"].open({
17200
+ observer: options.observer,
17201
+ now: options.now
17202
+ });
16427
17203
  }
16428
17204
 
16429
17205
  /**
@@ -16443,6 +17219,10 @@ class DocumentRegistry {
16443
17219
  * otherwise detects the format, loads via the matching provider,
16444
17220
  * caches, and returns it.
16445
17221
  *
17222
+ * Concurrent calls for a document that is still loading share that one
17223
+ * load instead of each fetching and parsing it. A failed load is not
17224
+ * remembered: the next call tries again.
17225
+ *
16446
17226
  * @throws DocumentLoadError - When the document cannot be read or loaded
16447
17227
  * @throws UnmatchedProviderError - When no provider can load the document
16448
17228
  */
@@ -16450,12 +17230,30 @@ class DocumentRegistry {
16450
17230
  const canonicalURI = this.#canonicalize(uri);
16451
17231
  const cachedDocument = this.#get(canonicalURI);
16452
17232
  if (cachedDocument) return cachedDocument;
17233
+ const loading = this.#loading.get(canonicalURI);
17234
+ if (loading) return loading;
17235
+ const load = this.#load(canonicalURI).finally(() => {
17236
+ // only its own entry: after clear(), a newer load may hold the key
17237
+ if (this.#loading.get(canonicalURI) === load) this.#loading.delete(canonicalURI);
17238
+ });
17239
+ this.#loading.set(canonicalURI, load);
17240
+ return load;
17241
+ }
17242
+
17243
+ /**
17244
+ * Loads a document through the first provider that can provide it, and
17245
+ * caches it.
17246
+ */
17247
+ async #load(canonicalURI) {
17248
+ this.#events?.emit({
17249
+ type: 'document-load-start',
17250
+ uri: canonicalURI
17251
+ });
16453
17252
  for (const provider of this.#providers) {
17253
+ let document;
16454
17254
  try {
16455
17255
  if (await provider.canProvide(canonicalURI)) {
16456
- const document = await provider.provide(canonicalURI);
16457
- this.#set(canonicalURI, document);
16458
- return document;
17256
+ document = await provider.provide(canonicalURI);
16459
17257
  }
16460
17258
  } catch (error) {
16461
17259
  // a document that cannot be read or loaded fails in ApiDOM or the parser;
@@ -16466,6 +17264,16 @@ class DocumentRegistry {
16466
17264
  cause: error
16467
17265
  });
16468
17266
  }
17267
+ if (document !== undefined) {
17268
+ // outside the try, so an observer's own error is not a failed load, and
17269
+ // before caching, so a run it aborts leaves no half-registered document.
17270
+ this.#events?.emit({
17271
+ type: 'document-load-settled',
17272
+ uri: canonicalURI
17273
+ });
17274
+ this.#set(canonicalURI, document);
17275
+ return document;
17276
+ }
16469
17277
  }
16470
17278
  throw new _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_7__["default"](`No provider can handle the document at "${canonicalURI}"`, {
16471
17279
  uri: canonicalURI
@@ -16473,16 +17281,17 @@ class DocumentRegistry {
16473
17281
  }
16474
17282
 
16475
17283
  /**
16476
- * Returns an already-loaded document by URI, or undefined if not cached.
17284
+ * Whether a source description of `type` can be loaded at all: some provider
17285
+ * loads that type, or does not say which type it loads. A source with no
17286
+ * `type` may be of any type, so it can.
16477
17287
  *
16478
- * Synchronous counterpart to `acquire`: it never loads a document, only
16479
- * returns one the registry already holds, marking it most recently used like
16480
- * any other access. Consumers that must resolve a reference without awaiting
16481
- * (e.g. runtime expression evaluation) use this; the executor is responsible
16482
- * for having acquired the document beforehand.
17288
+ * Answered from the providers alone, without fetching anything — so a
17289
+ * caller can skip a load that could only fail, such as an AsyncAPI source
17290
+ * while no provider loads AsyncAPI.
16483
17291
  */
16484
- get(uri) {
16485
- return this.#get(this.#canonicalize(uri));
17292
+ canLoad(type) {
17293
+ if (type === undefined) return true;
17294
+ return this.#providers.some(provider => provider.sourceDescriptionType === undefined || provider.sourceDescriptionType === type);
16486
17295
  }
16487
17296
 
16488
17297
  /**
@@ -16518,8 +17327,14 @@ class DocumentRegistry {
16518
17327
  document.isEntry = true;
16519
17328
  return document;
16520
17329
  }
17330
+
17331
+ /**
17332
+ * Drops every cached document. A load still in progress is no longer shared:
17333
+ * the next `acquire` of that document starts a fresh load.
17334
+ */
16521
17335
  clear() {
16522
17336
  this.#documents.clear();
17337
+ this.#loading.clear();
16523
17338
  }
16524
17339
 
16525
17340
  /**
@@ -16648,6 +17463,7 @@ const providerOptionsOverride = {
16648
17463
  * @public
16649
17464
  */
16650
17465
  class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_12__["default"] {
17466
+ sourceDescriptionType = 'arazzo';
16651
17467
  #options;
16652
17468
  constructor(options = {}) {
16653
17469
  super();
@@ -16677,11 +17493,13 @@ class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPA
16677
17493
  */
16678
17494
  async provide(uri) {
16679
17495
  const parseResult = await (0,_usearazzo_parser__WEBPACK_IMPORTED_MODULE_0__.parse)(uri, this.#buildParseOptions());
17496
+ this.assertParsed(uri, parseResult);
16680
17497
  const {
16681
17498
  workflowIndex,
16682
17499
  stepIndex,
16683
17500
  sourceDescriptionIndex
16684
17501
  } = this.#buildIndexes(uri, parseResult);
17502
+ ArazzoDocumentRegistryProvider.#recordPointers(parseResult);
16685
17503
  return new _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_11__["default"](uri, parseResult, workflowIndex, stepIndex, sourceDescriptionIndex);
16686
17504
  }
16687
17505
 
@@ -16741,6 +17559,24 @@ class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPA
16741
17559
  sourceDescriptionIndex
16742
17560
  };
16743
17561
  }
17562
+
17563
+ /**
17564
+ * Records, in each element's `json-pointer` meta, where it is written: every
17565
+ * workflow, step, criterion and action, its `components` included, and
17566
+ * every `dependsOn` entry. The record travels with the element through
17567
+ * normalization, so an inherited or referenced element keeps the pointer of
17568
+ * where it is defined, for the events to locate it by.
17569
+ */
17570
+ static #recordPointers(parseResult) {
17571
+ ;(0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_8__.traverse)(parseResult.api, {
17572
+ enter(path) {
17573
+ const element = path.node;
17574
+ const located = (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isWorkflowElement)(element) || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isStepElement)(element) || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isCriterionElement)(element) || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isSuccessActionElement)(element) || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isFailureActionElement)(element) || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_9__.isWorkflowDependsOnElement)(path.parentPath?.node);
17575
+ if (!located) return;
17576
+ element.meta.set('json-pointer', path.formatPath('jsonpointer'));
17577
+ }
17578
+ });
17579
+ }
16744
17580
  #buildParseOptions() {
16745
17581
  return (0,_speclynx_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_4__.merge)(_usearazzo_parser__WEBPACK_IMPORTED_MODULE_0__.defaultOptions, this.#options);
16746
17582
  }
@@ -16760,6 +17596,10 @@ class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPA
16760
17596
  "use strict";
16761
17597
  __webpack_require__.r(__webpack_exports__);
16762
17598
  /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32420);
17599
+ /* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7456);
17600
+ /* harmony import */ var _usearazzo_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(94433);
17601
+
17602
+
16763
17603
 
16764
17604
  /**
16765
17605
  * Replaces circular $ref references with an empty ObjectElement
@@ -16783,7 +17623,37 @@ const circularReplacer = ref => new _speclynx_apidom_datamodel__WEBPACK_IMPORTED
16783
17623
  * Subclasses implement `canProvide()` for format detection and `provide()` for loading.
16784
17624
  * @public
16785
17625
  */
16786
- class DocumentRegistryProvider {}
17626
+ class DocumentRegistryProvider {
17627
+ /**
17628
+ * The Source Description Object `type` this provider loads (`openapi`,
17629
+ * `arazzo`, …), or `undefined` when it does not say — then it may load a
17630
+ * source of any type.
17631
+ *
17632
+ * Lets the registry tell, without fetching anything, whether a source of a
17633
+ * given type can be loaded at all (`DocumentRegistry.canLoad`).
17634
+ */
17635
+ sourceDescriptionType;
17636
+
17637
+ /**
17638
+ * Checks if the content at the URI can be handled by this provider.
17639
+ */
17640
+
17641
+ /**
17642
+ * Loads and produces a document from a URI.
17643
+ */
17644
+
17645
+ /**
17646
+ * Rejects a document the parser could only partly read. The strict parsers
17647
+ * throw on a syntax error; the lenient ones that source maps need record it
17648
+ * and parse what they can instead, so a document must load with source maps
17649
+ * exactly when it loads without.
17650
+ */
17651
+ assertParsed(uri, parseResult) {
17652
+ const [error] = parseResult.errors;
17653
+ if (error === undefined) return;
17654
+ throw new _usearazzo_parser__WEBPACK_IMPORTED_MODULE_2__["default"](`Failed to parse the document at "${uri}": ${(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])(error)}`);
17655
+ }
17656
+ }
16787
17657
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DocumentRegistryProvider);
16788
17658
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
16789
17659
  /* harmony export */ "circularReplacer", 0, /* binding */ circularReplacer,
@@ -16855,6 +17725,7 @@ const providerOptionsOverride = {
16855
17725
  * @public
16856
17726
  */
16857
17727
  class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_11__["default"] {
17728
+ sourceDescriptionType = 'openapi';
16858
17729
  #options;
16859
17730
  constructor(options = {}) {
16860
17731
  super();
@@ -16884,10 +17755,11 @@ class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBP
16884
17755
  */
16885
17756
  async provide(uri) {
16886
17757
  const parseResult = await (0,_usearazzo_parser__WEBPACK_IMPORTED_MODULE_0__.parse)(uri, this.#buildParseOptions());
16887
- const operationIndex = await this.#buildOperationIndex(parseResult);
17758
+ this.assertParsed(uri, parseResult);
17759
+ const operationIndex = await this.#buildOperationIndex(uri, parseResult);
16888
17760
  return new _document_OpenAPIDocument_ts__WEBPACK_IMPORTED_MODULE_10__["default"](uri, parseResult, operationIndex);
16889
17761
  }
16890
- async #buildOperationIndex(parseResult) {
17762
+ async #buildOperationIndex(uri, parseResult) {
16891
17763
  const index = new _document_OpenAPIOperationIndex_ts__WEBPACK_IMPORTED_MODULE_12__["default"]();
16892
17764
  const dereferenceOptions = this.#buildDereferenceOptions(parseResult);
16893
17765
  const apiDereferenced = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_7__.traverseAsync)(parseResult.api, {
@@ -16895,16 +17767,37 @@ class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider_ts__WEBP
16895
17767
  const pathItem = path.node;
16896
17768
  if (!pathItem.hasMetaProperty('path')) return path.skip();
16897
17769
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(pathItem.$ref)) return;
16898
- const pathItemDereferenced = await (0,_usearazzo_resolver__WEBPACK_IMPORTED_MODULE_1__.dereferenceElement)(pathItem, dereferenceOptions);
16899
- path.replaceWith(pathItemDereferenced);
17770
+
17771
+ // an operation written next to the `$ref` stays where it is written
17772
+ const pointer = path.formatPath('jsonpointer');
17773
+ pathItem.forEach((value, key) => {
17774
+ if (value.element !== 'operation') return;
17775
+ value.meta.set('json-pointer', `${pointer}/${(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(key)}`);
17776
+ });
17777
+ path.replaceWith(await (0,_usearazzo_resolver__WEBPACK_IMPORTED_MODULE_1__.dereferenceElement)(pathItem, dereferenceOptions));
16900
17778
  },
16901
17779
  OperationElement(path) {
16902
17780
  const operation = path.node;
16903
17781
  const operationId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(operation.operationId);
17782
+ const pointer = path.formatPath('jsonpointer');
17783
+ // where the operation is written, for the events to locate it by: an
17784
+ // operation of a `$ref` path item is written where that path item is,
17785
+ // unless it was written next to the `$ref` and so already located
17786
+ if (!operation.hasMetaProperty('json-pointer')) {
17787
+ const member = path.parentPath?.node;
17788
+ const pathItem = path.parentPath?.parentPath?.node;
17789
+ const definition = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(pathItem.meta.get('ref-origin-pointer'));
17790
+ if (typeof definition === 'string') {
17791
+ operation.meta.set('ref-origin', (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(pathItem.meta.get('ref-origin')));
17792
+ operation.meta.set('json-pointer', `${definition}/${(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(member.key)}`);
17793
+ } else {
17794
+ operation.meta.set('json-pointer', pointer);
17795
+ }
17796
+ }
16904
17797
  if (typeof operationId !== 'string') return path.skip();
16905
17798
  if (operationId === '') return path.skip();
16906
17799
  if (index.has(operationId)) return path.skip();
16907
- index.set(operationId, path.formatPath('jsonpointer'));
17800
+ index.set(operationId, pointer);
16908
17801
  path.skip();
16909
17802
  }
16910
17803
  });
@@ -16948,11 +17841,14 @@ __webpack_require__.r(__webpack_exports__);
16948
17841
 
16949
17842
 
16950
17843
  /**
16951
- * Resolves a runtime expression to its value.
17844
+ * Resolves a runtime expression to its value, or to a Promise of it.
16952
17845
  *
16953
17846
  * Bridged to a lenient runtime expression evaluator
16954
17847
  * (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
16955
- * unresolvable reference yields `undefined` rather than throwing.
17848
+ * unresolvable reference yields `undefined` rather than throwing; a
17849
+ * `$sourceDescriptions` document that cannot be loaded still rejects with the
17850
+ * load error (see `RuntimeExpressionEvaluator.evaluate`). The result
17851
+ * is awaited, so a synchronous resolver works too.
16956
17852
  * @public
16957
17853
  */
16958
17854
 
@@ -16975,7 +17871,7 @@ class ArazzoValueResolver {
16975
17871
  /**
16976
17872
  * Resolves one authored value element by the rule above.
16977
17873
  */
16978
- resolveValue(element, resolve) {
17874
+ async resolveValue(element, resolve) {
16979
17875
  const value = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
16980
17876
  return typeof value === 'string' && (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_1__.test)(value) ? resolve(value) : value;
16981
17877
  }
@@ -17054,7 +17950,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
17054
17950
  *
17055
17951
  * `scope` names the step in a thrown {@link ResolverError}.
17056
17952
  */
17057
- resolve(parameters, resolve, scope) {
17953
+ async resolve(parameters, resolve, scope) {
17058
17954
  const delivery = new _client_ParameterDelivery_ts__WEBPACK_IMPORTED_MODULE_2__["default"]();
17059
17955
  if (parameters === undefined) return delivery.toRecord();
17060
17956
  // present but scalar: walking it would fail as a bare
@@ -17118,7 +18014,7 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver_ts__WEBPA
17118
18014
  reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_4__["default"].AmbiguousDelivery
17119
18015
  });
17120
18016
  }
17121
- delivery.set(key, this.resolveValue(parameter.value, resolve));
18017
+ delivery.set(key, await this.resolveValue(parameter.value, resolve));
17122
18018
  }
17123
18019
  return delivery.toRecord();
17124
18020
  }
@@ -17168,7 +18064,7 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
17168
18064
  * {@link ResolverError}. An output value that is not a valid runtime
17169
18065
  * expression throws with reason `ResolverError.InvalidExpression`.
17170
18066
  */
17171
- resolve(outputs, resolve, scope) {
18067
+ async resolve(outputs, resolve, scope) {
17172
18068
  const result = {};
17173
18069
  if (outputs === undefined) return result;
17174
18070
  // present but not a map: the walk below would fail as a bare
@@ -17180,7 +18076,14 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
17180
18076
  reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_3__["default"].MalformedOutputs
17181
18077
  });
17182
18078
  }
18079
+
18080
+ // collected first: `forEach` takes a synchronous callback, and each output
18081
+ // is awaited in turn below.
18082
+ const entries = [];
17183
18083
  outputs.forEach((value, key) => {
18084
+ entries.push([key, value]);
18085
+ });
18086
+ for (const [key, value] of entries) {
17184
18087
  const name = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(key);
17185
18088
  const expression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(value);
17186
18089
  if (typeof expression !== 'string' || !(0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_2__.test)(expression)) {
@@ -17195,12 +18098,12 @@ class OutputResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODULE_4_
17195
18098
  // ever created and the output is silently lost — and an object value
17196
18099
  // additionally rewrites the record's prototype
17197
18100
  Object.defineProperty(result, name, {
17198
- value: resolve(expression),
18101
+ value: await resolve(expression),
17199
18102
  enumerable: true,
17200
18103
  writable: true,
17201
18104
  configurable: true
17202
18105
  });
17203
- });
18106
+ }
17204
18107
  return result;
17205
18108
  }
17206
18109
  }
@@ -17286,7 +18189,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17286
18189
  *
17287
18190
  * `scope` names the step in a thrown {@link ResolverError}.
17288
18191
  */
17289
- resolve(requestBody, resolve, scope) {
18192
+ async resolve(requestBody, resolve, scope) {
17290
18193
  if (requestBody === undefined) return undefined;
17291
18194
 
17292
18195
  // present but scalar: `.payload`, `.replacements` and `.contentType` are
@@ -17300,7 +18203,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17300
18203
  });
17301
18204
  }
17302
18205
  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);
18206
+ let payload = this.#requireResolved(authoredPayload, await this.#resolvePayloadValue(authoredPayload, [], resolve, scope), [], scope);
17304
18207
  if (requestBody.replacements !== undefined) {
17305
18208
  // present but scalar: walking it would fail as a bare
17306
18209
  // `TypeError: requestBody.replacements is not iterable`.
@@ -17315,7 +18218,7 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17315
18218
  if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_6__.isPayloadReplacementElement)(replacement)) continue;
17316
18219
  const target = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(replacement.target);
17317
18220
  if (typeof target !== 'string') continue;
17318
- const value = this.resolveValue(replacement.value, resolve);
18221
+ const value = await this.resolveValue(replacement.value, resolve);
17319
18222
  if (value === undefined) continue;
17320
18223
  payload = this.#applyReplacement(payload, target, value, scope);
17321
18224
  }
@@ -17334,19 +18237,26 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17334
18237
  * objects and arrays. Returns {@link UNRESOLVED} for a bare expression that
17335
18238
  * did not resolve, for its container to handle.
17336
18239
  */
17337
- #resolvePayloadValue(value, tokens, resolve, scope) {
18240
+ async #resolvePayloadValue(value, tokens, resolve, scope) {
17338
18241
  if (typeof value === 'string') return this.#resolvePayloadString(value, tokens, resolve, scope);
17339
18242
  if (Array.isArray(value)) {
17340
- return value.map((item, index) => {
18243
+ const items = [];
18244
+ for (const [index, item] of value.entries()) {
17341
18245
  const itemTokens = [...tokens, String(index)];
17342
- const resolved = this.#resolvePayloadValue(item, itemTokens, resolve, scope);
17343
- return this.#requireResolved(item, resolved, itemTokens, scope);
17344
- });
18246
+ const resolved = await this.#resolvePayloadValue(item, itemTokens, resolve, scope);
18247
+ items.push(this.#requireResolved(item, resolved, itemTokens, scope));
18248
+ }
18249
+ return items;
17345
18250
  }
17346
18251
  if (value !== null && typeof value === 'object') {
18252
+ const members = [];
18253
+ for (const [key, member] of Object.entries(value)) {
18254
+ const resolved = await this.#resolvePayloadValue(member, [...tokens, key], resolve, scope);
18255
+ if (resolved !== UNRESOLVED) members.push([key, resolved]);
18256
+ }
17347
18257
  // `fromEntries` defines own properties, so an authored `__proto__` key
17348
18258
  // stays a plain member instead of replacing the prototype.
17349
- return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, this.#resolvePayloadValue(member, [...tokens, key], resolve, scope)]).filter(([, resolved]) => resolved !== UNRESOLVED));
18259
+ return Object.fromEntries(members);
17350
18260
  }
17351
18261
  return value;
17352
18262
  }
@@ -17356,16 +18266,12 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17356
18266
  * typed value (or {@link UNRESOLVED}), anything else by tolerant
17357
18267
  * interpolation of its embedded `{expression}` occurrences.
17358
18268
  */
17359
- #resolvePayloadString(value, tokens, resolve, scope) {
18269
+ async #resolvePayloadString(value, tokens, resolve, scope) {
17360
18270
  if ((0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.test)(value)) {
17361
- const resolved = resolve(value);
18271
+ const resolved = await resolve(value);
17362
18272
  return resolved === undefined ? UNRESOLVED : resolved;
17363
18273
  }
17364
- return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.interpolate)(value, expression => {
17365
- const resolved = resolve(expression);
17366
- if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
17367
- return resolved;
17368
- }, {
18274
+ const options = {
17369
18275
  strict: false,
17370
18276
  onError: ({
17371
18277
  text
@@ -17376,7 +18282,24 @@ class RequestBodyResolver extends _ArazzoValueResolver_ts__WEBPACK_IMPORTED_MODU
17376
18282
  reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_7__["default"].InvalidExpression
17377
18283
  });
17378
18284
  }
17379
- });
18285
+ };
18286
+
18287
+ // `interpolate` takes a synchronous resolver, so the embedded expressions
18288
+ // are collected by a first pass, resolved in order, and substituted by a
18289
+ // second. Interpolation never skips an expression, so the result is the same.
18290
+ const expressions = [];
18291
+ (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.interpolate)(value, expression => {
18292
+ expressions.push(expression);
18293
+ return '';
18294
+ }, options);
18295
+ const values = new Map();
18296
+ for (const expression of expressions) {
18297
+ if (values.has(expression)) continue;
18298
+ const resolved = await resolve(expression);
18299
+ if (resolved === undefined) throw this.#unresolvedError(expression, tokens, scope);
18300
+ values.set(expression, resolved);
18301
+ }
18302
+ return (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_5__.interpolate)(value, expression => values.get(expression), options);
17380
18303
  }
17381
18304
 
17382
18305
  /**
@@ -17522,7 +18445,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
17522
18445
  *
17523
18446
  * `scope` names the step in a thrown {@link ResolverError}.
17524
18447
  */
17525
- resolve(parameters, resolve, scope) {
18448
+ async resolve(parameters, resolve, scope) {
17526
18449
  const result = {};
17527
18450
  if (parameters === undefined) return result;
17528
18451
  // present but scalar: walking it would fail as a bare
@@ -17548,7 +18471,7 @@ class WorkflowParameterResolver extends _StepParameterResolver_ts__WEBPACK_IMPOR
17548
18471
  // ever created and the input is silently lost — and an object value
17549
18472
  // additionally rewrites the record's prototype
17550
18473
  Object.defineProperty(result, name, {
17551
- value: this.resolveValue(parameter.value, resolve),
18474
+ value: await this.resolveValue(parameter.value, resolve),
17552
18475
  enumerable: true,
17553
18476
  writable: true,
17554
18477
  configurable: true
@@ -60580,18 +61503,16 @@ class DereferenceVisitor {
60580
61503
  toTranscludedElement(referencingElement, transclusion) {
60581
61504
  // the referencing element waits for an enclosing element to transclude it
60582
61505
  if (transclusion.keep) return referencingElement;
61506
+ let target = transclusion.target.element;
60583
61507
  // an alias whose reference never reaches a value
60584
61508
  if (transclusion.target.unresolved) {
60585
61509
  const {
60586
61510
  aliasField
60587
61511
  } = transclusion;
60588
- const alias = transclusion.target.element;
60589
- if (aliasField === undefined || !(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isObjectElement)(alias)) return referencingElement;
60590
- const fields = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(alias);
60591
- fields.remove(aliasField);
60592
- return transclusion.toTranscludedElement(referencingElement, fields);
60593
- }
60594
- if (transclusion.back && this.options.dereference.circular === 'replace') {
61512
+ if (aliasField === undefined || !(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isObjectElement)(target)) return referencingElement;
61513
+ target = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(target);
61514
+ target.remove(aliasField);
61515
+ } else if (transclusion.back && this.options.dereference.circular === 'replace') {
60595
61516
  const refElement = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_10__["default"](transclusion.circular.uri, {
60596
61517
  type: referencingElement.element,
60597
61518
  ...transclusion.circular.meta
@@ -60599,7 +61520,21 @@ class DereferenceVisitor {
60599
61520
  const replacer = this.options.dereference.strategyOpts[this.strategyName]?.circularReplacer ?? this.options.dereference.circularReplacer;
60600
61521
  return replacer(refElement);
60601
61522
  }
60602
- return transclusion.toTranscludedElement(referencingElement, transclusion.target.element);
61523
+ const transcludedElement = transclusion.toTranscludedElement(referencingElement, target);
61524
+ const {
61525
+ origin
61526
+ } = transclusion;
61527
+ // an element used as it is isn't annotated, and a transcluded target (a chain of references)
61528
+ // is defined where its own annotation says, which the element cloned from it carries
61529
+ if (origin === undefined || transcludedElement === target || transcludedElement === referencingElement || !target.isMetaEmpty && target.meta.hasKey('ref-type')) {
61530
+ return transcludedElement;
61531
+ }
61532
+ transcludedElement.meta.set('ref-origin', origin.uri);
61533
+ // an alias whose reference never reaches a value has no content to point at
61534
+ if (origin.jsonPointer !== undefined && !transclusion.target.unresolved) {
61535
+ transcludedElement.meta.set('ref-origin-pointer', origin.jsonPointer);
61536
+ }
61537
+ return transcludedElement;
60603
61538
  }
60604
61539
 
60605
61540
  /**
@@ -61408,8 +62343,7 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61408
62343
  reference: runtimeExpression,
61409
62344
  value: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__["default"])(reusableElement.value)
61410
62345
  });
61411
- // annotate with info about origin
61412
- mergedElement.meta.set('ref-origin', this.reference.uri);
62346
+ // annotate with info about type
61413
62347
  mergedElement.meta.set('ref-type', element.element);
61414
62348
 
61415
62349
  // override value field if present for Parameter Objects
@@ -61419,6 +62353,10 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61419
62353
  }
61420
62354
  return mergedElement;
61421
62355
  },
62356
+ origin: {
62357
+ uri: _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(this.reference.uri),
62358
+ jsonPointer
62359
+ },
61422
62360
  circular: {
61423
62361
  uri: runtimeExpression,
61424
62362
  meta: {
@@ -61469,6 +62407,8 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61469
62407
  let referencedElement;
61470
62408
  // $ids of the schemas enclosing the referenced element within its document
61471
62409
  let ancestorSchema$ids;
62410
+ // known when the reference is resolved by JSON Pointer against its document
62411
+ let jsonPointer;
61472
62412
  try {
61473
62413
  if (isUnknownURI || isURL) {
61474
62414
  // we're dealing with canonical URI or URL with possible fragment
@@ -61574,12 +62514,12 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61574
62514
  return;
61575
62515
  }
61576
62516
  reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize($refBaseURI));
61577
- const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.URIFragmentIdentifier.fromURIReference($refBaseURI);
62517
+ jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.URIFragmentIdentifier.fromURIReference($refBaseURI);
61578
62518
  const referenceAsSchema = this.toJSONSchemaDocument(reference.value.result);
61579
62519
  ({
61580
62520
  element: referencedElement,
61581
62521
  ancestorSchema$ids
61582
- } = (0,_openapi_3_1_selectors_json_pointer_mjs__WEBPACK_IMPORTED_MODULE_17__.locate)(referenceAsSchema, selector));
62522
+ } = (0,_openapi_3_1_selectors_json_pointer_mjs__WEBPACK_IMPORTED_MODULE_17__.locate)(referenceAsSchema, jsonPointer));
61583
62523
  }
61584
62524
  } else {
61585
62525
  throw error;
@@ -61612,8 +62552,7 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61612
62552
  booleanJsonSchemaElement.meta.set('ref-fields', {
61613
62553
  $ref
61614
62554
  });
61615
- // annotate referenced element with info about origin
61616
- booleanJsonSchemaElement.meta.set('ref-origin', origin);
62555
+ // annotate referenced element with info about type
61617
62556
  booleanJsonSchemaElement.meta.set('ref-type', element.element);
61618
62557
  return booleanJsonSchemaElement;
61619
62558
  }
@@ -61633,12 +62572,15 @@ class Arazzo1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORTE
61633
62572
  mergedElement.meta.set('ref-fields', {
61634
62573
  $ref
61635
62574
  });
61636
- // annotate fragment with info about origin
61637
- mergedElement.meta.set('ref-origin', origin);
62575
+ // annotate fragment with info about type
61638
62576
  mergedElement.meta.set('ref-type', element.element);
61639
62577
  return mergedElement;
61640
62578
  },
61641
62579
  aliasField: '$ref',
62580
+ origin: {
62581
+ uri: origin,
62582
+ jsonPointer
62583
+ },
61642
62584
  circular: {
61643
62585
  uri: $refBaseURI,
61644
62586
  meta: {
@@ -61877,11 +62819,14 @@ class OpenAPI2DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORT
61877
62819
  mergedElement.meta.set('ref-fields', {
61878
62820
  $ref
61879
62821
  });
61880
- // annotate fragment with info about origin
61881
- mergedElement.meta.set('ref-origin', reference.uri);
62822
+ // annotate fragment with info about type
61882
62823
  mergedElement.meta.set('ref-type', element.element);
61883
62824
  return mergedElement;
61884
62825
  },
62826
+ origin: {
62827
+ uri: reference.uri,
62828
+ jsonPointer
62829
+ },
61885
62830
  circular: {
61886
62831
  uri: $refBaseURI,
61887
62832
  meta: {
@@ -61960,12 +62905,15 @@ class OpenAPI2DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORT
61960
62905
  mergedElement.meta.set('ref-fields', {
61961
62906
  $ref
61962
62907
  });
61963
- // annotate referenced element with info about origin and type
61964
- mergedElement.meta.set('ref-origin', reference.uri);
62908
+ // annotate referenced element with info about type
61965
62909
  mergedElement.meta.set('ref-type', element.element);
61966
62910
  return mergedElement;
61967
62911
  },
61968
62912
  aliasField: '$ref',
62913
+ origin: {
62914
+ uri: reference.uri,
62915
+ jsonPointer
62916
+ },
61969
62917
  circular: {
61970
62918
  uri: $refBaseURI,
61971
62919
  meta: {
@@ -62038,11 +62986,14 @@ class OpenAPI2DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPORT
62038
62986
  mergedElement.meta.set('ref-fields', {
62039
62987
  $ref
62040
62988
  });
62041
- // annotate fragment with info about origin
62042
- mergedElement.meta.set('ref-origin', reference.uri);
62989
+ // annotate fragment with info about type
62043
62990
  mergedElement.meta.set('ref-type', element.element);
62044
62991
  return mergedElement;
62045
62992
  },
62993
+ origin: {
62994
+ uri: reference.uri,
62995
+ jsonPointer
62996
+ },
62046
62997
  circular: {
62047
62998
  uri: $refBaseURI,
62048
62999
  meta: {
@@ -62276,11 +63227,14 @@ class OpenAPI3_0DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
62276
63227
  mergedElement.meta.set('ref-fields', {
62277
63228
  $ref
62278
63229
  });
62279
- // annotate fragment with info about origin
62280
- mergedElement.meta.set('ref-origin', reference.uri);
63230
+ // annotate fragment with info about type
62281
63231
  mergedElement.meta.set('ref-type', element.element);
62282
63232
  return mergedElement;
62283
63233
  },
63234
+ origin: {
63235
+ uri: reference.uri,
63236
+ jsonPointer
63237
+ },
62284
63238
  circular: {
62285
63239
  uri: $refBaseURI,
62286
63240
  meta: {
@@ -62359,12 +63313,15 @@ class OpenAPI3_0DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
62359
63313
  mergedElement.meta.set('ref-fields', {
62360
63314
  $ref
62361
63315
  });
62362
- // annotate referenced element with info about origin and type
62363
- mergedElement.meta.set('ref-origin', reference.uri);
63316
+ // annotate referenced element with info about type
62364
63317
  mergedElement.meta.set('ref-type', element.element);
62365
63318
  return mergedElement;
62366
63319
  },
62367
63320
  aliasField: '$ref',
63321
+ origin: {
63322
+ uri: reference.uri,
63323
+ jsonPointer
63324
+ },
62368
63325
  circular: {
62369
63326
  uri: $refBaseURI,
62370
63327
  meta: {
@@ -62430,6 +63387,7 @@ class OpenAPI3_0DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
62430
63387
  const operationCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.cloneShallow)(target);
62431
63388
  // annotate operation element with info about origin and type
62432
63389
  operationCopy.meta.set('ref-origin', reference.uri);
63390
+ operationCopy.meta.set('ref-origin-pointer', jsonPointer);
62433
63391
  operationCopy.meta.set('ref-type', element.element);
62434
63392
 
62435
63393
  /**
@@ -62460,8 +63418,14 @@ class OpenAPI3_0DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
62460
63418
  /**
62461
63419
  * Transclude Link Object containing Operation Object in its meta.
62462
63420
  */
63421
+ // create shallow clone to be able to annotate with metadata
63422
+ const operationCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.cloneShallow)(target);
63423
+ // annotate operation element with info about origin and type
63424
+ operationCopy.meta.set('ref-origin', reference.uri);
63425
+ operationCopy.meta.set('ref-origin-pointer', operationPath.formatPath());
63426
+ operationCopy.meta.set('ref-type', element.element);
62463
63427
  const linkElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.cloneShallow)(element);
62464
- linkElementCopy.operationId?.meta.set('operation', target);
63428
+ linkElementCopy.operationId?.meta.set('operation', operationCopy);
62465
63429
  return linkElementCopy;
62466
63430
  });
62467
63431
  } catch (error) {
@@ -62517,6 +63481,7 @@ class OpenAPI3_0DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
62517
63481
  const valueElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.cloneShallow)(target);
62518
63482
  // annotate element with info about origin and type
62519
63483
  valueElement.meta.set('ref-origin', reference.uri);
63484
+ valueElement.meta.set('ref-origin-pointer', '');
62520
63485
  valueElement.meta.set('ref-type', element.element);
62521
63486
 
62522
63487
  /**
@@ -63227,8 +64192,7 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63227
64192
  description: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(reusingElement.get('description')),
63228
64193
  summary: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(reusingElement.get('summary'))
63229
64194
  });
63230
- // annotate fragment with info about origin and type
63231
- mergedElement.meta.set('ref-origin', reference.uri);
64195
+ // annotate fragment with info about type
63232
64196
  mergedElement.meta.set('ref-type', element.element);
63233
64197
 
63234
64198
  // override description and summary (outer has higher priority then inner)
@@ -63247,6 +64211,10 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63247
64211
  }
63248
64212
  return mergedElement;
63249
64213
  },
64214
+ origin: {
64215
+ uri: reference.uri,
64216
+ jsonPointer
64217
+ },
63250
64218
  circular: {
63251
64219
  uri: $refBaseURI,
63252
64220
  meta: {
@@ -63327,12 +64295,15 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63327
64295
  mergedElement.meta.set('ref-fields', {
63328
64296
  $ref
63329
64297
  });
63330
- // annotate referenced element with info about origin and type
63331
- mergedElement.meta.set('ref-origin', reference.uri);
64298
+ // annotate referenced element with info about type
63332
64299
  mergedElement.meta.set('ref-type', element.element);
63333
64300
  return mergedElement;
63334
64301
  },
63335
64302
  aliasField: '$ref',
64303
+ origin: {
64304
+ uri: reference.uri,
64305
+ jsonPointer
64306
+ },
63336
64307
  circular: {
63337
64308
  uri: $refBaseURI,
63338
64309
  meta: {
@@ -63400,6 +64371,7 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63400
64371
  const operationCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(target);
63401
64372
  // annotate operation element with info about origin and type
63402
64373
  operationCopy.meta.set('ref-origin', reference.uri);
64374
+ operationCopy.meta.set('ref-origin-pointer', jsonPointer);
63403
64375
  operationCopy.meta.set('ref-type', element.element);
63404
64376
 
63405
64377
  /**
@@ -63432,8 +64404,14 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63432
64404
  /**
63433
64405
  * Transclude Link Object containing Operation Object in its meta.
63434
64406
  */
64407
+ // create shallow clone to be able to annotate with metadata
64408
+ const operationCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(target);
64409
+ // annotate operation element with info about origin and type
64410
+ operationCopy.meta.set('ref-origin', reference.uri);
64411
+ operationCopy.meta.set('ref-origin-pointer', operationPath.formatPath());
64412
+ operationCopy.meta.set('ref-type', element.element);
63435
64413
  const linkElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(element);
63436
- linkElementCopy.operationId?.meta.set('operation', target);
64414
+ linkElementCopy.operationId?.meta.set('operation', operationCopy);
63437
64415
  return linkElementCopy;
63438
64416
  });
63439
64417
  } catch (error) {
@@ -63491,6 +64469,7 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63491
64469
  const valueElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(target);
63492
64470
  // annotate element with info about origin and type
63493
64471
  valueElement.meta.set('ref-origin', reference.uri);
64472
+ valueElement.meta.set('ref-origin-pointer', '');
63494
64473
  valueElement.meta.set('ref-type', element.element);
63495
64474
 
63496
64475
  /**
@@ -63539,6 +64518,8 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63539
64518
  let referencedElement;
63540
64519
  // $ids of the schemas enclosing the referenced element within its document
63541
64520
  let ancestorSchema$ids;
64521
+ // known when the reference is resolved by JSON Pointer against its document
64522
+ let jsonPointer;
63542
64523
  try {
63543
64524
  if (isUnknownURI || isURL) {
63544
64525
  // we're dealing with canonical URI or URL with possible fragment
@@ -63661,11 +64642,11 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63661
64642
  return;
63662
64643
  }
63663
64644
  reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_20__.unsanitize($refBaseURI));
63664
- const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__.URIFragmentIdentifier.fromURIReference($refBaseURI);
64645
+ jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__.URIFragmentIdentifier.fromURIReference($refBaseURI);
63665
64646
  ({
63666
64647
  element: referencedElement,
63667
64648
  ancestorSchema$ids
63668
- } = (0,_selectors_json_pointer_mjs__WEBPACK_IMPORTED_MODULE_17__.locate)(this.toSchemaDocument(reference.value.result), selector));
64649
+ } = (0,_selectors_json_pointer_mjs__WEBPACK_IMPORTED_MODULE_17__.locate)(this.toSchemaDocument(reference.value.result), jsonPointer));
63669
64650
  }
63670
64651
  } else {
63671
64652
  throw error;
@@ -63697,8 +64678,7 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63697
64678
  booleanJsonSchemaElement.meta.set('ref-fields', {
63698
64679
  $ref
63699
64680
  });
63700
- // annotate referenced element with info about origin and type
63701
- booleanJsonSchemaElement.meta.set('ref-origin', origin);
64681
+ // annotate referenced element with info about type
63702
64682
  booleanJsonSchemaElement.meta.set('ref-type', element.element);
63703
64683
  return booleanJsonSchemaElement;
63704
64684
  }
@@ -63718,12 +64698,15 @@ class OpenAPI3_1DereferenceVisitor extends _DereferenceVisitor_mjs__WEBPACK_IMPO
63718
64698
  mergedElement.meta.set('ref-fields', {
63719
64699
  $ref
63720
64700
  });
63721
- // annotate fragment with info about origin and type
63722
- mergedElement.meta.set('ref-origin', origin);
64701
+ // annotate fragment with info about type
63723
64702
  mergedElement.meta.set('ref-type', element.element);
63724
64703
  return mergedElement;
63725
64704
  },
63726
64705
  aliasField: '$ref',
64706
+ origin: {
64707
+ uri: origin,
64708
+ jsonPointer
64709
+ },
63727
64710
  circular: {
63728
64711
  uri: $refBaseURI,
63729
64712
  meta: {
@@ -68219,6 +69202,11 @@ __webpack_require__.r(__webpack_exports__);
68219
69202
  * receives the runtime expression string and its parsed sub-AST, and returns the
68220
69203
  * concrete value.
68221
69204
  *
69205
+ * `resolve` must return the value itself: a `resolve` returning a native Promise
69206
+ * (e.g. an `async` function) makes `evaluate` throw a `TypeError` rather than
69207
+ * compare the Promise object. Use `evaluateAsync` when values are only available
69208
+ * asynchronously.
69209
+ *
68222
69210
  * @example
68223
69211
  * evaluate('$statusCode == 200', {
68224
69212
  * resolve: (expression, ast) => (expression === '$statusCode' ? 200 : undefined),
@@ -68227,11 +69215,41 @@ __webpack_require__.r(__webpack_exports__);
68227
69215
  const evaluate = (condition, {
68228
69216
  resolve
68229
69217
  } = {}) => {
69218
+ const tree = prepare(condition, resolve, 'evaluate');
69219
+ return toBoolean(evaluateNode(tree, resolve));
69220
+ };
69221
+
69222
+ /**
69223
+ * Evaluate a "simple" Arazzo criterion condition whose runtime expression values
69224
+ * may only be available asynchronously.
69225
+ *
69226
+ * Same semantics as `evaluate`, except that `resolve` may return the value or a
69227
+ * Promise of it, which is awaited, and the result is always a Promise of a
69228
+ * boolean. Every failure (invalid input, an unparseable condition, a `resolve`
69229
+ * that throws or rejects) rejects the returned Promise. `&&` and `||` still
69230
+ * short-circuit: the right operand is resolved only after the left one has
69231
+ * settled without deciding the result.
69232
+ *
69233
+ * @example
69234
+ * await evaluateAsync('$statusCode == 200', {
69235
+ * resolve: async (expression, ast) => (expression === '$statusCode' ? 200 : undefined),
69236
+ * }); // => true
69237
+ */
69238
+ const evaluateAsync = async (condition, {
69239
+ resolve
69240
+ } = {}) => {
69241
+ const tree = prepare(condition, resolve, 'evaluateAsync');
69242
+ return toBoolean(await evaluateNodeAsync(tree, resolve));
69243
+ };
69244
+
69245
+ // util.promisify(evaluate) returns evaluateAsync; Symbol.for keeps this free of node:util.
69246
+ evaluate[Symbol.for('nodejs.util.promisify.custom')] = evaluateAsync;
69247
+ const prepare = (condition, resolve, name) => {
68230
69248
  if (typeof condition !== 'string') {
68231
69249
  throw new TypeError('Criterion condition must be a string');
68232
69250
  }
68233
69251
  if (typeof resolve !== 'function') {
68234
- throw new TypeError('evaluate requires a "resolve" function in options');
69252
+ throw new TypeError(`${name} requires a "resolve" function in options`);
68235
69253
  }
68236
69254
  const {
68237
69255
  result,
@@ -68242,7 +69260,17 @@ const evaluate = (condition, {
68242
69260
  condition
68243
69261
  });
68244
69262
  }
68245
- return toBoolean(evaluateNode(tree, resolve));
69263
+ return tree;
69264
+ };
69265
+
69266
+ // a native Promise means an async resolver, whose Promise would otherwise be
69267
+ // compared as a plain object.
69268
+ const resolveValue = (resolve, expression, ast) => {
69269
+ const value = resolve(expression, ast);
69270
+ if (value instanceof Promise) {
69271
+ throw new TypeError('resolve returned a Promise; use evaluateAsync to await resolved values');
69272
+ }
69273
+ return value;
68246
69274
  };
68247
69275
  const evaluateNode = (node, resolve) => {
68248
69276
  switch (node.type) {
@@ -68251,13 +69279,13 @@ const evaluateNode = (node, resolve) => {
68251
69279
  case 'UnaryExpression':
68252
69280
  return !toBoolean(evaluateNode(node.argument, resolve));
68253
69281
  case 'BinaryExpression':
68254
- return evaluateComparison(node, resolve);
69282
+ return compare(node.operator, evaluateNode(node.left, resolve), evaluateNode(node.right, resolve));
68255
69283
  case 'Literal':
68256
69284
  return node.value;
68257
69285
  case 'RuntimeExpression':
68258
- return resolve(node.text, node.expression);
69286
+ return resolveValue(resolve, node.text, node.expression);
68259
69287
  case 'RuntimeExpressionNavigation':
68260
- return evaluateNavigation(node, resolve);
69288
+ return navigate(resolveValue(resolve, node.expression.text, node.expression.expression), node.navigation);
68261
69289
  default:
68262
69290
  throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown AST node type: ${node.type}`);
68263
69291
  }
@@ -68269,18 +69297,47 @@ const evaluateLogical = (node, resolve) => {
68269
69297
  // '||'
68270
69298
  return toBoolean(evaluateNode(node.left, resolve)) || toBoolean(evaluateNode(node.right, resolve));
68271
69299
  };
68272
- const evaluateNavigation = (node, resolve) => {
68273
- let value = resolve(node.expression.text, node.expression.expression);
68274
- for (const step of node.navigation) {
69300
+
69301
+ // the async counterpart of evaluateNode: same cases, each operand awaited in turn
69302
+ const evaluateNodeAsync = async (node, resolve) => {
69303
+ switch (node.type) {
69304
+ case 'LogicalExpression':
69305
+ return evaluateLogicalAsync(node, resolve);
69306
+ case 'UnaryExpression':
69307
+ return !toBoolean(await evaluateNodeAsync(node.argument, resolve));
69308
+ case 'BinaryExpression':
69309
+ {
69310
+ const left = await evaluateNodeAsync(node.left, resolve);
69311
+ return compare(node.operator, left, await evaluateNodeAsync(node.right, resolve));
69312
+ }
69313
+ case 'Literal':
69314
+ return node.value;
69315
+ case 'RuntimeExpression':
69316
+ return resolve(node.text, node.expression);
69317
+ case 'RuntimeExpressionNavigation':
69318
+ return navigate(await resolve(node.expression.text, node.expression.expression), node.navigation);
69319
+ default:
69320
+ throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown AST node type: ${node.type}`);
69321
+ }
69322
+ };
69323
+ const evaluateLogicalAsync = async (node, resolve) => {
69324
+ const left = toBoolean(await evaluateNodeAsync(node.left, resolve));
69325
+ // the right operand is evaluated only when the left one does not decide the result
69326
+ if (node.operator === '&&' ? !left : left) return left;
69327
+ return toBoolean(await evaluateNodeAsync(node.right, resolve));
69328
+ };
69329
+ const navigate = (resolved, navigation) => {
69330
+ let value = resolved;
69331
+ for (const step of navigation) {
68275
69332
  if (value == null) return undefined;
68276
- value = step.type === 'MemberAccess' ? value[step.name] : value[step.value];
69333
+ const key = step.type === 'MemberAccess' ? step.name : step.value;
69334
+ // only the value's own members: `.constructor` or `.toString` must not reach the prototype
69335
+ value = Object.prototype.hasOwnProperty.call(value, key) ? value[key] : undefined;
68277
69336
  }
68278
69337
  return value;
68279
69338
  };
68280
- const evaluateComparison = (node, resolve) => {
68281
- const left = evaluateNode(node.left, resolve);
68282
- const right = evaluateNode(node.right, resolve);
68283
- switch (node.operator) {
69339
+ const compare = (operator, left, right) => {
69340
+ switch (operator) {
68284
69341
  case '==':
68285
69342
  return looseEquals(left, right);
68286
69343
  case '!=':
@@ -68289,9 +69346,9 @@ const evaluateComparison = (node, resolve) => {
68289
69346
  case '<=':
68290
69347
  case '>':
68291
69348
  case '>=':
68292
- return relational(node.operator, left, right);
69349
+ return relational(operator, left, right);
68293
69350
  default:
68294
- throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown comparison operator: ${node.operator}`);
69351
+ throw new _errors_ArazzoCriterionEvaluateError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](`Unknown comparison operator: ${operator}`);
68295
69352
  }
68296
69353
  };
68297
69354
 
@@ -68301,6 +69358,10 @@ const looseEquals = (a, b) => {
68301
69358
  const bNull = b === null || b === undefined;
68302
69359
  if (aNull || bNull) return aNull && bNull;
68303
69360
 
69361
+ // only JSON scalars are compared: arrays, objects and non-JSON values are never equal,
69362
+ // whatever their identity (compare structured values with a jsonpath criterion)
69363
+ if (!isJSONScalar(a) || !isJSONScalar(b)) return false;
69364
+
68304
69365
  // string comparisons MUST be case insensitive
68305
69366
  if (typeof a === 'string' && typeof b === 'string') {
68306
69367
  return a.toLowerCase() === b.toLowerCase();
@@ -68323,6 +69384,14 @@ const relational = (operator, a, b) => {
68323
69384
  left = left.toLowerCase();
68324
69385
  right = right.toLowerCase();
68325
69386
  }
69387
+
69388
+ // only two numbers or two strings are ordered; any other pair is unordered rather than
69389
+ // left to host-language coercion, and, as in RFC 9535, `<=` / `>=` hold if it is equal
69390
+ const bothNumbers = typeof left === 'number' && typeof right === 'number';
69391
+ const bothStrings = typeof left === 'string' && typeof right === 'string';
69392
+ if (!bothNumbers && !bothStrings) {
69393
+ return (operator === '<=' || operator === '>=') && looseEquals(a, b);
69394
+ }
68326
69395
  switch (operator) {
68327
69396
  case '<':
68328
69397
  return left < right;
@@ -68336,14 +69405,23 @@ const relational = (operator, a, b) => {
68336
69405
  return false;
68337
69406
  }
68338
69407
  };
68339
- const isNumeric = str => str.trim() !== '' && Number.isFinite(Number(str));
69408
+
69409
+ // evaluation is defined on the JSON value model, independent of the host language
69410
+ // (null is handled separately; BigInt, Date, Map, functions, ... are not JSON values)
69411
+ const isJSONScalar = value => typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean';
69412
+
69413
+ // a numeric string is one matching the grammar's own `number` rule (the JSON number
69414
+ // format): no hex/binary/octal prefixes, leading zeros, '+' sign or surrounding whitespace
69415
+ const NUMERIC = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
69416
+ const isNumeric = str => NUMERIC.test(str) && Number.isFinite(Number(str));
68340
69417
 
68341
69418
  // A condition passes (truthy) when it evaluates to a truthy value; it fails (falsy)
68342
69419
  // on false, null, or a missing (undefined) value.
68343
69420
  const toBoolean = value => Boolean(value);
68344
69421
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (evaluate);
68345
69422
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
68346
- /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
69423
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
69424
+ /* harmony export */ "evaluateAsync", 0, /* binding */ evaluateAsync
68347
69425
  /* harmony export */ ]);
68348
69426
 
68349
69427
 
@@ -69480,6 +70558,7 @@ __webpack_require__.r(__webpack_exports__);
69480
70558
  /* harmony export */ Trace: () => (/* reexport safe */ _parse_trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]),
69481
70559
  /* harmony export */ XMLTranslator: () => (/* reexport safe */ _parse_translators_XMLTranslator_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]),
69482
70560
  /* harmony export */ evaluate: () => (/* reexport safe */ _evaluate_index_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]),
70561
+ /* harmony export */ evaluateAsync: () => (/* reexport safe */ _evaluate_index_mjs__WEBPACK_IMPORTED_MODULE_3__.evaluateAsync),
69483
70562
  /* harmony export */ parse: () => (/* reexport safe */ _parse_index_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]),
69484
70563
  /* harmony export */ test: () => (/* reexport safe */ _test_index_mjs__WEBPACK_IMPORTED_MODULE_2__["default"])
69485
70564
  /* harmony export */ });
@@ -69543,6 +70622,36 @@ const cst = nodeType => {
69543
70622
  /* harmony export */ ]);
69544
70623
 
69545
70624
 
70625
+ /***/ },
70626
+
70627
+ /***/ 94771
70628
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
70629
+
70630
+ "use strict";
70631
+ __webpack_require__.r(__webpack_exports__);
70632
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
70633
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
70634
+ /* harmony export */ });
70635
+ /* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
70636
+ /* harmony import */ var _translators_ASTTranslator_transformers_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56286);
70637
+
70638
+
70639
+ /**
70640
+ * Parser rule callback for `runtime-expression-operand`.
70641
+ *
70642
+ * The grammar matches an operand as one bounded token ("$" 1*operand-char); whether the token is
70643
+ * a runtime expression with valid criterion accessors is decided here, during parsing, so that an
70644
+ * invalid operand fails the parse like any other syntax error, whatever the translator.
70645
+ */
70646
+ const operand = (sys, chars, phraseIndex) => {
70647
+ if (sys.state !== apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH) return;
70648
+ if (!(0,_translators_ASTTranslator_transformers_mjs__WEBPACK_IMPORTED_MODULE_1__.isValidOperand)(apg_lite__WEBPACK_IMPORTED_MODULE_0__.utilities.charsToString(chars, phraseIndex, sys.phraseLength))) {
70649
+ sys.state = apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOMATCH;
70650
+ sys.phraseLength = 0;
70651
+ }
70652
+ };
70653
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (operand);
70654
+
69546
70655
  /***/ },
69547
70656
 
69548
70657
  /***/ 23937
@@ -69556,8 +70665,10 @@ __webpack_require__.r(__webpack_exports__);
69556
70665
  /* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
69557
70666
  /* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38550);
69558
70667
  /* harmony import */ var _translators_ASTTranslator_index_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4586);
69559
- /* harmony import */ var _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9080);
69560
- /* harmony import */ var _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17624);
70668
+ /* harmony import */ var _callbacks_operand_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(94771);
70669
+ /* harmony import */ var _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9080);
70670
+ /* harmony import */ var _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(17624);
70671
+
69561
70672
 
69562
70673
 
69563
70674
 
@@ -69576,8 +70687,9 @@ const parse = (condition, {
69576
70687
  try {
69577
70688
  const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
69578
70689
  if (translator) parser.ast = translator;
70690
+ parser.callbacks['runtime-expression-operand'] = _callbacks_operand_mjs__WEBPACK_IMPORTED_MODULE_3__["default"];
69579
70691
  if (stats) parser.stats = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Stats();
69580
- if (trace) parser.trace = new _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]();
70692
+ if (trace) parser.trace = new _trace_Trace_mjs__WEBPACK_IMPORTED_MODULE_4__["default"]();
69581
70693
  const result = parser.parse(grammar, startRule, condition);
69582
70694
  return {
69583
70695
  result,
@@ -69586,7 +70698,7 @@ const parse = (condition, {
69586
70698
  trace: parser.trace
69587
70699
  };
69588
70700
  } catch (error) {
69589
- throw new _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_4__["default"]('Unexpected error during Arazzo Criterion parsing', {
70701
+ throw new _errors_ArazzoCriterionParseError_mjs__WEBPACK_IMPORTED_MODULE_5__["default"]('Unexpected error during Arazzo Criterion parsing', {
69590
70702
  cause: error,
69591
70703
  condition
69592
70704
  });
@@ -69687,6 +70799,8 @@ class ASTTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
69687
70799
  __webpack_require__.r(__webpack_exports__);
69688
70800
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
69689
70801
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
70802
+ /* harmony export */ isValidOperand: () => (/* binding */ isValidOperand),
70803
+ /* harmony export */ parseOperand: () => (/* binding */ parseOperand),
69690
70804
  /* harmony export */ transformCSTtoAST: () => (/* binding */ transformCSTtoAST)
69691
70805
  /* harmony export */ });
69692
70806
  /* harmony import */ var _swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26847);
@@ -69716,8 +70830,12 @@ const OPERAND_TYPES = new Set(['paren-expr', 'comparison-expr', 'test-expr', 'ru
69716
70830
  * @swaggerexpert/arazzo-runtime-expression.
69717
70831
  */
69718
70832
  const splitAtRuntimeExpression = operand => {
69719
- const full = (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__.parse)(operand);
69720
- if (full.result.success) {
70833
+ // only validity is needed here, so the runtime expression parses build no tree
70834
+ const isRuntimeExpression = text => (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__.parse)(text, {
70835
+ translator: null
70836
+ }).result;
70837
+ const full = isRuntimeExpression(operand);
70838
+ if (full.success) {
69721
70839
  return {
69722
70840
  expressionText: operand,
69723
70841
  navigationText: ''
@@ -69726,15 +70844,29 @@ const splitAtRuntimeExpression = operand => {
69726
70844
 
69727
70845
  // A failing parse reports how far it matched; walk down from there to the
69728
70846
  // longest prefix that parses cleanly (robust against stopping mid-rule).
69729
- for (let n = full.result.maxMatched; n > 0; n -= 1) {
69730
- if ((0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_0__.parse)(operand.slice(0, n)).result.success) {
70847
+ for (let n = full.maxMatched; n > 0; n -= 1) {
70848
+ if (isRuntimeExpression(operand.slice(0, n)).success) {
69731
70849
  return {
69732
70850
  expressionText: operand.slice(0, n),
69733
70851
  navigationText: operand.slice(n)
69734
70852
  };
69735
70853
  }
69736
70854
  }
69737
- throw new Error(`Operand is not a valid runtime expression: "${operand}"`);
70855
+ return undefined;
70856
+ };
70857
+
70858
+ /**
70859
+ * Whether an operand token is a runtime expression followed by valid criterion accessors.
70860
+ * Builds no trees; used by the parser to reject an invalid operand while parsing.
70861
+ */
70862
+ const isValidOperand = operand => {
70863
+ const split = splitAtRuntimeExpression(operand);
70864
+ if (!split) return false;
70865
+ if (split.navigationText === '') return true;
70866
+ return (0,_index_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(split.navigationText, {
70867
+ startRule: 'runtime-expression-navigation',
70868
+ translator: null
70869
+ }).result.success;
69738
70870
  };
69739
70871
 
69740
70872
  /**
@@ -69761,10 +70893,12 @@ const parseNavigation = navigationText => {
69761
70893
  * both already parsed. `navigation` is an empty array when there are no accessors.
69762
70894
  */
69763
70895
  const parseOperand = operand => {
70896
+ const split = splitAtRuntimeExpression(operand);
70897
+ if (!split) throw new Error(`Operand is not a valid runtime expression: "${operand}"`);
69764
70898
  const {
69765
70899
  expressionText,
69766
70900
  navigationText
69767
- } = splitAtRuntimeExpression(operand);
70901
+ } = split;
69768
70902
  const runtimeExpression = {
69769
70903
  type: 'RuntimeExpression',
69770
70904
  text: expressionText,
@@ -70080,22 +71214,38 @@ const grammar = new _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]();
70080
71214
  * In strict mode (default) the whole string must parse as an expression-string,
70081
71215
  * otherwise an empty array is returned. With `strict: false`, any `{` not followed
70082
71216
  * by `$` is treated as literal text and every valid `{$...}` span is extracted;
70083
- * invalid expression attempts are skipped.
71217
+ * invalid expression attempts are skipped. Each of them is reported to `onError`,
71218
+ * when given, with the same information `interpolate` passes to its `onError`;
71219
+ * its return value is ignored, as there is nothing to replace. `onError` is
71220
+ * ignored in strict mode.
70084
71221
  *
70085
71222
  * @example
70086
71223
  *
70087
71224
  * extract('{$url}'); // => ['$url']
70088
71225
  * extract('id={$inputs.id}&name={$inputs.name}'); // => ['$inputs.id', '$inputs.name']
70089
71226
  * extract('{"id": "{$inputs.id}"}', { strict: false }); // => ['$inputs.id']
71227
+ *
71228
+ * const errors = [];
71229
+ * extract('x={$inputs.}&y={$inputs.ok}', { strict: false, onError: (info) => errors.push(info) });
71230
+ * // => ['$inputs.ok'], errors[0].text === '{$inputs.}'
70090
71231
  */
70091
71232
  const extract = (str, {
70092
- strict = true
71233
+ strict = true,
71234
+ onError
70093
71235
  } = {}) => {
70094
71236
  if (typeof str !== 'string') {
70095
71237
  return [];
70096
71238
  }
70097
71239
  if (strict === false) {
70098
- return (0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(str).filter(token => token.type === 'expression').map(token => token.expression);
71240
+ const expressions = [];
71241
+ for (const token of (0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__["default"])(str)) {
71242
+ if (token.type === 'expression') {
71243
+ expressions.push(token.expression);
71244
+ } else if (token.type === 'invalid' && typeof onError === 'function') {
71245
+ onError((0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__.invalidAttemptInfo)(token));
71246
+ }
71247
+ }
71248
+ return expressions;
70099
71249
  }
70100
71250
  const parser = new apg_lite__WEBPACK_IMPORTED_MODULE_0__.Parser();
70101
71251
  parser.ast = new _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]();
@@ -71641,8 +72791,6 @@ __webpack_require__.r(__webpack_exports__);
71641
72791
  /* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71652);
71642
72792
  /* harmony import */ var _parse_translators_CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35963);
71643
72793
  /* 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
72794
 
71647
72795
 
71648
72796
 
@@ -71719,31 +72867,7 @@ const interpolate = (template, resolver, {
71719
72867
  if (token.type === 'expression') {
71720
72868
  output += stringify(resolver(token.expression));
71721
72869
  } 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
- });
72870
+ const replacement = onError((0,_scanner_mjs__WEBPACK_IMPORTED_MODULE_3__.invalidAttemptInfo)(token));
71747
72871
  if (typeof replacement !== 'string') {
71748
72872
  throw new TypeError('onError must return a string');
71749
72873
  }
@@ -71880,7 +73004,8 @@ const parse = (runtimeExpression, {
71880
73004
  __webpack_require__.r(__webpack_exports__);
71881
73005
  class Expectations extends Array {
71882
73006
  toString() {
71883
- return this.map(c => `"${String(c)}"`).join(', ');
73007
+ // JSON string syntax, so that entries such as '"' and '\\' stay unambiguous
73008
+ return this.map(c => JSON.stringify(String(c))).join(', ');
71884
73009
  }
71885
73010
  }
71886
73011
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Expectations);
@@ -71897,34 +73022,226 @@ class Expectations extends Array {
71897
73022
  "use strict";
71898
73023
  __webpack_require__.r(__webpack_exports__);
71899
73024
  /* harmony import */ var apg_lite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51751);
71900
- /* harmony import */ var _Expectations_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3770);
73025
+ /* harmony import */ var _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71652);
73026
+ /* harmony import */ var _Expectations_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3770);
71901
73027
 
71902
73028
 
71903
- class Trace extends apg_lite__WEBPACK_IMPORTED_MODULE_0__.Trace {
71904
- inferExpectations() {
71905
- const lines = this.displayTrace().split('\n');
71906
- const expectations = new Set();
71907
- let lastMatchedIndex = -1;
71908
- for (let i = 0; i < lines.length; i++) {
71909
- const line = lines[i];
73029
+ // TLS (case-insensitive literal) opcodes store the string lowercased; the grammar source
73030
+ // keeps the spelling it is written with (e.g. "$statusCode"), so expectations use that.
73031
+ const literalSpellings = new Map();
73032
+ for (const [, literal] of String(new _grammar_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]()).matchAll(/"([^"\n]*)"/g)) {
73033
+ const key = literal.toLowerCase();
73034
+ if (!literalSpellings.has(key)) literalSpellings.set(key, literal);
73035
+ }
73036
+ const hex = code => code.toString(16).toUpperCase().padStart(2, '0');
73037
+ const describeTerminal = op => {
73038
+ switch (op.type) {
73039
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TLS:
73040
+ {
73041
+ const literal = String.fromCodePoint(...op.string);
73042
+ return literalSpellings.get(literal) ?? literal;
73043
+ }
73044
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TBS:
73045
+ return String.fromCodePoint(...op.string);
73046
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TRG:
73047
+ return op.min === op.max ? `%x${hex(op.min)}` : `%x${hex(op.min)}-${hex(op.max)}`;
73048
+ default:
73049
+ return undefined;
73050
+ }
73051
+ };
71910
73052
 
71911
- // capture the max match line (first one that ends in a single character match)
71912
- if (line.includes('M|')) {
71913
- const textMatch = line.match(/]'(.*)'$/);
71914
- if (textMatch && textMatch[1]) {
71915
- lastMatchedIndex = i;
73053
+ // FIRST set of an opcode: the terminals a match of it can start with, and whether it can
73054
+ // match the empty phrase (in which case what follows it can start the match as well)
73055
+ const first = (rules, opcodes, index, visiting = new Set()) => {
73056
+ const op = opcodes[index];
73057
+ switch (op.type) {
73058
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.ALT:
73059
+ {
73060
+ const terminals = [];
73061
+ let nullable = false;
73062
+ for (const child of op.children) {
73063
+ const result = first(rules, opcodes, child, visiting);
73064
+ terminals.push(...result.terminals);
73065
+ nullable = nullable || result.nullable;
71916
73066
  }
73067
+ return {
73068
+ terminals,
73069
+ nullable
73070
+ };
73071
+ }
73072
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.CAT:
73073
+ {
73074
+ const terminals = [];
73075
+ for (const child of op.children) {
73076
+ const result = first(rules, opcodes, child, visiting);
73077
+ terminals.push(...result.terminals);
73078
+ if (!result.nullable) return {
73079
+ terminals,
73080
+ nullable: false
73081
+ };
73082
+ }
73083
+ return {
73084
+ terminals,
73085
+ nullable: true
73086
+ };
71917
73087
  }
73088
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP:
73089
+ {
73090
+ const result = first(rules, opcodes, index + 1, visiting);
73091
+ return {
73092
+ terminals: result.terminals,
73093
+ nullable: op.min === 0 || result.nullable
73094
+ };
73095
+ }
73096
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.RNM:
73097
+ {
73098
+ // a left-recursive reference adds nothing the outer visit does not already add
73099
+ if (visiting.has(op.index)) return {
73100
+ terminals: [],
73101
+ nullable: false
73102
+ };
73103
+ visiting.add(op.index);
73104
+ const result = first(rules, rules[op.index].opcodes, 0, visiting);
73105
+ visiting.delete(op.index);
73106
+ return result;
73107
+ }
73108
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TLS:
73109
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TBS:
73110
+ return {
73111
+ terminals: op.string.length > 0 ? [op] : [],
73112
+ nullable: op.string.length === 0
73113
+ };
73114
+ case apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.TRG:
73115
+ return {
73116
+ terminals: [op],
73117
+ nullable: false
73118
+ };
73119
+ default:
73120
+ // AND, NOT (look-ahead) and UDT do not consume input that can be described as a terminal
73121
+ return {
73122
+ terminals: [],
73123
+ nullable: true
73124
+ };
73125
+ }
73126
+ };
73127
+ const stateSymbol = Symbol('trace state');
73128
+ class Trace extends apg_lite__WEBPACK_IMPORTED_MODULE_0__.Trace {
73129
+ constructor() {
73130
+ super();
73131
+ const baseInit = this.init;
73132
+ const baseDown = this.down;
73133
+ const baseUp = this.up;
73134
+ let rules = [];
73135
+ let inputLength = 0;
73136
+ let repetitions = new Map();
73137
+ let lookAhead = 0;
73138
+ // repetitions in progress: where each one has got to and how many times its child matched
73139
+ let progress = [];
73140
+ const state = {
73141
+ maxMatched: 0,
73142
+ failures: []
73143
+ };
73144
+ this[stateSymbol] = state;
71918
73145
 
71919
- // collect terminal failures after the deepest successful match
71920
- if (i > lastMatchedIndex) {
71921
- const terminalFailMatch = line.match(/N\|\[TLS\(([^)]+)\)]/);
71922
- if (terminalFailMatch) {
71923
- expectations.add(terminalFailMatch[1]);
73146
+ // only failures at the furthest offset are ever reported, so only those are kept
73147
+ const recordFailure = (op, offset) => {
73148
+ if (offset === state.maxMatched) state.failures.push({
73149
+ op,
73150
+ offset
73151
+ });
73152
+ };
73153
+ this.init = (r, u, c) => {
73154
+ rules = r;
73155
+ inputLength = c.length;
73156
+ // the opcodes of a repetition's rule, and its position there, to find its child
73157
+ repetitions = new Map();
73158
+ for (const rule of r) {
73159
+ rule.opcodes.forEach((op, index) => {
73160
+ if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) repetitions.set(op, {
73161
+ opcodes: rule.opcodes,
73162
+ index
73163
+ });
73164
+ });
73165
+ }
73166
+ // a Trace instance may be reused for another parse
73167
+ lookAhead = 0;
73168
+ progress = [];
73169
+ state.maxMatched = 0;
73170
+ state.failures = [];
73171
+ baseInit(r, u, c);
73172
+ };
73173
+ this.down = (op, offset) => {
73174
+ if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.AND || op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOT) lookAhead += 1;
73175
+ if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) {
73176
+ const {
73177
+ opcodes,
73178
+ index
73179
+ } = repetitions.get(op);
73180
+ progress.push({
73181
+ child: opcodes[index + 1],
73182
+ opcodes,
73183
+ index,
73184
+ position: offset,
73185
+ count: 0
73186
+ });
73187
+ }
73188
+ baseDown(op, offset);
73189
+ };
73190
+ this.up = (op, opState, offset, phraseLength) => {
73191
+ if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.AND || op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOT) lookAhead -= 1;
73192
+
73193
+ // look-ahead operators test the input without consuming it, so neither their
73194
+ // matches nor their failures say anything about what the input should contain
73195
+ if (lookAhead === 0) {
73196
+ if (opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH && offset + phraseLength > state.maxMatched) {
73197
+ state.maxMatched = offset + phraseLength;
73198
+ state.failures = [];
73199
+ }
73200
+ if (opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.NOMATCH && describeTerminal(op) !== undefined) {
73201
+ recordFailure(op, offset);
73202
+ }
73203
+ }
73204
+ const repetition = progress[progress.length - 1];
73205
+ if (repetition && op === repetition.child && opState === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.MATCH) {
73206
+ repetition.position = offset + phraseLength;
73207
+ repetition.count += 1;
73208
+ }
73209
+ if (op.type === apg_lite__WEBPACK_IMPORTED_MODULE_0__.identifiers.REP) {
73210
+ progress.pop();
73211
+ // at the end of the input a repetition stops without trying its child again, so the
73212
+ // terminals that could have continued it are never tried; add them from its FIRST set
73213
+ if (lookAhead === 0 && repetition.position === inputLength && repetition.count < op.max) {
73214
+ const {
73215
+ opcodes,
73216
+ index
73217
+ } = repetition;
73218
+ for (const terminal of first(rules, opcodes, index + 1).terminals) {
73219
+ recordFailure(terminal, inputLength);
73220
+ }
71924
73221
  }
71925
73222
  }
73223
+ baseUp(op, opState, offset, phraseLength);
73224
+ };
73225
+ }
73226
+
73227
+ /**
73228
+ * Terminals the grammar could have accepted at the offset where parsing stopped
73229
+ * (`result.maxMatched`), in the order the parser tried them, unabbreviated.
73230
+ * Character ranges are given in ABNF notation (e.g. `%x30-39`).
73231
+ */
73232
+ inferExpectations() {
73233
+ const {
73234
+ maxMatched,
73235
+ failures
73236
+ } = this[stateSymbol];
73237
+ const expectations = new Set();
73238
+ for (const {
73239
+ op,
73240
+ offset
73241
+ } of failures) {
73242
+ if (offset === maxMatched) expectations.add(describeTerminal(op));
71926
73243
  }
71927
- return new _Expectations_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](...expectations);
73244
+ return new _Expectations_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](...expectations);
71928
73245
  }
71929
73246
  }
71930
73247
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Trace);
@@ -72328,6 +73645,8 @@ class XMLTranslator extends _CSTTranslator_mjs__WEBPACK_IMPORTED_MODULE_0__["def
72328
73645
  "use strict";
72329
73646
  __webpack_require__.r(__webpack_exports__);
72330
73647
  /* harmony import */ var _test_index_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34976);
73648
+ /* harmony import */ var _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4089);
73649
+
72331
73650
 
72332
73651
  /**
72333
73652
  * Tolerantly scan a string containing embedded {expression} patterns.
@@ -72410,9 +73729,43 @@ const scan = str => {
72410
73729
  }
72411
73730
  return tokens;
72412
73731
  };
73732
+
73733
+ /**
73734
+ * Information about an invalid expression attempt, as passed to `onError`
73735
+ * of `interpolate` and `extract`: { text, start, length, error }.
73736
+ *
73737
+ * @private
73738
+ */
73739
+ const invalidAttemptInfo = ({
73740
+ text,
73741
+ expression,
73742
+ start,
73743
+ length,
73744
+ terminated
73745
+ }) => {
73746
+ let error;
73747
+ return {
73748
+ text,
73749
+ start,
73750
+ length,
73751
+ // created lazily - capturing a stack trace for every invalid attempt is costly
73752
+ get error() {
73753
+ if (error === undefined) {
73754
+ const message = terminated ? `Invalid runtime expression "${text}" at position ${start}` : `Unterminated runtime expression "${text}" at position ${start}`;
73755
+ error = new _errors_ArazzoRuntimeExpressionParseError_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](message, {
73756
+ runtimeExpression: expression,
73757
+ start,
73758
+ length
73759
+ });
73760
+ }
73761
+ return error;
73762
+ }
73763
+ };
73764
+ };
72413
73765
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (scan);
72414
73766
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
72415
- /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
73767
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
73768
+ /* harmony export */ "invalidAttemptInfo", 0, /* binding */ invalidAttemptInfo
72416
73769
  /* harmony export */ ]);
72417
73770
 
72418
73771
 
@@ -91111,18 +92464,34 @@ function throwIfCancellationRequested(config) {
91111
92464
  }
91112
92465
 
91113
92466
  /**
91114
- * Milliseconds elapsed since `start`, floored at zero.
92467
+ * Resolve the clock used to time adapter execution.
92468
+ *
92469
+ * Prefers the monotonic `performance.now()` so wall-clock adjustments do not
92470
+ * skew the measurement, and so frameworks that forbid reading the current
92471
+ * time during prerendering (e.g. Next.js Cache Components) accept it. Falls
92472
+ * back to `Date.now()` in runtimes without the High Resolution Time API.
92473
+ *
92474
+ * @returns {() => number} Millisecond clock
92475
+ */
92476
+ function resolveClock() {
92477
+ return typeof performance !== 'undefined' && _utils_js__WEBPACK_IMPORTED_MODULE_6__["default"].isFunction(performance.now)
92478
+ ? () => performance.now()
92479
+ : Date.now;
92480
+ }
92481
+
92482
+ /**
92483
+ * Whole milliseconds elapsed since `start`, floored at zero.
91115
92484
  *
91116
- * Wall-clock, to match the rest of the codebase (speedometer, throttle,
91117
- * AxiosTransformStream). A backwards clock adjustment mid-request would
91118
- * otherwise produce a negative duration, so the result is clamped.
92485
+ * Rounded so the value stays an integer as with `Date.now()`. The fallback
92486
+ * wall clock can move backwards mid-request, so the result is clamped.
91119
92487
  *
91120
- * @param {number} start Timestamp from `Date.now()`
92488
+ * @param {() => number} now Clock returned by `resolveClock()`
92489
+ * @param {number} start Timestamp read from `now`
91121
92490
  *
91122
92491
  * @returns {number} Non-negative elapsed milliseconds
91123
92492
  */
91124
- function elapsedSince(start) {
91125
- return Math.max(0, Date.now() - start);
92493
+ function elapsedSince(now, start) {
92494
+ return Math.max(0, Math.round(now() - start));
91126
92495
  }
91127
92496
 
91128
92497
  /**
@@ -91151,13 +92520,14 @@ function dispatchRequest(_config) {
91151
92520
 
91152
92521
  const adapter = _adapters_adapters_js__WEBPACK_IMPORTED_MODULE_5__["default"].getAdapter(config.adapter || _defaults_index_js__WEBPACK_IMPORTED_MODULE_2__["default"].adapter, config);
91153
92522
 
91154
- const start = Date.now();
92523
+ const now = resolveClock();
92524
+ const start = now();
91155
92525
 
91156
92526
  return adapter(config).then(
91157
92527
  function onAdapterResolution(response) {
91158
92528
  throwIfCancellationRequested(config);
91159
92529
 
91160
- response.duration = elapsedSince(start);
92530
+ response.duration = elapsedSince(now, start);
91161
92531
 
91162
92532
  // Expose the current response on config so that transformResponse can
91163
92533
  // attach it to any AxiosError it throws (e.g. on JSON parse failure).
@@ -91179,7 +92549,7 @@ function dispatchRequest(_config) {
91179
92549
 
91180
92550
  // Transform response data
91181
92551
  if (reason && reason.response) {
91182
- reason.response.duration = elapsedSince(start);
92552
+ reason.response.duration = elapsedSince(now, start);
91183
92553
  config.response = reason.response;
91184
92554
  try {
91185
92555
  reason.response.data = _transformData_js__WEBPACK_IMPORTED_MODULE_0__["default"].call(
@@ -91834,7 +93204,7 @@ __webpack_require__.r(__webpack_exports__);
91834
93204
 
91835
93205
  "use strict";
91836
93206
  __webpack_require__.r(__webpack_exports__);
91837
- const VERSION = "1.21.0";
93207
+ const VERSION = "1.21.1";
91838
93208
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
91839
93209
  /* harmony export */ "VERSION", 0, /* binding */ VERSION
91840
93210
  /* harmony export */ ]);
@@ -118467,6 +119837,16 @@ var r={8341(e,t,n){n(7603);var r=n(2856);e.exports=r("Array","includes")},5161(e
118467
119837
  /******/ }
118468
119838
  /******/
118469
119839
  /************************************************************************/
119840
+ /******/ /* webpack/runtime/compat get default export */
119841
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
119842
+ /******/ __webpack_require__.n = (module) => {
119843
+ /******/ const getter = module && module.__esModule ?
119844
+ /******/ () => (module['default']) :
119845
+ /******/ () => (module);
119846
+ /******/ __webpack_require__.d(getter, { a: getter });
119847
+ /******/ return getter;
119848
+ /******/ };
119849
+ /******/
118470
119850
  /******/ /* webpack/runtime/create fake namespace object */
118471
119851
  /******/ (() => {
118472
119852
  /******/ const getProto = Object.getPrototypeOf;
@@ -118570,7 +119950,7 @@ __webpack_require__.r(__webpack_exports__);
118570
119950
  /* harmony export */ ArazzoDocument: () => (/* reexport safe */ _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_6__["default"]),
118571
119951
  /* harmony export */ ArazzoDocumentRegistryProvider: () => (/* reexport safe */ _registry_providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]),
118572
119952
  /* harmony export */ ArazzoRunner: () => (/* reexport safe */ _ArazzoRunner_ts__WEBPACK_IMPORTED_MODULE_0__["default"]),
118573
- /* harmony export */ ArazzoRunnerError: () => (/* reexport safe */ _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_48__["default"]),
119953
+ /* harmony export */ ArazzoRunnerError: () => (/* reexport safe */ _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_49__["default"]),
118574
119954
  /* harmony export */ ArazzoSourceDescriptionIndex: () => (/* reexport safe */ _document_ArazzoSourceDescriptionIndex_ts__WEBPACK_IMPORTED_MODULE_10__["default"]),
118575
119955
  /* harmony export */ ArazzoStepExtractor: () => (/* reexport safe */ _extractor_ArazzoStepExtractor_ts__WEBPACK_IMPORTED_MODULE_13__["default"]),
118576
119956
  /* harmony export */ ArazzoStepIndex: () => (/* reexport safe */ _document_ArazzoStepIndex_ts__WEBPACK_IMPORTED_MODULE_9__["default"]),
@@ -118580,19 +119960,19 @@ __webpack_require__.r(__webpack_exports__);
118580
119960
  /* harmony export */ ArazzoWorkflowIndex: () => (/* reexport safe */ _document_ArazzoWorkflowIndex_ts__WEBPACK_IMPORTED_MODULE_8__["default"]),
118581
119961
  /* harmony export */ ArazzoWorkflowLocatorNormalizer: () => (/* reexport safe */ _executor_ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_47__["default"]),
118582
119962
  /* harmony export */ ArazzoWorkflowNormalizer: () => (/* reexport safe */ _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_15__["default"]),
118583
- /* harmony export */ AssemblerError: () => (/* reexport safe */ _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_49__["default"]),
118584
- /* harmony export */ ClientError: () => (/* reexport safe */ _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_50__["default"]),
118585
- /* harmony export */ CriterionError: () => (/* reexport safe */ _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_57__["default"]),
118586
- /* harmony export */ CriterionEvaluationError: () => (/* reexport safe */ _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_58__["default"]),
119963
+ /* harmony export */ AssemblerError: () => (/* reexport safe */ _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_50__["default"]),
119964
+ /* harmony export */ ClientError: () => (/* reexport safe */ _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_51__["default"]),
119965
+ /* harmony export */ CriterionError: () => (/* reexport safe */ _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_58__["default"]),
119966
+ /* harmony export */ CriterionEvaluationError: () => (/* reexport safe */ _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_59__["default"]),
118587
119967
  /* harmony export */ CriterionEvaluator: () => (/* reexport safe */ _criterion_CriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_29__["default"]),
118588
- /* harmony export */ DocumentLoadError: () => (/* reexport safe */ _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_55__["default"]),
119968
+ /* harmony export */ DocumentLoadError: () => (/* reexport safe */ _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_56__["default"]),
118589
119969
  /* harmony export */ DocumentRegistry: () => (/* reexport safe */ _registry_DocumentRegistry_ts__WEBPACK_IMPORTED_MODULE_1__["default"]),
118590
119970
  /* harmony export */ DocumentRegistryProvider: () => (/* reexport safe */ _registry_providers_DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"]),
118591
- /* harmony export */ ExecutionError: () => (/* reexport safe */ _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_60__["default"]),
118592
- /* harmony export */ ExtractionError: () => (/* reexport safe */ _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_52__["default"]),
118593
- /* harmony export */ InvalidEntryDocumentError: () => (/* reexport safe */ _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_53__["default"]),
119971
+ /* harmony export */ ExecutionError: () => (/* reexport safe */ _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_61__["default"]),
119972
+ /* harmony export */ ExtractionError: () => (/* reexport safe */ _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_53__["default"]),
119973
+ /* harmony export */ InvalidEntryDocumentError: () => (/* reexport safe */ _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_54__["default"]),
118594
119974
  /* harmony export */ JSONPathCriterionEvaluator: () => (/* reexport safe */ _criterion_JSONPathCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_32__["default"]),
118595
- /* harmony export */ NormalizationError: () => (/* reexport safe */ _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_51__["default"]),
119975
+ /* harmony export */ NormalizationError: () => (/* reexport safe */ _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_52__["default"]),
118596
119976
  /* harmony export */ OpenAPI2DocumentAssembler: () => (/* reexport safe */ _assembler_OpenAPI2DocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_22__["default"]),
118597
119977
  /* harmony export */ OpenAPI2OperationNormalizer: () => (/* reexport safe */ _normalizer_OpenAPI2OperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_18__["default"]),
118598
119978
  /* harmony export */ OpenAPI30DocumentAssembler: () => (/* reexport safe */ _assembler_OpenAPI30DocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_23__["default"]),
@@ -118611,16 +119991,17 @@ __webpack_require__.r(__webpack_exports__);
118611
119991
  /* harmony export */ OpenAPIOperationResponse: () => (/* reexport safe */ _client_OpenAPIOperationResponse_ts__WEBPACK_IMPORTED_MODULE_26__["default"]),
118612
119992
  /* harmony export */ OpenAPIOperationResponseNormalizer: () => (/* reexport safe */ _client_OpenAPIOperationResponseNormalizer_ts__WEBPACK_IMPORTED_MODULE_27__["default"]),
118613
119993
  /* harmony export */ OutputResolver: () => (/* reexport safe */ _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_39__["default"]),
119994
+ /* harmony export */ Redactor: () => (/* reexport safe */ _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_48__["default"]),
118614
119995
  /* harmony export */ RegexCriterionEvaluator: () => (/* reexport safe */ _criterion_RegexCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_31__["default"]),
118615
119996
  /* harmony export */ RequestBodyResolver: () => (/* reexport safe */ _resolver_RequestBodyResolver_ts__WEBPACK_IMPORTED_MODULE_40__["default"]),
118616
- /* harmony export */ ResolverError: () => (/* reexport safe */ _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_59__["default"]),
118617
- /* harmony export */ RuntimeExpressionError: () => (/* reexport safe */ _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_56__["default"]),
119997
+ /* harmony export */ ResolverError: () => (/* reexport safe */ _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_60__["default"]),
119998
+ /* harmony export */ RuntimeExpressionError: () => (/* reexport safe */ _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_57__["default"]),
118618
119999
  /* harmony export */ RuntimeExpressionEvaluator: () => (/* reexport safe */ _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_28__["default"]),
118619
120000
  /* harmony export */ SimpleCriterionEvaluator: () => (/* reexport safe */ _criterion_SimpleCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_30__["default"]),
118620
120001
  /* harmony export */ SourceDescriptionsLocatorNormalizer: () => (/* reexport safe */ _executor_SourceDescriptionsLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_45__["default"]),
118621
120002
  /* harmony export */ StepExecutor: () => (/* reexport safe */ _executor_StepExecutor_ts__WEBPACK_IMPORTED_MODULE_43__["default"]),
118622
120003
  /* harmony export */ StepParameterResolver: () => (/* reexport safe */ _resolver_StepParameterResolver_ts__WEBPACK_IMPORTED_MODULE_36__["default"]),
118623
- /* harmony export */ UnmatchedProviderError: () => (/* reexport safe */ _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_54__["default"]),
120004
+ /* harmony export */ UnmatchedProviderError: () => (/* reexport safe */ _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_55__["default"]),
118624
120005
  /* harmony export */ WorkflowExecutionState: () => (/* reexport safe */ _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_34__["default"]),
118625
120006
  /* harmony export */ WorkflowExecutor: () => (/* reexport safe */ _executor_WorkflowExecutor_ts__WEBPACK_IMPORTED_MODULE_42__["default"]),
118626
120007
  /* harmony export */ WorkflowParameterResolver: () => (/* reexport safe */ _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_38__["default"]),
@@ -118676,19 +120057,20 @@ __webpack_require__.r(__webpack_exports__);
118676
120057
  /* harmony import */ var _executor_SourceDescriptionsLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(83461);
118677
120058
  /* harmony import */ var _executor_OpenAPIOperationLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(7308);
118678
120059
  /* harmony import */ var _executor_ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(98885);
118679
- /* harmony import */ var _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(23949);
118680
- /* harmony import */ var _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(90706);
118681
- /* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(81763);
118682
- /* harmony import */ var _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(35523);
118683
- /* harmony import */ var _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(90713);
118684
- /* harmony import */ var _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(40198);
118685
- /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(46132);
118686
- /* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(24089);
118687
- /* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(48770);
118688
- /* harmony import */ var _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(41233);
118689
- /* harmony import */ var _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(71731);
118690
- /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(8696);
118691
- /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(17658);
120060
+ /* harmony import */ var _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(4050);
120061
+ /* harmony import */ var _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(23949);
120062
+ /* harmony import */ var _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(90706);
120063
+ /* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(81763);
120064
+ /* harmony import */ var _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(35523);
120065
+ /* harmony import */ var _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(90713);
120066
+ /* harmony import */ var _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(40198);
120067
+ /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(46132);
120068
+ /* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(24089);
120069
+ /* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(48770);
120070
+ /* harmony import */ var _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(41233);
120071
+ /* harmony import */ var _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(71731);
120072
+ /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(8696);
120073
+ /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(17658);
118692
120074
  /* Runner */
118693
120075
 
118694
120076
 
@@ -118760,6 +120142,10 @@ __webpack_require__.r(__webpack_exports__);
118760
120142
 
118761
120143
 
118762
120144
 
120145
+
120146
+ /* Observability */
120147
+
120148
+
118763
120149
  /* Errors */
118764
120150
 
118765
120151