@karmaniverous/entity-manager 6.2.3 → 6.3.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.
@@ -82,7 +82,7 @@ class EntityManager {
82
82
  *
83
83
  * @returns {@link QueryResult} object.
84
84
  *
85
- * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
85
+ * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.shardQueryMap | `shardQueryMap`} keys.
86
86
  */
87
87
  async query(options) {
88
88
  return await query.query(this, options);
@@ -5,10 +5,10 @@
5
5
  *
6
6
  * @category Query
7
7
  */
8
- class ShardQueryFunctionBuilder {
8
+ class ShardQueryMapBuilder {
9
9
  constructor(options) {
10
10
  this.options = options;
11
11
  }
12
12
  }
13
13
 
14
- exports.ShardQueryFunctionBuilder = ShardQueryFunctionBuilder;
14
+ exports.ShardQueryMapBuilder = ShardQueryMapBuilder;
package/dist/cjs/index.js CHANGED
@@ -3,11 +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
+ var ShardQueryMapBuilder = require('./ShardQueryMapBuilder.js');
7
7
 
8
8
 
9
9
 
10
10
  exports.conditionalize = conditionalize.conditionalize;
11
11
  exports.EntityManager = EntityManager.EntityManager;
12
12
  exports.EntityManagerClient = EntityManagerClient.EntityManagerClient;
13
- exports.ShardQueryFunctionBuilder = ShardQueryFunctionBuilder.ShardQueryFunctionBuilder;
13
+ exports.ShardQueryMapBuilder = ShardQueryMapBuilder.ShardQueryMapBuilder;
package/dist/cjs/query.js CHANGED
@@ -25,9 +25,9 @@ const { compressToEncodedURIComponent, decompressFromEncodedURIComponent } = lzS
25
25
  *
26
26
  * @returns {@link QueryResult} object.
27
27
  *
28
- * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
28
+ * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.shardQueryMap | `shardQueryMap`} keys.
29
29
  */
30
- async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
30
+ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, shardQueryMap, 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];
@@ -42,7 +42,7 @@ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, p
42
42
  // Rehydrate pageKeyMap.
43
43
  const rehydratedPageKeyMap = rehydratePageKeyMap.rehydratePageKeyMap(entityManager, pageKeyMap
44
44
  ? JSON.parse(decompressFromEncodedURIComponent(pageKeyMap))
45
- : undefined, entityToken, Object.keys(queryMap), timestampFrom, timestampTo);
45
+ : undefined, entityToken, Object.keys(shardQueryMap), timestampFrom, timestampTo);
46
46
  // Shortcut if pageKeyMap is empty.
47
47
  if (!Object.keys(rehydratedPageKeyMap).length)
48
48
  return {
@@ -67,7 +67,7 @@ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, p
67
67
  pageKey,
68
68
  ])), async ([index, hashKey, pageKey]) => ({
69
69
  index,
70
- queryResult: await queryMap[index](hashKey, pageKey, pageSize),
70
+ queryResult: await shardQueryMap[index](hashKey, pageKey, pageSize),
71
71
  hashKey,
72
72
  }));
73
73
  // Reduce shardQueryResults & updateworkingRresult.
package/dist/index.d.ts CHANGED
@@ -664,6 +664,8 @@ interface ShardQueryResult<Item extends ItemMap<M, HashKey, RangeKey>[EntityToke
664
664
  */
665
665
  type ShardQueryFunction<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string, M extends EntityMap, HashKey extends string = 'hashKey', RangeKey extends string = 'rangeKey', T extends TranscodeMap = DefaultTranscodeMap> = (hashKey: string, pageKey?: PartialTranscodable<Item, T>, pageSize?: number) => Promise<ShardQueryResult<Item, EntityToken, M, HashKey, RangeKey, T>>;
666
666
 
667
+ type ShardQueryMap<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> = Record<string, ShardQueryFunction<Item, EntityToken, M, HashKey, RangeKey, T>>;
668
+
667
669
  /**
668
670
  * Options passed to the {@link EntityManager.query | `EntityManager.query`} method.
669
671
  *
@@ -708,7 +710,7 @@ interface QueryOptions<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken],
708
710
  * page key, e.g. to match the same string against `firstName` and `lastName`
709
711
  * properties without performing a table scan for either.
710
712
  */
711
- queryMap: Record<string, ShardQueryFunction<Item, EntityToken, M, HashKey, RangeKey, T>>;
713
+ shardQueryMap: ShardQueryMap<Item, EntityToken, M, HashKey, RangeKey, T>;
712
714
  /**
713
715
  * A {@link SortOrder | `SortOrder`} object specifying the sort order of the result set. Defaults to `[]`.
714
716
  */
@@ -824,7 +826,7 @@ declare class EntityManager<M extends EntityMap, HashKey extends string, RangeKe
824
826
  *
825
827
  * @returns {@link QueryResult} object.
826
828
  *
827
- * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
829
+ * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.shardQueryMap | `shardQueryMap`} keys.
828
830
  */
829
831
  query<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string>(options: QueryOptions<Item, EntityToken, M, HashKey, RangeKey, T>): Promise<QueryResult<Item, EntityToken, M, HashKey, RangeKey>>;
830
832
  }
