dyno-table 2.2.1 → 2.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.
Files changed (102) hide show
  1. package/README.md +200 -1860
  2. package/dist/builders.cjs +55 -0
  3. package/dist/builders.d.cts +4 -0
  4. package/dist/builders.d.ts +4 -0
  5. package/dist/builders.js +2 -0
  6. package/dist/chunk-2EWNZOUK.js +618 -0
  7. package/dist/chunk-2WIBY7PZ.js +46 -0
  8. package/dist/chunk-7UJJ7JXM.cjs +63 -0
  9. package/dist/chunk-DTFJJASK.js +3200 -0
  10. package/dist/chunk-EODPMYPE.js +558 -0
  11. package/dist/chunk-KA3VPIPS.cjs +560 -0
  12. package/dist/chunk-NTA6GDPP.cjs +622 -0
  13. package/dist/chunk-PB7BBCZO.cjs +32 -0
  14. package/dist/chunk-QVRMYGC4.js +29 -0
  15. package/dist/chunk-XYL43FDX.cjs +3217 -0
  16. package/dist/conditions.cjs +67 -62
  17. package/dist/conditions.js +1 -48
  18. package/dist/entity.cjs +14 -625
  19. package/dist/entity.d.cts +2 -10
  20. package/dist/entity.d.ts +2 -10
  21. package/dist/entity.js +2 -626
  22. package/dist/index-2cbm07Bi.d.ts +2797 -0
  23. package/dist/index-DlN8G9hd.d.cts +2797 -0
  24. package/dist/index.cjs +111 -4460
  25. package/dist/index.d.cts +2 -10
  26. package/dist/index.d.ts +2 -10
  27. package/dist/index.js +5 -4442
  28. package/dist/standard-schema.cjs +0 -2
  29. package/dist/standard-schema.js +0 -2
  30. package/dist/table.cjs +7 -3796
  31. package/dist/table.d.cts +163 -12
  32. package/dist/table.d.ts +163 -12
  33. package/dist/table.js +3 -3799
  34. package/dist/types.cjs +0 -2
  35. package/dist/types.js +0 -2
  36. package/dist/utils.cjs +10 -30
  37. package/dist/utils.js +1 -31
  38. package/package.json +6 -66
  39. package/dist/batch-builder-BiQDIZ7p.d.cts +0 -398
  40. package/dist/batch-builder-CNsLS6sR.d.ts +0 -398
  41. package/dist/builder-types-BTVhQSHI.d.cts +0 -169
  42. package/dist/builder-types-CzuLR4Th.d.ts +0 -169
  43. package/dist/builders/condition-check-builder.cjs +0 -422
  44. package/dist/builders/condition-check-builder.cjs.map +0 -1
  45. package/dist/builders/condition-check-builder.d.cts +0 -153
  46. package/dist/builders/condition-check-builder.d.ts +0 -153
  47. package/dist/builders/condition-check-builder.js +0 -420
  48. package/dist/builders/condition-check-builder.js.map +0 -1
  49. package/dist/builders/delete-builder.cjs +0 -484
  50. package/dist/builders/delete-builder.cjs.map +0 -1
  51. package/dist/builders/delete-builder.d.cts +0 -211
  52. package/dist/builders/delete-builder.d.ts +0 -211
  53. package/dist/builders/delete-builder.js +0 -482
  54. package/dist/builders/delete-builder.js.map +0 -1
  55. package/dist/builders/paginator.cjs +0 -193
  56. package/dist/builders/paginator.cjs.map +0 -1
  57. package/dist/builders/paginator.d.cts +0 -155
  58. package/dist/builders/paginator.d.ts +0 -155
  59. package/dist/builders/paginator.js +0 -191
  60. package/dist/builders/paginator.js.map +0 -1
  61. package/dist/builders/put-builder.cjs +0 -554
  62. package/dist/builders/put-builder.cjs.map +0 -1
  63. package/dist/builders/put-builder.d.cts +0 -319
  64. package/dist/builders/put-builder.d.ts +0 -319
  65. package/dist/builders/put-builder.js +0 -552
  66. package/dist/builders/put-builder.js.map +0 -1
  67. package/dist/builders/query-builder.cjs +0 -757
  68. package/dist/builders/query-builder.cjs.map +0 -1
  69. package/dist/builders/query-builder.d.cts +0 -6
  70. package/dist/builders/query-builder.d.ts +0 -6
  71. package/dist/builders/query-builder.js +0 -755
  72. package/dist/builders/query-builder.js.map +0 -1
  73. package/dist/builders/transaction-builder.cjs +0 -906
  74. package/dist/builders/transaction-builder.cjs.map +0 -1
  75. package/dist/builders/transaction-builder.d.cts +0 -464
  76. package/dist/builders/transaction-builder.d.ts +0 -464
  77. package/dist/builders/transaction-builder.js +0 -904
  78. package/dist/builders/transaction-builder.js.map +0 -1
  79. package/dist/builders/update-builder.cjs +0 -668
  80. package/dist/builders/update-builder.cjs.map +0 -1
  81. package/dist/builders/update-builder.d.cts +0 -374
  82. package/dist/builders/update-builder.d.ts +0 -374
  83. package/dist/builders/update-builder.js +0 -666
  84. package/dist/builders/update-builder.js.map +0 -1
  85. package/dist/conditions.cjs.map +0 -1
  86. package/dist/conditions.js.map +0 -1
  87. package/dist/entity.cjs.map +0 -1
  88. package/dist/entity.js.map +0 -1
  89. package/dist/index.cjs.map +0 -1
  90. package/dist/index.js.map +0 -1
  91. package/dist/query-builder-D3URwK9k.d.cts +0 -477
  92. package/dist/query-builder-cfEkU0_w.d.ts +0 -477
  93. package/dist/standard-schema.cjs.map +0 -1
  94. package/dist/standard-schema.js.map +0 -1
  95. package/dist/table-ClST8nkR.d.cts +0 -276
  96. package/dist/table-vE3cGoDy.d.ts +0 -276
  97. package/dist/table.cjs.map +0 -1
  98. package/dist/table.js.map +0 -1
  99. package/dist/types.cjs.map +0 -1
  100. package/dist/types.js.map +0 -1
  101. package/dist/utils.cjs.map +0 -1
  102. package/dist/utils.js.map +0 -1
