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

@karmaniverous/entity-manager

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@karmaniverous/entity-manager - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

2

dist/default/lib/EntityManager/EntityManager.js

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

...properties,
...decode(index[component])
...(decode(index[component])?.groups ?? [])
};

@@ -155,0 +155,0 @@ }, {});

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

const validatorResult = (0, _jsonschema.validate)(value, configSchema);
if (!validatorResult.valid) {
validatorResult.errors.forEach(error => this.logger.error(error.message));
throw new Error(validatorResult.errors);
}
if (!validatorResult.valid) throw new Error(validatorResult.errors);

@@ -228,7 +225,3 @@ // Conform config.

const invalidIndexComponents = (0, _difference2.default)(index, (0, _keys2.default)(keys));
if (invalidIndexComponents.length) {
const message = `${entityToken} index '${indexToken}' components '${invalidIndexComponents}' are not entity keys.`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (invalidIndexComponents.length) throw new Error(`${entityToken} index '${indexToken}' components '${invalidIndexComponents}' are not entity keys.`);else return false;
});

@@ -244,14 +237,7 @@

const validatorResult = (0, _jsonschema.validate)(keys[key], keySchema);
if (!validatorResult.valid) {
validatorResult.errors.forEach(error => this.logger.error(error.message));
throw new Error(validatorResult.errors);
}
if (!validatorResult.valid) throw new Error(validatorResult.errors);
const {
decode
} = keys[key];
if (!(0, _isUndefined2.default)(decode) && !(0, _isFunction2.default)(decode)) {
const message = `entity ${entityKey} key '${key}' decode must be a function or undefined.`;
this.logger.error(message);
throw new Error(message);
}
if (!(0, _isUndefined2.default)(decode) && !(0, _isFunction2.default)(decode)) throw new Error(`entity ${entityKey} key '${key}' decode must be a function or undefined.`);
});

@@ -263,45 +249,21 @@

const [lastBump, lastValue] = i ? c[i - 1] : [];
if (value <= lastValue) {
const message = `${entityToken} sharding bumps do not monotonically increase from '${lastBump}: ${lastValue}' to '${bump}: ${value}'.)`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (value <= lastValue) throw new Error(`${entityToken} sharding bumps do not monotonically increase from '${lastBump}: ${lastValue}' to '${bump}: ${value}'.)`);else return false;
});
// Validate sharding entityKey is a function or undefined.
if (!(0, _isNil2.default)(entityKey) && !(0, _isFunction2.default)(entityKey)) {
const message = `${entityToken} sharding entityKey must be a function or nil`;
this.logger.error(message);
throw new Error(message);
}
if (!(0, _isNil2.default)(entityKey) && !(0, _isFunction2.default)(entityKey)) throw new Error(`${entityToken} sharding entityKey must be a function or nil`);
// Validate sharding nibbles do not exceed 32 bits.
if (nibbles * nibbleBits > 32) {
const message = `${entityToken} nibbles (${nibbles} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`;
this.logger.error(message);
throw new Error(message);
}
if (nibbles * nibbleBits > 32) throw new Error(`${entityToken} nibbles (${nibbles} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`);
// Validate sharding nibbles are less than first bump value.
const firstBumpValue = (0, _map2.default)(bumps)[0];
if (nibbles >= firstBumpValue) {
const message = `${entityToken} nibbles (${nibbles}) not less than minimum bump value (${firstBumpValue})`;
this.logger.error(message);
throw new Error(message);
}
if (nibbles >= firstBumpValue) throw new Error(`${entityToken} nibbles (${nibbles}) not less than minimum bump value (${firstBumpValue})`);
// Validate last bump value does not exceed 32 bits.
const lastBumpValue = (0, _map2.default)(bumps).slice(-1);
if (lastBumpValue * nibbleBits > 32) {
const message = `${entityToken} maximum bump value (${lastBumpValue} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`;
this.logger.error(message);
throw new Error(message);
}
if (lastBumpValue * nibbleBits > 32) throw new Error(`${entityToken} maximum bump value (${lastBumpValue} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`);
// Validate sharding timestamp is a function or undefined.
if (!(0, _isNil2.default)(timestamp) && !(0, _isFunction2.default)(timestamp)) {
const message = `${entityToken} sharding timestamp must be a function or nil.`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (!(0, _isNil2.default)(timestamp) && !(0, _isFunction2.default)(timestamp)) throw new Error(`${entityToken} sharding timestamp must be a function or nil.`);else return false;
});

