@karmaniverous/entity-manager
Advanced tools
Comparing version 6.13.3 to 6.14.0
'use strict'; | ||
var BaseEntityClient = require('./BaseEntityClient.js'); | ||
var BaseQueryBuilder = require('./BaseQueryBuilder.js'); | ||
var EntityManager = require('./EntityManager.js'); | ||
var BaseEntityClient = require('./BaseEntityClient/BaseEntityClient.js'); | ||
var BaseQueryBuilder = require('./BaseQueryBuilder/BaseQueryBuilder.js'); | ||
var EntityManager = require('./EntityManager/EntityManager.js'); | ||
var ParsedConfig = require('./EntityManager/ParsedConfig.js'); | ||
@@ -12,1 +13,2 @@ | ||
exports.EntityManager = EntityManager.EntityManager; | ||
exports.configSchema = ParsedConfig.configSchema; |
@@ -1,4 +0,4 @@ | ||
import { EntityMap, TranscodeMap, ConditionalProperty, Exactify, PropertiesOfType, TranscodableProperties, FlattenEntityMap, Transcodes, SortOrder, MutuallyExclusive, NotNever, DefaultTranscodeMap } from '@karmaniverous/entity-tools'; | ||
import { EntityMap, TranscodeMap, ConditionalProperty, Exactify, PropertiesOfType, TranscodableProperties, FlattenEntityMap, Transcodes, MutuallyExclusive, NotNever, DefaultTranscodeMap, SortOrder } from '@karmaniverous/entity-tools'; | ||
import { z } from 'zod'; | ||
import { BatchProcessOptions } from '@karmaniverous/batch-process'; | ||
import { z } from 'zod'; | ||
@@ -80,2 +80,43 @@ /** | ||
/** | ||
* Validates a type derived from {@link BaseConfigMap | `BaseConfigMap`} to ensure HashKey and RangeKey are both defined and that all sets of special keys are mutually exclusive. | ||
* | ||
* @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 EntityManager | ||
* @protected | ||
*/ | ||
type ValidateConfigMap<C extends BaseConfigMap> = MutuallyExclusive<[ | ||
C['HashKey'], | ||
C['RangeKey'], | ||
C['ShardedKeys'], | ||
C['UnshardedKeys'], | ||
keyof FlattenEntityMap<C['EntityMap']> | ||
]> extends true ? NotNever<C, ['HashKey' | 'RangeKey']> extends true ? C : Exclude<NotNever<C, ['HashKey' | 'RangeKey']>, true> : Exclude<MutuallyExclusive<[ | ||
C['HashKey'], | ||
C['RangeKey'], | ||
C['ShardedKeys'], | ||
C['UnshardedKeys'], | ||
keyof FlattenEntityMap<C['EntityMap']> | ||
]>, true>; | ||
/** | ||
* Generates & validates the map defining defines an {@link EntityManager | `EntityManager`} configuration's {@link EntityMap | `EntityMap`}, key properties, and {@link TranscodeMap | `TranscodeMap`}. | ||
* | ||
* Unspecified properties will default to those defined in {@link BaseConfigMap | `BaseConfigMap`}. | ||
* | ||
* @typeParam M - {@link BaseConfigMap | `BaseConfigMap`} extension. If omitted, defaults to {@link BaseConfigMap | `BaseConfigMap`}. | ||
* | ||
* @category EntityManager | ||
*/ | ||
type ConfigMap<M extends Partial<BaseConfigMap> = Partial<BaseConfigMap>> = ValidateConfigMap<{ | ||
EntityMap: 'EntityMap' extends keyof M ? NonNullable<M['EntityMap']> : Record<string, never>; | ||
HashKey: 'HashKey' extends keyof M ? NonNullable<M['HashKey']> : 'hashKey'; | ||
RangeKey: 'RangeKey' extends keyof M ? NonNullable<M['RangeKey']> : 'rangeKey'; | ||
ShardedKeys: 'ShardedKeys' extends keyof M ? NonNullable<M['ShardedKeys']> : never; | ||
UnshardedKeys: 'UnshardedKeys' extends keyof M ? NonNullable<M['UnshardedKeys']> : never; | ||
TranscodedProperties: 'TranscodedProperties' extends keyof M ? NonNullable<M['TranscodedProperties']> : never; | ||
TranscodeMap: 'TranscodeMap' extends keyof M ? NonNullable<M['TranscodeMap']> : DefaultTranscodeMap; | ||
}>; | ||
/** | ||
* Extracts a database-facing partial item type from a {@link BaseConfigMap | `ConfigMap`}. | ||
@@ -242,2 +283,7 @@ * | ||
}; | ||
propertyTranscodes: Record<string, string>; | ||
transcodes: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}>; | ||
indexes: Record<string, { | ||
@@ -250,9 +296,4 @@ hashKey: string; | ||
generatedValueDelimiter: string; | ||
propertyTranscodes: Record<string, string>; | ||
shardKeyDelimiter: string; | ||
throttle: number; | ||
transcodes: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}>; | ||
}, { | ||
@@ -276,2 +317,7 @@ hashKey: string; | ||
} | undefined; | ||
propertyTranscodes?: Record<string, string> | undefined; | ||
transcodes?: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}> | undefined; | ||
indexes?: Record<string, { | ||
@@ -284,9 +330,4 @@ hashKey: string; | ||
generatedValueDelimiter?: string | undefined; | ||
propertyTranscodes?: Record<string, string> | undefined; | ||
shardKeyDelimiter?: string | undefined; | ||
throttle?: number | undefined; | ||
transcodes?: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}> | undefined; | ||
}>, { | ||
@@ -310,2 +351,7 @@ hashKey: string; | ||
}; | ||
propertyTranscodes: Record<string, string>; | ||
transcodes: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}>; | ||
indexes: Record<string, { | ||
@@ -318,9 +364,4 @@ hashKey: string; | ||
generatedValueDelimiter: string; | ||
propertyTranscodes: Record<string, string>; | ||
shardKeyDelimiter: string; | ||
throttle: number; | ||
transcodes: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}>; | ||
}, { | ||
@@ -344,2 +385,7 @@ hashKey: string; | ||
} | undefined; | ||
propertyTranscodes?: Record<string, string> | undefined; | ||
transcodes?: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}> | undefined; | ||
indexes?: Record<string, { | ||
@@ -352,9 +398,4 @@ hashKey: string; | ||
generatedValueDelimiter?: string | undefined; | ||
propertyTranscodes?: Record<string, string> | undefined; | ||
shardKeyDelimiter?: string | undefined; | ||
throttle?: number | undefined; | ||
transcodes?: Record<string, { | ||
encode: (args_0: any, ...args: unknown[]) => string; | ||
decode: (args_0: string, ...args: unknown[]) => any; | ||
}> | undefined; | ||
}>; | ||
@@ -533,2 +574,3 @@ /** | ||
#private; | ||
/** Logger object (defaults to `console`, must support `debug` & `error` methods). */ | ||
readonly logger: Pick<Console, 'debug' | 'error'>; | ||
@@ -557,3 +599,3 @@ /** | ||
* | ||
* @param property - {@link Config.generatedProperties | Generated property} key. | ||
* @param property - {@link Config | Config} `generatedProperties` key. | ||
* @param item - {@link EntityItem | `EntityItem`} object. | ||
@@ -563,3 +605,3 @@ * | ||
* | ||
* @throws `Error` if `property` is not a {@link Config.generatedProperties | generated property}. | ||
* @throws `Error` if `property` is not a {@link Config | Config} `generatedProperties` key. | ||
*/ | ||
@@ -577,5 +619,21 @@ encodeGeneratedProperty<C extends BaseConfigMap>(property: C['ShardedKeys'] | C['UnshardedKeys'], item: EntityItem<C>): string | undefined; | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
addKeys(entityToken: EntityToken<C>, item: EntityItem<C>, overwrite?: boolean): EntityRecord<C>; | ||
/** | ||
* Update generated properties, hash key, and range key on an array of {@link EntityItem | `EntityItem`} objects. | ||
* | ||
* @param entityToken - {@link Config | `Config`} `entities` key. | ||
* @param items - Array of {@link EntityItem | `EntityItem`} objects. | ||
* @param overwrite - Overwrite existing properties (default `false`). | ||
* | ||
* @returns An array of {@link EntityRecord | `EntityRecord`} objects with updated properties. | ||
* | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
addKeys(entityToken: EntityToken<C>, item: EntityItem<C>[], overwrite?: boolean): EntityRecord<C>[]; | ||
/** | ||
* Convert an {@link EntityItem | `EntityItem`} into an {@link EntityKey | `EntityKey`}. | ||
@@ -590,5 +648,21 @@ * | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
getPrimaryKey(entityToken: EntityToken<C>, item: EntityItem<C>, overwrite?: boolean): EntityKey<C>; | ||
/** | ||
* Convert an array of {@link EntityItem | `EntityItem`} objects into {@link EntityKey | `EntityKey`} objects. | ||
* | ||
* @param entityToken - {@link Config | `Config`} `entities` key. | ||
* @param items - Array of {@link EntityItem | `EntityItem`} objects. | ||
* @param overwrite - Overwrite existing properties (default `false`). | ||
* | ||
* @returns An array of {@link EntityKey | `EntityKey`} objects extracted from shallow clone of each `item` with updated properties. | ||
* | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
getPrimaryKey(entityToken: EntityToken<C>, items: EntityItem<C>[], overwrite?: boolean): EntityKey<C>[]; | ||
/** | ||
* Strips generated properties, hash key, and range key from an {@link EntityRecord | `EntityRecord`} object. | ||
@@ -602,5 +676,20 @@ * | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
removeKeys(entityToken: EntityToken<C>, item: EntityRecord<C>): EntityItem<C>; | ||
/** | ||
* Strips generated properties, hash key, and range key from an array of {@link EntityRecord | `EntityRecord`} objects. | ||
* | ||
* @param entityToken - {@link Config | `Config`} `entities` key. | ||
* @param items - Array of {@link EntityRecord | `EntityRecord`} objects. | ||
* | ||
* @returns Array of {@link EntityItem | `EntityItem`} objects with generated properties, hash key & range key removed. | ||
* | ||
* @throws `Error` if `entityToken` is invalid. | ||
* | ||
* @overload | ||
*/ | ||
removeKeys(entityToken: EntityToken<C>, items: EntityRecord<C>[]): EntityItem<C>[]; | ||
/** | ||
* Find an index token in a {@link Config | `Config`} object based on the index `hashKey` and `rangeKey`. | ||
@@ -746,43 +835,2 @@ * | ||
/** | ||
* Validates a type derived from {@link BaseConfigMap | `BaseConfigMap`} to ensure HashKey and RangeKey are both defined and that all sets of special keys are mutually exclusive. | ||
* | ||
* @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 EntityManager | ||
* @protected | ||
*/ | ||
type ValidateConfigMap<C extends BaseConfigMap> = MutuallyExclusive<[ | ||
C['HashKey'], | ||
C['RangeKey'], | ||
C['ShardedKeys'], | ||
C['UnshardedKeys'], | ||
keyof FlattenEntityMap<C['EntityMap']> | ||
]> extends true ? NotNever<C, ['HashKey' | 'RangeKey']> extends true ? C : Exclude<NotNever<C, ['HashKey' | 'RangeKey']>, true> : Exclude<MutuallyExclusive<[ | ||
C['HashKey'], | ||
C['RangeKey'], | ||
C['ShardedKeys'], | ||
C['UnshardedKeys'], | ||
keyof FlattenEntityMap<C['EntityMap']> | ||
]>, true>; | ||
/** | ||
* Generates & validates the map defining defines an {@link EntityManager | `EntityManager`} configuration's {@link EntityMap | `EntityMap`}, key properties, and {@link TranscodeMap | `TranscodeMap`}. | ||
* | ||
* Unspecified properties will default to those defined in {@link BaseConfigMap | `BaseConfigMap`}. | ||
* | ||
* @typeParam M - {@link BaseConfigMap | `BaseConfigMap`} extension. If omitted, defaults to {@link BaseConfigMap | `BaseConfigMap`}. | ||
* | ||
* @category EntityManager | ||
*/ | ||
type ConfigMap<M extends Partial<BaseConfigMap> = Partial<BaseConfigMap>> = ValidateConfigMap<{ | ||
EntityMap: 'EntityMap' extends keyof M ? NonNullable<M['EntityMap']> : Record<string, never>; | ||
HashKey: 'HashKey' extends keyof M ? NonNullable<M['HashKey']> : 'hashKey'; | ||
RangeKey: 'RangeKey' extends keyof M ? NonNullable<M['RangeKey']> : 'rangeKey'; | ||
ShardedKeys: 'ShardedKeys' extends keyof M ? NonNullable<M['ShardedKeys']> : never; | ||
UnshardedKeys: 'UnshardedKeys' extends keyof M ? NonNullable<M['UnshardedKeys']> : never; | ||
TranscodedProperties: 'TranscodedProperties' extends keyof M ? NonNullable<M['TranscodedProperties']> : never; | ||
TranscodeMap: 'TranscodeMap' extends keyof M ? NonNullable<M['TranscodeMap']> : DefaultTranscodeMap; | ||
}>; | ||
export { type BaseConfigMap, BaseEntityClient, type BaseEntityClientOptions, BaseQueryBuilder, type BaseQueryBuilderOptions, type Config, type ConfigMap, type EntityItem, type EntityKey, EntityManager, type EntityRecord, type EntityToken, type PageKey, type ParsedConfig, type QueryBuilderQueryOptions, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryResult, type ValidateConfigMap }; | ||
export { type BaseConfigMap, BaseEntityClient, type BaseEntityClientOptions, BaseQueryBuilder, type BaseQueryBuilderOptions, type Config, type ConfigMap, type EntityItem, type EntityKey, EntityManager, type EntityRecord, type EntityToken, type PageKey, type ParsedConfig, type QueryBuilderQueryOptions, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryResult, type ValidateConfigMap, configSchema }; |
@@ -1,3 +0,4 @@ | ||
export { BaseEntityClient } from './BaseEntityClient.js'; | ||
export { BaseQueryBuilder } from './BaseQueryBuilder.js'; | ||
export { EntityManager } from './EntityManager.js'; | ||
export { BaseEntityClient } from './BaseEntityClient/BaseEntityClient.js'; | ||
export { BaseQueryBuilder } from './BaseQueryBuilder/BaseQueryBuilder.js'; | ||
export { EntityManager } from './EntityManager/EntityManager.js'; | ||
export { configSchema } from './EntityManager/ParsedConfig.js'; |
@@ -8,3 +8,3 @@ { | ||
"@karmaniverous/batch-process": "^0.1.0", | ||
"@karmaniverous/entity-tools": "^0.6.6", | ||
"@karmaniverous/entity-tools": "^0.6.8", | ||
"@karmaniverous/string-utilities": "^0.2.1", | ||
@@ -136,3 +136,3 @@ "lz-string": "^1.5.0", | ||
"types": "dist/index.d.ts", | ||
"version": "6.13.3" | ||
"version": "6.14.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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
181996
59
3953
1