@usearazzo/runner 1.0.1-alpha.17 → 1.0.1-alpha.19

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.17",
3
+ "version": "1.0.1-alpha.19",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -57,24 +57,24 @@
57
57
  "license": "Apache-2.0",
58
58
  "dependencies": {
59
59
  "@babel/runtime-corejs3": "^8.0.8",
60
- "@speclynx/apidom-core": "^6.1.0",
61
- "@speclynx/apidom-datamodel": "^6.1.0",
62
- "@speclynx/apidom-error": "^6.1.0",
63
- "@speclynx/apidom-json-pointer": "^6.1.0",
64
- "@speclynx/apidom-ns-arazzo-1": "^6.1.0",
65
- "@speclynx/apidom-ns-openapi-2": "^6.1.0",
66
- "@speclynx/apidom-ns-openapi-3-0": "^6.1.0",
67
- "@speclynx/apidom-ns-openapi-3-1": "^6.1.0",
68
- "@speclynx/apidom-reference": "^6.1.0",
69
- "@speclynx/apidom-traverse": "^6.1.0",
60
+ "@speclynx/apidom-core": "^6.1.2",
61
+ "@speclynx/apidom-datamodel": "^6.1.2",
62
+ "@speclynx/apidom-error": "^6.1.2",
63
+ "@speclynx/apidom-json-pointer": "^6.1.2",
64
+ "@speclynx/apidom-ns-arazzo-1": "^6.1.2",
65
+ "@speclynx/apidom-ns-openapi-2": "^6.1.2",
66
+ "@speclynx/apidom-ns-openapi-3-0": "^6.1.2",
67
+ "@speclynx/apidom-ns-openapi-3-1": "^6.1.2",
68
+ "@speclynx/apidom-reference": "^6.1.2",
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
72
  "@swaggerexpert/cookie": "^2.0.2",
73
73
  "@swaggerexpert/json-pointer": "^3.0.2",
74
74
  "@swaggerexpert/jsonpath": "^4.0.5",
75
- "@swaggerexpert/media-types": "^1.0.1",
76
- "@usearazzo/parser": "1.0.1-alpha.17",
77
- "@usearazzo/resolver": "1.0.1-alpha.17",
75
+ "@swaggerexpert/media-types": "^1.0.2",
76
+ "@usearazzo/parser": "1.0.1-alpha.19",
77
+ "@usearazzo/resolver": "1.0.1-alpha.19",
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": "92ccbcd1dff00a1744e6c0543db9d17ee5a91ef2"
97
+ "gitHead": "54a9b81c5607984c87d82ec159506f522b33a4d7"
98
98
  }
