dyno-table 1.6.0 → 1.8.0-next.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.
Files changed (74) hide show
  1. package/README.md +53 -140
  2. package/dist/batch-builder-BOBwOIUE.d.ts +398 -0
  3. package/dist/batch-builder-CKYnMRyz.d.cts +398 -0
  4. package/dist/{builder-types-DlaUSc-b.d.cts → builder-types-BTVhQSHI.d.cts} +55 -5
  5. package/dist/{builder-types-B_tCpn9F.d.ts → builder-types-CzuLR4Th.d.ts} +55 -5
  6. package/dist/builders/condition-check-builder.cjs +0 -13
  7. package/dist/builders/condition-check-builder.cjs.map +1 -1
  8. package/dist/builders/condition-check-builder.d.cts +1 -14
  9. package/dist/builders/condition-check-builder.d.ts +1 -14
  10. package/dist/builders/condition-check-builder.js +0 -13
  11. package/dist/builders/condition-check-builder.js.map +1 -1
  12. package/dist/builders/delete-builder.cjs +38 -0
  13. package/dist/builders/delete-builder.cjs.map +1 -1
  14. package/dist/builders/delete-builder.d.cts +37 -1
  15. package/dist/builders/delete-builder.d.ts +37 -1
  16. package/dist/builders/delete-builder.js +38 -0
  17. package/dist/builders/delete-builder.js.map +1 -1
  18. package/dist/builders/paginator.cjs +21 -27
  19. package/dist/builders/paginator.cjs.map +1 -1
  20. package/dist/builders/paginator.d.cts +3 -27
  21. package/dist/builders/paginator.d.ts +3 -27
  22. package/dist/builders/paginator.js +21 -27
  23. package/dist/builders/paginator.js.map +1 -1
  24. package/dist/builders/put-builder.cjs +39 -8
  25. package/dist/builders/put-builder.cjs.map +1 -1
  26. package/dist/builders/put-builder.d.cts +38 -9
  27. package/dist/builders/put-builder.d.ts +38 -9
  28. package/dist/builders/put-builder.js +39 -8
  29. package/dist/builders/put-builder.js.map +1 -1
  30. package/dist/builders/query-builder.cjs +115 -75
  31. package/dist/builders/query-builder.cjs.map +1 -1
  32. package/dist/builders/query-builder.d.cts +2 -2
  33. package/dist/builders/query-builder.d.ts +2 -2
  34. package/dist/builders/query-builder.js +115 -75
  35. package/dist/builders/query-builder.js.map +1 -1
  36. package/dist/builders/transaction-builder.cjs +0 -47
  37. package/dist/builders/transaction-builder.cjs.map +1 -1
  38. package/dist/builders/transaction-builder.d.cts +1 -48
  39. package/dist/builders/transaction-builder.d.ts +1 -48
  40. package/dist/builders/transaction-builder.js +0 -47
  41. package/dist/builders/transaction-builder.js.map +1 -1
  42. package/dist/builders/update-builder.cjs +2 -2
  43. package/dist/builders/update-builder.cjs.map +1 -1
  44. package/dist/builders/update-builder.d.cts +3 -3
  45. package/dist/builders/update-builder.d.ts +3 -3
  46. package/dist/builders/update-builder.js +2 -2
  47. package/dist/builders/update-builder.js.map +1 -1
  48. package/dist/conditions.cjs.map +1 -1
  49. package/dist/conditions.js.map +1 -1
  50. package/dist/entity.cjs +69 -37
  51. package/dist/entity.cjs.map +1 -1
  52. package/dist/entity.d.cts +30 -10
  53. package/dist/entity.d.ts +30 -10
  54. package/dist/entity.js +69 -37
  55. package/dist/entity.js.map +1 -1
  56. package/dist/index.cjs +661 -218
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +4 -3
  59. package/dist/index.d.ts +4 -3
  60. package/dist/index.js +660 -219
  61. package/dist/index.js.map +1 -1
  62. package/dist/{query-builder-BhrR31oO.d.ts → query-builder-CaHzZmDf.d.ts} +31 -63
  63. package/dist/{query-builder-CbHvimBk.d.cts → query-builder-DFkxojBM.d.cts} +31 -63
  64. package/dist/{table-CY9byPEg.d.cts → table-CHitMHXE.d.cts} +55 -169
  65. package/dist/{table-Des8C2od.d.ts → table-m7DQk5dK.d.ts} +55 -169
  66. package/dist/table.cjs +590 -181
  67. package/dist/table.cjs.map +1 -1
  68. package/dist/table.d.cts +4 -3
  69. package/dist/table.d.ts +4 -3
  70. package/dist/table.js +590 -181
  71. package/dist/table.js.map +1 -1
  72. package/dist/utils.cjs.map +1 -1
  73. package/dist/utils.js.map +1 -1
  74. package/package.json +1 -1
