@jspreddy/torq 0.1.31

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/module.js ADDED
@@ -0,0 +1,1149 @@
1
+ import $6B8p2$lodash from "lodash";
2
+ import $6B8p2$assert from "assert";
3
+
4
+
5
+ // picked up from https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
6
+ /**
7
+ * These words are reserved in dynamodb and can not be used as part of expressions.
8
+ * If we need to use these words, then we will have to use expression attribute names concept.
9
+ *
10
+ * CASE INSENSITIVE
11
+ */ const $8377f7c5fcf1cce8$export$e46d647da3214494 = [
12
+ 'ABORT',
13
+ 'ABSOLUTE',
14
+ 'ACTION',
15
+ 'ADD',
16
+ 'AFTER',
17
+ 'AGENT',
18
+ 'AGGREGATE',
19
+ 'ALL',
20
+ 'ALLOCATE',
21
+ 'ALTER',
22
+ 'ANALYZE',
23
+ 'AND',
24
+ 'ANY',
25
+ 'ARCHIVE',
26
+ 'ARE',
27
+ 'ARRAY',
28
+ 'AS',
29
+ 'ASC',
30
+ 'ASCII',
31
+ 'ASENSITIVE',
32
+ 'ASSERTION',
33
+ 'ASYMMETRIC',
34
+ 'AT',
35
+ 'ATOMIC',
36
+ 'ATTACH',
37
+ 'ATTRIBUTE',
38
+ 'AUTH',
39
+ 'AUTHORIZATION',
40
+ 'AUTHORIZE',
41
+ 'AUTO',
42
+ 'AVG',
43
+ 'BACK',
44
+ 'BACKUP',
45
+ 'BASE',
46
+ 'BATCH',
47
+ 'BEFORE',
48
+ 'BEGIN',
49
+ 'BETWEEN',
50
+ 'BIGINT',
51
+ 'BINARY',
52
+ 'BIT',
53
+ 'BLOB',
54
+ 'BLOCK',
55
+ 'BOOLEAN',
56
+ 'BOTH',
57
+ 'BREADTH',
58
+ 'BUCKET',
59
+ 'BULK',
60
+ 'BY',
61
+ 'BYTE',
62
+ 'CALL',
63
+ 'CALLED',
64
+ 'CALLING',
65
+ 'CAPACITY',
66
+ 'CASCADE',
67
+ 'CASCADED',
68
+ 'CASE',
69
+ 'CAST',
70
+ 'CATALOG',
71
+ 'CHAR',
72
+ 'CHARACTER',
73
+ 'CHECK',
74
+ 'CLASS',
75
+ 'CLOB',
76
+ 'CLOSE',
77
+ 'CLUSTER',
78
+ 'CLUSTERED',
79
+ 'CLUSTERING',
80
+ 'CLUSTERS',
81
+ 'COALESCE',
82
+ 'COLLATE',
83
+ 'COLLATION',
84
+ 'COLLECTION',
85
+ 'COLUMN',
86
+ 'COLUMNS',
87
+ 'COMBINE',
88
+ 'COMMENT',
89
+ 'COMMIT',
90
+ 'COMPACT',
91
+ 'COMPILE',
92
+ 'COMPRESS',
93
+ 'CONDITION',
94
+ 'CONFLICT',
95
+ 'CONNECT',
96
+ 'CONNECTION',
97
+ 'CONSISTENCY',
98
+ 'CONSISTENT',
99
+ 'CONSTRAINT',
100
+ 'CONSTRAINTS',
101
+ 'CONSTRUCTOR',
102
+ 'CONSUMED',
103
+ 'CONTINUE',
104
+ 'CONVERT',
105
+ 'COPY',
106
+ 'CORRESPONDING',
107
+ 'COUNT',
108
+ 'COUNTER',
109
+ 'CREATE',
110
+ 'CROSS',
111
+ 'CUBE',
112
+ 'CURRENT',
113
+ 'CURSOR',
114
+ 'CYCLE',
115
+ 'DATA',
116
+ 'DATABASE',
117
+ 'DATE',
118
+ 'DATETIME',
119
+ 'DAY',
120
+ 'DEALLOCATE',
121
+ 'DEC',
122
+ 'DECIMAL',
123
+ 'DECLARE',
124
+ 'DEFAULT',
125
+ 'DEFERRABLE',
126
+ 'DEFERRED',
127
+ 'DEFINE',
128
+ 'DEFINED',
129
+ 'DEFINITION',
130
+ 'DELETE',
131
+ 'DELIMITED',
132
+ 'DEPTH',
133
+ 'DEREF',
134
+ 'DESC',
135
+ 'DESCRIBE',
136
+ 'DESCRIPTOR',
137
+ 'DETACH',
138
+ 'DETERMINISTIC',
139
+ 'DIAGNOSTICS',
140
+ 'DIRECTORIES',
141
+ 'DISABLE',
142
+ 'DISCONNECT',
143
+ 'DISTINCT',
144
+ 'DISTRIBUTE',
145
+ 'DO',
146
+ 'DOMAIN',
147
+ 'DOUBLE',
148
+ 'DROP',
149
+ 'DUMP',
150
+ 'DURATION',
151
+ 'DYNAMIC',
152
+ 'EACH',
153
+ 'ELEMENT',
154
+ 'ELSE',
155
+ 'ELSEIF',
156
+ 'EMPTY',
157
+ 'ENABLE',
158
+ 'END',
159
+ 'EQUAL',
160
+ 'EQUALS',
161
+ 'ERROR',
162
+ 'ESCAPE',
163
+ 'ESCAPED',
164
+ 'EVAL',
165
+ 'EVALUATE',
166
+ 'EXCEEDED',
167
+ 'EXCEPT',
168
+ 'EXCEPTION',
169
+ 'EXCEPTIONS',
170
+ 'EXCLUSIVE',
171
+ 'EXEC',
172
+ 'EXECUTE',
173
+ 'EXISTS',
174
+ 'EXIT',
175
+ 'EXPLAIN',
176
+ 'EXPLODE',
177
+ 'EXPORT',
178
+ 'EXPRESSION',
179
+ 'EXTENDED',
180
+ 'EXTERNAL',
181
+ 'EXTRACT',
182
+ 'FAIL',
183
+ 'FALSE',
184
+ 'FAMILY',
185
+ 'FETCH',
186
+ 'FIELDS',
187
+ 'FILE',
188
+ 'FILTER',
189
+ 'FILTERING',
190
+ 'FINAL',
191
+ 'FINISH',
192
+ 'FIRST',
193
+ 'FIXED',
194
+ 'FLATTERN',
195
+ 'FLOAT',
196
+ 'FOR',
197
+ 'FORCE',
198
+ 'FOREIGN',
199
+ 'FORMAT',
200
+ 'FORWARD',
201
+ 'FOUND',
202
+ 'FREE',
203
+ 'FROM',
204
+ 'FULL',
205
+ 'FUNCTION',
206
+ 'FUNCTIONS',
207
+ 'GENERAL',
208
+ 'GENERATE',
209
+ 'GET',
210
+ 'GLOB',
211
+ 'GLOBAL',
212
+ 'GO',
213
+ 'GOTO',
214
+ 'GRANT',
215
+ 'GREATER',
216
+ 'GROUP',
217
+ 'GROUPING',
218
+ 'HANDLER',
219
+ 'HASH',
220
+ 'HAVE',
221
+ 'HAVING',
222
+ 'HEAP',
223
+ 'HIDDEN',
224
+ 'HOLD',
225
+ 'HOUR',
226
+ 'IDENTIFIED',
227
+ 'IDENTITY',
228
+ 'IF',
229
+ 'IGNORE',
230
+ 'IMMEDIATE',
231
+ 'IMPORT',
232
+ 'IN',
233
+ 'INCLUDING',
234
+ 'INCLUSIVE',
235
+ 'INCREMENT',
236
+ 'INCREMENTAL',
237
+ 'INDEX',
238
+ 'INDEXED',
239
+ 'INDEXES',
240
+ 'INDICATOR',
241
+ 'INFINITE',
242
+ 'INITIALLY',
243
+ 'INLINE',
244
+ 'INNER',
245
+ 'INNTER',
246
+ 'INOUT',
247
+ 'INPUT',
248
+ 'INSENSITIVE',
249
+ 'INSERT',
250
+ 'INSTEAD',
251
+ 'INT',
252
+ 'INTEGER',
253
+ 'INTERSECT',
254
+ 'INTERVAL',
255
+ 'INTO',
256
+ 'INVALIDATE',
257
+ 'IS',
258
+ 'ISOLATION',
259
+ 'ITEM',
260
+ 'ITEMS',
261
+ 'ITERATE',
262
+ 'JOIN',
263
+ 'KEY',
264
+ 'KEYS',
265
+ 'LAG',
266
+ 'LANGUAGE',
267
+ 'LARGE',
268
+ 'LAST',
269
+ 'LATERAL',
270
+ 'LEAD',
271
+ 'LEADING',
272
+ 'LEAVE',
273
+ 'LEFT',
274
+ 'LENGTH',
275
+ 'LESS',
276
+ 'LEVEL',
277
+ 'LIKE',
278
+ 'LIMIT',
279
+ 'LIMITED',
280
+ 'LINES',
281
+ 'LIST',
282
+ 'LOAD',
283
+ 'LOCAL',
284
+ 'LOCALTIME',
285
+ 'LOCALTIMESTAMP',
286
+ 'LOCATION',
287
+ 'LOCATOR',
288
+ 'LOCK',
289
+ 'LOCKS',
290
+ 'LOG',
291
+ 'LOGED',
292
+ 'LONG',
293
+ 'LOOP',
294
+ 'LOWER',
295
+ 'MAP',
296
+ 'MATCH',
297
+ 'MATERIALIZED',
298
+ 'MAX',
299
+ 'MAXLEN',
300
+ 'MEMBER',
301
+ 'MERGE',
302
+ 'METHOD',
303
+ 'METRICS',
304
+ 'MIN',
305
+ 'MINUS',
306
+ 'MINUTE',
307
+ 'MISSING',
308
+ 'MOD',
309
+ 'MODE',
310
+ 'MODIFIES',
311
+ 'MODIFY',
312
+ 'MODULE',
313
+ 'MONTH',
314
+ 'MULTI',
315
+ 'MULTISET',
316
+ 'NAME',
317
+ 'NAMES',
318
+ 'NATIONAL',
319
+ 'NATURAL',
320
+ 'NCHAR',
321
+ 'NCLOB',
322
+ 'NEW',
323
+ 'NEXT',
324
+ 'NO',
325
+ 'NONE',
326
+ 'NOT',
327
+ 'NULL',
328
+ 'NULLIF',
329
+ 'NUMBER',
330
+ 'NUMERIC',
331
+ 'OBJECT',
332
+ 'OF',
333
+ 'OFFLINE',
334
+ 'OFFSET',
335
+ 'OLD',
336
+ 'ON',
337
+ 'ONLINE',
338
+ 'ONLY',
339
+ 'OPAQUE',
340
+ 'OPEN',
341
+ 'OPERATOR',
342
+ 'OPTION',
343
+ 'OR',
344
+ 'ORDER',
345
+ 'ORDINALITY',
346
+ 'OTHER',
347
+ 'OTHERS',
348
+ 'OUT',
349
+ 'OUTER',
350
+ 'OUTPUT',
351
+ 'OVER',
352
+ 'OVERLAPS',
353
+ 'OVERRIDE',
354
+ 'OWNER',
355
+ 'PAD',
356
+ 'PARALLEL',
357
+ 'PARAMETER',
358
+ 'PARAMETERS',
359
+ 'PARTIAL',
360
+ 'PARTITION',
361
+ 'PARTITIONED',
362
+ 'PARTITIONS',
363
+ 'PATH',
364
+ 'PERCENT',
365
+ 'PERCENTILE',
366
+ 'PERMISSION',
367
+ 'PERMISSIONS',
368
+ 'PIPE',
369
+ 'PIPELINED',
370
+ 'PLAN',
371
+ 'POOL',
372
+ 'POSITION',
373
+ 'PRECISION',
374
+ 'PREPARE',
375
+ 'PRESERVE',
376
+ 'PRIMARY',
377
+ 'PRIOR',
378
+ 'PRIVATE',
379
+ 'PRIVILEGES',
380
+ 'PROCEDURE',
381
+ 'PROCESSED',
382
+ 'PROJECT',
383
+ 'PROJECTION',
384
+ 'PROPERTY',
385
+ 'PROVISIONING',
386
+ 'PUBLIC',
387
+ 'PUT',
388
+ 'QUERY',
389
+ 'QUIT',
390
+ 'QUORUM',
391
+ 'RAISE',
392
+ 'RANDOM',
393
+ 'RANGE',
394
+ 'RANK',
395
+ 'RAW',
396
+ 'READ',
397
+ 'READS',
398
+ 'REAL',
399
+ 'REBUILD',
400
+ 'RECORD',
401
+ 'RECURSIVE',
402
+ 'REDUCE',
403
+ 'REF',
404
+ 'REFERENCE',
405
+ 'REFERENCES',
406
+ 'REFERENCING',
407
+ 'REGEXP',
408
+ 'REGION',
409
+ 'REINDEX',
410
+ 'RELATIVE',
411
+ 'RELEASE',
412
+ 'REMAINDER',
413
+ 'RENAME',
414
+ 'REPEAT',
415
+ 'REPLACE',
416
+ 'REQUEST',
417
+ 'RESET',
418
+ 'RESIGNAL',
419
+ 'RESOURCE',
420
+ 'RESPONSE',
421
+ 'RESTORE',
422
+ 'RESTRICT',
423
+ 'RESULT',
424
+ 'RETURN',
425
+ 'RETURNING',
426
+ 'RETURNS',
427
+ 'REVERSE',
428
+ 'REVOKE',
429
+ 'RIGHT',
430
+ 'ROLE',
431
+ 'ROLES',
432
+ 'ROLLBACK',
433
+ 'ROLLUP',
434
+ 'ROUTINE',
435
+ 'ROW',
436
+ 'ROWS',
437
+ 'RULE',
438
+ 'RULES',
439
+ 'SAMPLE',
440
+ 'SATISFIES',
441
+ 'SAVE',
442
+ 'SAVEPOINT',
443
+ 'SCAN',
444
+ 'SCHEMA',
445
+ 'SCOPE',
446
+ 'SCROLL',
447
+ 'SEARCH',
448
+ 'SECOND',
449
+ 'SECTION',
450
+ 'SEGMENT',
451
+ 'SEGMENTS',
452
+ 'SELECT',
453
+ 'SELF',
454
+ 'SEMI',
455
+ 'SENSITIVE',
456
+ 'SEPARATE',
457
+ 'SEQUENCE',
458
+ 'SERIALIZABLE',
459
+ 'SESSION',
460
+ 'SET',
461
+ 'SETS',
462
+ 'SHARD',
463
+ 'SHARE',
464
+ 'SHARED',
465
+ 'SHORT',
466
+ 'SHOW',
467
+ 'SIGNAL',
468
+ 'SIMILAR',
469
+ 'SIZE',
470
+ 'SKEWED',
471
+ 'SMALLINT',
472
+ 'SNAPSHOT',
473
+ 'SOME',
474
+ 'SOURCE',
475
+ 'SPACE',
476
+ 'SPACES',
477
+ 'SPARSE',
478
+ 'SPECIFIC',
479
+ 'SPECIFICTYPE',
480
+ 'SPLIT',
481
+ 'SQL',
482
+ 'SQLCODE',
483
+ 'SQLERROR',
484
+ 'SQLEXCEPTION',
485
+ 'SQLSTATE',
486
+ 'SQLWARNING',
487
+ 'START',
488
+ 'STATE',
489
+ 'STATIC',
490
+ 'STATUS',
491
+ 'STORAGE',
492
+ 'STORE',
493
+ 'STORED',
494
+ 'STREAM',
495
+ 'STRING',
496
+ 'STRUCT',
497
+ 'STYLE',
498
+ 'SUB',
499
+ 'SUBMULTISET',
500
+ 'SUBPARTITION',
501
+ 'SUBSTRING',
502
+ 'SUBTYPE',
503
+ 'SUM',
504
+ 'SUPER',
505
+ 'SYMMETRIC',
506
+ 'SYNONYM',
507
+ 'SYSTEM',
508
+ 'TABLE',
509
+ 'TABLESAMPLE',
510
+ 'TEMP',
511
+ 'TEMPORARY',
512
+ 'TERMINATED',
513
+ 'TEXT',
514
+ 'THAN',
515
+ 'THEN',
516
+ 'THROUGHPUT',
517
+ 'TIME',
518
+ 'TIMESTAMP',
519
+ 'TIMEZONE',
520
+ 'TINYINT',
521
+ 'TO',
522
+ 'TOKEN',
523
+ 'TOTAL',
524
+ 'TOUCH',
525
+ 'TRAILING',
526
+ 'TRANSACTION',
527
+ 'TRANSFORM',
528
+ 'TRANSLATE',
529
+ 'TRANSLATION',
530
+ 'TREAT',
531
+ 'TRIGGER',
532
+ 'TRIM',
533
+ 'TRUE',
534
+ 'TRUNCATE',
535
+ 'TTL',
536
+ 'TUPLE',
537
+ 'TYPE',
538
+ 'UNDER',
539
+ 'UNDO',
540
+ 'UNION',
541
+ 'UNIQUE',
542
+ 'UNIT',
543
+ 'UNKNOWN',
544
+ 'UNLOGGED',
545
+ 'UNNEST',
546
+ 'UNPROCESSED',
547
+ 'UNSIGNED',
548
+ 'UNTIL',
549
+ 'UPDATE',
550
+ 'UPPER',
551
+ 'URL',
552
+ 'USAGE',
553
+ 'USE',
554
+ 'USER',
555
+ 'USERS',
556
+ 'USING',
557
+ 'UUID',
558
+ 'VACUUM',
559
+ 'VALUE',
560
+ 'VALUED',
561
+ 'VALUES',
562
+ 'VARCHAR',
563
+ 'VARIABLE',
564
+ 'VARIANCE',
565
+ 'VARINT',
566
+ 'VARYING',
567
+ 'VIEW',
568
+ 'VIEWS',
569
+ 'VIRTUAL',
570
+ 'VOID',
571
+ 'WAIT',
572
+ 'WHEN',
573
+ 'WHENEVER',
574
+ 'WHERE',
575
+ 'WHILE',
576
+ 'WINDOW',
577
+ 'WITH',
578
+ 'WITHIN',
579
+ 'WITHOUT',
580
+ 'WORK',
581
+ 'WRAPPED',
582
+ 'WRITE',
583
+ 'YEAR',
584
+ 'ZONE'
585
+ ];
586
+
587
+
588
+
589
+ var $1ced42141bbfde9c$export$99a24bd46fd1f406 = /*#__PURE__*/ function(DdbType) {
590
+ DdbType["String"] = "S";
591
+ DdbType["StringSet"] = "SS";
592
+ DdbType["Number"] = "N";
593
+ DdbType["NumberSet"] = "NS";
594
+ DdbType["Binary"] = "B";
595
+ DdbType["BinarySet"] = "BS";
596
+ DdbType["Boolean"] = "BOOL";
597
+ DdbType["Null"] = "NULL";
598
+ DdbType["List"] = "L";
599
+ DdbType["Map"] = "M";
600
+ return DdbType;
601
+ }({});
602
+ var $1ced42141bbfde9c$export$ab5aad00225c5662 = /*#__PURE__*/ function(Operation) {
603
+ Operation["Eq"] = "=";
604
+ Operation["NotEq"] = "<>";
605
+ Operation["Gt"] = ">";
606
+ Operation["GtEq"] = ">=";
607
+ Operation["Lt"] = "<";
608
+ Operation["LtEq"] = "<=";
609
+ return Operation;
610
+ }({});
611
+ class $1ced42141bbfde9c$export$62297b13309008b2 {
612
+ static #_ = this.DEFAULT_LIMIT = 25;
613
+ get state() {
614
+ return {
615
+ tableName: this._tableName,
616
+ hashKey: this._hashKey,
617
+ rangeKey: this._rangeKey,
618
+ mode: this._mode,
619
+ selections: this._selections,
620
+ keys: this._keys,
621
+ filters: this._filters,
622
+ index: this._index,
623
+ scanForward: this._scanForward,
624
+ limit: this._limit,
625
+ count: this._count,
626
+ startAfter: this._startAfter,
627
+ consumedCapacity: this._consumedCapacity
628
+ };
629
+ }
630
+ constructor(table){
631
+ this._limit = $1ced42141bbfde9c$export$62297b13309008b2.DEFAULT_LIMIT;
632
+ this._count = false;
633
+ this._tableName = table.name;
634
+ this._hashKey = table.hashKey;
635
+ this._rangeKey = table.rangeKey;
636
+ // initialize here so that each query obj has its own filter list.
637
+ this._filters = [];
638
+ this._keys = [];
639
+ this._selections = [];
640
+ this._rawFilters = [];
641
+ }
642
+ select(cols) {
643
+ $1ced42141bbfde9c$var$throwIfModeExists(this._mode);
644
+ this._selections = cols;
645
+ this._mode = 'select';
646
+ return this;
647
+ }
648
+ scan(cols) {
649
+ $1ced42141bbfde9c$var$throwIfModeExists(this._mode);
650
+ this._selections = cols;
651
+ this._mode = 'scan';
652
+ return this;
653
+ }
654
+ count() {
655
+ $1ced42141bbfde9c$var$throwIfModeExists(this._mode);
656
+ this._count = true;
657
+ this._mode = 'count';
658
+ return this;
659
+ }
660
+ get where() {
661
+ (0, $6B8p2$assert)(this._mode !== 'scan', 'Query.where: Cannot use "where" clause with scan(), use "filter" instead.');
662
+ const pushRangeKey = (val, type)=>{
663
+ if ((0, $6B8p2$lodash).isNil(this._index)) {
664
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(this._rangeKey) && (0, $6B8p2$lodash).size(this._rangeKey) > 0, 'Query.where.range: Table does not have a rangeKey');
665
+ this._keys.push({
666
+ key: this._rangeKey,
667
+ val: val,
668
+ type: type
669
+ });
670
+ return;
671
+ }
672
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(this._index.rangeKey) && (0, $6B8p2$lodash).size(this._index.rangeKey) > 0, 'Query.where.range: Provided Index does not have a rangeKey');
673
+ this._keys.push({
674
+ key: this._index.rangeKey,
675
+ val: val,
676
+ type: type
677
+ });
678
+ };
679
+ const whereSelectors = {
680
+ hash: {
681
+ eq: (val)=>{
682
+ if ((0, $6B8p2$lodash).isNil(this._index)) {
683
+ this._keys.push({
684
+ key: this._hashKey,
685
+ val: val,
686
+ type: 'hash-eq'
687
+ });
688
+ return this;
689
+ }
690
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(this._index?.hashKey) && (0, $6B8p2$lodash).size(this._index.hashKey) > 0, 'Query.where.hash: Provided Index does not have a hashKey');
691
+ this._keys.push({
692
+ key: this._index.hashKey,
693
+ val: val,
694
+ type: 'hash-eq'
695
+ });
696
+ return this;
697
+ }
698
+ },
699
+ range: {
700
+ eq: (val)=>{
701
+ pushRangeKey(val, 'eq');
702
+ return this;
703
+ },
704
+ beginsWith: (val)=>{
705
+ pushRangeKey(val, 'begins_with');
706
+ return this;
707
+ },
708
+ gt: (val)=>{
709
+ pushRangeKey(val, 'gt');
710
+ return this;
711
+ },
712
+ gtEq: (val)=>{
713
+ pushRangeKey(val, 'gtEq');
714
+ return this;
715
+ },
716
+ lt: (val)=>{
717
+ pushRangeKey(val, 'lt');
718
+ return this;
719
+ },
720
+ ltEq: (val)=>{
721
+ pushRangeKey(val, 'ltEq');
722
+ return this;
723
+ },
724
+ between: (start, end)=>{
725
+ pushRangeKey({
726
+ start: start,
727
+ end: end
728
+ }, 'between');
729
+ return this;
730
+ }
731
+ }
732
+ };
733
+ return whereSelectors;
734
+ }
735
+ get filter() {
736
+ const filterConditions = {
737
+ eq: (key, val)=>{
738
+ this._filters.push({
739
+ key: key,
740
+ val: val,
741
+ type: 'eq'
742
+ });
743
+ return this;
744
+ },
745
+ notEq: (key, val)=>{
746
+ this._filters.push({
747
+ key: key,
748
+ val: val,
749
+ type: 'notEq'
750
+ });
751
+ return this;
752
+ },
753
+ gt: (key, val)=>{
754
+ this._filters.push({
755
+ key: key,
756
+ val: val,
757
+ type: 'gt'
758
+ });
759
+ return this;
760
+ },
761
+ gtEq: (key, val)=>{
762
+ this._filters.push({
763
+ key: key,
764
+ val: val,
765
+ type: 'gtEq'
766
+ });
767
+ return this;
768
+ },
769
+ lt: (key, val)=>{
770
+ this._filters.push({
771
+ key: key,
772
+ val: val,
773
+ type: 'lt'
774
+ });
775
+ return this;
776
+ },
777
+ ltEq: (key, val)=>{
778
+ this._filters.push({
779
+ key: key,
780
+ val: val,
781
+ type: 'ltEq'
782
+ });
783
+ return this;
784
+ },
785
+ beginsWith: (key, val)=>{
786
+ this._filters.push({
787
+ key: key,
788
+ val: val,
789
+ type: 'begins_with'
790
+ });
791
+ return this;
792
+ },
793
+ attributeExists: (key)=>{
794
+ this._filters.push({
795
+ key: key,
796
+ type: 'attribute_exists'
797
+ });
798
+ return this;
799
+ },
800
+ attributeNotExists: (key)=>{
801
+ this._filters.push({
802
+ key: key,
803
+ type: 'attribute_not_exists'
804
+ });
805
+ return this;
806
+ },
807
+ attributeType: (key, val)=>{
808
+ this._filters.push({
809
+ key: key,
810
+ val: val,
811
+ type: 'attribute_type'
812
+ });
813
+ return this;
814
+ },
815
+ contains: (key, val)=>{
816
+ this._filters.push({
817
+ key: key,
818
+ val: val,
819
+ type: 'contains'
820
+ });
821
+ return this;
822
+ },
823
+ size: (key, op, val)=>{
824
+ this._filters.push({
825
+ key: key,
826
+ val: {
827
+ val: val,
828
+ op: op
829
+ },
830
+ type: 'size'
831
+ });
832
+ return this;
833
+ },
834
+ between: (key, start, end)=>{
835
+ this._filters.push({
836
+ key: key,
837
+ val: {
838
+ start: start,
839
+ end: end
840
+ },
841
+ type: 'between'
842
+ });
843
+ return this;
844
+ },
845
+ raw: (filterCondition, replacements)=>{
846
+ this._rawFilters.push({
847
+ condition: filterCondition,
848
+ replacements: replacements
849
+ });
850
+ return this;
851
+ }
852
+ };
853
+ return filterConditions;
854
+ }
855
+ using(index, scanForward) {
856
+ (0, $6B8p2$assert)(typeof scanForward === 'boolean' || (0, $6B8p2$lodash).isNil(scanForward), 'Query.using(): scanForward must be a boolean or undefined');
857
+ this._index = index;
858
+ this._scanForward = scanForward;
859
+ return this;
860
+ }
861
+ limit(l) {
862
+ this._limit = l ?? $1ced42141bbfde9c$export$62297b13309008b2.DEFAULT_LIMIT;
863
+ return this;
864
+ }
865
+ startAfter(lastEvaluatedKey) {
866
+ this._startAfter = lastEvaluatedKey;
867
+ return this;
868
+ }
869
+ withConsumedCapacity(capacityType = 'TOTAL') {
870
+ (0, $6B8p2$assert)(capacityType === 'INDEXES' || capacityType === 'TOTAL' || capacityType === 'NONE', 'Query.withConsumedCapacity(): capacity type must be INDEXES, TOTAL, or NONE');
871
+ if (capacityType === 'NONE') return this;
872
+ this._consumedCapacity = capacityType;
873
+ return this;
874
+ }
875
+ toDynamo() {
876
+ const [keyCond, keyAttribVals, keyAttribNames] = $1ced42141bbfde9c$var$formatKeyCondition(this._keys);
877
+ const [filterCond, filterAttribVals, filterAttribNames] = $1ced42141bbfde9c$var$formatFilterCondition(this._filters, this._rawFilters);
878
+ const [projection, projectionAttribNames] = $1ced42141bbfde9c$var$formatProjectionExpression(this._selections);
879
+ return (0, $6B8p2$lodash).omitBy({
880
+ TableName: this._tableName,
881
+ Select: this._count ? 'COUNT' : undefined,
882
+ ...projection,
883
+ ...keyCond,
884
+ ...filterCond,
885
+ ...(0, $6B8p2$lodash).merge(keyAttribNames, filterAttribNames, projectionAttribNames),
886
+ ...(0, $6B8p2$lodash).merge(keyAttribVals, filterAttribVals),
887
+ Limit: this._limit,
888
+ IndexName: this._index?.name,
889
+ ScanIndexForward: this._scanForward,
890
+ ExclusiveStartKey: this._startAfter,
891
+ ReturnConsumedCapacity: this._consumedCapacity
892
+ }, (0, $6B8p2$lodash).isNil);
893
+ }
894
+ }
895
+ const $1ced42141bbfde9c$var$isReserved = (name)=>{
896
+ // Does the upper cased "name" exists in the reserved words list.
897
+ return (0, $6B8p2$lodash).indexOf((0, $8377f7c5fcf1cce8$export$e46d647da3214494), (0, $6B8p2$lodash).toUpper(name)) != -1;
898
+ };
899
+ const $1ced42141bbfde9c$var$replaceReservedNames = (conditions)=>{
900
+ return (0, $6B8p2$lodash).map(conditions, (cond)=>{
901
+ if ($1ced42141bbfde9c$var$isReserved(cond.key)) return {
902
+ ...cond,
903
+ key: `#${cond.key}`,
904
+ actualName: cond.key
905
+ };
906
+ if ((0, $6B8p2$lodash).startsWith(cond.key, "_")) return {
907
+ ...cond,
908
+ key: `#${cond.key}`,
909
+ actualName: cond.key
910
+ };
911
+ return cond;
912
+ });
913
+ };
914
+ const $1ced42141bbfde9c$var$formatKeyCondition = (conditions)=>{
915
+ const updatedConditions = $1ced42141bbfde9c$var$replaceReservedNames(conditions);
916
+ const conditionParts = [];
917
+ const attribVals = {};
918
+ const attribNames = {};
919
+ (0, $6B8p2$lodash).each(updatedConditions, (cond)=>{
920
+ const { key: key, val: val, type: type, actualName: actualName } = cond;
921
+ const valRef = `:${(0, $6B8p2$lodash).trim(key, '#')}`;
922
+ switch(type){
923
+ case "hash-eq":
924
+ case "eq":
925
+ conditionParts.push(`${key} = ${valRef}`);
926
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
927
+ break;
928
+ case "gt":
929
+ conditionParts.push(`${key} > ${valRef}`);
930
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
931
+ break;
932
+ case "gtEq":
933
+ conditionParts.push(`${key} >= ${valRef}`);
934
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
935
+ break;
936
+ case "lt":
937
+ conditionParts.push(`${key} < ${valRef}`);
938
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
939
+ break;
940
+ case "ltEq":
941
+ conditionParts.push(`${key} <= ${valRef}`);
942
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
943
+ break;
944
+ case "between":
945
+ {
946
+ const valRefStart = `${valRef}_start`;
947
+ const valRefEnd = `${valRef}_end`;
948
+ const between = val;
949
+ conditionParts.push(`${key} BETWEEN ${valRefStart} AND ${valRefEnd}`);
950
+ (0, $6B8p2$lodash).set(attribVals, valRefStart, between.start);
951
+ (0, $6B8p2$lodash).set(attribVals, valRefEnd, between.end);
952
+ break;
953
+ }
954
+ case "begins_with":
955
+ conditionParts.push(`begins_with(${key}, ${valRef})`);
956
+ (0, $6B8p2$lodash).set(attribVals, valRef, val);
957
+ break;
958
+ }
959
+ if (actualName) (0, $6B8p2$lodash).set(attribNames, key, actualName);
960
+ });
961
+ return [
962
+ {
963
+ KeyConditionExpression: (0, $6B8p2$lodash).isEmpty(conditionParts) ? undefined : (0, $6B8p2$lodash).join(conditionParts, " and ")
964
+ },
965
+ {
966
+ ExpressionAttributeValues: (0, $6B8p2$lodash).isEmpty(attribVals) ? undefined : attribVals
967
+ },
968
+ {
969
+ ExpressionAttributeNames: (0, $6B8p2$lodash).isEmpty(attribNames) ? undefined : attribNames
970
+ }
971
+ ];
972
+ };
973
+ const $1ced42141bbfde9c$var$formatFilterCondition = (filters, rawFilters)=>{
974
+ const updatedFilters = $1ced42141bbfde9c$var$replaceReservedNames(filters);
975
+ const filterParts = [];
976
+ const attribVals = {};
977
+ const attribNames = {};
978
+ const usedValRefs = new Set();
979
+ (0, $6B8p2$lodash).each(updatedFilters, (f)=>{
980
+ let valRef = `:${(0, $6B8p2$lodash).trim(f.key, '#')}`;
981
+ // Add numeric suffix if valRef is already used
982
+ if (usedValRefs.has(valRef)) {
983
+ let counter = 1;
984
+ while(usedValRefs.has(`${valRef}_${counter}`))counter++;
985
+ valRef = `${valRef}_${counter}`;
986
+ }
987
+ usedValRefs.add(valRef);
988
+ switch(f.type){
989
+ case 'eq':
990
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
991
+ filterParts.push(`${f.key} = ${valRef}`);
992
+ break;
993
+ case 'notEq':
994
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
995
+ filterParts.push(`${f.key} <> ${valRef}`);
996
+ break;
997
+ case 'gt':
998
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
999
+ filterParts.push(`${f.key} > ${valRef}`);
1000
+ break;
1001
+ case 'gtEq':
1002
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1003
+ filterParts.push(`${f.key} >= ${valRef}`);
1004
+ break;
1005
+ case 'lt':
1006
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1007
+ filterParts.push(`${f.key} < ${valRef}`);
1008
+ break;
1009
+ case 'ltEq':
1010
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1011
+ filterParts.push(`${f.key} <= ${valRef}`);
1012
+ break;
1013
+ case 'begins_with':
1014
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1015
+ filterParts.push(`begins_with(${f.key}, ${valRef})`);
1016
+ break;
1017
+ case 'attribute_exists':
1018
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1019
+ filterParts.push(`attribute_exists(${f.key})`);
1020
+ break;
1021
+ case 'attribute_not_exists':
1022
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1023
+ filterParts.push(`attribute_not_exists(${f.key})`);
1024
+ break;
1025
+ case 'attribute_type':
1026
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1027
+ filterParts.push(`attribute_type(${f.key}, ${valRef})`);
1028
+ break;
1029
+ case 'contains':
1030
+ (0, $6B8p2$lodash).set(attribVals, valRef, f.val);
1031
+ filterParts.push(`contains(${f.key}, ${valRef})`);
1032
+ break;
1033
+ case 'size':
1034
+ {
1035
+ const sizeVal = f.val;
1036
+ const newValRef = `:size_${(0, $6B8p2$lodash).trim(valRef, ':')}`;
1037
+ (0, $6B8p2$lodash).set(attribVals, newValRef, sizeVal.val);
1038
+ filterParts.push(`size(${f.key}) ${sizeVal.op} ${newValRef}`);
1039
+ break;
1040
+ }
1041
+ case 'between':
1042
+ {
1043
+ const valRefStart = `${valRef}_start`;
1044
+ const valRefEnd = `${valRef}_end`;
1045
+ const between = f.val;
1046
+ filterParts.push(`${f.key} BETWEEN ${valRefStart} AND ${valRefEnd}`);
1047
+ (0, $6B8p2$lodash).set(attribVals, valRefStart, between.start);
1048
+ (0, $6B8p2$lodash).set(attribVals, valRefEnd, between.end);
1049
+ break;
1050
+ }
1051
+ }
1052
+ if (f.actualName) (0, $6B8p2$lodash).set(attribNames, f.key, f.actualName);
1053
+ });
1054
+ let filterExp = (0, $6B8p2$lodash).join(filterParts, ' and ');
1055
+ if (rawFilters.length > 0) {
1056
+ const rawFilterCondition = (0, $6B8p2$lodash).chain(rawFilters).map((f)=>f ? `(${f.condition})` : undefined).compact().join(' and ').value();
1057
+ if ((0, $6B8p2$lodash).isEmpty(filterExp)) filterExp = rawFilterCondition;
1058
+ else filterExp = (0, $6B8p2$lodash).join([
1059
+ filterExp,
1060
+ rawFilterCondition
1061
+ ], ' and ');
1062
+ (0, $6B8p2$lodash).merge(attribVals, (0, $6B8p2$lodash).chain(rawFilters).map((f)=>f?.replacements.vals).compact().reduce((0, $6B8p2$lodash).merge, {}).value());
1063
+ (0, $6B8p2$lodash).merge(attribNames, (0, $6B8p2$lodash).chain(rawFilters).map((f)=>f?.replacements.keys).compact().reduce((0, $6B8p2$lodash).merge, {}).value());
1064
+ }
1065
+ return [
1066
+ {
1067
+ FilterExpression: (0, $6B8p2$lodash).isEmpty(filterExp) ? undefined : filterExp
1068
+ },
1069
+ {
1070
+ ExpressionAttributeValues: (0, $6B8p2$lodash).isEmpty(attribVals) ? undefined : attribVals
1071
+ },
1072
+ {
1073
+ ExpressionAttributeNames: (0, $6B8p2$lodash).isEmpty(attribNames) ? undefined : attribNames
1074
+ }
1075
+ ];
1076
+ };
1077
+ const $1ced42141bbfde9c$var$formatProjectionExpression = (proj)=>{
1078
+ const attribNames = {};
1079
+ const projection = (0, $6B8p2$lodash).map(proj, (col)=>{
1080
+ const attribRef = `#${(0, $6B8p2$lodash).trim(col)}`;
1081
+ if ($1ced42141bbfde9c$var$isReserved(col)) {
1082
+ (0, $6B8p2$lodash).set(attribNames, attribRef, col);
1083
+ return attribRef;
1084
+ }
1085
+ if ((0, $6B8p2$lodash).startsWith(col, "_")) {
1086
+ (0, $6B8p2$lodash).set(attribNames, attribRef, col);
1087
+ return attribRef;
1088
+ }
1089
+ return col;
1090
+ });
1091
+ return [
1092
+ {
1093
+ ProjectionExpression: (0, $6B8p2$lodash).isEmpty(projection) ? undefined : (0, $6B8p2$lodash).join(projection, ", ")
1094
+ },
1095
+ {
1096
+ ExpressionAttributeNames: (0, $6B8p2$lodash).isEmpty(attribNames) ? undefined : attribNames
1097
+ }
1098
+ ];
1099
+ };
1100
+ function $1ced42141bbfde9c$var$throwIfModeExists(mode) {
1101
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isEmpty(mode), 'Query: Cannot use more than one mode (select, count, scan) at the same time.');
1102
+ }
1103
+
1104
+
1105
+
1106
+
1107
+ class $bfdbbc60df8720b8$export$54ec01a60f47d33d {
1108
+ constructor(name, hashKey, rangeKey){
1109
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(name) && (0, $6B8p2$lodash).size(name) > 0, 'Table.constructor(): name must be provided');
1110
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(hashKey) && (0, $6B8p2$lodash).size(hashKey) > 0, 'Table.constructor(): hashKey must be provided');
1111
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isNil(rangeKey) || (0, $6B8p2$lodash).isString(rangeKey) && (0, $6B8p2$lodash).size(rangeKey) > 0, 'Table.constructor(): rangeKey is invalid');
1112
+ this._name = name;
1113
+ this._hashKey = hashKey;
1114
+ this._rangeKey = rangeKey;
1115
+ }
1116
+ get name() {
1117
+ return this._name;
1118
+ }
1119
+ get hashKey() {
1120
+ return this._hashKey;
1121
+ }
1122
+ get rangeKey() {
1123
+ return this._rangeKey;
1124
+ }
1125
+ }
1126
+ class $bfdbbc60df8720b8$export$cf17b003b6192af3 {
1127
+ constructor(name, hashKey, rangeKey){
1128
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(name) && (0, $6B8p2$lodash).size(name) > 0, 'Index.constructor(): name must be provided');
1129
+ (0, $6B8p2$assert)((0, $6B8p2$lodash).isString(hashKey) && (0, $6B8p2$lodash).size(hashKey) > 0, 'Index.constructor(): hashKey must be provided');
1130
+ this._name = name;
1131
+ this._hashKey = hashKey;
1132
+ this._rangeKey = rangeKey;
1133
+ }
1134
+ get name() {
1135
+ return this._name;
1136
+ }
1137
+ get hashKey() {
1138
+ return this._hashKey;
1139
+ }
1140
+ get rangeKey() {
1141
+ return this._rangeKey;
1142
+ }
1143
+ }
1144
+
1145
+
1146
+
1147
+
1148
+ export {$1ced42141bbfde9c$export$62297b13309008b2 as Query, $1ced42141bbfde9c$export$99a24bd46fd1f406 as DdbType, $1ced42141bbfde9c$export$ab5aad00225c5662 as Operation, $bfdbbc60df8720b8$export$cf17b003b6192af3 as Index, $bfdbbc60df8720b8$export$54ec01a60f47d33d as Table};
1149
+ //# sourceMappingURL=module.js.map