@karmaniverous/entity-manager 6.1.2 → 6.2.1
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/EntityManagerClient.js +6 -0
- package/dist/cjs/ShardQueryFunctionBuilder.js +14 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/query.js +1 -1
- package/dist/index.d.ts +42 -12
- package/dist/mjs/EntityManagerClient.js +6 -0
- package/dist/mjs/ShardQueryFunctionBuilder.js +12 -0
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/query.js +1 -1
- package/package.json +1 -1
|
@@ -9,9 +9,15 @@ var _EntityManagerClient_options;
|
|
|
9
9
|
/**
|
|
10
10
|
* EntityManagerClient base class.
|
|
11
11
|
*
|
|
12
|
+
* @typeParam Options - Options type extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
13
|
+
*
|
|
12
14
|
* @category Client
|
|
13
15
|
*/
|
|
14
16
|
class EntityManagerClient {
|
|
17
|
+
/**
|
|
18
|
+
* EntityManagerClient base constructor.
|
|
19
|
+
* @param options - Options object extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
20
|
+
*/
|
|
15
21
|
constructor({ batchSize = 25, delayIncrement = 100, maxRetries = 5, throttle = 10, logger = console, logInternals = false, ...childOptions }) {
|
|
16
22
|
_EntityManagerClient_options.set(this, void 0);
|
|
17
23
|
if (!radash.isFunction(logger.debug))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Entity Manager shard query builder base class.
|
|
5
|
+
*
|
|
6
|
+
* @category Query
|
|
7
|
+
*/
|
|
8
|
+
class ShardQueryFunctionBuilder {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.ShardQueryFunctionBuilder = ShardQueryFunctionBuilder;
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
var conditionalize = require('./conditionalize.js');
|
|
4
4
|
var EntityManager = require('./EntityManager.js');
|
|
5
5
|
var EntityManagerClient = require('./EntityManagerClient.js');
|
|
6
|
+
var ShardQueryFunctionBuilder = require('./ShardQueryFunctionBuilder.js');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
exports.conditionalize = conditionalize.conditionalize;
|
|
10
11
|
exports.EntityManager = EntityManager.EntityManager;
|
|
11
12
|
exports.EntityManagerClient = EntityManagerClient.EntityManagerClient;
|
|
13
|
+
exports.ShardQueryFunctionBuilder = ShardQueryFunctionBuilder.ShardQueryFunctionBuilder;
|
package/dist/cjs/query.js
CHANGED
|
@@ -27,7 +27,7 @@ const { compressToEncodedURIComponent, decompressFromEncodedURIComponent } = lzS
|
|
|
27
27
|
*
|
|
28
28
|
* @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
|
|
29
29
|
*/
|
|
30
|
-
async function query(entityManager, { entityToken, hashKey,
|
|
30
|
+
async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
|
|
31
31
|
try {
|
|
32
32
|
// Get defaults.
|
|
33
33
|
const { defaultLimit, defaultPageSize } = entityManager.config.entities[entityToken];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Entity, Exactify, TranscodeMap, PropertiesOfType, TranscodableProperties, Transcodes, DefaultTranscodeMap, SortOrder } from '@karmaniverous/entity-tools';
|
|
2
|
-
export { DefaultTranscodeMap, Entity, PropertiesOfType, SortOrder, TranscodableProperties, TranscodeMap, Transcodes, defaultTranscodes } from '@karmaniverous/entity-tools';
|
|
2
|
+
export { DefaultTranscodeMap, Entity, Exactify, PropertiesOfType, SortOrder, TranscodableProperties, TranscodeMap, Transcodes, defaultTranscodes } from '@karmaniverous/entity-tools';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -677,13 +677,6 @@ interface QueryOptions<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken],
|
|
|
677
677
|
* {@link Config | `EntityManager.config.entities.<entityToken>.keys`}.
|
|
678
678
|
*/
|
|
679
679
|
hashKey: string;
|
|
680
|
-
/**
|
|
681
|
-
* A partial {@link ItemMap | `ItemMap`} object containing at least the properties specified in
|
|
682
|
-
* {@link Config | `EntityManager.config.entities.<entityToken>.keys.<keyToken>.elements`}, except for the properties specified in {@link Config | `EntityManager.config.tokens`}.
|
|
683
|
-
*
|
|
684
|
-
* This data will be used to generate query keys across all shards.
|
|
685
|
-
*/
|
|
686
|
-
item?: Item;
|
|
687
680
|
/**
|
|
688
681
|
* The target maximum number of records to be returned by the query across
|
|
689
682
|
* all shards.
|
|
@@ -886,15 +879,21 @@ type EntityManagerClientOptions = EntityManagerClientBatchOptions & LoggerOption
|
|
|
886
879
|
/**
|
|
887
880
|
* EntityManagerClient base class.
|
|
888
881
|
*
|
|
882
|
+
* @typeParam Options - Options type extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
883
|
+
*
|
|
889
884
|
* @category Client
|
|
890
885
|
*/
|
|
891
|
-
declare abstract class EntityManagerClient<
|
|
886
|
+
declare abstract class EntityManagerClient<Options extends EntityManagerClientOptions> {
|
|
892
887
|
#private;
|
|
893
|
-
|
|
888
|
+
/**
|
|
889
|
+
* EntityManagerClient base constructor.
|
|
890
|
+
* @param options - Options object extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
891
|
+
*/
|
|
892
|
+
constructor({ batchSize, delayIncrement, maxRetries, throttle, logger, logInternals, ...childOptions }: Options);
|
|
894
893
|
/**
|
|
895
894
|
* Returns the options used to create the EntityManagerClient instance.
|
|
896
895
|
*/
|
|
897
|
-
get options(): Required<
|
|
896
|
+
get options(): Required<Options>;
|
|
898
897
|
/**
|
|
899
898
|
* Executes a batch operation.
|
|
900
899
|
*
|
|
@@ -911,6 +910,37 @@ declare abstract class EntityManagerClient<O extends EntityManagerClientOptions>
|
|
|
911
910
|
protected batchExecute<Item, Output>(items: Item[], executeBatch: (items: Item[]) => Promise<Output>, getUnprocessedItems?: (output: Output) => Item[] | undefined, { batchSize, delayIncrement, maxRetries, throttle, }?: EntityManagerClientBatchOptions): Promise<Output[]>;
|
|
912
911
|
}
|
|
913
912
|
|
|
913
|
+
/**
|
|
914
|
+
* {@link ShardQueryFunctionBuilder | `ShardQueryFunctionBuilder`} options.
|
|
915
|
+
*
|
|
916
|
+
* @category Query
|
|
917
|
+
*/
|
|
918
|
+
interface ShardQueryFunctionBuilderOptions<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> {
|
|
919
|
+
/** {@link EntityManager | `EntityManager`} instance. */
|
|
920
|
+
entityManager: EntityManager<M, HashKey, RangeKey, T>;
|
|
921
|
+
/** `entityManager.config.entities` key. */
|
|
922
|
+
entityToken: EntityToken;
|
|
923
|
+
/** Either the designated entity hash key or a generated property with `sharded === true`. */
|
|
924
|
+
hashKeyToken: HashKey | PropertiesOfType<M[EntityToken], void>;
|
|
925
|
+
/** `entityManager.config.entities.<entityToken>.indexes` key. */
|
|
926
|
+
indexToken: string;
|
|
927
|
+
/** A partial `Item` sufficiently populated to generate the query hash key & index values. */
|
|
928
|
+
item: Partial<Item>;
|
|
929
|
+
/** Dehydrated page key from the previous query data page. */
|
|
930
|
+
pageKey?: string;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Entity Manager shard query builder base class.
|
|
935
|
+
*
|
|
936
|
+
* @category Query
|
|
937
|
+
*/
|
|
938
|
+
declare abstract class ShardQueryFunctionBuilder<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, Options extends ShardQueryFunctionBuilderOptions<Item, EntityToken, M, HashKey, RangeKey, T>> {
|
|
939
|
+
private readonly options;
|
|
940
|
+
constructor(options: Options);
|
|
941
|
+
abstract getShardQueryFunction(): ShardQueryFunction<Item, EntityToken, M, HashKey, RangeKey, T>;
|
|
942
|
+
}
|
|
943
|
+
|
|
914
944
|
/**
|
|
915
945
|
* Returns an object type with specific properties rendered required and non-nullable.
|
|
916
946
|
*
|
|
@@ -921,4 +951,4 @@ type WithRequiredAndNonNullable<T, K extends keyof T> = T & {
|
|
|
921
951
|
[P in K]-?: NonNullable<T[P]>;
|
|
922
952
|
};
|
|
923
953
|
|
|
924
|
-
export { type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigKeys, type ConfigTranscodes, EntityManager, EntityManagerClient, type EntityManagerClientBatchOptions, type EntityManagerClientOptions, type EntityMap, type ExclusiveKey, type ItemMap, type Logger, type LoggerEndpoint, type LoggerOptions, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryResult, type Unwrap, type WithRequiredAndNonNullable, conditionalize };
|
|
954
|
+
export { type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigKeys, type ConfigTranscodes, EntityManager, EntityManagerClient, type EntityManagerClientBatchOptions, type EntityManagerClientOptions, type EntityMap, type ExclusiveKey, type ItemMap, type Logger, type LoggerEndpoint, type LoggerOptions, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, ShardQueryFunctionBuilder, type ShardQueryFunctionBuilderOptions, type ShardQueryResult, type Unwrap, type WithRequiredAndNonNullable, conditionalize };
|
|
@@ -7,9 +7,15 @@ var _EntityManagerClient_options;
|
|
|
7
7
|
/**
|
|
8
8
|
* EntityManagerClient base class.
|
|
9
9
|
*
|
|
10
|
+
* @typeParam Options - Options type extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
11
|
+
*
|
|
10
12
|
* @category Client
|
|
11
13
|
*/
|
|
12
14
|
class EntityManagerClient {
|
|
15
|
+
/**
|
|
16
|
+
* EntityManagerClient base constructor.
|
|
17
|
+
* @param options - Options object extended from {@link EntityManagerClientOptions | `EntityManagerClientOptions`}.
|
|
18
|
+
*/
|
|
13
19
|
constructor({ batchSize = 25, delayIncrement = 100, maxRetries = 5, throttle = 10, logger = console, logInternals = false, ...childOptions }) {
|
|
14
20
|
_EntityManagerClient_options.set(this, void 0);
|
|
15
21
|
if (!isFunction(logger.debug))
|
package/dist/mjs/index.js
CHANGED
package/dist/mjs/query.js
CHANGED
|
@@ -25,7 +25,7 @@ const { compressToEncodedURIComponent, decompressFromEncodedURIComponent } = lzS
|
|
|
25
25
|
*
|
|
26
26
|
* @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
|
|
27
27
|
*/
|
|
28
|
-
async function query(entityManager, { entityToken, hashKey,
|
|
28
|
+
async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
|
|
29
29
|
try {
|
|
30
30
|
// Get defaults.
|
|
31
31
|
const { defaultLimit, defaultPageSize } = entityManager.config.entities[entityToken];
|
package/package.json
CHANGED