dyno-table 1.7.0 → 2.0.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.
Files changed (45) hide show
  1. package/dist/{batch-builder-Dz1yPGrJ.d.ts → batch-builder-BOBwOIUE.d.ts} +1 -1
  2. package/dist/{batch-builder-DNsz6zvh.d.cts → batch-builder-CKYnMRyz.d.cts} +1 -1
  3. package/dist/{builder-types-DlaUSc-b.d.cts → builder-types-BTVhQSHI.d.cts} +55 -5
  4. package/dist/{builder-types-B_tCpn9F.d.ts → builder-types-CzuLR4Th.d.ts} +55 -5
  5. package/dist/builders/condition-check-builder.d.cts +1 -1
  6. package/dist/builders/condition-check-builder.d.ts +1 -1
  7. package/dist/builders/delete-builder.d.cts +2 -2
  8. package/dist/builders/delete-builder.d.ts +2 -2
  9. package/dist/builders/paginator.cjs +21 -3
  10. package/dist/builders/paginator.cjs.map +1 -1
  11. package/dist/builders/paginator.d.cts +3 -3
  12. package/dist/builders/paginator.d.ts +3 -3
  13. package/dist/builders/paginator.js +21 -3
  14. package/dist/builders/paginator.js.map +1 -1
  15. package/dist/builders/put-builder.d.cts +2 -2
  16. package/dist/builders/put-builder.d.ts +2 -2
  17. package/dist/builders/query-builder.cjs +115 -22
  18. package/dist/builders/query-builder.cjs.map +1 -1
  19. package/dist/builders/query-builder.d.cts +2 -2
  20. package/dist/builders/query-builder.d.ts +2 -2
  21. package/dist/builders/query-builder.js +115 -22
  22. package/dist/builders/query-builder.js.map +1 -1
  23. package/dist/builders/transaction-builder.d.cts +1 -1
  24. package/dist/builders/transaction-builder.d.ts +1 -1
  25. package/dist/builders/update-builder.d.cts +1 -1
  26. package/dist/builders/update-builder.d.ts +1 -1
  27. package/dist/entity.d.cts +4 -4
  28. package/dist/entity.d.ts +4 -4
  29. package/dist/index.cjs +131 -36
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +4 -4
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.js +131 -36
  34. package/dist/index.js.map +1 -1
  35. package/dist/{query-builder-C6XjVEFH.d.ts → query-builder-CaHzZmDf.d.ts} +31 -29
  36. package/dist/{query-builder-BDuHHrb-.d.cts → query-builder-DFkxojBM.d.cts} +31 -29
  37. package/dist/{table-DAKlzQsK.d.cts → table-CHitMHXE.d.cts} +18 -20
  38. package/dist/{table-BWa4tx63.d.ts → table-m7DQk5dK.d.ts} +18 -20
  39. package/dist/table.cjs +131 -36
  40. package/dist/table.cjs.map +1 -1
  41. package/dist/table.d.cts +4 -4
  42. package/dist/table.d.ts +4 -4
  43. package/dist/table.js +131 -36
  44. package/dist/table.js.map +1 -1
  45. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { C as Condition, q as ConditionOperator } from './conditions-BtynAviC.js';
2
2
  import { Paginator } from './builders/paginator.js';
3
3
  import { DynamoItem, TableConfig, GSINames } from './types.js';
4
- import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-B_tCpn9F.js';
4
+ import { F as FilterBuilderInterface, R as ResultIterator, Q as QueryBuilderInterface } from './builder-types-CzuLR4Th.js';
5
5
 
