@karmaniverous/entity-manager 6.7.3 → 6.7.4
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 +21 -0
- package/dist/cjs/BaseShardQueryMapBuilder.js +2 -1
- package/dist/cjs/index.js +2 -0
- package/dist/index.d.ts +43 -8
- package/dist/mjs/BaseEntityClient.js +19 -0
- package/dist/mjs/BaseShardQueryMapBuilder.js +2 -1
- package/dist/mjs/index.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base EntityClient class. Integrates {@link EntityManager | `EntityManager`} with injected logging & enhanced batch processing.
|
|
5
|
+
*
|
|
6
|
+
* @category EntityClient
|
|
7
|
+
*/
|
|
8
|
+
class BaseEntityClient {
|
|
9
|
+
/**
|
|
10
|
+
* DynamoDB EntityClient constructor.
|
|
11
|
+
*
|
|
12
|
+
* @param options - {@link EntityClientOptions | `EntityClientOptions`} object.
|
|
13
|
+
*/
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { batchProcessOptions = {}, logger = console } = options;
|
|
16
|
+
this.batchProcessOptions = batchProcessOptions;
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.BaseEntityClient = BaseEntityClient;
|
|
@@ -16,7 +16,8 @@ class BaseShardQueryMapBuilder {
|
|
|
16
16
|
* @protected
|
|
17
17
|
*/
|
|
18
18
|
this.indexParamsMap = {};
|
|
19
|
-
const { entityManager, entityToken, hashKeyToken, pageKeyMap } = options;
|
|
19
|
+
const { entityClient, entityManager, entityToken, hashKeyToken, pageKeyMap, } = options;
|
|
20
|
+
this.entityClient = entityClient;
|
|
20
21
|
this.entityManager = entityManager;
|
|
21
22
|
this.entityToken = entityToken;
|
|
22
23
|
this.hashKeyToken = hashKeyToken;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var BaseEntityClient = require('./BaseEntityClient.js');
|
|
3
4
|
var BaseShardQueryMapBuilder = require('./BaseShardQueryMapBuilder.js');
|
|
4
5
|
var conditionalize = require('./conditionalize.js');
|
|
5
6
|
var EntityManager = require('./EntityManager.js');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
exports.BaseEntityClient = BaseEntityClient.BaseEntityClient;
|
|
9
11
|
exports.BaseShardQueryMapBuilder = BaseShardQueryMapBuilder.BaseShardQueryMapBuilder;
|
|
10
12
|
exports.conditionalize = conditionalize.conditionalize;
|
|
11
13
|
exports.EntityManager = EntityManager.EntityManager;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import { BatchProcessOptions } from '@karmaniverous/batch-process';
|
|
1
2
|
import { Entity, Exactify, TranscodeMap, PropertiesOfType, TranscodableProperties, Transcodes, DefaultTranscodeMap, SortOrder } from '@karmaniverous/entity-tools';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Base EntityClient options.
|
|
7
|
+
*
|
|
8
|
+
* @category EntityClient
|
|
9
|
+
*/
|
|
10
|
+
interface BaseEntityClientOptions {
|
|
11
|
+
/** Default batch process options. */
|
|
12
|
+
batchProcessOptions?: Omit<BatchProcessOptions<unknown, unknown>, 'batchHandler' | 'unprocessedItemExtractor'>;
|
|
13
|
+
/** Injected logger object. Must support `debug` and `error` methods. Default: `console` */
|
|
14
|
+
logger?: Pick<Console, 'debug' | 'error'>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base EntityClient class. Integrates {@link EntityManager | `EntityManager`} with injected logging & enhanced batch processing.
|
|
19
|
+
*
|
|
20
|
+
* @category EntityClient
|
|
21
|
+
*/
|
|
22
|
+
declare abstract class BaseEntityClient {
|
|
23
|
+
readonly batchProcessOptions: NonNullable<BaseEntityClientOptions['batchProcessOptions']>;
|
|
24
|
+
readonly logger: NonNullable<BaseEntityClientOptions['logger']>;
|
|
25
|
+
/**
|
|
26
|
+
* DynamoDB EntityClient constructor.
|
|
27
|
+
*
|
|
28
|
+
* @param options - {@link EntityClientOptions | `EntityClientOptions`} object.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options: BaseEntityClientOptions);
|
|
31
|
+
}
|
|
32
|
+
|
|
4
33
|
/**
|
|
5
34
|
* The base EntityMap type. All EntityMaps should extend this type.
|
|
6
35
|
*
|
|
@@ -553,6 +582,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
553
582
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
554
583
|
}>>>>;
|
|
555
584
|
}, "strict", z.ZodTypeAny, {
|
|
585
|
+
throttle: number;
|
|
556
586
|
hashKey: string;
|
|
557
587
|
rangeKey: string;
|
|
558
588
|
entities: Record<string, {
|
|
@@ -580,12 +610,12 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
580
610
|
generatedKeyDelimiter: string;
|
|
581
611
|
generatedValueDelimiter: string;
|
|
582
612
|
shardKeyDelimiter: string;
|
|
583
|
-
throttle: number;
|
|
584
613
|
transcodes: Record<string, {
|
|
585
614
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
586
615
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
587
616
|
}>;
|
|
588
617
|
}, {
|
|
618
|
+
throttle?: number | undefined;
|
|
589
619
|
hashKey?: string | undefined;
|
|
590
620
|
rangeKey?: string | undefined;
|
|
591
621
|
entities?: Record<string, {
|
|
@@ -613,12 +643,12 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
613
643
|
generatedKeyDelimiter?: string | undefined;
|
|
614
644
|
generatedValueDelimiter?: string | undefined;
|
|
615
645
|
shardKeyDelimiter?: string | undefined;
|
|
616
|
-
throttle?: number | undefined;
|
|
617
646
|
transcodes?: Record<string, {
|
|
618
647
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
619
648
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
620
649
|
}> | undefined;
|
|
621
650
|
}>, {
|
|
651
|
+
throttle: number;
|
|
622
652
|
hashKey: string;
|
|
623
653
|
rangeKey: string;
|
|
624
654
|
entities: Record<string, {
|
|
@@ -646,12 +676,12 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
646
676
|
generatedKeyDelimiter: string;
|
|
647
677
|
generatedValueDelimiter: string;
|
|
648
678
|
shardKeyDelimiter: string;
|
|
649
|
-
throttle: number;
|
|
650
679
|
transcodes: Record<string, {
|
|
651
680
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
652
681
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
653
682
|
}>;
|
|
654
683
|
}, {
|
|
684
|
+
throttle?: number | undefined;
|
|
655
685
|
hashKey?: string | undefined;
|
|
656
686
|
rangeKey?: string | undefined;
|
|
657
687
|
entities?: Record<string, {
|
|
@@ -679,7 +709,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
679
709
|
generatedKeyDelimiter?: string | undefined;
|
|
680
710
|
generatedValueDelimiter?: string | undefined;
|
|
681
711
|
shardKeyDelimiter?: string | undefined;
|
|
682
|
-
throttle?: number | undefined;
|
|
683
712
|
transcodes?: Record<string, {
|
|
684
713
|
encode: (args_0: any, ...args: unknown[]) => string;
|
|
685
714
|
decode: (args_0: string, ...args: unknown[]) => any;
|
|
@@ -877,8 +906,12 @@ declare class EntityManager<M extends EntityMap, HashKey extends string, RangeKe
|
|
|
877
906
|
|
|
878
907
|
/**
|
|
879
908
|
* Constructor options for {@link BaseShardQueryMapBuilder | `BaseShardQueryMapBuilder`}.
|
|
909
|
+
*
|
|
910
|
+
* @category ShardQueryMapBuilder
|
|
880
911
|
*/
|
|
881
|
-
interface BaseShardQueryMapBuilderOptions<EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string, RangeKey extends string, T extends TranscodeMap> {
|
|
912
|
+
interface BaseShardQueryMapBuilderOptions<EntityClient extends BaseEntityClient, EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string, RangeKey extends string, T extends TranscodeMap> {
|
|
913
|
+
/** {@link BaseEntityClient | `EntityClient`} instance. */
|
|
914
|
+
entityClient: EntityClient;
|
|
882
915
|
/** {@link EntityManager | `EntityManager`} instance. */
|
|
883
916
|
entityManager: EntityManager<M, HashKey, RangeKey, T>;
|
|
884
917
|
/** Entity token. */
|
|
@@ -896,7 +929,9 @@ type ShardQueryMapBuilderQueryOptions<Item extends ItemMap<M, HashKey, RangeKey>
|
|
|
896
929
|
*
|
|
897
930
|
* @category ShardQueryMapBuilder
|
|
898
931
|
*/
|
|
899
|
-
declare abstract class BaseShardQueryMapBuilder<IndexParams, Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string, RangeKey extends string, T extends TranscodeMap> {
|
|
932
|
+
declare abstract class BaseShardQueryMapBuilder<IndexParams, EntityClient extends BaseEntityClient, Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string, RangeKey extends string, T extends TranscodeMap> {
|
|
933
|
+
/** {@link BaseEntityClient | `EntityClient`} instance. */
|
|
934
|
+
readonly entityClient: EntityClient;
|
|
900
935
|
/** {@link EntityManager | `EntityManager`} instance. */
|
|
901
936
|
readonly entityManager: EntityManager<M, HashKey, RangeKey, T>;
|
|
902
937
|
/** Entity token. */
|
|
@@ -912,7 +947,7 @@ declare abstract class BaseShardQueryMapBuilder<IndexParams, Item extends ItemMa
|
|
|
912
947
|
*/
|
|
913
948
|
readonly indexParamsMap: Record<string, IndexParams>;
|
|
914
949
|
/** BaseShardQueryMapBuilder constructor. */
|
|
915
|
-
constructor(options: BaseShardQueryMapBuilderOptions<EntityToken, M, HashKey, RangeKey, T>);
|
|
950
|
+
constructor(options: BaseShardQueryMapBuilderOptions<EntityClient, EntityToken, M, HashKey, RangeKey, T>);
|
|
916
951
|
protected abstract getShardQueryFunction(indexToken: string): ShardQueryFunction<Item>;
|
|
917
952
|
/**
|
|
918
953
|
* Builds a {@link ShardQueryMap | `ShardQueryMap`} object.
|
|
@@ -936,4 +971,4 @@ declare abstract class BaseShardQueryMapBuilder<IndexParams, Item extends ItemMa
|
|
|
936
971
|
*/
|
|
937
972
|
declare function conditionalize<F extends (...args: Parameters<F>) => ReturnType<F>>(fn: F, condition?: unknown): (...args: Parameters<F>) => ReturnType<F> | undefined;
|
|
938
973
|
|
|
939
|
-
export { BaseShardQueryMapBuilder, type BaseShardQueryMapBuilderOptions, type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigEntityIndexComponent, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryMapBuilderQueryOptions, type ShardQueryResult, type Unwrap, conditionalize };
|
|
974
|
+
export { BaseEntityClient, type BaseEntityClientOptions, BaseShardQueryMapBuilder, type BaseShardQueryMapBuilderOptions, type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigEntityIndexComponent, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryMapBuilderQueryOptions, type ShardQueryResult, type Unwrap, conditionalize };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base EntityClient class. Integrates {@link EntityManager | `EntityManager`} with injected logging & enhanced batch processing.
|
|
3
|
+
*
|
|
4
|
+
* @category EntityClient
|
|
5
|
+
*/
|
|
6
|
+
class BaseEntityClient {
|
|
7
|
+
/**
|
|
8
|
+
* DynamoDB EntityClient constructor.
|
|
9
|
+
*
|
|
10
|
+
* @param options - {@link EntityClientOptions | `EntityClientOptions`} object.
|
|
11
|
+
*/
|
|
12
|
+
constructor(options) {
|
|
13
|
+
const { batchProcessOptions = {}, logger = console } = options;
|
|
14
|
+
this.batchProcessOptions = batchProcessOptions;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { BaseEntityClient };
|
|
@@ -14,7 +14,8 @@ class BaseShardQueryMapBuilder {
|
|
|
14
14
|
* @protected
|
|
15
15
|
*/
|
|
16
16
|
this.indexParamsMap = {};
|
|
17
|
-
const { entityManager, entityToken, hashKeyToken, pageKeyMap } = options;
|
|
17
|
+
const { entityClient, entityManager, entityToken, hashKeyToken, pageKeyMap, } = options;
|
|
18
|
+
this.entityClient = entityClient;
|
|
18
19
|
this.entityManager = entityManager;
|
|
19
20
|
this.entityToken = entityToken;
|
|
20
21
|
this.hashKeyToken = hashKeyToken;
|
package/dist/mjs/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/karmaniverous/entity-manager/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
+
"@karmaniverous/batch-process": "^0.1.0",
|
|
7
8
|
"@karmaniverous/entity-tools": "^0.4.4",
|
|
8
9
|
"@karmaniverous/string-utilities": "^0.2.1",
|
|
9
10
|
"lz-string": "^1.5.0",
|
|
@@ -131,5 +132,5 @@
|
|
|
131
132
|
},
|
|
132
133
|
"type": "module",
|
|
133
134
|
"types": "dist/index.d.ts",
|
|
134
|
-
"version": "6.7.
|
|
135
|
+
"version": "6.7.4"
|
|
135
136
|
}
|