@usearazzo/runner 1.0.1-alpha.21 → 1.0.1-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usearazzo/runner",
3
- "version": "1.0.1-alpha.21",
3
+ "version": "1.0.1-alpha.22",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -69,12 +69,12 @@
69
69
  "@speclynx/apidom-traverse": "^6.1.2",
70
70
  "@swaggerexpert/arazzo-criterion": "^1.0.1",
71
71
  "@swaggerexpert/arazzo-runtime-expression": "^3.3.0",
72
- "@swaggerexpert/cookie": "^2.0.2",
72
+ "@swaggerexpert/cookie": "^2.1.1",
73
73
  "@swaggerexpert/json-pointer": "^3.0.2",
74
74
  "@swaggerexpert/jsonpath": "^4.0.5",
75
75
  "@swaggerexpert/media-types": "^1.0.2",
76
- "@usearazzo/parser": "1.0.1-alpha.21",
77
- "@usearazzo/resolver": "1.0.1-alpha.21",
76
+ "@usearazzo/parser": "1.0.1-alpha.22",
77
+ "@usearazzo/resolver": "1.0.1-alpha.22",
78
78
  "@xmldom/xmldom": "^0.9.12",
79
79
  "fontoxpath": "^3.34.0",
80
80
  "ramda": "^0.32.0",
@@ -94,5 +94,5 @@
94
94
  "devDependencies": {
95
95
  "swagger-client": "^3.38.4"
96
96
  },
97
- "gitHead": "d342b02adbd11f5362aa4850b2417521e59448ce"
97
+ "gitHead": "e70dedbb2d249b9a6c16808048d9272609103f71"
98
98
  }
