@apidevtools/json-schema-ref-parser 14.2.0 → 15.0.0
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/README.md +0 -4
- package/dist/lib/bundle.d.ts +3 -3
- package/dist/lib/bundle.js +16 -54
- package/dist/lib/dereference.d.ts +1 -2
- package/dist/lib/dereference.js +12 -50
- package/dist/lib/index.js +42 -95
- package/dist/lib/normalize-args.d.ts +1 -1
- package/dist/lib/normalize-args.js +4 -7
- package/dist/lib/options.d.ts +6 -0
- package/dist/lib/options.js +16 -23
- package/dist/lib/parse.js +11 -46
- package/dist/lib/parsers/binary.js +1 -3
- package/dist/lib/parsers/json.js +4 -6
- package/dist/lib/parsers/text.js +3 -5
- package/dist/lib/parsers/yaml.js +12 -11
- package/dist/lib/pointer.d.ts +3 -2
- package/dist/lib/pointer.js +18 -63
- package/dist/lib/ref.d.ts +5 -3
- package/dist/lib/ref.js +60 -52
- package/dist/lib/refs.d.ts +1 -1
- package/dist/lib/refs.js +7 -46
- package/dist/lib/resolve-external.js +10 -48
- package/dist/lib/resolvers/file.js +7 -45
- package/dist/lib/resolvers/http.js +5 -40
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/index.js +1 -2
- package/dist/lib/util/convert-path-to-posix.js +3 -9
- package/dist/lib/util/errors.d.ts +1 -1
- package/dist/lib/util/errors.js +17 -33
- package/dist/lib/util/is-windows.js +1 -5
- package/dist/lib/util/maybe.js +4 -10
- package/dist/lib/util/next.js +1 -3
- package/dist/lib/util/plugins.js +4 -10
- package/dist/lib/util/url.d.ts +1 -1
- package/dist/lib/util/url.js +40 -88
- package/lib/bundle.ts +12 -9
- package/lib/dereference.ts +3 -4
- package/lib/normalize-args.ts +1 -1
- package/lib/options.ts +8 -0
- package/lib/parsers/yaml.ts +6 -1
- package/lib/pointer.ts +19 -20
- package/lib/ref.ts +55 -5
- package/lib/refs.ts +2 -2
- package/lib/types/index.ts +1 -1
- package/lib/util/errors.ts +2 -2
- package/lib/util/url.ts +13 -7
- package/package.json +21 -20
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const ref_js_1 = __importDefault(require("./ref.js"));
|
|
40
|
-
const pointer_js_1 = __importDefault(require("./pointer.js"));
|
|
41
|
-
const parse_js_1 = __importDefault(require("./parse.js"));
|
|
42
|
-
const url = __importStar(require("./util/url.js"));
|
|
43
|
-
const errors_js_1 = require("./util/errors.js");
|
|
1
|
+
import $Ref from "./ref.js";
|
|
2
|
+
import Pointer from "./pointer.js";
|
|
3
|
+
import parse from "./parse.js";
|
|
4
|
+
import * as url from "./util/url.js";
|
|
5
|
+
import { isHandledError } from "./util/errors.js";
|
|
44
6
|
/**
|
|
45
7
|
* Crawls the JSON schema, finds all external JSON references, and resolves their values.
|
|
46
8
|
* This method does not mutate the JSON schema. The resolved values are added to {@link $RefParser#$refs}.
|
|
@@ -86,12 +48,12 @@ function crawl(obj, path, $refs, options, seen, external) {
|
|
|
86
48
|
let promises = [];
|
|
87
49
|
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !seen.has(obj)) {
|
|
88
50
|
seen.add(obj); // Track previously seen objects to avoid infinite recursion
|
|
89
|
-
if (
|
|
51
|
+
if ($Ref.isExternal$Ref(obj)) {
|
|
90
52
|
promises.push(resolve$Ref(obj, path, $refs, options));
|
|
91
53
|
}
|
|
92
54
|
const keys = Object.keys(obj);
|
|
93
55
|
for (const key of keys) {
|
|
94
|
-
const keyPath =
|
|
56
|
+
const keyPath = Pointer.join(path, key);
|
|
95
57
|
const value = obj[key];
|
|
96
58
|
promises = promises.concat(crawl(value, keyPath, $refs, options, seen, external));
|
|
97
59
|
}
|
|
@@ -123,14 +85,14 @@ async function resolve$Ref($ref, path, $refs, options) {
|
|
|
123
85
|
}
|
|
124
86
|
// Parse the $referenced file/url
|
|
125
87
|
try {
|
|
126
|
-
const result = await (
|
|
88
|
+
const result = await parse(resolvedPath, $refs, options);
|
|
127
89
|
// Crawl the parsed value
|
|
128
90
|
// console.log('Resolving $ref pointers in %s', withoutHash);
|
|
129
91
|
const promises = crawl(result, withoutHash + "#", $refs, options, new Set(), true);
|
|
130
92
|
return Promise.all(promises);
|
|
131
93
|
}
|
|
132
94
|
catch (err) {
|
|
133
|
-
if (!options?.continueOnError || !
|
|
95
|
+
if (!options?.continueOnError || !isHandledError(err)) {
|
|
134
96
|
throw err;
|
|
135
97
|
}
|
|
136
98
|
if ($refs._$refs[withoutHash]) {
|
|
@@ -140,4 +102,4 @@ async function resolve$Ref($ref, path, $refs, options) {
|
|
|
140
102
|
return [];
|
|
141
103
|
}
|
|
142
104
|
}
|
|
143
|
-
|
|
105
|
+
export default resolveExternal;
|
|
@@ -1,45 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const fs_1 = __importDefault(require("fs"));
|
|
40
|
-
const url = __importStar(require("../util/url.js"));
|
|
41
|
-
const errors_js_1 = require("../util/errors.js");
|
|
42
|
-
exports.default = {
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import * as url from "../util/url.js";
|
|
3
|
+
import { ResolverError } from "../util/errors.js";
|
|
4
|
+
export default {
|
|
43
5
|
/**
|
|
44
6
|
* The order that this resolver will run, in relation to other resolvers.
|
|
45
7
|
*/
|
|
@@ -63,19 +25,19 @@ exports.default = {
|
|
|
63
25
|
catch (err) {
|
|
64
26
|
const e = err;
|
|
65
27
|
e.message = `Malformed URI: ${file.url}: ${e.message}`;
|
|
66
|
-
throw new
|
|
28
|
+
throw new ResolverError(e, file.url);
|
|
67
29
|
}
|
|
68
30
|
// strip trailing slashes
|
|
69
31
|
if (path.endsWith("/") || path.endsWith("\\")) {
|
|
70
32
|
path = path.slice(0, -1);
|
|
71
33
|
}
|
|
72
34
|
try {
|
|
73
|
-
return await
|
|
35
|
+
return await fs.promises.readFile(path);
|
|
74
36
|
}
|
|
75
37
|
catch (err) {
|
|
76
38
|
const e = err;
|
|
77
39
|
e.message = `Error opening file ${path}: ${e.message}`;
|
|
78
|
-
throw new
|
|
40
|
+
throw new ResolverError(e, path);
|
|
79
41
|
}
|
|
80
42
|
},
|
|
81
43
|
};
|
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const url = __importStar(require("../util/url.js"));
|
|
37
|
-
const errors_js_1 = require("../util/errors.js");
|
|
38
|
-
exports.default = {
|
|
1
|
+
import * as url from "../util/url.js";
|
|
2
|
+
import { ResolverError } from "../util/errors.js";
|
|
3
|
+
export default {
|
|
39
4
|
/**
|
|
40
5
|
* The order that this resolver will run, in relation to other resolvers.
|
|
41
6
|
*/
|
|
@@ -108,7 +73,7 @@ async function download(u, httpOptions, _redirects) {
|
|
|
108
73
|
if (!Number.isNaN(httpOptions.redirects) && redirects.length > httpOptions.redirects) {
|
|
109
74
|
const error = new Error(`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`);
|
|
110
75
|
error.status = res.status;
|
|
111
|
-
throw new
|
|
76
|
+
throw new ResolverError(error);
|
|
112
77
|
}
|
|
113
78
|
else if (!("location" in res.headers) || !res.headers.location) {
|
|
114
79
|
const error = new Error(`HTTP ${res.status} redirect with no location header`);
|
|
@@ -131,7 +96,7 @@ async function download(u, httpOptions, _redirects) {
|
|
|
131
96
|
catch (err) {
|
|
132
97
|
const e = err;
|
|
133
98
|
e.message = `Error downloading ${u.href}: ${e.message}`;
|
|
134
|
-
throw new
|
|
99
|
+
throw new ResolverError(e, u.href);
|
|
135
100
|
}
|
|
136
101
|
}
|
|
137
102
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSONSchema4, JSONSchema4Object, JSONSchema6, JSONSchema6Object, JSONSchema7, JSONSchema7Object } from "json-schema";
|
|
2
2
|
import type $Refs from "../refs.js";
|
|
3
|
-
import type { ParserOptions } from "../options";
|
|
3
|
+
import type { ParserOptions } from "../options.js";
|
|
4
4
|
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
5
5
|
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
|
|
6
6
|
export type SchemaCallback<S extends object = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
package/dist/lib/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = convertPathToPosix;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
function convertPathToPosix(filePath) {
|
|
1
|
+
import path from "path";
|
|
2
|
+
export default function convertPathToPosix(filePath) {
|
|
9
3
|
const isExtendedLengthPath = filePath.startsWith("\\\\?\\");
|
|
10
4
|
if (isExtendedLengthPath) {
|
|
11
5
|
return filePath;
|
|
12
6
|
}
|
|
13
|
-
return filePath.split(
|
|
7
|
+
return filePath.split(path?.win32?.sep).join(path?.posix?.sep ?? "/");
|
|
14
8
|
}
|
|
@@ -69,5 +69,5 @@ export declare class InvalidPointerError extends JSONParserError {
|
|
|
69
69
|
name: string;
|
|
70
70
|
constructor(pointer: string, path: string);
|
|
71
71
|
}
|
|
72
|
-
export declare function isHandledError(err:
|
|
72
|
+
export declare function isHandledError(err: unknown): err is JSONParserError;
|
|
73
73
|
export declare function normalizeError(err: any): any;
|
package/dist/lib/util/errors.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidPointerError = exports.TimeoutError = exports.MissingPointerError = exports.UnmatchedResolverError = exports.ResolverError = exports.UnmatchedParserError = exports.ParserError = exports.JSONParserErrorGroup = exports.JSONParserError = void 0;
|
|
4
|
-
exports.toJSON = toJSON;
|
|
5
|
-
exports.getDeepKeys = getDeepKeys;
|
|
6
|
-
exports.isHandledError = isHandledError;
|
|
7
|
-
exports.normalizeError = normalizeError;
|
|
8
|
-
const url_js_1 = require("./url.js");
|
|
1
|
+
import { getHash, stripHash, toFileSystemPath } from "./url.js";
|
|
9
2
|
const nonJsonTypes = ["function", "symbol", "undefined"];
|
|
10
3
|
const protectedProps = ["constructor", "prototype", "__proto__"];
|
|
11
4
|
const objectPrototype = Object.getPrototypeOf({});
|
|
@@ -13,7 +6,7 @@ const objectPrototype = Object.getPrototypeOf({});
|
|
|
13
6
|
* Custom JSON serializer for Error objects.
|
|
14
7
|
* Returns all built-in error properties, as well as extended properties.
|
|
15
8
|
*/
|
|
16
|
-
function toJSON() {
|
|
9
|
+
export function toJSON() {
|
|
17
10
|
// HACK: We have to cast the objects to `any` so we can use symbol indexers.
|
|
18
11
|
// see https://github.com/Microsoft/TypeScript/issues/1863
|
|
19
12
|
const pojo = {};
|
|
@@ -33,7 +26,7 @@ function toJSON() {
|
|
|
33
26
|
* Returns own, inherited, enumerable, non-enumerable, string, and symbol keys of `obj`.
|
|
34
27
|
* Does NOT return members of the base Object prototype, or the specified omitted keys.
|
|
35
28
|
*/
|
|
36
|
-
function getDeepKeys(obj, omit = []) {
|
|
29
|
+
export function getDeepKeys(obj, omit = []) {
|
|
37
30
|
let keys = [];
|
|
38
31
|
// Crawl the prototype chain, finding all the string and symbol keys
|
|
39
32
|
while (obj && obj !== objectPrototype) {
|
|
@@ -48,7 +41,7 @@ function getDeepKeys(obj, omit = []) {
|
|
|
48
41
|
}
|
|
49
42
|
return uniqueKeys;
|
|
50
43
|
}
|
|
51
|
-
class JSONParserError extends Error {
|
|
44
|
+
export class JSONParserError extends Error {
|
|
52
45
|
name;
|
|
53
46
|
message;
|
|
54
47
|
source;
|
|
@@ -67,14 +60,13 @@ class JSONParserError extends Error {
|
|
|
67
60
|
return `${this.path}+${this.source}+${this.code}+${this.message}`;
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
|
-
|
|
71
|
-
class JSONParserErrorGroup extends Error {
|
|
63
|
+
export class JSONParserErrorGroup extends Error {
|
|
72
64
|
files;
|
|
73
65
|
constructor(parser) {
|
|
74
66
|
super();
|
|
75
67
|
this.files = parser;
|
|
76
68
|
this.name = "JSONParserErrorGroup";
|
|
77
|
-
this.message = `${this.errors.length} error${this.errors.length > 1 ? "s" : ""} occurred while reading '${
|
|
69
|
+
this.message = `${this.errors.length} error${this.errors.length > 1 ? "s" : ""} occurred while reading '${toFileSystemPath(parser.$refs._root$Ref.path)}'`;
|
|
78
70
|
}
|
|
79
71
|
toJSON = toJSON.bind(this);
|
|
80
72
|
static getParserErrors(parser) {
|
|
@@ -90,24 +82,21 @@ class JSONParserErrorGroup extends Error {
|
|
|
90
82
|
return JSONParserErrorGroup.getParserErrors(this.files);
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
class ParserError extends JSONParserError {
|
|
85
|
+
export class ParserError extends JSONParserError {
|
|
95
86
|
code = "EPARSER";
|
|
96
87
|
name = "ParserError";
|
|
97
88
|
constructor(message, source) {
|
|
98
89
|
super(`Error parsing ${source}: ${message}`, source);
|
|
99
90
|
}
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
class UnmatchedParserError extends JSONParserError {
|
|
92
|
+
export class UnmatchedParserError extends JSONParserError {
|
|
103
93
|
code = "EUNMATCHEDPARSER";
|
|
104
94
|
name = "UnmatchedParserError";
|
|
105
95
|
constructor(source) {
|
|
106
96
|
super(`Could not find parser for "${source}"`, source);
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
|
-
|
|
110
|
-
class ResolverError extends JSONParserError {
|
|
99
|
+
export class ResolverError extends JSONParserError {
|
|
111
100
|
code = "ERESOLVER";
|
|
112
101
|
name = "ResolverError";
|
|
113
102
|
ioErrorCode;
|
|
@@ -118,16 +107,14 @@ class ResolverError extends JSONParserError {
|
|
|
118
107
|
}
|
|
119
108
|
}
|
|
120
109
|
}
|
|
121
|
-
|
|
122
|
-
class UnmatchedResolverError extends JSONParserError {
|
|
110
|
+
export class UnmatchedResolverError extends JSONParserError {
|
|
123
111
|
code = "EUNMATCHEDRESOLVER";
|
|
124
112
|
name = "UnmatchedResolverError";
|
|
125
113
|
constructor(source) {
|
|
126
114
|
super(`Could not find resolver for "${source}"`, source);
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
|
-
|
|
130
|
-
class MissingPointerError extends JSONParserError {
|
|
117
|
+
export class MissingPointerError extends JSONParserError {
|
|
131
118
|
code = "EMISSINGPOINTER";
|
|
132
119
|
name = "MissingPointerError";
|
|
133
120
|
targetToken;
|
|
@@ -135,34 +122,31 @@ class MissingPointerError extends JSONParserError {
|
|
|
135
122
|
targetFound;
|
|
136
123
|
parentPath;
|
|
137
124
|
constructor(token, path, targetRef, targetFound, parentPath) {
|
|
138
|
-
super(`Missing $ref pointer "${
|
|
125
|
+
super(`Missing $ref pointer "${getHash(path)}". Token "${token}" does not exist.`, stripHash(path));
|
|
139
126
|
this.targetToken = token;
|
|
140
127
|
this.targetRef = targetRef;
|
|
141
128
|
this.targetFound = targetFound;
|
|
142
129
|
this.parentPath = parentPath;
|
|
143
130
|
}
|
|
144
131
|
}
|
|
145
|
-
|
|
146
|
-
class TimeoutError extends JSONParserError {
|
|
132
|
+
export class TimeoutError extends JSONParserError {
|
|
147
133
|
code = "ETIMEOUT";
|
|
148
134
|
name = "TimeoutError";
|
|
149
135
|
constructor(timeout) {
|
|
150
136
|
super(`Dereferencing timeout reached: ${timeout}ms`);
|
|
151
137
|
}
|
|
152
138
|
}
|
|
153
|
-
|
|
154
|
-
class InvalidPointerError extends JSONParserError {
|
|
139
|
+
export class InvalidPointerError extends JSONParserError {
|
|
155
140
|
code = "EUNMATCHEDRESOLVER";
|
|
156
141
|
name = "InvalidPointerError";
|
|
157
142
|
constructor(pointer, path) {
|
|
158
|
-
super(`Invalid $ref pointer "${pointer}". Pointers must begin with "#/"`,
|
|
143
|
+
super(`Invalid $ref pointer "${pointer}". Pointers must begin with "#/"`, stripHash(path));
|
|
159
144
|
}
|
|
160
145
|
}
|
|
161
|
-
|
|
162
|
-
function isHandledError(err) {
|
|
146
|
+
export function isHandledError(err) {
|
|
163
147
|
return err instanceof JSONParserError || err instanceof JSONParserErrorGroup;
|
|
164
148
|
}
|
|
165
|
-
function normalizeError(err) {
|
|
149
|
+
export function normalizeError(err) {
|
|
166
150
|
if (err.path === null) {
|
|
167
151
|
err.path = [];
|
|
168
152
|
}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isWindows = void 0;
|
|
4
1
|
const isWindowsConst = /^win/.test(globalThis.process ? globalThis.process.platform : "");
|
|
5
|
-
const isWindows = () => isWindowsConst;
|
|
6
|
-
exports.isWindows = isWindows;
|
|
2
|
+
export const isWindows = () => isWindowsConst;
|
package/dist/lib/util/maybe.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = maybe;
|
|
7
|
-
const next_js_1 = __importDefault(require("./next.js"));
|
|
8
|
-
function maybe(cb, promise) {
|
|
1
|
+
import next from "./next.js";
|
|
2
|
+
export default function maybe(cb, promise) {
|
|
9
3
|
if (cb) {
|
|
10
4
|
promise.then(function (result) {
|
|
11
|
-
(
|
|
5
|
+
next(function () {
|
|
12
6
|
cb(null, result);
|
|
13
7
|
});
|
|
14
8
|
}, function (err) {
|
|
15
|
-
(
|
|
9
|
+
next(function () {
|
|
16
10
|
cb(err);
|
|
17
11
|
});
|
|
18
12
|
});
|
package/dist/lib/util/next.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
function makeNext() {
|
|
4
2
|
if (typeof process === "object" && typeof process.nextTick === "function") {
|
|
5
3
|
return process.nextTick;
|
|
@@ -13,4 +11,4 @@ function makeNext() {
|
|
|
13
11
|
};
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
export default makeNext();
|
package/dist/lib/util/plugins.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.all = all;
|
|
4
|
-
exports.filter = filter;
|
|
5
|
-
exports.sort = sort;
|
|
6
|
-
exports.run = run;
|
|
7
1
|
/**
|
|
8
2
|
* Returns the given plugins as an array, rather than an object map.
|
|
9
3
|
* All other methods in this module expect an array of plugins rather than an object map.
|
|
10
4
|
*
|
|
11
5
|
* @returns
|
|
12
6
|
*/
|
|
13
|
-
function all(plugins) {
|
|
7
|
+
export function all(plugins) {
|
|
14
8
|
return Object.keys(plugins || {})
|
|
15
9
|
.filter((key) => {
|
|
16
10
|
return typeof plugins[key] === "object";
|
|
@@ -23,7 +17,7 @@ function all(plugins) {
|
|
|
23
17
|
/**
|
|
24
18
|
* Filters the given plugins, returning only the ones return `true` for the given method.
|
|
25
19
|
*/
|
|
26
|
-
function filter(plugins, method, file) {
|
|
20
|
+
export function filter(plugins, method, file) {
|
|
27
21
|
return plugins.filter((plugin) => {
|
|
28
22
|
return !!getResult(plugin, method, file);
|
|
29
23
|
});
|
|
@@ -31,7 +25,7 @@ function filter(plugins, method, file) {
|
|
|
31
25
|
/**
|
|
32
26
|
* Sorts the given plugins, in place, by their `order` property.
|
|
33
27
|
*/
|
|
34
|
-
function sort(plugins) {
|
|
28
|
+
export function sort(plugins) {
|
|
35
29
|
for (const plugin of plugins) {
|
|
36
30
|
plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
|
|
37
31
|
}
|
|
@@ -47,7 +41,7 @@ function sort(plugins) {
|
|
|
47
41
|
* If the promise rejects, or the callback is called with an error, then the next plugin is called.
|
|
48
42
|
* If ALL plugins fail, then the last error is thrown.
|
|
49
43
|
*/
|
|
50
|
-
async function run(plugins, method, file, $refs) {
|
|
44
|
+
export async function run(plugins, method, file, $refs) {
|
|
51
45
|
let plugin;
|
|
52
46
|
let lastError;
|
|
53
47
|
let index = 0;
|
package/dist/lib/util/url.d.ts
CHANGED
|
@@ -97,5 +97,5 @@ export declare function toFileSystemPath(path: string | undefined, keepFileProto
|
|
|
97
97
|
* @param pointer
|
|
98
98
|
* @returns
|
|
99
99
|
*/
|
|
100
|
-
export declare function safePointerToPath(pointer:
|
|
100
|
+
export declare function safePointerToPath(pointer: string): string[];
|
|
101
101
|
export declare function relative(from: string, to: string): string;
|