Huge News!Announcing our $40M Series B led by Abstract Ventures.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.6.1 to 0.6.2

6

lib/index.d.ts
import { Entity, EntitySchema } from './types/schema';
import { Filter, FilterCondition } from './types/filter';
import { Filter, FilterCondition, SerializedFilter, SerializedFilterCondition } from './types/filter';
import { Operator } from './operators';

@@ -10,2 +10,6 @@ interface EntityLogic {

validatePropertiesModifiable: (prev_properties: Record<string, unknown>, properties: Record<string, unknown>) => void;
serializeFilterCondition: (condition: FilterCondition) => SerializedFilterCondition;
unserializeFilterCondition: (condition: SerializedFilterCondition) => FilterCondition;
serializeFilter: (filter: Filter) => SerializedFilter;
unserializeFilter: (filter: SerializedFilter) => Filter;
}

@@ -12,0 +16,0 @@ declare const validateSchema: (schema: EntitySchema) => void;

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -299,2 +310,26 @@ if (k2 === undefined) k2 = k;

};
var serializeFilterCondition = function (condition) {
if (condition.type === 'date') {
if (condition.operator === 'before' || condition.operator === 'after') {
return __assign(__assign({}, condition), { value: condition.value.toISO() });
}
else if (condition.operator === 'between' ||
condition.operator === 'not_between') {
return __assign(__assign({}, condition), { value: condition.value.map(function (c) { return c.toISO(); }) });
}
}
return condition;
};
var unserializeFilterCondition = function (condition) {
if (condition.type === 'date') {
if (condition.operator === 'before' || condition.operator === 'after') {
return __assign(__assign({}, condition), { value: luxon_1.DateTime.fromISO(condition.value) });
}
else if (condition.operator === 'between' ||
condition.operator === 'not_between') {
return __assign(__assign({}, condition), { value: condition.value.map(function (c) { return luxon_1.DateTime.fromISO(c); }) });
}
}
return condition;
};
var EntityLogic = function (schema) {

@@ -318,2 +353,14 @@ validateSchema(schema);

validatePropertiesModifiable: function (prev_properties, properties) { return validatePropertiesModifiable(propsByKey, prev_properties, properties); },
serializeFilterCondition: function (condition) {
return serializeFilterCondition(condition);
},
unserializeFilterCondition: function (condition) {
return unserializeFilterCondition(condition);
},
serializeFilter: function (filter) {
return filter.map(function (fc) { return serializeFilterCondition(fc); });
},
unserializeFilter: function (filter) {
return filter.map(function (fc) { return unserializeFilterCondition(fc); });
},
};

@@ -320,0 +367,0 @@ };

@@ -76,2 +76,13 @@ import { DateTime } from 'luxon';

export declare type FilterConditionDateTime = FilterConditionDateTimeNoArgs | FilterConditionDateTimeSingleArg | FilterConditionDateTimeManyArgs;
export interface FilterConditionSerializedDateTimeSingleArg extends FilterConditionBase {
type: 'date';
operator: 'before' | 'after';
value: string;
}
export interface FilterConditionSerializedDateTimeManyArgs extends FilterConditionBase {
type: 'date';
operator: 'between' | 'not_between';
value: string[];
}
export declare type FilterConditionSerializedDateTime = FilterConditionDateTimeNoArgs | FilterConditionSerializedDateTimeSingleArg | FilterConditionSerializedDateTimeManyArgs;
export interface FilterConditionPhotoNoArg extends FilterConditionBase {

@@ -103,3 +114,5 @@ type: 'photo';

export declare type FilterCondition = FilterConditionBoolean | FilterConditionNumber | FilterConditionString | FilterConditionEnum | FilterConditionDateTime | FilterConditionPhoto | FilterConditionStringArray | FilterConditionNumberArray;
export declare type SerializedFilterCondition = FilterConditionBoolean | FilterConditionNumber | FilterConditionString | FilterConditionEnum | FilterConditionSerializedDateTime | FilterConditionPhoto | FilterConditionStringArray | FilterConditionNumberArray;
export declare type Filter = FilterCondition[];
export declare type SerializedFilter = SerializedFilterCondition[];
export {};

2

package.json
{
"name": "@allbin/entity-logic",
"version": "0.6.1",
"version": "0.6.2",
"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