@@ -52,11 +52,12 @@ var _SourceDescriptionsLocatorNormalizer = _interopRequireDefault(require("./Sou
52
52
  * The `type` declared on a source description is not trusted (it may be
53
53
  * absent or wrong); a source is classified by what it actually parses to,
54
54
  * the same convention the OpenAPI operation locator follows. Source
55
- * documents are acquired from the registry on demand. Whether the resolved
56
- * document *defines* the workflow is deliberately left to the caller, which
57
- * owns the timing of that check (eager for a `dependsOn` list validated
58
- * before any prerequisite runs, lazy for a sub-workflow step resolved per
59
- * attempt).
55
+ * documents are acquired from the registry on demand. A reference to a
56
+ * workflow the resolved document does not define is rejected here, so every
57
+ * returned locator names an existing workflow; a caller controls when that
58
+ * check happens by when it normalizes (eagerly for a `dependsOn` list
59
+ * validated before any prerequisite runs, lazily for a sub-workflow step
60
+ * resolved on its first attempt).
60
61
  * @public
61
62
  */
62
63
  class ArazzoWorkflowLocatorNormalizer extends _SourceDescriptionsLocatorNormalizer.default {
@@ -64,10 +65,20 @@ class ArazzoWorkflowLocatorNormalizer extends _SourceDescriptionsLocatorNormaliz
64
65
  * Resolves a reference — a plain workflowId or a
65
66
  * `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
66
67
  * canonical locator: the Arazzo document that owns the target workflow,
67
- * and the bare id within it.
68
+ * and the bare id within it. Rejects a workflow that document does not
69
+ * define as `workflow-not-found`, attributed to the referencing context
70
+ * like every other error raised here.
68
71
  */
69
72
  async normalize(reference, document, context) {
70
- return this.#resolve(this.#parseReference(reference, context), document, context);
73
+ const locator = await this.#resolve(this.#parseReference(reference, context), document, context);
74
+ if (!locator.document.workflowIndex.has(locator.workflowId)) {
75
+ throw new _ExecutionError.default(`workflow reference "${reference}" in workflow "${context.workflowId}" names workflow "${locator.workflowId}", which the Arazzo document at "${locator.document.uri}" does not define`, {
76
+ workflowId: context.workflowId,
77
+ stepId: context.stepId,
78
+ reason: 'workflow-not-found'
79
+ });
80
+ }
81
+ return locator;
71
82
  }
72
83
 
73
84
  /**
@@ -42,11 +42,12 @@ import SourceDescriptionsLocatorNormalizer from "./SourceDescriptionsLocatorNorm
42
42
  * The `type` declared on a source description is not trusted (it may be
43
43
  * absent or wrong); a source is classified by what it actually parses to,
44
44
  * the same convention the OpenAPI operation locator follows. Source
45
- * documents are acquired from the registry on demand. Whether the resolved
46
- * document *defines* the workflow is deliberately left to the caller, which
47
- * owns the timing of that check (eager for a `dependsOn` list validated
48
- * before any prerequisite runs, lazy for a sub-workflow step resolved per
49
- * attempt).
45
+ * documents are acquired from the registry on demand. A reference to a
46
+ * workflow the resolved document does not define is rejected here, so every
47
+ * returned locator names an existing workflow; a caller controls when that
48
+ * check happens by when it normalizes (eagerly for a `dependsOn` list
49
+ * validated before any prerequisite runs, lazily for a sub-workflow step
50
+ * resolved on its first attempt).
50
51
  * @public
51
52
  */
52
53
  class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
@@ -54,10 +55,20 @@ class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalize
54
55
  * Resolves a reference — a plain workflowId or a
55
56
  * `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
56
57
  * canonical locator: the Arazzo document that owns the target workflow,
57
- * and the bare id within it.
58
+ * and the bare id within it. Rejects a workflow that document does not
59
+ * define as `workflow-not-found`, attributed to the referencing context
60
+ * like every other error raised here.
58
61
  */
59
62
  async normalize(reference, document, context) {
60
- return this.#resolve(this.#parseReference(reference, context), document, context);
63
+ const locator = await this.#resolve(this.#parseReference(reference, context), document, context);
64
+ if (!locator.document.workflowIndex.has(locator.workflowId)) {
65
+ throw new ExecutionError(`workflow reference "${reference}" in workflow "${context.workflowId}" names workflow "${locator.workflowId}", which the Arazzo document at "${locator.document.uri}" does not define`, {
66
+ workflowId: context.workflowId,
67
+ stepId: context.stepId,
68
+ reason: 'workflow-not-found'
69
+ });
70
+ }
71
+ return locator;
61
72
  }
62
73
 
63
74
  /**
@@ -55,6 +55,16 @@ const STEP_TARGET_FIELDS = exports.STEP_TARGET_FIELDS = ['operationId', 'operati
55
55
  * @public
56
56
  */
57
57
 
58
+ /**
59
+ * What one attempt at a step produced.
60
+ *
61
+ * Both kinds of step reduce to this — an operation step (whose richer
62
+ * {@link StepExecutionResult} satisfies this shape) and a sub-workflow step
63
+ * (synthesized from the sub-run's outcome) — so the retry loop drives them
64
+ * identically and knows nothing about either.
65
+ * @internal
66
+ */
67
+
58
68
  /**
59
69
  * Executes a single Arazzo step that invokes an OpenAPI operation.
60
70
  *
@@ -48,6 +48,16 @@ export const STEP_TARGET_FIELDS = ['operationId', 'operationPath', 'workflowId']
48
48
  * @public
49
49
  */
50
50
 
51
+ /**
52
+ * What one attempt at a step produced.
53
+ *
54
+ * Both kinds of step reduce to this — an operation step (whose richer
55
+ * {@link StepExecutionResult} satisfies this shape) and a sub-workflow step
56
+ * (synthesized from the sub-run's outcome) — so the retry loop drives them
57
+ * identically and knows nothing about either.
58
+ * @internal
59
+ */
60
+
51
61
  /**
52
62
  * Executes a single Arazzo step that invokes an OpenAPI operation.
53
63
  *
@@ -9,16 +9,6 @@ var _apidomCore = require("@speclynx/apidom-core");
9
9
  var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
10
  var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
11
11
  var _ExecutionError = _interopRequireDefault(require("../errors/ExecutionError.cjs"));
12
- /**
13
- * What one attempt at a step produced.
14
- *
15
- * Both kinds of step reduce to this — an operation step (whose richer
16
- * `StepExecutionResult` satisfies this shape) and a sub-workflow step
17
- * (synthesized from the sub-run's outcome) — so the retry loop drives them
18
- * identically and knows nothing about either.
19
- * @internal
20
- */
21
-
22
12
  /**
23
13
  * The terminal outcome of a step once its retries are settled.
24
14
  * @internal
@@ -2,15 +2,6 @@ import { toValue } from '@speclynx/apidom-core';
2
2
  import { isNumberElement, isStringElement } from '@speclynx/apidom-datamodel';
3
3
  import { isFailureActionElement } from '@speclynx/apidom-ns-arazzo-1';
4
4
  import ExecutionError from "../errors/ExecutionError.mjs";
5
- /**
6
- * What one attempt at a step produced.
7
- *
8
- * Both kinds of step reduce to this — an operation step (whose richer
9
- * `StepExecutionResult` satisfies this shape) and a sub-workflow step
10
- * (synthesized from the sub-run's outcome) — so the retry loop drives them
11
- * identically and knows nothing about either.
12
- * @internal
13
- */
14
5
  /**
15
6
  * The terminal outcome of a step once its retries are settled.
16
7
  * @internal
@@ -778,12 +778,6 @@ class WorkflowExecutor {
778
778
  const locator = await this.#workflowLocatorNormalizer.normalize(reference, document, {
779
779
  workflowId
780
780
  });
781
- if (!locator.document.workflowIndex.has(locator.workflowId)) {
782
- throw new _ExecutionError.default(`workflow "${workflowId}" depends on "${reference}", which the Arazzo document at "${locator.document.uri}" does not define`, {
783
- workflowId,
784
- reason: 'workflow-not-found'
785
- });
786
- }
787
781
  refs.push({
788
782
  locator,
789
783
  inputsKey: reference
@@ -972,24 +966,14 @@ class WorkflowExecutor {
972
966
  *
973
967
  * Shared rather than duplicated by its two callers, which otherwise repeat
974
968
  * the identical "resolve the reference, then run with no inputs" sequence.
975
- * Rejects a target its document does not define with the calling `stepId`
976
- * attached, unlike {@link WorkflowExecutor.#resolveWorkflow}'s own
977
- * `workflow-not-found` (reached only once `#run` itself resolves the
978
- * target) — which carries no caller context at all, since it is reached
979
- * generically from every kind of nested call.
969
+ * A target its document does not define is rejected by the normalizer,
970
+ * attributed to the calling workflow and `stepId`.
980
971
  */
981
972
  async #runReferencedWorkflow(reference, stepId, invocation, scope, via) {
982
973
  const locator = await this.#workflowLocatorNormalizer.normalize(reference, invocation.document, {
983
974
  workflowId: invocation.workflowId,
984
975
  stepId
985
976
  });
986
- if (!locator.document.workflowIndex.has(locator.workflowId)) {
987
- throw new _ExecutionError.default(`workflow "${locator.workflowId}" not found in Arazzo document at "${locator.document.uri}"`, {
988
- workflowId: locator.workflowId,
989
- stepId,
990
- reason: 'workflow-not-found'
991
- });
992
- }
993
977
  return this.#run(locator, {}, scope, invocation.callStack, via);
994
978
  }
