json-machete 0.8.0-alpha-71b54d9af.0 → 0.8.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 +103 -94
  2. package/index.mjs +103 -94
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
- const JsonPointer = _interopDefault(require('json-pointer'));
8
7
  const utils = require('@graphql-mesh/utils');
8
+ const JsonPointer = _interopDefault(require('json-pointer'));
9
9
  const crossHelpers = require('@graphql-mesh/cross-helpers');
10
10
  const urlJoin = _interopDefault(require('url-join'));
11
11
  const crossUndiciFetch = require('cross-undici-fetch');
@@ -219,101 +219,17 @@ async function visitJSONSchema(schema, visitorFn, { visitedSubschemaResultMap, p
219
219
  });
220
220
  }
221
221
 
222
- async function compareJSONSchemas(oldSchema, newSchema) {
223
- const breakingChanges = [];
224
- await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
225
- var _a, _b, _c, _d;
226
- if (typeof newSchema === 'object') {
227
- const newSubSchema = JsonPointer.get(newSchema, path);
228
- if (typeof oldSubSchema === 'boolean') {
229
- if (newSubSchema !== oldSubSchema) {
230
- breakingChanges.push(`${path} is changed from ${oldSubSchema} to ${newSubSchema}`);
231
- }
232
- }
233
- else {
234
- if (oldSubSchema.$ref) {
235
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
236
- breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
237
- }
238
- }
239
- if (oldSubSchema.const) {
240
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const) !== oldSubSchema.const) {
241
- breakingChanges.push(`${path}/const is changed from ${oldSubSchema.const} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const}`);
242
- }
243
- }
244
- if (oldSubSchema.enum) {
245
- for (const enumValue of oldSubSchema.enum) {
246
- if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
247
- breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
248
- }
249
- }
250
- }
251
- if (oldSubSchema.format) {
252
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format) !== oldSubSchema.format) {
253
- breakingChanges.push(`${path}/format is changed from ${oldSubSchema.format} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format}`);
254
- }
255
- }
256
- if (oldSubSchema.maxLength) {
257
- if (oldSubSchema.maxLength > (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength)) {
258
- breakingChanges.push(`${path}/maxLength is changed from ${oldSubSchema.maxLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength}`);
259
- }
260
- }
261
- if (oldSubSchema.minLength) {
262
- if (oldSubSchema.minLength < (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength)) {
263
- breakingChanges.push(`${path}/minLength is changed from ${oldSubSchema.minLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength}`);
264
- }
265
- }
266
- if (oldSubSchema.pattern) {
267
- if (((_b = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern) === null || _b === void 0 ? void 0 : _b.toString()) !== oldSubSchema.pattern.toString()) {
268
- breakingChanges.push(`${path}/pattern is changed from ${oldSubSchema.pattern} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern}`);
269
- }
270
- }
271
- if (oldSubSchema.properties) {
272
- for (const propertyName in oldSubSchema.properties) {
273
- if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
274
- breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
275
- }
276
- }
277
- }
278
- if (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.required) {
279
- for (const propertyName of newSubSchema.required) {
280
- if (!((_d = oldSubSchema.required) === null || _d === void 0 ? void 0 : _d.includes(propertyName))) {
281
- breakingChanges.push(`${path}/required has ${propertyName} an extra`);
282
- }
283
- }
284
- }
285
- if (oldSubSchema.title) {
286
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title) !== oldSubSchema.title) {
287
- breakingChanges.push(`${path}/title is changed from ${oldSubSchema.title} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title}`);
288
- }
289
- }
290
- if (oldSubSchema.type) {
291
- if (typeof (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) === 'string'
292
- ? (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) !== oldSubSchema.type
293
- : Array.isArray(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type)
294
- ? Array.isArray(oldSubSchema.type)
295
- ? oldSubSchema.type.some(typeName => !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(typeName)))
296
- : !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(oldSubSchema.type))
297
- : true) {
298
- breakingChanges.push(`${path}/type is changed from ${oldSubSchema.type} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type}`);
299
- }
300
- }
301
- }
222
+ const resolvePath = (path, root) => {
223
+ var _a;
224
+ try {
225
+ return JsonPointer.get(root, path);
226
+ }
227
+ catch (e) {
228
+ if ((_a = e.message) === null || _a === void 0 ? void 0 : _a.startsWith('Invalid reference')) {
229
+ return undefined;
302
230
  }
303
- return oldSubSchema;
304
- }, {
305
- visitedSubschemaResultMap: new WeakMap(),
306
- path: '',
307
- keepObjectRef: true,
308
- onCircularReference: process.env.DEBUG ? exports.OnCircularReference.WARN : exports.OnCircularReference.IGNORE,
309
- });
310
- if (breakingChanges.length > 0) {
311
- throw new utils.AggregateError(breakingChanges.map(breakingChange => new Error(breakingChange)), `Breaking changes are found:\n${breakingChanges.join('\n')}`);
231
+ throw e;
312
232
  }
