@apidevtools/json-schema-ref-parser 11.7.3 → 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.
@@ -123,8 +123,17 @@ export class UnmatchedResolverError extends JSONParserError {
123
123
  export class MissingPointerError extends JSONParserError {
124
124
  code = "EMISSINGPOINTER" as JSONParserErrorType;
125
125
  name = "MissingPointerError";
126
- constructor(token: string, path: string) {
126
+ public targetToken: any;
127
+ public targetRef: string;
128
+ public targetFound: string;
129
+ public parentPath: string;
130
+ constructor(token: any, path: any, targetRef: any, targetFound: any, parentPath: any) {
127
131
  super(`Missing $ref pointer "${getHash(path)}". Token "${token}" does not exist.`, stripHash(path));
132
+
133
+ this.targetToken = token;
134
+ this.targetRef = targetRef;
135
+ this.targetFound = targetFound;
136
+ this.parentPath = parentPath;
128
137
  }
129
138
  }
130
139
 
@@ -45,8 +45,7 @@ export function sort(plugins: Plugin[]) {
45
45
  });
46
46
  }
47
47
 
48
- // @ts-ignore
49
- export interface PluginResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
48
+ export interface PluginResult<S extends object = JSONSchema> {
50
49
  plugin: Plugin;
51
50
  result?: string | Buffer | S;
52
51
  error?: any;
@@ -67,10 +66,10 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
67
66
  $refs: $Refs<S, O>,
68
67
  ) {
69
68
  let plugin: Plugin;
70
- let lastError: PluginResult<S, O>;
69
+ let lastError: PluginResult<S>;
71
70
  let index = 0;
72
71
 
73
- return new Promise<PluginResult<S, O>>((resolve, reject) => {
72
+ return new Promise<PluginResult<S>>((resolve, reject) => {
74
73
  runNextPlugin();
75
74
 
76
75
  function runNextPlugin() {
@@ -97,7 +96,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
97
96
  }
98
97
  }
99
98
 
100
- function callback(err: PluginResult<S, O>["error"], result: PluginResult<S, O>["result"]) {
99
+ function callback(err: PluginResult<S>["error"], result: PluginResult<S>["result"]) {
101
100
  if (err) {
102
101
  onError(err);
103
102
  } else {
@@ -105,7 +104,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
105
104
  }
106
105
  }
107
106
 
108
- function onSuccess(result: PluginResult<S, O>["result"]) {
107
+ function onSuccess(result: PluginResult<S>["result"]) {
109
108
  // console.log(' success');
110
109
  resolve({
111
110
  plugin,
@@ -113,7 +112,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
113
112
  });
114
113
  }
115
114
 
116
- function onError(error: PluginResult<S, O>["error"]) {
115
+ function onError(error: PluginResult<S>["error"]) {
117
116
  // console.log(' %s', err.message || err);
118
117
  lastError = {
119
118
  plugin,
package/lib/util/url.ts CHANGED
@@ -26,10 +26,11 @@ export const parse = (u: string | URL) => new URL(u);
26
26
  * @returns
27
27
  */
28
28
  export function resolve(from: string, to: string) {
29
- const fromUrl = new URL(convertPathToPosix(from), "resolve://");
29
+ // we use a non-existent URL to check if its a relative URL
30
+ const fromUrl = new URL(convertPathToPosix(from), "https://aaa.nonexistanturl.com");
30
31
  const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
31
32
  const endSpaces = to.match(/(\s*)$/)?.[1] || "";
32
- if (resolvedUrl.protocol === "resolve:") {
33
+ if (resolvedUrl.hostname === "aaa.nonexistanturl.com") {
33
34
  // `from` is a relative URL.
34
35
  const { pathname, search, hash } = resolvedUrl;
35
36
  return pathname + search + hash + endSpaces;
package/package.json CHANGED
@@ -1,7 +1,19 @@
1
1
  {
2
2
  "name": "@apidevtools/json-schema-ref-parser",
3
- "version": "11.7.3",
3
+ "version": "11.8.2",
4
4
  "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5
+ "scripts": {
6
+ "prepublishOnly": "yarn build",
7
+ "lint": "eslint lib",
8
+ "build": "rimraf dist && tsc",
9
+ "typecheck": "tsc --noEmit",
10
+ "prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
11
+ "test": "vitest --coverage",
12
+ "test:node": "yarn test",
13
+ "test:browser": "cross-env BROWSER=\"true\" yarn test",
14
+ "test:update": "vitest -u",
15
+ "test:watch": "vitest -w"
16
+ },
5
17
  "keywords": [
6
18
  "json",
7
19
  "schema",
@@ -54,42 +66,30 @@
54
66
  "dist",
55
67
  "cjs"
56
68
  ],
57
- "scripts": {
58
- "prepublishOnly": "yarn build",
59
- "lint": "eslint lib",
60
- "build": "rimraf dist && tsc",
61
- "typecheck": "tsc --noEmit",
62
- "prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
63
- "test": "vitest --coverage",
64
- "test:node": "yarn test",
65
- "test:browser": "cross-env BROWSER=\"true\" yarn test",
66
- "test:update": "vitest -u",
67
- "test:watch": "vitest -w"
68
- },
69
69
  "devDependencies": {
70
- "@eslint/compat": "^1.2.4",
71
- "@eslint/js": "^9.16.0",
72
- "@types/eslint": "9.6.1",
70
+ "@eslint/compat": "^1.2.5",
71
+ "@eslint/js": "^9.18.0",
72
+ "@types/eslint": "^9.6.1",
73
73
  "@types/js-yaml": "^4.0.9",
74
74
  "@types/node": "^22",
75
- "@typescript-eslint/eslint-plugin": "^8.17.0",
76
- "@typescript-eslint/parser": "^8.17.0",
77
- "@vitest/coverage-v8": "^2.1.8",
75
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
76
+ "@typescript-eslint/parser": "^8.21.0",
77
+ "@vitest/coverage-v8": "^3.0.4",
78
78
  "cross-env": "^7.0.3",
79
- "eslint": "^9.16.0",
80
- "eslint-config-prettier": "^9.1.0",
79
+ "eslint": "^9.18.0",
80
+ "eslint-config-prettier": "^10.0.1",
81
81
  "eslint-config-standard": "^17.1.0",
82
82
  "eslint-plugin-import": "^2.31.0",
83
- "eslint-plugin-prettier": "^5.2.1",
83
+ "eslint-plugin-prettier": "^5.2.3",
84
84
  "eslint-plugin-promise": "^7.2.1",
85
85
  "eslint-plugin-unused-imports": "^4.1.4",
86
- "globals": "^15.13.0",
87
- "jsdom": "^25.0.1",
86
+ "globals": "^15.14.0",
87
+ "jsdom": "^26.0.0",
88
88
  "prettier": "^3.4.2",
89
89
  "rimraf": "^6.0.1",
90
- "typescript": "^5.7.2",
91
- "typescript-eslint": "^8.17.0",
92
- "vitest": "^2.1.8"
90
+ "typescript": "^5.7.3",
91
+ "typescript-eslint": "^8.21.0",
92
+ "vitest": "^3.0.4"
93
93
  },
94
94
  "dependencies": {
95
95
  "@jsdevtools/ono": "^7.1.3",