@@ -45,6 +45,7 @@ class ArazzoRunner {
45
45
  * Loads the entry Arazzo document at `uri` (a file system path or URL) and
46
46
  * returns a runner bound to it.
47
47
  *
48
+ * @throws DocumentLoadError - When the document cannot be read or loaded
48
49
  * @throws UnmatchedProviderError - When no provider can load the document
49
50
  * @throws InvalidEntryDocumentError - When the document is not an Arazzo
50
51
  * document, or the given registry already backs another entry document
@@ -36,6 +36,7 @@ class ArazzoRunner {
36
36
  * Loads the entry Arazzo document at `uri` (a file system path or URL) and
37
37
  * returns a runner bound to it.
38
38
  *
39
+ * @throws DocumentLoadError - When the document cannot be read or loaded
39
40
  * @throws UnmatchedProviderError - When no provider can load the document
40
41
  * @throws InvalidEntryDocumentError - When the document is not an Arazzo
41
42
  * document, or the given registry already backs another entry document
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _ArazzoRunnerError = _interopRequireDefault(require("./ArazzoRunnerError.cjs"));
9
+ /** @public */
10
+ class DocumentLoadError extends _ArazzoRunnerError.default {}
11
+ var _default = exports.default = DocumentLoadError;
@@ -0,0 +1,4 @@
1
+ import ArazzoRunnerError from "./ArazzoRunnerError.mjs";
2
+ /** @public */
3
+ class DocumentLoadError extends ArazzoRunnerError {}
4
+ export default DocumentLoadError;
package/src/index.cjs CHANGED
@@ -119,6 +119,12 @@ Object.defineProperty(exports, "CriterionEvaluator", {
119
119
  return _CriterionEvaluator.default;
120
120
  }
121
121
  });
122
+ Object.defineProperty(exports, "DocumentLoadError", {
123
+ enumerable: true,
124
+ get: function () {
125
+ return _DocumentLoadError.default;
126
+ }
127
+ });
122
128
  Object.defineProperty(exports, "DocumentRegistry", {
123
129
  enumerable: true,
124
130
  get: function () {
@@ -420,6 +426,7 @@ var _NormalizationError = _interopRequireDefault(require("./errors/Normalization
420
426
  var _ExtractionError = _interopRequireDefault(require("./errors/ExtractionError.cjs"));
421
427
  var _InvalidEntryDocumentError = _interopRequireDefault(require("./errors/InvalidEntryDocumentError.cjs"));
422
428
  var _UnmatchedProviderError = _interopRequireDefault(require("./errors/UnmatchedProviderError.cjs"));
429
+ var _DocumentLoadError = _interopRequireDefault(require("./errors/DocumentLoadError.cjs"));
423
430
  var _RuntimeExpressionError = _interopRequireDefault(require("./errors/RuntimeExpressionError.cjs"));
424
431
  var _CriterionError = _interopRequireDefault(require("./errors/CriterionError.cjs"));
425
432
  var _ResolverError = _interopRequireDefault(require("./errors/ResolverError.cjs"));
package/src/index.mjs CHANGED
@@ -69,6 +69,7 @@ export { default as NormalizationError } from "./errors/NormalizationError.mjs";
69
69
  export { default as ExtractionError } from "./errors/ExtractionError.mjs";
70
70
  export { default as InvalidEntryDocumentError } from "./errors/InvalidEntryDocumentError.mjs";
71
71
  export { default as UnmatchedProviderError } from "./errors/UnmatchedProviderError.mjs";
72
+ export { default as DocumentLoadError } from "./errors/DocumentLoadError.mjs";
72
73
  export { default as RuntimeExpressionError } from "./errors/RuntimeExpressionError.mjs";
73
74
  export { default as CriterionError } from "./errors/CriterionError.mjs";
74
75
  export { default as ResolverError } from "./errors/ResolverError.mjs";
@@ -10,6 +10,8 @@ var _empty = require("@speclynx/apidom-reference/configuration/empty");
10
10
  var _ArazzoDocument = _interopRequireDefault(require("../document/ArazzoDocument.cjs"));
11
11
  var _ArazzoDocumentRegistryProvider = _interopRequireDefault(require("./providers/ArazzoDocumentRegistryProvider.cjs"));
12
12
  var _OpenAPIDocumentRegistryProvider = _interopRequireDefault(require("./providers/OpenAPIDocumentRegistryProvider.cjs"));
13
+ var _ArazzoRunnerError = _interopRequireDefault(require("../errors/ArazzoRunnerError.cjs"));
14
+ var _DocumentLoadError = _interopRequireDefault(require("../errors/DocumentLoadError.cjs"));
13
15
  var _InvalidEntryDocumentError = _interopRequireDefault(require("../errors/InvalidEntryDocumentError.cjs"));
14
16
  var _UnmatchedProviderError = _interopRequireDefault(require("../errors/UnmatchedProviderError.cjs"));
15
17
  var constants = _interopRequireWildcard(require("../constants.cjs"));
@@ -49,16 +51,29 @@ class DocumentRegistry {
49
51
  * Acquires a document by URI. Returns cached document if available,
50
52
  * otherwise detects the format, loads via the matching provider,
51
53
  * caches, and returns it.
54
+ *
55
+ * @throws DocumentLoadError - When the document cannot be read or loaded
56
+ * @throws UnmatchedProviderError - When no provider can load the document
52
57
  */
53
58
  async acquire(uri) {
54
59
  const canonicalURI = this.#canonicalize(uri);
55
60
  const cachedDocument = this.#get(canonicalURI);
56
61
  if (cachedDocument) return cachedDocument;
57
62
  for (const provider of this.#providers) {
58
- if (await provider.canProvide(canonicalURI)) {
59
- const document = await provider.provide(canonicalURI);
60
- this.#set(canonicalURI, document);
61
- return document;
63
+ try {
64
+ if (await provider.canProvide(canonicalURI)) {
65
+ const document = await provider.provide(canonicalURI);
66
+ this.#set(canonicalURI, document);
67
+ return document;
68
+ }
69
+ } catch (error) {
70
+ // a document that cannot be read or loaded fails in ApiDOM or the parser;
71
+ // wrapping it keeps every load failure inside the runner's error hierarchy.
72
+ if (error instanceof _ArazzoRunnerError.default) throw error;
73
+ throw new _DocumentLoadError.default(`Failed to load the document at "${canonicalURI}"`, {
74
+ uri: canonicalURI,
75
+ cause: error
76
+ });
62
77
  }
63
78
  }
64
79
  throw new _UnmatchedProviderError.default(`No provider can handle the document at "${canonicalURI}"`, {
@@ -97,6 +112,10 @@ class DocumentRegistry {
97
112
  /**
98
113
  * Acquires the entry Arazzo document and marks it with `isEntry: true`.
99
114
  * Validates that the document is an Arazzo specification.
115
+ *
116
+ * @throws DocumentLoadError - When the document cannot be read or loaded
117
+ * @throws UnmatchedProviderError - When no provider can load the document
118
+ * @throws InvalidEntryDocumentError - When the document is not an Arazzo document
100
119
  */
101
120
  async acquireEntryDocument(uri) {
102
121
  const document = await this.acquire(uri);
@@ -2,6 +2,8 @@ import { url } from '@speclynx/apidom-reference/configuration/empty';
2
2
  import ArazzoDocument from "../document/ArazzoDocument.mjs";
3
3
  import ArazzoDocumentRegistryProvider from "./providers/ArazzoDocumentRegistryProvider.mjs";
4
4
  import OpenAPIDocumentRegistryProvider from "./providers/OpenAPIDocumentRegistryProvider.mjs";
5
+ import ArazzoRunnerError from "../errors/ArazzoRunnerError.mjs";
6
+ import DocumentLoadError from "../errors/DocumentLoadError.mjs";
5
7
  import InvalidEntryDocumentError from "../errors/InvalidEntryDocumentError.mjs";
6
8
  import UnmatchedProviderError from "../errors/UnmatchedProviderError.mjs";
7
9
  import * as constants from "../constants.mjs";
@@ -40,16 +42,29 @@ class DocumentRegistry {
40
42
  * Acquires a document by URI. Returns cached document if available,
41
43
  * otherwise detects the format, loads via the matching provider,
42
44
  * caches, and returns it.
45
+ *
46
+ * @throws DocumentLoadError - When the document cannot be read or loaded
47
+ * @throws UnmatchedProviderError - When no provider can load the document
43
48
  */
44
49
  async acquire(uri) {
45
50
  const canonicalURI = this.#canonicalize(uri);
46
51
  const cachedDocument = this.#get(canonicalURI);
47
52
  if (cachedDocument) return cachedDocument;
48
53
  for (const provider of this.#providers) {
49
- if (await provider.canProvide(canonicalURI)) {
50
- const document = await provider.provide(canonicalURI);
51
- this.#set(canonicalURI, document);
52
- return document;
54
+ try {
55
+ if (await provider.canProvide(canonicalURI)) {
56
+ const document = await provider.provide(canonicalURI);
57
+ this.#set(canonicalURI, document);
58
+ return document;
59
+ }
60
+ } catch (error) {
61
+ // a document that cannot be read or loaded fails in ApiDOM or the parser;
62
+ // wrapping it keeps every load failure inside the runner's error hierarchy.
63
+ if (error instanceof ArazzoRunnerError) throw error;
64
+ throw new DocumentLoadError(`Failed to load the document at "${canonicalURI}"`, {
65
+ uri: canonicalURI,
66
+ cause: error
67
+ });
53
68
  }
54
69
  }
55
70
  throw new UnmatchedProviderError(`No provider can handle the document at "${canonicalURI}"`, {
@@ -88,6 +103,10 @@ class DocumentRegistry {
88
103
  /**
89
104
  * Acquires the entry Arazzo document and marks it with `isEntry: true`.
90
105
  * Validates that the document is an Arazzo specification.
106
+ *
107
+ * @throws DocumentLoadError - When the document cannot be read or loaded
108
+ * @throws UnmatchedProviderError - When no provider can load the document
109
+ * @throws InvalidEntryDocumentError - When the document is not an Arazzo document
91
110
  */
92
111
  async acquireEntryDocument(uri) {
93
112
  const document = await this.acquire(uri);