6
6
  /**
7
7
  * Configuration options for DynamoDB filter operations.
@@ -179,11 +179,16 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
179
179
  *
180
180
  * @example
181
181
  * ```typescript
182
- * // Create a paginator for dinosaur records
182
+ * // Create a paginator for dinosaur records with specific page size
183
183
  * const paginator = builder
184
184
  * .filter(op => op.eq('status', 'ACTIVE'))
185
185
  * .paginate(10);
186
186
  *
187
+ * // Create a paginator with automatic DynamoDB paging (no page size limit)
188
+ * const autoPaginator = builder
189
+ * .filter(op => op.eq('status', 'ACTIVE'))
190
+ * .paginate();
191
+ *
187
192
  * // Process pages of dinosaur results
188
193
  * while (paginator.hasNextPage()) {
189
194
  * const page = await paginator.getNextPage();
@@ -192,11 +197,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
192
197
  * }
193
198
  * ```
194
199
  *
195
- * @param pageSize - The number of items to return per page
200
+ * @param pageSize - The number of items to return per page. If not provided, DynamoDB will automatically determine page sizes.
196
201
  * @returns A Paginator instance that manages the pagination state
197
202
  * @see Paginator for more pagination control options
198
203
  */
199
- paginate(pageSize: number): Paginator<T, TConfig>;
204
+ paginate(pageSize?: number): Paginator<T, TConfig>;
200
205
  /**
201
206
  * Sets the starting point using a previous lastEvaluatedKey.
202
207
  *
@@ -211,15 +216,17 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
211
216
  * .limit(5)
212
217
  * .execute();
213
218
  *
214
- * if (result1.lastEvaluatedKey) {
219
+ * const lastKey = result1.getLastEvaluatedKey();
220
+ * if (lastKey) {
215
221
  * // Continue listing dinosaurs
216
222
  * const result2 = await builder
217
223
  * .filter(op => op.eq('status', 'ACTIVE'))
218
- * .startFrom(result1.lastEvaluatedKey)
224
+ * .startFrom(lastKey)
219
225
  * .limit(5)
220
226
  * .execute();
221
227
  *
222
- * console.log('Additional dinosaurs:', result2.items);
228
+ * const items = await result2.toArray();
229
+ * console.log('Additional dinosaurs:', items);
223
230
  * }
224
231
  * ```
225
232
  *
@@ -257,14 +264,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
257
264
  */
258
265
  abstract clone(): FilterBuilderInterface<T, TConfig>;
259
266
  /**
260
- * Executes the operation against DynamoDB.
267
+ * Executes the operation against DynamoDB and returns a generator that behaves like an array.
261
268
  * This method must be implemented by subclasses to handle
262
269
  * their specific execution logic.
263
270
  */
264
- abstract execute(): Promise<{
265
- items: T[];
266
- lastEvaluatedKey?: DynamoItem;
267
- }>;
271
+ abstract execute(): Promise<ResultIterator<T, TConfig>>;
268
272
  }
269
273
 
270
274
  /**
@@ -428,16 +432,16 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
428
432
  */
429
433
  clone(): QueryBuilder<T, TConfig>;
430
434
  /**
431
- * Executes the query against DynamoDB.
435
+ * Executes the query against DynamoDB and returns a generator that behaves like an array.
432
436
  *
433
- * The method returns both the matched items and, if there are more results,
434
- * a lastEvaluatedKey that can be used with startFrom() to continue the query.
437
+ * The generator automatically handles pagination and provides array-like methods
438
+ * for processing results efficiently without loading everything into memory at once.
435
439
  *
436
440
  * @example
437
441
  * ```typescript
438
442
  * try {
439
- * // Find active carnivores in specific habitat
440
- * const result = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
443
+ * // Find active carnivores with automatic pagination
444
+ * const results = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
441
445
  * .useIndex('species-status-index')
442
446
  * .filter(op =>
443
447
  * op.and([
@@ -447,27 +451,25 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
447
451
  * ])
448
452
  * )
449
453
  * .sortDescending()
450
- * .limit(5)
451
454
  * .execute();
452
455
  *
453
- * console.log(`Found ${result.items.length} dangerous dinosaurs`);
454
- *
455
- * if (result.lastEvaluatedKey) {
456
- * console.log('Additional threats detected');
456
+ * // Use like an array with automatic pagination
457
+ * for await (const dinosaur of results) {
458
+ * console.log(`Processing ${dinosaur.name}`);
457
459
  * }
460
+ *
461
+ * // Or convert to array and use array methods
462
+ * const allItems = await results.toArray();
463
+ * const dangerousOnes = allItems.filter(dino => dino.aggressionLevel > 9);
464
+ * const totalCount = allItems.length;
458
465
  * } catch (error) {
459
466
  * console.error('Security scan failed:', error);
460
467
  * }
461
468
  * ```
462
469
  *
463
- * @returns A promise that resolves to an object containing:
464
- * - items: Array of items matching the query
465
- * - lastEvaluatedKey: Token for continuing the query, if more items exist
470
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
466
471
  */
