Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-diff

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-diff - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

commitlint.config.js

15

CHANGELOG.md

@@ -0,1 +1,16 @@

<a name="0.16.0"></a>
# [0.16.0](https://bitbucket.org/atlassian/json-schema-diff/compare/0.15.0...0.16.0) (2020-08-14)
### Bug Fixes
* issue when schema property names matched functions in object.prototype ([50e2fa3](https://bitbucket.org/atlassian/json-schema-diff/commits/50e2fa3)), closes [#2](https://bitbucket.org/atlassian/json-schema-diff/issue/2)
### Features
* add support for string maxLength and minLength ([cc41c09](https://bitbucket.org/atlassian/json-schema-diff/commits/cc41c09))
<a name="0.15.0"></a>

@@ -2,0 +17,0 @@ # [0.15.0](https://bitbucket.org/atlassian/json-schema-diff/compare/0.14.0...0.15.0) (2020-01-24)

2

CONTRIBUTING.md

@@ -62,3 +62,3 @@ # Contributing

1. Verify latest node LTS version is used, otherwise bump it in `.nvmrc`.
2. In `bitbucket-pipelines.yml` update build steps to use the latest version of all currently supported major releases of node, e.g. the latest 10.x, 12.x, etc. See https://nodejs.org/en/about/releases/ for version details.
2. In `bitbucket-pipelines.yml` update each build step to use the latest version of node for that step's major release. e.g. Step 1 should use the latest 8.x, Step 2 the latest 10.x etc. See https://nodejs.org/en/about/releases/ for version details.
3. Run `nvm install`.

@@ -65,0 +65,0 @@ 4. Run: `npx npm-check -u` and follow the instructions

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -20,3 +21,3 @@ });

.description('Finds differences between two json schema files')
.action((sourceSchemaFile, destinationSchemaFile) => __awaiter(this, void 0, void 0, function* () {
.action((sourceSchemaFile, destinationSchemaFile) => __awaiter(void 0, void 0, void 0, function* () {
try {

@@ -23,0 +24,0 @@ yield jsonSchemaDiff.diffFiles(sourceSchemaFile, destinationSchemaFile);

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -15,3 +16,3 @@ });

const validate_schemas_1 = require("./diff-schemas/validate-schemas");
exports.diffSchemas = (sourceSchema, destinationSchema) => __awaiter(this, void 0, void 0, function* () {
exports.diffSchemas = (sourceSchema, destinationSchema) => __awaiter(void 0, void 0, void 0, function* () {
const [dereferencedSourceSchema, dereferencedDestinationSchema] = yield Promise.all([

@@ -18,0 +19,0 @@ dereference_schema_1.dereferenceSchema(sourceSchema), dereference_schema_1.dereferenceSchema(destinationSchema)

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -12,3 +13,3 @@ });

const RefParser = require("json-schema-ref-parser");
exports.dereferenceSchema = (schema) => __awaiter(this, void 0, void 0, function* () {
exports.dereferenceSchema = (schema) => __awaiter(void 0, void 0, void 0, function* () {
const refParser = new RefParser();

@@ -15,0 +16,0 @@ return typeof schema === 'boolean'

@@ -28,4 +28,6 @@ "use strict";

maxItems: parseNumericKeyword(schema.maxItems, keyword_defaults_1.defaultMaxItems),
maxLength: parseNumericKeyword(schema.maxLength, keyword_defaults_1.defaultMaxLength),
maxProperties: parseNumericKeyword(schema.maxProperties, keyword_defaults_1.defaultMaxProperties),
minItems: parseNumericKeyword(schema.minItems, keyword_defaults_1.defaultMinItems),
minLength: parseNumericKeyword(schema.minLength, keyword_defaults_1.defaultMinLength),
minProperties: parseNumericKeyword(schema.minProperties, keyword_defaults_1.defaultMinProperties),

@@ -32,0 +34,0 @@ properties: parseSchemaProperties(schema.properties),

@@ -17,3 +17,3 @@ "use strict";

}
return array_subset_1.createArraySubsetFromConfig(Object.assign({}, arraySetParsedKeywords, { not: [] }));
return array_subset_1.createArraySubsetFromConfig(Object.assign(Object.assign({}, arraySetParsedKeywords), { not: [] }));
};

@@ -20,0 +20,0 @@ exports.createArraySet = (arraySetParsedKeywords) => {

@@ -6,2 +6,3 @@ "use strict";

const create_object_set_1 = require("./create-object-set");
const create_string_set_1 = require("./create-string-set");
const create_type_set_1 = require("./create-type-set");

@@ -15,5 +16,5 @@ exports.createJsonSetFromParsedSchemaKeywords = (parsedSchemaKeywords) => json_set_1.createJsonSetFromConfig({

object: create_object_set_1.createObjectSet(parsedSchemaKeywords),
string: create_type_set_1.createTypeSet('string', parsedSchemaKeywords.type)
string: create_string_set_1.createStringSet(parsedSchemaKeywords)
});
exports.createAllJsonSet = () => json_set_1.allJsonSet;
exports.createEmptyJsonSet = () => json_set_1.emptyJsonSet;

@@ -10,4 +10,4 @@ "use strict";

// tslint:disable:cyclomatic-complexity
const everyPropertyIsAll = Object.keys(objectSetParsedKeywords.properties)
.every((propertyName) => objectSetParsedKeywords.properties[propertyName].type === 'all');
const everyPropertyIsAll = Object.values(objectSetParsedKeywords.properties)
.every((propertySet) => propertySet.type === 'all');
return everyPropertyIsAll

@@ -26,3 +26,3 @@ && _.isEqual(objectSetParsedKeywords.required, keyword_defaults_1.defaultRequired)

}
return object_subset_1.createObjectSubsetFromConfig(Object.assign({}, objectSetParsedKeywords, { not: [] }));
return object_subset_1.createObjectSubsetFromConfig(Object.assign(Object.assign({}, objectSetParsedKeywords), { not: [] }));
};

@@ -29,0 +29,0 @@ exports.createObjectSet = (objectSetParsedKeywords) => {

@@ -23,3 +23,3 @@ "use strict";

const mergeCoreRepresentationJsonSchemas = (schema, otherSchema) => {
const mergedSchema = Object.assign({}, schema, otherSchema, { type: mergeTypes(schema, otherSchema) });
const mergedSchema = Object.assign(Object.assign(Object.assign({}, schema), otherSchema), { type: mergeTypes(schema, otherSchema) });
if (schema.not && otherSchema.not) {

@@ -26,0 +26,0 @@ mergedSchema.not = mergeCoreRepresentationJsonSchemas(toCoreRepresentationJsonSchema(schema.not), toCoreRepresentationJsonSchema(otherSchema.not));

@@ -9,2 +9,4 @@ "use strict";

exports.defaultRequired = [];
exports.defaultMaxLength = Infinity;
exports.defaultMinLength = 0;
exports.defaultTypes = ['array', 'boolean', 'integer', 'null', 'number', 'object', 'string'];

@@ -9,2 +9,2 @@ "use strict";

const getMinItemsSchema = (config) => config.minItems === keyword_defaults_1.defaultMinItems ? {} : { minItems: config.minItems };
exports.arraySubsetConfigToJsonSchema = (config) => (Object.assign({ type: 'array' }, getItemsSchema(config), getMaxItemsSchema(config), getMinItemsSchema(config), getNotSchema(config)));
exports.arraySubsetConfigToJsonSchema = (config) => (Object.assign(Object.assign(Object.assign(Object.assign({ type: 'array' }, getItemsSchema(config)), getMaxItemsSchema(config)), getMinItemsSchema(config)), getNotSchema(config)));

@@ -14,8 +14,8 @@ "use strict";

if (maxItemsAllowsNoItems(config)) {
return Object.assign({}, config, { items: json_set_1.emptyJsonSet, maxItems: keyword_defaults_1.defaultMaxItems });
return Object.assign(Object.assign({}, config), { items: json_set_1.emptyJsonSet, maxItems: keyword_defaults_1.defaultMaxItems });
}
if (notItemsDisallowsEmptyArrays(config)) {
return Object.assign({}, config, { not: [], minItems: 1 });
return Object.assign(Object.assign({}, config), { not: [], minItems: 1 });
}
return config;
};

@@ -5,4 +5,3 @@ "use strict";

const isMinPropertiesBiggerThanDefinedProperties = (config) => {
const numberOfDefinedPropertiesInSchema = Object.keys(config.properties)
.map((propertyName) => config.properties[propertyName])
const numberOfDefinedPropertiesInSchema = Object.values(config.properties)
.filter((propertySchema) => propertySchema.type !== 'empty')

@@ -9,0 +8,0 @@ .length;

@@ -20,2 +20,2 @@ "use strict";

const getRequiredSchema = (config) => config.required.length === 0 ? {} : { required: config.required };
exports.objectSubsetConfigToJsonSchema = (config) => (Object.assign({}, getAdditionalPropertiesSchema(config), getMaxPropertiesSchema(config), getMinPropertiesSchema(config), getNotSchema(config), getPropertiesSchema(config), getRequiredSchema(config), { type: 'object' }));
exports.objectSubsetConfigToJsonSchema = (config) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, getAdditionalPropertiesSchema(config)), getMaxPropertiesSchema(config)), getMinPropertiesSchema(config)), getNotSchema(config)), getPropertiesSchema(config)), getRequiredSchema(config)), { type: 'object' }));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPropertyNames = (config) => Object.keys(config.properties);
exports.getPropertySet = (config, propertyName) => config.properties[propertyName] || config.additionalProperties;
exports.getPropertySet = (config, propertyName) => Object.getOwnPropertyNames(config.properties).includes(propertyName)
? config.properties[propertyName]
: config.additionalProperties;

@@ -16,8 +16,8 @@ "use strict";

if (maxPropertiesAllowsNoProperties(config)) {
return Object.assign({}, config, { maxProperties: keyword_defaults_1.defaultMaxProperties, additionalProperties: json_set_1.emptyJsonSet });
return Object.assign(Object.assign({}, config), { maxProperties: keyword_defaults_1.defaultMaxProperties, additionalProperties: json_set_1.emptyJsonSet });
}
if (notDisallowsObjectsWithNoProperties(config)) {
return Object.assign({}, config, { not: [], minProperties: 1 });
return Object.assign(Object.assign({}, config), { not: [], minProperties: 1 });
}
return config;
};
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

@@ -98,3 +98,3 @@ 'use strict';

const lintCommits = () =>
utilities.exec('./node_modules/.bin/conventional-changelog-lint --from=HEAD~20 --preset angular');
utilities.exec('./node_modules/.bin/commitlint --from=HEAD~20 --preset angular');

@@ -101,0 +101,0 @@ const lintTypescript = () =>

@@ -29,4 +29,4 @@ # Json Schema Diff Supported Keywords

| format | no |
| maxLength | no |
| minLength | no |
| maxLength | yes |
| minLength | yes |
| pattern | no |

@@ -33,0 +33,0 @@

@@ -9,4 +9,6 @@ import {CoreSchemaMetaSchema, JsonSchema, JsonSchemaMap, SimpleTypes} from 'json-schema-spec-types';

defaultMaxItems,
defaultMaxLength,
defaultMaxProperties,
defaultMinItems,
defaultMinLength,
defaultMinProperties,

@@ -51,4 +53,6 @@ defaultRequired,

maxItems: parseNumericKeyword(schema.maxItems, defaultMaxItems),
maxLength: parseNumericKeyword(schema.maxLength, defaultMaxLength),
maxProperties: parseNumericKeyword(schema.maxProperties, defaultMaxProperties),
minItems: parseNumericKeyword(schema.minItems, defaultMinItems),
minLength: parseNumericKeyword(schema.minLength, defaultMinLength),
minProperties: parseNumericKeyword(schema.minProperties, defaultMinProperties),

@@ -55,0 +59,0 @@ properties: parseSchemaProperties(schema.properties),

@@ -7,2 +7,3 @@ import {SimpleTypes} from 'json-schema-spec-types';

import {createObjectSet} from './create-object-set';
import {createStringSet} from './create-string-set';
import {createTypeSet} from './create-type-set';

@@ -14,4 +15,6 @@

maxItems: number;
maxLength: number;
maxProperties: number;
minItems: number;
minLength: number;
minProperties: number;

@@ -31,3 +34,3 @@ properties: ParsedPropertiesKeyword;

object: createObjectSet(parsedSchemaKeywords),
string: createTypeSet('string', parsedSchemaKeywords.type)
string: createStringSet(parsedSchemaKeywords)
});

@@ -34,0 +37,0 @@

@@ -21,4 +21,4 @@ import {SimpleTypes} from 'json-schema-spec-types';

// tslint:disable:cyclomatic-complexity
const everyPropertyIsAll = Object.keys(objectSetParsedKeywords.properties)
.every((propertyName) => objectSetParsedKeywords.properties[propertyName].type === 'all');
const everyPropertyIsAll = Object.values(objectSetParsedKeywords.properties)
.every((propertySet) => propertySet.type === 'all');

@@ -25,0 +25,0 @@ return everyPropertyIsAll

@@ -10,2 +10,4 @@ import {SimpleTypes} from 'json-schema-spec-types';

export const defaultRequired: string[] = [];
export const defaultMaxLength: number = Infinity;
export const defaultMinLength: number = 0;
export const defaultTypes: SimpleTypes[] = ['array', 'boolean', 'integer', 'null', 'number', 'object', 'string'];
import {getPropertySet, ObjectSubsetConfig} from './object-subset-config';
const isMinPropertiesBiggerThanDefinedProperties = (config: ObjectSubsetConfig): boolean => {
const numberOfDefinedPropertiesInSchema = Object.keys(config.properties)
.map((propertyName) => config.properties[propertyName])
const numberOfDefinedPropertiesInSchema = Object.values(config.properties)
.filter((propertySchema) => propertySchema.type !== 'empty')

@@ -7,0 +6,0 @@ .length;

@@ -19,2 +19,4 @@ import {Set} from '../../set';

export const getPropertySet = (config: ObjectSubsetConfig, propertyName: string): Set<'json'> =>
config.properties[propertyName] || config.additionalProperties;
Object.getOwnPropertyNames(config.properties).includes(propertyName)
? config.properties[propertyName]
: config.additionalProperties;
{
"name": "json-schema-diff",
"version": "0.15.0",
"version": "0.16.0",
"description": "A language agnostic CLI tool and nodejs api to identify differences between two json schema files.",

@@ -38,33 +38,34 @@ "bin": {

"devDependencies": {
"@types/jasmine": "^3.5.0",
"@types/json-schema": "^7.0.4",
"@types/lodash": "^4.14.149",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@types/jasmine": "^3.5.11",
"@types/json-schema": "^7.0.5",
"@types/lodash": "^4.14.158",
"@types/node": "^12",
"@types/verror": "^1.10.3",
"@types/verror": "^1.10.4",
"ansi-colors": "^4.1.1",
"conventional-changelog-lint": "^2.1.1",
"gulp": "^4.0.2",
"gulp-bump": "^3.1.1",
"gulp-bump": "^3.2.0",
"gulp-clean": "^0.4.0",
"gulp-cli": "^2.0.1",
"gulp-conventional-changelog": "^2.0.29",
"gulp-cli": "^2.3.0",
"gulp-conventional-changelog": "^2.0.32",
"gulp-filter": "^6.0.0",
"gulp-git": "^2.10.0",
"gulp-git": "^2.10.1",
"gulp-jasmine": "^4.0.0",
"gulp-tslint": "^8.1.4",
"gulp-typescript": "^5.0.1",
"minimist": "^1.2.0",
"minimist": "^1.2.5",
"run-sequence": "^2.2.1",
"tslint": "5.20.1",
"typescript": "3.7.4"
"tslint": "6.1.2",
"typescript": "3.9.7"
},
"types": "lib/api-types.d.ts",
"dependencies": {
"ajv": "^6.10.2",
"commander": "^4.1.0",
"json-schema-ref-parser": "^7.1.3",
"ajv": "^6.12.3",
"commander": "^5.0.0",
"json-schema-ref-parser": "^9.0.6",
"json-schema-spec-types": "^0.1.2",
"lodash": "^4.17.15",
"lodash": "^4.17.19",
"verror": "^1.10.0"
}
}

@@ -11,4 +11,5 @@ {

"no-default-export": true,
"member-access": [true, "check-constructor"]
"member-access": [true, "check-constructor"],
"array-type": [true, "array-simple"]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc