New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@allbin/entity-logic

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allbin/entity-logic - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

116

lib/index.js

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

exports.validateSchema = exports.EntityLogic = void 0;
var luxon_1 = require("luxon");
var operators_1 = __importDefault(require("./operators"));

@@ -112,3 +113,116 @@ var executeCondition = function (schemaPropsByKey, entities, condition) {

}
// FIXME: validate filter values
if (condition.operator === 'known' ||
condition.operator === 'unknown' ||
condition.operator === 'true' ||
condition.operator === 'false') {
if (typeof condition.value !== 'undefined') {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
}
if (condition.type === 'number') {
switch (condition.operator) {
case 'eq':
case 'neq':
case 'gt':
case 'gte':
case 'lt':
case 'lte':
if (typeof condition.value !== 'number') {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
case 'between':
case 'not_between':
case 'none_of':
case 'any_of':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) { return typeof v !== 'number'; })) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
else if (condition.type === 'string') {
switch (condition.operator) {
case 'eq':
case 'neq':
case 'matches':
case 'not_matches':
if (typeof condition.value !== 'string') {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
case 'none_of':
case 'any_of':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) { return typeof v !== 'string'; })) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
else if (condition.type === 'enum') {
switch (condition.operator) {
case 'eq':
case 'neq':
case 'matches':
case 'not_matches':
if (typeof condition.value !== 'string') {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
case 'none_of':
case 'any_of':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) {
return typeof v !== 'string' ||
!prop.alternatives ||
!prop.alternatives.includes(v);
})) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
else if (condition.type === 'date') {
switch (condition.operator) {
case 'before':
case 'after':
if (!luxon_1.DateTime.isDateTime(condition.value)) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
case 'between':
case 'not_between':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) { return !luxon_1.DateTime.isDateTime(v); })) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
else if (condition.type === 'array:number') {
switch (condition.operator) {
case 'none_of':
case 'any_of':
case 'all_of':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) { return typeof v !== 'number'; })) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
else if (condition.type === 'array:string') {
switch (condition.operator) {
case 'none_of':
case 'any_of':
case 'all_of':
if (!Array.isArray(condition.value) ||
condition.value.some(function (v) { return typeof v !== 'string'; })) {
throw new Error("Invalid condition value for " + condition.type + ":" + condition.operator);
}
break;
}
}
return op;

@@ -115,0 +229,0 @@ };

2

package.json
{
"name": "@allbin/entity-logic",
"version": "0.3.2",
"version": "0.4.0",
"description": "Logic solver for mobilix filters",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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