@karmaniverous/entity-manager
Advanced tools
Comparing version 6.10.3 to 6.11.0
'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 @@ * |
@@ -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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174118
3783