dyno-table 0.1.6 → 0.1.7
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.
- package/dist/index.d.ts +1129 -1056
- package/dist/index.js +154 -153
- package/package.json +22 -15
package/dist/index.js
CHANGED
|
@@ -191,16 +191,16 @@ var Paginator = class {
|
|
|
191
191
|
* - Track progress through dinosaur lists
|
|
192
192
|
* - Display habitat inspection status
|
|
193
193
|
* - Monitor security sweep progress
|
|
194
|
-
*
|
|
194
|
+
*
|
|
195
195
|
* @example
|
|
196
196
|
* ```ts
|
|
197
197
|
* const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))
|
|
198
198
|
* .paginate(5);
|
|
199
|
-
*
|
|
199
|
+
*
|
|
200
200
|
* await paginator.getNextPage();
|
|
201
201
|
* console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);
|
|
202
202
|
* ```
|
|
203
|
-
*
|
|
203
|
+
*
|
|
204
204
|
* @returns The current page number, starting from 1
|
|
205
205
|
*/
|
|
206
206
|
getCurrentPage() {
|
|
@@ -213,18 +213,18 @@ var Paginator = class {
|
|
|
213
213
|
* - Continue habitat inspections
|
|
214
214
|
* - Process security incidents
|
|
215
215
|
* - Complete feeding schedules
|
|
216
|
-
*
|
|
216
|
+
*
|
|
217
217
|
* This method takes into account both:
|
|
218
218
|
* - DynamoDB's lastEvaluatedKey mechanism
|
|
219
219
|
* - Any overall limit set on the query
|
|
220
|
-
*
|
|
220
|
+
*
|
|
221
221
|
* @example
|
|
222
222
|
* ```ts
|
|
223
223
|
* // Process all security incidents
|
|
224
224
|
* const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
|
|
225
225
|
* .sortDescending()
|
|
226
226
|
* .paginate(10);
|
|
227
|
-
*
|
|
227
|
+
*
|
|
228
228
|
* while (paginator.hasNextPage()) {
|
|
229
229
|
* const page = await paginator.getNextPage();
|
|
230
230
|
* for (const incident of page.items) {
|
|
@@ -233,7 +233,7 @@ var Paginator = class {
|
|
|
233
233
|
* console.log(`Processed incidents page ${page.page}`);
|
|
234
234
|
* }
|
|
235
235
|
* ```
|
|
236
|
-
*
|
|
236
|
+
*
|
|
237
237
|
* @returns true if there are more pages available, false otherwise
|
|
238
238
|
*/
|
|
239
239
|
hasNextPage() {
|
|
@@ -249,33 +249,33 @@ var Paginator = class {
|
|
|
249
249
|
* - Review habitat inspections in batches
|
|
250
250
|
* - Monitor security incidents in sequence
|
|
251
251
|
* - Schedule feeding rotations
|
|
252
|
-
*
|
|
252
|
+
*
|
|
253
253
|
* This method handles:
|
|
254
254
|
* - Automatic continuation between groups
|
|
255
255
|
* - Respect for park capacity limits
|
|
256
256
|
* - Group size adjustments for safety
|
|
257
|
-
*
|
|
257
|
+
*
|
|
258
258
|
* @example
|
|
259
259
|
* ```ts
|
|
260
260
|
* const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
261
261
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
262
262
|
* .paginate(5);
|
|
263
|
-
*
|
|
263
|
+
*
|
|
264
264
|
* // Check first raptor group
|
|
265
265
|
* const page1 = await paginator.getNextPage();
|
|
266
266
|
* console.log(`Found ${page1.items.length} active raptors`);
|
|
267
|
-
*
|
|
267
|
+
*
|
|
268
268
|
* // Continue inspection if more groups exist
|
|
269
269
|
* if (page1.hasNextPage) {
|
|
270
270
|
* const page2 = await paginator.getNextPage();
|
|
271
271
|
* console.log(`Inspecting raptor group ${page2.page}`);
|
|
272
|
-
*
|
|
272
|
+
*
|
|
273
273
|
* for (const raptor of page2.items) {
|
|
274
274
|
* await performHealthCheck(raptor);
|
|
275
275
|
* }
|
|
276
276
|
* }
|
|
277
277
|
* ```
|
|
278
|
-
*
|
|
278
|
+
*
|
|
279
279
|
* @returns A promise that resolves to a PaginationResult containing:
|
|
280
280
|
* - items: The dinosaurs/habitats for this page
|
|
281
281
|
* - hasNextPage: Whether more groups exist
|
|
@@ -325,23 +325,23 @@ var Paginator = class {
|
|
|
325
325
|
* - Perform full security audit
|
|
326
326
|
* - Create comprehensive feeding schedule
|
|
327
327
|
* - Run park-wide health checks
|
|
328
|
-
*
|
|
328
|
+
*
|
|
329
329
|
* Note: Use with caution! This method:
|
|
330
330
|
* - Could overwhelm systems with large dinosaur populations
|
|
331
331
|
* - Makes multiple database requests
|
|
332
332
|
* - May cause system strain during peak hours
|
|
333
|
-
*
|
|
333
|
+
*
|
|
334
334
|
* @example
|
|
335
335
|
* ```ts
|
|
336
336
|
* // Get complete carnivore inventory
|
|
337
337
|
* const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))
|
|
338
338
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
339
339
|
* .paginate(10);
|
|
340
|
-
*
|
|
340
|
+
*
|
|
341
341
|
* try {
|
|
342
342
|
* const allCarnivores = await paginator.getAllPages();
|
|
343
343
|
* console.log(`Park contains ${allCarnivores.length} active carnivores`);
|
|
344
|
-
*
|
|
344
|
+
*
|
|
345
345
|
* // Calculate total threat level
|
|
346
346
|
* const totalThreat = allCarnivores.reduce(
|
|
347
347
|
* (sum, dino) => sum + dino.stats.threatLevel,
|
|
@@ -352,7 +352,7 @@ var Paginator = class {
|
|
|
352
352
|
* console.error('Failed to complete carnivore census:', error);
|
|
353
353
|
* }
|
|
354
354
|
* ```
|
|
355
|
-
*
|
|
355
|
+
*
|
|
356
356
|
* @returns A promise that resolves to an array containing all remaining items
|
|
357
357
|
*/
|
|
358
358
|
async getAllPages() {
|
|
@@ -448,25 +448,25 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
448
448
|
* - Search habitats by security level
|
|
449
449
|
* - Find incidents by date
|
|
450
450
|
* - List feeding schedules by time
|
|
451
|
-
*
|
|
451
|
+
*
|
|
452
452
|
* @example
|
|
453
453
|
* ```typescript
|
|
454
454
|
* // Find all dinosaurs of a specific species
|
|
455
455
|
* builder
|
|
456
456
|
* .useIndex('species-status-index')
|
|
457
457
|
* .filter(op => op.eq('status', 'ACTIVE'));
|
|
458
|
-
*
|
|
458
|
+
*
|
|
459
459
|
* // Search high-security habitats
|
|
460
460
|
* builder
|
|
461
461
|
* .useIndex('security-level-index')
|
|
462
|
-
* .filter(op =>
|
|
462
|
+
* .filter(op =>
|
|
463
463
|
* op.and([
|
|
464
464
|
* op.gt('securityLevel', 8),
|
|
465
465
|
* op.eq('status', 'OPERATIONAL')
|
|
466
466
|
* ])
|
|
467
467
|
* );
|
|
468
468
|
* ```
|
|
469
|
-
*
|
|
469
|
+
*
|
|
470
470
|
* @param indexName - The name of the GSI to use (type-safe based on table configuration)
|
|
471
471
|
* @returns The builder instance for method chaining
|
|
472
472
|
*/
|
|
@@ -481,12 +481,12 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
481
481
|
* - Monitor critical security systems
|
|
482
482
|
* - Track immediate habitat changes
|
|
483
483
|
* - Verify containment protocols
|
|
484
|
-
*
|
|
484
|
+
*
|
|
485
485
|
* Note:
|
|
486
486
|
* - Consistent reads are not available on GSIs
|
|
487
487
|
* - Consistent reads consume twice the throughput
|
|
488
488
|
* - Default is eventually consistent reads
|
|
489
|
-
*
|
|
489
|
+
*
|
|
490
490
|
* @example
|
|
491
491
|
* ```ts
|
|
492
492
|
* // Check immediate dinosaur status
|
|
@@ -494,14 +494,14 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
494
494
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
495
495
|
* .consistentRead()
|
|
496
496
|
* .execute();
|
|
497
|
-
*
|
|
497
|
+
*
|
|
498
498
|
* // Monitor security breaches
|
|
499
499
|
* const result = await new QueryBuilder(executor, eq('type', 'SECURITY_ALERT'))
|
|
500
500
|
* .useIndex('primary-index')
|
|
501
501
|
* .consistentRead(isEmergencyMode)
|
|
502
502
|
* .execute();
|
|
503
503
|
* ```
|
|
504
|
-
*
|
|
504
|
+
*
|
|
505
505
|
* @param consistentRead - Whether to use consistent reads (defaults to true)
|
|
506
506
|
* @returns The builder instance for method chaining
|
|
507
507
|
*/
|
|
@@ -544,20 +544,20 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
544
544
|
* - Find habitats with specific conditions
|
|
545
545
|
* - Search for security incidents
|
|
546
546
|
* - Monitor feeding patterns
|
|
547
|
-
*
|
|
547
|
+
*
|
|
548
548
|
* @example
|
|
549
549
|
* ```typescript
|
|
550
550
|
* // Find aggressive carnivores
|
|
551
|
-
* builder.filter(op =>
|
|
551
|
+
* builder.filter(op =>
|
|
552
552
|
* op.and([
|
|
553
553
|
* op.eq('diet', 'CARNIVORE'),
|
|
554
554
|
* op.gt('aggressionLevel', 7),
|
|
555
555
|
* op.eq('status', 'ACTIVE')
|
|
556
556
|
* ])
|
|
557
557
|
* );
|
|
558
|
-
*
|
|
558
|
+
*
|
|
559
559
|
* // Search suitable breeding habitats
|
|
560
|
-
* builder.filter(op =>
|
|
560
|
+
* builder.filter(op =>
|
|
561
561
|
* op.and([
|
|
562
562
|
* op.between('temperature', 25, 30),
|
|
563
563
|
* op.lt('currentOccupants', 3),
|
|
@@ -565,7 +565,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
565
565
|
* ])
|
|
566
566
|
* );
|
|
567
567
|
* ```
|
|
568
|
-
*
|
|
568
|
+
*
|
|
569
569
|
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
570
570
|
* @returns The builder instance for method chaining
|
|
571
571
|
*/
|
|
@@ -627,7 +627,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
627
627
|
* - Retrieve habitat statistics
|
|
628
628
|
* - Monitor security metrics
|
|
629
629
|
* - Optimize response size
|
|
630
|
-
*
|
|
630
|
+
*
|
|
631
631
|
* @example
|
|
632
632
|
* ```typescript
|
|
633
633
|
* // Get basic dinosaur info
|
|
@@ -637,7 +637,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
637
637
|
* 'stats.health',
|
|
638
638
|
* 'stats.aggressionLevel'
|
|
639
639
|
* ]);
|
|
640
|
-
*
|
|
640
|
+
*
|
|
641
641
|
* // Monitor habitat conditions
|
|
642
642
|
* builder
|
|
643
643
|
* .select('securityStatus')
|
|
@@ -647,7 +647,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
647
647
|
* 'lastInspectionDate'
|
|
648
648
|
* ]);
|
|
649
649
|
* ```
|
|
650
|
-
*
|
|
650
|
+
*
|
|
651
651
|
* @param fields - A single field name or an array of field names to return
|
|
652
652
|
* @returns The builder instance for method chaining
|
|
653
653
|
*/
|
|
@@ -694,7 +694,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
694
694
|
* - View incidents chronologically
|
|
695
695
|
* - Track feeding schedule progression
|
|
696
696
|
* - Monitor habitat inspections
|
|
697
|
-
*
|
|
697
|
+
*
|
|
698
698
|
* @example
|
|
699
699
|
* ```typescript
|
|
700
700
|
* // List dinosaurs by age
|
|
@@ -702,14 +702,14 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
702
702
|
* .useIndex('age-index')
|
|
703
703
|
* .sortAscending()
|
|
704
704
|
* .execute();
|
|
705
|
-
*
|
|
705
|
+
*
|
|
706
706
|
* // View incidents chronologically
|
|
707
707
|
* const result = await new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
|
|
708
708
|
* .useIndex('date-index')
|
|
709
709
|
* .sortAscending()
|
|
710
710
|
* .execute();
|
|
711
711
|
* ```
|
|
712
|
-
*
|
|
712
|
+
*
|
|
713
713
|
* @returns The builder instance for method chaining
|
|
714
714
|
*/
|
|
715
715
|
sortAscending() {
|
|
@@ -732,7 +732,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
732
732
|
* .sortDescending()
|
|
733
733
|
* .limit(10)
|
|
734
734
|
* .execute();
|
|
735
|
-
*
|
|
735
|
+
*
|
|
736
736
|
* // Check latest dinosaur activities
|
|
737
737
|
* const result = await new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
738
738
|
* .useIndex('activity-time-index')
|
|
@@ -754,12 +754,12 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
754
754
|
* - View habitat inspection history
|
|
755
755
|
* - Monitor security incidents
|
|
756
756
|
* - Track feeding patterns
|
|
757
|
-
*
|
|
757
|
+
*
|
|
758
758
|
* The paginator handles:
|
|
759
759
|
* - Tracking the last evaluated key
|
|
760
760
|
* - Managing page boundaries
|
|
761
761
|
* - Respecting overall query limits
|
|
762
|
-
*
|
|
762
|
+
*
|
|
763
763
|
* @example
|
|
764
764
|
* ```typescript
|
|
765
765
|
* // List dinosaurs by species
|
|
@@ -767,20 +767,20 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
767
767
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
768
768
|
* .useIndex('species-index')
|
|
769
769
|
* .paginate(10);
|
|
770
|
-
*
|
|
770
|
+
*
|
|
771
771
|
* // Process pages of security incidents
|
|
772
772
|
* const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
|
|
773
773
|
* .filter(op => op.gt('severityLevel', 7))
|
|
774
774
|
* .sortDescending()
|
|
775
775
|
* .paginate(25);
|
|
776
|
-
*
|
|
776
|
+
*
|
|
777
777
|
* while (paginator.hasNextPage()) {
|
|
778
778
|
* const page = await paginator.getNextPage();
|
|
779
779
|
* console.log(`Processing incidents page ${page.page}, count: ${page.items.length}`);
|
|
780
780
|
* // Handle security incidents
|
|
781
781
|
* }
|
|
782
782
|
* ```
|
|
783
|
-
*
|
|
783
|
+
*
|
|
784
784
|
* @param pageSize - The number of items to return per page
|
|
785
785
|
* @returns A Paginator instance that manages the pagination state
|
|
786
786
|
* @see Paginator for more pagination control options
|
|
@@ -795,10 +795,10 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
795
795
|
* - Resume habitat inspection reviews
|
|
796
796
|
* - Continue security incident analysis
|
|
797
797
|
* - Store query position between sessions
|
|
798
|
-
*
|
|
798
|
+
*
|
|
799
799
|
* Note: This method is typically used for manual pagination.
|
|
800
800
|
* For automatic pagination, use the paginate() method instead.
|
|
801
|
-
*
|
|
801
|
+
*
|
|
802
802
|
* @example
|
|
803
803
|
* ```typescript
|
|
804
804
|
* // First batch of dinosaurs
|
|
@@ -806,7 +806,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
806
806
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
807
807
|
* .limit(5)
|
|
808
808
|
* .execute();
|
|
809
|
-
*
|
|
809
|
+
*
|
|
810
810
|
* if (result1.lastEvaluatedKey) {
|
|
811
811
|
* // Continue listing dinosaurs
|
|
812
812
|
* const result2 = await new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
@@ -814,11 +814,11 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
814
814
|
* .startFrom(result1.lastEvaluatedKey)
|
|
815
815
|
* .limit(5)
|
|
816
816
|
* .execute();
|
|
817
|
-
*
|
|
817
|
+
*
|
|
818
818
|
* console.log('Additional dinosaurs:', result2.items);
|
|
819
819
|
* }
|
|
820
820
|
* ```
|
|
821
|
-
*
|
|
821
|
+
*
|
|
822
822
|
* @param lastEvaluatedKey - The exclusive start key from a previous query result
|
|
823
823
|
* @returns The builder instance for method chaining
|
|
824
824
|
*/
|
|
@@ -833,35 +833,35 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
833
833
|
* - Check multiple habitat conditions
|
|
834
834
|
* - Monitor various security levels
|
|
835
835
|
* - Create report templates
|
|
836
|
-
*
|
|
836
|
+
*
|
|
837
837
|
* This is particularly useful when:
|
|
838
838
|
* - Implementing pagination (used internally by paginate())
|
|
839
839
|
* - Creating query templates
|
|
840
840
|
* - Running multiple variations of a query
|
|
841
|
-
*
|
|
841
|
+
*
|
|
842
842
|
* @example
|
|
843
843
|
* ```typescript
|
|
844
844
|
* // Create base dinosaur query
|
|
845
845
|
* const baseQuery = new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
846
846
|
* .useIndex('status-index')
|
|
847
847
|
* .select(['id', 'status', 'location']);
|
|
848
|
-
*
|
|
848
|
+
*
|
|
849
849
|
* // Check active dinosaurs
|
|
850
850
|
* const activeRaptors = baseQuery.clone()
|
|
851
851
|
* .filter(op => op.eq('status', 'HUNTING'))
|
|
852
852
|
* .execute();
|
|
853
|
-
*
|
|
853
|
+
*
|
|
854
854
|
* // Check contained dinosaurs
|
|
855
855
|
* const containedRaptors = baseQuery.clone()
|
|
856
856
|
* .filter(op => op.eq('status', 'CONTAINED'))
|
|
857
857
|
* .execute();
|
|
858
|
-
*
|
|
858
|
+
*
|
|
859
859
|
* // Check sedated dinosaurs
|
|
860
860
|
* const sedatedRaptors = baseQuery.clone()
|
|
861
861
|
* .filter(op => op.eq('status', 'SEDATED'))
|
|
862
862
|
* .execute();
|
|
863
863
|
* ```
|
|
864
|
-
*
|
|
864
|
+
*
|
|
865
865
|
* @returns A new QueryBuilder instance with the same configuration
|
|
866
866
|
*/
|
|
867
867
|
clone() {
|
|
@@ -877,17 +877,17 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
877
877
|
* - Check habitat conditions
|
|
878
878
|
* - Monitor security incidents
|
|
879
879
|
* - Track feeding patterns
|
|
880
|
-
*
|
|
880
|
+
*
|
|
881
881
|
* The method returns both the matched items and, if there are more results,
|
|
882
882
|
* a lastEvaluatedKey that can be used with startFrom() to continue the query.
|
|
883
|
-
*
|
|
883
|
+
*
|
|
884
884
|
* @example
|
|
885
885
|
* ```typescript
|
|
886
886
|
* try {
|
|
887
887
|
* // Find active carnivores in specific habitat
|
|
888
888
|
* const result = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
|
|
889
889
|
* .useIndex('species-status-index')
|
|
890
|
-
* .filter(op =>
|
|
890
|
+
* .filter(op =>
|
|
891
891
|
* op.and([
|
|
892
892
|
* op.eq('diet', 'CARNIVORE'),
|
|
893
893
|
* op.eq('status', 'ACTIVE'),
|
|
@@ -897,9 +897,9 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
897
897
|
* .sortDescending()
|
|
898
898
|
* .limit(5)
|
|
899
899
|
* .execute();
|
|
900
|
-
*
|
|
900
|
+
*
|
|
901
901
|
* console.log(`Found ${result.items.length} dangerous dinosaurs`);
|
|
902
|
-
*
|
|
902
|
+
*
|
|
903
903
|
* if (result.lastEvaluatedKey) {
|
|
904
904
|
* console.log('Additional threats detected');
|
|
905
905
|
* }
|
|
@@ -907,7 +907,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
907
907
|
* console.error('Security scan failed:', error);
|
|
908
908
|
* }
|
|
909
909
|
* ```
|
|
910
|
-
*
|
|
910
|
+
*
|
|
911
911
|
* @returns A promise that resolves to an object containing:
|
|
912
912
|
* - items: Array of items matching the query
|
|
913
913
|
* - lastEvaluatedKey: Token for continuing the query, if more items exist
|
|
@@ -1447,20 +1447,20 @@ var UpdateBuilder = class {
|
|
|
1447
1447
|
* - Delete attributes completely
|
|
1448
1448
|
* - Remove nested attributes
|
|
1449
1449
|
* - Clean up deprecated fields
|
|
1450
|
-
*
|
|
1450
|
+
*
|
|
1451
1451
|
* @example
|
|
1452
1452
|
* ```typescript
|
|
1453
1453
|
* // Remove simple attributes
|
|
1454
1454
|
* builder
|
|
1455
1455
|
* .remove('temporaryTag')
|
|
1456
1456
|
* .remove('previousLocation');
|
|
1457
|
-
*
|
|
1457
|
+
*
|
|
1458
1458
|
* // Remove nested attributes
|
|
1459
1459
|
* builder
|
|
1460
1460
|
* .remove('metadata.testData')
|
|
1461
1461
|
* .remove('stats.experimentalMetrics');
|
|
1462
1462
|
* ```
|
|
1463
|
-
*
|
|
1463
|
+
*
|
|
1464
1464
|
* @param path - The path to the attribute to remove
|
|
1465
1465
|
* @returns The builder instance for method chaining
|
|
1466
1466
|
*/
|
|
@@ -1477,20 +1477,20 @@ var UpdateBuilder = class {
|
|
|
1477
1477
|
* - Increment counters
|
|
1478
1478
|
* - Add elements to a set atomically
|
|
1479
1479
|
* - Update numerical statistics
|
|
1480
|
-
*
|
|
1480
|
+
*
|
|
1481
1481
|
* @example
|
|
1482
1482
|
* ```typescript
|
|
1483
1483
|
* // Increment counters
|
|
1484
1484
|
* builder
|
|
1485
1485
|
* .add('escapeAttempts', 1)
|
|
1486
1486
|
* .add('feedingCount', 1);
|
|
1487
|
-
*
|
|
1487
|
+
*
|
|
1488
1488
|
* // Add to sets
|
|
1489
1489
|
* builder
|
|
1490
1490
|
* .add('knownBehaviors', new Set(['PACK_HUNTING', 'AMBUSH_TACTICS']))
|
|
1491
1491
|
* .add('visitedZones', new Set(['ZONE_A', 'ZONE_B']));
|
|
1492
1492
|
* ```
|
|
1493
|
-
*
|
|
1493
|
+
*
|
|
1494
1494
|
* @param path - The path to the attribute to update
|
|
1495
1495
|
* @param value - The value to add (number or set)
|
|
1496
1496
|
* @returns The builder instance for method chaining
|
|
@@ -1509,7 +1509,7 @@ var UpdateBuilder = class {
|
|
|
1509
1509
|
* - Remove specific elements from a set
|
|
1510
1510
|
* - Update set-based attributes atomically
|
|
1511
1511
|
* - Maintain set membership
|
|
1512
|
-
*
|
|
1512
|
+
*
|
|
1513
1513
|
* @example
|
|
1514
1514
|
* ```typescript
|
|
1515
1515
|
* // Remove from sets using arrays
|
|
@@ -1517,20 +1517,20 @@ var UpdateBuilder = class {
|
|
|
1517
1517
|
* 'allowedHabitats',
|
|
1518
1518
|
* ['JUNGLE', 'COASTAL']
|
|
1519
1519
|
* );
|
|
1520
|
-
*
|
|
1520
|
+
*
|
|
1521
1521
|
* // Remove from sets using Set objects
|
|
1522
1522
|
* builder.deleteElementsFromSet(
|
|
1523
1523
|
* 'knownBehaviors',
|
|
1524
1524
|
* new Set(['NOCTURNAL', 'TERRITORIAL'])
|
|
1525
1525
|
* );
|
|
1526
|
-
*
|
|
1526
|
+
*
|
|
1527
1527
|
* // Remove from nested sets
|
|
1528
1528
|
* builder.deleteElementsFromSet(
|
|
1529
1529
|
* 'stats.compatibleSpecies',
|
|
1530
1530
|
* ['VELOCIRAPTOR', 'DILOPHOSAURUS']
|
|
1531
1531
|
* );
|
|
1532
1532
|
* ```
|
|
1533
|
-
*
|
|
1533
|
+
*
|
|
1534
1534
|
* @param path - The path to the set attribute
|
|
1535
1535
|
* @param value - Elements to remove (array or Set)
|
|
1536
1536
|
* @returns The builder instance for method chaining
|
|
@@ -1556,37 +1556,37 @@ var UpdateBuilder = class {
|
|
|
1556
1556
|
* - Ensure item state before update
|
|
1557
1557
|
* - Validate business rules
|
|
1558
1558
|
* - Prevent concurrent modifications
|
|
1559
|
-
*
|
|
1559
|
+
*
|
|
1560
1560
|
* @example
|
|
1561
1561
|
* ```typescript
|
|
1562
1562
|
* // Simple condition
|
|
1563
|
-
* builder.condition(op =>
|
|
1563
|
+
* builder.condition(op =>
|
|
1564
1564
|
* op.eq('status', 'ACTIVE')
|
|
1565
1565
|
* );
|
|
1566
|
-
*
|
|
1566
|
+
*
|
|
1567
1567
|
* // Health check condition
|
|
1568
|
-
* builder.condition(op =>
|
|
1568
|
+
* builder.condition(op =>
|
|
1569
1569
|
* op.and([
|
|
1570
1570
|
* op.gt('health', 50),
|
|
1571
1571
|
* op.eq('status', 'HUNTING')
|
|
1572
1572
|
* ])
|
|
1573
1573
|
* );
|
|
1574
|
-
*
|
|
1574
|
+
*
|
|
1575
1575
|
* // Complex security condition
|
|
1576
|
-
* builder.condition(op =>
|
|
1576
|
+
* builder.condition(op =>
|
|
1577
1577
|
* op.and([
|
|
1578
1578
|
* op.attributeExists('securitySystem'),
|
|
1579
1579
|
* op.eq('containmentStatus', 'SECURE'),
|
|
1580
1580
|
* op.lt('aggressionLevel', 8)
|
|
1581
1581
|
* ])
|
|
1582
1582
|
* );
|
|
1583
|
-
*
|
|
1583
|
+
*
|
|
1584
1584
|
* // Version check (optimistic locking)
|
|
1585
|
-
* builder.condition(op =>
|
|
1585
|
+
* builder.condition(op =>
|
|
1586
1586
|
* op.eq('version', currentVersion)
|
|
1587
1587
|
* );
|
|
1588
1588
|
* ```
|
|
1589
|
-
*
|
|
1589
|
+
*
|
|
1590
1590
|
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
1591
1591
|
* @returns The builder instance for method chaining
|
|
1592
1592
|
*/
|
|
@@ -1621,14 +1621,14 @@ var UpdateBuilder = class {
|
|
|
1621
1621
|
* - Track changes to specific attributes
|
|
1622
1622
|
* - Compare old and new values
|
|
1623
1623
|
* - Monitor attribute modifications
|
|
1624
|
-
*
|
|
1624
|
+
*
|
|
1625
1625
|
* Available options:
|
|
1626
1626
|
* - ALL_NEW: All attributes after the update
|
|
1627
1627
|
* - UPDATED_NEW: Only updated attributes, new values
|
|
1628
1628
|
* - ALL_OLD: All attributes before the update
|
|
1629
1629
|
* - UPDATED_OLD: Only updated attributes, old values
|
|
1630
1630
|
* - NONE: No attributes returned (default)
|
|
1631
|
-
*
|
|
1631
|
+
*
|
|
1632
1632
|
* @example
|
|
1633
1633
|
* ```typescript
|
|
1634
1634
|
* // Get complete updated dinosaur
|
|
@@ -1636,7 +1636,7 @@ var UpdateBuilder = class {
|
|
|
1636
1636
|
* .set('status', 'SLEEPING')
|
|
1637
1637
|
* .returnValues('ALL_NEW')
|
|
1638
1638
|
* .execute();
|
|
1639
|
-
*
|
|
1639
|
+
*
|
|
1640
1640
|
* // Track specific attribute changes
|
|
1641
1641
|
* const result = await builder
|
|
1642
1642
|
* .set({
|
|
@@ -1645,12 +1645,12 @@ var UpdateBuilder = class {
|
|
|
1645
1645
|
* })
|
|
1646
1646
|
* .returnValues('UPDATED_OLD')
|
|
1647
1647
|
* .execute();
|
|
1648
|
-
*
|
|
1648
|
+
*
|
|
1649
1649
|
* if (result.item) {
|
|
1650
1650
|
* console.log('Previous health:', result.item.stats?.health);
|
|
1651
1651
|
* }
|
|
1652
1652
|
* ```
|
|
1653
|
-
*
|
|
1653
|
+
*
|
|
1654
1654
|
* @param returnValues - Which attributes to return in the response
|
|
1655
1655
|
* @returns The builder instance for method chaining
|
|
1656
1656
|
*/
|
|
@@ -1752,26 +1752,26 @@ var UpdateBuilder = class {
|
|
|
1752
1752
|
* - Update items as part of a larger transaction
|
|
1753
1753
|
* - Ensure multiple updates are atomic
|
|
1754
1754
|
* - Coordinate updates across multiple items
|
|
1755
|
-
*
|
|
1755
|
+
*
|
|
1756
1756
|
* @example
|
|
1757
1757
|
* ```typescript
|
|
1758
1758
|
* const transaction = new TransactionBuilder(executor);
|
|
1759
|
-
*
|
|
1759
|
+
*
|
|
1760
1760
|
* // Update dinosaur status and habitat occupancy atomically
|
|
1761
1761
|
* new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
1762
1762
|
* .set('location', 'PADDOCK_A')
|
|
1763
1763
|
* .set('status', 'CONTAINED')
|
|
1764
1764
|
* .withTransaction(transaction);
|
|
1765
|
-
*
|
|
1765
|
+
*
|
|
1766
1766
|
* new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
1767
1767
|
* .add('occupants', 1)
|
|
1768
1768
|
* .set('lastOccupied', new Date().toISOString())
|
|
1769
1769
|
* .withTransaction(transaction);
|
|
1770
|
-
*
|
|
1770
|
+
*
|
|
1771
1771
|
* // Execute all operations atomically
|
|
1772
1772
|
* await transaction.execute();
|
|
1773
1773
|
* ```
|
|
1774
|
-
*
|
|
1774
|
+
*
|
|
1775
1775
|
* @param transaction - The transaction builder to add this operation to
|
|
1776
1776
|
* @returns The builder instance for method chaining
|
|
1777
1777
|
*/
|
|
@@ -1786,7 +1786,7 @@ var UpdateBuilder = class {
|
|
|
1786
1786
|
* - Verify attribute names and values
|
|
1787
1787
|
* - Log update operations
|
|
1788
1788
|
* - Troubleshoot condition expressions
|
|
1789
|
-
*
|
|
1789
|
+
*
|
|
1790
1790
|
* @example
|
|
1791
1791
|
* ```typescript
|
|
1792
1792
|
* // Create complex update
|
|
@@ -1798,12 +1798,12 @@ var UpdateBuilder = class {
|
|
|
1798
1798
|
* })
|
|
1799
1799
|
* .add('huntingSuccesses', 1)
|
|
1800
1800
|
* .condition(op => op.gt('health', 50));
|
|
1801
|
-
*
|
|
1801
|
+
*
|
|
1802
1802
|
* // Debug the update
|
|
1803
1803
|
* const debugInfo = builder.debug();
|
|
1804
1804
|
* console.log('Update operation:', debugInfo);
|
|
1805
1805
|
* ```
|
|
1806
|
-
*
|
|
1806
|
+
*
|
|
1807
1807
|
* @returns A readable representation of the update command with resolved expressions
|
|
1808
1808
|
*/
|
|
1809
1809
|
debug() {
|
|
@@ -1816,7 +1816,7 @@ var UpdateBuilder = class {
|
|
|
1816
1816
|
* - Apply updates immediately
|
|
1817
1817
|
* - Get the updated item values
|
|
1818
1818
|
* - Handle conditional update failures
|
|
1819
|
-
*
|
|
1819
|
+
*
|
|
1820
1820
|
* @example
|
|
1821
1821
|
* ```typescript
|
|
1822
1822
|
* try {
|
|
@@ -1828,7 +1828,7 @@ var UpdateBuilder = class {
|
|
|
1828
1828
|
* 'stats.hunger': 0
|
|
1829
1829
|
* })
|
|
1830
1830
|
* .add('feedingCount', 1)
|
|
1831
|
-
* .condition(op =>
|
|
1831
|
+
* .condition(op =>
|
|
1832
1832
|
* op.and([
|
|
1833
1833
|
* op.gt('stats.hunger', 80),
|
|
1834
1834
|
* op.eq('status', 'HUNTING')
|
|
@@ -1836,7 +1836,7 @@ var UpdateBuilder = class {
|
|
|
1836
1836
|
* )
|
|
1837
1837
|
* .returnValues('ALL_NEW')
|
|
1838
1838
|
* .execute();
|
|
1839
|
-
*
|
|
1839
|
+
*
|
|
1840
1840
|
* if (result.item) {
|
|
1841
1841
|
* console.log('Updated dinosaur:', result.item);
|
|
1842
1842
|
* }
|
|
@@ -1849,7 +1849,7 @@ var UpdateBuilder = class {
|
|
|
1849
1849
|
* }
|
|
1850
1850
|
* }
|
|
1851
1851
|
* ```
|
|
1852
|
-
*
|
|
1852
|
+
*
|
|
1853
1853
|
* @returns A promise that resolves to an object containing the updated item (if returnValues is set)
|
|
1854
1854
|
* @throws {ConditionalCheckFailedException} If the condition check fails
|
|
1855
1855
|
* @throws {Error} If the update operation fails for other reasons
|
|
@@ -1951,10 +1951,10 @@ var TransactionBuilder = class {
|
|
|
1951
1951
|
* - Insert new items as part of a transaction
|
|
1952
1952
|
* - Replace existing items atomically
|
|
1953
1953
|
* - Ensure items meet certain conditions before insertion
|
|
1954
|
-
*
|
|
1954
|
+
*
|
|
1955
1955
|
* The method automatically checks for duplicate items within the transaction
|
|
1956
1956
|
* to prevent multiple operations on the same item.
|
|
1957
|
-
*
|
|
1957
|
+
*
|
|
1958
1958
|
* @example
|
|
1959
1959
|
* ```typescript
|
|
1960
1960
|
* // Simple put operation
|
|
@@ -1963,14 +1963,14 @@ var TransactionBuilder = class {
|
|
|
1963
1963
|
* status: 'PENDING',
|
|
1964
1964
|
* amount: 100
|
|
1965
1965
|
* });
|
|
1966
|
-
*
|
|
1966
|
+
*
|
|
1967
1967
|
* // Conditional put operation
|
|
1968
1968
|
* transaction.put(
|
|
1969
1969
|
* 'inventory',
|
|
1970
1970
|
* { productId: 'ABC', quantity: 50 },
|
|
1971
1971
|
* op => op.attributeNotExists('productId')
|
|
1972
1972
|
* );
|
|
1973
|
-
*
|
|
1973
|
+
*
|
|
1974
1974
|
* // Put with complex condition
|
|
1975
1975
|
* transaction.put(
|
|
1976
1976
|
* 'users',
|
|
@@ -1981,7 +1981,7 @@ var TransactionBuilder = class {
|
|
|
1981
1981
|
* ])
|
|
1982
1982
|
* );
|
|
1983
1983
|
* ```
|
|
1984
|
-
*
|
|
1984
|
+
*
|
|
1985
1985
|
* @param tableName - The name of the DynamoDB table
|
|
1986
1986
|
* @param item - The item to put into the table
|
|
1987
1987
|
* @param condition - Optional condition that must be satisfied
|
|
@@ -2012,21 +2012,21 @@ var TransactionBuilder = class {
|
|
|
2012
2012
|
* - Reuse put commands from PutBuilder
|
|
2013
2013
|
* - Add complex put operations with pre-configured parameters
|
|
2014
2014
|
* - Integrate with existing put command configurations
|
|
2015
|
-
*
|
|
2015
|
+
*
|
|
2016
2016
|
* This method is particularly useful when working with PutBuilder
|
|
2017
2017
|
* to maintain consistency in put operations across your application.
|
|
2018
|
-
*
|
|
2018
|
+
*
|
|
2019
2019
|
* @example
|
|
2020
2020
|
* ```typescript
|
|
2021
2021
|
* // Create a put command with PutBuilder
|
|
2022
2022
|
* const putCommand = new PutBuilder(executor, newItem, 'users')
|
|
2023
2023
|
* .condition(op => op.attributeNotExists('userId'))
|
|
2024
2024
|
* .toDynamoCommand();
|
|
2025
|
-
*
|
|
2025
|
+
*
|
|
2026
2026
|
* // Add the command to the transaction
|
|
2027
2027
|
* transaction.putWithCommand(putCommand);
|
|
2028
2028
|
* ```
|
|
2029
|
-
*
|
|
2029
|
+
*
|
|
2030
2030
|
* @param command - The complete put command configuration
|
|
2031
2031
|
* @returns The transaction builder for method chaining
|
|
2032
2032
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
@@ -2047,10 +2047,10 @@ var TransactionBuilder = class {
|
|
|
2047
2047
|
* - Remove items as part of a transaction
|
|
2048
2048
|
* - Conditionally delete items
|
|
2049
2049
|
* - Ensure items exist before deletion
|
|
2050
|
-
*
|
|
2050
|
+
*
|
|
2051
2051
|
* The method automatically checks for duplicate items within the transaction
|
|
2052
2052
|
* to prevent multiple operations on the same item.
|
|
2053
|
-
*
|
|
2053
|
+
*
|
|
2054
2054
|
* @example
|
|
2055
2055
|
* ```typescript
|
|
2056
2056
|
* // Simple delete operation
|
|
@@ -2058,14 +2058,14 @@ var TransactionBuilder = class {
|
|
|
2058
2058
|
* pk: 'ORDER#123',
|
|
2059
2059
|
* sk: 'METADATA'
|
|
2060
2060
|
* });
|
|
2061
|
-
*
|
|
2061
|
+
*
|
|
2062
2062
|
* // Conditional delete operation
|
|
2063
2063
|
* transaction.delete(
|
|
2064
2064
|
* 'users',
|
|
2065
2065
|
* { pk: 'USER#123' },
|
|
2066
2066
|
* op => op.eq('status', 'INACTIVE')
|
|
2067
2067
|
* );
|
|
2068
|
-
*
|
|
2068
|
+
*
|
|
2069
2069
|
* // Delete with complex condition
|
|
2070
2070
|
* transaction.delete(
|
|
2071
2071
|
* 'products',
|
|
@@ -2076,7 +2076,7 @@ var TransactionBuilder = class {
|
|
|
2076
2076
|
* ])
|
|
2077
2077
|
* );
|
|
2078
2078
|
* ```
|
|
2079
|
-
*
|
|
2079
|
+
*
|
|
2080
2080
|
* @param tableName - The name of the DynamoDB table
|
|
2081
2081
|
* @param key - The primary key of the item to delete
|
|
2082
2082
|
* @param condition - Optional condition that must be satisfied
|
|
@@ -2110,10 +2110,10 @@ var TransactionBuilder = class {
|
|
|
2110
2110
|
* - Reuse delete commands from DeleteBuilder
|
|
2111
2111
|
* - Add complex delete operations with pre-configured parameters
|
|
2112
2112
|
* - Integrate with existing delete command configurations
|
|
2113
|
-
*
|
|
2113
|
+
*
|
|
2114
2114
|
* This method is particularly useful when working with DeleteBuilder
|
|
2115
2115
|
* to maintain consistency in delete operations across your application.
|
|
2116
|
-
*
|
|
2116
|
+
*
|
|
2117
2117
|
* @example
|
|
2118
2118
|
* ```typescript
|
|
2119
2119
|
* // Create a delete command with DeleteBuilder
|
|
@@ -2123,11 +2123,11 @@ var TransactionBuilder = class {
|
|
|
2123
2123
|
* op.eq('status', 'INACTIVE')
|
|
2124
2124
|
* ]))
|
|
2125
2125
|
* .toDynamoCommand();
|
|
2126
|
-
*
|
|
2126
|
+
*
|
|
2127
2127
|
* // Add the command to the transaction
|
|
2128
2128
|
* transaction.deleteWithCommand(deleteCommand);
|
|
2129
2129
|
* ```
|
|
2130
|
-
*
|
|
2130
|
+
*
|
|
2131
2131
|
* @param command - The complete delete command configuration
|
|
2132
2132
|
* @returns The transaction builder for method chaining
|
|
2133
2133
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
@@ -2149,13 +2149,13 @@ var TransactionBuilder = class {
|
|
|
2149
2149
|
* - Update multiple attributes atomically
|
|
2150
2150
|
* - Apply conditional updates
|
|
2151
2151
|
* - Perform complex attribute manipulations
|
|
2152
|
-
*
|
|
2152
|
+
*
|
|
2153
2153
|
* The method supports all DynamoDB update expressions:
|
|
2154
2154
|
* - SET: Modify or add attributes
|
|
2155
2155
|
* - REMOVE: Delete attributes
|
|
2156
2156
|
* - ADD: Update numbers and sets
|
|
2157
2157
|
* - DELETE: Remove elements from a set
|
|
2158
|
-
*
|
|
2158
|
+
*
|
|
2159
2159
|
* @example
|
|
2160
2160
|
* ```typescript
|
|
2161
2161
|
* // Simple update
|
|
@@ -2166,7 +2166,7 @@ var TransactionBuilder = class {
|
|
|
2166
2166
|
* { '#status': 'status' },
|
|
2167
2167
|
* { ':status': 'PROCESSING' }
|
|
2168
2168
|
* );
|
|
2169
|
-
*
|
|
2169
|
+
*
|
|
2170
2170
|
* // Complex update with multiple operations
|
|
2171
2171
|
* transaction.update(
|
|
2172
2172
|
* 'products',
|
|
@@ -2175,7 +2175,7 @@ var TransactionBuilder = class {
|
|
|
2175
2175
|
* { '#qty': 'quantity', '#status': 'status', '#oldAttr': 'deprecated_field' },
|
|
2176
2176
|
* { ':amount': 1, ':status': 'LOW_STOCK' }
|
|
2177
2177
|
* );
|
|
2178
|
-
*
|
|
2178
|
+
*
|
|
2179
2179
|
* // Conditional update
|
|
2180
2180
|
* transaction.update(
|
|
2181
2181
|
* 'users',
|
|
@@ -2186,7 +2186,7 @@ var TransactionBuilder = class {
|
|
|
2186
2186
|
* op => op.attributeExists('pk')
|
|
2187
2187
|
* );
|
|
2188
2188
|
* ```
|
|
2189
|
-
*
|
|
2189
|
+
*
|
|
2190
2190
|
* @param tableName - The name of the DynamoDB table
|
|
2191
2191
|
* @param key - The primary key of the item to update
|
|
2192
2192
|
* @param updateExpression - The update expression (SET, REMOVE, ADD, DELETE)
|
|
@@ -2232,10 +2232,10 @@ var TransactionBuilder = class {
|
|
|
2232
2232
|
* - Reuse update commands from UpdateBuilder
|
|
2233
2233
|
* - Add complex update operations with pre-configured parameters
|
|
2234
2234
|
* - Integrate with existing update command configurations
|
|
2235
|
-
*
|
|
2235
|
+
*
|
|
2236
2236
|
* This method is particularly useful when working with UpdateBuilder
|
|
2237
2237
|
* to maintain consistency in update operations across your application.
|
|
2238
|
-
*
|
|
2238
|
+
*
|
|
2239
2239
|
* @example
|
|
2240
2240
|
* ```typescript
|
|
2241
2241
|
* // Create an update command with UpdateBuilder
|
|
@@ -2248,11 +2248,11 @@ var TransactionBuilder = class {
|
|
|
2248
2248
|
* })
|
|
2249
2249
|
* .condition(op => op.gt('quantity', 0))
|
|
2250
2250
|
* .toDynamoCommand();
|
|
2251
|
-
*
|
|
2251
|
+
*
|
|
2252
2252
|
* // Add the command to the transaction
|
|
2253
2253
|
* transaction.updateWithCommand(updateCommand);
|
|
2254
2254
|
* ```
|
|
2255
|
-
*
|
|
2255
|
+
*
|
|
2256
2256
|
* @param command - The complete update command configuration
|
|
2257
2257
|
* @returns The transaction builder for method chaining
|
|
2258
2258
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
@@ -2274,12 +2274,12 @@ var TransactionBuilder = class {
|
|
|
2274
2274
|
* - Ensure data consistency across tables
|
|
2275
2275
|
* - Implement complex business rules
|
|
2276
2276
|
* - Verify preconditions for other operations
|
|
2277
|
-
*
|
|
2277
|
+
*
|
|
2278
2278
|
* Condition checks are particularly useful for:
|
|
2279
2279
|
* - Implementing optimistic locking
|
|
2280
2280
|
* - Ensuring referential integrity
|
|
2281
2281
|
* - Validating business rules atomically
|
|
2282
|
-
*
|
|
2282
|
+
*
|
|
2283
2283
|
* @example
|
|
2284
2284
|
* ```typescript
|
|
2285
2285
|
* // Check if order is in correct state
|
|
@@ -2288,7 +2288,7 @@ var TransactionBuilder = class {
|
|
|
2288
2288
|
* { pk: 'ORDER#123' },
|
|
2289
2289
|
* op => op.eq('status', 'PENDING')
|
|
2290
2290
|
* );
|
|
2291
|
-
*
|
|
2291
|
+
*
|
|
2292
2292
|
* // Complex condition check
|
|
2293
2293
|
* transaction.conditionCheck(
|
|
2294
2294
|
* 'inventory',
|
|
@@ -2299,7 +2299,7 @@ var TransactionBuilder = class {
|
|
|
2299
2299
|
* op.attributeExists('lastRestockDate')
|
|
2300
2300
|
* ])
|
|
2301
2301
|
* );
|
|
2302
|
-
*
|
|
2302
|
+
*
|
|
2303
2303
|
* // Check with multiple attributes
|
|
2304
2304
|
* transaction.conditionCheck(
|
|
2305
2305
|
* 'users',
|
|
@@ -2310,7 +2310,7 @@ var TransactionBuilder = class {
|
|
|
2310
2310
|
* ])
|
|
2311
2311
|
* );
|
|
2312
2312
|
* ```
|
|
2313
|
-
*
|
|
2313
|
+
*
|
|
2314
2314
|
* @param tableName - The name of the DynamoDB table
|
|
2315
2315
|
* @param key - The primary key of the item to check
|
|
2316
2316
|
* @param condition - The condition that must be satisfied
|
|
@@ -2346,10 +2346,10 @@ var TransactionBuilder = class {
|
|
|
2346
2346
|
* - Reuse condition checks from ConditionCheckBuilder
|
|
2347
2347
|
* - Add complex condition checks with pre-configured parameters
|
|
2348
2348
|
* - Integrate with existing condition check configurations
|
|
2349
|
-
*
|
|
2349
|
+
*
|
|
2350
2350
|
* This method is particularly useful when working with ConditionCheckBuilder
|
|
2351
2351
|
* to maintain consistency in condition checks across your application.
|
|
2352
|
-
*
|
|
2352
|
+
*
|
|
2353
2353
|
* @example
|
|
2354
2354
|
* ```typescript
|
|
2355
2355
|
* // Create a condition check with ConditionCheckBuilder
|
|
@@ -2360,11 +2360,11 @@ var TransactionBuilder = class {
|
|
|
2360
2360
|
* op.attributeExists('lastAuditDate')
|
|
2361
2361
|
* ]))
|
|
2362
2362
|
* .toDynamoCommand();
|
|
2363
|
-
*
|
|
2363
|
+
*
|
|
2364
2364
|
* // Add the command to the transaction
|
|
2365
2365
|
* transaction.conditionCheckWithCommand(checkCommand);
|
|
2366
2366
|
* ```
|
|
2367
|
-
*
|
|
2367
|
+
*
|
|
2368
2368
|
* @param command - The complete condition check command configuration
|
|
2369
2369
|
* @returns The transaction builder for method chaining
|
|
2370
2370
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
@@ -2385,7 +2385,7 @@ var TransactionBuilder = class {
|
|
|
2385
2385
|
* - Enable idempotent transactions
|
|
2386
2386
|
* - Track consumed capacity
|
|
2387
2387
|
* - Monitor item collection metrics
|
|
2388
|
-
*
|
|
2388
|
+
*
|
|
2389
2389
|
* @example
|
|
2390
2390
|
* ```typescript
|
|
2391
2391
|
* // Enable idempotency and capacity tracking
|
|
@@ -2393,16 +2393,16 @@ var TransactionBuilder = class {
|
|
|
2393
2393
|
* clientRequestToken: 'unique-request-id-123',
|
|
2394
2394
|
* returnConsumedCapacity: 'TOTAL'
|
|
2395
2395
|
* });
|
|
2396
|
-
*
|
|
2396
|
+
*
|
|
2397
2397
|
* // Track item collection metrics
|
|
2398
2398
|
* transaction.withOptions({
|
|
2399
2399
|
* returnItemCollectionMetrics: 'SIZE'
|
|
2400
2400
|
* });
|
|
2401
2401
|
* ```
|
|
2402
|
-
*
|
|
2402
|
+
*
|
|
2403
2403
|
* Note: ClientRequestToken can be used to make transactions idempotent,
|
|
2404
2404
|
* ensuring the same transaction is not executed multiple times.
|
|
2405
|
-
*
|
|
2405
|
+
*
|
|
2406
2406
|
* @param options - Configuration options for the transaction
|
|
2407
2407
|
* @returns The transaction builder for method chaining
|
|
2408
2408
|
*/
|
|
@@ -2417,27 +2417,27 @@ var TransactionBuilder = class {
|
|
|
2417
2417
|
* - Verify operation parameters
|
|
2418
2418
|
* - Log transaction details
|
|
2419
2419
|
* - Troubleshoot condition expressions
|
|
2420
|
-
*
|
|
2420
|
+
*
|
|
2421
2421
|
* The method resolves all expression placeholders with their actual values,
|
|
2422
2422
|
* making it easier to understand the transaction's operations.
|
|
2423
|
-
*
|
|
2423
|
+
*
|
|
2424
2424
|
* @example
|
|
2425
2425
|
* ```typescript
|
|
2426
2426
|
* // Add multiple operations
|
|
2427
2427
|
* transaction
|
|
2428
2428
|
* .put('orders', { orderId: '123', status: 'PENDING' })
|
|
2429
|
-
* .update('inventory',
|
|
2429
|
+
* .update('inventory',
|
|
2430
2430
|
* { productId: 'ABC' },
|
|
2431
2431
|
* 'SET quantity = quantity - :amount',
|
|
2432
2432
|
* undefined,
|
|
2433
2433
|
* { ':amount': 1 }
|
|
2434
2434
|
* );
|
|
2435
|
-
*
|
|
2435
|
+
*
|
|
2436
2436
|
* // Debug the transaction
|
|
2437
2437
|
* const debugInfo = transaction.debug();
|
|
2438
2438
|
* console.log('Transaction operations:', debugInfo);
|
|
2439
2439
|
* ```
|
|
2440
|
-
*
|
|
2440
|
+
*
|
|
2441
2441
|
* @returns An array of readable representations of the transaction items
|
|
2442
2442
|
*/
|
|
2443
2443
|
debug() {
|
|
@@ -2449,17 +2449,17 @@ var TransactionBuilder = class {
|
|
|
2449
2449
|
* - Perform multiple operations atomically
|
|
2450
2450
|
* - Ensure all-or-nothing execution
|
|
2451
2451
|
* - Maintain data consistency across operations
|
|
2452
|
-
*
|
|
2452
|
+
*
|
|
2453
2453
|
* The transaction will only succeed if all operations succeed.
|
|
2454
2454
|
* If any operation fails, the entire transaction is rolled back.
|
|
2455
|
-
*
|
|
2455
|
+
*
|
|
2456
2456
|
* @example
|
|
2457
2457
|
* ```typescript
|
|
2458
2458
|
* try {
|
|
2459
2459
|
* // Build and execute transaction
|
|
2460
2460
|
* await transaction
|
|
2461
2461
|
* .put('orders', newOrder)
|
|
2462
|
-
* .update('inventory',
|
|
2462
|
+
* .update('inventory',
|
|
2463
2463
|
* { productId: 'ABC' },
|
|
2464
2464
|
* 'SET quantity = quantity - :qty',
|
|
2465
2465
|
* undefined,
|
|
@@ -2470,14 +2470,14 @@ var TransactionBuilder = class {
|
|
|
2470
2470
|
* op => op.eq('status', 'ACTIVE')
|
|
2471
2471
|
* )
|
|
2472
2472
|
* .execute();
|
|
2473
|
-
*
|
|
2473
|
+
*
|
|
2474
2474
|
* console.log('Transaction completed successfully');
|
|
2475
2475
|
* } catch (error) {
|
|
2476
2476
|
* // Handle transaction failure
|
|
2477
2477
|
* console.error('Transaction failed:', error);
|
|
2478
2478
|
* }
|
|
2479
2479
|
* ```
|
|
2480
|
-
*
|
|
2480
|
+
*
|
|
2481
2481
|
* @throws {Error} If no transaction items are specified
|
|
2482
2482
|
* @throws {Error} If any operation in the transaction fails
|
|
2483
2483
|
* @returns A promise that resolves when the transaction completes
|
|
@@ -2576,29 +2576,29 @@ var ConditionCheckBuilder = class {
|
|
|
2576
2576
|
* - Validate complex item states
|
|
2577
2577
|
* - Check multiple attributes together
|
|
2578
2578
|
* - Ensure safety conditions are met
|
|
2579
|
-
*
|
|
2579
|
+
*
|
|
2580
2580
|
* @example
|
|
2581
2581
|
* ```typescript
|
|
2582
2582
|
* // Check dinosaur health and behavior
|
|
2583
|
-
* builder.condition(op =>
|
|
2583
|
+
* builder.condition(op =>
|
|
2584
2584
|
* op.and([
|
|
2585
2585
|
* op.gt('stats.health', 50),
|
|
2586
2586
|
* op.not(op.eq('status', 'SEDATED')),
|
|
2587
2587
|
* op.lt('aggressionLevel', 8)
|
|
2588
2588
|
* ])
|
|
2589
2589
|
* );
|
|
2590
|
-
*
|
|
2590
|
+
*
|
|
2591
2591
|
* // Verify habitat conditions
|
|
2592
|
-
* builder.condition(op =>
|
|
2592
|
+
* builder.condition(op =>
|
|
2593
2593
|
* op.and([
|
|
2594
2594
|
* op.eq('powerStatus', 'ONLINE'),
|
|
2595
2595
|
* op.between('temperature', 20, 30),
|
|
2596
2596
|
* op.attributeExists('lastMaintenance')
|
|
2597
2597
|
* ])
|
|
2598
2598
|
* );
|
|
2599
|
-
*
|
|
2599
|
+
*
|
|
2600
2600
|
* // Check breeding conditions
|
|
2601
|
-
* builder.condition(op =>
|
|
2601
|
+
* builder.condition(op =>
|
|
2602
2602
|
* op.and([
|
|
2603
2603
|
* op.eq('species', 'VELOCIRAPTOR'),
|
|
2604
2604
|
* op.gte('age', 3),
|
|
@@ -2606,7 +2606,7 @@ var ConditionCheckBuilder = class {
|
|
|
2606
2606
|
* ])
|
|
2607
2607
|
* );
|
|
2608
2608
|
* ```
|
|
2609
|
-
*
|
|
2609
|
+
*
|
|
2610
2610
|
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
2611
2611
|
* @returns The builder instance for method chaining
|
|
2612
2612
|
*/
|
|
@@ -3257,6 +3257,7 @@ export {
|
|
|
3257
3257
|
beginsWith,
|
|
3258
3258
|
between,
|
|
3259
3259
|
contains,
|
|
3260
|
+
createComparisonCondition,
|
|
3260
3261
|
eq,
|
|
3261
3262
|
gt,
|
|
3262
3263
|
gte,
|