@karmaniverous/entity-manager 6.1.2 → 6.2.0

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.
@@ -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, item, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
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
@@ -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<O extends EntityManagerClientOptions> {
886
+ declare abstract class EntityManagerClient<Options extends EntityManagerClientOptions> {
892
887
  #private;
893
- constructor({ batchSize, delayIncrement, maxRetries, throttle, logger, logInternals, ...childOptions }: O);
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<O>;
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))
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Entity Manager shard query builder base class.
3
+ *
4
+ * @category Query
5
+ */
6
+ class ShardQueryFunctionBuilder {
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ }
11
+
12
+ export { ShardQueryFunctionBuilder };
package/dist/mjs/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { conditionalize } from './conditionalize.js';
2
2
  export { EntityManager } from './EntityManager.js';
3
3
  export { EntityManagerClient } from './EntityManagerClient.js';
4
+ export { ShardQueryFunctionBuilder } from './ShardQueryFunctionBuilder.js';
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, item, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
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
@@ -132,5 +132,5 @@
132
132
  },
133
133
  "type": "module",
134
134
  "types": "dist/index.d.ts",
135
- "version": "6.1.2"
135
+ "version": "6.2.0"
136
136
  }