@@ -1,152 +1,13 @@
1
1
  import { DynamoItem, TableConfig, Index } from './types.cjs';
2
2
  import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-3ae5znV_.cjs';
3
- import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-CbHvimBk.cjs';
3
+ import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-DFkxojBM.cjs';
4
4
  import { PutBuilder } from './builders/put-builder.cjs';
5
5
  import { DeleteBuilder } from './builders/delete-builder.cjs';
6
6
  import { UpdateBuilder } from './builders/update-builder.cjs';
7
7
  import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.cjs';
8
+ import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-CKYnMRyz.cjs';
8
9
  import { ConditionCheckBuilder } from './builders/condition-check-builder.cjs';
9
- import { S as ScanBuilderInterface } from './builder-types-DlaUSc-b.cjs';
10
-
11
- type BatchWriteOperation<T extends Record<string, unknown>> = {
12
- type: "put";
13
- item: T;
14
- } | {
15
- type: "delete";
16
- key: PrimaryKeyWithoutExpression;
17
- };
18
-
19
- /**
20
- * Parameters for the DynamoDB get command.
21
- */
22
- interface GetCommandParams {
23
- /** The name of the DynamoDB table */
24
- tableName: string;
25
- /** The primary key of the item to get */
26
- key: PrimaryKeyWithoutExpression;
27
- /** Comma-separated list of attributes to return */
28
- projectionExpression?: string;
29
- /** Map of expression attribute name placeholders to actual names */
30
- expressionAttributeNames?: Record<string, string>;
31
- /** Whether to use strongly consistent reads */
32
- consistentRead?: boolean;
33
- }
34
- /**
35
- * Function type for executing DynamoDB get operations.
36
- * @typeParam T - The type of item being retrieved
37
- */
38
- type GetExecutor<T extends DynamoItem> = (params: GetCommandParams) => Promise<{
39
- item: T | undefined;
40
- }>;
41
- /**
42
- * Builder for creating DynamoDB get operations.
43
- * Use this builder when you need to:
44
- * - Retrieve a single dinosaur by its primary key
45
- * - Project specific dinosaur attributes
46
- * - Use consistent reads for critical dinosaur data
47
- *
48
- * @example
49
- * ```typescript
50
- * // Simple get
51
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
52
- * .execute();
53
- *
54
- * // Get with projection and consistent read
55
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
56
- * .select(['species', 'name', 'diet'])
57
- * .consistentRead()
58
- * .execute();
59
- * ```
60
- *
61
- * @typeParam T - The type of item being retrieved
62
- */
63
- declare class GetBuilder<T extends DynamoItem> {
64
- private readonly executor;
65
- private readonly params;
66
- private options;
67
- private selectedFields;
68
- /**
69
- * Creates a new GetBuilder instance.
70
- *
71
- * @param executor - Function that executes the get operation
72
- * @param key - Primary key of the item to retrieve
73
- * @param tableName - Name of the DynamoDB table
74
- */
75
- constructor(executor: GetExecutor<T>, key: PrimaryKeyWithoutExpression, tableName: string);
76
- /**
77
- * Specifies which attributes to return in the get results.
78
- * Use this method when you need to:
79
- * - Reduce data transfer by selecting specific dinosaur attributes
80
- * - Optimize response size for dinosaur records
81
- * - Focus on relevant dinosaur characteristics only
82
- *
83
- * @example
84
- * ```typescript
85
- * // Select single attribute
86
- * builder.select('species')
87
- *
88
- * // Select multiple attributes
89
- * builder.select(['id', 'species', 'diet'])
90
- *
91
- * // Chain multiple select calls
92
- * builder
93
- * .select('id')
94
- * .select(['species', 'diet'])
95
- * ```
96
- *
97
- * @param fields - A single field name or an array of field names to return
98
- * @returns The builder instance for method chaining
99
- */
100
- select(fields: string | string[]): GetBuilder<T>;
101
- /**
102
- * Sets whether to use strongly consistent reads for the get operation.
103
- * Use this method when you need:
104
- * - The most up-to-date dinosaur data
105
- * - To ensure you're reading the latest dinosaur status
106
- * - Critical safety information about dangerous species
107
- *
108
- * Note: Consistent reads consume twice the throughput
109
- *
110
- * @example
111
- * ```typescript
112
- * // Get the latest T-Rex data
113
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
114
- * .consistentRead()
115
- * .execute();
116
- * ```
117
- *
118
- * @param consistentRead - Whether to use consistent reads (defaults to true)
119
- * @returns The builder instance for method chaining
120
- */
121
- consistentRead(consistentRead?: boolean): GetBuilder<T>;
122
- /**
123
- * Executes the get operation against DynamoDB.
124
- *
125
- * @example
126
- * ```typescript
127
- * try {
128
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
129
- * .select(['species', 'name', 'diet'])
130
- * .consistentRead()
131
- * .execute();
132
- *
133
- * if (result.item) {
134
- * console.log('Dinosaur found:', result.item);
135
- * } else {
136
- * console.log('Dinosaur not found');
137
- * }
138
- * } catch (error) {
139
- * console.error('Error getting dinosaur:', error);
140
- * }
141
- * ```
142
- *
143
- * @returns A promise that resolves to an object containing:
144
- * - item: The retrieved dinosaur or undefined if not found
145
- */
146
- execute(): Promise<{
147
- item: T | undefined;
148
- }>;
149
- }
10
+ import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-BTVhQSHI.cjs';
150
11
 
