@json-schema-tools/reference-resolver 1.2.4 → 1.2.5
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 +3 -4
- package/build/default-protocol-handler-map.js +2 -2
- package/build/errors.js +5 -5
- package/build/index.js +6 -2
- package/build/reference-resolver.js +3 -4
- package/build/resolve-pointer.js +1 -1
- package/package.json +17 -14
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<span>
|
|
5
5
|
<img alt="CircleCI branch" src="https://img.shields.io/circleci/project/github/json-schema-tools/reference-resolver/master.svg">
|
|
6
6
|
<img src="https://codecov.io/gh/json-schema-tools/reference-resolver/branch/master/graph/badge.svg" />
|
|
7
|
-
<img alt="Dependabot status" src="https://api.dependabot.com/badges/status?host=github&repo=json-schema-tools/reference-resolver" />
|
|
8
7
|
<img alt="npm" src="https://img.shields.io/npm/dt/@json-schema-tools/reference-resolver.svg" />
|
|
9
8
|
<img alt="GitHub release" src="https://img.shields.io/github/release/json-schema-tools/reference-resolver.svg" />
|
|
10
9
|
<img alt="GitHub commits since latest release" src="https://img.shields.io/github/commits-since/json-schema-tools/reference-resolver/latest.svg" />
|
|
@@ -37,15 +36,15 @@ import JSONSchema from "@json-schema-tools/meta-schema";
|
|
|
37
36
|
|
|
38
37
|
referenceResolver.protocolHandlerMap.ipfs = (uri) => {
|
|
39
38
|
const pretendItsFetchedFromIpfs = {
|
|
40
|
-
title: "foo",
|
|
39
|
+
title: "foo",
|
|
41
40
|
type: "string",
|
|
42
41
|
} as JSONSchema;
|
|
43
42
|
return Promise.resolve(fetchedFromIpfs);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
referenceResolver.protocolHandlerMap["customprotocol"] = (uri) => {
|
|
47
|
-
return Promise.resolve({
|
|
48
|
-
type: "string",
|
|
46
|
+
return Promise.resolve({
|
|
47
|
+
type: "string",
|
|
49
48
|
title: uri.replace("customprotocol://", ""),
|
|
50
49
|
});
|
|
51
50
|
};
|
|
@@ -41,13 +41,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var errors_1 = require("./errors");
|
|
43
43
|
var isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));
|
|
44
|
-
var fetchHandler = function (uri
|
|
44
|
+
var fetchHandler = function (uri) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
45
|
var schemaReq, e_1, e_2;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
47
|
switch (_a.label) {
|
|
48
48
|
case 0:
|
|
49
49
|
_a.trys.push([0, 2, , 3]);
|
|
50
|
-
return [4 /*yield*/, isomorphic_fetch_1.default(uri)];
|
|
50
|
+
return [4 /*yield*/, (0, isomorphic_fetch_1.default)(uri)];
|
|
51
51
|
case 1:
|
|
52
52
|
schemaReq = _a.sent();
|
|
53
53
|
return [3 /*break*/, 3];
|
package/build/errors.js
CHANGED
|
@@ -22,8 +22,8 @@ var NonJsonRefError = /** @class */ (function () {
|
|
|
22
22
|
this.name = "NonJsonRefError";
|
|
23
23
|
this.message = [
|
|
24
24
|
"NonJsonRefError",
|
|
25
|
-
"The resolved value at the reference: "
|
|
26
|
-
"The non-json content in question: "
|
|
25
|
+
"The resolved value at the reference: ".concat(obj.$ref, " was not JSON.parse 'able"),
|
|
26
|
+
"The non-json content in question: ".concat(nonJson),
|
|
27
27
|
].join("\n");
|
|
28
28
|
}
|
|
29
29
|
return NonJsonRefError;
|
|
@@ -34,7 +34,7 @@ var NotResolvableError = /** @class */ (function () {
|
|
|
34
34
|
this.name = "NotResolvableError";
|
|
35
35
|
this.message = [
|
|
36
36
|
"NotResolvableError",
|
|
37
|
-
"Could not resolve the reference: "
|
|
37
|
+
"Could not resolve the reference: ".concat(ref),
|
|
38
38
|
"No protocol handler was found, and it was not found to be an internal reference",
|
|
39
39
|
].join("\n");
|
|
40
40
|
}
|
|
@@ -50,7 +50,7 @@ var InvalidRemoteURLError = /** @class */ (function () {
|
|
|
50
50
|
this.name = "InvalidRemoteURLError";
|
|
51
51
|
this.message = [
|
|
52
52
|
"InvalidRemoteURLError",
|
|
53
|
-
"The url was not resolvable: "
|
|
53
|
+
"The url was not resolvable: ".concat(ref),
|
|
54
54
|
].join("\n");
|
|
55
55
|
}
|
|
56
56
|
return InvalidRemoteURLError;
|
|
@@ -76,7 +76,7 @@ var InvalidFileSystemPathError = /** @class */ (function () {
|
|
|
76
76
|
this.name = "InvalidFileSystemPathError";
|
|
77
77
|
this.message = [
|
|
78
78
|
"InvalidFileSystemPathError",
|
|
79
|
-
"The path was not resolvable: "
|
|
79
|
+
"The path was not resolvable: ".concat(ref),
|
|
80
80
|
].join("\n");
|
|
81
81
|
}
|
|
82
82
|
return InvalidFileSystemPathError;
|
package/build/index.js
CHANGED
|
@@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
14
|
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
16
20
|
}) : (function(o, m, k, k2) {
|
|
17
21
|
if (k2 === undefined) k2 = k;
|
|
18
22
|
o[k2] = m[k];
|
|
@@ -101,7 +105,7 @@ var nodeProtocolHandlerMap = __assign(__assign({}, default_protocol_handler_map_
|
|
|
101
105
|
_b.label = 2;
|
|
102
106
|
case 2:
|
|
103
107
|
if (_a)
|
|
104
|
-
filePath = path_1.default.parse(ref).dir
|
|
108
|
+
filePath = "".concat(path_1.default.parse(ref).dir, "/").concat(uri);
|
|
105
109
|
return [4 /*yield*/, fileExistsAndReadable(filePath)];
|
|
106
110
|
case 3:
|
|
107
111
|
if (!((_b.sent()) === true)) return [3 /*break*/, 5];
|
|
@@ -44,7 +44,6 @@ var resolve_pointer_1 = __importDefault(require("./resolve-pointer"));
|
|
|
44
44
|
var isUrlLike = function (s) {
|
|
45
45
|
return s.includes("://");
|
|
46
46
|
};
|
|
47
|
-
;
|
|
48
47
|
var ReferenceResolver = /** @class */ (function () {
|
|
49
48
|
function ReferenceResolver(protocolHandlerMap) {
|
|
50
49
|
this.protocolHandlerMap = protocolHandlerMap;
|
|
@@ -63,7 +62,7 @@ var ReferenceResolver = /** @class */ (function () {
|
|
|
63
62
|
// Check if its an internal reference that starts from the root
|
|
64
63
|
// Internal references.
|
|
65
64
|
if (ref[0] === "#") {
|
|
66
|
-
return [2 /*return*/, Promise.resolve(resolve_pointer_1.default(ref, root))];
|
|
65
|
+
return [2 /*return*/, Promise.resolve((0, resolve_pointer_1.default)(ref, root))];
|
|
67
66
|
}
|
|
68
67
|
hashFragmentSplit = ref.split("#");
|
|
69
68
|
if (hashFragmentSplit.length > 1) {
|
|
@@ -84,7 +83,7 @@ var ReferenceResolver = /** @class */ (function () {
|
|
|
84
83
|
if (relativePathSchema !== undefined) {
|
|
85
84
|
schema = relativePathSchema;
|
|
86
85
|
if (hashFragment) {
|
|
87
|
-
schema = resolve_pointer_1.default(hashFragment, schema);
|
|
86
|
+
schema = (0, resolve_pointer_1.default)(hashFragment, schema);
|
|
88
87
|
}
|
|
89
88
|
return [2 /*return*/, schema];
|
|
90
89
|
}
|
|
@@ -103,7 +102,7 @@ var ReferenceResolver = /** @class */ (function () {
|
|
|
103
102
|
if (maybeSchema !== undefined) {
|
|
104
103
|
schema = maybeSchema;
|
|
105
104
|
if (hashFragment) {
|
|
106
|
-
schema = resolve_pointer_1.default(hashFragment, schema);
|
|
105
|
+
schema = (0, resolve_pointer_1.default)(hashFragment, schema);
|
|
107
106
|
}
|
|
108
107
|
return [2 /*return*/, schema];
|
|
109
108
|
}
|
package/build/resolve-pointer.js
CHANGED
|
@@ -14,7 +14,7 @@ var InvalidJsonPointerRefError = /** @class */ (function () {
|
|
|
14
14
|
this.name = "InvalidJsonPointerRefError";
|
|
15
15
|
this.message = [
|
|
16
16
|
"InvalidJsonPointerRefError",
|
|
17
|
-
"The provided RFC6901 JSON Pointer is invalid: "
|
|
17
|
+
"The provided RFC6901 JSON Pointer is invalid: ".concat(ref),
|
|
18
18
|
"",
|
|
19
19
|
"addition info: ",
|
|
20
20
|
additionalMsg,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-schema-tools/reference-resolver",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "Turns a $ref into a JSONSchema",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"browser": "build/index-web.js",
|
|
7
7
|
"publishConfig": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "npm run build:code && typedoc --out docs && touch docs/.nojekyll",
|
|
12
12
|
"build:code": "tsc",
|
|
13
|
-
"lint": "
|
|
13
|
+
"lint": "eslint . --ext .ts",
|
|
14
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
14
15
|
"test": "npm run test:unit && npm run test:web",
|
|
15
16
|
"test:unit": "npm run lint && jest --coverage",
|
|
16
17
|
"test:web": "npm run build:code && webpack && rm -rf dist"
|
|
@@ -29,17 +30,19 @@
|
|
|
29
30
|
"!build/**/*.test.*"
|
|
30
31
|
],
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@json-schema-tools/meta-schema": "^1.
|
|
33
|
-
"@types/isomorphic-fetch": "0.0.
|
|
34
|
-
"@types/jest": "^
|
|
35
|
-
"@types/node": "^
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
33
|
+
"@json-schema-tools/meta-schema": "^1.7.0",
|
|
34
|
+
"@types/isomorphic-fetch": "^0.0.36",
|
|
35
|
+
"@types/jest": "^29.1.1",
|
|
36
|
+
"@types/node": "^18.8.2",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
39
|
+
"eslint": "^8.24.0",
|
|
40
|
+
"jest": "^29.1.2",
|
|
41
|
+
"ts-jest": "^29.0.3",
|
|
42
|
+
"typedoc": "^0.23.15",
|
|
43
|
+
"typescript": "^4.8.4",
|
|
44
|
+
"webpack": "^5.74.0",
|
|
45
|
+
"webpack-cli": "^4.10.0"
|
|
43
46
|
},
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"@json-schema-spec/json-pointer": "^0.1.2",
|