313
- }
314
-
315
- const resolvePath = (path, root) => {
316
- return JsonPointer.get(root, path);
317
233
  };
318
234
  function isRefObject(obj) {
319
235
  return typeof obj === 'object' && obj.$ref;
@@ -487,6 +403,99 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
487
403
  return obj;
488
404
  }
489
405
 
406
+ async function compareJSONSchemas(oldSchema, newSchema) {
407
+ const breakingChanges = [];
408
+ await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
409
+ var _a, _b, _c, _d;
410
+ if (typeof newSchema === 'object') {
411
+ const newSubSchema = resolvePath(path, newSchema);
412
+ if (typeof oldSubSchema === 'boolean') {
413
+ if (newSubSchema !== oldSubSchema) {
414
+ breakingChanges.push(`${path} is changed from ${oldSubSchema} to ${newSubSchema}`);
415
+ }
416
+ }
417
+ else {
418
+ if (oldSubSchema.$ref) {
419
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
420
+ breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
421
+ }
422
+ }
423
+ if (oldSubSchema.const) {
424
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const) !== oldSubSchema.const) {
425
+ breakingChanges.push(`${path}/const is changed from ${oldSubSchema.const} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const}`);
426
+ }
427
+ }
428
+ if (oldSubSchema.enum) {
429
+ for (const enumValue of oldSubSchema.enum) {
430
+ if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
431
+ breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
432
+ }
433
+ }
434
+ }
435
+ if (oldSubSchema.format) {
436
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format) !== oldSubSchema.format) {
437
+ breakingChanges.push(`${path}/format is changed from ${oldSubSchema.format} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format}`);
438
+ }
439
+ }
440
+ if (oldSubSchema.maxLength) {
441
+ if (oldSubSchema.maxLength > (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength)) {
442
+ breakingChanges.push(`${path}/maxLength is changed from ${oldSubSchema.maxLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength}`);
443
+ }
444
+ }
445
+ if (oldSubSchema.minLength) {
446
+ if (oldSubSchema.minLength < (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength)) {
447
+ breakingChanges.push(`${path}/minLength is changed from ${oldSubSchema.minLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength}`);
448
+ }
449
+ }
450
+ if (oldSubSchema.pattern) {
451
+ if (((_b = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern) === null || _b === void 0 ? void 0 : _b.toString()) !== oldSubSchema.pattern.toString()) {
452
+ breakingChanges.push(`${path}/pattern is changed from ${oldSubSchema.pattern} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern}`);
453
+ }
454
+ }
455
+ if (oldSubSchema.properties) {
456
+ for (const propertyName in oldSubSchema.properties) {
457
+ if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
458
+ breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
459
+ }
460
+ }
461
+ }
462
+ if (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.required) {
463
+ for (const propertyName of newSubSchema.required) {
464
+ if (!((_d = oldSubSchema.required) === null || _d === void 0 ? void 0 : _d.includes(propertyName))) {
465
+ breakingChanges.push(`${path}/required has ${propertyName} an extra`);
466
+ }
467
+ }
468
+ }
469
+ if (oldSubSchema.title) {
470
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title) !== oldSubSchema.title) {
471
+ breakingChanges.push(`${path}/title is changed from ${oldSubSchema.title} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title}`);
472
+ }
473
+ }
474
+ if (oldSubSchema.type) {
475
+ if (typeof (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) === 'string'
476
+ ? (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) !== oldSubSchema.type
477
+ : Array.isArray(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type)
478
+ ? Array.isArray(oldSubSchema.type)
479
+ ? oldSubSchema.type.some(typeName => !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(typeName)))
480
+ : !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(oldSubSchema.type))
481
+ : true) {
482
+ breakingChanges.push(`${path}/type is changed from ${oldSubSchema.type} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type}`);
483
+ }
484
+ }
485
+ }
486
+ }
487
+ return oldSubSchema;
488
+ }, {
489
+ visitedSubschemaResultMap: new WeakMap(),
490
+ path: '',
491
+ keepObjectRef: true,
492
+ onCircularReference: process.env.DEBUG ? exports.OnCircularReference.WARN : exports.OnCircularReference.IGNORE,
493
+ });
494
+ if (breakingChanges.length > 0) {
495
+ throw new utils.AggregateError(breakingChanges.map(breakingChange => new Error(breakingChange)), `Breaking changes are found:\n${breakingChanges.join('\n')}`);
496
+ }
497
+ }
498
+
490
499
  const asArray = (value) => (Array.isArray(value) ? value : [value]);
