@usearazzo/runner 1.0.1-alpha.36 → 1.0.1-alpha.38

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.36",
3
+ "version": "1.0.1-alpha.38",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -112,8 +112,8 @@
112
112
  "@swaggerexpert/json-pointer": "^3.0.3",
113
113
  "@swaggerexpert/jsonpath": "^4.1.0",
114
114
  "@swaggerexpert/media-types": "^1.0.3",
115
- "@usearazzo/parser": "1.0.1-alpha.36",
116
- "@usearazzo/resolver": "1.0.1-alpha.36",
115
+ "@usearazzo/parser": "1.0.1-alpha.38",
116
+ "@usearazzo/resolver": "1.0.1-alpha.38",
117
117
  "@xmldom/xmldom": "^0.9.12",
118
118
  "fontoxpath": "^3.34.0",
119
119
  "ramda": "^0.32.0",
@@ -143,10 +143,10 @@
143
143
  }
144
144
  },
145
145
  "devDependencies": {
146
- "@opentelemetry/api": "~1.9.0",
146
+ "@opentelemetry/api": "~1.10.0",
147
147
  "@opentelemetry/context-async-hooks": "^3.1.1",
148
148
  "@opentelemetry/sdk-trace-base": "^2.12.0",
149
149
  "swagger-client": "^3.39.0"
150
150
  },
151
- "gitHead": "039f55923d0f86676181764b02744affcf5f6da2"
151
+ "gitHead": "e6f5880ca7ab04dd04bc1d559fa7574d15fc8203"
152
152
  }