@@ -1,276 +0,0 @@
1
- import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-BiQDIZ7p.cjs';
2
- import { ConditionCheckBuilder } from './builders/condition-check-builder.cjs';
3
- import { DeleteBuilder } from './builders/delete-builder.cjs';
4
- import { PutBuilder } from './builders/put-builder.cjs';
5
- import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-D3URwK9k.cjs';
6
- import { DynamoItem, TableConfig, Index } from './types.cjs';
7
- import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-BTVhQSHI.cjs';
8
- import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.cjs';
9
- import { UpdateBuilder } from './builders/update-builder.cjs';
10
- import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-CcZL0sR2.cjs';
11
-
12
- /**
13
- * Configuration options for DynamoDB scan operations.
14
- * Extends the base FilterOptions.
15
- */
16
- type ScanOptions = FilterOptions;
17
- /**
18
- * Function type for executing DynamoDB filter operations.
19
- * @typeParam T - The type of items being filtered
20
- */
21
- type ScanExecutor<T extends DynamoItem> = (options: ScanOptions) => Promise<{
22
- items: T[];
23
- lastEvaluatedKey?: DynamoItem;
24
- }>;
25
- /**
26
- * Builder for creating DynamoDB scan operations.
27
- * Use this builder when you need to:
28
- * - Scan all items in a table
29
- * - Filter results based on non-key attributes
30
- * - Scan items on a Secondary Index (GSI)
31
- * - Implement pagination
32
- * - Project specific attributes
33
- *
34
- * The builder supports:
35
- * - Type-safe GSI selection
36
- * - Complex filter conditions
37
- * - Automatic pagination handling
38
- * - Consistent reads
39
- * - Attribute projection
40
- *
41
- * @example
42
- * ```typescript
43
- * // Simple scan with filtering
44
- * const result = await new ScanBuilder(executor)
45
- * .filter(op => op.eq('status', 'ACTIVE'))
46
- * .execute();
47
- *
48
- * // Scan with GSI and filtering
49
- * const result = await new ScanBuilder(executor)
50
- * .useIndex('status-index')
51
- * .filter(op => op.gt('securityLevel', 8))
52
- * .select(['id', 'capacity', 'currentOccupants'])
53
- * .limit(10)
54
- * .execute();
55
- *
56
- * // Scan with pagination
57
- * const paginator = new ScanBuilder(executor)
58
- * .filter(op => op.eq('type', 'INCIDENT'))
59
- * .paginate(25);
60
- *
61
- * while (paginator.hasNextPage()) {
62
- * const page = await paginator.getNextPage();
63
- * // Process page.items
64
- * }
65
- * ```
66
- *
67
- * @typeParam T - The type of items being scanned
68
- * @typeParam TConfig - The table configuration type for type-safe GSI selection
69
- */
70
- declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends FilterBuilder<T, TConfig> implements ScanBuilderInterface<T, TConfig> {
71
- protected readonly executor: ScanExecutor<T>;
72
- constructor(executor: ScanExecutor<T>);
73
- /**
74
- * Creates a deep clone of this ScanBuilder instance.
75
- *
76
- * @returns A new ScanBuilder instance with the same configuration
77
- */
78
- clone(): ScanBuilder<T, TConfig>;
79
- private deepCloneFilter;
80
- /**
81
- * Executes the scan against DynamoDB and returns a generator that behaves like an array.
82
- *
83
- * The generator automatically handles pagination and provides array-like methods
84
- * for processing results efficiently without loading everything into memory at once.
85
- *
86
- * @example
87
- * ```typescript
88
- * try {
89
- * // Find all dinosaurs with high aggression levels with automatic pagination
90
- * const results = await new ScanBuilder(executor)
91
- * .filter(op =>
92
- * op.and([
93
- * op.eq('status', 'ACTIVE'),
94
- * op.gt('aggressionLevel', 7)
95
- * ])
96
- * )
97
- * .execute();
98
- *
99
- * // Use like an array with automatic pagination
100
- * for await (const dinosaur of results) {
101
- * console.log(`Processing dangerous dinosaur: ${dinosaur.name}`);
102
- * }
103
- *
104
- * // Or convert to array and use array methods
105
- * const allItems = await results.toArray();
106
- * const criticalThreats = allItems.filter(dino => dino.aggressionLevel > 9);
107
- * const totalCount = allItems.length;
108
- * } catch (error) {
109
- * console.error('Security scan failed:', error);
110
- * }
111
- * ```
112
- *
113
- * @returns A promise that resolves to a ResultGenerator that behaves like an array
114
- */
115
- execute(): Promise<ResultIterator<T, TConfig>>;
116
- }
117
-
118
- declare class Table<TConfig extends TableConfig = TableConfig> {
119
- private readonly dynamoClient;
120
- readonly tableName: string;
121
- /**
122
- * The column name of the partitionKey for the Table
123
- */
124
- readonly partitionKey: string;
125
- /**
126
- * The column name of the sortKey for the Table
127
- */
128
- readonly sortKey?: string;
129
- /**
130
- * The Global Secondary Indexes that are configured on this table
131
- */
132
- readonly gsis: Record<string, Index>;
133
- constructor(config: TConfig);
134
- protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
135
- /**
136
- * Creates a new item in the table, it will fail if the item already exists.
137
- *
138
- * By default, this method returns the input values passed to the create operation
139
- * upon successful creation.
140
- *
141
- * You can customise the return behaviour by chaining the `.returnValues()` method:
142
- *
143
- * @param item The item to create
144
- * @returns A PutBuilder instance for chaining additional conditions and executing the create operation
145
- *
146
- * @example
147
- * ```ts
148
- * // Create with default behavior (returns input values)
149
- * const result = await table.create({
150
- * id: 'user-123',
151
- * name: 'John Doe',
152
- * email: 'john@example.com'
153
- * }).execute();
154
- * console.log(result); // Returns the input object
155
- *
156
- * // Create with no return value for better performance
157
- * await table.create(userData).returnValues('NONE').execute();
158
- *
159
- * // Create and get fresh data from dynamodb using a strongly consistent read
160
- * const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
161
- *
162
- * // Create and get previous values (if the item was overwritten)
163
- * const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
164
- * ```
165
- */
166
- create<T extends DynamoItem>(item: T): PutBuilder<T>;
167
- get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
168
- /**
169
- * Updates an item in the table
170
- *
171
- * @param item The item to update
172
- * @returns A PutBuilder instance for chaining conditions and executing the put operation
173
- */
174
- put<T extends DynamoItem>(item: T): PutBuilder<T>;
175
- /**
176
- * Creates a query builder for complex queries
177
- * If useIndex is called on the returned QueryBuilder, it will use the GSI configuration
178
- */
179
- query<T extends DynamoItem>(keyCondition: PrimaryKey): QueryBuilder<T, TConfig>;
180
- /**
181
- * Creates a scan builder for scanning the entire table
182
- * Use this when you need to:
183
- * - Process all items in a table
184
- * - Apply filters to a large dataset
185
- * - Use a GSI for scanning
186
- *
187
- * @returns A ScanBuilder instance for chaining operations
188
- */
189
- scan<T extends DynamoItem>(): ScanBuilder<T, TConfig>;
190
- delete(keyCondition: PrimaryKeyWithoutExpression): DeleteBuilder;
191
- /**
192
- * Updates an item in the table
193
- *
194
- * @param keyCondition The primary key of the item to update
195
- * @returns An UpdateBuilder instance for chaining update operations and conditions
196
- */
197
- update<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): UpdateBuilder<T>;
198
- /**
199
- * Creates a transaction builder for performing multiple operations atomically
200
- */
201
- transactionBuilder(): TransactionBuilder;
202
- /**
203
- * Creates a batch builder for performing multiple operations efficiently with optional type inference
204
- *
205
- * @example Basic Usage
206
- * ```typescript
207
- * const batch = table.batchBuilder();
208
- *
209
- * // Add operations
210
- * userRepo.create(newUser).withBatch(batch);
211
- * orderRepo.get({ id: 'order-1' }).withBatch(batch);
212
- *
213
- * // Execute operations
214
- * const result = await batch.execute();
215
- * ```
216
- *
217
- * @example Typed Usage
218
- * ```typescript
219
- * // Define entity types for the batch
220
- * const batch = table.batchBuilder<{
221
- * User: UserEntity;
222
- * Order: OrderEntity;
223
- * Product: ProductEntity;
224
- * }>();
225
- *
226
- * // Add operations with type information
227
- * userRepo.create(newUser).withBatch(batch, 'User');
228
- * orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
229
- * productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
230
- *
231
- * // Execute and get typed results
232
- * const result = await batch.execute();
233
- * const users: UserEntity[] = result.reads.itemsByType.User;
234
- * const orders: OrderEntity[] = result.reads.itemsByType.Order;
235
- * ```
236
- */
237
- batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
238
- /**
239
- * Executes a transaction using a callback function
240
- *
241
- * @param callback A function that receives a transaction context and performs operations on it
242
- * @param options Optional transaction options
243
- * @returns A promise that resolves when the transaction is complete
244
- */
245
- transaction(callback: (tx: TransactionBuilder) => Promise<void> | void, options?: TransactionOptions): Promise<void>;
246
- /**
247
- * Creates a condition check operation for use in transactions
248
- *
249
- * This is useful for when you require a transaction to succeed only when a specific condition is met on a
250
- * a record within the database that you are not directly updating.
251
- *
252
- * For example, you are updating a record and you want to ensure that another record exists and/or has a specific value before proceeding.
253
- */
254
- conditionCheck(keyCondition: PrimaryKeyWithoutExpression): ConditionCheckBuilder;
255
- /**
256
- * Performs a batch get operation to retrieve multiple items at once
257
- *
258
- * @param keys Array of primary keys to retrieve
259
- * @returns A promise that resolves to the retrieved items
260
- */
261
- batchGet<T extends DynamoItem>(keys: Array<PrimaryKeyWithoutExpression>): Promise<{
262
- items: T[];
263
- unprocessedKeys: PrimaryKeyWithoutExpression[];
264
- }>;
265
- /**
266
- * Performs a batch write operation to put or delete multiple items at once
267
- *
268
- * @param operations Array of put or delete operations
269
- * @returns A promise that resolves to any unprocessed operations
270
- */
271
- batchWrite<T extends DynamoItem>(operations: Array<BatchWriteOperation<T>>): Promise<{
272
- unprocessedItems: Array<BatchWriteOperation<T>>;
273
- }>;
274
- }
275
-
276
- export { ScanBuilder as S, Table as T };
@@ -1,276 +0,0 @@
1
- import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-CNsLS6sR.js';
2
- import { ConditionCheckBuilder } from './builders/condition-check-builder.js';
3
- import { DeleteBuilder } from './builders/delete-builder.js';
4
- import { PutBuilder } from './builders/put-builder.js';
5
- import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-cfEkU0_w.js';
6
- import { DynamoItem, TableConfig, Index } from './types.js';
7
- import { S as ScanBuilderInterface, R as ResultIterator } from './builder-types-CzuLR4Th.js';
8
- import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.js';
9
- import { UpdateBuilder } from './builders/update-builder.js';
10
- import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-D_w7vVYG.js';
11
-
12
- /**
13
- * Configuration options for DynamoDB scan operations.
14
- * Extends the base FilterOptions.
15
- */
16
- type ScanOptions = FilterOptions;
17
- /**
18
- * Function type for executing DynamoDB filter operations.
19
- * @typeParam T - The type of items being filtered
20
- */
21
- type ScanExecutor<T extends DynamoItem> = (options: ScanOptions) => Promise<{
22
- items: T[];
23
- lastEvaluatedKey?: DynamoItem;
24
- }>;
25
- /**
26
- * Builder for creating DynamoDB scan operations.
27
- * Use this builder when you need to:
28
- * - Scan all items in a table
29
- * - Filter results based on non-key attributes
30
- * - Scan items on a Secondary Index (GSI)
31
- * - Implement pagination
32
- * - Project specific attributes
33
- *
34
- * The builder supports:
35
- * - Type-safe GSI selection
36
- * - Complex filter conditions
37
- * - Automatic pagination handling
38
- * - Consistent reads
39
- * - Attribute projection
40
- *
41
- * @example
42
- * ```typescript
43
- * // Simple scan with filtering
44
- * const result = await new ScanBuilder(executor)
45
- * .filter(op => op.eq('status', 'ACTIVE'))
46
- * .execute();
47
- *
48
- * // Scan with GSI and filtering
49
- * const result = await new ScanBuilder(executor)
50
- * .useIndex('status-index')
51
- * .filter(op => op.gt('securityLevel', 8))
52
- * .select(['id', 'capacity', 'currentOccupants'])
53
- * .limit(10)
54
- * .execute();
55
- *
56
- * // Scan with pagination
57
- * const paginator = new ScanBuilder(executor)
58
- * .filter(op => op.eq('type', 'INCIDENT'))
59
- * .paginate(25);
60
- *
61
- * while (paginator.hasNextPage()) {
62
- * const page = await paginator.getNextPage();
63
- * // Process page.items
64
- * }
65
- * ```
66
- *
67
- * @typeParam T - The type of items being scanned
68
- * @typeParam TConfig - The table configuration type for type-safe GSI selection
69
- */
70
- declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends FilterBuilder<T, TConfig> implements ScanBuilderInterface<T, TConfig> {
71
- protected readonly executor: ScanExecutor<T>;
72
- constructor(executor: ScanExecutor<T>);
73
- /**
74
- * Creates a deep clone of this ScanBuilder instance.
75
- *
76
- * @returns A new ScanBuilder instance with the same configuration
77
- */
78
- clone(): ScanBuilder<T, TConfig>;
79
- private deepCloneFilter;
80
- /**
81
- * Executes the scan against DynamoDB and returns a generator that behaves like an array.
82
- *
83
- * The generator automatically handles pagination and provides array-like methods
84
- * for processing results efficiently without loading everything into memory at once.
85
- *
86
- * @example
87
- * ```typescript
88
- * try {
89
- * // Find all dinosaurs with high aggression levels with automatic pagination
90
- * const results = await new ScanBuilder(executor)
91
- * .filter(op =>
92
- * op.and([
93
- * op.eq('status', 'ACTIVE'),
94
- * op.gt('aggressionLevel', 7)
95
- * ])
96
- * )
97
- * .execute();
98
- *
99
- * // Use like an array with automatic pagination
100
- * for await (const dinosaur of results) {
101
- * console.log(`Processing dangerous dinosaur: ${dinosaur.name}`);
102
- * }
103
- *
104
- * // Or convert to array and use array methods
105
- * const allItems = await results.toArray();
106
- * const criticalThreats = allItems.filter(dino => dino.aggressionLevel > 9);
107
- * const totalCount = allItems.length;
108
- * } catch (error) {
109
- * console.error('Security scan failed:', error);
110
- * }
111
- * ```
112
- *
113
- * @returns A promise that resolves to a ResultGenerator that behaves like an array
114
- */
115
- execute(): Promise<ResultIterator<T, TConfig>>;
116
- }
117
-
118
- declare class Table<TConfig extends TableConfig = TableConfig> {
119
- private readonly dynamoClient;
120
- readonly tableName: string;
121
- /**
122
- * The column name of the partitionKey for the Table
123
- */
124
- readonly partitionKey: string;
125
- /**
126
- * The column name of the sortKey for the Table
127
- */
128
- readonly sortKey?: string;
129
- /**
130
- * The Global Secondary Indexes that are configured on this table
131
- */
132
- readonly gsis: Record<string, Index>;
133
- constructor(config: TConfig);
134
- protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
135
- /**
136
- * Creates a new item in the table, it will fail if the item already exists.
137
- *
138
- * By default, this method returns the input values passed to the create operation
139
- * upon successful creation.
140
- *
141
- * You can customise the return behaviour by chaining the `.returnValues()` method:
142
- *
143
- * @param item The item to create
144
- * @returns A PutBuilder instance for chaining additional conditions and executing the create operation
145
- *
146
- * @example
147
- * ```ts
148
- * // Create with default behavior (returns input values)
149
- * const result = await table.create({
150
- * id: 'user-123',
151
- * name: 'John Doe',
152
- * email: 'john@example.com'
153
- * }).execute();
154
- * console.log(result); // Returns the input object
155
- *
156
- * // Create with no return value for better performance
157
- * await table.create(userData).returnValues('NONE').execute();
158
- *
159
- * // Create and get fresh data from dynamodb using a strongly consistent read
160
- * const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
161
- *
162
- * // Create and get previous values (if the item was overwritten)
163
- * const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
164
- * ```
165
- */
166
- create<T extends DynamoItem>(item: T): PutBuilder<T>;
167
- get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
168
- /**
169
- * Updates an item in the table
170
- *
171
- * @param item The item to update
172
- * @returns A PutBuilder instance for chaining conditions and executing the put operation
173
- */
174
- put<T extends DynamoItem>(item: T): PutBuilder<T>;
175
- /**
176
- * Creates a query builder for complex queries
177
- * If useIndex is called on the returned QueryBuilder, it will use the GSI configuration
178
- */
179
- query<T extends DynamoItem>(keyCondition: PrimaryKey): QueryBuilder<T, TConfig>;
180
- /**
181
- * Creates a scan builder for scanning the entire table
182
- * Use this when you need to:
183
- * - Process all items in a table
184
- * - Apply filters to a large dataset
185
- * - Use a GSI for scanning
186
- *
187
- * @returns A ScanBuilder instance for chaining operations
188
- */
189
- scan<T extends DynamoItem>(): ScanBuilder<T, TConfig>;
190
- delete(keyCondition: PrimaryKeyWithoutExpression): DeleteBuilder;
191
- /**
192
- * Updates an item in the table
193
- *
194
- * @param keyCondition The primary key of the item to update
195
- * @returns An UpdateBuilder instance for chaining update operations and conditions
196
- */
197
- update<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): UpdateBuilder<T>;
198
- /**
199
- * Creates a transaction builder for performing multiple operations atomically
200
- */
201
- transactionBuilder(): TransactionBuilder;
202
- /**
203
- * Creates a batch builder for performing multiple operations efficiently with optional type inference
204
- *
205
- * @example Basic Usage
206
- * ```typescript
207
- * const batch = table.batchBuilder();
208
- *
209
- * // Add operations
210
- * userRepo.create(newUser).withBatch(batch);
211
- * orderRepo.get({ id: 'order-1' }).withBatch(batch);
212
- *
213
- * // Execute operations
214
- * const result = await batch.execute();
215
- * ```
216
- *
217
- * @example Typed Usage
218
- * ```typescript
219
- * // Define entity types for the batch
220
- * const batch = table.batchBuilder<{
221
- * User: UserEntity;
222
- * Order: OrderEntity;
223
- * Product: ProductEntity;
224
- * }>();
225
- *
226
- * // Add operations with type information
227
- * userRepo.create(newUser).withBatch(batch, 'User');
228
- * orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
229
- * productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
230
- *
231
- * // Execute and get typed results
232
- * const result = await batch.execute();
233
- * const users: UserEntity[] = result.reads.itemsByType.User;
234
- * const orders: OrderEntity[] = result.reads.itemsByType.Order;
235
- * ```
236
- */
237
- batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
238
- /**
239
- * Executes a transaction using a callback function
240
- *
241
- * @param callback A function that receives a transaction context and performs operations on it
242
- * @param options Optional transaction options
243
- * @returns A promise that resolves when the transaction is complete
244
- */
245
- transaction(callback: (tx: TransactionBuilder) => Promise<void> | void, options?: TransactionOptions): Promise<void>;
246
- /**
247
- * Creates a condition check operation for use in transactions
248
- *
249
- * This is useful for when you require a transaction to succeed only when a specific condition is met on a
250
- * a record within the database that you are not directly updating.
251
- *
252
- * For example, you are updating a record and you want to ensure that another record exists and/or has a specific value before proceeding.
253
- */
254
- conditionCheck(keyCondition: PrimaryKeyWithoutExpression): ConditionCheckBuilder;
255
- /**
256
- * Performs a batch get operation to retrieve multiple items at once
257
- *
258
- * @param keys Array of primary keys to retrieve
259
- * @returns A promise that resolves to the retrieved items
260
- */
261
- batchGet<T extends DynamoItem>(keys: Array<PrimaryKeyWithoutExpression>): Promise<{
262
- items: T[];
263
- unprocessedKeys: PrimaryKeyWithoutExpression[];
264
- }>;
265
- /**
266
- * Performs a batch write operation to put or delete multiple items at once
267
- *
268
- * @param operations Array of put or delete operations
269
- * @returns A promise that resolves to any unprocessed operations
270
- */
271
- batchWrite<T extends DynamoItem>(operations: Array<BatchWriteOperation<T>>): Promise<{
272
- unprocessedItems: Array<BatchWriteOperation<T>>;
273
- }>;
274
- }
275
-
276
- export { ScanBuilder as S, Table as T };