dyno-table 0.1.8 → 1.0.0-alpha.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 (58) hide show
  1. package/README.md +35 -7
  2. package/package.json +13 -3
  3. package/dist/builders/condition-check-builder.cjs +0 -394
  4. package/dist/builders/condition-check-builder.cjs.map +0 -1
  5. package/dist/builders/condition-check-builder.js +0 -392
  6. package/dist/builders/condition-check-builder.js.map +0 -1
  7. package/dist/builders/delete-builder.cjs +0 -422
  8. package/dist/builders/delete-builder.cjs.map +0 -1
  9. package/dist/builders/delete-builder.js +0 -420
  10. package/dist/builders/delete-builder.js.map +0 -1
  11. package/dist/builders/paginator.cjs +0 -199
  12. package/dist/builders/paginator.cjs.map +0 -1
  13. package/dist/builders/paginator.js +0 -197
  14. package/dist/builders/paginator.js.map +0 -1
  15. package/dist/builders/put-builder.cjs +0 -468
  16. package/dist/builders/put-builder.cjs.map +0 -1
  17. package/dist/builders/put-builder.js +0 -466
  18. package/dist/builders/put-builder.js.map +0 -1
  19. package/dist/builders/query-builder.cjs +0 -674
  20. package/dist/builders/query-builder.cjs.map +0 -1
  21. package/dist/builders/query-builder.js +0 -672
  22. package/dist/builders/query-builder.js.map +0 -1
  23. package/dist/builders/transaction-builder.cjs +0 -876
  24. package/dist/builders/transaction-builder.cjs.map +0 -1
  25. package/dist/builders/transaction-builder.js +0 -874
  26. package/dist/builders/transaction-builder.js.map +0 -1
  27. package/dist/builders/update-builder.cjs +0 -662
  28. package/dist/builders/update-builder.cjs.map +0 -1
  29. package/dist/builders/update-builder.js +0 -660
  30. package/dist/builders/update-builder.js.map +0 -1
  31. package/dist/conditions.cjs +0 -59
  32. package/dist/conditions.cjs.map +0 -1
  33. package/dist/conditions.js +0 -43
  34. package/dist/conditions.js.map +0 -1
  35. package/dist/entity.cjs +0 -169
  36. package/dist/entity.cjs.map +0 -1
  37. package/dist/entity.js +0 -165
  38. package/dist/entity.js.map +0 -1
  39. package/dist/standard-schema.cjs +0 -4
  40. package/dist/standard-schema.cjs.map +0 -1
  41. package/dist/standard-schema.js +0 -3
  42. package/dist/standard-schema.js.map +0 -1
  43. package/dist/table.cjs +0 -3265
  44. package/dist/table.cjs.map +0 -1
  45. package/dist/table.js +0 -3263
  46. package/dist/table.js.map +0 -1
  47. package/dist/types.cjs +0 -4
  48. package/dist/types.cjs.map +0 -1
  49. package/dist/types.js +0 -3
  50. package/dist/types.js.map +0 -1
  51. package/dist/utils/key-template.cjs +0 -19
  52. package/dist/utils/key-template.cjs.map +0 -1
  53. package/dist/utils/key-template.js +0 -17
  54. package/dist/utils/key-template.js.map +0 -1
  55. package/dist/utils/sort-key-template.cjs +0 -19
  56. package/dist/utils/sort-key-template.cjs.map +0 -1
  57. package/dist/utils/sort-key-template.js +0 -17
  58. package/dist/utils/sort-key-template.js.map +0 -1
