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

@karmaniverous/entity-manager

Package Overview
Dependencies
Maintainers
0
Versions
101
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 6.10.3 to 6.11.0

18

dist/cjs/EntityManager.js
'use strict';
var tslib = require('tslib');
var radash = require('radash');
var addKeys = require('./addKeys.js');

@@ -64,2 +65,19 @@ var ParsedConfig = require('./ParsedConfig.js');

/**
* Convert an {@link EntityItem | `EntityItem`} into an {@link EntityKey | `EntityKey`}.
*
* @param entityToken - {@link Config | `Config`} `entities` key.
* @param item - {@link EntityItem | `EntityItem`} object.
* @param overwrite - Overwrite existing properties (default `false`).
*
* @returns {@link EntityKey | `EntityKey`} extracted from shallow clone of `item` with updated properties.
*
* @throws `Error` if `entityToken` is invalid.
*/
getPrimaryKey(entityToken, item, overwrite = false) {
const { hashKey, rangeKey } = this.config;
return radash.pick(!overwrite && item[hashKey] && item[rangeKey]
? item
: addKeys.addKeys(this, entityToken, item, overwrite), [this.config.hashKey, this.config.rangeKey]);
}
/**
* Strips generated properties, hash key, and range key from an {@link EntityItem | `EntityItem`} object.

@@ -66,0 +84,0 @@ *

32

dist/index.d.ts

@@ -90,2 +90,12 @@ import { EntityMap, TranscodeMap, ConditionalProperty, Exactify, PropertiesOfType, TranscodableProperties, FlattenEntityMap, Transcodes, SortOrder, MutuallyExclusive, NotNever, DefaultTranscodeMap } from '@karmaniverous/entity-tools';

/**
* Database-facing record key type from a {@link BaseConfigMap | `ConfigMap`} with required hash & range keys.
*
* @typeParam C - {@link ConfigMap | `ConfigMap`} that defines an {@link Config | `EntityManager configuration`}'s {@link EntityMap | `EntityMap`}, key properties, and {@link TranscodeMap | `TranscodeMap`}. If omitted, defaults to {@link BaseConfigMap | `BaseConfigMap`}.
*
* @category EntityClient
* @protected
*/
type EntityKey<C extends BaseConfigMap> = Record<C['HashKey'] | C['RangeKey'], string>;
/**
* Extracts entity tokens from a {@link ConfigMap | `ConfigMap`}.

@@ -538,2 +548,14 @@ *

/**
* Convert an {@link EntityItem | `EntityItem`} into an {@link EntityKey | `EntityKey`}.
*
* @param entityToken - {@link Config | `Config`} `entities` key.
* @param item - {@link EntityItem | `EntityItem`} object.
* @param overwrite - Overwrite existing properties (default `false`).
*
* @returns {@link EntityKey | `EntityKey`} extracted from shallow clone of `item` with updated properties.
*
* @throws `Error` if `entityToken` is invalid.
*/
getPrimaryKey(entityToken: EntityToken<C>, item: EntityItem<C>, overwrite?: boolean): EntityKey<C>;
/**
* Strips generated properties, hash key, and range key from an {@link EntityItem | `EntityItem`} object.

@@ -720,12 +742,2 @@ *

/**
* Database-facing record key type from a {@link BaseConfigMap | `ConfigMap`} with required hash & range keys.
*
* @typeParam C - {@link ConfigMap | `ConfigMap`} that defines an {@link Config | `EntityManager configuration`}'s {@link EntityMap | `EntityMap`}, key properties, and {@link TranscodeMap | `TranscodeMap`}. If omitted, defaults to {@link BaseConfigMap | `BaseConfigMap`}.
*
* @category EntityClient
* @protected
*/
type EntityKey<C extends BaseConfigMap> = Record<C['HashKey'] | C['RangeKey'], string>;
/**
* Database-facing record type from a {@link BaseConfigMap | `ConfigMap`} with required hash & range keys.

@@ -732,0 +744,0 @@ *

import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
import { pick } from 'radash';
import { addKeys } from './addKeys.js';

@@ -62,2 +63,19 @@ import { configSchema } from './ParsedConfig.js';

/**
* Convert an {@link EntityItem | `EntityItem`} into an {@link EntityKey | `EntityKey`}.
*
* @param entityToken - {@link Config | `Config`} `entities` key.
* @param item - {@link EntityItem | `EntityItem`} object.
* @param overwrite - Overwrite existing properties (default `false`).
*
* @returns {@link EntityKey | `EntityKey`} extracted from shallow clone of `item` with updated properties.
*
* @throws `Error` if `entityToken` is invalid.
*/
getPrimaryKey(entityToken, item, overwrite = false) {
const { hashKey, rangeKey } = this.config;
return pick(!overwrite && item[hashKey] && item[rangeKey]
? item
: addKeys(this, entityToken, item, overwrite), [this.config.hashKey, this.config.rangeKey]);
}
/**
* Strips generated properties, hash key, and range key from an {@link EntityItem | `EntityItem`} object.

@@ -64,0 +82,0 @@ *

@@ -135,3 +135,3 @@ {

"types": "dist/index.d.ts",
"version": "6.10.3"
"version": "6.11.0"
}
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