151
12
  /**
152
13
  * Configuration options for DynamoDB scan operations.
@@ -211,57 +72,46 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
211
72
  constructor(executor: ScanExecutor<T>);
212
73
  /**
213
74
  * Creates a deep clone of this ScanBuilder instance.
214
- * Use this method when you need to:
215
- * - Create scan templates
216
- * - Run multiple variations of a scan
217
- * - Implement pagination (used internally by paginate())
218
75
  *
219
76
  * @returns A new ScanBuilder instance with the same configuration
220
77
  */
221
78
  clone(): ScanBuilder<T, TConfig>;
222
79
  /**
223
- * Executes the scan against DynamoDB.
224
- * Use this method when you need to:
225
- * - Search across the entire table
226
- * - Find items matching specific criteria
227
- * - Perform full table analysis
228
- * - Generate reports across all data
80
+ * Executes the scan against DynamoDB and returns a generator that behaves like an array.
229
81
  *
230
- * The method returns both the matched items and, if there are more results,
231
- * a lastEvaluatedKey that can be used with startFrom() to continue the scan.
82
+ * The generator automatically handles pagination and provides array-like methods
83
+ * for processing results efficiently without loading everything into memory at once.
232
84
  *
233
85
  * @example
234
86
  * ```typescript
235
87
  * try {
236
- * // Find all dinosaurs with high aggression levels
237
- * const result = await new ScanBuilder(executor)
88
+ * // Find all dinosaurs with high aggression levels with automatic pagination
89
+ * const results = await new ScanBuilder(executor)
238
90
  * .filter(op =>
239
91
  * op.and([
240
92
  * op.eq('status', 'ACTIVE'),
241
93
  * op.gt('aggressionLevel', 7)
242
94
  * ])
243
95
  * )
244
- * .limit(20)
245
96
  * .execute();
246
97
  *
247
- * console.log(`Found ${result.items.length} potentially dangerous dinosaurs`);
248
- *
249
- * if (result.lastEvaluatedKey) {
250
- * console.log('More results available');
98
+ * // Use like an array with automatic pagination
99
+ * for await (const dinosaur of results) {
100
+ * console.log(`Processing dangerous dinosaur: ${dinosaur.name}`);
251
101
  * }
102
+ *
103
+ * // Or convert to array and use array methods
104
+ * const allItems = await results.toArray();
105
+ * const criticalThreats = allItems.filter(dino => dino.aggressionLevel > 9);
106
+ * const totalCount = allItems.length;
252
107
  * } catch (error) {
253
108
  * console.error('Security scan failed:', error);
254
109
  * }
255
110
  * ```
256
111
  *
257
- * @returns A promise that resolves to an object containing:
258
- * - items: Array of items matching the scan criteria
259
- * - lastEvaluatedKey: Token for continuing the scan, if more items exist
112
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
260
113
  */