467
- execute(): Promise<{
468
- items: T[];
469
- lastEvaluatedKey?: Record<string, unknown>;
470
- }>;
472
+ execute(): Promise<ResultIterator<T, TConfig>>;
471
473
  }
472
474
 
473
475
  export { FilterBuilder as F, QueryBuilder as Q, type QueryOptions as a, type FilterOptions as b };
@@ -1,7 +1,7 @@
1
1
  import { C as Condition, q as ConditionOperator } from './conditions-3ae5znV_.cjs';
2
2
  import { Paginator } from './builders/paginator.cjs';
3
3
  import { DynamoItem, TableConfig, GSINames } from './types.cjs';
4
- import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-DlaUSc-b.cjs';
4
+ import { F as FilterBuilderInterface, R as ResultIterator, Q as QueryBuilderInterface } from './builder-types-BTVhQSHI.cjs';
5
5
 
6
6
  /**
7
7
  * Configuration options for DynamoDB filter operations.
@@ -179,11 +179,16 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
179
179
  *
180
180
  * @example
181
181
  * ```typescript
182
- * // Create a paginator for dinosaur records
182
+ * // Create a paginator for dinosaur records with specific page size
183
183
  * const paginator = builder
184
184
  * .filter(op => op.eq('status', 'ACTIVE'))
185
185
  * .paginate(10);
186
186
  *
187
+ * // Create a paginator with automatic DynamoDB paging (no page size limit)
188
+ * const autoPaginator = builder
189
+ * .filter(op => op.eq('status', 'ACTIVE'))
190
+ * .paginate();
191
+ *
187
192
  * // Process pages of dinosaur results
188
193
  * while (paginator.hasNextPage()) {
189
194
  * const page = await paginator.getNextPage();
@@ -192,11 +197,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
192
197
  * }
193
198
  * ```
194
199
  *
195
- * @param pageSize - The number of items to return per page
200
+ * @param pageSize - The number of items to return per page. If not provided, DynamoDB will automatically determine page sizes.
196
201
  * @returns A Paginator instance that manages the pagination state
197
202
  * @see Paginator for more pagination control options
198
203
  */
199
- paginate(pageSize: number): Paginator<T, TConfig>;
204
+ paginate(pageSize?: number): Paginator<T, TConfig>;
200
205
  /**
201
206
  * Sets the starting point using a previous lastEvaluatedKey.
202
207
  *
@@ -211,15 +216,17 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
211
216
  * .limit(5)
212
217
  * .execute();
213
218
  *
214
- * if (result1.lastEvaluatedKey) {
219
+ * const lastKey = result1.getLastEvaluatedKey();
220
+ * if (lastKey) {
215
221
  * // Continue listing dinosaurs
216
222
  * const result2 = await builder
217
223
  * .filter(op => op.eq('status', 'ACTIVE'))
218
- * .startFrom(result1.lastEvaluatedKey)
224
+ * .startFrom(lastKey)
219
225
  * .limit(5)
220
226
  * .execute();
221
227
  *
222
- * console.log('Additional dinosaurs:', result2.items);
228
+ * const items = await result2.toArray();
229
+ * console.log('Additional dinosaurs:', items);
223
230
  * }
224
231
  * ```
225
232
  *
@@ -257,14 +264,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
257
264
  */
