@apidevtools/json-schema-ref-parser 11.7.2 → 11.8.2

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 (46) hide show
  1. package/README.md +4 -8
  2. package/cjs/bundle.js +304 -0
  3. package/cjs/dereference.js +258 -0
  4. package/cjs/index.js +603 -0
  5. package/cjs/normalize-args.js +64 -0
  6. package/cjs/options.js +125 -0
  7. package/cjs/package.json +3 -0
  8. package/cjs/parse.js +338 -0
  9. package/cjs/parsers/binary.js +54 -0
  10. package/cjs/parsers/json.js +199 -0
  11. package/cjs/parsers/text.js +61 -0
  12. package/cjs/parsers/yaml.js +239 -0
  13. package/cjs/pointer.js +290 -0
  14. package/cjs/ref.js +333 -0
  15. package/cjs/refs.js +214 -0
  16. package/cjs/resolve-external.js +333 -0
  17. package/cjs/resolvers/file.js +106 -0
  18. package/cjs/resolvers/http.js +184 -0
  19. package/cjs/util/errors.js +401 -0
  20. package/cjs/util/plugins.js +159 -0
  21. package/cjs/util/projectDir.cjs +6 -0
  22. package/cjs/util/url.js +228 -0
  23. package/dist/lib/bundle.js +17 -7
  24. package/dist/lib/dereference.js +20 -8
  25. package/dist/lib/index.d.ts +6 -6
  26. package/dist/lib/index.js +17 -7
  27. package/dist/lib/options.d.ts +9 -2
  28. package/dist/lib/parse.d.ts +1 -1
  29. package/dist/lib/parse.js +17 -7
  30. package/dist/lib/pointer.js +25 -9
  31. package/dist/lib/refs.js +17 -7
  32. package/dist/lib/resolve-external.js +17 -7
  33. package/dist/lib/resolvers/file.js +17 -7
  34. package/dist/lib/resolvers/http.js +17 -7
  35. package/dist/lib/util/errors.d.ts +6 -2
  36. package/dist/lib/util/errors.js +7 -3
  37. package/dist/lib/util/plugins.d.ts +2 -2
  38. package/dist/lib/util/url.js +20 -9
  39. package/lib/dereference.ts +4 -1
  40. package/lib/index.ts +6 -12
  41. package/lib/options.ts +7 -0
  42. package/lib/pointer.ts +13 -2
  43. package/lib/util/errors.ts +14 -5
  44. package/lib/util/plugins.ts +6 -7
  45. package/lib/util/url.ts +3 -2
  46. package/package.json +31 -31
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ var _ono = require("@jsdevtools/ono");
12
+ var _urlJs = /*#__PURE__*/ _interopRequireWildcard(require("../util/url.js"));
13
+ var _errorsJs = require("../util/errors.js");
14
+ function _getRequireWildcardCache(nodeInterop) {
15
+ if (typeof WeakMap !== "function") return null;
16
+ var cacheBabelInterop = new WeakMap();
17
+ var cacheNodeInterop = new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop) {
19
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interopRequireWildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {};
36
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
+ for(var key in obj){
38
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
+ if (desc && (desc.get || desc.set)) {
41
+ Object.defineProperty(newObj, key, desc);
42
+ } else {
43
+ newObj[key] = obj[key];
44
+ }
45
+ }
46
+ }
47
+ newObj.default = obj;
48
+ if (cache) {
49
+ cache.set(obj, newObj);
50
+ }
51
+ return newObj;
52
+ }
53
+ var _default = {
54
+ /**
55
+ * The order that this resolver will run, in relation to other resolvers.
56
+ *
57
+ * @type {number}
58
+ */ order: 200,
59
+ /**
60
+ * HTTP headers to send when downloading files.
61
+ *
62
+ * @example:
63
+ * {
64
+ * "User-Agent": "JSON Schema $Ref Parser",
65
+ * Accept: "application/json"
66
+ * }
67
+ *
68
+ * @type {object}
69
+ */ headers: null,
70
+ /**
71
+ * HTTP request timeout (in milliseconds).
72
+ *
73
+ * @type {number}
74
+ */ timeout: 5000,
75
+ /**
76
+ * The maximum number of HTTP redirects to follow.
77
+ * To disable automatic following of redirects, set this to zero.
78
+ *
79
+ * @type {number}
80
+ */ redirects: 5,
81
+ /**
82
+ * The `withCredentials` option of XMLHttpRequest.
83
+ * Set this to `true` if you're downloading files from a CORS-enabled server that requires authentication
84
+ *
85
+ * @type {boolean}
86
+ */ withCredentials: false,
87
+ /**
88
+ * Determines whether this resolver can read a given file reference.
89
+ * Resolvers that return true will be tried in order, until one successfully resolves the file.
90
+ * Resolvers that return false will not be given a chance to resolve the file.
91
+ *
92
+ * @param {object} file - An object containing information about the referenced file
93
+ * @param {string} file.url - The full URL of the referenced file
94
+ * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
95
+ * @returns {boolean}
96
+ */ canRead: function canRead(file) {
97
+ return _urlJs.isHttp(file.url);
98
+ },
99
+ /**
100
+ * Reads the given URL and returns its raw contents as a Buffer.
101
+ *
102
+ * @param {object} file - An object containing information about the referenced file
103
+ * @param {string} file.url - The full URL of the referenced file
104
+ * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
105
+ * @returns {Promise<Buffer>}
106
+ */ read: function read(file) {
107
+ var u = _urlJs.parse(file.url);
108
+ if (typeof window !== "undefined" && !u.protocol) {
109
+ // Use the protocol of the current page
110
+ u.protocol = _urlJs.parse(location.href).protocol;
111
+ }
112
+ return download(u, this);
113
+ }
114
+ };
115
+ /**
116
+ * Downloads the given file.
117
+ *
118
+ * @param {Url|string} u - The url to download (can be a parsed {@link Url} object)
119
+ * @param {object} httpOptions - The `options.resolve.http` object
120
+ * @param {number} [redirects] - The redirect URLs that have already been followed
121
+ *
122
+ * @returns {Promise<Buffer>}
123
+ * The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
124
+ */ function download(u, httpOptions, redirects) {
125
+ u = _urlJs.parse(u);
126
+ redirects = redirects || [];
127
+ redirects.push(u.href);
128
+ return get(u, httpOptions).then(function(res) {
129
+ if (res.status >= 400) {
130
+ throw (0, _ono.ono)({
131
+ status: res.statusCode
132
+ }, "HTTP ERROR ".concat(res.status));
133
+ } else if (res.status >= 300) {
134
+ if (redirects.length > httpOptions.redirects) {
135
+ throw new _errorsJs.ResolverError((0, _ono.ono)({
136
+ status: res.status
137
+ }, "Error downloading ".concat(redirects[0], ". \nToo many redirects: \n ").concat(redirects.join(" \n "))));
138
+ } else if (!res.headers.location) {
139
+ throw (0, _ono.ono)({
140
+ status: res.status
141
+ }, "HTTP ".concat(res.status, " redirect with no location header"));
142
+ } else {
143
+ // console.log('HTTP %d redirect %s -> %s', res.status, u.href, res.headers.location);
144
+ var redirectTo = _urlJs.resolve(u, res.headers.location);
145
+ return download(redirectTo, httpOptions, redirects);
146
+ }
147
+ } else {
148
+ return res.body ? res.arrayBuffer().then(function(buf) {
149
+ return Buffer.from(buf);
150
+ }) : Buffer.alloc(0);
151
+ }
152
+ }).catch(function(err) {
153
+ throw new _errorsJs.ResolverError((0, _ono.ono)(err, "Error downloading ".concat(u.href)), u.href);
154
+ });
155
+ }
156
+ /**
157
+ * Sends an HTTP GET request.
158
+ *
159
+ * @param {Url} u - A parsed {@link Url} object
160
+ * @param {object} httpOptions - The `options.resolve.http` object
161
+ *
162
+ * @returns {Promise<Response>}
163
+ * The promise resolves with the HTTP Response object.
164
+ */ function get(u, httpOptions) {
165
+ var controller;
166
+ var timeoutId;
167
+ if (httpOptions.timeout) {
168
+ controller = new AbortController();
169
+ timeoutId = setTimeout(function() {
170
+ return controller.abort();
171
+ }, httpOptions.timeout);
172
+ }
173
+ return fetch(u, {
174
+ method: "GET",
175
+ headers: httpOptions.headers || {},
176
+ credentials: httpOptions.withCredentials ? "include" : "same-origin",
177
+ signal: controller ? controller.signal : null
178
+ }).then(function(response) {
179
+ if (timeoutId) {
180
+ clearTimeout(timeoutId);
181
+ }
182
+ return response;
183
+ });
184
+ }
@@ -0,0 +1,401 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ JSONParserError: function() {
13
+ return JSONParserError;
14
+ },
15
+ JSONParserErrorGroup: function() {
16
+ return JSONParserErrorGroup;
17
+ },
18
+ ParserError: function() {
19
+ return ParserError;
20
+ },
21
+ UnmatchedParserError: function() {
22
+ return UnmatchedParserError;
23
+ },
24
+ ResolverError: function() {
25
+ return ResolverError;
26
+ },
27
+ UnmatchedResolverError: function() {
28
+ return UnmatchedResolverError;
29
+ },
30
+ MissingPointerError: function() {
31
+ return MissingPointerError;
32
+ },
33
+ InvalidPointerError: function() {
34
+ return InvalidPointerError;
35
+ },
36
+ isHandledError: function() {
37
+ return isHandledError;
38
+ },
39
+ normalizeError: function() {
40
+ return normalizeError;
41
+ }
42
+ });
43
+ var _ono = require("@jsdevtools/ono");
44
+ var _urlJs = require("./url.js");
45
+ function _arrayLikeToArray(arr, len) {
46
+ if (len == null || len > arr.length) len = arr.length;
47
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
48
+ return arr2;
49
+ }
50
+ function _arrayWithoutHoles(arr) {
51
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
52
+ }
53
+ function _assertThisInitialized(self) {
54
+ if (self === void 0) {
55
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
56
+ }
57
+ return self;
58
+ }
59
+ function _classCallCheck(instance, Constructor) {
60
+ if (!(instance instanceof Constructor)) {
61
+ throw new TypeError("Cannot call a class as a function");
62
+ }
63
+ }
64
+ function isNativeReflectConstruct() {
65
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
66
+ if (Reflect.construct.sham) return false;
67
+ if (typeof Proxy === "function") return true;
68
+ try {
69
+ Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
70
+ return true;
71
+ } catch (e) {
72
+ return false;
73
+ }
74
+ }
75
+ function _construct(Parent, args, Class) {
76
+ if (isNativeReflectConstruct()) {
77
+ _construct = Reflect.construct;
78
+ } else {
79
+ _construct = function _construct(Parent, args, Class) {
80
+ var a = [
81
+ null
82
+ ];
83
+ a.push.apply(a, args);
84
+ var Constructor = Function.bind.apply(Parent, a);
85
+ var instance = new Constructor();
86
+ if (Class) _setPrototypeOf(instance, Class.prototype);
87
+ return instance;
88
+ };
89
+ }
90
+ return _construct.apply(null, arguments);
91
+ }
92
+ function _defineProperties(target, props) {
93
+ for(var i = 0; i < props.length; i++){
94
+ var descriptor = props[i];
95
+ descriptor.enumerable = descriptor.enumerable || false;
96
+ descriptor.configurable = true;
97
+ if ("value" in descriptor) descriptor.writable = true;
98
+ Object.defineProperty(target, descriptor.key, descriptor);
99
+ }
100
+ }
101
+ function _createClass(Constructor, protoProps, staticProps) {
102
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
103
+ if (staticProps) _defineProperties(Constructor, staticProps);
104
+ return Constructor;
105
+ }
106
+ function _getPrototypeOf(o) {
107
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
108
+ return o.__proto__ || Object.getPrototypeOf(o);
109
+ };
110
+ return _getPrototypeOf(o);
111
+ }
112
+ function _inherits(subClass, superClass) {
113
+ if (typeof superClass !== "function" && superClass !== null) {
114
+ throw new TypeError("Super expression must either be null or a function");
115
+ }
116
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
117
+ constructor: {
118
+ value: subClass,
119
+ writable: true,
120
+ configurable: true
121
+ }
122
+ });
123
+ if (superClass) _setPrototypeOf(subClass, superClass);
124
+ }
125
+ function _instanceof(left, right) {
126
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
127
+ return !!right[Symbol.hasInstance](left);
128
+ } else {
129
+ return left instanceof right;
130
+ }
131
+ }
132
+ function _isNativeFunction(fn) {
133
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
134
+ }
135
+ function _iterableToArray(iter) {
136
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
137
+ }
138
+ function _nonIterableSpread() {
139
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
140
+ }
141
+ function _possibleConstructorReturn(self, call) {
142
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
143
+ return call;
144
+ }
145
+ return _assertThisInitialized(self);
146
+ }
147
+ function _setPrototypeOf(o, p) {
148
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
149
+ o.__proto__ = p;
150
+ return o;
151
+ };
152
+ return _setPrototypeOf(o, p);
153
+ }
154
+ function _toConsumableArray(arr) {
155
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
156
+ }
157
+ var _typeof = function(obj) {
158
+ "@swc/helpers - typeof";
159
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
160
+ };
161
+ function _unsupportedIterableToArray(o, minLen) {
162
+ if (!o) return;
163
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
164
+ var n = Object.prototype.toString.call(o).slice(8, -1);
165
+ if (n === "Object" && o.constructor) n = o.constructor.name;
166
+ if (n === "Map" || n === "Set") return Array.from(n);
167
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
168
+ }
169
+ function _wrapNativeSuper(Class) {
170
+ var _cache = typeof Map === "function" ? new Map() : undefined;
171
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
172
+ if (Class === null || !_isNativeFunction(Class)) return Class;
173
+ if (typeof Class !== "function") {
174
+ throw new TypeError("Super expression must either be null or a function");
175
+ }
176
+ if (typeof _cache !== "undefined") {
177
+ if (_cache.has(Class)) return _cache.get(Class);
178
+ _cache.set(Class, Wrapper);
179
+ }
180
+ function Wrapper() {
181
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
182
+ }
183
+ Wrapper.prototype = Object.create(Class.prototype, {
184
+ constructor: {
185
+ value: Wrapper,
186
+ enumerable: false,
187
+ writable: true,
188
+ configurable: true
189
+ }
190
+ });
191
+ return _setPrototypeOf(Wrapper, Class);
192
+ };
193
+ return _wrapNativeSuper(Class);
194
+ }
195
+ function _isNativeReflectConstruct() {
196
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
197
+ if (Reflect.construct.sham) return false;
198
+ if (typeof Proxy === "function") return true;
199
+ try {
200
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
201
+ return true;
202
+ } catch (e) {
203
+ return false;
204
+ }
205
+ }
206
+ function _createSuper(Derived) {
207
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
208
+ return function _createSuperInternal() {
209
+ var Super = _getPrototypeOf(Derived), result;
210
+ if (hasNativeReflectConstruct) {
211
+ var NewTarget = _getPrototypeOf(this).constructor;
212
+ result = Reflect.construct(Super, arguments, NewTarget);
213
+ } else {
214
+ result = Super.apply(this, arguments);
215
+ }
216
+ return _possibleConstructorReturn(this, result);
217
+ };
218
+ }
219
+ var JSONParserError = /*#__PURE__*/ function(Error1) {
220
+ "use strict";
221
+ _inherits(JSONParserError, Error1);
222
+ var _super = _createSuper(JSONParserError);
223
+ function JSONParserError(message, source) {
224
+ _classCallCheck(this, JSONParserError);
225
+ var _this;
226
+ _this = _super.call(this);
227
+ _this.code = "EUNKNOWN";
228
+ _this.message = message;
229
+ _this.source = source;
230
+ _this.path = null;
231
+ _ono.Ono.extend(_assertThisInitialized(_this));
232
+ return _this;
233
+ }
234
+ _createClass(JSONParserError, [
235
+ {
236
+ key: "footprint",
237
+ get: function get() {
238
+ return "".concat(this.path, "+").concat(this.source, "+").concat(this.code, "+").concat(this.message);
239
+ }
240
+ }
241
+ ]);
242
+ return JSONParserError;
243
+ }(_wrapNativeSuper(Error));
244
+ setErrorName(JSONParserError);
245
+ var JSONParserErrorGroup = /*#__PURE__*/ function(Error1) {
246
+ "use strict";
247
+ _inherits(JSONParserErrorGroup, Error1);
248
+ var _super = _createSuper(JSONParserErrorGroup);
249
+ function JSONParserErrorGroup(parser) {
250
+ _classCallCheck(this, JSONParserErrorGroup);
251
+ var _this;
252
+ _this = _super.call(this);
253
+ _this.files = parser;
254
+ _this.message = "".concat(_this.errors.length, " error").concat(_this.errors.length > 1 ? "s" : "", " occurred while reading '").concat((0, _urlJs.toFileSystemPath)(parser.$refs._root$Ref.path), "'");
255
+ _ono.Ono.extend(_assertThisInitialized(_this));
256
+ return _this;
257
+ }
258
+ _createClass(JSONParserErrorGroup, [
259
+ {
260
+ key: "errors",
261
+ get: function get() {
262
+ return JSONParserErrorGroup.getParserErrors(this.files);
263
+ }
264
+ }
265
+ ], [
266
+ {
267
+ key: "getParserErrors",
268
+ value: function getParserErrors(parser) {
269
+ var errors = [];
270
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
271
+ try {
272
+ for(var _iterator = Object.values(parser.$refs._$refs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
273
+ var $ref = _step.value;
274
+ if ($ref.errors) {
275
+ var _errors;
276
+ (_errors = errors).push.apply(_errors, _toConsumableArray($ref.errors));
277
+ }
278
+ }
279
+ } catch (err) {
280
+ _didIteratorError = true;
281
+ _iteratorError = err;
282
+ } finally{
283
+ try {
284
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
285
+ _iterator.return();
286
+ }
287
+ } finally{
288
+ if (_didIteratorError) {
289
+ throw _iteratorError;
290
+ }
291
+ }
292
+ }
293
+ return errors;
294
+ }
295
+ }
296
+ ]);
297
+ return JSONParserErrorGroup;
298
+ }(_wrapNativeSuper(Error));
299
+ setErrorName(JSONParserErrorGroup);
300
+ var ParserError = /*#__PURE__*/ function(JSONParserError) {
301
+ "use strict";
302
+ _inherits(ParserError, JSONParserError);
303
+ var _super = _createSuper(ParserError);
304
+ function ParserError(message, source) {
305
+ _classCallCheck(this, ParserError);
306
+ var _this;
307
+ _this = _super.call(this, "Error parsing ".concat(source, ": ").concat(message), source);
308
+ _this.code = "EPARSER";
309
+ return _this;
310
+ }
311
+ return ParserError;
312
+ }(JSONParserError);
313
+ setErrorName(ParserError);
314
+ var UnmatchedParserError = /*#__PURE__*/ function(JSONParserError) {
315
+ "use strict";
316
+ _inherits(UnmatchedParserError, JSONParserError);
317
+ var _super = _createSuper(UnmatchedParserError);
318
+ function UnmatchedParserError(source) {
319
+ _classCallCheck(this, UnmatchedParserError);
320
+ var _this;
321
+ _this = _super.call(this, 'Could not find parser for "'.concat(source, '"'), source);
322
+ _this.code = "EUNMATCHEDPARSER";
323
+ return _this;
324
+ }
325
+ return UnmatchedParserError;
326
+ }(JSONParserError);
327
+ setErrorName(UnmatchedParserError);
328
+ var ResolverError = /*#__PURE__*/ function(JSONParserError) {
329
+ "use strict";
330
+ _inherits(ResolverError, JSONParserError);
331
+ var _super = _createSuper(ResolverError);
332
+ function ResolverError(ex, source) {
333
+ _classCallCheck(this, ResolverError);
334
+ var _this;
335
+ _this = _super.call(this, ex.message || 'Error reading file "'.concat(source, '"'), source);
336
+ _this.code = "ERESOLVER";
337
+ if ("code" in ex) {
338
+ _this.ioErrorCode = String(ex.code);
339
+ }
340
+ return _this;
341
+ }
342
+ return ResolverError;
343
+ }(JSONParserError);
344
+ setErrorName(ResolverError);
345
+ var UnmatchedResolverError = /*#__PURE__*/ function(JSONParserError) {
346
+ "use strict";
347
+ _inherits(UnmatchedResolverError, JSONParserError);
348
+ var _super = _createSuper(UnmatchedResolverError);
349
+ function UnmatchedResolverError(source) {
350
+ _classCallCheck(this, UnmatchedResolverError);
351
+ var _this;
352
+ _this = _super.call(this, 'Could not find resolver for "'.concat(source, '"'), source);
353
+ _this.code = "EUNMATCHEDRESOLVER";
354
+ return _this;
355
+ }
356
+ return UnmatchedResolverError;
357
+ }(JSONParserError);
358
+ setErrorName(UnmatchedResolverError);
359
+ var MissingPointerError = /*#__PURE__*/ function(JSONParserError) {
360
+ "use strict";
361
+ _inherits(MissingPointerError, JSONParserError);
362
+ var _super = _createSuper(MissingPointerError);
363
+ function MissingPointerError(token, path) {
364
+ _classCallCheck(this, MissingPointerError);
365
+ var _this;
366
+ _this = _super.call(this, 'Token "'.concat(token, '" does not exist.'), (0, _urlJs.stripHash)(path));
367
+ _this.code = "EMISSINGPOINTER";
368
+ return _this;
369
+ }
370
+ return MissingPointerError;
371
+ }(JSONParserError);
372
+ setErrorName(MissingPointerError);
373
+ var InvalidPointerError = /*#__PURE__*/ function(JSONParserError) {
374
+ "use strict";
375
+ _inherits(InvalidPointerError, JSONParserError);
376
+ var _super = _createSuper(InvalidPointerError);
377
+ function InvalidPointerError(pointer, path) {
378
+ _classCallCheck(this, InvalidPointerError);
379
+ var _this;
380
+ _this = _super.call(this, 'Invalid $ref pointer "'.concat(pointer, '". Pointers must begin with "#/"'), (0, _urlJs.stripHash)(path));
381
+ _this.code = "EINVALIDPOINTER";
382
+ return _this;
383
+ }
384
+ return InvalidPointerError;
385
+ }(JSONParserError);
386
+ setErrorName(InvalidPointerError);
387
+ function setErrorName(err) {
388
+ Object.defineProperty(err.prototype, "name", {
389
+ value: err.name,
390
+ enumerable: true
391
+ });
392
+ }
393
+ function isHandledError(err) {
394
+ return _instanceof(err, JSONParserError) || _instanceof(err, JSONParserErrorGroup);
395
+ }
396
+ function normalizeError(err) {
397
+ if (err.path === null) {
398
+ err.path = [];
399
+ }
400
+ return err;
401
+ }