json-machete 0.0.24 → 0.0.28-alpha-dbca29ce8.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.
Files changed (3) hide show
  1. package/index.js +7 -2
  2. package/index.mjs +7 -2
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -24,6 +24,7 @@ function _interopNamespace(e) {
24
24
  const jsonPtr = require('json-ptr');
25
25
  const utils = require('@graphql-mesh/utils');
26
26
  const path = require('path');
27
+ const util = require('util');
27
28
 
28
29
  (function (OnCircularReference) {
29
30
  OnCircularReference["WARN"] = "WARN";
@@ -313,7 +314,7 @@ async function compareJSONSchemas(oldSchema, newSchema) {
313
314
  const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
314
315
  function deduplicateJSONSchema(schema, seenMap = new Map()) {
315
316
  if (typeof schema === 'object' && schema != null) {
316
- const stringified = JSON.stringify(schema);
317
+ const stringified = util.inspect(schema, undefined, 3);
317
318
  const seen = seenMap.get(stringified);
318
319
  if (seen) {
319
320
  return seen;
@@ -455,7 +456,11 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
455
456
  const newCwd = path.dirname(externalFilePath);
456
457
  let externalFile = externalFileCache.get(externalFilePath);
457
458
  if (!externalFile) {
458
- externalFile = await new Promise(function (resolve) { resolve(_interopNamespace(require(externalFilePath))); });
459
+ const importedJSON = await new Promise(function (resolve) { resolve(_interopNamespace(require(externalFilePath))); });
460
+ externalFile = {};
461
+ for (const key in importedJSON) {
462
+ externalFile[key] = importedJSON[key];
463
+ }
459
464
  externalFile = await healJSONSchema(externalFile);
460
465
  externalFileCache.set(externalFilePath, externalFile);
461
466
  }
package/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { JsonPointer } from 'json-ptr';
2
2
  import { AggregateError } from '@graphql-mesh/utils';
3
3
  import { isAbsolute, join, dirname } from 'path';
4
+ import { inspect } from 'util';
4
5
 
5
6
  var OnCircularReference;
6
7
  (function (OnCircularReference) {
@@ -291,7 +292,7 @@ async function compareJSONSchemas(oldSchema, newSchema) {
291
292
  const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
292
293
  function deduplicateJSONSchema(schema, seenMap = new Map()) {
293
294
  if (typeof schema === 'object' && schema != null) {
294
- const stringified = JSON.stringify(schema);
295
+ const stringified = inspect(schema, undefined, 3);
295
296
  const seen = seenMap.get(stringified);
296
297
  if (seen) {
297
298
  return seen;
@@ -433,7 +434,11 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
433
434
  const newCwd = dirname(externalFilePath);
434
435
  let externalFile = externalFileCache.get(externalFilePath);
435
436
  if (!externalFile) {
436
- externalFile = await import(externalFilePath);
437
+ const importedJSON = await import(externalFilePath);
438
+ externalFile = {};
439
+ for (const key in importedJSON) {
440
+ externalFile[key] = importedJSON[key];
441
+ }
437
442
  externalFile = await healJSONSchema(externalFile);
438
443
  externalFileCache.set(externalFilePath, externalFile);
439
444
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "json-machete",
3
- "version": "0.0.24",
3
+ "version": "0.0.28-alpha-dbca29ce8.0",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
- "@graphql-mesh/utils": "0.21.0",
6
+ "@graphql-mesh/utils": "0.22.0-alpha-dbca29ce8.0",
7
7
  "@json-schema-tools/meta-schema": "1.6.19",
8
8
  "json-ptr": "2.2.0"
9
9
  },