@@ -344,7 +306,3 @@ _classPrivateFieldSet(this, _config, conformedConfig);

} = this.getEntityConfig(entityToken);
if (!(0, _has2.default)(indexes, indexToken)) {
const message = `Index '${indexToken}' does not exist for entity '${entityToken}'.`;
this.logger.error(message);
throw new Error(message);
}
if (!(0, _has2.default)(indexes, indexToken)) throw new Error(`Index '${indexToken}' does not exist for entity '${entityToken}'.`);
return indexes[indexToken];

@@ -356,7 +314,3 @@ }

} = this.getEntityConfig(entityToken);
if (!(0, _has2.default)(keys, keyToken)) {
const message = `Key '${keyToken}' does not exist for entity '${entityToken}'.`;
this.logger.error(message);
throw new Error(message);
}
if (!(0, _has2.default)(keys, keyToken)) throw new Error(`Key '${keyToken}' does not exist for entity '${entityToken}'.`);
return keys[keyToken];

@@ -441,7 +395,3 @@ }

validateEntityToken(entityToken) {
if (!this.config.entities[entityToken]) {
const message = `Invalid entityToken: ${entityToken}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!this.config.entities[entityToken]) throw new Error(`Invalid entityToken: ${entityToken}`);else return true;
}

@@ -456,7 +406,3 @@

validateItem(item) {
if (!(0, _isPlainObject2.default)(item)) {
const message = `Invalid item: ${item}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!(0, _isPlainObject2.default)(item)) throw new Error(`Invalid item: ${item}`);else return true;
}

@@ -473,7 +419,3 @@