491
500
  const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
492
501
  const JSONSchemaStringFormats = [
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
+ import { readFileOrUrl, AggregateError } from '@graphql-mesh/utils';
1
2
  import JsonPointer from 'json-pointer';
2
- import { AggregateError, readFileOrUrl } from '@graphql-mesh/utils';
3
3
  import { path } from '@graphql-mesh/cross-helpers';
4
4
  import urlJoin from 'url-join';
5
5
  import { fetch } from 'cross-undici-fetch';
@@ -214,101 +214,17 @@ async function visitJSONSchema(schema, visitorFn, { visitedSubschemaResultMap, p
214
214
  });
215
215
  }
216
216
 
217
- async function compareJSONSchemas(oldSchema, newSchema) {
218
- const breakingChanges = [];
219
- await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
220
- var _a, _b, _c, _d;
221
- if (typeof newSchema === 'object') {
222
- const newSubSchema = JsonPointer.get(newSchema, path);
223
- if (typeof oldSubSchema === 'boolean') {
224
- if (newSubSchema !== oldSubSchema) {
225
- breakingChanges.push(`${path} is changed from ${oldSubSchema} to ${newSubSchema}`);
226
- }
227
- }
228
- else {
229
- if (oldSubSchema.$ref) {
230
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
231
- breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
232
- }
233
- }
234
- if (oldSubSchema.const) {
235
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const) !== oldSubSchema.const) {
236
- breakingChanges.push(`${path}/const is changed from ${oldSubSchema.const} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const}`);
237
- }
238
- }
239
- if (oldSubSchema.enum) {
240
- for (const enumValue of oldSubSchema.enum) {
241
- if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
242
- breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
243
- }
244
- }
245
- }
246
- if (oldSubSchema.format) {
247
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format) !== oldSubSchema.format) {
248
- breakingChanges.push(`${path}/format is changed from ${oldSubSchema.format} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format}`);
249
- }
250
- }
251
- if (oldSubSchema.maxLength) {
252
- if (oldSubSchema.maxLength > (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength)) {
253
- breakingChanges.push(`${path}/maxLength is changed from ${oldSubSchema.maxLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength}`);
254
- }
255
- }
256
- if (oldSubSchema.minLength) {
257
- if (oldSubSchema.minLength < (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength)) {
258
- breakingChanges.push(`${path}/minLength is changed from ${oldSubSchema.minLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength}`);
259
- }
260
- }
261
- if (oldSubSchema.pattern) {
262
- if (((_b = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern) === null || _b === void 0 ? void 0 : _b.toString()) !== oldSubSchema.pattern.toString()) {
263
- breakingChanges.push(`${path}/pattern is changed from ${oldSubSchema.pattern} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern}`);
264
- }
265
- }
266
- if (oldSubSchema.properties) {
267
- for (const propertyName in oldSubSchema.properties) {
268
- if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
269
- breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
270
- }
271
- }
272
- }
273
- if (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.required) {
274
- for (const propertyName of newSubSchema.required) {
275
- if (!((_d = oldSubSchema.required) === null || _d === void 0 ? void 0 : _d.includes(propertyName))) {
276
- breakingChanges.push(`${path}/required has ${propertyName} an extra`);
277
- }
278
- }
279
- }
280
- if (oldSubSchema.title) {
281
- if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title) !== oldSubSchema.title) {
282
- breakingChanges.push(`${path}/title is changed from ${oldSubSchema.title} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title}`);
283
- }
284
- }
285
- if (oldSubSchema.type) {
286
- if (typeof (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) === 'string'
287
- ? (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) !== oldSubSchema.type
288
- : Array.isArray(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type)
289
- ? Array.isArray(oldSubSchema.type)
290
- ? oldSubSchema.type.some(typeName => !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(typeName)))
291
- : !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(oldSubSchema.type))
292
- : true) {
293
- breakingChanges.push(`${path}/type is changed from ${oldSubSchema.type} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type}`);
294
- }
295
- }
296
- }
217
+ const resolvePath = (path, root) => {
218
+ var _a;
219
+ try {
220
+ return JsonPointer.get(root, path);
221
+ }
222
+ catch (e) {
223
+ if ((_a = e.message) === null || _a === void 0 ? void 0 : _a.startsWith('Invalid reference')) {
224
+ return undefined;
297
225
  }
298
- return oldSubSchema;
299
- }, {
300
- visitedSubschemaResultMap: new WeakMap(),
301
- path: '',
302
- keepObjectRef: true,
303
- onCircularReference: process.env.DEBUG ? OnCircularReference.WARN : OnCircularReference.IGNORE,
304
- });
305
- if (breakingChanges.length > 0) {
306
- throw new AggregateError(breakingChanges.map(breakingChange => new Error(breakingChange)), `Breaking changes are found:\n${breakingChanges.join('\n')}`);
226
+ throw e;
307
227
  }
