@usearazzo/runner 1.0.1-alpha.23 → 1.0.1-alpha.25

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 (58) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +3 -1
  3. package/dist/arazzo-runner.browser.js +400 -229
  4. package/dist/arazzo-runner.browser.min.js +1 -1
  5. package/package.json +4 -4
  6. package/src/action/ActionResolver.cjs +4 -4
  7. package/src/action/ActionResolver.mjs +4 -4
  8. package/src/criterion/CriterionEvaluator.cjs +8 -9
  9. package/src/criterion/CriterionEvaluator.mjs +8 -9
  10. package/src/criterion/JSONPathCriterionEvaluator.cjs +1 -2
  11. package/src/criterion/JSONPathCriterionEvaluator.mjs +1 -2
  12. package/src/criterion/RegexCriterionEvaluator.cjs +1 -2
  13. package/src/criterion/RegexCriterionEvaluator.mjs +1 -2
  14. package/src/criterion/SimpleCriterionEvaluator.cjs +1 -2
  15. package/src/criterion/SimpleCriterionEvaluator.mjs +1 -2
  16. package/src/criterion/XPathCriterionEvaluator.cjs +4 -5
  17. package/src/criterion/XPathCriterionEvaluator.mjs +4 -5
  18. package/src/document/ArazzoDocument.cjs +33 -1
  19. package/src/document/ArazzoDocument.mjs +32 -1
  20. package/src/errors/CriterionError.cjs +52 -2
  21. package/src/errors/CriterionError.mjs +53 -2
  22. package/src/errors/ExecutionError.cjs +73 -2
  23. package/src/errors/ExecutionError.mjs +74 -2
  24. package/src/errors/ResolverError.cjs +53 -2
  25. package/src/errors/ResolverError.mjs +54 -2
  26. package/src/errors/RuntimeExpressionError.cjs +32 -2
  27. package/src/errors/RuntimeExpressionError.mjs +33 -2
  28. package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +4 -4
  29. package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +4 -4
  30. package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +11 -11
  31. package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +11 -11
  32. package/src/executor/StepExecutor.cjs +7 -7
  33. package/src/executor/StepExecutor.mjs +7 -7
  34. package/src/executor/StepRetryRunner.cjs +1 -1
  35. package/src/executor/StepRetryRunner.mjs +1 -1
  36. package/src/executor/StepTransitionInterpreter.cjs +3 -3
  37. package/src/executor/StepTransitionInterpreter.mjs +3 -3
  38. package/src/executor/WorkflowCallStack.cjs +2 -2
  39. package/src/executor/WorkflowCallStack.mjs +2 -2
  40. package/src/executor/WorkflowExecutor.cjs +13 -13
  41. package/src/executor/WorkflowExecutor.mjs +13 -13
  42. package/src/executor/abort.cjs +3 -3
  43. package/src/executor/abort.mjs +3 -3
  44. package/src/expression/RuntimeExpressionEvaluator.cjs +5 -5
  45. package/src/expression/RuntimeExpressionEvaluator.mjs +5 -5
  46. package/src/index.cjs +0 -7
  47. package/src/index.mjs +0 -1
  48. package/src/resolver/OpenAPIOperationParameterResolver.cjs +6 -6
  49. package/src/resolver/OpenAPIOperationParameterResolver.mjs +6 -6
  50. package/src/resolver/OutputResolver.cjs +3 -3
  51. package/src/resolver/OutputResolver.mjs +3 -3
  52. package/src/resolver/RequestBodyResolver.cjs +6 -6
  53. package/src/resolver/RequestBodyResolver.mjs +6 -6
  54. package/src/resolver/WorkflowParameterResolver.cjs +1 -1
  55. package/src/resolver/WorkflowParameterResolver.mjs +1 -1
  56. package/types/runner.d.ts +228 -46
  57. package/src/criterion/CriterionErrorReason.cjs +0 -51
  58. package/src/criterion/CriterionErrorReason.mjs +0 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usearazzo/runner",
3
- "version": "1.0.1-alpha.23",
3
+ "version": "1.0.1-alpha.25",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -73,8 +73,8 @@
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.23",
77
- "@usearazzo/resolver": "1.0.1-alpha.23",
76
+ "@usearazzo/parser": "1.0.1-alpha.25",
77
+ "@usearazzo/resolver": "1.0.1-alpha.25",
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": "49de409b1fb851453c8c8c19cfdc12ec88545ca1"
97
+ "gitHead": "37de6e45a52dabf8a924f09fed3ae4d41396be7d"
98
98
  }
