@karmaniverous/entity-manager 6.7.3 → 6.7.5
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 → BaseQueryBuilder.js} +5 -4
- package/dist/cjs/index.js +4 -2
- package/dist/index.d.ts +47 -12
- package/dist/mjs/BaseEntityClient.js +19 -0
- package/dist/mjs/{BaseShardQueryMapBuilder.js → BaseQueryBuilder.js} +5 -4
- package/dist/mjs/index.js +2 -1
- 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;
|
|
@@ -7,8 +7,8 @@ var radash = require('radash');
|
|
|
7
7
|
*
|
|
8
8
|
* @category ShardQueryMapBuilder
|
|
9
9
|
*/
|
|
10
|
-
class
|
|
11
|
-
/**
|
|
10
|
+
class BaseQueryBuilder {
|
|
11
|
+
/** BaseQueryBuilder constructor. */
|
|
12
12
|
constructor(options) {
|
|
13
13
|
/**
|
|
14
14
|
* Maps `indexToken` values to database platform-specific query parameters.
|
|
@@ -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;
|
|
@@ -42,4 +43,4 @@ class BaseShardQueryMapBuilder {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
exports.
|
|
46
|
+
exports.BaseQueryBuilder = BaseQueryBuilder;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var BaseEntityClient = require('./BaseEntityClient.js');
|
|
4
|
+
var BaseQueryBuilder = require('./BaseQueryBuilder.js');
|
|
4
5
|
var conditionalize = require('./conditionalize.js');
|
|
5
6
|
var EntityManager = require('./EntityManager.js');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
exports.
|
|
10
|
+
exports.BaseEntityClient = BaseEntityClient.BaseEntityClient;
|
|
11
|
+
exports.BaseQueryBuilder = BaseQueryBuilder.BaseQueryBuilder;
|
|
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;
|
|
@@ -876,9 +905,13 @@ declare class EntityManager<M extends EntityMap, HashKey extends string, RangeKe
|
|
|
876
905
|
}
|
|
877
906
|
|
|
878
907
|
/**
|
|
879
|
-
* Constructor options for {@link
|
|
908
|
+
* Constructor options for {@link BaseQueryBuilder | `BaseQueryBuilder`}.
|
|
909
|
+
*
|
|
910
|
+
* @category ShardQueryMapBuilder
|
|
880
911
|
*/
|
|
881
|
-
interface
|
|
912
|
+
interface BaseQueryBuilderOptions<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. */
|
|
@@ -889,14 +922,16 @@ interface BaseShardQueryMapBuilderOptions<EntityToken extends keyof Exactify<M>
|
|
|
889
922
|
pageKeyMap?: string;
|
|
890
923
|
}
|
|
891
924
|
|
|
892
|
-
type
|
|
925
|
+
type QueryBuilderQueryOptions<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string, RangeKey extends string> = Omit<QueryOptions<Item, EntityToken, M, HashKey, RangeKey>, 'entityToken' | 'pageKeyMap' | 'shardQueryMap'>;
|
|
893
926
|
|
|
894
927
|
/**
|
|
895
928
|
* Abstract base class supporting a fluent API for building a {@link ShardQueryMap | `ShardQueryMap`} using a database client.
|
|
896
929
|
*
|
|
897
930
|
* @category ShardQueryMapBuilder
|
|
898
931
|
*/
|
|
899
|
-
declare abstract class
|
|
932
|
+
declare abstract class BaseQueryBuilder<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. */
|
|
@@ -911,8 +946,8 @@ declare abstract class BaseShardQueryMapBuilder<IndexParams, Item extends ItemMa
|
|
|
911
946
|
* @protected
|
|
912
947
|
*/
|
|
913
948
|
readonly indexParamsMap: Record<string, IndexParams>;
|
|
914
|
-
/**
|
|
915
|
-
constructor(options:
|
|
949
|
+
/** BaseQueryBuilder constructor. */
|
|
950
|
+
constructor(options: BaseQueryBuilderOptions<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.
|
|
@@ -920,7 +955,7 @@ declare abstract class BaseShardQueryMapBuilder<IndexParams, Item extends ItemMa
|
|
|
920
955
|
* @returns - The {@link ShardQueryMap | `ShardQueryMap`} object.
|
|
921
956
|
*/
|
|
922
957
|
build(): ShardQueryMap<Item>;
|
|
923
|
-
query(options:
|
|
958
|
+
query(options: QueryBuilderQueryOptions<Item, EntityToken, M, HashKey, RangeKey>): Promise<QueryResult<Item, EntityToken, M, HashKey, RangeKey>>;
|
|
924
959
|
}
|
|
925
960
|
|
|
926
961
|
/**
|
|
@@ -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 {
|
|
974
|
+
export { BaseEntityClient, type BaseEntityClientOptions, BaseQueryBuilder, type BaseQueryBuilderOptions, type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigEntityIndexComponent, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type ParsedConfig, type QueryBuilderQueryOptions, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, 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 };
|
|
@@ -5,8 +5,8 @@ import { mapValues } from 'radash';
|
|
|
5
5
|
*
|
|
6
6
|
* @category ShardQueryMapBuilder
|
|
7
7
|
*/
|
|
8
|
-
class
|
|
9
|
-
/**
|
|
8
|
+
class BaseQueryBuilder {
|
|
9
|
+
/** BaseQueryBuilder constructor. */
|
|
10
10
|
constructor(options) {
|
|
11
11
|
/**
|
|
12
12
|
* Maps `indexToken` values to database platform-specific query parameters.
|
|
@@ -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;
|
|
@@ -40,4 +41,4 @@ class BaseShardQueryMapBuilder {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export {
|
|
44
|
+
export { BaseQueryBuilder };
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BaseEntityClient } from './BaseEntityClient.js';
|
|
2
|
+
export { BaseQueryBuilder } from './BaseQueryBuilder.js';
|
|
2
3
|
export { conditionalize } from './conditionalize.js';
|
|
3
4
|
export { EntityManager } from './EntityManager.js';
|
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.5"
|
|
135
136
|
}
|