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

@contember/schema-utils

Package Overview
Dependencies
Maintainers
5
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/schema-utils - npm Package Compare versions

Comparing version 0.8.0-alpha.4 to 0.8.0-alpha.5

dist/src/utils/deepCompare.d.ts

1

dist/src/index.d.ts

@@ -8,3 +8,4 @@ import { Schema } from '@contember/schema';

export * from './schemaFilter';
export { deepCompare } from './utils';
export declare const emptySchema: Schema;
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./schemaFilter"), exports);
var utils_1 = require("./utils");
Object.defineProperty(exports, "deepCompare", { enumerable: true, get: function () { return utils_1.deepCompare; } });
exports.emptySchema = {

@@ -23,0 +25,0 @@ model: model_1.emptyModelSchema,

export * from './isIt';
export * from './deepCompare';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./isIt"), exports);
__exportStar(require("./deepCompare"), exports);
//# sourceMappingURL=index.js.map

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

const util_1 = require("util");
const ValidationValidator_1 = require("./ValidationValidator");
const utils_1 = require("../utils");
class SchemaValidator {

@@ -14,6 +16,14 @@ static validate(schema) {

const [model, modelErrors] = modelValidator.validate();
const validSchema = { ...schema, acl, model };
const errors = [...aclErrors, ...modelErrors];
const validationValidator = new ValidationValidator_1.ValidationValidator(schema.model);
const [validation, validationErrors] = validationValidator.validate(schema.validation);
const validSchema = { ...schema, acl, model, validation };
const errors = [...aclErrors, ...modelErrors, ...validationErrors];
if (errors.length === 0 && !util_1.isDeepStrictEqual(validSchema, schema)) {
throw new Error('There is something wrong with a schema validator');
const errors = utils_1.deepCompare(validSchema, schema, []);
let message = 'There is something wrong with a schema validator:';
for (const err of errors) {
message += '\n\t' + err.path.join('.') + ': ' + err.message;
}
message += '\n\nPlease fill a bug report';
throw new Error(message);
}

@@ -20,0 +30,0 @@ return errors;

export declare type UnknownObject = Record<string, unknown>;
export declare function isObject(input: unknown): input is UnknownObject;
export declare function isArray(input: unknown): input is unknown[];
export declare function hasStringProperty<Input extends UnknownObject, Property extends string>(input: Input, property: Property): input is Input & {

@@ -9,2 +10,5 @@ [key in Property]: string;

};
export declare function hasObjectProperty<Input extends UnknownObject, Property extends string>(input: Input, property: Property): input is Input & {
[key in Property]: UnknownObject;
};
export declare function hasArrayProperty<Input extends UnknownObject, Property extends string>(input: Input, property: Property): input is Input & {

@@ -11,0 +15,0 @@ [key in Property]: unknown[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkExtraProperties = exports.everyIs = exports.hasArrayProperty = exports.hasNumberProperty = exports.hasStringProperty = exports.isObject = void 0;
exports.checkExtraProperties = exports.everyIs = exports.hasArrayProperty = exports.hasObjectProperty = exports.hasNumberProperty = exports.hasStringProperty = exports.isArray = exports.isObject = void 0;
function isObject(input) {

@@ -8,2 +8,6 @@ return typeof input === 'object' && input !== null;

exports.isObject = isObject;
function isArray(input) {
return Array.isArray(input);
}
exports.isArray = isArray;
function hasStringProperty(input, property) {

@@ -17,4 +21,8 @@ return typeof input[property] === 'string';

exports.hasNumberProperty = hasNumberProperty;
function hasObjectProperty(input, property) {
return isObject(input[property]);
}
exports.hasObjectProperty = hasObjectProperty;
function hasArrayProperty(input, property) {
return Array.isArray(input[property]);
return isArray(input[property]);
}

@@ -21,0 +29,0 @@ exports.hasArrayProperty = hasArrayProperty;

6

package.json
{
"name": "@contember/schema-utils",
"version": "0.8.0-alpha.4",
"version": "0.8.0-alpha.5",
"license": "Apache-2.0",

@@ -9,3 +9,3 @@ "main": "dist/src/index.js",

"dependencies": {
"@contember/schema": "^0.8.0-alpha.4"
"@contember/schema": "^0.8.0-alpha.5"
},

@@ -16,3 +16,3 @@ "devDependencies": {

},
"gitHead": "4c622600158ead6c971b56393b2716625ac657dc"
"gitHead": "b5cc6249a32f3c16618a9ba8364abf10f85acf6b"
}

@@ -10,2 +10,3 @@ import { Schema } from '@contember/schema'

export * from './schemaFilter'
export { deepCompare } from './utils'

@@ -12,0 +13,0 @@ export const emptySchema: Schema = {

export * from './isIt'
export * from './deepCompare'

@@ -6,2 +6,4 @@ import { Schema } from '@contember/schema'

import { isDeepStrictEqual } from 'util'
import { ValidationValidator } from './ValidationValidator'
import { deepCompare } from '../utils'

@@ -16,7 +18,16 @@ export class SchemaValidator {

const validSchema = { ...schema, acl, model }
const validationValidator = new ValidationValidator(schema.model)
const [validation, validationErrors] = validationValidator.validate(schema.validation)
const errors = [...aclErrors, ...modelErrors]
const validSchema = { ...schema, acl, model, validation }
const errors = [...aclErrors, ...modelErrors, ...validationErrors]
if (errors.length === 0 && !isDeepStrictEqual(validSchema, schema)) {
throw new Error('There is something wrong with a schema validator')
const errors = deepCompare(validSchema, schema, [])
let message = 'There is something wrong with a schema validator:'
for (const err of errors) {
message += '\n\t' + err.path.join('.') + ': ' + err.message
}
message += '\n\nPlease fill a bug report'
throw new Error(message)
}

@@ -23,0 +34,0 @@ return errors

@@ -7,2 +7,6 @@ export type UnknownObject = Record<string, unknown>

export function isArray(input: unknown): input is unknown[] {
return Array.isArray(input)
}
export function hasStringProperty<Input extends UnknownObject, Property extends string>(

@@ -22,2 +26,9 @@ input: Input,

export function hasObjectProperty<Input extends UnknownObject, Property extends string>(
input: Input,
property: Property,
): input is Input & { [key in Property]: UnknownObject } {
return isObject(input[property])
}
export function hasArrayProperty<Input extends UnknownObject, Property extends string>(

@@ -27,3 +38,3 @@ input: Input,

): input is Input & { [key in Property]: unknown[] } {
return Array.isArray(input[property])
return isArray(input[property])
}

@@ -30,0 +41,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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