258
265
  abstract clone(): FilterBuilderInterface<T, TConfig>;
259
266
  /**
260
- * Executes the operation against DynamoDB.
267
+ * Executes the operation against DynamoDB and returns a generator that behaves like an array.
261
268
  * This method must be implemented by subclasses to handle
262
269
  * their specific execution logic.
263
270
  */
264
- abstract execute(): Promise<{
265
- items: T[];
266
- lastEvaluatedKey?: DynamoItem;
267
- }>;
271
+ abstract execute(): Promise<ResultIterator<T, TConfig>>;
268
272
  }
269
273
 
270
274
  /**
@@ -428,16 +432,16 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
428
432
  */
429
433
  clone(): QueryBuilder<T, TConfig>;
430
434
  /**
431
- * Executes the query against DynamoDB.
435
+ * Executes the query against DynamoDB and returns a generator that behaves like an array.
432
436
  *
433
- * The method returns both the matched items and, if there are more results,
434
- * a lastEvaluatedKey that can be used with startFrom() to continue the query.
437
+ * The generator automatically handles pagination and provides array-like methods
438
+ * for processing results efficiently without loading everything into memory at once.
435
439
  *
436
440
  * @example
437
441
  * ```typescript
438
442
  * try {
439
- * // Find active carnivores in specific habitat
440
- * const result = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
443
+ * // Find active carnivores with automatic pagination
444
+ * const results = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
441
445
  * .useIndex('species-status-index')
442
446
  * .filter(op =>
443
447
  * op.and([
@@ -447,27 +451,25 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
447
451
  * ])
448
452
  * )
449
453
  * .sortDescending()
450
- * .limit(5)
451
454
  * .execute();
452
455
  *
453
- * console.log(`Found ${result.items.length} dangerous dinosaurs`);
454
- *
455
- * if (result.lastEvaluatedKey) {
456
- * console.log('Additional threats detected');
456
+ * // Use like an array with automatic pagination
457
+ * for await (const dinosaur of results) {
458
+ * console.log(`Processing ${dinosaur.name}`);
457
459
  * }
460
+ *
461
+ * // Or convert to array and use array methods
462
+ * const allItems = await results.toArray();
463
+ * const dangerousOnes = allItems.filter(dino => dino.aggressionLevel > 9);
464
+ * const totalCount = allItems.length;
458
465
  * } catch (error) {
459
466
  * console.error('Security scan failed:', error);
460
467
  * }
461
468
  * ```
462
469
  *
463
- * @returns A promise that resolves to an object containing:
464
- * - items: Array of items matching the query
465
- * - lastEvaluatedKey: Token for continuing the query, if more items exist
470
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
466
471
  */
467
- execute(): Promise<{
468
- items: T[];
469
- lastEvaluatedKey?: Record<string, unknown>;
470
- }>;
472
+ execute(): Promise<ResultIterator<T, TConfig>>;
471
473
  }
472
474
 
473
475
  export { FilterBuilder as F, QueryBuilder as Q, type QueryOptions as a, type FilterOptions as b };
@@ -1,13 +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-BDuHHrb-.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-DNsz6zvh.cjs';
8
+ import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-CKYnMRyz.cjs';
9
9
  import { ConditionCheckBuilder } from './builders/condition-check-builder.cjs';
10
- import { S as ScanBuilderInterface } from './builder-types-DlaUSc-b.cjs';
10
+ import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-BTVhQSHI.cjs';
11
11
 
12
12
  /**
13
13
  * Configuration options for DynamoDB scan operations.
@@ -77,43 +77,41 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
77
77
  */
78
78
  clone(): ScanBuilder<T, TConfig>;