@@ -1,662 +0,0 @@
1
- 'use strict';
2
-
3
- // src/conditions.ts
4
- var createComparisonCondition = (type) => (attr, value) => ({
5
- type,
6
- attr,
7
- value
8
- });
9
- var eq = createComparisonCondition("eq");
10
- var ne = createComparisonCondition("ne");
11
- var lt = createComparisonCondition("lt");
12
- var lte = createComparisonCondition("lte");
13
- var gt = createComparisonCondition("gt");
14
- var gte = createComparisonCondition("gte");
15
- var between = (attr, lower, upper) => ({
16
- type: "between",
17
- attr,
18
- value: [lower, upper]
19
- });
20
- var beginsWith = createComparisonCondition("beginsWith");
21
- var contains = createComparisonCondition("contains");
22
- var attributeExists = (attr) => ({
23
- type: "attributeExists",
24
- attr
25
- });
26
- var attributeNotExists = (attr) => ({
27
- type: "attributeNotExists",
28
- attr
29
- });
30
- var and = (...conditions) => ({
31
- type: "and",
32
- conditions
33
- });
34
- var or = (...conditions) => ({
35
- type: "or",
36
- conditions
37
- });
38
- var not = (condition) => ({
39
- type: "not",
40
- condition
41
- });
42
-
43
- // src/expression.ts
44
- var generateAttributeName = (params, attr) => {
45
- for (const [existingName, existingAttr] of Object.entries(params.expressionAttributeNames)) {
46
- if (existingAttr === attr) {
47
- return existingName;
48
- }
49
- }
50
- const attrName = `#${Object.keys(params.expressionAttributeNames).length}`;
51
- params.expressionAttributeNames[attrName] = attr;
52
- return attrName;
53
- };
54
- var generateValueName = (params, value) => {
55
- const valueName = `:${params.valueCounter.count++}`;
56
- params.expressionAttributeValues[valueName] = value;
57
- return valueName;
58
- };
59
- var validateCondition = (condition, requiresAttr = true, requiresValue = true) => {
60
- if (requiresAttr && !condition.attr) {
61
- throw new Error(`Attribute is required for ${condition.type} condition`);
62
- }
63
- if (requiresValue && condition.value === void 0) {
64
- throw new Error(`Value is required for ${condition.type} condition`);
65
- }
66
- };
67
- var buildComparisonExpression = (condition, operator, params) => {
68
- validateCondition(condition);
69
- if (!condition.attr) {
70
- throw new Error(`Attribute is required for ${condition.type} condition`);
71
- }
72
- const attrName = generateAttributeName(params, condition.attr);
73
- const valueName = generateValueName(params, condition.value);
74
- return `${attrName} ${operator} ${valueName}`;
75
- };
76
- var buildBetweenExpression = (condition, params) => {
77
- validateCondition(condition);
78
- if (!condition.attr) {
79
- throw new Error(`Attribute is required for ${condition.type} condition`);
80
- }
81
- if (!Array.isArray(condition.value) || condition.value.length !== 2) {
82
- throw new Error("Between condition requires an array of two values");
83
- }
84
- const attrName = generateAttributeName(params, condition.attr);
85
- const lowerName = generateValueName(params, condition.value[0]);
86
- const upperName = generateValueName(params, condition.value[1]);
87
- return `${attrName} BETWEEN ${lowerName} AND ${upperName}`;
88
- };
89
- var buildFunctionExpression = (functionName, condition, params) => {
90
- validateCondition(condition);
91
- if (!condition.attr) {
92
- throw new Error(`Attribute is required for ${condition.type} condition`);
93
- }
94
- const attrName = generateAttributeName(params, condition.attr);
95
- const valueName = generateValueName(params, condition.value);
96
- return `${functionName}(${attrName}, ${valueName})`;
97
- };
98
- var buildAttributeFunction = (functionName, condition, params) => {
99
- validateCondition(condition, true, false);
100
- if (!condition.attr) {
101
- throw new Error(`Attribute is required for ${condition.type} condition`);
102
- }
103
- const attrName = generateAttributeName(params, condition.attr);
104
- return `${functionName}(${attrName})`;
105
- };
106
- var buildLogicalExpression = (operator, conditions, params) => {
107
- if (!conditions || conditions.length === 0) {
108
- throw new Error(`At least one condition is required for ${operator} expression`);
109
- }
110
- const expressions = conditions.map((c) => buildExpression(c, params));
111
- return `(${expressions.join(` ${operator} `)})`;
112
- };
113
- var buildExpression = (condition, params) => {
114
- if (!condition) return "";
115
- try {
116
- const expressionBuilders = {
117
- eq: () => buildComparisonExpression(condition, "=", params),
118
- ne: () => buildComparisonExpression(condition, "<>", params),
119
- lt: () => buildComparisonExpression(condition, "<", params),
120
- lte: () => buildComparisonExpression(condition, "<=", params),
121
- gt: () => buildComparisonExpression(condition, ">", params),
122
- gte: () => buildComparisonExpression(condition, ">=", params),
123
- between: () => buildBetweenExpression(condition, params),
124
- beginsWith: () => buildFunctionExpression("begins_with", condition, params),
125
- contains: () => buildFunctionExpression("contains", condition, params),
126
- attributeExists: () => buildAttributeFunction("attribute_exists", condition, params),
127
- attributeNotExists: () => buildAttributeFunction("attribute_not_exists", condition, params),
128
- and: () => {
129
- if (!condition.conditions) {
130
- throw new Error("Conditions array is required for AND operator");
131
- }
132
- return buildLogicalExpression("AND", condition.conditions, params);
133
- },
134
- or: () => {
135
- if (!condition.conditions) {
136
- throw new Error("Conditions array is required for OR operator");
137
- }
138
- return buildLogicalExpression("OR", condition.conditions, params);
139
- },
140
- not: () => {
141
- if (!condition.condition) {
142
- throw new Error("Condition is required for NOT operator");
143
- }
144
- return `NOT (${buildExpression(condition.condition, params)})`;
145
- }
146
- };
147
- const builder = expressionBuilders[condition.type];
148
- if (!builder) {
149
- throw new Error(`Unknown condition type: ${condition.type}`);
150
- }
151
- return builder();
152
- } catch (error) {
153
- if (error instanceof Error) {
154
- console.error(`Error building expression for condition type ${condition.type}:`, error.message);
155
- } else {
156
- console.error(`Error building expression for condition type ${condition.type}:`, error);
157
- }
158
- throw error;
159
- }
160
- };
161
-
162
- // src/utils/debug-expression.ts
163
- function debugCommand(command) {
164
- const result = {};
165
- function replaceAliases(expressionString) {
166
- if (!expressionString) {
167
- return expressionString;
168
- }
169
- let replacedString = expressionString;
170
- for (const alias in command.expressionAttributeNames) {
171
- const attributeName = command.expressionAttributeNames[alias];
172
- const regex = new RegExp(alias, "g");
173
- replacedString = replacedString.replace(regex, attributeName);
174
- }
175
- for (const alias in command.expressionAttributeValues) {
176
- let attributeValue = command.expressionAttributeValues[alias];
177
- if (attributeValue instanceof Set) {
178
- const array = Array.from(attributeValue);
179
- attributeValue = `Set(${array.length}){${array.map((v) => JSON.stringify(v)).join(", ")}}`;
180
- } else {
181
- attributeValue = JSON.stringify(attributeValue);
182
- }
183
- const regex = new RegExp(alias, "g");
184
- replacedString = replacedString.replace(regex, attributeValue);
185
- }
186
- return replacedString;
187
- }
188
- if (command.updateExpression) {
189
- result.updateExpression = replaceAliases(command.updateExpression);
190
- }
191
- if (command.conditionExpression) {
192
- result.conditionExpression = replaceAliases(command.conditionExpression);
193
- }
194
- if (command.filterExpression) {
195
- result.filterExpression = replaceAliases(command.filterExpression);
196
- }
197
- if (command.keyConditionExpression) {
198
- result.keyConditionExpression = replaceAliases(command.keyConditionExpression);
199
- }
200
- if (command.projectionExpression) {
201
- result.projectionExpression = replaceAliases(command.projectionExpression);
202
- }
203
- return {
204
- raw: command,
205
- readable: result
206
- };
207
- }
208
-
209
- // src/builders/update-builder.ts
210
- var UpdateBuilder = class {
211
- updates = [];
212
- options = {
213
- returnValues: "ALL_NEW"
214
- };
215
- executor;
216
- tableName;
217
- key;
218
- constructor(executor, tableName, key) {
219
- this.executor = executor;
220
- this.tableName = tableName;
221
- this.key = key;
222
- }
223
- set(valuesOrPath, value) {
224
- if (typeof valuesOrPath === "object") {
225
- for (const [key, value2] of Object.entries(valuesOrPath)) {
226
- this.updates.push({
227
- type: "SET",
228
- path: key,
229
- value: value2
230
- });
231
- }
232
- } else {
233
- this.updates.push({
234
- type: "SET",
235
- path: valuesOrPath,
236
- value
237
- });
238
- }
239
- return this;
240
- }
241
- /**
242
- * Removes an attribute from the item.
243
- * Use this method when you need to:
244
- * - Delete attributes completely
245
- * - Remove nested attributes
246
- * - Clean up deprecated fields
247
- *
248
- * @example
249
- * ```typescript
250
- * // Remove simple attributes
251
- * builder
252
- * .remove('temporaryTag')
253
- * .remove('previousLocation');
254
- *
255
- * // Remove nested attributes
256
- * builder
257
- * .remove('metadata.testData')
258
- * .remove('stats.experimentalMetrics');
259
- * ```
260
- *
261
- * @param path - The path to the attribute to remove
262
- * @returns The builder instance for method chaining
263
- */
264
- remove(path) {
265
- this.updates.push({
266
- type: "REMOVE",
267
- path
268
- });
269
- return this;
270
- }
271
- /**
272
- * Adds a value to a number attribute or adds elements to a set.
273
- * Use this method when you need to:
274
- * - Increment counters
275
- * - Add elements to a set atomically
276
- * - Update numerical statistics
277
- *
278
- * @example
279
- * ```typescript
280
- * // Increment counters
281
- * builder
282
- * .add('escapeAttempts', 1)
283
- * .add('feedingCount', 1);
284
- *
285
- * // Add to sets
286
- * builder
287
- * .add('knownBehaviors', new Set(['PACK_HUNTING', 'AMBUSH_TACTICS']))
288
- * .add('visitedZones', new Set(['ZONE_A', 'ZONE_B']));
289
- * ```
290
- *
291
- * @param path - The path to the attribute to update
292
- * @param value - The value to add (number or set)
293
- * @returns The builder instance for method chaining
294
- */
295
- add(path, value) {
296
- this.updates.push({
297
- type: "ADD",
298
- path,
299
- value
300
- });
301
- return this;
302
- }
303
- /**
304
- * Removes elements from a set attribute.
305
- * Use this method when you need to:
306
- * - Remove specific elements from a set
307
- * - Update set-based attributes atomically
308
- * - Maintain set membership
309
- *
310
- * @example
311
- * ```typescript
312
- * // Remove from sets using arrays
313
- * builder.deleteElementsFromSet(
314
- * 'allowedHabitats',
315
- * ['JUNGLE', 'COASTAL']
316
- * );
317
- *
318
- * // Remove from sets using Set objects
319
- * builder.deleteElementsFromSet(
320
- * 'knownBehaviors',
321
- * new Set(['NOCTURNAL', 'TERRITORIAL'])
322
- * );
323
- *
324
- * // Remove from nested sets
325
- * builder.deleteElementsFromSet(
326
- * 'stats.compatibleSpecies',
327
- * ['VELOCIRAPTOR', 'DILOPHOSAURUS']
328
- * );
329
- * ```
330
- *
331
- * @param path - The path to the set attribute
332
- * @param value - Elements to remove (array or Set)
333
- * @returns The builder instance for method chaining
334
- */
335
- deleteElementsFromSet(path, value) {
336
- let valuesToDelete;
337
- if (Array.isArray(value)) {
338
- valuesToDelete = new Set(value);
339
- } else {
340
- valuesToDelete = value;
341
- }
342
- this.updates.push({
343
- type: "DELETE",
344
- path,
345
- value: valuesToDelete
346
- });
347
- return this;
348
- }
349
- /**
350
- * Adds a condition that must be satisfied for the update to succeed.
351
- * Use this method when you need to:
352
- * - Implement optimistic locking
353
- * - Ensure item state before update
354
- * - Validate business rules
355
- * - Prevent concurrent modifications
356
- *
357
- * @example
358
- * ```typescript
359
- * // Simple condition
360
- * builder.condition(op =>
361
- * op.eq('status', 'ACTIVE')
362
- * );
363
- *
364
- * // Health check condition
365
- * builder.condition(op =>
366
- * op.and([
367
- * op.gt('health', 50),
368
- * op.eq('status', 'HUNTING')
369
- * ])
370
- * );
371
- *
372
- * // Complex security condition
373
- * builder.condition(op =>
374
- * op.and([
375
- * op.attributeExists('securitySystem'),
376
- * op.eq('containmentStatus', 'SECURE'),
377
- * op.lt('aggressionLevel', 8)
378
- * ])
379
- * );
380
- *
381
- * // Version check (optimistic locking)
382
- * builder.condition(op =>
383
- * op.eq('version', currentVersion)
384
- * );
385
- * ```
386
- *
387
- * @param condition - Either a Condition object or a callback function that builds the condition
388
- * @returns The builder instance for method chaining
389
- */
390
- condition(condition) {
391
- if (typeof condition === "function") {
392
- const conditionOperator = {
393
- eq,
394
- ne,
395
- lt,
396
- lte,
397
- gt,
398
- gte,
399
- between,
400
- beginsWith,
401
- contains,
402
- attributeExists,
403
- attributeNotExists,
404
- and,
405
- or,
406
- not
407
- };
408
- this.options.condition = condition(conditionOperator);
409
- } else {
410
- this.options.condition = condition;
411
- }
412
- return this;
413
- }
414
- /**
415
- * Sets which item attributes to include in the response.
416
- * Use this method when you need to:
417
- * - Get the complete updated item
418
- * - Track changes to specific attributes
419
- * - Compare old and new values
420
- * - Monitor attribute modifications
421
- *
422
- * Available options:
423
- * - ALL_NEW: All attributes after the update
424
- * - UPDATED_NEW: Only updated attributes, new values
425
- * - ALL_OLD: All attributes before the update
426
- * - UPDATED_OLD: Only updated attributes, old values
427
- * - NONE: No attributes returned (default)
428
- *
429
- * @example
430
- * ```typescript
431
- * // Get complete updated dinosaur
432
- * const result = await builder
433
- * .set('status', 'SLEEPING')
434
- * .returnValues('ALL_NEW')
435
- * .execute();
436
- *
437
- * // Track specific attribute changes
438
- * const result = await builder
439
- * .set({
440
- * 'stats.health': 100,
441
- * 'stats.energy': 95
442
- * })
443
- * .returnValues('UPDATED_OLD')
444
- * .execute();
445
- *
446
- * if (result.item) {
447
- * console.log('Previous health:', result.item.stats?.health);
448
- * }
449
- * ```
450
- *
451
- * @param returnValues - Which attributes to return in the response
452
- * @returns The builder instance for method chaining
453
- */
454
- returnValues(returnValues) {
455
- this.options.returnValues = returnValues;
456
- return this;
457
- }
458
- /**
459
- * Generate the DynamoDB command parameters
460
- */
461
- toDynamoCommand() {
462
- if (this.updates.length === 0) {
463
- throw new Error("No update actions specified");
464
- }
465
- const expressionParams = {
466
- expressionAttributeNames: {},
467
- expressionAttributeValues: {},
468
- valueCounter: { count: 0 }
469
- };
470
- let updateExpression = "";
471
- const setUpdates = [];
472
- const removeUpdates = [];
473
- const addUpdates = [];
474
- const deleteUpdates = [];
475
- for (const update of this.updates) {
476
- switch (update.type) {
477
- case "SET":
478
- setUpdates.push(update);
479
- break;
480
- case "REMOVE":
481
- removeUpdates.push(update);
482
- break;
483
- case "ADD":
484
- addUpdates.push(update);
485
- break;
486
- case "DELETE":
487
- deleteUpdates.push(update);
488
- break;
489
- }
490
- }
491
- if (setUpdates.length > 0) {
492
- updateExpression += "SET ";
493
- updateExpression += setUpdates.map((update) => {
494
- const attrName = generateAttributeName(expressionParams, update.path);
495
- const valueName = generateValueName(expressionParams, update.value);
496
- expressionParams.expressionAttributeValues[valueName] = update.value;
497
- return `${attrName} = ${valueName}`;
498
- }).join(", ");
499
- }
500
- if (removeUpdates.length > 0) {
501
- if (updateExpression) {
502
- updateExpression += " ";
503
- }
504
- updateExpression += "REMOVE ";
505
- updateExpression += removeUpdates.map((update) => {
506
- return generateAttributeName(expressionParams, update.path);
507
- }).join(", ");
508
- }
509
- if (addUpdates.length > 0) {
510
- if (updateExpression) {
511
- updateExpression += " ";
512
- }
513
- updateExpression += "ADD ";
514
- updateExpression += addUpdates.map((update) => {
515
- const attrName = generateAttributeName(expressionParams, update.path);
516
- const valueName = generateValueName(expressionParams, update.value);
517
- return `${attrName} ${valueName}`;
518
- }).join(", ");
519
- }
520
- if (deleteUpdates.length > 0) {
521
- if (updateExpression) {
522
- updateExpression += " ";
523
- }
524
- updateExpression += "DELETE ";
525
- updateExpression += deleteUpdates.map((update) => {
526
- const attrName = generateAttributeName(expressionParams, update.path);
527
- const valueName = generateValueName(expressionParams, update.value);
528
- return `${attrName} ${valueName}`;
529
- }).join(", ");
530
- }
531
- let conditionExpression;
532
- if (this.options.condition) {
533
- conditionExpression = buildExpression(this.options.condition, expressionParams);
534
- }
535
- const { expressionAttributeNames, expressionAttributeValues } = expressionParams;
536
- return {
537
- tableName: this.tableName,
538
- key: this.key,
539
- updateExpression,
540
- conditionExpression,
541
- expressionAttributeNames: Object.keys(expressionAttributeNames).length > 0 ? expressionAttributeNames : void 0,
542
- expressionAttributeValues: Object.keys(expressionAttributeValues).length > 0 ? expressionAttributeValues : void 0,
543
- returnValues: this.options.returnValues
544
- };
545
- }
546
- /**
547
- * Adds this update operation to a transaction.
548
- * Use this method when you need to:
549
- * - Update items as part of a larger transaction
550
- * - Ensure multiple updates are atomic
551
- * - Coordinate updates across multiple items
552
- *
553
- * @example
554
- * ```typescript
555
- * const transaction = new TransactionBuilder(executor);
556
- *
557
- * // Update dinosaur status and habitat occupancy atomically
558
- * new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
559
- * .set('location', 'PADDOCK_A')
560
- * .set('status', 'CONTAINED')
561
- * .withTransaction(transaction);
562
- *
563
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
564
- * .add('occupants', 1)
565
- * .set('lastOccupied', new Date().toISOString())
566
- * .withTransaction(transaction);
567
- *
568
- * // Execute all operations atomically
569
- * await transaction.execute();
570
- * ```
571
- *
572
- * @param transaction - The transaction builder to add this operation to
573
- * @returns The builder instance for method chaining
574
- */
575
- withTransaction(transaction) {
576
- const command = this.toDynamoCommand();
577
- transaction.updateWithCommand(command);
578
- }
579
- /**
580
- * Gets a human-readable representation of the update command.
581
- * Use this method when you need to:
582
- * - Debug complex update expressions
583
- * - Verify attribute names and values
584
- * - Log update operations
585
- * - Troubleshoot condition expressions
586
- *
587
- * @example
588
- * ```typescript
589
- * // Create complex update
590
- * const builder = new UpdateBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
591
- * .set({
592
- * status: 'HUNTING',
593
- * 'stats.health': 95,
594
- * 'behavior.lastObserved': new Date().toISOString()
595
- * })
596
- * .add('huntingSuccesses', 1)
597
- * .condition(op => op.gt('health', 50));
598
- *
599
- * // Debug the update
600
- * const debugInfo = builder.debug();
601
- * console.log('Update operation:', debugInfo);
602
- * ```
603
- *
604
- * @returns A readable representation of the update command with resolved expressions
605
- */
606
- debug() {
607
- const command = this.toDynamoCommand();
608
- return debugCommand(command);
609
- }
610
- /**
611
- * Executes the update operation against DynamoDB.
612
- * Use this method when you need to:
613
- * - Apply updates immediately
614
- * - Get the updated item values
615
- * - Handle conditional update failures
616
- *
617
- * @example
618
- * ```typescript
619
- * try {
620
- * // Update dinosaur status with conditions
621
- * const result = await new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
622
- * .set({
623
- * status: 'FEEDING',
624
- * lastMeal: new Date().toISOString(),
625
- * 'stats.hunger': 0
626
- * })
627
- * .add('feedingCount', 1)
628
- * .condition(op =>
629
- * op.and([
630
- * op.gt('stats.hunger', 80),
631
- * op.eq('status', 'HUNTING')
632
- * ])
633
- * )
634
- * .returnValues('ALL_NEW')
635
- * .execute();
636
- *
637
- * if (result.item) {
638
- * console.log('Updated dinosaur:', result.item);
639
- * }
640
- * } catch (error) {
641
- * // Handle condition check failure
642
- * console.error('Failed to update dinosaur:', error);
643
- * // Check if dinosaur wasn't hungry enough
644
- * if (error.name === 'ConditionalCheckFailedException') {
645
- * console.log('Dinosaur not ready for feeding');
646
- * }
647
- * }
648
- * ```
649
- *
650
- * @returns A promise that resolves to an object containing the updated item (if returnValues is set)
651
- * @throws {ConditionalCheckFailedException} If the condition check fails
652
- * @throws {Error} If the update operation fails for other reasons
653
- */
654
- async execute() {
655
- const params = this.toDynamoCommand();
656
- return this.executor(params);
657
- }
658
- };
659
-
660
- exports.UpdateBuilder = UpdateBuilder;
661
- //# sourceMappingURL=update-builder.cjs.map
662
- //# sourceMappingURL=update-builder.cjs.map