308
- }
309
-
310
- const resolvePath = (path, root) => {
311
- return JsonPointer.get(root, path);
312
228
  };
313
229
  function isRefObject(obj) {
314
230
  return typeof obj === 'object' && obj.$ref;
@@ -482,6 +398,99 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
482
398
  return obj;
483
399
  }
484
400
 
401
+ async function compareJSONSchemas(oldSchema, newSchema) {
402
+ const breakingChanges = [];
403
+ await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
404
+ var _a, _b, _c, _d;
405
+ if (typeof newSchema === 'object') {
406
+ const newSubSchema = resolvePath(path, newSchema);
407
+ if (typeof oldSubSchema === 'boolean') {
408
+ if (newSubSchema !== oldSubSchema) {
409
+ breakingChanges.push(`${path} is changed from ${oldSubSchema} to ${newSubSchema}`);
410
+ }
411
+ }
412
+ else {
413
+ if (oldSubSchema.$ref) {
414
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
415
+ breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
416
+ }
417
+ }
418
+ if (oldSubSchema.const) {
419
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const) !== oldSubSchema.const) {
420
+ breakingChanges.push(`${path}/const is changed from ${oldSubSchema.const} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.const}`);
421
+ }
422
+ }
423
+ if (oldSubSchema.enum) {
424
+ for (const enumValue of oldSubSchema.enum) {
425
+ if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
426
+ breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
427
+ }
428
+ }
429
+ }
430
+ if (oldSubSchema.format) {
431
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format) !== oldSubSchema.format) {
432
+ breakingChanges.push(`${path}/format is changed from ${oldSubSchema.format} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.format}`);
433
+ }
434
+ }
435
+ if (oldSubSchema.maxLength) {
436
+ if (oldSubSchema.maxLength > (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength)) {
437
+ breakingChanges.push(`${path}/maxLength is changed from ${oldSubSchema.maxLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.maxLength}`);
438
+ }
439
+ }
440
+ if (oldSubSchema.minLength) {
441
+ if (oldSubSchema.minLength < (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength)) {
442
+ breakingChanges.push(`${path}/minLength is changed from ${oldSubSchema.minLength} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.minLength}`);
443
+ }
444
+ }
445
+ if (oldSubSchema.pattern) {
446
+ if (((_b = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern) === null || _b === void 0 ? void 0 : _b.toString()) !== oldSubSchema.pattern.toString()) {
447
+ breakingChanges.push(`${path}/pattern is changed from ${oldSubSchema.pattern} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.pattern}`);
448
+ }
449
+ }
450
+ if (oldSubSchema.properties) {
451
+ for (const propertyName in oldSubSchema.properties) {
452
+ if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
453
+ breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
454
+ }
455
+ }
456
+ }
457
+ if (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.required) {
458
+ for (const propertyName of newSubSchema.required) {
459
+ if (!((_d = oldSubSchema.required) === null || _d === void 0 ? void 0 : _d.includes(propertyName))) {
460
+ breakingChanges.push(`${path}/required has ${propertyName} an extra`);
461
+ }
462
+ }
463
+ }
464
+ if (oldSubSchema.title) {
465
+ if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title) !== oldSubSchema.title) {
466
+ breakingChanges.push(`${path}/title is changed from ${oldSubSchema.title} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.title}`);
467
+ }
468
+ }
469
+ if (oldSubSchema.type) {
470
+ if (typeof (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) === 'string'
471
+ ? (newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type) !== oldSubSchema.type
472
+ : Array.isArray(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type)
473
+ ? Array.isArray(oldSubSchema.type)
474
+ ? oldSubSchema.type.some(typeName => !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(typeName)))
475
+ : !(newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type.includes(oldSubSchema.type))
476
+ : true) {
477
+ breakingChanges.push(`${path}/type is changed from ${oldSubSchema.type} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.type}`);
478
+ }
479
+ }
480
+ }
481
+ }
482
+ return oldSubSchema;
483
+ }, {
484
+ visitedSubschemaResultMap: new WeakMap(),
485
+ path: '',
486
+ keepObjectRef: true,
487
+ onCircularReference: process.env.DEBUG ? OnCircularReference.WARN : OnCircularReference.IGNORE,
488
+ });
489
+ if (breakingChanges.length > 0) {
490
+ throw new AggregateError(breakingChanges.map(breakingChange => new Error(breakingChange)), `Breaking changes are found:\n${breakingChanges.join('\n')}`);
491
+ }
492
+ }
493
+
485
494
  const asArray = (value) => (Array.isArray(value) ? value : [value]);
486
495
  const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
487
496
  const JSONSchemaStringFormats = [
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "json-machete",
3
- "version": "0.8.0-alpha-71b54d9af.0",
3
+ "version": "0.8.0",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "@graphql-mesh/cross-helpers": "0.1.2",
7
- "@graphql-mesh/utils": "0.34.3-alpha-71b54d9af.0",
7
+ "@graphql-mesh/utils": "0.34.3",
8
8
  "@graphql-tools/utils": "8.6.9",
9
9
  "@json-schema-tools/meta-schema": "1.6.19",
10
- "cross-undici-fetch": "0.3.0",
10
+ "cross-undici-fetch": "0.3.1",
11
11
  "json-pointer": "0.6.2",
12
12
  "to-json-schema": "0.2.5",
13
13
  "tslib": "^2.3.1",