@karmaniverous/entity-manager 6.4.6 → 6.4.7

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.
@@ -5,10 +5,10 @@
5
5
  *
6
6
  * @category Query
7
7
  */
8
- class ShardQueryMapBuilder {
8
+ class BaseShardQueryMapBuilder {
9
9
  constructor(options) {
10
10
  this.options = options;
11
11
  }
12
12
  }
13
13
 
14
- exports.ShardQueryMapBuilder = ShardQueryMapBuilder;
14
+ exports.BaseShardQueryMapBuilder = BaseShardQueryMapBuilder;
package/dist/cjs/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var BaseShardQueryMapBuilder = require('./BaseShardQueryMapBuilder.js');
3
4
  var conditionalize = require('./conditionalize.js');
4
5
  var EntityManager = require('./EntityManager.js');
5
- var ShardQueryMapBuilder = require('./ShardQueryMapBuilder.js');
6
6
 
7
7
 
8
8
 
9
+ exports.BaseShardQueryMapBuilder = BaseShardQueryMapBuilder.BaseShardQueryMapBuilder;
9
10
  exports.conditionalize = conditionalize.conditionalize;
10
11
  exports.EntityManager = EntityManager.EntityManager;
11
- exports.ShardQueryMapBuilder = ShardQueryMapBuilder.ShardQueryMapBuilder;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,66 @@ import { Entity, Exactify, TranscodeMap, PropertiesOfType, TranscodablePropertie
2
2
  export { DefaultTranscodeMap, Entity, Exactify, PartialTranscodable, PropertiesNotOfType, PropertiesOfType, SortOrder, TranscodableProperties, TranscodeMap, Transcodes, defaultTranscodes } from '@karmaniverous/entity-tools';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * {@link BaseShardQueryMapBuilder | `BaseShardQueryMapBuilder`} options.
7
+ *
8
+ * @category Query
9
+ */
10
+ interface BaseShardQueryMapBuilderOptions {
11
+ /** `entityManager.config.entities` key. */
12
+ entityToken: string;
13
+ /** Either the designated entity hash key or a generated property with `sharded === true`. */
14
+ hashKeyToken: string;
15
+ /** Dehydrated page key from the previous query data page. */
16
+ pageKey?: string;
17
+ }
18
+
19
+ /**
20
+ * A result returned by a {@link ShardQueryFunction | `ShardQueryFunction`} querying an individual shard.
21
+ *
22
+ * @typeParam Item - The {@link Item | `Item`} type being queried.
23
+
24
+ * @category Query
25
+ */
26
+ interface ShardQueryResult<Item extends Entity> {
27
+ /** The number of records returned. */
28
+ count: number;
29
+ /** The returned records. */
30
+ items: Item[];
31
+ /** The page key for the next query on this shard. */
32
+ pageKey?: Partial<Item>;
33
+ }
34
+
35
+ /**
36
+ * A query function that returns a single page of results from an individual
37
+ * shard. This function will typically be composed dynamically to express a
38
+ * specific query index & logic. The arguments to this function will be
39
+ * provided by the {@link EntityManager.query | `EntityManager.query`} method, which assembles many returned
40
+ * pages queried across multiple shards into a single query result.
41
+ *
42
+ * @typeParam Item - The {@link Item | `Item`} type being queried.
43
+
44
+ * @param hashKey - The hash key value of the shard being queried.
45
+ * @param pageKey - The page key returned by the previous query on this shard.
46
+ * @param pageSize - The maximum number of items to return from this query.
47
+ *
48
+ * @category Query
49
+ */
50
+ type ShardQueryFunction<Item extends Entity> = (hashKey: string, pageKey?: Partial<Item>, pageSize?: number) => Promise<ShardQueryResult<Item>>;
51
+
52
+ type ShardQueryMap<Item extends Entity> = Record<string, ShardQueryFunction<Item>>;
53
+
54
+ /**
55
+ * Entity Manager shard query builder base class.
56
+ *
57
+ * @category Query
58
+ */
59
+ declare abstract class BaseShardQueryMapBuilder<Item extends Entity, Options extends BaseShardQueryMapBuilderOptions> {
60
+ readonly options: Options;
61
+ constructor(options: Options);
62
+ abstract getShardQueryMap(): ShardQueryMap<Item>;
63
+ }
64
+
5
65
  /**
6
66
  * Transforms a function such that it only executes when `condition` is truthy.
7
67
  *
@@ -629,41 +689,6 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
629
689
  */
630
690
  type ParsedConfig = z.infer<typeof configSchema>;
631
691
 
632
- /**
633
- * A result returned by a {@link ShardQueryFunction | `ShardQueryFunction`} querying an individual shard.
634
- *
635
- * @typeParam Item - The {@link Item | `Item`} type being queried.
636
-
637
- * @category Query
638
- */
639
- interface ShardQueryResult<Item extends Entity> {
640
- /** The number of records returned. */
641
- count: number;
642
- /** The returned records. */
643
- items: Item[];
644
- /** The page key for the next query on this shard. */
645
- pageKey?: Partial<Item>;
646
- }
647
-
648
- /**
649
- * A query function that returns a single page of results from an individual
650
- * shard. This function will typically be composed dynamically to express a
651
- * specific query index & logic. The arguments to this function will be
652
- * provided by the {@link EntityManager.query | `EntityManager.query`} method, which assembles many returned
653
- * pages queried across multiple shards into a single query result.
654
- *
655
- * @typeParam Item - The {@link Item | `Item`} type being queried.
656
-
657
- * @param hashKey - The hash key value of the shard being queried.
658
- * @param pageKey - The page key returned by the previous query on this shard.
659
- * @param pageSize - The maximum number of items to return from this query.
660
- *
661
- * @category Query
662
- */
663
- type ShardQueryFunction<Item extends Entity> = (hashKey: string, pageKey?: Partial<Item>, pageSize?: number) => Promise<ShardQueryResult<Item>>;
664
-
665
- type ShardQueryMap<Item extends Entity> = Record<string, ShardQueryFunction<Item>>;
666
-
667
692
  /**
668
693
  * Options passed to the {@link EntityManager.query | `EntityManager.query`} method.
669
694
  *
@@ -858,31 +883,6 @@ interface LoggerOptions {
858
883
  logInternals?: boolean;
859
884
  }
860
885
 
861
- /**
862
- * {@link ShardQueryMapBuilder | `ShardQueryMapBuilder`} options.
863
- *
864
- * @category Query
865
- */
866
- interface ShardQueryMapBuilderOptions {
867
- /** `entityManager.config.entities` key. */
868
- entityToken: string;
869
- /** Either the designated entity hash key or a generated property with `sharded === true`. */
870
- hashKeyToken: string;
871
- /** Dehydrated page key from the previous query data page. */
872
- pageKey?: string;
873
- }
874
-
875
- /**
876
- * Entity Manager shard query builder base class.
877
- *
878
- * @category Query
879
- */
880
- declare abstract class ShardQueryMapBuilder<Item extends Entity, Options extends ShardQueryMapBuilderOptions> {
881
- readonly options: Options;
882
- constructor(options: Options);
883
- abstract getShardQueryMap(): ShardQueryMap<Item>;
884
- }
885
-
886
886
  /**
887
887
  * Returns an object type with specific properties rendered required and non-nullable.
888
888
  *
@@ -893,4 +893,4 @@ type WithRequiredAndNonNullable<T, K extends keyof T> = T & {
893
893
  [P in K]-?: NonNullable<T[P]>;
894
894
  };
895
895
 
896
- export { type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigKeys, type ConfigTranscodes, EntityManager, 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 };
896
+ export { BaseShardQueryMapBuilder, type BaseShardQueryMapBuilderOptions, type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type Logger, type LoggerEndpoint, type LoggerOptions, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryResult, type Unwrap, type WithRequiredAndNonNullable, conditionalize };
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @category Query
5
5
  */
6
- class ShardQueryMapBuilder {
6
+ class BaseShardQueryMapBuilder {
7
7
  constructor(options) {
8
8
  this.options = options;
9
9
  }
10
10
  }
11
11
 
12
- export { ShardQueryMapBuilder };
12
+ export { BaseShardQueryMapBuilder };
package/dist/mjs/index.js CHANGED
@@ -1,3 +1,3 @@
1
+ export { BaseShardQueryMapBuilder } from './BaseShardQueryMapBuilder.js';
1
2
  export { conditionalize } from './conditionalize.js';
2
3
  export { EntityManager } from './EntityManager.js';
3
- export { ShardQueryMapBuilder } from './ShardQueryMapBuilder.js';
package/package.json CHANGED
@@ -132,5 +132,5 @@
132
132
  },
133
133
  "type": "module",
134
134
  "types": "dist/index.d.ts",
135
- "version": "6.4.6"
135
+ "version": "6.4.7"
136
136
  }