@json-schema-tools/reference-resolver 1.2.4 → 1.2.6

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 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
  };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -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, root) { return __awaiter(void 0, void 0, void 0, function () {
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: " + obj.$ref + " was not JSON.parse 'able",
26
- "The non-json content in question: " + nonJson,
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: " + ref,
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: " + ref,
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: " + ref,
79
+ "The path was not resolvable: ".concat(ref),
80
80
  ].join("\n");
81
81
  }
82
82
  return InvalidFileSystemPathError;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -44,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
44
48
  function verb(n) { return function (v) { return step([n, v]); }; }
45
49
  function step(op) {
46
50
  if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
52
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
53
  if (y = 0, t) op = [op[0] & 2, t.value];
50
54
  switch (op[0]) {
@@ -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 + "/" + uri;
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];
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -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;
@@ -53,17 +52,17 @@ var ReferenceResolver = /** @class */ (function () {
53
52
  * Given a $ref string, it will return the underlying pointed-to value.
54
53
  * For remote references, the root object is not used.
55
54
  */
56
- ReferenceResolver.prototype.resolve = function (ref, root) {
57
- if (root === void 0) { root = {}; }
58
- return __awaiter(this, void 0, void 0, function () {
55
+ ReferenceResolver.prototype.resolve = function (ref_1) {
56
+ return __awaiter(this, arguments, void 0, function (ref, root) {
59
57
  var hashFragmentSplit, hashFragment, hashlessRef, relativePathSchema, e_1, schema, _i, _a, protocol, maybeSchema, schema;
58
+ if (root === void 0) { root = {}; }
60
59
  return __generator(this, function (_b) {
61
60
  switch (_b.label) {
62
61
  case 0:
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
  }
@@ -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: " + ref,
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",
4
- "description": "",
3
+ "version": "1.2.6",
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": "tslint --fix -p .",
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.6.18",
33
- "@types/isomorphic-fetch": "0.0.35",
34
- "@types/jest": "^26.0.23",
35
- "@types/node": "^15.12.2",
36
- "jest": "^24.9.0",
37
- "ts-jest": "^24.3.0",
38
- "tslint": "^6.1.3",
39
- "typedoc": "^0.21.0",
40
- "typescript": "4.3.4",
41
- "webpack": "^5.38.1",
42
- "webpack-cli": "^4.7.2"
33
+ "@json-schema-tools/meta-schema": "^1.7.5",
34
+ "@types/isomorphic-fetch": "^0.0.39",
35
+ "@types/jest": "^29.1.1",
36
+ "@types/node": "^20.12.7",
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.25.13",
43
+ "typescript": "^5.4.4",
44
+ "webpack": "^5.74.0",
45
+ "webpack-cli": "^5.1.4"
43
46
  },
44
47
  "dependencies": {
45
48
  "@json-schema-spec/json-pointer": "^0.1.2",