@@ -106,7 +106,7 @@ class ActionResolver {
106
106
  throw new _ResolverError.default(`\`${field}\` is present but is not a list`, {
107
107
  ...scope,
108
108
  target: field,
109
- reason: 'malformed-actions'
109
+ reason: _ResolverError.default.MalformedActions
110
110
  });
111
111
  }
112
112
  const matched = [];
@@ -115,7 +115,7 @@ class ActionResolver {
115
115
  throw new _ResolverError.default(`\`${field}\` contains an entry that is not a Success/Failure Action Object`, {
116
116
  ...scope,
117
117
  target: field,
118
- reason: 'malformed-action-entry'
118
+ reason: _ResolverError.default.MalformedActionEntry
119
119
  });
120
120
  }
121
121
  if (this.#criteriaMet(action, isCriterionMet, scope)) {
@@ -142,7 +142,7 @@ class ActionResolver {
142
142
  throw new _ResolverError.default("An action's `criteria` is present but is not a list", {
143
143
  ...scope,
144
144
  target: 'criteria',
145
- reason: 'malformed-criteria'
145
+ reason: _ResolverError.default.MalformedCriteria
146
146
  });
147
147
  }
148
148
  let met = true;
@@ -151,7 +151,7 @@ class ActionResolver {
151
151
  throw new _ResolverError.default("An action's `criteria` contains an entry that is not a Criterion Object", {
152
152
  ...scope,
153
153
  target: 'criteria',
154
- reason: 'malformed-criterion'
154
+ reason: _ResolverError.default.MalformedCriterion
155
155
  });
156
156
  }
157
157
  // every criterion is evaluated, not only up to the first unmet one, so
@@ -96,7 +96,7 @@ class ActionResolver {
96
96
  throw new ResolverError(`\`${field}\` is present but is not a list`, {
97
97
  ...scope,
98
98
  target: field,
99
- reason: 'malformed-actions'
99
+ reason: ResolverError.MalformedActions
100
100
  });
101
101
  }
102
102
  const matched = [];
@@ -105,7 +105,7 @@ class ActionResolver {
105
105
  throw new ResolverError(`\`${field}\` contains an entry that is not a Success/Failure Action Object`, {
106
106
  ...scope,
107
107
  target: field,
108
- reason: 'malformed-action-entry'
108
+ reason: ResolverError.MalformedActionEntry
109
109
  });
110
110
  }
111
111
  if (this.#criteriaMet(action, isCriterionMet, scope)) {
@@ -132,7 +132,7 @@ class ActionResolver {
132
132
  throw new ResolverError("An action's `criteria` is present but is not a list", {
133
133
  ...scope,
134
134
  target: 'criteria',
135
- reason: 'malformed-criteria'
135
+ reason: ResolverError.MalformedCriteria
136
136
  });
137
137
  }
138
138
  let met = true;
@@ -141,7 +141,7 @@ class ActionResolver {
141
141
  throw new ResolverError("An action's `criteria` contains an entry that is not a Criterion Object", {
142
142
  ...scope,
143
143
  target: 'criteria',
144
- reason: 'malformed-criterion'
144
+ reason: ResolverError.MalformedCriterion
145
145
  });
146
146
  }
147
147
  // every criterion is evaluated, not only up to the first unmet one, so
@@ -11,7 +11,6 @@ var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
11
11
  var _arazzoRuntimeExpression = require("@swaggerexpert/arazzo-runtime-expression");
12
12
  var _CriterionError = _interopRequireDefault(require("../errors/CriterionError.cjs"));
13
13
  var _CriterionEvaluationError = _interopRequireDefault(require("../errors/CriterionEvaluationError.cjs"));
14
- var _CriterionErrorReason = _interopRequireDefault(require("./CriterionErrorReason.cjs"));
15
14
  var _RegexCriterionEvaluator = _interopRequireDefault(require("./RegexCriterionEvaluator.cjs"));
16
15
  var _SimpleCriterionEvaluator = _interopRequireDefault(require("./SimpleCriterionEvaluator.cjs"));
17
16
  var _JSONPathCriterionEvaluator = _interopRequireDefault(require("./JSONPathCriterionEvaluator.cjs"));
@@ -103,7 +102,7 @@ class CriterionEvaluator {
103
102
  evaluate(criterion, resolve) {
104
103
  if (!(0, _apidomNsArazzo.isCriterionElement)(criterion)) {
105
104
  throw new _CriterionError.default('Element is not a Criterion Object', {
106
- reason: _CriterionErrorReason.default.InvalidCriterion
105
+ reason: _CriterionError.default.InvalidCriterion
107
106
  });
108
107
  }
109
108
  const condition = (0, _apidomDatamodel.isStringElement)(criterion.condition) ? (0, _apidomCore.toValue)(criterion.condition) : undefined;
@@ -111,7 +110,7 @@ class CriterionEvaluator {
111
110
  // (e.g. an empty regex would match unconditionally), so reject it too.
112
111
  if (condition === undefined || condition === '') {
113
112
  throw new _CriterionError.default('Criterion is missing a "condition"', {
114
- reason: _CriterionErrorReason.default.MissingCondition
113
+ reason: _CriterionError.default.MissingCondition
115
114
  });
116
115
  }
117
116
  const type = this.#resolveType(criterion);
@@ -142,7 +141,7 @@ class CriterionEvaluator {
142
141
  throw new _CriterionError.default(`Unknown criterion type "${type}"`, {
143
142
  condition,
144
143
  type,
145
- reason: _CriterionErrorReason.default.UnknownType
144
+ reason: _CriterionError.default.UnknownType
146
145
  });
147
146
  }
148
147
  } catch (error) {
@@ -173,7 +172,7 @@ class CriterionEvaluator {
173
172
  }
174
173
  if ((0, _apidomDatamodel.isStringElement)(type)) return (0, _apidomCore.toValue)(type);
175
174
  throw new _CriterionError.default('Criterion has an invalid "type"', {
176
- reason: _CriterionErrorReason.default.InvalidType
175
+ reason: _CriterionError.default.InvalidType
177
176
  });
178
177
  }
179
178
 
@@ -193,7 +192,7 @@ class CriterionEvaluator {
193
192
  return (0, _apidomCore.toValue)(type.version);
194
193
  }
195
194
  throw new _CriterionError.default('Criterion has an invalid expression type "version"', {
196
- reason: _CriterionErrorReason.default.InvalidVersion
195
+ reason: _CriterionError.default.InvalidVersion
197
196
  });
198
197
  }
199
198
 
@@ -208,7 +207,7 @@ class CriterionEvaluator {
208
207
  throw new _CriterionError.default(`Unsupported ${type} version "${version}" (only ${supported})`, {
209
208
  condition,
210
209
  type,
211
- reason: _CriterionErrorReason.default.UnsupportedVersion
210
+ reason: _CriterionError.default.UnsupportedVersion
212
211
  });
213
212
  }
214
213
  }
@@ -226,7 +225,7 @@ class CriterionEvaluator {
226
225
  if (!(0, _apidomDatamodel.isStringElement)(context) || !(0, _arazzoRuntimeExpression.test)((0, _apidomCore.toValue)(context))) {
227
226
  throw new _CriterionError.default('Criterion has a "context" that is not a valid runtime expression', {
228
227
  type,
229
- reason: _CriterionErrorReason.default.InvalidContext
228
+ reason: _CriterionError.default.InvalidContext
230
229
  });
231
230
  }
232
231
  }
@@ -241,7 +240,7 @@ class CriterionEvaluator {
241
240
  if (!(0, _apidomDatamodel.isStringElement)(criterion.context)) {
242
241
  throw new _CriterionError.default(`Criterion type "${type}" requires a "context"`, {
243
242
  type,
244
- reason: _CriterionErrorReason.default.MissingContext
243
+ reason: _CriterionError.default.MissingContext
245
244
  });
246
245
  }
247
246
  return resolve((0, _apidomCore.toValue)(criterion.context));
@@ -4,7 +4,6 @@ import { isCriterionElement, isCriterionExpressionTypeElement } from '@speclynx/
4
4
  import { test as isRuntimeExpression } from '@swaggerexpert/arazzo-runtime-expression';
5
5
  import CriterionError from "../errors/CriterionError.mjs";
6
6
  import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
7
- import CriterionErrorReason from "./CriterionErrorReason.mjs";
8
7
  import RegexCriterionEvaluator from "./RegexCriterionEvaluator.mjs";
9
8
  import SimpleCriterionEvaluator from "./SimpleCriterionEvaluator.mjs";
10
9
  import JSONPathCriterionEvaluator from "./JSONPathCriterionEvaluator.mjs";
@@ -93,7 +92,7 @@ class CriterionEvaluator {
93
92
  evaluate(criterion, resolve) {
94
93
  if (!isCriterionElement(criterion)) {
95
94
  throw new CriterionError('Element is not a Criterion Object', {
96
- reason: CriterionErrorReason.InvalidCriterion
95
+ reason: CriterionError.InvalidCriterion
97
96
  });
98
97
  }
99
98
  const condition = isStringElement(criterion.condition) ? toValue(criterion.condition) : undefined;
@@ -101,7 +100,7 @@ class CriterionEvaluator {
101
100
  // (e.g. an empty regex would match unconditionally), so reject it too.
102
101
  if (condition === undefined || condition === '') {
103
102
  throw new CriterionError('Criterion is missing a "condition"', {
104
- reason: CriterionErrorReason.MissingCondition
103
+ reason: CriterionError.MissingCondition
105
104
  });
106
105
  }
107
106
  const type = this.#resolveType(criterion);
@@ -132,7 +131,7 @@ class CriterionEvaluator {
132
131
  throw new CriterionError(`Unknown criterion type "${type}"`, {
133
132
  condition,
134
133
  type,
135
- reason: CriterionErrorReason.UnknownType
134
+ reason: CriterionError.UnknownType
136
135
  });
137
136
  }
138
137
  } catch (error) {
@@ -163,7 +162,7 @@ class CriterionEvaluator {
163
162
  }
164
163
  if (isStringElement(type)) return toValue(type);
165
164
  throw new CriterionError('Criterion has an invalid "type"', {
166
- reason: CriterionErrorReason.InvalidType
165
+ reason: CriterionError.InvalidType
167
166
  });
168
167
  }
169
168
 
@@ -183,7 +182,7 @@ class CriterionEvaluator {
183
182
  return toValue(type.version);
184
183
  }
185
184
  throw new CriterionError('Criterion has an invalid expression type "version"', {
186
- reason: CriterionErrorReason.InvalidVersion
185
+ reason: CriterionError.InvalidVersion
187
186
  });
188
187
  }
189
188
 
@@ -198,7 +197,7 @@ class CriterionEvaluator {
198
197
  throw new CriterionError(`Unsupported ${type} version "${version}" (only ${supported})`, {
199
198
  condition,
200
199
  type,
201
- reason: CriterionErrorReason.UnsupportedVersion
200
+ reason: CriterionError.UnsupportedVersion
202
201
  });
203
202
  }
204
203
  }
@@ -216,7 +215,7 @@ class CriterionEvaluator {
216
215
  if (!isStringElement(context) || !isRuntimeExpression(toValue(context))) {
217
216
  throw new CriterionError('Criterion has a "context" that is not a valid runtime expression', {
218
217
  type,
219
- reason: CriterionErrorReason.InvalidContext
218
+ reason: CriterionError.InvalidContext
220
219
  });
221
220
  }
222
221
  }
@@ -231,7 +230,7 @@ class CriterionEvaluator {
231
230
  if (!isStringElement(criterion.context)) {
232
231
  throw new CriterionError(`Criterion type "${type}" requires a "context"`, {
233
232
  type,
234
- reason: CriterionErrorReason.MissingContext
233
+ reason: CriterionError.MissingContext
235
234
  });
236
235
  }
237
236
  return resolve(toValue(criterion.context));
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _jsonpath = require("@swaggerexpert/jsonpath");
9
9
  var _CriterionEvaluationError = _interopRequireDefault(require("../errors/CriterionEvaluationError.cjs"));
10
- var _CriterionErrorReason = _interopRequireDefault(require("./CriterionErrorReason.cjs"));
11
10
  /**
12
11
  * Evaluates a `jsonpath` Arazzo criterion condition against a resolved context value.
13
12
  *
@@ -41,7 +40,7 @@ class JSONPathCriterionEvaluator {
41
40
  cause: error,
42
41
  condition,
43
42
  type: 'jsonpath',
44
- reason: _CriterionErrorReason.default.InvalidJSONPath
43
+ reason: _CriterionEvaluationError.default.InvalidJSONPath
45
44
  });
46
45
  }
47
46
  throw error;
@@ -1,6 +1,5 @@
1
1
  import { evaluate as evaluateJSONPath, JSONPathError, JSONPathParseError } from '@swaggerexpert/jsonpath';
2
2
  import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
3
- import CriterionErrorReason from "./CriterionErrorReason.mjs";
4
3
  /**
5
4
  * Evaluates a `jsonpath` Arazzo criterion condition against a resolved context value.
6
5
  *
@@ -34,7 +33,7 @@ class JSONPathCriterionEvaluator {
34
33
  cause: error,
35
34
  condition,
36
35
  type: 'jsonpath',
37
- reason: CriterionErrorReason.InvalidJSONPath
36
+ reason: CriterionEvaluationError.InvalidJSONPath
38
37
  });
39
38
  }
40
39
  throw error;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _CriterionEvaluationError = _interopRequireDefault(require("../errors/CriterionEvaluationError.cjs"));
9
- var _CriterionErrorReason = _interopRequireDefault(require("./CriterionErrorReason.cjs"));
10
9
  /**
11
10
  * Evaluates a `regex` Arazzo criterion condition against a resolved context value.
12
11
  *
@@ -49,7 +48,7 @@ class RegexCriterionEvaluator {
49
48
  cause: error,
50
49
  condition,
51
50
  type: 'regex',
52
- reason: _CriterionErrorReason.default.InvalidRegex
51
+ reason: _CriterionEvaluationError.default.InvalidRegex
53
52
  });
54
53
  }
55
54
  return regExp.test(this.#stringify(context));
@@ -1,5 +1,4 @@
1
1
  import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
2
- import CriterionErrorReason from "./CriterionErrorReason.mjs";
3
2
  /**
4
3
  * Evaluates a `regex` Arazzo criterion condition against a resolved context value.
5
4
  *
@@ -42,7 +41,7 @@ class RegexCriterionEvaluator {
42
41
  cause: error,
43
42
  condition,
44
43
  type: 'regex',
45
- reason: CriterionErrorReason.InvalidRegex
44
+ reason: CriterionEvaluationError.InvalidRegex
46
45
  });
47
46
  }
48
47
  return regExp.test(this.#stringify(context));
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _arazzoCriterion = require("@swaggerexpert/arazzo-criterion");
9
9
  var _CriterionEvaluationError = _interopRequireDefault(require("../errors/CriterionEvaluationError.cjs"));
10
- var _CriterionErrorReason = _interopRequireDefault(require("./CriterionErrorReason.cjs"));
11
10
  /**
12
11
  * Evaluates a `simple` Arazzo criterion condition.
13
12
  *
@@ -41,7 +40,7 @@ class SimpleCriterionEvaluator {
41
40
  cause: error,
42
41
  condition,
43
42
  type: 'simple',
44
- reason: _CriterionErrorReason.default.InvalidSimple
43
+ reason: _CriterionEvaluationError.default.InvalidSimple
45
44
  });
46
45
  }
47
46
  throw error;
@@ -1,6 +1,5 @@
1
1
  import { evaluate as evaluateSimpleCriterion, ArazzoCriterionError } from '@swaggerexpert/arazzo-criterion';
2
2
  import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
3
- import CriterionErrorReason from "./CriterionErrorReason.mjs";
4
3
  /**
5
4
  * Evaluates a `simple` Arazzo criterion condition.
6
5
  *
@@ -34,7 +33,7 @@ class SimpleCriterionEvaluator {
34
33
  cause: error,
35
34
  condition,
36
35
  type: 'simple',
37
- reason: CriterionErrorReason.InvalidSimple
36
+ reason: CriterionEvaluationError.InvalidSimple
38
37
  });
39
38
  }
40
39
  throw error;
@@ -8,7 +8,6 @@ exports.default = void 0;
8
8
  var _fontoxpath = _interopRequireDefault(require("fontoxpath"));
9
9
  var _xmldom = require("@xmldom/xmldom");
10
10
  var _CriterionEvaluationError = _interopRequireDefault(require("../errors/CriterionEvaluationError.cjs"));
11
- var _CriterionErrorReason = _interopRequireDefault(require("./CriterionErrorReason.cjs"));
12
11
  // fontoxpath is CommonJS and its named exports are not statically resolvable
13
12
  // under ESM, so import the default and destructure.
14
13
 
@@ -55,7 +54,7 @@ class XPathCriterionEvaluator {
55
54
  cause: error,
56
55
  condition,
57
56
  type: 'xpath',
58
- reason: _CriterionErrorReason.default.InvalidXPath
57
+ reason: _CriterionEvaluationError.default.InvalidXPath
59
58
  });
60
59
  }
61
60
  }
@@ -71,7 +70,7 @@ class XPathCriterionEvaluator {
71
70
  throw new _CriterionEvaluationError.default('xpath criterion context is not XML', {
72
71
  condition,
73
72
  type: 'xpath',
74
- reason: _CriterionErrorReason.default.InvalidXPathContext
73
+ reason: _CriterionEvaluationError.default.InvalidXPathContext
75
74
  });
76
75
  }
77
76
 
@@ -91,7 +90,7 @@ class XPathCriterionEvaluator {
91
90
  cause: parseError,
92
91
  condition,
93
92
  type: 'xpath',
94
- reason: _CriterionErrorReason.default.InvalidXPathContext
93
+ reason: _CriterionEvaluationError.default.InvalidXPathContext
95
94
  });
96
95
  }
97
96
  return document;
@@ -101,7 +100,7 @@ class XPathCriterionEvaluator {
101
100
  cause: error,
102
101
  condition,
103
102
  type: 'xpath',
104
- reason: _CriterionErrorReason.default.InvalidXPathContext
103
+ reason: _CriterionEvaluationError.default.InvalidXPathContext
105
104
  });
106
105
  }
107
106
  }
@@ -3,7 +3,6 @@
3
3
  import fontoxpath from 'fontoxpath';
4
4
  import { DOMParser } from '@xmldom/xmldom';
5
5
  import CriterionEvaluationError from "../errors/CriterionEvaluationError.mjs";
6
- import CriterionErrorReason from "./CriterionErrorReason.mjs";
7
6
  const {
8
7
  evaluateXPathToBoolean,
9
8
  evaluateXPath
@@ -47,7 +46,7 @@ class XPathCriterionEvaluator {
47
46
  cause: error,
48
47
  condition,
49
48
  type: 'xpath',
50
- reason: CriterionErrorReason.InvalidXPath
49
+ reason: CriterionEvaluationError.InvalidXPath
51
50
  });
52
51
  }
53
52
  }
@@ -63,7 +62,7 @@ class XPathCriterionEvaluator {
63
62
  throw new CriterionEvaluationError('xpath criterion context is not XML', {
64
63
  condition,
65
64
  type: 'xpath',
66
- reason: CriterionErrorReason.InvalidXPathContext
65
+ reason: CriterionEvaluationError.InvalidXPathContext
67
66
  });
68
67
  }
69
68
 
@@ -83,7 +82,7 @@ class XPathCriterionEvaluator {
83
82
  cause: parseError,
84
83
  condition,
85
84
  type: 'xpath',
86
- reason: CriterionErrorReason.InvalidXPathContext
85
+ reason: CriterionEvaluationError.InvalidXPathContext
87
86
  });
88
87
  }
89
88
  return document;
@@ -93,7 +92,7 @@ class XPathCriterionEvaluator {
93
92
  cause: error,
94
93
  condition,
95
94
  type: 'xpath',
96
- reason: CriterionErrorReason.InvalidXPathContext
95
+ reason: CriterionEvaluationError.InvalidXPathContext
97
96
  });
98
97
  }
99
98
  }
@@ -6,11 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _apidomCore = require("@speclynx/apidom-core");
9
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
+ var _apidomJsonPointer = require("@speclynx/apidom-json-pointer");
9
11
  var _APIDocument = _interopRequireDefault(require("./APIDocument.cjs"));
12
+ /**
13
+ * A workflow of an Arazzo document, as listed by
14
+ * {@link ArazzoDocument.listWorkflows}.
15
+ * @public
16
+ */
17
+
10
18
  /**
11
19
  * An Arazzo document held by the document registry: the parse result together
12
20
  * with the indexes the provider built over it — a container, not a logic
13
- * bearer. The methods below are thin reads of the source description index.
21
+ * bearer. The methods below are thin reads of those indexes.
14
22
  * @public
15
23
  */
16
24
  class ArazzoDocument extends _APIDocument.default {
@@ -46,6 +54,30 @@ class ArazzoDocument extends _APIDocument.default {
46
54
  return doc.type === 'arazzo';
47
55
  }
48
56
 
57
+ /**
58
+ * The workflows of this document that can be addressed by `workflowId`, in
59
+ * document order. Reads this document only: source descriptions are neither
60
+ * loaded nor listed.
61
+ */
62
+ listWorkflows() {
63
+ return [...this.workflowIndex].map(([workflowId, jsonPointer]) => {
64
+ const {
65
+ summary,
66
+ description
67
+ } = (0, _apidomJsonPointer.evaluate)(this.parseResult.api, jsonPointer);
68
+ return {
69
+ workflowId,
70
+ jsonPointer,
71
+ ...((0, _apidomDatamodel.isStringElement)(summary) && {
72
+ summary: (0, _apidomCore.toValue)(summary)
73
+ }),
74
+ ...((0, _apidomDatamodel.isStringElement)(description) && {
75
+ description: (0, _apidomCore.toValue)(description)
76
+ })
77
+ };
78
+ });
79
+ }
80
+
49
81
  /**
50
82
  * Resolves a source description name to its canonical URI — precomputed by
51
83
  * the provider, resolved against this document's base URI.
@@ -1,9 +1,16 @@
1
1
  import { toValue } from '@speclynx/apidom-core';
2
+ import { isStringElement } from '@speclynx/apidom-datamodel';
3
+ import { evaluate } from '@speclynx/apidom-json-pointer';
2
4
  import APIDocument from "./APIDocument.mjs";
5
+ /**
6
+ * A workflow of an Arazzo document, as listed by
7
+ * {@link ArazzoDocument.listWorkflows}.
8
+ * @public
9
+ */
3
10
  /**
4
11
  * An Arazzo document held by the document registry: the parse result together
5
12
  * with the indexes the provider built over it — a container, not a logic
6
- * bearer. The methods below are thin reads of the source description index.
13
+ * bearer. The methods below are thin reads of those indexes.
7
14
  * @public
8
15
  */
9
16
  class ArazzoDocument extends APIDocument {
@@ -39,6 +46,30 @@ class ArazzoDocument extends APIDocument {
39
46
  return doc.type === 'arazzo';
40
47
  }
41
48
 
49
+ /**
50
+ * The workflows of this document that can be addressed by `workflowId`, in
51
+ * document order. Reads this document only: source descriptions are neither
52
+ * loaded nor listed.
53
+ */
54
+ listWorkflows() {
55
+ return [...this.workflowIndex].map(([workflowId, jsonPointer]) => {
56
+ const {
57
+ summary,
58
+ description
59
+ } = evaluate(this.parseResult.api, jsonPointer);
60
+ return {
61
+ workflowId,
62
+ jsonPointer,
63
+ ...(isStringElement(summary) && {
64
+ summary: toValue(summary)
65
+ }),
66
+ ...(isStringElement(description) && {
67
+ description: toValue(description)
68
+ })
69
+ };
70
+ });
71
+ }
72
+
42
73
  /**
43
74
  * Resolves a source description name to its canonical URI — precomputed by
44
75
  * the provider, resolved against this document's base URI.
@@ -6,6 +6,56 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
9
- /** @public */
10
- class CriterionError extends _ArazzoRunnerError.default {}
9
+ /**
10
+ * Carries a `reason`, one of the class's static reason fields.
11
+ *
12
+ * Every static on this class is a reason: {@link CriterionErrorReason} is
13
+ * derived from the class's own statics, so a non-reason static would join the
14
+ * union.
15
+ * @public
16
+ */
17
+ class CriterionError extends _ArazzoRunnerError.default {
18
+ /** The element is not a Criterion Object. */
19
+ static InvalidCriterion = 'invalid-criterion';
20
+ /** The `condition` is missing or empty. */
21
+ static MissingCondition = 'missing-condition';
22
+ /** The `type` is present but unreadable. */
23
+ static InvalidType = 'invalid-type';
24
+ /** The `type` names no known criterion type. */
25
+ static UnknownType = 'unknown-type';
26
+ /** The expression type `version` is present but not a string. */
27
+ static InvalidVersion = 'invalid-version';
28
+ /** The expression type `version` is not the one this runner supports. */
29
+ static UnsupportedVersion = 'unsupported-version';
30
+ /** The `context` is not a runtime expression. */
31
+ static InvalidContext = 'invalid-context';
32
+ /** A `regex`, `jsonpath` or `xpath` criterion has no `context`. */
33
+ static MissingContext = 'missing-context';
34
+ /** The `simple` condition cannot be parsed. */
35
+ static InvalidSimple = 'invalid-simple';
36
+ /** The `regex` condition is not a valid regular expression. */
37
+ static InvalidRegex = 'invalid-regex';
38
+ /** The `jsonpath` condition is not a valid JSONPath query. */
39
+ static InvalidJSONPath = 'invalid-jsonpath';
40
+ /** The `xpath` condition is invalid or fails to evaluate. */
41
+ static InvalidXPath = 'invalid-xpath';
42
+ /** The resolved `xpath` context is not XML. */
43
+ static InvalidXPathContext = 'invalid-xpath-context';
44
+ constructor(message, options) {
45
+ super(message, options);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * One of the reasons a {@link CriterionError} carries: a `CriterionError`
51
+ * static such as `CriterionError.InvalidRegex`.
52
+ *
53
+ * Structural reasons mark a criterion that is malformed as written; they are
54
+ * thrown as a plain `CriterionError`. Evaluation reasons (`InvalidSimple`,
55
+ * `InvalidRegex`, `InvalidJSONPath`, `InvalidXPath`, `InvalidXPathContext`) mark
56
+ * a condition that cannot be evaluated; they are thrown as a
57
+ * {@link CriterionEvaluationError}, which `CriterionEvaluator` turns into an
58
+ * unmet criterion.
59
+ * @public
60
+ */
11
61
  var _default = exports.default = CriterionError;
@@ -1,4 +1,55 @@
1
1
  import ArazzoRunnerError from "./ArazzoRunnerError.mjs";
2
- /** @public */
3
- class CriterionError extends ArazzoRunnerError {}
2
+ /**
3
+ * Carries a `reason`, one of the class's static reason fields.
4
+ *
5
+ * Every static on this class is a reason: {@link CriterionErrorReason} is
6
+ * derived from the class's own statics, so a non-reason static would join the
7
+ * union.
8
+ * @public
9
+ */
10
+ class CriterionError extends ArazzoRunnerError {
11
+ /** The element is not a Criterion Object. */
12
+ static InvalidCriterion = 'invalid-criterion';
13
+ /** The `condition` is missing or empty. */
14
+ static MissingCondition = 'missing-condition';
15
+ /** The `type` is present but unreadable. */
16
+ static InvalidType = 'invalid-type';
17
+ /** The `type` names no known criterion type. */
18
+ static UnknownType = 'unknown-type';
19
+ /** The expression type `version` is present but not a string. */
20
+ static InvalidVersion = 'invalid-version';
21
+ /** The expression type `version` is not the one this runner supports. */
22
+ static UnsupportedVersion = 'unsupported-version';
23
+ /** The `context` is not a runtime expression. */
24
+ static InvalidContext = 'invalid-context';
25
+ /** A `regex`, `jsonpath` or `xpath` criterion has no `context`. */
26
+ static MissingContext = 'missing-context';
27
+ /** The `simple` condition cannot be parsed. */
28
+ static InvalidSimple = 'invalid-simple';
29
+ /** The `regex` condition is not a valid regular expression. */
30
+ static InvalidRegex = 'invalid-regex';
31
+ /** The `jsonpath` condition is not a valid JSONPath query. */
32
+ static InvalidJSONPath = 'invalid-jsonpath';
33
+ /** The `xpath` condition is invalid or fails to evaluate. */
34
+ static InvalidXPath = 'invalid-xpath';
35
+ /** The resolved `xpath` context is not XML. */
36
+ static InvalidXPathContext = 'invalid-xpath-context';
37
+ constructor(message, options) {
38
+ super(message, options);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * One of the reasons a {@link CriterionError} carries: a `CriterionError`
44
+ * static such as `CriterionError.InvalidRegex`.
45
+ *
46
+ * Structural reasons mark a criterion that is malformed as written; they are
47
+ * thrown as a plain `CriterionError`. Evaluation reasons (`InvalidSimple`,
48
+ * `InvalidRegex`, `InvalidJSONPath`, `InvalidXPath`, `InvalidXPathContext`) mark
49
+ * a condition that cannot be evaluated; they are thrown as a
50
+ * {@link CriterionEvaluationError}, which `CriterionEvaluator` turns into an
51
+ * unmet criterion.
52
+ * @public
53
+ */
54
+
4
55
  export default CriterionError;