79
79
  /**
80
- * Executes the scan against DynamoDB.
80
+ * Executes the scan against DynamoDB and returns a generator that behaves like an array.
81
81
  *
82
- * The method returns both the matched items and, if there are more results,
83
- * 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.
84
84
  *
85
85
  * @example
86
86
  * ```typescript
87
87
  * try {
88
- * // Find all dinosaurs with high aggression levels
89
- * const result = await new ScanBuilder(executor)
88
+ * // Find all dinosaurs with high aggression levels with automatic pagination
89
+ * const results = await new ScanBuilder(executor)
90
90
  * .filter(op =>
91
91
  * op.and([
92
92
  * op.eq('status', 'ACTIVE'),
93
93
  * op.gt('aggressionLevel', 7)
94
94
  * ])
95
95
  * )
96
- * .limit(20)
97
96
  * .execute();
98
97
  *
99
- * console.log(`Found ${result.items.length} potentially dangerous dinosaurs`);
100
- *
101
- * if (result.lastEvaluatedKey) {
102
- * 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}`);
103
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;
104
107
  * } catch (error) {
105
108
  * console.error('Security scan failed:', error);
106
109
  * }
107
110
  * ```
108
111
  *
109
- * @returns A promise that resolves to an object containing:
110
- * - items: Array of items matching the scan criteria
111
- * - lastEvaluatedKey: Token for continuing the scan, if more items exist
112
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
112
113
  */
113
- execute(): Promise<{
114
- items: T[];
115
- lastEvaluatedKey?: Record<string, unknown>;
116
- }>;
114
+ execute(): Promise<ResultIterator<T, TConfig>>;
117
115
  }
118
116
 
119
117
  declare class Table<TConfig extends TableConfig = TableConfig> {
@@ -1,13 +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-C6XjVEFH.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-Dz1yPGrJ.js';
8
+ import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-BOBwOIUE.js';
9
9
  import { ConditionCheckBuilder } from './builders/condition-check-builder.js';
10
- import { S as ScanBuilderInterface } from './builder-types-B_tCpn9F.js';
10
+ import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-CzuLR4Th.js';
11
11
 
12
12
  /**
13
13
  * Configuration options for DynamoDB scan operations.
@@ -77,43 +77,41 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
77
77
  */
78
78
  clone(): ScanBuilder<T, TConfig>;
79
79
  /**
80
- * Executes the scan against DynamoDB.
80
+ * Executes the scan against DynamoDB and returns a generator that behaves like an array.
81
81
  *
82
- * The method returns both the matched items and, if there are more results,
83
- * 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.
84
84
  *
85
85
  * @example
86
86
  * ```typescript
87
87
  * try {
88
- * // Find all dinosaurs with high aggression levels
89
- * const result = await new ScanBuilder(executor)
88
+ * // Find all dinosaurs with high aggression levels with automatic pagination
89
+ * const results = await new ScanBuilder(executor)
90
90
  * .filter(op =>
91
91
  * op.and([
92
92
  * op.eq('status', 'ACTIVE'),
93
93
  * op.gt('aggressionLevel', 7)
94
94
  * ])
95
95
  * )
96
- * .limit(20)
97
96
  * .execute();
98
97
  *
99
- * console.log(`Found ${result.items.length} potentially dangerous dinosaurs`);
100
- *
101
- * if (result.lastEvaluatedKey) {
102
- * 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}`);
103
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;
104
107
  * } catch (error) {
105
108
  * console.error('Security scan failed:', error);
106
109
  * }
107
110
  * ```
108
111
  *
109
- * @returns A promise that resolves to an object containing:
110
- * - items: Array of items matching the scan criteria
111
- * - lastEvaluatedKey: Token for continuing the scan, if more items exist
112
+ * @returns A promise that resolves to a ResultGenerator that behaves like an array
112
113
  */
113
- execute(): Promise<{
114
- items: T[];
115
- lastEvaluatedKey?: Record<string, unknown>;
116
- }>;
114
+ execute(): Promise<ResultIterator<T, TConfig>>;
117
115
  }
118
116
 
119
117
  declare class Table<TConfig extends TableConfig = TableConfig> {