this.validateEntityToken(entityToken);
if (!this.config.entities[entityToken].keys[keyToken]) {
const message = `Invalid entity ${entityToken} keyToken: ${keyToken}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!this.config.entities[entityToken].keys[keyToken]) throw new Error(`Invalid entity ${entityToken} keyToken: ${keyToken}`);else return true;
}

@@ -480,0 +422,0 @@

@@ -120,3 +120,3 @@ /**

return { ...properties, ...decode(index[component]) };
return { ...properties, ...(decode(index[component])?.groups ?? []) };
}, {});

@@ -123,0 +123,0 @@

@@ -127,8 +127,3 @@ import { validate } from 'jsonschema';

const validatorResult = validate(value, configSchema);
if (!validatorResult.valid) {
validatorResult.errors.forEach((error) =>
this.logger.error(error.message)
);
throw new Error(validatorResult.errors);
}
if (!validatorResult.valid) throw new Error(validatorResult.errors);

@@ -179,7 +174,7 @@ // Conform config.

const invalidIndexComponents = _.difference(index, _.keys(keys));
if (invalidIndexComponents.length) {
const message = `${entityToken} index '${indexToken}' components '${invalidIndexComponents}' are not entity keys.`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (invalidIndexComponents.length)
throw new Error(
`${entityToken} index '${indexToken}' components '${invalidIndexComponents}' are not entity keys.`
);
else return false;
});

@@ -193,15 +188,9 @@

const validatorResult = validate(keys[key], keySchema);
if (!validatorResult.valid) {
validatorResult.errors.forEach((error) =>
this.logger.error(error.message)
);
throw new Error(validatorResult.errors);
}
if (!validatorResult.valid) throw new Error(validatorResult.errors);
const { decode } = keys[key];
if (!_.isUndefined(decode) && !_.isFunction(decode)) {
const message = `entity ${entityKey} key '${key}' decode must be a function or undefined.`;
this.logger.error(message);
throw new Error(message);
}
if (!_.isUndefined(decode) && !_.isFunction(decode))
throw new Error(
`entity ${entityKey} key '${key}' decode must be a function or undefined.`
);
});

@@ -212,45 +201,41 @@

const [lastBump, lastValue] = i ? c[i - 1] : [];
if (value <= lastValue) {
const message = `${entityToken} sharding bumps do not monotonically increase from '${lastBump}: ${lastValue}' to '${bump}: ${value}'.)`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (value <= lastValue)
throw new Error(
`${entityToken} sharding bumps do not monotonically increase from '${lastBump}: ${lastValue}' to '${bump}: ${value}'.)`
);
else return false;
});
// Validate sharding entityKey is a function or undefined.
if (!_.isNil(entityKey) && !_.isFunction(entityKey)) {
const message = `${entityToken} sharding entityKey must be a function or nil`;
this.logger.error(message);
throw new Error(message);
}
if (!_.isNil(entityKey) && !_.isFunction(entityKey))
throw new Error(
`${entityToken} sharding entityKey must be a function or nil`
);
// Validate sharding nibbles do not exceed 32 bits.
if (nibbles * nibbleBits > 32) {
const message = `${entityToken} nibbles (${nibbles} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`;
this.logger.error(message);
throw new Error(message);
}
if (nibbles * nibbleBits > 32)
throw new Error(
`${entityToken} nibbles (${nibbles} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`
);
// Validate sharding nibbles are less than first bump value.
const firstBumpValue = _.map(bumps)[0];
if (nibbles >= firstBumpValue) {
const message = `${entityToken} nibbles (${nibbles}) not less than minimum bump value (${firstBumpValue})`;
this.logger.error(message);
throw new Error(message);
}
if (nibbles >= firstBumpValue)
throw new Error(
`${entityToken} nibbles (${nibbles}) not less than minimum bump value (${firstBumpValue})`
);
// Validate last bump value does not exceed 32 bits.
const lastBumpValue = _.map(bumps).slice(-1);
if (lastBumpValue * nibbleBits > 32) {
const message = `${entityToken} maximum bump value (${lastBumpValue} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`;
this.logger.error(message);
throw new Error(message);
}
if (lastBumpValue * nibbleBits > 32)
throw new Error(
`${entityToken} maximum bump value (${lastBumpValue} nibbles at ${nibbleBits} nibbleBits) exceed 32 bits`
);
// Validate sharding timestamp is a function or undefined.
if (!_.isNil(timestamp) && !_.isFunction(timestamp)) {
const message = `${entityToken} sharding timestamp must be a function or nil.`;
this.logger.error(message);
throw new Error(message);
} else return false;
if (!_.isNil(timestamp) && !_.isFunction(timestamp))
throw new Error(
`${entityToken} sharding timestamp must be a function or nil.`
);
else return false;
}

@@ -295,7 +280,6 @@ );

if (!_.has(indexes, indexToken)) {
const message = `Index '${indexToken}' does not exist for entity '${entityToken}'.`;
this.logger.error(message);
throw new Error(message);
}
if (!_.has(indexes, indexToken))
throw new Error(
`Index '${indexToken}' does not exist for entity '${entityToken}'.`
);

@@ -308,7 +292,6 @@ return indexes[indexToken];

if (!_.has(keys, keyToken)) {
const message = `Key '${keyToken}' does not exist for entity '${entityToken}'.`;
this.logger.error(message);
throw new Error(message);
}
if (!_.has(keys, keyToken))
throw new Error(
`Key '${keyToken}' does not exist for entity '${entityToken}'.`
);

@@ -407,7 +390,5 @@ return keys[keyToken];

validateEntityToken(entityToken) {
if (!this.config.entities[entityToken]) {
const message = `Invalid entityToken: ${entityToken}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!this.config.entities[entityToken])
throw new Error(`Invalid entityToken: ${entityToken}`);
else return true;
}

@@ -422,7 +403,4 @@

validateItem(item) {
if (!_.isPlainObject(item)) {
const message = `Invalid item: ${item}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!_.isPlainObject(item)) throw new Error(`Invalid item: ${item}`);
else return true;
}

@@ -440,7 +418,5 @@

if (!this.config.entities[entityToken].keys[keyToken]) {
const message = `Invalid entity ${entityToken} keyToken: ${keyToken}`;
this.logger.error(message);
throw new Error(message);
} else return true;
if (!this.config.entities[entityToken].keys[keyToken])
throw new Error(`Invalid entity ${entityToken} keyToken: ${keyToken}`);
else return true;
}

@@ -447,0 +423,0 @@

{
"name": "@karmaniverous/entity-manager",
"version": "2.1.1",
"version": "2.1.2",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

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