261
- execute(): Promise<{
262
- items: T[];
263
- lastEvaluatedKey?: Record<string, unknown>;
264
- }>;
114
+ execute(): Promise<ResultIterator<T, TConfig>>;
265
115
  }
266
116
 
267
117
  declare class Table<TConfig extends TableConfig = TableConfig> {
@@ -348,6 +198,42 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
348
198
  * Creates a transaction builder for performing multiple operations atomically
349
199
  */
350
200
  transactionBuilder(): TransactionBuilder;
201
+ /**
202
+ * Creates a batch builder for performing multiple operations efficiently with optional type inference
203
+ *
204
+ * @example Basic Usage
205
+ * ```typescript
206
+ * const batch = table.batchBuilder();
207
+ *
208
+ * // Add operations
209
+ * userRepo.create(newUser).withBatch(batch);
210
+ * orderRepo.get({ id: 'order-1' }).withBatch(batch);
211
+ *
212
+ * // Execute operations
213
+ * const result = await batch.execute();
214
+ * ```
215
+ *
216
+ * @example Typed Usage
217
+ * ```typescript
218
+ * // Define entity types for the batch
219
+ * const batch = table.batchBuilder<{
220
+ * User: UserEntity;
221
+ * Order: OrderEntity;
222
+ * Product: ProductEntity;
223
+ * }>();
224
+ *
225
+ * // Add operations with type information
226
+ * userRepo.create(newUser).withBatch(batch, 'User');
227
+ * orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
228
+ * productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
229
+ *
230
+ * // Execute and get typed results
231
+ * const result = await batch.execute();
232
+ * const users: UserEntity[] = result.reads.itemsByType.User;
233
+ * const orders: OrderEntity[] = result.reads.itemsByType.Order;
234
+ * ```
235
+ */
236
+ batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
351
237
  /**
352
238
  * Executes a transaction using a callback function
353
239
  *
@@ -386,4 +272,4 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
386
272
  }>;
387
273
  }
388
274
 
389
- export { GetBuilder as G, ScanBuilder as S, Table as T };
275
+ export { ScanBuilder as S, Table as T };
@@ -1,152 +1,13 @@
1
1
  import { DynamoItem, TableConfig, Index } from './types.js';
2
2
  import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-BtynAviC.js';
3
- import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-BhrR31oO.js';
3
+ import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-CaHzZmDf.js';
4
4
  import { PutBuilder } from './builders/put-builder.js';
5
5
  import { DeleteBuilder } from './builders/delete-builder.js';
6
6
  import { UpdateBuilder } from './builders/update-builder.js';
7
7
  import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.js';
8
+ import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-BOBwOIUE.js';
8
9
  import { ConditionCheckBuilder } from './builders/condition-check-builder.js';
9
- import { S as ScanBuilderInterface } from './builder-types-B_tCpn9F.js';
10
-
11
- type BatchWriteOperation<T extends Record<string, unknown>> = {
12
- type: "put";
13
- item: T;
14
- } | {
15
- type: "delete";
16
- key: PrimaryKeyWithoutExpression;
17
- };
18
-
19
- /**
20
- * Parameters for the DynamoDB get command.
21
- */
22
- interface GetCommandParams {
23
- /** The name of the DynamoDB table */
24
- tableName: string;
25
- /** The primary key of the item to get */
26
- key: PrimaryKeyWithoutExpression;
27
- /** Comma-separated list of attributes to return */
28
- projectionExpression?: string;
29
- /** Map of expression attribute name placeholders to actual names */
30
- expressionAttributeNames?: Record<string, string>;
31
- /** Whether to use strongly consistent reads */
32
- consistentRead?: boolean;
33
- }
34
- /**
35
- * Function type for executing DynamoDB get operations.
36
- * @typeParam T - The type of item being retrieved
37
- */
38
- type GetExecutor<T extends DynamoItem> = (params: GetCommandParams) => Promise<{
39
- item: T | undefined;
40
- }>;
41
- /**
42
- * Builder for creating DynamoDB get operations.
43
- * Use this builder when you need to:
44
- * - Retrieve a single dinosaur by its primary key
45
- * - Project specific dinosaur attributes
46
- * - Use consistent reads for critical dinosaur data
47
- *
48
- * @example
49
- * ```typescript
50
- * // Simple get
51
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
52
- * .execute();
53
- *
54
- * // Get with projection and consistent read
55
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
56
- * .select(['species', 'name', 'diet'])
57
- * .consistentRead()
58
- * .execute();
59
- * ```
60
- *
61
- * @typeParam T - The type of item being retrieved
62
- */
63
- declare class GetBuilder<T extends DynamoItem> {
64
- private readonly executor;
65
- private readonly params;
66
- private options;
67
- private selectedFields;
68
- /**
69
- * Creates a new GetBuilder instance.
70
- *
71
- * @param executor - Function that executes the get operation
72
- * @param key - Primary key of the item to retrieve
73
- * @param tableName - Name of the DynamoDB table
74
- */
75
- constructor(executor: GetExecutor<T>, key: PrimaryKeyWithoutExpression, tableName: string);
76
- /**
77
- * Specifies which attributes to return in the get results.
78
- * Use this method when you need to:
79
- * - Reduce data transfer by selecting specific dinosaur attributes
80
- * - Optimize response size for dinosaur records
81
- * - Focus on relevant dinosaur characteristics only
82
- *
83
- * @example
84
- * ```typescript
85
- * // Select single attribute
86
- * builder.select('species')
87
- *
88
- * // Select multiple attributes
89
- * builder.select(['id', 'species', 'diet'])
90
- *
91
- * // Chain multiple select calls
92
- * builder
93
- * .select('id')
94
- * .select(['species', 'diet'])
95
- * ```
96
- *
97
- * @param fields - A single field name or an array of field names to return
98
- * @returns The builder instance for method chaining
99
- */
100
- select(fields: string | string[]): GetBuilder<T>;
101
- /**
102
- * Sets whether to use strongly consistent reads for the get operation.
103
- * Use this method when you need:
104
- * - The most up-to-date dinosaur data
105
- * - To ensure you're reading the latest dinosaur status
106
- * - Critical safety information about dangerous species
107
- *
108
- * Note: Consistent reads consume twice the throughput
109
- *
110
- * @example
111
- * ```typescript
112
- * // Get the latest T-Rex data
113
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
114
- * .consistentRead()
115
- * .execute();
116
- * ```
117
- *
118
- * @param consistentRead - Whether to use consistent reads (defaults to true)
119
- * @returns The builder instance for method chaining
120
- */
121
- consistentRead(consistentRead?: boolean): GetBuilder<T>;
122
- /**
123
- * Executes the get operation against DynamoDB.
124
- *
125
- * @example
126
- * ```typescript
127
- * try {
128
- * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
129
- * .select(['species', 'name', 'diet'])
130
- * .consistentRead()
131
- * .execute();
132
- *
133
- * if (result.item) {
134
- * console.log('Dinosaur found:', result.item);
135
- * } else {
136
- * console.log('Dinosaur not found');
137
- * }
138
- * } catch (error) {
139
- * console.error('Error getting dinosaur:', error);
140
- * }
141
- * ```
142
- *
143
- * @returns A promise that resolves to an object containing:
144
- * - item: The retrieved dinosaur or undefined if not found
145
- */
146
- execute(): Promise<{
147
- item: T | undefined;
148
- }>;
149
- }
10
+ import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-CzuLR4Th.js';
150
11
 
151
12
  /**
152
13
  * Configuration options for DynamoDB scan operations.
@@ -211,57 +72,46 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
211
72
  constructor(executor: ScanExecutor<T>);
212
73
  /**
213
74
  * Creates a deep clone of this ScanBuilder instance.
214
- * Use this method when you need to:
215
- * - Create scan templates
216
- * - Run multiple variations of a scan
217
- * - Implement pagination (used internally by paginate())
218
75
  *
219
76
  * @returns A new ScanBuilder instance with the same configuration
220
77
  */
221
78
  clone(): ScanBuilder<T, TConfig>;
222
79
  /**
223
- * Executes the scan against DynamoDB.
224
- * Use this method when you need to:
225
- * - Search across the entire table
226
- * - Find items matching specific criteria
227
- * - Perform full table analysis
228
- * - Generate reports across all data
80
+ * Executes the scan against DynamoDB and returns a generator that behaves like an array.
229
81
  *
230
- * The method returns both the matched items and, if there are more results,
231
- * a lastEvaluatedKey that can be used with startFrom() to continue the scan.
82
+ * The generator automatically handles pagination and provides array-like methods
83
+ * for processing results efficiently without loading everything into memory at once.
232
84
  *
233
85
  * @example
234
86
  * ```typescript
235
87
  * try {
236
- * // Find all dinosaurs with high aggression levels
237
- * const result = await new ScanBuilder(executor)
88
+ * // Find all dinosaurs with high aggression levels with automatic pagination
89
+ * const results = await new ScanBuilder(executor)
238
90
  * .filter(op =>
239
91
  * op.and([
240
92
  * op.eq('status', 'ACTIVE'),
241
93
  * op.gt('aggressionLevel', 7)
242
94
  * ])
243
95
  * )
244
- * .limit(20)
245
96
  * .execute();
246
97
  *
247
- * console.log(`Found ${result.items.length} potentially dangerous dinosaurs`);
248
- *
249
- * if (result.lastEvaluatedKey) {
250
- * console.log('More results available');
98
+ * // Use like an array with automatic pagination
99
+ * for await (const dinosaur of results) {
100
+ * console.log(`Processing dangerous dinosaur: ${dinosaur.name}`);
251
101
  * }
102
+ *
103
+ * // Or convert to array and use array methods
104
+ * const allItems = await results.toArray();
105
+ * const criticalThreats = allItems.filter(dino => dino.aggressionLevel > 9);
106
+ * const totalCount = allItems.length;
252
107
  * } catch (error) {
253
108
  * console.error('Security scan failed:', error);
254
109
  * }
255
110
  * ```
256
111
  *
257
- * @returns A promise that resolves to an object containing:
258
- * - items: Array of items matching the scan criteria
259
- * - lastEvaluatedKey: Token for continuing the scan, if more items exist
112
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
260
113
  */
261
- execute(): Promise<{
262
- items: T[];
263
- lastEvaluatedKey?: Record<string, unknown>;
264
- }>;
114
+ execute(): Promise<ResultIterator<T, TConfig>>;
265
115
  }
