@karmaniverous/entity-manager 6.10.1 → 6.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseEntityClient.js +3 -3
- package/dist/index.d.ts +47 -22
- package/dist/mjs/BaseEntityClient.js +3 -3
- package/package.json +1 -1
|
@@ -13,10 +13,10 @@ class BaseEntityClient {
|
|
|
13
13
|
*
|
|
14
14
|
* @param options - {@link BaseEntityClientOptions | `BaseEntityClientOptions`} object.
|
|
15
15
|
*/
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
18
|
-
const { batchProcessOptions = {}, logger = console } = options;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
const { batchProcessOptions = {}, entityManager, logger = console, } = options;
|
|
19
18
|
this.batchProcessOptions = batchProcessOptions;
|
|
19
|
+
this.entityManager = entityManager;
|
|
20
20
|
this.logger = logger;
|
|
21
21
|
}
|
|
22
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,20 +17,6 @@ interface BaseConfigMap {
|
|
|
17
17
|
TranscodeMap: TranscodeMap;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Base EntityClient options.
|
|
22
|
-
*
|
|
23
|
-
* @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`}.
|
|
24
|
-
*
|
|
25
|
-
* @category EntityClient
|
|
26
|
-
*/
|
|
27
|
-
interface BaseEntityClientOptions {
|
|
28
|
-
/** Default batch process options. */
|
|
29
|
-
batchProcessOptions?: Omit<BatchProcessOptions<unknown, unknown>, 'batchHandler' | 'unprocessedItemExtractor'>;
|
|
30
|
-
/** Injected logger object. Must support `debug` and `error` methods. Default: `console` */
|
|
31
|
-
logger?: Pick<Console, 'debug' | 'error'>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
20
|
/**
|
|
35
21
|
* Defines a single time period in an entity sharding strategy.
|
|
36
22
|
*
|
|
@@ -217,7 +203,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
217
203
|
}, "strict", z.ZodTypeAny, {
|
|
218
204
|
hashKey: string;
|
|
219
205
|
rangeKey: string;
|
|
220
|
-
throttle: number;
|
|
221
206
|
entities: Record<string, {
|
|
222
207
|
defaultLimit: number;
|
|
223
208
|
defaultPageSize: number;
|
|
@@ -242,6 +227,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
242
227
|
generatedValueDelimiter: string;
|
|
243
228
|
propertyTranscodes: Record<string, string>;
|
|
244
229
|
shardKeyDelimiter: string;
|
|
230
|
+
throttle: number;
|
|
245
231
|
transcodes: Record<string, {
|
|
246
232
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
247
233
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
@@ -249,7 +235,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
249
235
|
}, {
|
|
250
236
|
hashKey: string;
|
|
251
237
|
rangeKey: string;
|
|
252
|
-
throttle?: number | undefined;
|
|
253
238
|
entities?: Record<string, {
|
|
254
239
|
timestampProperty: string;
|
|
255
240
|
uniqueProperty: string;
|
|
@@ -274,6 +259,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
274
259
|
generatedValueDelimiter?: string | undefined;
|
|
275
260
|
propertyTranscodes?: Record<string, string> | undefined;
|
|
276
261
|
shardKeyDelimiter?: string | undefined;
|
|
262
|
+
throttle?: number | undefined;
|
|
277
263
|
transcodes?: Record<string, {
|
|
278
264
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
279
265
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
@@ -281,7 +267,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
281
267
|
}>, {
|
|
282
268
|
hashKey: string;
|
|
283
269
|
rangeKey: string;
|
|
284
|
-
throttle: number;
|
|
285
270
|
entities: Record<string, {
|
|
286
271
|
defaultLimit: number;
|
|
287
272
|
defaultPageSize: number;
|
|
@@ -306,6 +291,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
306
291
|
generatedValueDelimiter: string;
|
|
307
292
|
propertyTranscodes: Record<string, string>;
|
|
308
293
|
shardKeyDelimiter: string;
|
|
294
|
+
throttle: number;
|
|
309
295
|
transcodes: Record<string, {
|
|
310
296
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
311
297
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
@@ -313,7 +299,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
313
299
|
}, {
|
|
314
300
|
hashKey: string;
|
|
315
301
|
rangeKey: string;
|
|
316
|
-
throttle?: number | undefined;
|
|
317
302
|
entities?: Record<string, {
|
|
318
303
|
timestampProperty: string;
|
|
319
304
|
uniqueProperty: string;
|
|
@@ -338,6 +323,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
338
323
|
generatedValueDelimiter?: string | undefined;
|
|
339
324
|
propertyTranscodes?: Record<string, string> | undefined;
|
|
340
325
|
shardKeyDelimiter?: string | undefined;
|
|
326
|
+
throttle?: number | undefined;
|
|
341
327
|
transcodes?: Record<string, {
|
|
342
328
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
343
329
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
@@ -583,6 +569,22 @@ declare class EntityManager<C extends BaseConfigMap> {
|
|
|
583
569
|
query(options: QueryOptions<C>): Promise<QueryResult<C>>;
|
|
584
570
|
}
|
|
585
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Base EntityClient options.
|
|
574
|
+
*
|
|
575
|
+
* @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`}.
|
|
576
|
+
*
|
|
577
|
+
* @category EntityClient
|
|
578
|
+
*/
|
|
579
|
+
interface BaseEntityClientOptions<C extends BaseConfigMap> {
|
|
580
|
+
/** Default batch process options. */
|
|
581
|
+
batchProcessOptions?: Omit<BatchProcessOptions<unknown, unknown>, 'batchHandler' | 'unprocessedItemExtractor'>;
|
|
582
|
+
/** {@link EntityManager | `EntityManager`} instance. */
|
|
583
|
+
entityManager: EntityManager<C>;
|
|
584
|
+
/** Injected logger object. Must support `debug` and `error` methods. Default: `console` */
|
|
585
|
+
logger?: Pick<Console, 'debug' | 'error'>;
|
|
586
|
+
}
|
|
587
|
+
|
|
586
588
|
/**
|
|
587
589
|
* Base EntityClient class. Integrates {@link EntityManager | `EntityManager`} with injected logging & enhanced batch processing.
|
|
588
590
|
*
|
|
@@ -591,15 +593,18 @@ declare class EntityManager<C extends BaseConfigMap> {
|
|
|
591
593
|
* @category EntityClient
|
|
592
594
|
*/
|
|
593
595
|
declare abstract class BaseEntityClient<C extends BaseConfigMap> {
|
|
596
|
+
/** Default batch process options. */
|
|
597
|
+
readonly batchProcessOptions: NonNullable<BaseEntityClientOptions<C>['batchProcessOptions']>;
|
|
598
|
+
/** {@link EntityManager | `EntityManager`} instance. */
|
|
594
599
|
readonly entityManager: EntityManager<C>;
|
|
595
|
-
|
|
596
|
-
readonly logger: NonNullable<BaseEntityClientOptions['logger']>;
|
|
600
|
+
/** Injected logger object. Must support `debug` and `error` methods. Default: `console` */
|
|
601
|
+
readonly logger: NonNullable<BaseEntityClientOptions<C>['logger']>;
|
|
597
602
|
/**
|
|
598
603
|
* DynamoDB EntityClient constructor.
|
|
599
604
|
*
|
|
600
605
|
* @param options - {@link BaseEntityClientOptions | `BaseEntityClientOptions`} object.
|
|
601
606
|
*/
|
|
602
|
-
constructor(
|
|
607
|
+
constructor(options: BaseEntityClientOptions<C>);
|
|
603
608
|
}
|
|
604
609
|
|
|
605
610
|
/**
|
|
@@ -709,4 +714,24 @@ type ConfigMap<M extends Partial<BaseConfigMap> = Partial<BaseConfigMap>> = Vali
|
|
|
709
714
|
TranscodeMap: 'TranscodeMap' extends keyof M ? NonNullable<M['TranscodeMap']> : DefaultTranscodeMap;
|
|
710
715
|
}>;
|
|
711
716
|
|
|
712
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Database-facing record key type from a {@link BaseConfigMap | `ConfigMap`} with required hash & range keys.
|
|
719
|
+
*
|
|
720
|
+
* @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`}.
|
|
721
|
+
*
|
|
722
|
+
* @category EntityClient
|
|
723
|
+
* @protected
|
|
724
|
+
*/
|
|
725
|
+
type EntityKey<C extends BaseConfigMap> = Record<C['HashKey'] | C['RangeKey'], string>;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Database-facing record type from a {@link BaseConfigMap | `ConfigMap`} with required hash & range keys.
|
|
729
|
+
*
|
|
730
|
+
* @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`}.
|
|
731
|
+
*
|
|
732
|
+
* @category EntityManager
|
|
733
|
+
* @protected
|
|
734
|
+
*/
|
|
735
|
+
type EntityRecord<C extends BaseConfigMap> = EntityItem<C> & EntityKey<C>;
|
|
736
|
+
|
|
737
|
+
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 };
|
|
@@ -11,10 +11,10 @@ class BaseEntityClient {
|
|
|
11
11
|
*
|
|
12
12
|
* @param options - {@link BaseEntityClientOptions | `BaseEntityClientOptions`} object.
|
|
13
13
|
*/
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
16
|
-
const { batchProcessOptions = {}, logger = console } = options;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { batchProcessOptions = {}, entityManager, logger = console, } = options;
|
|
17
16
|
this.batchProcessOptions = batchProcessOptions;
|
|
17
|
+
this.entityManager = entityManager;
|
|
18
18
|
this.logger = logger;
|
|
19
19
|
}
|
|
20
20
|
}
|
package/package.json
CHANGED