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

@coveo/bueno

Package Overview
Dependencies
Maintainers
13
Versions
439
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coveo/bueno - npm Package Compare versions

Comparing version 0.34.6 to 0.34.7

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [0.34.7](https://github.com/coveo/ui-kit/compare/@coveo/bueno@0.34.6...@coveo/bueno@0.34.7) (2022-03-24)
**Note:** Version bump only for package @coveo/bueno
## [0.34.6](https://github.com/coveo/ui-kit/compare/@coveo/bueno@0.34.5...@coveo/bueno@0.34.6) (2022-03-18)

@@ -8,0 +16,0 @@

618

dist/browser/bueno.js

@@ -18,48 +18,52 @@ /**

*/
var Bueno = (() => {
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
(function (global, factory) {
const isCommonjs = typeof exports === 'object' && typeof module !== 'undefined';
if (isCommonjs) {
return factory(exports);
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
const isAmd = typeof define === 'function' && define.amd;
// src/index.ts
var src_exports = {};
__export(src_exports, {
ArrayValue: () => ArrayValue,
BooleanValue: () => BooleanValue,
EnumValue: () => EnumValue,
NumberValue: () => NumberValue,
RecordValue: () => RecordValue,
Schema: () => Schema,
SchemaValidationError: () => SchemaValidationError,
StringValue: () => StringValue,
Value: () => Value,
isArray: () => isArray,
isBoolean: () => isBoolean,
isBooleanOrUndefined: () => isBooleanOrUndefined,
isNull: () => isNull,
isNullOrUndefined: () => isNullOrUndefined,
isNumber: () => isNumber,
isNumberOrUndefined: () => isNumberOrUndefined,
isRecord: () => isRecord,
isString: () => isString,
isUndefined: () => isUndefined
});
if (isAmd) {
return define(['exports'], factory);
}
// src/schema.ts
function buildSchemaValidationError(errors, context) {
const message = `
global = typeof globalThis !== 'undefined' ? globalThis : global || self;
factory(global.Bueno = {});
})(this, (function (exports) { 'use strict';
var __defProp = Object.defineProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/index.ts
__export(exports, {
ArrayValue: () => ArrayValue,
BooleanValue: () => BooleanValue,
EnumValue: () => EnumValue,
NumberValue: () => NumberValue,
RecordValue: () => RecordValue,
Schema: () => Schema,
SchemaValidationError: () => SchemaValidationError,
StringValue: () => StringValue,
Value: () => Value,
isArray: () => isArray,
isBoolean: () => isBoolean,
isBooleanOrUndefined: () => isBooleanOrUndefined,
isNull: () => isNull,
isNullOrUndefined: () => isNullOrUndefined,
isNumber: () => isNumber,
isNumberOrUndefined: () => isNumberOrUndefined,
isRecord: () => isRecord,
isString: () => isString,
isUndefined: () => isUndefined
});
// src/schema.ts
function buildSchemaValidationError(errors, context) {
const message = `
The following properties are invalid:

@@ -71,313 +75,311 @@

`;
return new SchemaValidationError(message);
return new SchemaValidationError(message);
}
var SchemaValidationError = class extends Error {
constructor(message) {
super(message);
this.name = "SchemaValidationError";
}
var SchemaValidationError = class extends Error {
constructor(message) {
super(message);
this.name = "SchemaValidationError";
};
var Schema = class {
constructor(definition) {
this.definition = definition;
}
validate(values = {}, message = "") {
const mergedValues = {
...this.default,
...values
};
const errors = [];
for (const property in this.definition) {
const error = this.definition[property].validate(mergedValues[property]);
error && errors.push(`${property}: ${error}`);
}
};
var Schema = class {
constructor(definition) {
this.definition = definition;
if (errors.length) {
throw buildSchemaValidationError(errors, message);
}
validate(values = {}, message = "") {
const mergedValues = {
...this.default,
...values
};
const errors = [];
for (const property in this.definition) {
const error = this.definition[property].validate(mergedValues[property]);
error && errors.push(`${property}: ${error}`);
return mergedValues;
}
get default() {
const defaultValues = {};
for (const property in this.definition) {
const defaultValue = this.definition[property].default;
if (defaultValue !== void 0) {
defaultValues[property] = defaultValue;
}
if (errors.length) {
throw buildSchemaValidationError(errors, message);
}
return mergedValues;
}
get default() {
const defaultValues = {};
for (const property in this.definition) {
const defaultValue = this.definition[property].default;
if (defaultValue !== void 0) {
defaultValues[property] = defaultValue;
}
}
return defaultValues;
return defaultValues;
}
};
// src/values/value.ts
var Value = class {
constructor(baseConfig = {}) {
this.baseConfig = baseConfig;
}
validate(value) {
if (this.baseConfig.required && isNullOrUndefined(value)) {
return "value is required.";
}
};
return null;
}
get default() {
return this.baseConfig.default instanceof Function ? this.baseConfig.default() : this.baseConfig.default;
}
get required() {
return this.baseConfig.required === true;
}
};
function isUndefined(value) {
return value === void 0;
}
function isNull(value) {
return value === null;
}
function isNullOrUndefined(value) {
return isUndefined(value) || isNull(value);
}
// src/values/value.ts
var Value = class {
constructor(baseConfig = {}) {
this.baseConfig = baseConfig;
// src/values/number-value.ts
var NumberValue = class {
constructor(config = {}) {
this.config = config;
this.value = new Value(config);
}
validate(value) {
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
validate(value) {
if (this.baseConfig.required && isNullOrUndefined(value)) {
return "value is required.";
}
return null;
if (!isNumberOrUndefined(value)) {
return "value is not a number.";
}
get default() {
return this.baseConfig.default instanceof Function ? this.baseConfig.default() : this.baseConfig.default;
if (value < this.config.min) {
return `minimum value of ${this.config.min} not respected.`;
}
get required() {
return this.baseConfig.required === true;
if (value > this.config.max) {
return `maximum value of ${this.config.max} not respected.`;
}
};
function isUndefined(value) {
return value === void 0;
return null;
}
function isNull(value) {
return value === null;
get default() {
return this.value.default;
}
function isNullOrUndefined(value) {
return isUndefined(value) || isNull(value);
get required() {
return this.value.required;
}
};
function isNumberOrUndefined(value) {
return isUndefined(value) || isNumber(value);
}
function isNumber(value) {
return typeof value === "number" && !isNaN(value);
}
// src/values/number-value.ts
var NumberValue = class {
constructor(config = {}) {
this.config = config;
this.value = new Value(config);
// src/values/boolean-value.ts
var BooleanValue = class {
constructor(config = {}) {
this.value = new Value(config);
}
validate(value) {
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
validate(value) {
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
if (!isNumberOrUndefined(value)) {
return "value is not a number.";
}
if (value < this.config.min) {
return `minimum value of ${this.config.min} not respected.`;
}
if (value > this.config.max) {
return `maximum value of ${this.config.max} not respected.`;
}
return null;
if (!isBooleanOrUndefined(value)) {
return "value is not a boolean.";
}
get default() {
return this.value.default;
}
get required() {
return this.value.required;
}
};
function isNumberOrUndefined(value) {
return isUndefined(value) || isNumber(value);
return null;
}
function isNumber(value) {
return typeof value === "number" && !isNaN(value);
get default() {
return this.value.default;
}
get required() {
return this.value.required;
}
};
function isBooleanOrUndefined(value) {
return isUndefined(value) || isBoolean(value);
}
function isBoolean(value) {
return typeof value === "boolean";
}
// src/values/boolean-value.ts
var BooleanValue = class {
constructor(config = {}) {
this.value = new Value(config);
// src/values/string-value.ts
var urlRegex = /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;
var StringValue = class {
constructor(config = {}) {
this.config = {
emptyAllowed: true,
url: false,
...config
};
this.value = new Value(this.config);
}
validate(value) {
const { emptyAllowed, url, regex, constrainTo } = this.config;
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
validate(value) {
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
if (!isBooleanOrUndefined(value)) {
return "value is not a boolean.";
}
if (isUndefined(value)) {
return null;
}
get default() {
return this.value.default;
if (!isString(value)) {
return "value is not a string.";
}
get required() {
return this.value.required;
if (!emptyAllowed && !value.length) {
return "value is an empty string.";
}
};
function isBooleanOrUndefined(value) {
return isUndefined(value) || isBoolean(value);
}
function isBoolean(value) {
return typeof value === "boolean";
}
// src/values/string-value.ts
var urlRegex = /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;
var StringValue = class {
constructor(config = {}) {
this.config = {
emptyAllowed: true,
url: false,
...config
};
this.value = new Value(this.config);
if (url && !urlRegex.test(value)) {
return "value is not a valid URL.";
}
validate(value) {
const { emptyAllowed, url, regex, constrainTo } = this.config;
const valueValidation = this.value.validate(value);
if (valueValidation) {
return valueValidation;
}
if (isUndefined(value)) {
return null;
}
if (!isString(value)) {
return "value is not a string.";
}
if (!emptyAllowed && !value.length) {
return "value is an empty string.";
}
if (url && !urlRegex.test(value)) {
return "value is not a valid URL.";
}
if (regex && !regex.test(value)) {
return `value did not match provided regex ${regex}`;
}
if (constrainTo && !constrainTo.includes(value)) {
const values = constrainTo.join(", ");
return `value should be one of: ${values}.`;
}
return null;
if (regex && !regex.test(value)) {
return `value did not match provided regex ${regex}`;
}
get default() {
return this.value.default;
if (constrainTo && !constrainTo.includes(value)) {
const values = constrainTo.join(", ");
return `value should be one of: ${values}.`;
}
get required() {
return this.value.required;
}
};
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
return null;
}
get default() {
return this.value.default;
}
get required() {
return this.value.required;
}
};
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
// src/values/complex-value.ts
var RecordValue = class {
constructor(config = {}) {
this.config = {
options: { required: false },
values: {},
...config
};
// src/values/complex-value.ts
var RecordValue = class {
constructor(config = {}) {
this.config = {
options: { required: false },
values: {},
...config
};
}
validate(input) {
if (isUndefined(input)) {
return this.config.options.required ? "value is required and is currently undefined" : null;
}
validate(input) {
if (isUndefined(input)) {
return this.config.options.required ? "value is required and is currently undefined" : null;
if (!isRecord(input)) {
return "value is not an object";
}
for (const [k, v] of Object.entries(this.config.values)) {
if (v.required && isNullOrUndefined(input[k])) {
return `value does not contain ${k}`;
}
if (!isRecord(input)) {
return "value is not an object";
}
let out = "";
for (const [key, validator] of Object.entries(this.config.values)) {
const value = input[key];
const invalidValue = validator.validate(value);
if (invalidValue !== null) {
out += " " + invalidValue;
}
for (const [k, v] of Object.entries(this.config.values)) {
if (v.required && isNullOrUndefined(input[k])) {
return `value does not contain ${k}`;
}
}
let out = "";
for (const [key, validator] of Object.entries(this.config.values)) {
const value = input[key];
const invalidValue = validator.validate(value);
if (invalidValue !== null) {
out += " " + invalidValue;
}
}
return out === "" ? null : out;
}
get default() {
return void 0;
return out === "" ? null : out;
}
get default() {
return void 0;
}
get required() {
return !!this.config.options.required;
}
};
function isRecord(value) {
return value !== void 0 && typeof value === "object";
}
var ArrayValue = class {
constructor(config = {}) {
this.config = config;
this.value = new Value(this.config);
}
validate(input) {
if (!isNullOrUndefined(input) && !Array.isArray(input)) {
return "value is not an array";
}
get required() {
return !!this.config.options.required;
const invalid = this.value.validate(input);
if (invalid !== null) {
return invalid;
}
};
function isRecord(value) {
return value !== void 0 && typeof value === "object";
}
var ArrayValue = class {
constructor(config = {}) {
this.config = config;
this.value = new Value(this.config);
}
validate(input) {
if (!isNullOrUndefined(input) && !Array.isArray(input)) {
return "value is not an array";
}
const invalid = this.value.validate(input);
if (invalid !== null) {
return invalid;
}
if (isNullOrUndefined(input)) {
return null;
}
if (this.config.max !== void 0 && input.length > this.config.max) {
return `value contains more than ${this.config.max}`;
}
if (this.config.min !== void 0 && input.length < this.config.min) {
return `value contains less than ${this.config.min}`;
}
if (this.config.each !== void 0) {
let out = "";
input.forEach((el) => {
if (this.config.each.required && isNullOrUndefined(el)) {
out = `value is null or undefined: ${input.join(",")}`;
}
const isInvalid = this.validatePrimitiveValue(el, this.config.each);
if (isInvalid !== null) {
out += " " + isInvalid;
}
});
return out === "" ? null : out;
}
if (isNullOrUndefined(input)) {
return null;
}
validatePrimitiveValue(v, validator) {
if (isBoolean(v)) {
return validator.validate(v);
} else if (isString(v)) {
return validator.validate(v);
} else if (isNumber(v)) {
return validator.validate(v);
} else if (isRecord(v)) {
return validator.validate(v);
}
return "value is not a primitive value";
if (this.config.max !== void 0 && input.length > this.config.max) {
return `value contains more than ${this.config.max}`;
}
get default() {
return void 0;
if (this.config.min !== void 0 && input.length < this.config.min) {
return `value contains less than ${this.config.min}`;
}
get required() {
return this.value.required;
if (this.config.each !== void 0) {
let out = "";
input.forEach((el) => {
if (this.config.each.required && isNullOrUndefined(el)) {
out = `value is null or undefined: ${input.join(",")}`;
}
const isInvalid = this.validatePrimitiveValue(el, this.config.each);
if (isInvalid !== null) {
out += " " + isInvalid;
}
});
return out === "" ? null : out;
}
};
function isArray(value) {
return Array.isArray(value);
return null;
}
validatePrimitiveValue(v, validator) {
if (isBoolean(v)) {
return validator.validate(v);
} else if (isString(v)) {
return validator.validate(v);
} else if (isNumber(v)) {
return validator.validate(v);
} else if (isRecord(v)) {
return validator.validate(v);
}
return "value is not a primitive value";
}
get default() {
return void 0;
}
get required() {
return this.value.required;
}
};
function isArray(value) {
return Array.isArray(value);
}
// src/values/enum-value.ts
var EnumValue = class {
constructor(config) {
this.config = config;
this.value = new Value(config);
// src/values/enum-value.ts
var EnumValue = class {
constructor(config) {
this.config = config;
this.value = new Value(config);
}
validate(value) {
const invalid = this.value.validate(value);
if (invalid !== null) {
return invalid;
}
validate(value) {
const invalid = this.value.validate(value);
if (invalid !== null) {
return invalid;
}
if (isUndefined(value)) {
return null;
}
const valueInEnum = Object.values(this.config.enum).find((enumValue) => enumValue === value);
if (!valueInEnum) {
return "value is not in enum.";
}
if (isUndefined(value)) {
return null;
}
get default() {
return this.value.default;
const valueInEnum = Object.values(this.config.enum).find((enumValue) => enumValue === value);
if (!valueInEnum) {
return "value is not in enum.";
}
get required() {
return this.value.required;
}
};
return __toCommonJS(src_exports);
})();
undefined
return null;
}
get default() {
return this.value.default;
}
get required() {
return this.value.required;
}
};
}));

@@ -19,22 +19,11 @@ /**

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
__export(exports, {
ArrayValue: () => ArrayValue,

@@ -60,3 +49,2 @@ BooleanValue: () => BooleanValue,

});
module.exports = __toCommonJS(src_exports);

@@ -63,0 +51,0 @@ // src/schema.ts

@@ -17,3 +17,3 @@ {

"license": "Apache-2.0",
"version": "0.34.6",
"version": "0.34.7",
"files": [

@@ -20,0 +20,0 @@ "dist/"

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