@@ -911,19 +913,17 @@ declare abstract class EntityManagerClient<Options extends EntityManagerClientOp
911
913
  }
912
914
 
913
915
  /**
914
- * {@link ShardQueryFunctionBuilder | `ShardQueryFunctionBuilder`} options.
916
+ * {@link ShardQueryMapBuilder | `ShardQueryMapBuilder`} options.
915
917
  *
916
918
  * @category Query
917
919
  */
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> {
920
+ interface ShardQueryMapBuilderOptions<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
921
  /** {@link EntityManager | `EntityManager`} instance. */
920
922
  entityManager: EntityManager<M, HashKey, RangeKey, T>;
921
923
  /** `entityManager.config.entities` key. */
922
924
  entityToken: EntityToken;
923
925
  /** 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;
926
+ hashKeyToken: HashKey | (PropertiesOfType<M[EntityToken], void> & string);
927
927
  /** A partial `Item` sufficiently populated to generate the query hash key & index values. */
928
928
  item: Partial<Item>;
929
929
  /** Dehydrated page key from the previous query data page. */
@@ -935,10 +935,10 @@ interface ShardQueryFunctionBuilderOptions<Item extends ItemMap<M, HashKey, Rang
935
935
  *
936
936
  * @category Query
937
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
- protected options: Options;
938
+ declare abstract class ShardQueryMapBuilder<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 ShardQueryMapBuilderOptions<Item, EntityToken, M, HashKey, RangeKey, T>> {
939
+ protected readonly options: Options;
940
940
  constructor(options: Options);
941
- abstract getShardQueryFunction(): ShardQueryFunction<Item, EntityToken, M, HashKey, RangeKey, T>;
941
+ abstract getShardQueryMap(): ShardQueryMap<Item, EntityToken, M, HashKey, RangeKey, T>;
942
942
  }
943
943
 
944
944
  /**
@@ -951,4 +951,4 @@ type WithRequiredAndNonNullable<T, K extends keyof T> = T & {
951
951
  [P in K]-?: NonNullable<T[P]>;
952
952
  };
953
953
 
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 };
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, type ShardQueryMap, ShardQueryMapBuilder, type ShardQueryMapBuilderOptions, type ShardQueryResult, type Unwrap, type WithRequiredAndNonNullable, conditionalize };
@@ -80,7 +80,7 @@ class EntityManager {
80
80
  *
81
81
  * @returns {@link QueryResult} object.
82
82
  *
83
- * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
83
+ * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.shardQueryMap | `shardQueryMap`} keys.
84
84
  */
85
85
  async query(options) {
86
86
  return await query(this, options);
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @category Query
5
5
  */
6
- class ShardQueryFunctionBuilder {
6
+ class ShardQueryMapBuilder {
7
7
  constructor(options) {
8
8
  this.options = options;
9
9
  }
10
10
  }
11
11
 
12
- export { ShardQueryFunctionBuilder };
12
+ export { ShardQueryMapBuilder };
package/dist/mjs/index.js CHANGED
@@ -1,4 +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';
4
+ export { ShardQueryMapBuilder } from './ShardQueryMapBuilder.js';
package/dist/mjs/query.js CHANGED
@@ -23,9 +23,9 @@ const { compressToEncodedURIComponent, decompressFromEncodedURIComponent } = lzS
23
23
  *
24
24
  * @returns {@link QueryResult} object.
25
25
  *
26
- * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.queryMap | `queryMap`} keys.
26
+ * @throws Error if {@link QueryOptions.pageKeyMap | `pageKeyMap`} keys do not match {@link QueryOptions.shardQueryMap | `shardQueryMap`} keys.
27
27
  */
28
- async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, queryMap, sortOrder = [], timestampFrom = 0, timestampTo = Date.now(), throttle = entityManager.config.throttle, }) {
28
+ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, pageSize, shardQueryMap, 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];
@@ -40,7 +40,7 @@ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, p
40
40
  // Rehydrate pageKeyMap.
41
41
  const rehydratedPageKeyMap = rehydratePageKeyMap(entityManager, pageKeyMap
42
42
  ? JSON.parse(decompressFromEncodedURIComponent(pageKeyMap))
43
- : undefined, entityToken, Object.keys(queryMap), timestampFrom, timestampTo);
43
+ : undefined, entityToken, Object.keys(shardQueryMap), timestampFrom, timestampTo);
44
44
  // Shortcut if pageKeyMap is empty.
45
45
  if (!Object.keys(rehydratedPageKeyMap).length)
46
46
  return {
@@ -65,7 +65,7 @@ async function query(entityManager, { entityToken, hashKey, limit, pageKeyMap, p
65
65
  pageKey,
66
66
  ])), async ([index, hashKey, pageKey]) => ({
67
67
  index,
68
- queryResult: await queryMap[index](hashKey, pageKey, pageSize),
68
+ queryResult: await shardQueryMap[index](hashKey, pageKey, pageSize),
69
69
  hashKey,
70
70
  }));
71
71
  // Reduce shardQueryResults & updateworkingRresult.
package/package.json CHANGED
@@ -132,5 +132,5 @@
132
132
  },
133
133
  "type": "module",
134
134
  "types": "dist/index.d.ts",
135
- "version": "6.2.3"
135
+ "version": "6.3.0"
136
136
  }