@@ -35,7 +35,7 @@ class ExecutionError extends _ArazzoRunnerError.default {
35
35
  static InvalidWorkflowReference = 'invalid-workflow-reference';
36
36
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
37
37
  static MalformedDependsOn = 'malformed-dependsOn';
38
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
38
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
39
39
  static MalformedSteps = 'malformed-steps';
40
40
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
41
41
  static MissingOperation = 'missing-operation';
@@ -28,7 +28,7 @@ class ExecutionError extends ArazzoRunnerError {
28
28
  static InvalidWorkflowReference = 'invalid-workflow-reference';
29
29
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
30
30
  static MalformedDependsOn = 'malformed-dependsOn';
31
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
31
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
32
32
  static MalformedSteps = 'malformed-steps';
33
33
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
34
34
  static MissingOperation = 'missing-operation';
@@ -152,7 +152,8 @@ const IGNORED_HEADERS = new Set(['accept', 'authorization', 'content-type']);
152
152
  * sends it through the pluggable {@link HTTPClient}, and normalizes the raw
153
153
  * `Response` into the runner's response model. A non-2xx status is a valid
154
154
  * outcome (judged by a step's `successCriteria`) and is returned, never
155
- * thrown; a transport failure is wrapped as a {@link ClientError}.
155
+ * thrown; a transport failure, a response body that cannot be read in full
156
+ * included, is wrapped as a {@link ClientError}.
156
157
  *
157
158
  * The executor is Arazzo-agnostic: it neither locates the operation (that is
158
159
  * the operation locator normalizer's concern) nor resolves parameters or
@@ -332,10 +333,26 @@ class OpenAPIOperationExecutor {
332
333
  } catch (error) {
333
334
  throw new _ClientError.default('OpenAPI operation request failed', {
334
335
  operationPath: locator.jsonPointer,
336
+ uri: locator.document.uri,
337
+ cause: error
338
+ });
339
+ }
340
+
341
+ // the transport resolves once the headers are in, so a connection lost
342
+ // while the body streams fails here, inside the normalizer that reads it,
343
+ // and is as much a transport failure as a request that never got a
344
+ // response. Anything else the normalizer throws is reported the same way:
345
+ // either way there is no response to hand to the step.
346
+ let response;
347
+ try {
348
+ response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
349
+ } catch (error) {
350
+ throw new _ClientError.default('OpenAPI operation response could not be read', {
351
+ operationPath: locator.jsonPointer,
352
+ uri: locator.document.uri,
335
353
  cause: error
336
354
  });
337
355
  }
338
- const response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
339
356
  if (this.#events.hasObservers) {
340
357
  this.#events.emit({
341
358
  type: 'openapi:operation:request:settled',
@@ -140,7 +140,8 @@ const IGNORED_HEADERS = new Set(['accept', 'authorization', 'content-type']);
140
140
  * sends it through the pluggable {@link HTTPClient}, and normalizes the raw
141
141
  * `Response` into the runner's response model. A non-2xx status is a valid
142
142
  * outcome (judged by a step's `successCriteria`) and is returned, never
143
- * thrown; a transport failure is wrapped as a {@link ClientError}.
143
+ * thrown; a transport failure, a response body that cannot be read in full
144
+ * included, is wrapped as a {@link ClientError}.
144
145
  *
145
146
  * The executor is Arazzo-agnostic: it neither locates the operation (that is
146
147
  * the operation locator normalizer's concern) nor resolves parameters or
@@ -320,10 +321,26 @@ class OpenAPIOperationExecutor {
320
321
  } catch (error) {
321
322
  throw new ClientError('OpenAPI operation request failed', {
322
323
  operationPath: locator.jsonPointer,
324
+ uri: locator.document.uri,
325
+ cause: error
326
+ });
327
+ }
328
+
329
+ // the transport resolves once the headers are in, so a connection lost
330
+ // while the body streams fails here, inside the normalizer that reads it,
331
+ // and is as much a transport failure as a request that never got a
332
+ // response. Anything else the normalizer throws is reported the same way:
333
+ // either way there is no response to hand to the step.
334
+ let response;
335
+ try {
336
+ response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
337
+ } catch (error) {
338
+ throw new ClientError('OpenAPI operation response could not be read', {
339
+ operationPath: locator.jsonPointer,
340
+ uri: locator.document.uri,
323
341
  cause: error
324
342
  });
325
343
  }
326
- const response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
327
344
  if (this.#events.hasObservers) {
328
345
  this.#events.emit({
329
346
  type: 'openapi:operation:request:settled',
@@ -902,8 +902,8 @@ class WorkflowExecutor {
902
902
  * it is named a call cycle, not a dependency one, and charged one unit
903
903
  * for entering the reference itself, matching the "1 for the step itself
904
904
  * plus whatever its sub-run spends" convention a sub-workflow step
905
- * already follows (without it, a reference to a workflow with few or no
906
- * steps of its own would cost nothing to fire). Its inputs are the
905
+ * already follows (without it, a reference to a one-step workflow would
906
+ * cost no more than that step to fire). Its inputs are the
907
907
  * action's `parameters` (`#115`), resolved again on every firing
908
908
  * against the attempt that fired it — `{}` without them. Its outputs are
909
909
  * recorded via `state.setWorkflow`, which *is* "context transfers back",
@@ -1525,13 +1525,24 @@ class WorkflowExecutor {
1525
1525
  }
1526
1526
 
1527
1527
  /**
1528
- * The workflow's steps as an array in list order. An absent `steps` is a
1529
- * workflow with no steps — an empty list, a completed no-op run. A present but
1530
- * malformed `steps` (not a list, or holding a non-step entry) is an authoring
1531
- * error and throws rather than being silently treated as empty or partial.
1528
+ * The workflow's steps as an array in list order. `steps` is a REQUIRED field
1529
+ * holding at least one step, and the validator reports an absent or empty one
1530
+ * as an Error, so neither runs as a completed no-op. Those, like a `steps`
1531
+ * that is not a list or holds a non-step entry, are authoring errors and
1532
+ * throw rather than being silently treated as empty or partial.
1533
+ *
1534
+ * Checked when the workflow is entered, before any of its own prerequisites
1535
+ * or steps. A workflow another one only references (a `goto` target, a retry
1536
+ * reference) is therefore rejected when the run reaches it, after the
1537
+ * requests sent on the way there.
1532
1538
  */
1533
1539
  #orderedSteps(workflow, workflowId) {
1534
- if (!workflow.hasKey('steps')) return [];
1540
+ if (!workflow.hasKey('steps')) {
1541
+ throw new _ExecutionError.default(`workflow "${workflowId}" has no "steps"`, {
1542
+ workflowId,
1543
+ reason: _ExecutionError.default.MalformedSteps
1544
+ });
1545
+ }
1535
1546
  const steps = workflow.steps;
1536
1547
  if (!(0, _apidomDatamodel.isArrayElement)(steps)) {
1537
1548
  throw new _ExecutionError.default(`workflow "${workflowId}" has a non-list "steps"`, {
@@ -1539,6 +1550,12 @@ class WorkflowExecutor {
1539
1550
  reason: _ExecutionError.default.MalformedSteps
1540
1551
  });
1541
1552
  }
1553
+ if (steps.isEmpty) {
1554
+ throw new _ExecutionError.default(`workflow "${workflowId}" has an empty "steps"`, {
1555
+ workflowId,
1556
+ reason: _ExecutionError.default.MalformedSteps
1557
+ });
1558
+ }
1542
1559
  return [...steps].map((step, index) => {
1543
1560
  if (!(0, _apidomNsArazzo.isStepElement)(step)) {
1544
1561
  throw new _ExecutionError.default(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
@@ -888,8 +888,8 @@ class WorkflowExecutor {
888
888
  * it is named a call cycle, not a dependency one, and charged one unit
889
889
  * for entering the reference itself, matching the "1 for the step itself
890
890
  * plus whatever its sub-run spends" convention a sub-workflow step
891
- * already follows (without it, a reference to a workflow with few or no
892
- * steps of its own would cost nothing to fire). Its inputs are the
891
+ * already follows (without it, a reference to a one-step workflow would
892
+ * cost no more than that step to fire). Its inputs are the
893
893
  * action's `parameters` (`#115`), resolved again on every firing
894
894
  * against the attempt that fired it — `{}` without them. Its outputs are
895
895
  * recorded via `state.setWorkflow`, which *is* "context transfers back",
@@ -1511,13 +1511,24 @@ class WorkflowExecutor {
1511
1511
  }
1512
1512
 
1513
1513
  /**
1514
- * The workflow's steps as an array in list order. An absent `steps` is a
1515
- * workflow with no steps — an empty list, a completed no-op run. A present but
1516
- * malformed `steps` (not a list, or holding a non-step entry) is an authoring
1517
- * error and throws rather than being silently treated as empty or partial.
1514
+ * The workflow's steps as an array in list order. `steps` is a REQUIRED field
1515
+ * holding at least one step, and the validator reports an absent or empty one
1516
+ * as an Error, so neither runs as a completed no-op. Those, like a `steps`
1517
+ * that is not a list or holds a non-step entry, are authoring errors and
1518
+ * throw rather than being silently treated as empty or partial.
1519
+ *
1520
+ * Checked when the workflow is entered, before any of its own prerequisites
1521
+ * or steps. A workflow another one only references (a `goto` target, a retry
1522
+ * reference) is therefore rejected when the run reaches it, after the
1523
+ * requests sent on the way there.
1518
1524
  */
1519
1525
  #orderedSteps(workflow, workflowId) {
1520
- if (!workflow.hasKey('steps')) return [];
1526
+ if (!workflow.hasKey('steps')) {
1527
+ throw new ExecutionError(`workflow "${workflowId}" has no "steps"`, {
1528
+ workflowId,
1529
+ reason: ExecutionError.MalformedSteps
1530
+ });
1531
+ }
1521
1532
  const steps = workflow.steps;
1522
1533
  if (!isArrayElement(steps)) {
1523
1534
  throw new ExecutionError(`workflow "${workflowId}" has a non-list "steps"`, {
@@ -1525,6 +1536,12 @@ class WorkflowExecutor {
1525
1536
  reason: ExecutionError.MalformedSteps
1526
1537
  });
1527
1538
  }
1539
+ if (steps.isEmpty) {
1540
+ throw new ExecutionError(`workflow "${workflowId}" has an empty "steps"`, {
1541
+ workflowId,
1542
+ reason: ExecutionError.MalformedSteps
1543
+ });
1544
+ }
1528
1545
  return [...steps].map((step, index) => {
1529
1546
  if (!isStepElement(step)) {
1530
1547
  throw new ExecutionError(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
package/src/version.cjs CHANGED
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  // generated by scripts/version-update.mjs from package.json; do not edit
8
- const version = '1.0.1-alpha.35';
8
+ const version = '1.0.1-alpha.37';
9
9
  var _default = exports.default = version;
package/src/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  // generated by scripts/version-update.mjs from package.json; do not edit
2
- const version = '1.0.1-alpha.35';
2
+ const version = '1.0.1-alpha.37';
3
3
  export default version;
@@ -1136,7 +1136,7 @@ export declare class ExecutionError extends ArazzoRunnerError {
1136
1136
  static readonly InvalidWorkflowReference: "invalid-workflow-reference";
1137
1137
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
1138
1138
  static readonly MalformedDependsOn: "malformed-dependsOn";
1139
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
1139
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
1140
1140
  static readonly MalformedSteps: "malformed-steps";
1141
1141
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
1142
1142
  static readonly MissingOperation: "missing-operation";
@@ -1681,7 +1681,8 @@ export declare type OpenAPIOperationExecuteOptionsBag = OpenAPIOperationExecuteO
1681
1681
  * sends it through the pluggable {@link HTTPClient}, and normalizes the raw
1682
1682
  * `Response` into the runner's response model. A non-2xx status is a valid
1683
1683
  * outcome (judged by a step's `successCriteria`) and is returned, never
1684
- * thrown; a transport failure is wrapped as a {@link ClientError}.
1684
+ * thrown; a transport failure, a response body that cannot be read in full
1685
+ * included, is wrapped as a {@link ClientError}.
1685
1686
  *
1686
1687
  * The executor is Arazzo-agnostic: it neither locates the operation (that is
1687
1688
  * the operation locator normalizer's concern) nor resolves parameters or
@@ -2926,6 +2927,12 @@ export declare type StepExecuteOptions = Record<string, unknown> | ((locator: Op
2926
2927
  export declare interface StepExecutionResult {
2927
2928
  readonly stepId: string;
2928
2929
  readonly response: OpenAPIOperationResponse;
2930
+ /**
2931
+ * Whether every one of the step's `successCriteria` was met. A step without
2932
+ * `successCriteria` asserts nothing, so it is successful on any received
2933
+ * response, whatever its status code; its `successCriteria` records are then
2934
+ * empty.
2935
+ */
2929
2936
  readonly successful: boolean;
2930
2937
  readonly outputs: Record<string, unknown>;
2931
2938
  /**
@@ -3156,6 +3163,16 @@ export declare interface StepRunRecord {
3156
3163
  * Where the step is written.
3157
3164
  */
3158
3165
  readonly location: DocumentLocation;
3166
+ /**
3167
+ * Whether the step succeeded in its last attempt: every one of its
3168
+ * `successCriteria` was met and, for a step calling a workflow, that
3169
+ * workflow's run did not settle as failed (see
3170
+ * {@link WorkflowExecutionResult.settledStatus}). A step without
3171
+ * `successCriteria` asserts nothing, so its records are empty: one calling an
3172
+ * operation is then successful on any received response, whatever its status
3173
+ * code, and one calling a workflow unless that workflow's run settled as
3174
+ * failed.
3175
+ */
3159
3176
  readonly successful: boolean;
3160
3177
  readonly action: SelectedAction | undefined;
3161
3178
  /**
package/types/runner.d.ts CHANGED
@@ -1136,7 +1136,7 @@ export declare class ExecutionError extends ArazzoRunnerError {
1136
1136
  static readonly InvalidWorkflowReference: "invalid-workflow-reference";
1137
1137
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
1138
1138
  static readonly MalformedDependsOn: "malformed-dependsOn";
1139
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
1139
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
1140
1140
  static readonly MalformedSteps: "malformed-steps";
1141
1141
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
1142
1142
  static readonly MissingOperation: "missing-operation";
@@ -1681,7 +1681,8 @@ export declare type OpenAPIOperationExecuteOptionsBag = OpenAPIOperationExecuteO
1681
1681
  * sends it through the pluggable {@link HTTPClient}, and normalizes the raw
1682
1682
  * `Response` into the runner's response model. A non-2xx status is a valid
1683
1683
  * outcome (judged by a step's `successCriteria`) and is returned, never
1684
- * thrown; a transport failure is wrapped as a {@link ClientError}.
1684
+ * thrown; a transport failure, a response body that cannot be read in full
1685
+ * included, is wrapped as a {@link ClientError}.
1685
1686
  *
1686
1687
  * The executor is Arazzo-agnostic: it neither locates the operation (that is
1687
1688
  * the operation locator normalizer's concern) nor resolves parameters or
@@ -2926,6 +2927,12 @@ export declare type StepExecuteOptions = Record<string, unknown> | ((locator: Op
2926
2927
  export declare interface StepExecutionResult {
2927
2928
  readonly stepId: string;
2928
2929
  readonly response: OpenAPIOperationResponse;
2930
+ /**
2931
+ * Whether every one of the step's `successCriteria` was met. A step without
2932
+ * `successCriteria` asserts nothing, so it is successful on any received
2933
+ * response, whatever its status code; its `successCriteria` records are then
2934
+ * empty.
2935
+ */
2929
2936
  readonly successful: boolean;
2930
2937
  readonly outputs: Record<string, unknown>;
2931
2938
  /**
@@ -3156,6 +3163,16 @@ export declare interface StepRunRecord {
3156
3163
  * Where the step is written.
3157
3164
  */
3158
3165
  readonly location: DocumentLocation;
3166
+ /**
3167
+ * Whether the step succeeded in its last attempt: every one of its
3168
+ * `successCriteria` was met and, for a step calling a workflow, that
3169
+ * workflow's run did not settle as failed (see
3170
+ * {@link WorkflowExecutionResult.settledStatus}). A step without
3171
+ * `successCriteria` asserts nothing, so its records are empty: one calling an
3172
+ * operation is then successful on any received response, whatever its status
3173
+ * code, and one calling a workflow unless that workflow's run settled as
3174
+ * failed.
3175
+ */
3159
3176
  readonly successful: boolean;
3160
3177
  readonly action: SelectedAction | undefined;
3161
3178
  /**