266
116
 
267
117
  declare class Table<TConfig extends TableConfig = TableConfig> {
@@ -348,6 +198,42 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
348
198
  * Creates a transaction builder for performing multiple operations atomically
349
199
  */
350
200
  transactionBuilder(): TransactionBuilder;
201
+ /**
202
+ * Creates a batch builder for performing multiple operations efficiently with optional type inference
203
+ *
204
+ * @example Basic Usage
205
+ * ```typescript
206
+ * const batch = table.batchBuilder();
207
+ *
208
+ * // Add operations
209
+ * userRepo.create(newUser).withBatch(batch);
210
+ * orderRepo.get({ id: 'order-1' }).withBatch(batch);
211
+ *
212
+ * // Execute operations
213
+ * const result = await batch.execute();
214
+ * ```
215
+ *
216
+ * @example Typed Usage
217
+ * ```typescript
218
+ * // Define entity types for the batch
219
+ * const batch = table.batchBuilder<{
220
+ * User: UserEntity;
221
+ * Order: OrderEntity;
222
+ * Product: ProductEntity;
223
+ * }>();
224
+ *
225
+ * // Add operations with type information
226
+ * userRepo.create(newUser).withBatch(batch, 'User');
227
+ * orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
228
+ * productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
229
+ *
230
+ * // Execute and get typed results
231
+ * const result = await batch.execute();
232
+ * const users: UserEntity[] = result.reads.itemsByType.User;
233
+ * const orders: OrderEntity[] = result.reads.itemsByType.Order;
234
+ * ```
235
+ */
236
+ batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
351
237
  /**
352
238
  * Executes a transaction using a callback function
353
239
  *
@@ -386,4 +272,4 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
386
272
  }>;
387
273
  }
388
274
 
389
- export { GetBuilder as G, ScanBuilder as S, Table as T };
275
+ export { ScanBuilder as S, Table as T };