995
979
 
@@ -997,7 +981,11 @@ class WorkflowExecutor {
997
981
  * Extracts and normalizes the workflow a locator names. A workflow its
998
982
  * document does not define is the executor-level `workflow-not-found`
999
983
  * authoring error, raised here rather than leaking the extractor's
1000
- * `ExtractionError`.
984
+ * `ExtractionError`. Only the root {@link WorkflowExecutor.execute} id
985
+ * reaches this check unvalidated — every reference position goes through
986
+ * the locator normalizer, which already rejects a missing workflow with
987
+ * the referencing context attached — so the error's `workflowId` is the
988
+ * missing id itself.
1001
989
  */
1002
990
  async #resolveWorkflow(locator, scope) {
1003
991
  const {
@@ -764,12 +764,6 @@ class WorkflowExecutor {
764
764
  const locator = await this.#workflowLocatorNormalizer.normalize(reference, document, {
765
765
  workflowId
766
766
  });
767
- if (!locator.document.workflowIndex.has(locator.workflowId)) {
768
- throw new ExecutionError(`workflow "${workflowId}" depends on "${reference}", which the Arazzo document at "${locator.document.uri}" does not define`, {
769
- workflowId,
770
- reason: 'workflow-not-found'
771
- });
772
- }
773
767
  refs.push({
774
768
  locator,
775
769
  inputsKey: reference
@@ -958,24 +952,14 @@ class WorkflowExecutor {
958
952
  *
959
953
  * Shared rather than duplicated by its two callers, which otherwise repeat
960
954
  * the identical "resolve the reference, then run with no inputs" sequence.
961
- * Rejects a target its document does not define with the calling `stepId`
962
- * attached, unlike {@link WorkflowExecutor.#resolveWorkflow}'s own
963
- * `workflow-not-found` (reached only once `#run` itself resolves the
964
- * target) — which carries no caller context at all, since it is reached
965
- * generically from every kind of nested call.
955
+ * A target its document does not define is rejected by the normalizer,
956
+ * attributed to the calling workflow and `stepId`.
966
957
  */
967
958
  async #runReferencedWorkflow(reference, stepId, invocation, scope, via) {
968
959
  const locator = await this.#workflowLocatorNormalizer.normalize(reference, invocation.document, {
969
960
  workflowId: invocation.workflowId,
970
961
  stepId
971
962
  });
972
- if (!locator.document.workflowIndex.has(locator.workflowId)) {
973
- throw new ExecutionError(`workflow "${locator.workflowId}" not found in Arazzo document at "${locator.document.uri}"`, {
974
- workflowId: locator.workflowId,
975
- stepId,
976
- reason: 'workflow-not-found'
977
- });
978
- }
979
963
  return this.#run(locator, {}, scope, invocation.callStack, via);
980
964
  }
981
965
 
@@ -983,7 +967,11 @@ class WorkflowExecutor {
983
967
  * Extracts and normalizes the workflow a locator names. A workflow its
984
968
  * document does not define is the executor-level `workflow-not-found`
985
969
  * authoring error, raised here rather than leaking the extractor's
986
- * `ExtractionError`.
970
+ * `ExtractionError`. Only the root {@link WorkflowExecutor.execute} id
971
+ * reaches this check unvalidated — every reference position goes through
972
+ * the locator normalizer, which already rejects a missing workflow with
973
+ * the referencing context attached — so the error's `workflowId` is the
974
+ * missing id itself.
987
975
  */
988
976
  async #resolveWorkflow(locator, scope) {
989
977
  const {