json-machete 0.7.15 → 0.8.0-alpha-1ffe1fa37.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.
- package/index.js +62 -60
- package/index.mjs +61 -59
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
const JsonPointer = _interopDefault(require('json-pointer'));
|
|
8
8
|
const utils = require('@graphql-mesh/utils');
|
|
9
9
|
const crossHelpers = require('@graphql-mesh/cross-helpers');
|
|
10
10
|
const urlJoin = _interopDefault(require('url-join'));
|
|
@@ -223,78 +223,80 @@ async function compareJSONSchemas(oldSchema, newSchema) {
|
|
|
223
223
|
const breakingChanges = [];
|
|
224
224
|
await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
|
|
225
225
|
var _a, _b, _c, _d;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
if (oldSubSchema.$ref) {
|
|
234
|
-
if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
|
|
235
|
-
breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
|
|
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}`);
|
|
236
231
|
}
|
|
237
232
|
}
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
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
|
+
}
|
|
241
238
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
|
|
246
|
-
breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
|
|
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}`);
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
+
}
|
|
253
250
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
+
}
|
|
258
255
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
}
|
|
263
260
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
+
}
|
|
268
265
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
|
|
273
|
-
breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
|
|
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}`);
|
|
274
269
|
}
|
|
275
270
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
+
}
|
|
281
276
|
}
|
|
282
277
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
+
}
|
|
287
284
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
:
|
|
297
|
-
|
|
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
|
+
}
|
|
298
300
|
}
|
|
299
301
|
}
|
|
300
302
|
}
|
|
@@ -311,7 +313,7 @@ async function compareJSONSchemas(oldSchema, newSchema) {
|
|
|
311
313
|
}
|
|
312
314
|
|
|
313
315
|
const resolvePath = (path, root) => {
|
|
314
|
-
return
|
|
316
|
+
return JsonPointer.get(root, path);
|
|
315
317
|
};
|
|
316
318
|
function isRefObject(obj) {
|
|
317
319
|
return typeof obj === 'object' && obj.$ref;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import JsonPointer from 'json-pointer';
|
|
2
2
|
import { AggregateError, readFileOrUrl } from '@graphql-mesh/utils';
|
|
3
3
|
import { path } from '@graphql-mesh/cross-helpers';
|
|
4
4
|
import urlJoin from 'url-join';
|
|
@@ -218,78 +218,80 @@ async function compareJSONSchemas(oldSchema, newSchema) {
|
|
|
218
218
|
const breakingChanges = [];
|
|
219
219
|
await visitJSONSchema(oldSchema, (oldSubSchema, { path }) => {
|
|
220
220
|
var _a, _b, _c, _d;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
if (oldSubSchema.$ref) {
|
|
229
|
-
if ((newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref) !== oldSubSchema.$ref) {
|
|
230
|
-
breakingChanges.push(`${path}/$ref is changed from ${oldSubSchema.$ref} to ${newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.$ref}`);
|
|
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}`);
|
|
231
226
|
}
|
|
232
227
|
}
|
|
233
|
-
|
|
234
|
-
if (
|
|
235
|
-
|
|
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
|
+
}
|
|
236
233
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (!((_a = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.enum) === null || _a === void 0 ? void 0 : _a.includes(enumValue))) {
|
|
241
|
-
breakingChanges.push(`${path}/enum doesn't have ${enumValue} anymore`);
|
|
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}`);
|
|
242
237
|
}
|
|
243
238
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
+
}
|
|
248
245
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
+
}
|
|
253
250
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
+
}
|
|
258
255
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
}
|
|
263
260
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (((_c = newSubSchema === null || newSubSchema === void 0 ? void 0 : newSubSchema.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) == null) {
|
|
268
|
-
breakingChanges.push(`${path}/properties doesn't have ${propertyName}`);
|
|
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}`);
|
|
269
264
|
}
|
|
270
265
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
+
}
|
|
276
271
|
}
|
|
277
272
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
+
}
|
|
282
279
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
:
|
|
292
|
-
|
|
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
|
+
}
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-machete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-alpha-1ffe1fa37.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@graphql-mesh/cross-helpers": "0.1.2",
|
|
7
|
-
"@graphql-mesh/utils": "0.34.
|
|
7
|
+
"@graphql-mesh/utils": "0.34.3-alpha-1ffe1fa37.0",
|
|
8
8
|
"@graphql-tools/utils": "8.6.9",
|
|
9
9
|
"@json-schema-tools/meta-schema": "1.6.19",
|
|
10
10
|
"cross-undici-fetch": "0.3.0",
|
|
11
|
-
"json-
|
|
11
|
+
"json-pointer": "0.6.2",
|
|
12
12
|
"to-json-schema": "0.2.5",
|
|
13
13
|
"tslib": "^2.3.1",
|
|
14
14
|
"url-join": "4.0.1"
|