dyno-table 2.2.0 → 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 (106) 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-CC3NDfUU.d.cts → conditions-CcZL0sR2.d.cts} +1 -1
  17. package/dist/{conditions-DD0bvyHm.d.ts → conditions-D_w7vVYG.d.ts} +1 -1
  18. package/dist/conditions.cjs +67 -62
  19. package/dist/conditions.d.cts +1 -1
  20. package/dist/conditions.d.ts +1 -1
  21. package/dist/conditions.js +1 -48
  22. package/dist/entity.cjs +14 -625
  23. package/dist/entity.d.cts +5 -13
  24. package/dist/entity.d.ts +5 -13
  25. package/dist/entity.js +2 -626
  26. package/dist/index-2cbm07Bi.d.ts +2797 -0
  27. package/dist/index-DlN8G9hd.d.cts +2797 -0
  28. package/dist/index.cjs +111 -4446
  29. package/dist/index.d.cts +3 -11
  30. package/dist/index.d.ts +3 -11
  31. package/dist/index.js +5 -4428
  32. package/dist/standard-schema.cjs +0 -2
  33. package/dist/standard-schema.js +0 -2
  34. package/dist/table.cjs +7 -3782
  35. package/dist/table.d.cts +163 -12
  36. package/dist/table.d.ts +163 -12
  37. package/dist/table.js +3 -3785
  38. package/dist/types.cjs +0 -2
  39. package/dist/types.js +0 -2
  40. package/dist/utils.cjs +10 -30
  41. package/dist/utils.js +1 -31
  42. package/package.json +12 -67
  43. package/dist/batch-builder-BPoHyN_Q.d.cts +0 -398
  44. package/dist/batch-builder-Cdo49C2r.d.ts +0 -398
  45. package/dist/builder-types-BTVhQSHI.d.cts +0 -169
  46. package/dist/builder-types-CzuLR4Th.d.ts +0 -169
  47. package/dist/builders/condition-check-builder.cjs +0 -422
  48. package/dist/builders/condition-check-builder.cjs.map +0 -1
  49. package/dist/builders/condition-check-builder.d.cts +0 -153
  50. package/dist/builders/condition-check-builder.d.ts +0 -153
  51. package/dist/builders/condition-check-builder.js +0 -420
  52. package/dist/builders/condition-check-builder.js.map +0 -1
  53. package/dist/builders/delete-builder.cjs +0 -484
  54. package/dist/builders/delete-builder.cjs.map +0 -1
  55. package/dist/builders/delete-builder.d.cts +0 -211
  56. package/dist/builders/delete-builder.d.ts +0 -211
  57. package/dist/builders/delete-builder.js +0 -482
  58. package/dist/builders/delete-builder.js.map +0 -1
  59. package/dist/builders/paginator.cjs +0 -193
  60. package/dist/builders/paginator.cjs.map +0 -1
  61. package/dist/builders/paginator.d.cts +0 -155
  62. package/dist/builders/paginator.d.ts +0 -155
  63. package/dist/builders/paginator.js +0 -191
  64. package/dist/builders/paginator.js.map +0 -1
  65. package/dist/builders/put-builder.cjs +0 -554
  66. package/dist/builders/put-builder.cjs.map +0 -1
  67. package/dist/builders/put-builder.d.cts +0 -319
  68. package/dist/builders/put-builder.d.ts +0 -319
  69. package/dist/builders/put-builder.js +0 -552
  70. package/dist/builders/put-builder.js.map +0 -1
  71. package/dist/builders/query-builder.cjs +0 -743
  72. package/dist/builders/query-builder.cjs.map +0 -1
  73. package/dist/builders/query-builder.d.cts +0 -6
  74. package/dist/builders/query-builder.d.ts +0 -6
  75. package/dist/builders/query-builder.js +0 -741
  76. package/dist/builders/query-builder.js.map +0 -1
  77. package/dist/builders/transaction-builder.cjs +0 -906
  78. package/dist/builders/transaction-builder.cjs.map +0 -1
  79. package/dist/builders/transaction-builder.d.cts +0 -464
  80. package/dist/builders/transaction-builder.d.ts +0 -464
  81. package/dist/builders/transaction-builder.js +0 -904
  82. package/dist/builders/transaction-builder.js.map +0 -1
  83. package/dist/builders/update-builder.cjs +0 -668
  84. package/dist/builders/update-builder.cjs.map +0 -1
  85. package/dist/builders/update-builder.d.cts +0 -374
  86. package/dist/builders/update-builder.d.ts +0 -374
  87. package/dist/builders/update-builder.js +0 -666
  88. package/dist/builders/update-builder.js.map +0 -1
  89. package/dist/conditions.cjs.map +0 -1
  90. package/dist/conditions.js.map +0 -1
  91. package/dist/entity.cjs.map +0 -1
  92. package/dist/entity.js.map +0 -1
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist/query-builder-CUWdavZw.d.ts +0 -477
  96. package/dist/query-builder-DoZzZz_c.d.cts +0 -477
  97. package/dist/standard-schema.cjs.map +0 -1
  98. package/dist/standard-schema.js.map +0 -1
  99. package/dist/table-CZBMkW2Z.d.ts +0 -276
  100. package/dist/table-f-3wsT7K.d.cts +0 -276
  101. package/dist/table.cjs.map +0 -1
  102. package/dist/table.js.map +0 -1
  103. package/dist/types.cjs.map +0 -1
  104. package/dist/types.js.map +0 -1
  105. package/dist/utils.cjs.map +0 -1
  106. package/dist/utils.js.map +0 -1
