json-machete 0.8.15 → 0.9.0-alpha-354d24eb5.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.
@@ -1,11 +1,13 @@
1
1
  export declare const resolvePath: (path: string, root: any) => any;
2
2
  export declare function getAbsolutePath(path: string, cwd: string): string;
3
3
  export declare function getCwd(path: string): string;
4
- export declare function dereferenceObject<T extends object, TRoot = T>(obj: T, { cwd, externalFileCache, refMap, root, fetch, headers, }?: {
4
+ export declare function dereferenceObject<T extends object, TRoot = T>(obj: T, { cwd, externalFileCache, refMap, root, fetchFn: fetch, importFn, logger, headers, }?: {
5
5
  cwd?: string;
6
6
  externalFileCache?: Map<string, any>;
7
7
  refMap?: Map<string, any>;
8
8
  root?: TRoot;
9
- fetch?: WindowOrWorkerGlobalScope['fetch'];
9
+ fetchFn?: WindowOrWorkerGlobalScope['fetch'];
10
+ importFn?: (m: string) => any;
11
+ logger?: any;
10
12
  headers?: Record<string, string>;
11
13
  }): Promise<T>;
package/index.js CHANGED
@@ -273,7 +273,7 @@ function getCwd(path) {
273
273
  return isURL(path) ? getCwdForUrl(path) : crossHelpers.path.dirname(path);
274
274
  }
275
275
  // eslint-disable-next-line @typescript-eslint/ban-types
276
- async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetch = crossUndiciFetch.fetch, headers, } = {}) {
276
+ async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetchFn: fetch = crossUndiciFetch.fetch, importFn = utils$1.defaultImportFn, logger = new utils$1.DefaultLogger('dereferenceObject'), headers, } = {}) {
277
277
  var _a;
278
278
  if (obj != null && typeof obj === 'object') {
279
279
  if (isRefObject(obj)) {
@@ -295,6 +295,8 @@ async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), extern
295
295
  fetch,
296
296
  headers,
297
297
  cwd,
298
+ importFn,
299
+ logger,
298
300
  }).catch(() => {
299
301
  throw new Error(`Unable to load ${externalRelativeFilePath} from ${cwd}`);
300
302
  });
@@ -347,7 +349,9 @@ async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), extern
347
349
  throw new Error('Not implemented ' + key.toString());
348
350
  },
349
351
  }),
350
- fetch,
352
+ fetchFn: fetch,
353
+ importFn,
354
+ logger,
351
355
  headers,
352
356
  root: externalFile,
353
357
  });
@@ -373,7 +377,9 @@ async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), extern
373
377
  externalFileCache,
374
378
  refMap,
375
379
  root,
376
- fetch,
380
+ fetchFn: fetch,
381
+ importFn,
382
+ logger,
377
383
  headers,
378
384
  });
379
385
  refMap.set($ref, result);
@@ -393,7 +399,7 @@ async function dereferenceObject(obj, { cwd = crossHelpers.process.cwd(), extern
393
399
  externalFileCache,
394
400
  refMap,
395
401
  root,
396
- fetch,
402
+ fetchFn: fetch,
397
403
  headers,
398
404
  });
399
405
  }
package/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { AggregateError } from '@graphql-tools/utils';
3
3
  import JsonPointer from 'json-pointer';
4
4
  import urlJoin from 'url-join';
5
5
  import { fetch } from 'cross-undici-fetch';
6
- import { readFileOrUrl } from '@graphql-mesh/utils';
6
+ import { defaultImportFn, DefaultLogger, readFileOrUrl } from '@graphql-mesh/utils';
7
7
  import toJsonSchema from 'to-json-schema';
8
8
 
9
9
  var OnCircularReference;
@@ -268,7 +268,7 @@ function getCwd(path$1) {
268
268
  return isURL(path$1) ? getCwdForUrl(path$1) : path.dirname(path$1);
269
269
  }
270
270
  // eslint-disable-next-line @typescript-eslint/ban-types
271
- async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetch: fetch$1 = fetch, headers, } = {}) {
271
+ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetchFn: fetch$1 = fetch, importFn = defaultImportFn, logger = new DefaultLogger('dereferenceObject'), headers, } = {}) {
272
272
  var _a;
273
273
  if (obj != null && typeof obj === 'object') {
274
274
  if (isRefObject(obj)) {
@@ -290,6 +290,8 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
290
290
  fetch: fetch$1,
291
291
  headers,
292
292
  cwd,
293
+ importFn,
294
+ logger,
293
295
  }).catch(() => {
294
296
  throw new Error(`Unable to load ${externalRelativeFilePath} from ${cwd}`);
295
297
  });
@@ -342,7 +344,9 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
342
344
  throw new Error('Not implemented ' + key.toString());
343
345
  },
344
346
  }),
345
- fetch: fetch$1,
347
+ fetchFn: fetch$1,
348
+ importFn,
349
+ logger,
346
350
  headers,
347
351
  root: externalFile,
348
352
  });
@@ -368,7 +372,9 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
368
372
  externalFileCache,
369
373
  refMap,
370
374
  root,
371
- fetch: fetch$1,
375
+ fetchFn: fetch$1,
376
+ importFn,
377
+ logger,
372
378
  headers,
373
379
  });
374
380
  refMap.set($ref, result);
@@ -388,7 +394,7 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
388
394
  externalFileCache,
389
395
  refMap,
390
396
  root,
391
- fetch: fetch$1,
397
+ fetchFn: fetch$1,
392
398
  headers,
393
399
  });
394
400
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "json-machete",
3
- "version": "0.8.15",
3
+ "version": "0.9.0-alpha-354d24eb5.0",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "@graphql-mesh/cross-helpers": "0.1.6",
7
- "@graphql-mesh/utils": "0.35.7",
7
+ "@graphql-mesh/utils": "0.36.0-alpha-354d24eb5.0",
8
8
  "@graphql-tools/utils": "8.6.13",
9
9
  "@json-schema-tools/meta-schema": "1.6.19",
10
10
  "cross-undici-fetch": "^0.4.0",