@@ -1,319 +0,0 @@
1
- import { s as Path, t as PathType, C as Condition, q as ConditionOperator } from '../conditions-DD0bvyHm.js';
2
- import { TransactionBuilder } from './transaction-builder.js';
3
- import { B as BatchBuilder } from '../batch-builder-Cdo49C2r.js';
4
- import { a as PutCommandParams } from '../builder-types-CzuLR4Th.js';
5
- import { DynamoItem } from '../types.js';
6
- import '@aws-sdk/lib-dynamodb';
7
-
8
- /**
9
- * Configuration options for DynamoDB put operations.
10
- */
11
- interface PutOptions {
12
- /** Optional condition that must be satisfied for the put operation to succeed */
13
- condition?: Condition;
14
- /** Determines how to handle the return value of the put operation
15
- * @options
16
- * - NONE: No return value
17
- * - ALL_OLD: Returns the item's previous state if it existed
18
- * - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
19
- * - INPUT: Returns the input values that were passed to the operation
20
- */
21
- returnValues?: "ALL_OLD" | "NONE" | "CONSISTENT" | "INPUT";
22
- }
23
- type PutExecutor<T extends DynamoItem> = (params: PutCommandParams) => Promise<T>;
24
- /**
25
- * Builder for creating DynamoDB put operations.
26
- *
27
- * @example
28
- * ```typescript
29
- * // Add new dinosaur
30
- * const result = await new PutBuilder(executor, {
31
- * id: 'RAPTOR-001',
32
- * species: 'Velociraptor',
33
- * status: 'ACTIVE',
34
- * stats: {
35
- * health: 100,
36
- * age: 5,
37
- * threatLevel: 8
38
- * }
39
- * }, 'dinosaurs').execute();
40
- *
41
- * // Create new habitat with conditions
42
- * const result = await new PutBuilder(executor, {
43
- * id: 'PADDOCK-C',
44
- * type: 'CARNIVORE',
45
- * securityLevel: 'MAXIMUM',
46
- * capacity: 3,
47
- * environmentType: 'TROPICAL'
48
- * }, 'habitats')
49
- * .condition(op => op.attributeNotExists('id'))
50
- * .execute();
51
- * ```
52
- *
53
- * @typeParam T - The type of item being put into the table
54
- */
55
- declare class PutBuilder<T extends DynamoItem> {
56
- private readonly item;
57
- private options;
58
- private readonly executor;
59
- private readonly tableName;
60
- constructor(executor: PutExecutor<T>, item: T, tableName: string);
61
- /**
62
- * Sets multiple attributes of an item using an DynamoItem.
63
- *
64
- * @example
65
- * ```typescript
66
- * // Update multiple attributes
67
- * builder.set({
68
- * species: 'Tyrannosaurus Rex',
69
- * height: 20,
70
- * diet: 'CARNIVORE',
71
- * 'stats.threatLevel': 10
72
- * });
73
- * ```
74
- */
75
- set(values: Partial<T>): this;
76
- /**
77
- * Sets a single attribute to a specific value.
78
- *
79
- * @example
80
- * ```typescript
81
- * // Set simple attributes
82
- * builder
83
- * .set('status', 'SLEEPING')
84
- * .set('lastFeeding', new Date().toISOString());
85
- *
86
- * // Set nested attributes
87
- * builder
88
- * .set('location.zone', 'RESTRICTED')
89
- * .set('stats.health', 100);
90
- * ```
91
- */
92
- set<K extends Path<T>>(path: K, value: PathType<T, K>): this;
93
- /**
94
- * Adds a condition that must be satisfied for the put operation to succeed.
95
- *
96
- * @example
97
- * ```ts
98
- * // Ensure item doesn't exist (insert only)
99
- * builder.condition(op => op.attributeNotExists('id'))
100
- *
101
- * // Complex condition with version check
102
- * builder.condition(op =>
103
- * op.and([
104
- * op.attributeExists('id'),
105
- * op.eq('version', currentVersion),
106
- * op.eq('status', 'ACTIVE')
107
- * ])
108
- * )
109
- * ```
110
- *
111
- * @param condition - Either a Condition object or a callback function that builds the condition
112
- * @returns The builder instance for method chaining
113
- */
114
- /**
115
- * Adds a condition that must be satisfied for the put operation to succeed.
116
- *
117
- * @example
118
- * ```typescript
119
- * // Ensure unique dinosaur ID
120
- * builder.condition(op =>
121
- * op.attributeNotExists('id')
122
- * );
123
- *
124
- * // Verify habitat requirements
125
- * builder.condition(op =>
126
- * op.and([
127
- * op.eq('securityStatus', 'READY'),
128
- * op.attributeExists('lastInspection'),
129
- * op.gt('securityLevel', 5)
130
- * ])
131
- * );
132
- *
133
- * // Check breeding facility conditions
134
- * builder.condition(op =>
135
- * op.and([
136
- * op.between('temperature', 25, 30),
137
- * op.between('humidity', 60, 80),
138
- * op.eq('quarantineStatus', 'CLEAR')
139
- * ])
140
- * );
141
- * ```
142
- *
143
- * @param condition - Either a Condition object or a callback function that builds the condition
144
- * @returns The builder instance for method chaining
145
- */
146
- condition(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
147
- /**
148
- * Sets whether to return the item's previous values (if it existed).
149
- *
150
- * @options
151
- * - NONE: No return value
152
- * - ALL_OLD: Returns the item's previous state if it existed, no read capacity units are consumed
153
- * - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
154
- * - INPUT: Returns the input values that were passed to the operation
155
- *
156
- * @example
157
- * ```ts
158
- * // Get previous dinosaur state
159
- * const result = await builder
160
- * .returnValues('ALL_OLD')
161
- * .execute();
162
- *
163
- * if (result) {
164
- * console.log('Previous profile:', {
165
- * species: result.species,
166
- * status: result.status,
167
- * stats: {
168
- * health: result.stats.health,
169
- * threatLevel: result.stats.threatLevel
170
- * }
171
- * });
172
- * }
173
- *
174
- * // Return input values for create operations
175
- * const createResult = await builder
176
- * .returnValues('INPUT')
177
- * .execute();
178
- * ```
179
- *
180
- * @param returnValues - Use 'ALL_OLD' to return previous values, 'INPUT' to return input values, 'CONSISTENT' for fresh data, or 'NONE' (default).
181
- * @returns The builder instance for method chaining
182
- */
183
- returnValues(returnValues: "ALL_OLD" | "NONE" | "CONSISTENT" | "INPUT"): this;
184
- /**
185
- * Generate the DynamoDB command parameters
186
- */
187
- private toDynamoCommand;
188
- /**
189
- * Adds this put operation to a transaction.
190
- *
191
- * @example
192
- * ```ts
193
- * const transaction = new TransactionBuilder();
194
- *
195
- * // Add dinosaur to new habitat
196
- * new PutBuilder(executor, {
197
- * id: 'TREX-002',
198
- * location: 'PADDOCK-B',
199
- * status: 'ACTIVE',
200
- * transferDate: new Date().toISOString()
201
- * }, 'dinosaurs')
202
- * .withTransaction(transaction);
203
- *
204
- * // Update habitat records
205
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-B' })
206
- * .add('occupants', 1)
207
- * .set('lastTransfer', new Date().toISOString())
208
- * .withTransaction(transaction);
209
- *
210
- * // Execute transfer atomically
211
- * await transaction.execute();
212
- * ```
213
- *
214
- * @param transaction - The transaction builder to add this operation to
215
- * @returns The builder instance for method chaining
216
- */
217
- withTransaction(transaction: TransactionBuilder): this;
218
- /**
219
- * Adds this put operation to a batch with optional entity type information.
220
- *
221
- * @example Basic Usage
222
- * ```ts
223
- * const batch = table.batchBuilder();
224
- *
225
- * // Add multiple dinosaurs to batch
226
- * dinosaurRepo.create(newDino1).withBatch(batch);
227
- * dinosaurRepo.create(newDino2).withBatch(batch);
228
- * dinosaurRepo.create(newDino3).withBatch(batch);
229
- *
230
- * // Execute all operations efficiently
231
- * await batch.execute();
232
- * ```
233
- *
234
- * @example Typed Usage
235
- * ```ts
236
- * const batch = table.batchBuilder<{
237
- * User: UserEntity;
238
- * Order: OrderEntity;
239
- * }>();
240
- *
241
- * // Add operations with type information
242
- * userRepo.create(newUser).withBatch(batch, 'User');
243
- * orderRepo.create(newOrder).withBatch(batch, 'Order');
244
- *
245
- * // Execute and get typed results
246
- * const result = await batch.execute();
247
- * const users: UserEntity[] = result.reads.itemsByType.User;
248
- * ```
249
- *
250
- * @param batch - The batch builder to add this operation to
251
- * @param entityType - Optional entity type key for type tracking
252
- */
253
- withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
254
- /**
255
- * Executes the put operation against DynamoDB.
256
- *
257
- * @example
258
- * ```ts
259
- * try {
260
- * // Put with condition and return old values
261
- * const result = await new PutBuilder(executor, newItem, 'myTable')
262
- * .condition(op => op.eq('version', 1))
263
- * .returnValues('ALL_OLD')
264
- * .execute();
265
- *
266
- * console.log('Put successful, old item:', result);
267
- * } catch (error) {
268
- * // Handle condition check failure or other errors
269
- * console.error('Put failed:', error);
270
- * }
271
- * ```
272
- *
273
- * @returns A promise that resolves to the operation result (type depends on returnValues setting)
274
- * @throws Will throw an error if the condition check fails or other DynamoDB errors occur
275
- */
276
- execute(): Promise<T | undefined>;
277
- /**
278
- * Gets a human-readable representation of the put command
279
- * with all expression placeholders replaced by their actual values.
280
- *
281
- * @example
282
- * ```ts
283
- * const debugInfo = new PutBuilder(executor, {
284
- * id: 'RAPTOR-003',
285
- * species: 'Velociraptor',
286
- * status: 'QUARANTINE',
287
- * stats: {
288
- * health: 100,
289
- * aggressionLevel: 7,
290
- * age: 2
291
- * }
292
- * }, 'dinosaurs')
293
- * .condition(op =>
294
- * op.and([
295
- * op.attributeNotExists('id'),
296
- * op.eq('quarantineStatus', 'READY'),
297
- * op.gt('securityLevel', 8)
298
- * ])
299
- * )
300
- * .debug();
301
- *
302
- * console.log('Dinosaur transfer command:', debugInfo);
303
- * ```
304
- *
305
- * @returns A readable representation of the put command with resolved expressions
306
- */
307
- debug(): {
308
- raw: PutCommandParams;
309
- readable: {
310
- conditionExpression?: string;
311
- updateExpression?: string;
312
- filterExpression?: string;
313
- keyConditionExpression?: string;
314
- projectionExpression?: string;
315
- };
316
- };
317
- }
318
-
319
- export { PutBuilder, type PutOptions };