electrodb 3.6.1 → 3.6.2

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.
@@ -0,0 +1,4043 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _1 = require("./");
4
+ const tsd_1 = require("tsd");
5
+ require("./test/tests.test-d");
6
+ const magnify = (value) => {
7
+ return value;
8
+ };
9
+ let entityWithSK = new _1.Entity({
10
+ model: {
11
+ entity: "abc",
12
+ service: "myservice",
13
+ version: "myversion",
14
+ },
15
+ attributes: {
16
+ attr1: {
17
+ type: "string",
18
+ default: "abc",
19
+ get: (val) => val + 123,
20
+ set: (val) => (val ?? "") + 456,
21
+ validate: (val) => !!val,
22
+ },
23
+ attr2: {
24
+ type: "string",
25
+ // default: () => "sfg",
26
+ // required: false,
27
+ validate: (val) => val.length > 0,
28
+ },
29
+ attr3: {
30
+ type: ["123", "def", "ghi"],
31
+ default: "def",
32
+ },
33
+ attr4: {
34
+ type: ["abc", "ghi"],
35
+ required: true,
36
+ },
37
+ attr5: {
38
+ type: "string",
39
+ },
40
+ attr6: {
41
+ type: "number",
42
+ default: () => 100,
43
+ get: (val) => val + 5,
44
+ set: (val) => (val ?? 0) + 5,
45
+ validate: (val) => true,
46
+ },
47
+ attr7: {
48
+ type: "any",
49
+ default: () => false,
50
+ get: (val) => ({ key: "value" }),
51
+ set: (val) => (val ?? 0) + 5,
52
+ validate: (val) => true,
53
+ },
54
+ attr8: {
55
+ type: "boolean",
56
+ required: true,
57
+ get: (val) => !!val,
58
+ set: (val) => !!val,
59
+ validate: (val) => !!val,
60
+ },
61
+ attr9: {
62
+ type: "number",
63
+ },
64
+ attr10: {
65
+ type: "boolean",
66
+ },
67
+ },
68
+ indexes: {
69
+ myIndex: {
70
+ collection: "mycollection2",
71
+ pk: {
72
+ field: "pk",
73
+ composite: ["attr1"],
74
+ },
75
+ sk: {
76
+ field: "sk",
77
+ composite: ["attr2"],
78
+ },
79
+ },
80
+ myIndex2: {
81
+ collection: "mycollection1",
82
+ index: "gsi1",
83
+ pk: {
84
+ field: "gsipk1",
85
+ composite: ["attr6", "attr9"],
86
+ },
87
+ sk: {
88
+ field: "gsisk1",
89
+ composite: ["attr4", "attr5"],
90
+ },
91
+ },
92
+ myIndex3: {
93
+ collection: "mycollection",
94
+ index: "gsi2",
95
+ pk: {
96
+ field: "gsipk2",
97
+ composite: ["attr5"],
98
+ },
99
+ sk: {
100
+ field: "gsisk2",
101
+ composite: ["attr4", "attr3", "attr9"],
102
+ },
103
+ },
104
+ },
105
+ });
106
+ let entityWithoutSK = new _1.Entity({
107
+ model: {
108
+ entity: "abc",
109
+ service: "myservice",
110
+ version: "myversion",
111
+ },
112
+ attributes: {
113
+ attr1: {
114
+ type: "string",
115
+ // default: "abc",
116
+ get: (val) => val + 123,
117
+ set: (val) => (val ?? "0") + 456,
118
+ validate: (val) => !!val,
119
+ },
120
+ attr2: {
121
+ type: "string",
122
+ // default: () => "sfg",
123
+ // required: false,
124
+ validate: (val) => val.length > 0,
125
+ },
126
+ attr3: {
127
+ type: ["123", "def", "ghi"],
128
+ default: "def",
129
+ },
130
+ attr4: {
131
+ type: ["abc", "def"],
132
+ required: true,
133
+ },
134
+ attr5: {
135
+ type: "string",
136
+ },
137
+ attr6: {
138
+ type: "number",
139
+ default: () => 100,
140
+ get: (val) => val + 5,
141
+ set: (val) => (val ?? 0) + 5,
142
+ validate: (val) => true,
143
+ },
144
+ attr7: {
145
+ type: "any",
146
+ default: () => false,
147
+ get: (val) => ({ key: "value" }),
148
+ set: (val) => (val ?? 0) + 5,
149
+ validate: (val) => true,
150
+ },
151
+ attr8: {
152
+ type: "boolean",
153
+ required: true,
154
+ default: () => false,
155
+ get: (val) => !!val,
156
+ set: (val) => !!val,
157
+ validate: (val) => !!val,
158
+ },
159
+ attr9: {
160
+ type: "number",
161
+ },
162
+ },
163
+ indexes: {
164
+ myIndex: {
165
+ pk: {
166
+ field: "pk",
167
+ composite: ["attr1"],
168
+ },
169
+ },
170
+ myIndex2: {
171
+ index: "gsi1",
172
+ collection: "mycollection1",
173
+ pk: {
174
+ field: "gsipk1",
175
+ composite: ["attr6", "attr9"],
176
+ },
177
+ sk: {
178
+ field: "gsisk1",
179
+ composite: [],
180
+ },
181
+ },
182
+ myIndex3: {
183
+ collection: "mycollection",
184
+ index: "gsi2",
185
+ pk: {
186
+ field: "gsipk2",
187
+ composite: ["attr5"],
188
+ },
189
+ sk: {
190
+ field: "gsisk2",
191
+ composite: [],
192
+ },
193
+ },
194
+ },
195
+ });
196
+ let standAloneEntity = new _1.Entity({
197
+ model: {
198
+ entity: "standalone",
199
+ service: "myservice",
200
+ version: "1",
201
+ },
202
+ attributes: {
203
+ prop1: {
204
+ type: "string",
205
+ default: "abc",
206
+ },
207
+ prop2: {
208
+ type: "string",
209
+ },
210
+ prop3: {
211
+ type: "string",
212
+ },
213
+ },
214
+ indexes: {
215
+ index1: {
216
+ pk: {
217
+ field: "pk",
218
+ composite: ["prop1", "prop2"],
219
+ },
220
+ sk: {
221
+ field: "sk",
222
+ composite: ["prop3"],
223
+ },
224
+ },
225
+ },
226
+ });
227
+ let normalEntity1 = new _1.Entity({
228
+ model: {
229
+ entity: "normalEntity1",
230
+ service: "myservice",
231
+ version: "1",
232
+ },
233
+ attributes: {
234
+ prop1: {
235
+ type: "string",
236
+ default: "abc",
237
+ },
238
+ prop2: {
239
+ type: "string",
240
+ },
241
+ prop3: {
242
+ type: "string",
243
+ required: true,
244
+ },
245
+ prop4: {
246
+ type: "number",
247
+ },
248
+ prop10: {
249
+ type: "boolean",
250
+ },
251
+ },
252
+ indexes: {
253
+ tableIndex: {
254
+ collection: "normalcollection",
255
+ pk: {
256
+ field: "pk",
257
+ composite: ["prop1", "prop2"],
258
+ },
259
+ sk: {
260
+ field: "sk",
261
+ composite: ["prop4"],
262
+ },
263
+ },
264
+ },
265
+ });
266
+ let normalEntity2 = new _1.Entity({
267
+ model: {
268
+ entity: "normalEntity2",
269
+ service: "myservice",
270
+ version: "1",
271
+ },
272
+ attributes: {
273
+ prop1: {
274
+ type: "string",
275
+ },
276
+ prop2: {
277
+ type: "string",
278
+ },
279
+ prop3: {
280
+ type: "string",
281
+ required: true,
282
+ },
283
+ prop5: {
284
+ type: "number",
285
+ },
286
+ attr6: {
287
+ type: "number",
288
+ default: () => 100,
289
+ get: (val) => val + 5,
290
+ set: (val) => (val ?? 0) + 5,
291
+ validate: (val) => true,
292
+ },
293
+ attr9: {
294
+ type: "number",
295
+ },
296
+ },
297
+ indexes: {
298
+ indexTable: {
299
+ collection: "normalcollection",
300
+ pk: {
301
+ field: "pk",
302
+ composite: ["prop1", "prop2"],
303
+ },
304
+ sk: {
305
+ field: "sk",
306
+ composite: ["prop5"],
307
+ },
308
+ },
309
+ anotherIndex: {
310
+ index: "gsi1",
311
+ collection: "mycollection1",
312
+ pk: {
313
+ field: "gsipk1",
314
+ composite: ["attr6", "attr9"],
315
+ },
316
+ sk: {
317
+ field: "gsisk1",
318
+ composite: [],
319
+ },
320
+ },
321
+ },
322
+ });
323
+ const item = {
324
+ attr1: "attr1",
325
+ attr2: "attr2",
326
+ attr3: "def",
327
+ attr4: "abc",
328
+ attr5: "attr5",
329
+ attr6: 123,
330
+ attr7: "attr7",
331
+ attr8: true,
332
+ attr9: 456,
333
+ };
334
+ const AttributeName = "";
335
+ let getKeys = ((val) => { });
336
+ /** Schema With SK **/
337
+ // Get
338
+ // Single
339
+ entityWithSK.get({ attr1: "adg", attr2: "ada" });
340
+ entityWithoutSK.get({ attr1: "abc" });
341
+ (0, tsd_1.expectAssignable)([{ attr1: "abc", attr2: "abd" }]);
342
+ (0, tsd_1.expectAssignable)([{ attr1: "abc" }]);
343
+ // Invalid Get
344
+ (0, tsd_1.expectError)([{}]);
345
+ (0, tsd_1.expectError)([{ attr1: "sdggd" }]);
346
+ (0, tsd_1.expectError)([{ attr2: "sdggd" }]);
347
+ (0, tsd_1.expectError)({ attr1: 1324, attr2: "adsga" });
348
+ (0, tsd_1.expectError)([{}]);
349
+ (0, tsd_1.expectError)([{ attr2: "adsga" }]);
350
+ (0, tsd_1.expectError)({ attr2: "adsga" });
351
+ (0, tsd_1.expectError)({ attr1: 1324, attr2: "adsga" });
352
+ let getSingleFinishersWithSK = getKeys(entityWithSK.get({ attr1: "abc", attr2: "24" }));
353
+ let getBatchFinishersWithSK = getKeys(entityWithSK.get([{ attr1: "abc", attr2: "24" }]));
354
+ let getSingleFinishersWithoutSK = getKeys(entityWithoutSK.get({ attr1: "abc" }));
355
+ let getBatchFinishersWithoutSK = getKeys(entityWithoutSK.get([{ attr1: "abc" }]));
356
+ (0, tsd_1.expectAssignable)(getSingleFinishersWithSK);
357
+ (0, tsd_1.expectAssignable)(getBatchFinishersWithSK);
358
+ (0, tsd_1.expectAssignable)(getSingleFinishersWithoutSK);
359
+ (0, tsd_1.expectAssignable)(getBatchFinishersWithoutSK);
360
+ entityWithSK
361
+ .get([{ attr1: "adg", attr2: "ada" }])
362
+ .go({ concurrent: 24, preserveBatchOrder: true });
363
+ (0, tsd_1.expectError)(entityWithSK
364
+ .get([{ attr1: "adg", attr2: "ada" }])
365
+ .params({ concurrent: 24, preserveBatchOrder: true }));
366
+ entityWithoutSK
367
+ .get([{ attr1: "adg" }])
368
+ .go({ concurrent: 24, preserveBatchOrder: true });
369
+ (0, tsd_1.expectError)(entityWithoutSK
370
+ .get([{ attr1: "adg" }])
371
+ .params({ concurrent: 24, preserveBatchOrder: true }));
372
+ let getSingleGoWithSK = entityWithSK.get({ attr1: "adg", attr2: "ada" }).go;
373
+ let getSingleGoWithoutSK = entityWithoutSK.get({ attr1: "adg" }).go;
374
+ let getSingleParamsWithSK = entityWithSK.get({
375
+ attr1: "adg",
376
+ attr2: "ada",
377
+ }).params;
378
+ let getSingleParamsWithoutSK = entityWithoutSK.get({ attr1: "adg" }).params;
379
+ let getBatchGoWithSK = entityWithSK.get([{ attr1: "adg", attr2: "ada" }]).go;
380
+ let getBatchGoWithoutSK = entityWithoutSK.get([{ attr1: "adg" }]).go;
381
+ let getBatchParamsWithSK = entityWithSK.get([
382
+ { attr1: "adg", attr2: "ada" },
383
+ ]).params;
384
+ let getBatchParamsWithoutSK = entityWithoutSK.get([{ attr1: "adg" }]).params;
385
+ (0, tsd_1.expectAssignable)({
386
+ originalErr: true,
387
+ params: {},
388
+ table: "abc",
389
+ });
390
+ (0, tsd_1.expectAssignable)({
391
+ originalErr: true,
392
+ params: {},
393
+ table: "abc",
394
+ });
395
+ (0, tsd_1.expectAssignable)({
396
+ originalErr: true,
397
+ params: {},
398
+ table: "abc",
399
+ });
400
+ (0, tsd_1.expectAssignable)({
401
+ originalErr: true,
402
+ params: {},
403
+ table: "abc",
404
+ });
405
+ (0, tsd_1.expectError)({
406
+ concurrent: 10,
407
+ unprocessed: "raw",
408
+ preserveBatchOrder: true,
409
+ });
410
+ (0, tsd_1.expectError)({
411
+ concurrent: 10,
412
+ unprocessed: "raw",
413
+ preserveBatchOrder: true,
414
+ });
415
+ (0, tsd_1.expectError)({
416
+ concurrent: 10,
417
+ unprocessed: "raw",
418
+ preserveBatchOrder: true,
419
+ });
420
+ (0, tsd_1.expectError)({
421
+ concurrent: 10,
422
+ unprocessed: "raw",
423
+ preserveBatchOrder: true,
424
+ });
425
+ (0, tsd_1.expectAssignable)({
426
+ data: 'includeKeys',
427
+ originalErr: true,
428
+ params: {},
429
+ table: "abc",
430
+ concurrent: 10,
431
+ unprocessed: "raw",
432
+ });
433
+ (0, tsd_1.expectAssignable)({
434
+ data: 'includeKeys',
435
+ originalErr: true,
436
+ params: {},
437
+ table: "abc",
438
+ concurrent: 10,
439
+ unprocessed: "raw",
440
+ });
441
+ (0, tsd_1.expectAssignable)({
442
+ originalErr: true,
443
+ params: {},
444
+ table: "abc",
445
+ attributes: ["attr1"],
446
+ });
447
+ (0, tsd_1.expectAssignable)({
448
+ originalErr: true,
449
+ params: {},
450
+ table: "abc",
451
+ attributes: ["attr1"],
452
+ });
453
+ (0, tsd_1.expectNotAssignable)({
454
+ data: 'includeKeys',
455
+ originalErr: true,
456
+ params: {},
457
+ table: "abc",
458
+ concurrent: 10,
459
+ unprocessed: "raw",
460
+ attributes: ["attrz1"],
461
+ });
462
+ (0, tsd_1.expectNotAssignable)({
463
+ data: 'includeKeys',
464
+ originalErr: true,
465
+ params: {},
466
+ table: "abc",
467
+ concurrent: 10,
468
+ unprocessed: "raw",
469
+ attributes: ["attrz1"],
470
+ });
471
+ (0, tsd_1.expectNotAssignable)({ attributes: ["attrz1"] });
472
+ (0, tsd_1.expectNotAssignable)({ attributes: ["attrz1"] });
473
+ (0, tsd_1.expectAssignable)(entityWithSK
474
+ .get({ attr1: "abc", attr2: "def" })
475
+ .go()
476
+ .then((res) => res.data));
477
+ (0, tsd_1.expectAssignable)(entityWithoutSK
478
+ .get({ attr1: "abc" })
479
+ .go()
480
+ .then((res) => res.data));
481
+ (0, tsd_1.expectAssignable)(entityWithSK.get({ attr1: "abc", attr2: "def" }).params());
482
+ (0, tsd_1.expectAssignable)(entityWithoutSK.get({ attr1: "abc" }).params());
483
+ (0, tsd_1.expectAssignable)(entityWithSK.scan
484
+ .go({ attributes: ["attr1", "attr2"] })
485
+ .then((res) => res.data));
486
+ (0, tsd_1.expectAssignable)(entityWithSK
487
+ .find({ attr10: true })
488
+ .go({ attributes: ["attr1", "attr7", "attr6"] })
489
+ .then((res) => res.data));
490
+ (0, tsd_1.expectAssignable)(entityWithSK
491
+ .match({ attr3: "def" })
492
+ .go({ attributes: ["attr4", "attr5"] })
493
+ .then((res) => res.data));
494
+ entityWithSK
495
+ .get([{ attr1: "abc", attr2: "def" }])
496
+ .go()
497
+ .then((res) => {
498
+ const [item] = res.data;
499
+ const [unprocessed] = res.unprocessed;
500
+ (0, tsd_1.expectType)(item);
501
+ (0, tsd_1.expectType)(magnify(unprocessed));
502
+ });
503
+ entityWithSK
504
+ .get([{ attr1: "abc", attr2: "def" }])
505
+ .go({ preserveBatchOrder: true })
506
+ .then((res) => {
507
+ const item = magnify(res.data[0]);
508
+ const unprocessed = res.unprocessed[0];
509
+ (0, tsd_1.expectType)(item);
510
+ (0, tsd_1.expectType)(magnify(unprocessed));
511
+ });
512
+ entityWithSK
513
+ .get([{ attr1: "abc", attr2: "def" }])
514
+ .go()
515
+ .then((res) => {
516
+ (0, tsd_1.expectType)(magnify(res.data));
517
+ (0, tsd_1.expectType)(magnify(res.unprocessed));
518
+ });
519
+ entityWithSK
520
+ .get([{ attr1: "abc", attr2: "def" }])
521
+ .go()
522
+ .then(({ data, unprocessed }) => {
523
+ (0, tsd_1.expectAssignable)(data);
524
+ (0, tsd_1.expectAssignable)(unprocessed);
525
+ });
526
+ entityWithoutSK
527
+ .get([{ attr1: "abc" }])
528
+ .go()
529
+ .then((res) => {
530
+ const [item] = res.data;
531
+ const [unprocessed] = res.unprocessed;
532
+ (0, tsd_1.expectType)(item);
533
+ (0, tsd_1.expectType)(magnify(unprocessed));
534
+ });
535
+ entityWithoutSK
536
+ .get([{ attr1: "abc" }])
537
+ .go({ preserveBatchOrder: true })
538
+ .then((res) => {
539
+ const item = res.data[0];
540
+ const unprocessed = res.unprocessed[0];
541
+ (0, tsd_1.expectType)(item);
542
+ (0, tsd_1.expectType)(magnify(unprocessed));
543
+ });
544
+ entityWithoutSK
545
+ .get([{ attr1: "abc" }])
546
+ .go()
547
+ .then((res) => {
548
+ (0, tsd_1.expectAssignable)(res.data);
549
+ (0, tsd_1.expectAssignable)(res.unprocessed);
550
+ });
551
+ // Delete
552
+ // Single
553
+ entityWithSK.delete({ attr1: "adg", attr2: "ada" });
554
+ entityWithoutSK.delete({ attr1: "adg" });
555
+ (0, tsd_1.expectError)(entityWithSK.delete({}));
556
+ (0, tsd_1.expectError)(entityWithSK.delete({ attr2: "abc" }));
557
+ (0, tsd_1.expectError)(entityWithoutSK.delete({}));
558
+ (0, tsd_1.expectError)(entityWithoutSK.delete({ attr1: "13", attr2: "abc" }));
559
+ (0, tsd_1.expectAssignable)([{ attr1: "abc", attr2: "abd" }]);
560
+ (0, tsd_1.expectAssignable)([{ attr1: "abc" }]);
561
+ // Invalid Query
562
+ (0, tsd_1.expectError)({ attr1: "sdggd" });
563
+ (0, tsd_1.expectError)([{}]);
564
+ (0, tsd_1.expectError)({ attr1: 1324, attr2: "adsga" });
565
+ (0, tsd_1.expectError)({ attr1: 1324, attr2: "adsga" });
566
+ let deleteSingleFinishers = getKeys(entityWithSK.delete({ attr1: "abc", attr2: "24" }));
567
+ let deleteSingleFinishersWithoutSK = getKeys(entityWithoutSK.delete({ attr1: "abc" }));
568
+ let deleteBatchFinishers = getKeys(entityWithSK.delete([{ attr1: "abc", attr2: "24" }]));
569
+ let deleteBatchFinishersWithoutSK = getKeys(entityWithoutSK.delete([{ attr1: "abc" }]));
570
+ (0, tsd_1.expectAssignable)(deleteSingleFinishers);
571
+ (0, tsd_1.expectAssignable)(deleteSingleFinishersWithoutSK);
572
+ (0, tsd_1.expectAssignable)(deleteBatchFinishers);
573
+ (0, tsd_1.expectAssignable)(deleteBatchFinishersWithoutSK);
574
+ entityWithSK.delete([{ attr1: "adg", attr2: "ada" }]).go({ concurrent: 24 });
575
+ entityWithoutSK.delete([{ attr1: "adg" }]).go({ concurrent: 24 });
576
+ entityWithSK
577
+ .delete([{ attr1: "adg", attr2: "ada" }])
578
+ .params({ concurrent: 24 });
579
+ entityWithoutSK.delete([{ attr1: "adg" }]).params({ concurrent: 24 });
580
+ let deleteSingleGo = entityWithSK.delete({ attr1: "adg", attr2: "ada" }).go;
581
+ let deleteSingleGoWithoutSK = entityWithoutSK.delete({ attr1: "adg" }).go;
582
+ let deleteSingleParams = entityWithSK.delete({
583
+ attr1: "adg",
584
+ attr2: "ada",
585
+ }).params;
586
+ let deleteSingleParamsWithoutSK = entityWithoutSK.delete({
587
+ attr1: "adg",
588
+ }).params;
589
+ let deleteBatchGo = entityWithSK.delete([{ attr1: "adg", attr2: "ada" }]).go;
590
+ let deleteBatchGoWithoutSK = entityWithoutSK.delete([{ attr1: "adg" }]).go;
591
+ let deleteBatchParams = entityWithSK.delete([
592
+ { attr1: "adg", attr2: "ada" },
593
+ ]).params;
594
+ let deleteBatchParamsWithoutSK = entityWithoutSK.delete([
595
+ { attr1: "adg" },
596
+ ]).params;
597
+ (0, tsd_1.expectAssignable)({
598
+ data: 'includeKeys',
599
+ originalErr: true,
600
+ params: {},
601
+ table: "abc",
602
+ response: "all_old",
603
+ });
604
+ (0, tsd_1.expectAssignable)({
605
+ data: 'includeKeys',
606
+ originalErr: true,
607
+ params: {},
608
+ table: "abc",
609
+ response: "all_old",
610
+ });
611
+ (0, tsd_1.expectAssignable)({
612
+ data: 'includeKeys',
613
+ originalErr: true,
614
+ params: {},
615
+ table: "abc",
616
+ });
617
+ (0, tsd_1.expectAssignable)({
618
+ data: 'includeKeys',
619
+ originalErr: true,
620
+ params: {},
621
+ table: "abc",
622
+ });
623
+ (0, tsd_1.expectAssignable)({
624
+ data: 'includeKeys',
625
+ originalErr: true,
626
+ params: {},
627
+ table: "abc",
628
+ response: "all_old",
629
+ });
630
+ (0, tsd_1.expectAssignable)({
631
+ data: 'includeKeys',
632
+ originalErr: true,
633
+ params: {},
634
+ table: "abc",
635
+ response: "all_old",
636
+ });
637
+ (0, tsd_1.expectAssignable)({
638
+ data: 'includeKeys',
639
+ originalErr: true,
640
+ params: {},
641
+ table: "abc",
642
+ });
643
+ (0, tsd_1.expectAssignable)({
644
+ data: 'includeKeys',
645
+ originalErr: true,
646
+ params: {},
647
+ table: "abc",
648
+ });
649
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
650
+ (0, tsd_1.expectError)({
651
+ concurrent: 10,
652
+ unprocessed: "raw",
653
+ });
654
+ (0, tsd_1.expectNotAssignable)({ response: "updated_new" });
655
+ (0, tsd_1.expectNotAssignable)({ response: "updated_new" });
656
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
657
+ (0, tsd_1.expectError)({
658
+ concurrent: 10,
659
+ unprocessed: "raw",
660
+ });
661
+ (0, tsd_1.expectNotAssignable)({ response: "updated_new" });
662
+ (0, tsd_1.expectNotAssignable)({
663
+ response: "updated_new",
664
+ });
665
+ (0, tsd_1.expectAssignable)({
666
+ data: 'includeKeys',
667
+ originalErr: true,
668
+ params: {},
669
+ table: "abc",
670
+ concurrent: 10,
671
+ unprocessed: "raw",
672
+ });
673
+ (0, tsd_1.expectAssignable)({
674
+ data: 'includeKeys',
675
+ originalErr: true,
676
+ params: {},
677
+ table: "abc",
678
+ concurrent: 10,
679
+ unprocessed: "raw",
680
+ });
681
+ (0, tsd_1.expectAssignable)({
682
+ data: 'includeKeys',
683
+ originalErr: true,
684
+ params: {},
685
+ table: "abc",
686
+ concurrent: 10,
687
+ unprocessed: "raw",
688
+ });
689
+ (0, tsd_1.expectAssignable)({
690
+ data: 'includeKeys',
691
+ originalErr: true,
692
+ params: {},
693
+ table: "abc",
694
+ concurrent: 10,
695
+ unprocessed: "raw",
696
+ });
697
+ // Where
698
+ entityWithSK.delete({ attr1: "asbc", attr2: "gdd" }).where((attr, op) => {
699
+ let opKeys = getKeys(op);
700
+ (0, tsd_1.expectAssignable)(AttributeName);
701
+ (0, tsd_1.expectAssignable)(opKeys);
702
+ return "";
703
+ });
704
+ entityWithoutSK.delete({ attr1: "asbc" }).where((attr, op) => {
705
+ let opKeys = getKeys(op);
706
+ (0, tsd_1.expectAssignable)(AttributeName);
707
+ (0, tsd_1.expectAssignable)(opKeys);
708
+ return "";
709
+ });
710
+ // Results
711
+ (0, tsd_1.expectAssignable)(entityWithSK
712
+ .delete({ attr1: "abc", attr2: "def" })
713
+ .go({ response: "all_old" })
714
+ .then((res) => res.data));
715
+ (0, tsd_1.expectAssignable)(entityWithSK
716
+ .delete({ attr1: "abc", attr2: "def" })
717
+ .go({ response: "default" })
718
+ .then((res) => res.data));
719
+ (0, tsd_1.expectAssignable)(entityWithSK
720
+ .delete({ attr1: "abc", attr2: "def" })
721
+ .go()
722
+ .then((res) => res.data));
723
+ (0, tsd_1.expectAssignable)(entityWithSK
724
+ .delete({ attr1: "abc", attr2: "def" })
725
+ .go({ response: "none" })
726
+ .then((res) => res.data));
727
+ (0, tsd_1.expectAssignable)(entityWithoutSK
728
+ .delete({ attr1: "abc" })
729
+ .go({ response: "all_old" })
730
+ .then((res) => res.data));
731
+ (0, tsd_1.expectAssignable)(entityWithoutSK
732
+ .delete({ attr1: "abc" })
733
+ .go({ response: "none" })
734
+ .then((res) => res.data));
735
+ (0, tsd_1.expectAssignable)(entityWithoutSK
736
+ .delete({ attr1: "abc" })
737
+ .go({ response: "default" })
738
+ .then((res) => res.data));
739
+ (0, tsd_1.expectAssignable)(entityWithoutSK
740
+ .delete({ attr1: "abc" })
741
+ .go()
742
+ .then((res) => res.data));
743
+ (0, tsd_1.expectAssignable)(entityWithSK.delete({ attr1: "abc", attr2: "def" }).params());
744
+ (0, tsd_1.expectAssignable)(entityWithoutSK.delete({ attr1: "abc" }).params());
745
+ (0, tsd_1.expectAssignable)(entityWithoutSK
746
+ .delete([{ attr1: "abc" }])
747
+ .go()
748
+ .then((res) => res.unprocessed));
749
+ // Put
750
+ let putItemFull = {
751
+ attr1: "abnc",
752
+ attr2: "dsg",
753
+ attr3: "def",
754
+ attr4: "abc",
755
+ attr5: "dbs",
756
+ attr6: 13,
757
+ attr7: { abc: "2345" },
758
+ attr8: true,
759
+ attr9: 24,
760
+ attr10: true,
761
+ };
762
+ let putItemPartial = {
763
+ attr1: "abnc",
764
+ attr2: "dsg",
765
+ attr4: "abc",
766
+ attr8: true,
767
+ };
768
+ let putItemWithoutSK = {
769
+ attr1: "abnc",
770
+ attr4: "abc",
771
+ attr8: true,
772
+ attr3: "def",
773
+ attr5: "dbs",
774
+ attr6: 13,
775
+ attr9: 24,
776
+ attr7: { abc: "2345" },
777
+ };
778
+ let putItemWithoutPK = {
779
+ attr4: "abc",
780
+ attr2: "def",
781
+ attr8: true,
782
+ attr3: "def",
783
+ attr5: "dbs",
784
+ attr6: 13,
785
+ attr9: 24,
786
+ attr7: { abc: "2345" },
787
+ };
788
+ // Single
789
+ entityWithSK.put(putItemFull);
790
+ entityWithoutSK.put({
791
+ attr1: "abnc",
792
+ attr2: "dsg",
793
+ attr3: "def",
794
+ attr4: "def",
795
+ attr5: "dbs",
796
+ attr6: 13,
797
+ attr7: { abc: "2345" },
798
+ attr8: true,
799
+ attr9: 24,
800
+ });
801
+ entityWithSK.put({
802
+ attr1: "abnc",
803
+ attr2: "dsg",
804
+ attr3: "def",
805
+ attr4: "abc",
806
+ attr5: "dbs",
807
+ attr6: 13,
808
+ attr7: { abc: "2345" },
809
+ attr8: true,
810
+ attr9: undefined,
811
+ attr10: undefined,
812
+ });
813
+ entityWithoutSK.put(putItemPartial);
814
+ (0, tsd_1.expectAssignable)([putItemFull]);
815
+ (0, tsd_1.expectAssignable)([putItemFull]);
816
+ (0, tsd_1.expectAssignable)([putItemPartial]);
817
+ (0, tsd_1.expectAssignable)([putItemPartial]);
818
+ // Invalid Query
819
+ (0, tsd_1.expectError)([{}]);
820
+ (0, tsd_1.expectError)([{}]);
821
+ (0, tsd_1.expectError)([putItemWithoutSK]);
822
+ (0, tsd_1.expectError)(putItemWithoutSK);
823
+ (0, tsd_1.expectError)(putItemWithoutPK);
824
+ (0, tsd_1.expectError)(putItemWithoutPK);
825
+ // Assignable because attr1 has a default
826
+ (0, tsd_1.expectAssignable)([putItemWithoutPK]);
827
+ (0, tsd_1.expectError)([putItemWithoutPK]);
828
+ (0, tsd_1.expectError)([
829
+ { attr1: "abnc", attr2: "dsg", attr4: "abc", attr8: "adef" },
830
+ ]);
831
+ (0, tsd_1.expectError)([
832
+ { attr1: "abnc", attr2: "dsg", attr4: "abc", attr8: "adef" },
833
+ ]);
834
+ let putSingleFinishers = getKeys(entityWithSK.put(putItemFull));
835
+ let putSingleFinishersWithoutSK = getKeys(entityWithoutSK.put(putItemFull));
836
+ let putBatchFinishers = getKeys(entityWithSK.put(putItemFull));
837
+ let putBatchFinishersWithoutSK = getKeys(entityWithoutSK.put(putItemFull));
838
+ let putSingleItem = entityWithSK.put(putItemFull);
839
+ let putSingleItemWithoutSK = entityWithoutSK.put(putItemFull);
840
+ let putBulkItem = entityWithSK.put([putItemFull]);
841
+ let putBulkItemWithoutSK = entityWithoutSK.put([putItemFull]);
842
+ (0, tsd_1.expectAssignable)(putSingleFinishers);
843
+ (0, tsd_1.expectAssignable)(putSingleFinishersWithoutSK);
844
+ (0, tsd_1.expectAssignable)(putBatchFinishers);
845
+ (0, tsd_1.expectAssignable)(putBatchFinishersWithoutSK);
846
+ (0, tsd_1.expectAssignable)({
847
+ data: 'includeKeys',
848
+ originalErr: true,
849
+ params: {},
850
+ table: "abc",
851
+ response: "all_old",
852
+ });
853
+ (0, tsd_1.expectAssignable)({
854
+ data: 'includeKeys',
855
+ originalErr: true,
856
+ params: {},
857
+ table: "abc",
858
+ response: "all_old",
859
+ });
860
+ (0, tsd_1.expectAssignable)({
861
+ data: 'includeKeys',
862
+ originalErr: true,
863
+ params: {},
864
+ table: "abc",
865
+ response: "all_old",
866
+ });
867
+ (0, tsd_1.expectAssignable)({
868
+ data: 'includeKeys',
869
+ originalErr: true,
870
+ params: {},
871
+ table: "abc",
872
+ response: "all_old",
873
+ });
874
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
875
+ (0, tsd_1.expectError)({
876
+ concurrent: 10,
877
+ unprocessed: "raw",
878
+ });
879
+ (0, tsd_1.expectError)({ response: "updated_new" });
880
+ (0, tsd_1.expectError)({ response: "updated_new" });
881
+ (0, tsd_1.expectError)({ response: "updated_new" });
882
+ (0, tsd_1.expectError)({ response: "updated_new" });
883
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
884
+ (0, tsd_1.expectError)({
885
+ concurrent: 10,
886
+ unprocessed: "raw",
887
+ });
888
+ (0, tsd_1.expectAssignable)({
889
+ data: 'includeKeys',
890
+ originalErr: true,
891
+ params: {},
892
+ table: "abc",
893
+ concurrent: 10,
894
+ unprocessed: "raw",
895
+ });
896
+ (0, tsd_1.expectAssignable)({
897
+ data: 'includeKeys',
898
+ originalErr: true,
899
+ params: {},
900
+ table: "abc",
901
+ concurrent: 10,
902
+ unprocessed: "raw",
903
+ });
904
+ (0, tsd_1.expectNotAssignable)({
905
+ data: 'includeKeys',
906
+ originalErr: true,
907
+ params: {},
908
+ table: "abc",
909
+ concurrent: 10,
910
+ unprocessed: "raw",
911
+ response: "all_old",
912
+ });
913
+ (0, tsd_1.expectNotAssignable)({
914
+ data: 'includeKeys',
915
+ originalErr: true,
916
+ params: {},
917
+ table: "abc",
918
+ concurrent: 10,
919
+ unprocessed: "raw",
920
+ response: "all_old",
921
+ });
922
+ (0, tsd_1.expectAssignable)({
923
+ data: 'includeKeys',
924
+ originalErr: true,
925
+ params: {},
926
+ table: "abc",
927
+ concurrent: 10,
928
+ unprocessed: "raw",
929
+ });
930
+ (0, tsd_1.expectAssignable)({
931
+ data: 'includeKeys',
932
+ originalErr: true,
933
+ params: {},
934
+ table: "abc",
935
+ concurrent: 10,
936
+ unprocessed: "raw",
937
+ });
938
+ (0, tsd_1.expectNotAssignable)({
939
+ data: 'includeKeys',
940
+ originalErr: true,
941
+ params: {},
942
+ table: "abc",
943
+ concurrent: 10,
944
+ unprocessed: "raw",
945
+ response: "all_old",
946
+ });
947
+ (0, tsd_1.expectNotAssignable)({
948
+ data: 'includeKeys',
949
+ originalErr: true,
950
+ params: {},
951
+ table: "abc",
952
+ concurrent: 10,
953
+ unprocessed: "raw",
954
+ response: "all_old",
955
+ });
956
+ // Where
957
+ entityWithSK.put(putItemFull).where((attr, op) => {
958
+ let opKeys = getKeys(op);
959
+ (0, tsd_1.expectAssignable)(AttributeName);
960
+ (0, tsd_1.expectAssignable)(opKeys);
961
+ return "";
962
+ });
963
+ entityWithoutSK.put(putItemFull).where((attr, op) => {
964
+ let opKeys = getKeys(op);
965
+ (0, tsd_1.expectAssignable)(AttributeName);
966
+ (0, tsd_1.expectAssignable)(opKeys);
967
+ return "";
968
+ });
969
+ // Results
970
+ (0, tsd_1.expectAssignable)(entityWithSK
971
+ .put(putItemFull)
972
+ .go()
973
+ .then((res) => res.data));
974
+ (0, tsd_1.expectAssignable)(entityWithoutSK
975
+ .put(putItemFull)
976
+ .go()
977
+ .then((res) => res.data));
978
+ (0, tsd_1.expectAssignable)(entityWithSK.put(putItemFull).params());
979
+ (0, tsd_1.expectAssignable)(entityWithoutSK.put(putItemFull).params());
980
+ (0, tsd_1.expectAssignable)(entityWithSK
981
+ .put([putItemFull])
982
+ .go()
983
+ .then((res) => res.unprocessed));
984
+ (0, tsd_1.expectAssignable)(entityWithoutSK
985
+ .put([putItemFull])
986
+ .go()
987
+ .then((res) => res.unprocessed));
988
+ // Create
989
+ let createItemFull = {
990
+ attr1: "abnc",
991
+ attr2: "dsg",
992
+ attr4: "abc",
993
+ attr8: true,
994
+ attr3: "def",
995
+ attr5: "dbs",
996
+ attr6: 13,
997
+ attr9: 24,
998
+ attr7: { abc: "2345" },
999
+ };
1000
+ let createItemPartial = {
1001
+ attr1: "abnc",
1002
+ attr2: "dsg",
1003
+ attr4: "abc",
1004
+ attr8: true,
1005
+ };
1006
+ let createItemFullWithoutSK = {
1007
+ attr4: "abc",
1008
+ attr8: true,
1009
+ attr3: "def",
1010
+ attr5: "dbs",
1011
+ attr6: 13,
1012
+ attr9: 24,
1013
+ attr7: { abc: "2345" },
1014
+ };
1015
+ let createItemFullWithoutPK = {
1016
+ attr2: "dsg",
1017
+ attr4: "abc",
1018
+ attr8: true,
1019
+ attr3: "def",
1020
+ attr5: "dbs",
1021
+ attr6: 13,
1022
+ attr9: 24,
1023
+ attr7: { abc: "2345" },
1024
+ };
1025
+ // Single
1026
+ entityWithSK.create(createItemFull);
1027
+ entityWithSK.create(createItemFullWithoutPK);
1028
+ entityWithoutSK.create(createItemFull);
1029
+ entityWithSK.create(createItemPartial);
1030
+ entityWithoutSK.create(createItemPartial);
1031
+ // batch not supported with create
1032
+ (0, tsd_1.expectError)([createItemFull]);
1033
+ (0, tsd_1.expectError)([createItemFull]);
1034
+ // batch not supported with create
1035
+ (0, tsd_1.expectError)([createItemPartial]);
1036
+ (0, tsd_1.expectError)([createItemPartial]);
1037
+ // Invalid Query
1038
+ (0, tsd_1.expectError)({});
1039
+ (0, tsd_1.expectError)({});
1040
+ (0, tsd_1.expectError)(createItemFullWithoutSK);
1041
+ // Assignable because attr1 has a default value
1042
+ (0, tsd_1.expectAssignable)(createItemFullWithoutPK);
1043
+ (0, tsd_1.expectError)(createItemFullWithoutPK);
1044
+ // Missing required properties
1045
+ (0, tsd_1.expectError)([
1046
+ { attr1: "abnc", attr2: "dsg", attr4: "abc", attr8: "adef" },
1047
+ ]);
1048
+ (0, tsd_1.expectError)([
1049
+ { attr1: "abnc", attr2: "dsg", attr4: "abc", attr8: "adef" },
1050
+ ]);
1051
+ let createSingleFinishers = getKeys(entityWithSK.create(putItemFull));
1052
+ let createSingleFinishersWithoutSK = getKeys(entityWithoutSK.create(putItemFull));
1053
+ let createItem = entityWithSK.put(createItemFull);
1054
+ let createItemWithoutSK = entityWithoutSK.put(createItemFull);
1055
+ (0, tsd_1.expectAssignable)(createSingleFinishers);
1056
+ (0, tsd_1.expectAssignable)(createSingleFinishersWithoutSK);
1057
+ (0, tsd_1.expectAssignable)({
1058
+ data: 'includeKeys',
1059
+ originalErr: true,
1060
+ params: {},
1061
+ table: "abc",
1062
+ });
1063
+ (0, tsd_1.expectAssignable)({
1064
+ data: 'includeKeys',
1065
+ originalErr: true,
1066
+ params: {},
1067
+ table: "abc",
1068
+ });
1069
+ (0, tsd_1.expectAssignable)({
1070
+ data: 'includeKeys',
1071
+ originalErr: true,
1072
+ params: {},
1073
+ table: "abc",
1074
+ });
1075
+ (0, tsd_1.expectAssignable)({
1076
+ data: 'includeKeys',
1077
+ originalErr: true,
1078
+ params: {},
1079
+ table: "abc",
1080
+ });
1081
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
1082
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
1083
+ (0, tsd_1.expectError)({ concurrent: 10, unprocessed: "raw" });
1084
+ (0, tsd_1.expectError)({
1085
+ concurrent: 10,
1086
+ unprocessed: "raw",
1087
+ });
1088
+ // Where
1089
+ entityWithSK.create(putItemFull).where((attr, op) => {
1090
+ let opKeys = getKeys(op);
1091
+ (0, tsd_1.expectAssignable)(AttributeName);
1092
+ (0, tsd_1.expectAssignable)(opKeys);
1093
+ return "";
1094
+ });
1095
+ entityWithoutSK.create(putItemFull).where((attr, op) => {
1096
+ let opKeys = getKeys(op);
1097
+ (0, tsd_1.expectAssignable)(AttributeName);
1098
+ (0, tsd_1.expectAssignable)(opKeys);
1099
+ return "";
1100
+ });
1101
+ // Results
1102
+ (0, tsd_1.expectAssignable)(entityWithSK
1103
+ .create(putItemFull)
1104
+ .go()
1105
+ .then((res) => res.data));
1106
+ (0, tsd_1.expectAssignable)(entityWithoutSK
1107
+ .create(putItemFull)
1108
+ .go()
1109
+ .then((res) => res.data));
1110
+ (0, tsd_1.expectAssignable)(entityWithSK.create(putItemFull).params());
1111
+ (0, tsd_1.expectAssignable)(entityWithoutSK.create(putItemFull).params());
1112
+ // Update
1113
+ let setItemFull = {
1114
+ attr4: "abc",
1115
+ attr8: true,
1116
+ attr3: "def",
1117
+ attr5: "dbs",
1118
+ attr6: 13,
1119
+ attr9: 24,
1120
+ attr7: { abc: "2345" },
1121
+ };
1122
+ let setFn = entityWithSK.update({ attr1: "abc", attr2: "def" }).set;
1123
+ let setFnWithoutSK = entityWithoutSK.update({ attr1: "abc" }).set;
1124
+ (0, tsd_1.expectAssignable)(setItemFull);
1125
+ (0, tsd_1.expectAssignable)(setItemFull);
1126
+ (0, tsd_1.expectAssignable)({});
1127
+ (0, tsd_1.expectAssignable)({});
1128
+ // Invalid Set
1129
+ (0, tsd_1.expectError)({ attr1: "ff" });
1130
+ (0, tsd_1.expectError)({ attr1: "ff" });
1131
+ (0, tsd_1.expectError)({ attr6: "1234" });
1132
+ (0, tsd_1.expectError)({ attr6: "1234" });
1133
+ let compositeFn = entityWithSK.update({ attr1: "abc", attr2: "def" }).composite;
1134
+ let compositeFnWithoutSK = entityWithoutSK.update({ attr1: "abc" }).composite;
1135
+ const compositeParameters = {};
1136
+ const compositeParametersWithoutSk = {};
1137
+ (0, tsd_1.expectType)(magnify(compositeParameters));
1138
+ (0, tsd_1.expectType)(magnify(compositeParametersWithoutSk));
1139
+ let updateItem = entityWithSK.update({ attr1: "abc", attr2: "def" }).set({});
1140
+ let updateItemWithoutSK = entityWithoutSK.update({ attr1: "abc" }).set({});
1141
+ let updateFinishers = getKeys(updateItem);
1142
+ let updateFinishersWithoutSK = getKeys(updateItemWithoutSK);
1143
+ (0, tsd_1.expectAssignable)(updateFinishers);
1144
+ (0, tsd_1.expectAssignable)(updateFinishersWithoutSK);
1145
+ let updateGo = updateItem.go;
1146
+ let updateGoWithoutSK = updateItemWithoutSK.go;
1147
+ let updateParams = updateItem.params;
1148
+ let updateParamsWithoutSK = updateItemWithoutSK.params;
1149
+ (0, tsd_1.expectAssignable)({
1150
+ data: 'includeKeys',
1151
+ originalErr: true,
1152
+ params: {},
1153
+ table: "abc",
1154
+ response: "updated_new",
1155
+ });
1156
+ (0, tsd_1.expectAssignable)({
1157
+ data: 'includeKeys',
1158
+ originalErr: true,
1159
+ params: {},
1160
+ table: "abc",
1161
+ response: "updated_new",
1162
+ });
1163
+ (0, tsd_1.expectAssignable)({
1164
+ params: {},
1165
+ table: "abc",
1166
+ response: "updated_new",
1167
+ });
1168
+ (0, tsd_1.expectAssignable)({
1169
+ params: {},
1170
+ table: "abc",
1171
+ response: "updated_new",
1172
+ });
1173
+ // Where
1174
+ updateItem.where((attr, op) => {
1175
+ let opKeys = getKeys(op);
1176
+ (0, tsd_1.expectAssignable)(AttributeName);
1177
+ (0, tsd_1.expectAssignable)(opKeys);
1178
+ return "";
1179
+ });
1180
+ updateItemWithoutSK.where((attr, op) => {
1181
+ let opKeys = getKeys(op);
1182
+ (0, tsd_1.expectAssignable)(AttributeName);
1183
+ (0, tsd_1.expectAssignable)(opKeys);
1184
+ return "";
1185
+ });
1186
+ // Patch
1187
+ let patchItemFull = {
1188
+ attr4: "abc",
1189
+ attr8: true,
1190
+ attr3: "def",
1191
+ attr5: "dbs",
1192
+ attr6: 13,
1193
+ attr9: 24,
1194
+ attr7: { abc: "2345" },
1195
+ };
1196
+ let patchFn = entityWithSK.patch({ attr1: "abc", attr2: "def" }).set;
1197
+ let patchFnWithoutSK = entityWithoutSK.patch({ attr1: "abc" }).set;
1198
+ (0, tsd_1.expectAssignable)(patchItemFull);
1199
+ (0, tsd_1.expectAssignable)(patchItemFull);
1200
+ (0, tsd_1.expectAssignable)({});
1201
+ (0, tsd_1.expectAssignable)({});
1202
+ // Invalid Set
1203
+ (0, tsd_1.expectError)({ attr1: "ff" });
1204
+ (0, tsd_1.expectError)({ attr1: "ff" });
1205
+ (0, tsd_1.expectError)({ attr6: "1234" });
1206
+ (0, tsd_1.expectError)({ attr6: "1234" });
1207
+ let compositePatchFn = entityWithSK.update({
1208
+ attr1: "abc",
1209
+ attr2: "def",
1210
+ }).composite;
1211
+ let compositePatchFnWithoutSK = entityWithoutSK.update({
1212
+ attr1: "abc",
1213
+ }).composite;
1214
+ const compositePatchParameters = {};
1215
+ const compositePatchParametersWithoutSk = {};
1216
+ (0, tsd_1.expectType)(magnify(compositePatchParameters));
1217
+ (0, tsd_1.expectType)(magnify(compositePatchParametersWithoutSk));
1218
+ let patchItem = entityWithSK.patch({ attr1: "abc", attr2: "def" }).set({});
1219
+ let patchItemWithoutSK = entityWithoutSK.patch({ attr1: "abc" }).set({});
1220
+ let patchFinishers = getKeys(patchItem);
1221
+ let patchFinishersWithoutSK = getKeys(patchItemWithoutSK);
1222
+ (0, tsd_1.expectAssignable)(patchFinishers);
1223
+ (0, tsd_1.expectAssignable)(patchFinishersWithoutSK);
1224
+ let patchGo = patchItem.go;
1225
+ let patchGoWithoutSK = patchItemWithoutSK.go;
1226
+ let patchParams = patchItem.params;
1227
+ let patchParamsWithoutSK = patchItemWithoutSK.params;
1228
+ (0, tsd_1.expectAssignable)({
1229
+ data: 'includeKeys',
1230
+ originalErr: true,
1231
+ params: {},
1232
+ table: "abc",
1233
+ response: "updated_new",
1234
+ });
1235
+ (0, tsd_1.expectAssignable)({
1236
+ data: 'includeKeys',
1237
+ originalErr: true,
1238
+ params: {},
1239
+ table: "abc",
1240
+ response: "updated_new",
1241
+ });
1242
+ (0, tsd_1.expectAssignable)({
1243
+ params: {},
1244
+ table: "abc",
1245
+ response: "updated_new",
1246
+ });
1247
+ (0, tsd_1.expectAssignable)({
1248
+ params: {},
1249
+ table: "abc",
1250
+ response: "updated_new",
1251
+ });
1252
+ // Where
1253
+ patchItem.where((attr, op) => {
1254
+ let opKeys = getKeys(op);
1255
+ (0, tsd_1.expectAssignable)(AttributeName);
1256
+ (0, tsd_1.expectAssignable)(opKeys);
1257
+ return "";
1258
+ });
1259
+ patchItemWithoutSK.where((attr, op) => {
1260
+ let opKeys = getKeys(op);
1261
+ (0, tsd_1.expectAssignable)(AttributeName);
1262
+ (0, tsd_1.expectAssignable)(opKeys);
1263
+ return "";
1264
+ });
1265
+ // Find
1266
+ // Query
1267
+ let findFn = entityWithSK.find;
1268
+ let findFnWithoutSK = entityWithoutSK.find;
1269
+ (0, tsd_1.expectAssignable)(AttributeName);
1270
+ (0, tsd_1.expectAssignable)(AttributeName);
1271
+ (0, tsd_1.expectAssignable)({ attr6: 13 });
1272
+ (0, tsd_1.expectAssignable)({ attr6: 13 });
1273
+ // Invalid query
1274
+ (0, tsd_1.expectError)({ attr6: "ff" });
1275
+ (0, tsd_1.expectError)({ attr6: "ff" });
1276
+ (0, tsd_1.expectError)({ noexist: "ff" });
1277
+ (0, tsd_1.expectError)({ noexist: "ff" });
1278
+ // Where
1279
+ findFn({}).where((attr, op) => {
1280
+ let opKeys = getKeys(op);
1281
+ (0, tsd_1.expectAssignable)(AttributeName);
1282
+ (0, tsd_1.expectAssignable)(opKeys);
1283
+ return "";
1284
+ });
1285
+ findFnWithoutSK({}).where((attr, op) => {
1286
+ let opKeys = getKeys(op);
1287
+ (0, tsd_1.expectAssignable)(AttributeName);
1288
+ (0, tsd_1.expectAssignable)(opKeys);
1289
+ return "";
1290
+ });
1291
+ let findFinishers = entityWithSK.find({});
1292
+ let findFinishersWithoutSK = entityWithoutSK.find({});
1293
+ let matchFinishers = entityWithSK.match({});
1294
+ let matchFinishersWithoutSK = entityWithoutSK.match({});
1295
+ let findFinisherKeys = getKeys(findFinishers);
1296
+ let findFinisherKeysWithoutSK = getKeys(findFinishersWithoutSK);
1297
+ let matchFinisherKeys = getKeys(matchFinishers);
1298
+ let matchFinisherKeysWithoutSK = getKeys(matchFinishersWithoutSK);
1299
+ (0, tsd_1.expectAssignable)(findFinisherKeys);
1300
+ (0, tsd_1.expectAssignable)(findFinisherKeysWithoutSK);
1301
+ (0, tsd_1.expectAssignable)(matchFinisherKeys);
1302
+ (0, tsd_1.expectAssignable)(matchFinisherKeysWithoutSK);
1303
+ let findGo = findFinishers.go;
1304
+ let findGoWithoutSK = findFinishersWithoutSK.go;
1305
+ let matchGo = matchFinishers.go;
1306
+ let matchGoWithoutSK = matchFinishersWithoutSK.go;
1307
+ let findParams = findFinishers.params;
1308
+ let findParamsWithoutSK = findFinishersWithoutSK.params;
1309
+ let matchParams = matchFinishers.params;
1310
+ let matchParamsWithoutSK = matchFinishersWithoutSK.params;
1311
+ (0, tsd_1.expectAssignable)({
1312
+ data: 'includeKeys',
1313
+ originalErr: true,
1314
+ params: {},
1315
+ table: "abc",
1316
+ pages: 123,
1317
+ });
1318
+ (0, tsd_1.expectAssignable)({
1319
+ data: 'includeKeys',
1320
+ originalErr: true,
1321
+ params: {},
1322
+ table: "abc",
1323
+ pages: 123,
1324
+ });
1325
+ (0, tsd_1.expectAssignable)({
1326
+ data: 'includeKeys',
1327
+ originalErr: true,
1328
+ params: {},
1329
+ table: "abc",
1330
+ pages: 123,
1331
+ });
1332
+ (0, tsd_1.expectAssignable)({
1333
+ data: 'includeKeys',
1334
+ originalErr: true,
1335
+ params: {},
1336
+ table: "abc",
1337
+ pages: 123,
1338
+ });
1339
+ (0, tsd_1.expectAssignable)({ params: {}, table: "abc" });
1340
+ (0, tsd_1.expectAssignable)({ params: {}, table: "abc" });
1341
+ (0, tsd_1.expectAssignable)({ params: {}, table: "abc" });
1342
+ (0, tsd_1.expectAssignable)({ params: {}, table: "abc" });
1343
+ let accessPatternNames = getKeys(entityWithSK.query);
1344
+ let accessPatternNamesWithoutSK = getKeys(entityWithoutSK.query);
1345
+ (0, tsd_1.expectType)(accessPatternNames);
1346
+ (0, tsd_1.expectType)(accessPatternNamesWithoutSK);
1347
+ let myIndexBegins = entityWithSK.query.myIndex({ attr1: "abc" }).begins;
1348
+ // Begins does not exist on Find because the user has tossed out knowledge of order/indexes
1349
+ (0, tsd_1.expectError)(entityWithoutSK.query.myIndex({ attr1: "abc" }).begins);
1350
+ (0, tsd_1.expectAssignable)({ attr1: "abd" });
1351
+ (0, tsd_1.expectAssignable)({ attr1: "abd" });
1352
+ (0, tsd_1.expectAssignable)({ attr1: "abd", attr2: "def" });
1353
+ (0, tsd_1.expectAssignable)({ attr1: "abd" });
1354
+ (0, tsd_1.expectAssignable)({});
1355
+ (0, tsd_1.expectAssignable)({ attr2: "abc" });
1356
+ // attr1 not supplied
1357
+ (0, tsd_1.expectError)({ attr2: "abc" });
1358
+ (0, tsd_1.expectError)({ attr2: "abc" });
1359
+ // attr2 is a strin, not number
1360
+ (0, tsd_1.expectError)({ attr1: "abd", attr2: 133 });
1361
+ (0, tsd_1.expectError)({ attr1: 243 });
1362
+ // attr3 is not a pk or sk
1363
+ (0, tsd_1.expectError)({
1364
+ attr1: "abd",
1365
+ attr2: "def",
1366
+ attr3: "should_not_work",
1367
+ });
1368
+ (0, tsd_1.expectError)({
1369
+ attr1: "abd",
1370
+ attr2: "def",
1371
+ attr3: "should_not_work",
1372
+ });
1373
+ // attr1 was already used in the query method
1374
+ (0, tsd_1.expectError)({ attr1: "abd" });
1375
+ // attr2 is a string not number (this tests the 'remaining' composite attributes which should also enforce type)
1376
+ (0, tsd_1.expectError)({ attr2: 1243 });
1377
+ // require at least PK
1378
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({}));
1379
+ (0, tsd_1.expectError)(entityWithoutSK.query.myIndex({}));
1380
+ // attr6 should be number
1381
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex2({ attr6: "45" }));
1382
+ (0, tsd_1.expectError)(entityWithoutSK.query.myIndex2({ attr6: "45" }));
1383
+ entityWithSK.query
1384
+ .myIndex({ attr1: "abc", attr2: "def" })
1385
+ .go({ params: {} })
1386
+ .then((a) => a.data.map((val) => val.attr4));
1387
+ entityWithSK.query
1388
+ .myIndex({ attr1: "abc" })
1389
+ .go({ params: {} })
1390
+ .then((a) => a.data.map((val) => val.attr4));
1391
+ entityWithSK.query
1392
+ .myIndex2({ attr6: 45, attr9: 454, attr4: "abc", attr5: "def" })
1393
+ .go({ params: {} })
1394
+ .then((a) => a.data.map((val) => val.attr4));
1395
+ entityWithSK.query
1396
+ .myIndex2({ attr6: 45, attr9: 24 })
1397
+ .go({ params: {} })
1398
+ .then((a) => a.data.map((val) => val.attr4));
1399
+ entityWithSK.query
1400
+ .myIndex3({ attr5: "dgdagad" })
1401
+ .go({ params: {} })
1402
+ .then((a) => a.data.map((val) => val.attr4));
1403
+ entityWithoutSK.query
1404
+ .myIndex({ attr1: "abc" })
1405
+ .go({ params: {} })
1406
+ .then((a) => a.data.map((val) => val.attr4));
1407
+ entityWithoutSK.query
1408
+ .myIndex2({ attr6: 53, attr9: 35 })
1409
+ .go({ params: {} })
1410
+ .then((a) => a.data.map((val) => val.attr4));
1411
+ entityWithoutSK.query
1412
+ .myIndex3({ attr5: "dgdagad" })
1413
+ .go({ params: {} })
1414
+ .then((a) => a.data.map((val) => val.attr4));
1415
+ // Query Operations
1416
+ entityWithSK.query
1417
+ .myIndex({ attr1: "abc" })
1418
+ .begins({ attr2: "asf" })
1419
+ .go({ params: {} })
1420
+ .then((a) => a.data.map((val) => val.attr4));
1421
+ entityWithSK.query
1422
+ .myIndex2({ attr6: 45, attr9: 34, attr4: "abc" })
1423
+ .begins({ attr5: "db" })
1424
+ .go({ params: {} })
1425
+ .then((a) => a.data.map((val) => val.attr4));
1426
+ entityWithSK.query
1427
+ .myIndex3({ attr5: "dgdagad" })
1428
+ .between({ attr4: "abc", attr9: 3, attr3: "def" }, { attr4: "abc", attr9: 4, attr3: "def" })
1429
+ .go({ params: {} })
1430
+ .then((a) => a.data.map((val) => val.attr4));
1431
+ entityWithSK.query
1432
+ .myIndex({ attr1: "abc" })
1433
+ .gte({ attr2: "asf" })
1434
+ .go({ params: {} })
1435
+ .then((a) => a.data.map((val) => val.attr4));
1436
+ entityWithSK.query
1437
+ .myIndex2({ attr6: 45, attr9: 33, attr4: "abc" })
1438
+ .gt({ attr5: "abd" })
1439
+ .go({ params: {} })
1440
+ .then((a) => a.data.map((val) => val.attr4));
1441
+ entityWithSK.query
1442
+ .myIndex3({ attr5: "dgdagad" })
1443
+ .lte({ attr4: "abc", attr9: 3 })
1444
+ .go({ params: {} })
1445
+ .then((a) => a.data.map((val) => val.attr4));
1446
+ entityWithSK.query
1447
+ .myIndex3({ attr5: "dgdagad" })
1448
+ .lt({ attr4: "abc", attr9: 3 })
1449
+ .go({ params: {} })
1450
+ .then((a) => a.data.map((val) => val.attr4));
1451
+ entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1452
+ ${name(attr6)} = ${value(attr6, 12)}
1453
+ AND ${exists(attr6)}
1454
+ AND ${notExists(attr6)}
1455
+ AND ${begins(attr6, 35)}
1456
+ AND ${between(attr6, 1, 10)}
1457
+ AND ${contains(attr6, 14)}
1458
+ AND ${eq(attr6, 14)}
1459
+ AND ${gt(attr6, 14)}
1460
+ AND ${gte(attr6, 14)}
1461
+ AND ${lt(attr6, 14)}
1462
+ AND ${lte(attr6, 14)}
1463
+ AND ${notContains(attr6, 14)}
1464
+ `);
1465
+ // Query Operations (Except with Type Errors)
1466
+ // This one ensures that an SK value in the index method still is type checked
1467
+ (0, tsd_1.expectError)(entityWithSK.query
1468
+ .myIndex({ attr1: "452", attr2: 245 })
1469
+ .go({ params: {} })
1470
+ .then((a) => a.data.map((val) => val.attr4)));
1471
+ (0, tsd_1.expectError)(entityWithSK.query
1472
+ .myIndex2({ attr6: "45" })
1473
+ .go({ params: {} })
1474
+ .then((a) => a.data.map((val) => val.attr4)));
1475
+ (0, tsd_1.expectError)(entityWithSK.query
1476
+ .myIndex3({ attr5: 426 })
1477
+ .go({ params: {} })
1478
+ .then((a) => a.data.map((val) => val.attr4)));
1479
+ (0, tsd_1.expectError)(entityWithoutSK.query
1480
+ .myIndex({ attr1: 246 })
1481
+ .go({ params: {} })
1482
+ .then((a) => a.data.map((val) => val.attr4)));
1483
+ (0, tsd_1.expectError)(entityWithoutSK.query
1484
+ .myIndex2({ attr6: 24, attr9: "1" })
1485
+ .go({ params: {} })
1486
+ .then((a) => a.data.map((val) => val.attr4)));
1487
+ (0, tsd_1.expectError)(entityWithoutSK.query
1488
+ .myIndex3({ attr5: 346 })
1489
+ .go({ params: {} })
1490
+ .then((a) => a.data.map((val) => val.attr4)));
1491
+ // Query Operations
1492
+ (0, tsd_1.expectError)(entityWithSK.query
1493
+ .myIndex({ attr1: "abc" })
1494
+ .begins({ attr2: 42 })
1495
+ .go({ params: {} })
1496
+ .then((a) => a.data.map((val) => val.attr4)));
1497
+ (0, tsd_1.expectError)(entityWithSK.query
1498
+ .myIndex2({ attr6: 45, attr4: "abc" })
1499
+ .begins({ attr5: 462 })
1500
+ .go({ params: {} })
1501
+ .then((a) => a.data.map((val) => val.attr4)));
1502
+ (0, tsd_1.expectError)(entityWithSK.query
1503
+ .myIndex3({ attr5: "dgdagad" })
1504
+ .between({ attr4: "abc", attr9: "3", attr3: "def" }, { attr4: "abc", attr9: "4", attr3: "def" })
1505
+ .go({ params: {} })
1506
+ .then((a) => a.data.map((val) => val.attr4)));
1507
+ (0, tsd_1.expectError)(entityWithSK.query
1508
+ .myIndex({ attr1: "abc" })
1509
+ .gte({ attr2: 462 })
1510
+ .go({ params: {} })
1511
+ .then((a) => a.data.map((val) => val.attr4)));
1512
+ (0, tsd_1.expectError)(entityWithSK.query
1513
+ .myIndex2({ attr6: 45, attr4: "abc" })
1514
+ .gt({ attr5: 246 })
1515
+ .go({ params: {} })
1516
+ .then((a) => a.data.map((val) => val.attr4)));
1517
+ (0, tsd_1.expectError)(entityWithSK.query
1518
+ .myIndex3({ attr5: "dgdagad" })
1519
+ .lte({ attr4: "abc", attr9: "3" })
1520
+ .go({ params: {} })
1521
+ .then((a) => a.data.map((val) => val.attr4)));
1522
+ (0, tsd_1.expectError)(entityWithSK.query
1523
+ .myIndex3({ attr5: "dgdagad" })
1524
+ .lt({ attr4: "abc", attr9: "3" })
1525
+ .go({ params: {} })
1526
+ .then((a) => a.data.map((val) => val.attr4)));
1527
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1528
+ ${name(attr6)} = ${value()}
1529
+ `));
1530
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1531
+ ${exists()}
1532
+ `));
1533
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1534
+ ${notExists()}
1535
+ `));
1536
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1537
+ ${begins(attr6, "35")}
1538
+ `));
1539
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1540
+ ${between(attr6, "1", 10)}
1541
+ `));
1542
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1543
+ ${between(attr6, 1, "10")}
1544
+ `));
1545
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1546
+ ${contains(attr6, "14")}
1547
+ `));
1548
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1549
+ ${eq(attr6, "14")}
1550
+ `));
1551
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1552
+ ${gt(attr6, "14")}
1553
+ `));
1554
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1555
+ ${gte(attr6, "14")}
1556
+ `));
1557
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1558
+ ${lt(attr6, "14")}
1559
+ `));
1560
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1561
+ ${lte(attr6, "14")}
1562
+ `));
1563
+ (0, tsd_1.expectError)(entityWithSK.query.myIndex({ attr1: "abc", attr2: "db" }).where(({ attr6 }, { value, name, exists, begins, between, contains, eq, gt, gte, lt, lte, notContains, notExists, }) => `
1564
+ ${notContains(attr6, "14")}
1565
+ `));
1566
+ // Invalid cases
1567
+ (0, tsd_1.expectError)(() => new _1.Service({ abc: "123" }));
1568
+ // Service with no Entities
1569
+ // let nullCaseService = new Service({});
1570
+ // type NullCollections = typeof nullCaseService.collections;
1571
+ // type NullEntities = typeof nullCaseService.collections;
1572
+ // expectType<NullCollections>(magnify({}));
1573
+ // expectType<NullEntities>(magnify({}));
1574
+ // Service with no Collections
1575
+ // let serviceNoCollections = new Service({standAloneEntity});
1576
+ // type noEntityCollections = typeof serviceNoCollections.collections;
1577
+ // expectType<noEntityCollections>({});
1578
+ // Service no shared entity collections
1579
+ let serviceNoShared = new _1.Service({
1580
+ entityWithoutSK,
1581
+ standAloneEntity,
1582
+ normalEntity1,
1583
+ });
1584
+ let expectNoSharedCollections = "";
1585
+ (0, tsd_1.expectType)(expectNoSharedCollections);
1586
+ const noSharedCollectionParameter1 = {};
1587
+ (0, tsd_1.expectType)(noSharedCollectionParameter1);
1588
+ (0, tsd_1.expectError)({});
1589
+ (0, tsd_1.expectError)({ attr5: 123 });
1590
+ (0, tsd_1.expectError)({ attr1: "123" });
1591
+ const noSharedCollectionParameter2 = {};
1592
+ (0, tsd_1.expectType)(noSharedCollectionParameter2);
1593
+ (0, tsd_1.expectError)({});
1594
+ (0, tsd_1.expectError)({ prop2: "abc" });
1595
+ (0, tsd_1.expectError)({ prop1: "abc" });
1596
+ (0, tsd_1.expectError)({ prop1: 35 });
1597
+ (0, tsd_1.expectError)({ prop2: 35 });
1598
+ (0, tsd_1.expectError)({ prop3: "35" });
1599
+ // Service with complex collections
1600
+ let complexService = new _1.Service({
1601
+ entityWithoutSK,
1602
+ entityWithSK,
1603
+ standAloneEntity,
1604
+ normalEntity1,
1605
+ normalEntity2,
1606
+ });
1607
+ let expectSharedCollections = "";
1608
+ (0, tsd_1.expectType)(expectSharedCollections);
1609
+ // success
1610
+ complexService.collections.mycollection({ attr5: "abc" });
1611
+ // failure - no collection composite attributes
1612
+ (0, tsd_1.expectError)({});
1613
+ // failure - incorrect entity composite attribute types
1614
+ (0, tsd_1.expectError)({ attr5: 123 });
1615
+ // failure - incorrect entity composite attribute properties
1616
+ (0, tsd_1.expectError)({ attr1: "123" });
1617
+ // success
1618
+ complexService.collections.normalcollection({ prop2: "abc", prop1: "def" });
1619
+ // failure - no collection composite attributes
1620
+ (0, tsd_1.expectError)({});
1621
+ // failure - incomplete composite attributes
1622
+ (0, tsd_1.expectError)({ prop2: "abc" });
1623
+ // failure - incomplete composite attributes
1624
+ (0, tsd_1.expectError)({ prop1: "abc" });
1625
+ // failure - incorrect entity composite attribute types
1626
+ (0, tsd_1.expectError)({ prop1: 35 });
1627
+ // failure - incorrect entity composite attribute types
1628
+ (0, tsd_1.expectError)({ prop2: 35 });
1629
+ // failure - incorrect entity composite attribute properties
1630
+ (0, tsd_1.expectError)({ prop3: "35" });
1631
+ let chainMethods = complexService.collections.normalcollection({
1632
+ prop2: "abc",
1633
+ prop1: "def",
1634
+ });
1635
+ let expectedAfterQueryChainMethods = "";
1636
+ (0, tsd_1.expectType)(expectedAfterQueryChainMethods);
1637
+ (0, tsd_1.expectAssignable)({
1638
+ table: "df",
1639
+ params: {},
1640
+ originalErr: true,
1641
+ data: 'includeKeys',
1642
+ pages: 123,
1643
+ });
1644
+ complexService.collections
1645
+ .normalcollection({ prop2: "abc", prop1: "def" })
1646
+ .go()
1647
+ .then((res) => {
1648
+ let expectedEntities = "";
1649
+ (0, tsd_1.expectType)(expectedEntities);
1650
+ res.data.normalEntity1.map((item) => {
1651
+ (0, tsd_1.expectError)(item.attr1);
1652
+ (0, tsd_1.expectError)(item.attr2);
1653
+ (0, tsd_1.expectError)(item.attr3);
1654
+ (0, tsd_1.expectError)(item.attr4);
1655
+ (0, tsd_1.expectError)(item.attr5);
1656
+ (0, tsd_1.expectError)(item.attr6);
1657
+ (0, tsd_1.expectError)(item.attr7);
1658
+ (0, tsd_1.expectError)(item.attr8);
1659
+ (0, tsd_1.expectError)(item.attr9);
1660
+ (0, tsd_1.expectError)(item.attr10);
1661
+ (0, tsd_1.expectType)(item.prop1);
1662
+ (0, tsd_1.expectType)(item.prop2);
1663
+ (0, tsd_1.expectType)(item.prop3);
1664
+ (0, tsd_1.expectType)(item.prop4);
1665
+ (0, tsd_1.expectType)(item.prop10);
1666
+ let itemKeys = "";
1667
+ (0, tsd_1.expectType)(itemKeys);
1668
+ });
1669
+ res.data.normalEntity2.map((item) => {
1670
+ (0, tsd_1.expectType)(item.prop1);
1671
+ (0, tsd_1.expectType)(item.prop2);
1672
+ (0, tsd_1.expectType)(item.prop3);
1673
+ (0, tsd_1.expectType)(item.prop5);
1674
+ (0, tsd_1.expectType)(item.attr9);
1675
+ (0, tsd_1.expectType)(item.attr6);
1676
+ (0, tsd_1.expectNotAssignable)(item);
1677
+ (0, tsd_1.expectNotAssignable)(item);
1678
+ (0, tsd_1.expectNotAssignable)(item);
1679
+ (0, tsd_1.expectNotAssignable)(item);
1680
+ (0, tsd_1.expectNotAssignable)(item);
1681
+ (0, tsd_1.expectNotAssignable)(item);
1682
+ (0, tsd_1.expectNotAssignable)(item);
1683
+ (0, tsd_1.expectNotAssignable)(item);
1684
+ (0, tsd_1.expectNotAssignable)(item);
1685
+ (0, tsd_1.expectNotAssignable)(item);
1686
+ (0, tsd_1.expectNotAssignable)(item);
1687
+ let itemKeys = "";
1688
+ (0, tsd_1.expectType)(itemKeys);
1689
+ });
1690
+ });
1691
+ complexService.collections
1692
+ .mycollection({ attr5: "sgad" })
1693
+ .go()
1694
+ .then((res) => {
1695
+ let expectedEntities = "";
1696
+ (0, tsd_1.expectType)(expectedEntities);
1697
+ res.data.entityWithSK.map((item) => {
1698
+ (0, tsd_1.expectType)(item.attr1);
1699
+ (0, tsd_1.expectType)(item.attr2);
1700
+ (0, tsd_1.expectType)(item.attr3);
1701
+ (0, tsd_1.expectType)(item.attr4);
1702
+ (0, tsd_1.expectType)(item.attr5);
1703
+ (0, tsd_1.expectType)(item.attr6);
1704
+ (0, tsd_1.expectType)(item.attr7);
1705
+ (0, tsd_1.expectType)(item.attr8);
1706
+ (0, tsd_1.expectType)(item.attr9);
1707
+ (0, tsd_1.expectType)(item.attr10);
1708
+ // .go response related entities correct items
1709
+ let itemKeys = "";
1710
+ (0, tsd_1.expectType)(itemKeys);
1711
+ });
1712
+ res.data.entityWithoutSK.map((item) => {
1713
+ item.attr2;
1714
+ (0, tsd_1.expectType)(item.attr1);
1715
+ (0, tsd_1.expectType)(item.attr2);
1716
+ (0, tsd_1.expectType)(item.attr3);
1717
+ (0, tsd_1.expectType)(item.attr4);
1718
+ (0, tsd_1.expectType)(item.attr5);
1719
+ (0, tsd_1.expectType)(item.attr6);
1720
+ (0, tsd_1.expectType)(item.attr7);
1721
+ (0, tsd_1.expectType)(item.attr8);
1722
+ (0, tsd_1.expectType)(item.attr9);
1723
+ // .go response related entities correct items
1724
+ let itemKeys = "";
1725
+ (0, tsd_1.expectType)(itemKeys);
1726
+ });
1727
+ });
1728
+ let serviceWhere = complexService.collections
1729
+ .mycollection1({ attr6: 13, attr9: 54 })
1730
+ .where((attr, op) => {
1731
+ let opKeys = getKeys(op);
1732
+ (0, tsd_1.expectType)(opKeys);
1733
+ op.eq(attr.attr9, 455);
1734
+ op.eq(attr.prop5, 455);
1735
+ (0, tsd_1.expectAssignable)(attr);
1736
+ (0, tsd_1.expectAssignable)(attr);
1737
+ (0, tsd_1.expectAssignable)(attr);
1738
+ (0, tsd_1.expectAssignable)(attr);
1739
+ (0, tsd_1.expectAssignable)(attr);
1740
+ (0, tsd_1.expectAssignable)(attr);
1741
+ (0, tsd_1.expectAssignable)(attr);
1742
+ (0, tsd_1.expectAssignable)(attr);
1743
+ (0, tsd_1.expectAssignable)(attr);
1744
+ (0, tsd_1.expectAssignable)(attr);
1745
+ (0, tsd_1.expectAssignable)(attr);
1746
+ (0, tsd_1.expectAssignable)(attr);
1747
+ (0, tsd_1.expectAssignable)(attr);
1748
+ (0, tsd_1.expectNotAssignable)(attr);
1749
+ (0, tsd_1.expectAssignable)(attr);
1750
+ (0, tsd_1.expectNotAssignable)(attr);
1751
+ return "";
1752
+ })
1753
+ .go()
1754
+ .then((res) => {
1755
+ res.data.normalEntity2.map((item) => {
1756
+ let keys = "";
1757
+ (0, tsd_1.expectType)(keys);
1758
+ (0, tsd_1.expectType)(item.prop1);
1759
+ (0, tsd_1.expectType)(item.prop2);
1760
+ (0, tsd_1.expectType)(item.prop3);
1761
+ (0, tsd_1.expectType)(item.prop5);
1762
+ (0, tsd_1.expectType)(item.attr6);
1763
+ (0, tsd_1.expectType)(item.attr9);
1764
+ });
1765
+ res.data.entityWithSK.map((item) => {
1766
+ let keys = "";
1767
+ (0, tsd_1.expectType)(keys);
1768
+ (0, tsd_1.expectType)(item.attr1);
1769
+ (0, tsd_1.expectType)(item.attr2);
1770
+ (0, tsd_1.expectType)(item.attr3);
1771
+ (0, tsd_1.expectType)(item.attr4);
1772
+ (0, tsd_1.expectType)(item.attr5);
1773
+ (0, tsd_1.expectType)(item.attr6);
1774
+ (0, tsd_1.expectType)(item.attr7);
1775
+ (0, tsd_1.expectType)(item.attr8);
1776
+ (0, tsd_1.expectType)(item.attr9);
1777
+ (0, tsd_1.expectType)(item.attr10);
1778
+ });
1779
+ res.data.entityWithoutSK.map((item) => {
1780
+ let keys = "";
1781
+ (0, tsd_1.expectType)(keys);
1782
+ (0, tsd_1.expectType)(item.attr1);
1783
+ (0, tsd_1.expectType)(item.attr2);
1784
+ (0, tsd_1.expectType)(item.attr3);
1785
+ (0, tsd_1.expectType)(item.attr4);
1786
+ (0, tsd_1.expectType)(item.attr5);
1787
+ (0, tsd_1.expectType)(item.attr6);
1788
+ (0, tsd_1.expectType)(item.attr7);
1789
+ (0, tsd_1.expectType)(item.attr8);
1790
+ (0, tsd_1.expectType)(item.attr9);
1791
+ });
1792
+ });
1793
+ complexService.collections
1794
+ .normalcollection({ prop1: "abc", prop2: "def" })
1795
+ .where((attr, op) => {
1796
+ let opKeys = getKeys(op);
1797
+ (0, tsd_1.expectType)(opKeys);
1798
+ (0, tsd_1.expectNotAssignable)(attr);
1799
+ (0, tsd_1.expectNotAssignable)(attr);
1800
+ (0, tsd_1.expectNotAssignable)(attr);
1801
+ (0, tsd_1.expectNotAssignable)(attr);
1802
+ (0, tsd_1.expectNotAssignable)(attr);
1803
+ (0, tsd_1.expectAssignable)(attr);
1804
+ (0, tsd_1.expectNotAssignable)(attr);
1805
+ (0, tsd_1.expectNotAssignable)(attr);
1806
+ (0, tsd_1.expectAssignable)(attr);
1807
+ (0, tsd_1.expectNotAssignable)(attr);
1808
+ (0, tsd_1.expectAssignable)(attr);
1809
+ (0, tsd_1.expectAssignable)(attr);
1810
+ (0, tsd_1.expectAssignable)(attr);
1811
+ (0, tsd_1.expectAssignable)(attr);
1812
+ (0, tsd_1.expectAssignable)(attr);
1813
+ (0, tsd_1.expectAssignable)(attr);
1814
+ return op.eq(attr.prop1, "db");
1815
+ })
1816
+ .go()
1817
+ .then((res) => {
1818
+ res.data.normalEntity1.map((item) => {
1819
+ let keys = "";
1820
+ (0, tsd_1.expectType)(keys);
1821
+ (0, tsd_1.expectType)(item.prop1);
1822
+ (0, tsd_1.expectType)(item.prop2);
1823
+ (0, tsd_1.expectType)(item.prop3);
1824
+ (0, tsd_1.expectType)(item.prop4);
1825
+ (0, tsd_1.expectType)(item.prop10);
1826
+ });
1827
+ res.data.normalEntity2.map((item) => {
1828
+ let keys = "";
1829
+ (0, tsd_1.expectType)(keys);
1830
+ (0, tsd_1.expectType)(item.prop1);
1831
+ (0, tsd_1.expectType)(item.prop2);
1832
+ (0, tsd_1.expectType)(item.prop3);
1833
+ (0, tsd_1.expectType)(item.prop5);
1834
+ (0, tsd_1.expectType)(item.attr6);
1835
+ (0, tsd_1.expectType)(item.attr9);
1836
+ });
1837
+ });
1838
+ complexService.collections
1839
+ .mycollection2({ attr1: "abc" })
1840
+ .where((attr, op) => {
1841
+ let opKeys = getKeys(op);
1842
+ (0, tsd_1.expectType)(opKeys);
1843
+ (0, tsd_1.expectAssignable)(attr);
1844
+ (0, tsd_1.expectAssignable)(attr);
1845
+ (0, tsd_1.expectAssignable)(attr);
1846
+ (0, tsd_1.expectAssignable)(attr);
1847
+ (0, tsd_1.expectAssignable)(attr);
1848
+ (0, tsd_1.expectAssignable)(attr);
1849
+ (0, tsd_1.expectAssignable)(attr);
1850
+ (0, tsd_1.expectAssignable)(attr);
1851
+ (0, tsd_1.expectAssignable)(attr);
1852
+ (0, tsd_1.expectAssignable)(attr);
1853
+ (0, tsd_1.expectNotAssignable)(attr);
1854
+ (0, tsd_1.expectNotAssignable)(attr);
1855
+ (0, tsd_1.expectNotAssignable)(attr);
1856
+ (0, tsd_1.expectNotAssignable)(attr);
1857
+ (0, tsd_1.expectNotAssignable)(attr);
1858
+ (0, tsd_1.expectNotAssignable)(attr);
1859
+ return op.eq(attr.attr9, 768);
1860
+ })
1861
+ .go()
1862
+ .then((res) => {
1863
+ res.data.entityWithSK.map((item) => {
1864
+ let keys = "";
1865
+ (0, tsd_1.expectType)(keys);
1866
+ (0, tsd_1.expectType)(item.attr1);
1867
+ (0, tsd_1.expectType)(item.attr2);
1868
+ (0, tsd_1.expectType)(item.attr3);
1869
+ (0, tsd_1.expectType)(item.attr4);
1870
+ (0, tsd_1.expectType)(item.attr5);
1871
+ (0, tsd_1.expectType)(item.attr6);
1872
+ (0, tsd_1.expectType)(item.attr7);
1873
+ (0, tsd_1.expectType)(item.attr8);
1874
+ (0, tsd_1.expectType)(item.attr9);
1875
+ (0, tsd_1.expectType)(item.attr10);
1876
+ });
1877
+ });
1878
+ let entityWithHiddenAttributes1 = new _1.Entity({
1879
+ model: {
1880
+ entity: "e1",
1881
+ service: "s1",
1882
+ version: "1",
1883
+ },
1884
+ attributes: {
1885
+ prop1: {
1886
+ type: "string",
1887
+ },
1888
+ prop2: {
1889
+ type: "string",
1890
+ },
1891
+ prop3: {
1892
+ type: "string",
1893
+ hidden: true,
1894
+ },
1895
+ },
1896
+ indexes: {
1897
+ record: {
1898
+ collection: "collection1",
1899
+ pk: {
1900
+ field: "pk",
1901
+ composite: ["prop1"],
1902
+ },
1903
+ sk: {
1904
+ field: "sk",
1905
+ composite: ["prop2"],
1906
+ },
1907
+ },
1908
+ },
1909
+ });
1910
+ let entityWithHiddenAttributes2 = new _1.Entity({
1911
+ model: {
1912
+ entity: "e2",
1913
+ service: "s1",
1914
+ version: "1",
1915
+ },
1916
+ attributes: {
1917
+ prop1: {
1918
+ type: "string",
1919
+ },
1920
+ prop2: {
1921
+ type: "string",
1922
+ },
1923
+ prop4: {
1924
+ type: "string",
1925
+ hidden: true,
1926
+ },
1927
+ prop5: {
1928
+ type: "string",
1929
+ },
1930
+ },
1931
+ indexes: {
1932
+ record: {
1933
+ collection: "collection1",
1934
+ pk: {
1935
+ field: "pk",
1936
+ composite: ["prop1"],
1937
+ },
1938
+ sk: {
1939
+ field: "sk",
1940
+ composite: ["prop2"],
1941
+ },
1942
+ },
1943
+ },
1944
+ });
1945
+ const serviceWithHiddenAttributes = new _1.Service({
1946
+ e1: entityWithHiddenAttributes1,
1947
+ e2: entityWithHiddenAttributes2,
1948
+ });
1949
+ let entity1WithHiddenAttributeKey = "";
1950
+ let entity2WithHiddenAttributeKey = "";
1951
+ entityWithHiddenAttributes1
1952
+ .get({ prop1: "abc", prop2: "def" })
1953
+ .where((attr, op) => {
1954
+ (0, tsd_1.expectAssignable)(attr);
1955
+ return op.eq(attr.prop3, "abc");
1956
+ })
1957
+ .go()
1958
+ .then((res) => {
1959
+ if (res.data !== null) {
1960
+ (0, tsd_1.expectType)(entity1WithHiddenAttributeKey);
1961
+ (0, tsd_1.expectType)(res.data);
1962
+ }
1963
+ });
1964
+ entityWithHiddenAttributes1.query
1965
+ .record({ prop1: "abc" })
1966
+ .where((attr, op) => {
1967
+ (0, tsd_1.expectAssignable)(attr);
1968
+ return op.eq(attr.prop3, "abc");
1969
+ })
1970
+ .go()
1971
+ .then((res) => {
1972
+ return res.data.map((value) => {
1973
+ (0, tsd_1.expectType)(entity1WithHiddenAttributeKey);
1974
+ (0, tsd_1.expectType)(value);
1975
+ });
1976
+ });
1977
+ serviceWithHiddenAttributes.collections
1978
+ .collection1({ prop1: "abc" })
1979
+ .where((attr, op) => {
1980
+ (0, tsd_1.expectAssignable)(attr);
1981
+ (0, tsd_1.expectAssignable)(attr);
1982
+ return `${op.eq(attr.prop3, "abc")} AND ${op.eq(attr.prop4, "def")}`;
1983
+ })
1984
+ .go()
1985
+ .then((res) => {
1986
+ res.data.e1.map((value) => {
1987
+ (0, tsd_1.expectType)(entity1WithHiddenAttributeKey);
1988
+ (0, tsd_1.expectType)(value);
1989
+ });
1990
+ res.data.e2.map((value) => {
1991
+ (0, tsd_1.expectType)(entity2WithHiddenAttributeKey);
1992
+ (0, tsd_1.expectType)(value.prop1);
1993
+ (0, tsd_1.expectType)(value.prop2);
1994
+ (0, tsd_1.expectType)(value.prop5);
1995
+ });
1996
+ });
1997
+ let entityWithRequiredAttribute = new _1.Entity({
1998
+ model: {
1999
+ entity: "e1",
2000
+ service: "s1",
2001
+ version: "1",
2002
+ },
2003
+ attributes: {
2004
+ prop1: {
2005
+ type: "string",
2006
+ },
2007
+ prop2: {
2008
+ type: "string",
2009
+ },
2010
+ prop3: {
2011
+ type: "string",
2012
+ required: true,
2013
+ },
2014
+ prop4: {
2015
+ type: "number",
2016
+ required: true,
2017
+ },
2018
+ prop5: {
2019
+ type: "any",
2020
+ required: true,
2021
+ },
2022
+ prop6: {
2023
+ type: "map",
2024
+ properties: {
2025
+ nested1: {
2026
+ type: "string",
2027
+ required: true,
2028
+ },
2029
+ },
2030
+ required: true,
2031
+ },
2032
+ prop7: {
2033
+ type: "list",
2034
+ items: {
2035
+ type: "string",
2036
+ required: true,
2037
+ },
2038
+ required: true,
2039
+ },
2040
+ prop8: {
2041
+ type: "string",
2042
+ required: true,
2043
+ default: "abc",
2044
+ },
2045
+ prop9: {
2046
+ type: "map",
2047
+ properties: {
2048
+ nested1: {
2049
+ type: "string",
2050
+ required: true,
2051
+ default: () => "abc",
2052
+ },
2053
+ nested2: {
2054
+ type: "string",
2055
+ required: true,
2056
+ default: "abc",
2057
+ },
2058
+ },
2059
+ default: {},
2060
+ required: true,
2061
+ },
2062
+ prop10: {
2063
+ type: "list",
2064
+ items: {
2065
+ type: "string",
2066
+ },
2067
+ required: true,
2068
+ default: [],
2069
+ },
2070
+ },
2071
+ indexes: {
2072
+ record: {
2073
+ collection: "collection1",
2074
+ pk: {
2075
+ field: "pk",
2076
+ composite: ["prop1"],
2077
+ },
2078
+ sk: {
2079
+ field: "sk",
2080
+ composite: ["prop2"],
2081
+ },
2082
+ },
2083
+ },
2084
+ });
2085
+ // required attributes, as object and array, without required (but defaulted attributes)
2086
+ entityWithRequiredAttribute.put({
2087
+ prop1: "abc",
2088
+ prop2: "def",
2089
+ prop3: "ghi",
2090
+ prop4: 123,
2091
+ prop5: { anyVal: ["anyItem"] },
2092
+ prop6: {
2093
+ nested1: "abc",
2094
+ },
2095
+ prop7: [],
2096
+ });
2097
+ // required attributes, as object and array, without required (but defaulted attributes)
2098
+ entityWithRequiredAttribute.put([
2099
+ {
2100
+ prop1: "abc",
2101
+ prop2: "def",
2102
+ prop3: "ghi",
2103
+ prop4: 123,
2104
+ prop5: { anyVal: ["anyItem"] },
2105
+ prop6: {
2106
+ nested1: "abc",
2107
+ },
2108
+ prop7: [],
2109
+ },
2110
+ ]);
2111
+ // required attributes, as object and array, without required (but defaulted attributes)
2112
+ entityWithRequiredAttribute.create({
2113
+ prop1: "abc",
2114
+ prop2: "def",
2115
+ prop3: "ghi",
2116
+ prop4: 123,
2117
+ prop5: { anyVal: ["anyItem"] },
2118
+ prop6: {
2119
+ nested1: "abc",
2120
+ },
2121
+ prop7: [],
2122
+ });
2123
+ // create doesnt allow for bulk
2124
+ (0, tsd_1.expectError)(() => {
2125
+ entityWithRequiredAttribute.create([
2126
+ {
2127
+ prop1: "abc",
2128
+ prop2: "def",
2129
+ prop3: "ghi",
2130
+ prop4: 123,
2131
+ prop5: { anyVal: ["anyItem"] },
2132
+ prop6: {
2133
+ nested1: "abc",
2134
+ },
2135
+ prop7: [],
2136
+ },
2137
+ ]);
2138
+ });
2139
+ // missing `nested1` on `prop6`
2140
+ (0, tsd_1.expectError)(() => {
2141
+ entityWithRequiredAttribute.put({
2142
+ prop1: "abc",
2143
+ prop2: "def",
2144
+ prop3: "ghi",
2145
+ prop4: 123,
2146
+ prop5: { anyVal: ["anyItem"] },
2147
+ prop6: {},
2148
+ prop7: [],
2149
+ });
2150
+ });
2151
+ // missing `nested1` on `prop6`
2152
+ (0, tsd_1.expectError)(() => {
2153
+ entityWithRequiredAttribute.put([
2154
+ {
2155
+ prop1: "abc",
2156
+ prop2: "def",
2157
+ prop3: "ghi",
2158
+ prop4: 123,
2159
+ prop5: { anyVal: ["anyItem"] },
2160
+ prop6: {},
2161
+ prop7: [],
2162
+ },
2163
+ ]);
2164
+ });
2165
+ // missing `nested1` on `prop6`
2166
+ (0, tsd_1.expectError)(() => {
2167
+ entityWithRequiredAttribute.create({
2168
+ prop1: "abc",
2169
+ prop2: "def",
2170
+ prop3: "ghi",
2171
+ prop4: 123,
2172
+ prop5: { anyVal: ["anyItem"] },
2173
+ prop6: {},
2174
+ prop7: [],
2175
+ });
2176
+ });
2177
+ // no removing required attributes
2178
+ (0, tsd_1.expectError)(() => {
2179
+ entityWithRequiredAttribute
2180
+ .update({ prop1: "abc", prop2: "def" })
2181
+ .remove(["prop3"]);
2182
+ });
2183
+ // no removing required attributes
2184
+ (0, tsd_1.expectError)(() => {
2185
+ entityWithRequiredAttribute
2186
+ .update({ prop1: "abc", prop2: "def" })
2187
+ .remove(["prop5"]);
2188
+ });
2189
+ // no removing required attributes
2190
+ (0, tsd_1.expectError)(() => {
2191
+ entityWithRequiredAttribute
2192
+ .update({ prop1: "abc", prop2: "def" })
2193
+ .remove(["prop6"]);
2194
+ });
2195
+ // no removing required attributes
2196
+ (0, tsd_1.expectError)(() => {
2197
+ entityWithRequiredAttribute
2198
+ .update({ prop1: "abc", prop2: "def" })
2199
+ .remove(["prop7"]);
2200
+ });
2201
+ let entityWithReadOnlyAttribute = new _1.Entity({
2202
+ model: {
2203
+ entity: "e1",
2204
+ service: "s1",
2205
+ version: "1",
2206
+ },
2207
+ attributes: {
2208
+ prop1: {
2209
+ type: "string",
2210
+ },
2211
+ prop2: {
2212
+ type: "string",
2213
+ },
2214
+ prop3: {
2215
+ type: "string",
2216
+ readOnly: true,
2217
+ },
2218
+ prop4: {
2219
+ type: "string",
2220
+ },
2221
+ prop5: {
2222
+ type: "number",
2223
+ },
2224
+ prop6: {
2225
+ type: "any",
2226
+ },
2227
+ prop7: {
2228
+ type: "string",
2229
+ },
2230
+ prop8: {
2231
+ type: ["abc", "def"],
2232
+ },
2233
+ prop9: {
2234
+ type: "number",
2235
+ readOnly: true,
2236
+ },
2237
+ prop10: {
2238
+ type: "any",
2239
+ readOnly: true,
2240
+ },
2241
+ prop11: {
2242
+ type: "list",
2243
+ items: {
2244
+ type: "string",
2245
+ },
2246
+ },
2247
+ },
2248
+ indexes: {
2249
+ record: {
2250
+ collection: "collection1",
2251
+ pk: {
2252
+ field: "pk",
2253
+ composite: ["prop1"],
2254
+ },
2255
+ sk: {
2256
+ field: "sk",
2257
+ composite: ["prop2"],
2258
+ },
2259
+ },
2260
+ },
2261
+ });
2262
+ entityWithReadOnlyAttribute
2263
+ .put({ prop1: "abc", prop2: "def", prop3: "ghi" })
2264
+ .params();
2265
+ entityWithReadOnlyAttribute
2266
+ .create({ prop1: "abc", prop2: "def", prop3: "ghi" })
2267
+ .params();
2268
+ // readonly
2269
+ (0, tsd_1.expectError)(() => {
2270
+ entityWithReadOnlyAttribute
2271
+ .update({ prop1: "abc", prop2: "def" })
2272
+ .set({ prop3: "abc" })
2273
+ .params();
2274
+ });
2275
+ // readonly
2276
+ (0, tsd_1.expectError)(() => {
2277
+ entityWithReadOnlyAttribute
2278
+ .update({ prop1: "abc", prop2: "def" })
2279
+ .add({ prop9: 13 })
2280
+ .params();
2281
+ });
2282
+ // readonly
2283
+ (0, tsd_1.expectError)(() => {
2284
+ entityWithReadOnlyAttribute
2285
+ .update({ prop1: "abc", prop2: "def" })
2286
+ .subtract({ prop9: 13 })
2287
+ .params();
2288
+ });
2289
+ // readonly
2290
+ (0, tsd_1.expectError)(() => {
2291
+ entityWithReadOnlyAttribute
2292
+ .update({ prop1: "abc", prop2: "def" })
2293
+ .delete({ prop10: "13" })
2294
+ .params();
2295
+ });
2296
+ // readonly
2297
+ // TODO: FIX ME
2298
+ (0, tsd_1.expectError)(() => {
2299
+ entityWithReadOnlyAttribute
2300
+ .update({ prop1: "abc", prop2: "def" })
2301
+ .append({ prop10: ["abc"] })
2302
+ .params();
2303
+ });
2304
+ // bad type - not number
2305
+ (0, tsd_1.expectError)(() => {
2306
+ entityWithReadOnlyAttribute
2307
+ .update({ prop1: "abc", prop2: "def" })
2308
+ .add({ prop7: 13 })
2309
+ .params();
2310
+ });
2311
+ // bad type - not number
2312
+ (0, tsd_1.expectError)(() => {
2313
+ entityWithReadOnlyAttribute
2314
+ .update({ prop1: "abc", prop2: "def" })
2315
+ .subtract({ prop7: 13 })
2316
+ .params();
2317
+ });
2318
+ // bad type - not string
2319
+ (0, tsd_1.expectError)(() => {
2320
+ entityWithReadOnlyAttribute
2321
+ .update({ prop1: "abc", prop2: "def" })
2322
+ // prop7 is string not number
2323
+ .data(({ prop7 }, { set }) => set(prop7, 5))
2324
+ .params();
2325
+ });
2326
+ // bad type - incorrect enum
2327
+ (0, tsd_1.expectError)(() => {
2328
+ entityWithReadOnlyAttribute
2329
+ .update({ prop1: "abc", prop2: "def" })
2330
+ // prop8 is enum with values ["abc", "def"]
2331
+ .data(({ prop8 }, { set }) => set(prop8, "ghi"))
2332
+ .params();
2333
+ });
2334
+ // bad type - not number
2335
+ (0, tsd_1.expectError)(() => {
2336
+ entityWithReadOnlyAttribute
2337
+ .update({ prop1: "abc", prop2: "def" })
2338
+ .data(({ prop7 }, { subtract }) => subtract(prop7, 5))
2339
+ .params();
2340
+ });
2341
+ // bad type - not number
2342
+ (0, tsd_1.expectError)(() => {
2343
+ entityWithReadOnlyAttribute
2344
+ .update({ prop1: "abc", prop2: "def" })
2345
+ .data(({ prop7 }, { add }) => add(prop7, 5))
2346
+ .params();
2347
+ });
2348
+ // bad type - not any
2349
+ (0, tsd_1.expectError)(() => {
2350
+ entityWithReadOnlyAttribute
2351
+ .update({ prop1: "abc", prop2: "def" })
2352
+ .data(({ prop7 }, { del }) => del(prop7, 5))
2353
+ .params();
2354
+ });
2355
+ // bad type - not any
2356
+ (0, tsd_1.expectError)(() => {
2357
+ entityWithReadOnlyAttribute
2358
+ .update({ prop1: "abc", prop2: "def" })
2359
+ .data(({ prop7 }, op) => op.delete(prop7, 5))
2360
+ .params();
2361
+ });
2362
+ // bad type - not any
2363
+ (0, tsd_1.expectError)(() => {
2364
+ entityWithReadOnlyAttribute
2365
+ .update({ prop1: "abc", prop2: "def" })
2366
+ .delete({ prop7: "13", prop5: 24 })
2367
+ .params();
2368
+ });
2369
+ // bad type - not any
2370
+ (0, tsd_1.expectError)(() => {
2371
+ entityWithReadOnlyAttribute
2372
+ .update({ prop1: "abc", prop2: "def" })
2373
+ .delete({ prop5: 24 })
2374
+ .params();
2375
+ });
2376
+ (0, tsd_1.expectError)(() => {
2377
+ entityWithReadOnlyAttribute
2378
+ .update({ prop1: "abc", prop2: "def" })
2379
+ .append({ prop7: "13", prop5: 24 })
2380
+ .params();
2381
+ });
2382
+ (0, tsd_1.expectError)(() => {
2383
+ entityWithReadOnlyAttribute
2384
+ .update({ prop1: "abc", prop2: "def" })
2385
+ .append({ prop5: 24 })
2386
+ .params();
2387
+ });
2388
+ // readonly
2389
+ (0, tsd_1.expectError)(() => {
2390
+ entityWithReadOnlyAttribute
2391
+ .update({ prop1: "abc", prop2: "def" })
2392
+ .remove(["prop3"])
2393
+ .params();
2394
+ });
2395
+ // readonly
2396
+ (0, tsd_1.expectError)(() => {
2397
+ entityWithReadOnlyAttribute
2398
+ .update({ prop1: "abc", prop2: "def" })
2399
+ .data(({ prop3 }, { remove }) => {
2400
+ remove(prop3);
2401
+ })
2402
+ .params();
2403
+ });
2404
+ (0, tsd_1.expectError)(() => {
2405
+ entityWithReadOnlyAttribute
2406
+ .update({ prop1: "abc", prop2: "def" })
2407
+ .data(({ prop5 }, { append }) => {
2408
+ append(prop5, 25);
2409
+ })
2410
+ .params();
2411
+ });
2412
+ // patch
2413
+ (0, tsd_1.expectError)(() => {
2414
+ entityWithReadOnlyAttribute
2415
+ .patch({ prop1: "abc", prop2: "def" })
2416
+ .set({ prop3: "abc" })
2417
+ .params();
2418
+ });
2419
+ (0, tsd_1.expectError)(() => {
2420
+ entityWithReadOnlyAttribute
2421
+ .patch({ prop1: "abc", prop2: "def" })
2422
+ .add({ prop7: 13 })
2423
+ .params();
2424
+ });
2425
+ (0, tsd_1.expectError)(() => {
2426
+ entityWithReadOnlyAttribute
2427
+ .patch({ prop1: "abc", prop2: "def" })
2428
+ .subtract({ prop7: 13 })
2429
+ .params();
2430
+ });
2431
+ (0, tsd_1.expectError)(() => {
2432
+ entityWithReadOnlyAttribute
2433
+ .patch({ prop1: "abc", prop2: "def" })
2434
+ .delete({ prop7: "13", prop5: 24 })
2435
+ .params();
2436
+ });
2437
+ (0, tsd_1.expectError)(() => {
2438
+ entityWithReadOnlyAttribute
2439
+ .patch({ prop1: "abc", prop2: "def" })
2440
+ .delete({ prop5: 24 })
2441
+ .params();
2442
+ });
2443
+ (0, tsd_1.expectError)(() => {
2444
+ entityWithReadOnlyAttribute
2445
+ .patch({ prop1: "abc", prop2: "def" })
2446
+ .append({ prop7: "13", prop5: 24 })
2447
+ .params();
2448
+ });
2449
+ (0, tsd_1.expectError)(() => {
2450
+ entityWithReadOnlyAttribute
2451
+ .patch({ prop1: "abc", prop2: "def" })
2452
+ .append({ prop5: 24 })
2453
+ .params();
2454
+ });
2455
+ (0, tsd_1.expectError)(() => {
2456
+ entityWithReadOnlyAttribute
2457
+ .patch({ prop1: "abc", prop2: "def" })
2458
+ .remove(["prop3"])
2459
+ .params();
2460
+ });
2461
+ (0, tsd_1.expectError)(() => {
2462
+ entityWithReadOnlyAttribute
2463
+ .patch({ prop1: "abc", prop2: "def" })
2464
+ .remove(["prop3"])
2465
+ .params();
2466
+ });
2467
+ let setItemValue = {};
2468
+ entityWithReadOnlyAttribute
2469
+ .update({ prop1: "abc", prop2: "def" })
2470
+ .set(setItemValue)
2471
+ .params();
2472
+ entityWithReadOnlyAttribute
2473
+ .update({ prop1: "abc", prop2: "def" })
2474
+ .remove(["prop4"])
2475
+ .params();
2476
+ entityWithReadOnlyAttribute
2477
+ .update({ prop1: "abc", prop2: "def" })
2478
+ .add({
2479
+ prop5: 13,
2480
+ })
2481
+ .params();
2482
+ entityWithReadOnlyAttribute
2483
+ .update({ prop1: "abc", prop2: "def" })
2484
+ .subtract({
2485
+ prop5: 13,
2486
+ })
2487
+ .params();
2488
+ entityWithReadOnlyAttribute
2489
+ .update({ prop1: "abc", prop2: "def" })
2490
+ .append({
2491
+ prop6: ["value"],
2492
+ })
2493
+ .params();
2494
+ entityWithReadOnlyAttribute
2495
+ .update({ prop1: "abc", prop2: "def" })
2496
+ .delete({
2497
+ prop6: ["value"],
2498
+ })
2499
+ .params();
2500
+ // full chain with duplicates
2501
+ entityWithReadOnlyAttribute
2502
+ .update({ prop1: "abc", prop2: "def" })
2503
+ .set(setItemValue)
2504
+ .remove(["prop4"])
2505
+ .add({
2506
+ prop5: 13,
2507
+ })
2508
+ .subtract({
2509
+ prop5: 13,
2510
+ })
2511
+ .append({
2512
+ prop6: ["value"],
2513
+ })
2514
+ .delete({
2515
+ prop6: ["value"],
2516
+ })
2517
+ .set(setItemValue)
2518
+ .remove(["prop4"])
2519
+ .data((attr, op) => {
2520
+ op.set(attr.prop4, "abc");
2521
+ op.set(attr.prop5, 134);
2522
+ op.set(attr.prop6, "def");
2523
+ op.set(attr.prop6, 123);
2524
+ op.set(attr.prop6, true);
2525
+ op.set(attr.prop6[1], true);
2526
+ op.set(attr.prop6.prop1, true);
2527
+ op.set(attr.prop8, "def");
2528
+ op.remove(attr.prop4);
2529
+ op.remove(attr.prop5);
2530
+ op.remove(attr.prop6);
2531
+ op.remove(attr.prop6);
2532
+ op.remove(attr.prop6);
2533
+ op.remove(attr.prop6[1]);
2534
+ op.remove(attr.prop6.prop1);
2535
+ op.remove(attr.prop8);
2536
+ op.append(attr.prop6, ["abc"]);
2537
+ op.append(attr.prop6, ["abc"]);
2538
+ op.append(attr.prop6, ["abc"]);
2539
+ op.append(attr.prop6[1], ["abc"]);
2540
+ op.append(attr.prop6.prop1, ["abc"]);
2541
+ op.delete(attr.prop6, ["abc"]);
2542
+ op.delete(attr.prop6, ["abc"]);
2543
+ op.delete(attr.prop6, ["abc"]);
2544
+ op.delete(attr.prop6[1], ["abc"]);
2545
+ op.delete(attr.prop6.prop1, ["abc"]);
2546
+ op.del(attr.prop6, ["abc"]);
2547
+ op.del(attr.prop6, ["abc"]);
2548
+ op.del(attr.prop6, ["abc"]);
2549
+ op.del(attr.prop6[1], ["abc"]);
2550
+ op.del(attr.prop6.prop1, ["abc"]);
2551
+ op.name(attr.prop4);
2552
+ op.name(attr.prop5);
2553
+ op.name(attr.prop6);
2554
+ op.name(attr.prop6);
2555
+ op.name(attr.prop6);
2556
+ op.name(attr.prop6[1]);
2557
+ op.name(attr.prop6.prop1);
2558
+ op.name(attr.prop8);
2559
+ op.value(attr.prop4, "abc");
2560
+ op.value(attr.prop5, 134);
2561
+ op.value(attr.prop6, "abc");
2562
+ op.value(attr.prop6, "abc");
2563
+ op.value(attr.prop6, "abc");
2564
+ op.value(attr.prop6[1], "abc");
2565
+ op.value(attr.prop6.prop1, "abc");
2566
+ op.value(attr.prop8, "abc");
2567
+ })
2568
+ .add({
2569
+ prop5: 13,
2570
+ })
2571
+ .subtract({
2572
+ prop5: 13,
2573
+ })
2574
+ .append({
2575
+ prop6: ["value"],
2576
+ })
2577
+ .delete({
2578
+ prop6: ["value"],
2579
+ })
2580
+ .params();
2581
+ const names = "";
2582
+ // complexService.collections
2583
+ // .mycollection1({attr9: 123, attr6: 245})
2584
+ // .page()
2585
+ // .then(([next, results]) => {
2586
+ // expectType<string | undefined>(next?.attr1);
2587
+ // expectType<string | undefined>(next?.attr2);
2588
+ // expectType<number | undefined>(next?.attr6);
2589
+ // expectType<number | undefined>(next?.attr9);
2590
+ // expectType<"abc" | "def" | "ghi" | undefined>(next?.attr4);
2591
+ // expectType<string | undefined>(next?.attr5);
2592
+ // expectType<number | undefined>(next?.prop5);
2593
+ // expectType<string | undefined>(next?.prop1);
2594
+ // expectType<string | undefined>(next?.prop2);
2595
+ // expectType<string | undefined>(next?.__edb_e__);
2596
+ // expectType<string | undefined>(next?.__edb_v__);
2597
+ // expectAssignable<typeof next>({
2598
+ // attr1: "abc",
2599
+ // attr2: "abc",
2600
+ // attr6: 27,
2601
+ // attr9: 89,
2602
+ // attr4: "abc",
2603
+ // attr5: "abc",
2604
+ // __edb_e__: "entityWithSK",
2605
+ // __edb_v__: "1"
2606
+ // });
2607
+ // expectAssignable<typeof next>({
2608
+ // prop1: "abc",
2609
+ // prop2: "abc",
2610
+ // attr6: 27,
2611
+ // attr9: 89,
2612
+ // prop5: 12,
2613
+ // __edb_e__: "normalEntity2",
2614
+ // __edb_v__: "1"
2615
+ // });
2616
+ // expectAssignable<typeof next>({
2617
+ // attr1: "abc",
2618
+ // attr6: 27,
2619
+ // attr9: 89,
2620
+ // __edb_e__: "entityWithoutSK",
2621
+ // __edb_v__: "1"
2622
+ // });
2623
+ // expectType<keyof typeof results>(names);
2624
+ // expectNotType<any>(next);
2625
+ // })
2626
+ complexService.collections
2627
+ .mycollection1({ attr9: 123, attr6: 245 })
2628
+ .go({ cursor: null });
2629
+ complexService.collections
2630
+ .mycollection1({ attr9: 123, attr6: 245 })
2631
+ .go({ cursor: "abc" });
2632
+ complexService.entities.entityWithSK
2633
+ .remove({ attr1: "abc", attr2: "def" })
2634
+ .where((attr, op) => op.eq(attr.attr9, 14))
2635
+ .go();
2636
+ const entityWithMultipleCollections1 = new _1.Entity({
2637
+ model: {
2638
+ entity: "entity1",
2639
+ service: "myservice",
2640
+ version: "myversion",
2641
+ },
2642
+ attributes: {
2643
+ attr1: {
2644
+ type: "string",
2645
+ },
2646
+ attr2: {
2647
+ type: "string",
2648
+ },
2649
+ },
2650
+ indexes: {
2651
+ myIndex: {
2652
+ collection: ["outercollection", "innercollection"],
2653
+ pk: {
2654
+ field: "pk",
2655
+ composite: ["attr1"],
2656
+ },
2657
+ sk: {
2658
+ field: "sk",
2659
+ composite: ["attr2"],
2660
+ },
2661
+ },
2662
+ },
2663
+ });
2664
+ const entityWithMultipleCollections2 = new _1.Entity({
2665
+ model: {
2666
+ entity: "entity2",
2667
+ service: "myservice",
2668
+ version: "myversion",
2669
+ },
2670
+ attributes: {
2671
+ attr1: {
2672
+ type: "string",
2673
+ },
2674
+ attr2: {
2675
+ type: "string",
2676
+ },
2677
+ },
2678
+ indexes: {
2679
+ myIndex: {
2680
+ collection: ["outercollection", "innercollection"],
2681
+ pk: {
2682
+ field: "pk",
2683
+ composite: ["attr1"],
2684
+ },
2685
+ sk: {
2686
+ field: "sk",
2687
+ composite: ["attr2"],
2688
+ },
2689
+ },
2690
+ myIndex2: {
2691
+ index: "index2",
2692
+ collection: ["extracollection"],
2693
+ pk: {
2694
+ field: "index2pk",
2695
+ composite: ["attr1"],
2696
+ },
2697
+ sk: {
2698
+ field: "index2sk",
2699
+ composite: ["attr2"],
2700
+ },
2701
+ },
2702
+ },
2703
+ });
2704
+ const entityWithMultipleCollections3 = new _1.Entity({
2705
+ model: {
2706
+ entity: "entity3",
2707
+ service: "myservice",
2708
+ version: "myversion",
2709
+ },
2710
+ attributes: {
2711
+ attr1: {
2712
+ type: "string",
2713
+ },
2714
+ attr2: {
2715
+ type: "string",
2716
+ },
2717
+ },
2718
+ indexes: {
2719
+ myIndex: {
2720
+ collection: "outercollection",
2721
+ pk: {
2722
+ field: "pk",
2723
+ composite: ["attr1"],
2724
+ },
2725
+ sk: {
2726
+ field: "sk",
2727
+ composite: ["attr2"],
2728
+ },
2729
+ },
2730
+ myIndex2: {
2731
+ index: "index2",
2732
+ collection: "extracollection",
2733
+ pk: {
2734
+ field: "index2pk",
2735
+ composite: ["attr1"],
2736
+ },
2737
+ sk: {
2738
+ field: "index2sk",
2739
+ composite: ["attr2"],
2740
+ },
2741
+ },
2742
+ },
2743
+ });
2744
+ const serviceWithMultipleCollections = new _1.Service({
2745
+ entityWithMultipleCollections3,
2746
+ entityWithMultipleCollections1,
2747
+ entityWithMultipleCollections2,
2748
+ });
2749
+ serviceWithMultipleCollections.collections
2750
+ .outercollection({ attr1: "abc" })
2751
+ .go()
2752
+ .then((res) => {
2753
+ const keys = "";
2754
+ (0, tsd_1.expectType)(keys);
2755
+ });
2756
+ serviceWithMultipleCollections.collections
2757
+ .innercollection({ attr1: "abc" })
2758
+ .go()
2759
+ .then((res) => {
2760
+ const keys = "";
2761
+ (0, tsd_1.expectType)(keys);
2762
+ });
2763
+ serviceWithMultipleCollections.collections
2764
+ .extracollection({ attr1: "abc" })
2765
+ .go()
2766
+ .then((res) => {
2767
+ const keys = "";
2768
+ (0, tsd_1.expectType)(keys);
2769
+ });
2770
+ const entityWithWatchAll = new _1.Entity({
2771
+ model: {
2772
+ entity: "withwatchall",
2773
+ service: "service",
2774
+ version: "1",
2775
+ },
2776
+ attributes: {
2777
+ prop1: {
2778
+ type: "string",
2779
+ },
2780
+ prop2: {
2781
+ type: "string",
2782
+ },
2783
+ prop3: {
2784
+ type: "string",
2785
+ watch: "*",
2786
+ set: (value) => {
2787
+ return value;
2788
+ },
2789
+ },
2790
+ },
2791
+ indexes: {
2792
+ record: {
2793
+ pk: {
2794
+ field: "pk",
2795
+ composite: ["prop1"],
2796
+ },
2797
+ sk: {
2798
+ field: "sk",
2799
+ composite: ["prop2"],
2800
+ },
2801
+ },
2802
+ },
2803
+ });
2804
+ const entityWithComplexShapes = new _1.Entity({
2805
+ model: {
2806
+ entity: "entity",
2807
+ service: "service",
2808
+ version: "1",
2809
+ },
2810
+ attributes: {
2811
+ prop1: {
2812
+ type: "string",
2813
+ label: "props",
2814
+ },
2815
+ prop2: {
2816
+ type: "string",
2817
+ },
2818
+ prop3: {
2819
+ type: "map",
2820
+ properties: {
2821
+ val1: {
2822
+ type: "string",
2823
+ },
2824
+ },
2825
+ },
2826
+ prop4: {
2827
+ type: "list",
2828
+ items: {
2829
+ type: "map",
2830
+ properties: {
2831
+ val2: {
2832
+ type: "number",
2833
+ },
2834
+ val3: {
2835
+ type: "list",
2836
+ items: {
2837
+ type: "string",
2838
+ },
2839
+ },
2840
+ val4: {
2841
+ type: "set",
2842
+ items: "number",
2843
+ },
2844
+ },
2845
+ },
2846
+ },
2847
+ prop5: {
2848
+ type: "set",
2849
+ items: "string",
2850
+ },
2851
+ prop6: {
2852
+ type: "set",
2853
+ items: "string",
2854
+ },
2855
+ },
2856
+ indexes: {
2857
+ record: {
2858
+ collection: "mops",
2859
+ pk: {
2860
+ field: "pk",
2861
+ composite: ["prop1"],
2862
+ },
2863
+ sk: {
2864
+ field: "sk",
2865
+ composite: ["prop2"],
2866
+ },
2867
+ },
2868
+ },
2869
+ });
2870
+ const entityWithComplexShapesRequired = new _1.Entity({
2871
+ model: {
2872
+ entity: "entity",
2873
+ service: "service",
2874
+ version: "1",
2875
+ },
2876
+ attributes: {
2877
+ prop1: {
2878
+ type: "string",
2879
+ label: "props",
2880
+ },
2881
+ prop2: {
2882
+ type: "string",
2883
+ },
2884
+ attr3: {
2885
+ type: "map",
2886
+ properties: {
2887
+ val1: {
2888
+ type: "string",
2889
+ required: true,
2890
+ },
2891
+ },
2892
+ required: true,
2893
+ },
2894
+ attr4: {
2895
+ type: "list",
2896
+ items: {
2897
+ type: "map",
2898
+ properties: {
2899
+ val2: {
2900
+ type: "number",
2901
+ required: true,
2902
+ },
2903
+ val3: {
2904
+ type: "list",
2905
+ items: {
2906
+ type: "string",
2907
+ required: true,
2908
+ },
2909
+ required: true,
2910
+ },
2911
+ val4: {
2912
+ type: "set",
2913
+ items: "number",
2914
+ required: true,
2915
+ },
2916
+ },
2917
+ },
2918
+ required: true,
2919
+ },
2920
+ attr5: {
2921
+ type: "set",
2922
+ items: "string",
2923
+ required: true,
2924
+ },
2925
+ attr6: {
2926
+ type: "set",
2927
+ items: "string",
2928
+ required: true,
2929
+ },
2930
+ },
2931
+ indexes: {
2932
+ record: {
2933
+ collection: "mops",
2934
+ pk: {
2935
+ field: "pk",
2936
+ composite: ["prop1"],
2937
+ },
2938
+ sk: {
2939
+ field: "sk",
2940
+ composite: ["prop2"],
2941
+ },
2942
+ },
2943
+ },
2944
+ });
2945
+ const entityWithComplexShapesRequiredOnEdge = new _1.Entity({
2946
+ model: {
2947
+ entity: "entity",
2948
+ service: "service",
2949
+ version: "1",
2950
+ },
2951
+ attributes: {
2952
+ prop1: {
2953
+ type: "string",
2954
+ label: "props",
2955
+ },
2956
+ prop2: {
2957
+ type: "string",
2958
+ },
2959
+ attrz3: {
2960
+ type: "map",
2961
+ properties: {
2962
+ val1: {
2963
+ type: "string",
2964
+ required: true,
2965
+ validate: /./gi,
2966
+ },
2967
+ },
2968
+ },
2969
+ attrz4: {
2970
+ type: "list",
2971
+ items: {
2972
+ type: "map",
2973
+ properties: {
2974
+ val2: {
2975
+ type: "number",
2976
+ required: true,
2977
+ },
2978
+ val3: {
2979
+ type: "list",
2980
+ items: {
2981
+ type: "string",
2982
+ required: true,
2983
+ },
2984
+ },
2985
+ val4: {
2986
+ type: "set",
2987
+ items: "number",
2988
+ },
2989
+ val5: {
2990
+ type: "map",
2991
+ properties: {
2992
+ val6: {
2993
+ type: "string",
2994
+ required: true,
2995
+ },
2996
+ },
2997
+ },
2998
+ },
2999
+ },
3000
+ },
3001
+ attrz5: {
3002
+ type: "set",
3003
+ items: "string",
3004
+ },
3005
+ attrz6: {
3006
+ type: "set",
3007
+ items: "string",
3008
+ },
3009
+ },
3010
+ indexes: {
3011
+ record: {
3012
+ collection: "mops",
3013
+ pk: {
3014
+ field: "pk",
3015
+ composite: ["prop1"],
3016
+ },
3017
+ sk: {
3018
+ field: "sk",
3019
+ composite: ["prop2"],
3020
+ },
3021
+ },
3022
+ },
3023
+ });
3024
+ const complexShapeService = new _1.Service({
3025
+ ent1: entityWithComplexShapesRequiredOnEdge,
3026
+ ent2: entityWithComplexShapes,
3027
+ ent3: entityWithComplexShapesRequired,
3028
+ });
3029
+ const parsed = entityWithComplexShapes.parse({});
3030
+ entityWithComplexShapes.query
3031
+ .record({ prop1: "abc" })
3032
+ .go()
3033
+ .then((res) => {
3034
+ (0, tsd_1.expectType)(entityWithComplexShapes.parse({
3035
+ Items: [],
3036
+ }));
3037
+ });
3038
+ (0, tsd_1.expectError)(() => {
3039
+ entityWithSK.parse({ Items: [] }, {
3040
+ attributes: ["attr1", "oops"],
3041
+ });
3042
+ });
3043
+ const parsedWithAttributes = entityWithSK.parse({ Items: [] }, {
3044
+ attributes: ["attr1", "attr2", "attr3"],
3045
+ });
3046
+ const parsedWithAttributesSingle = entityWithSK.parse({ Item: {} }, {
3047
+ attributes: ["attr1", "attr2", "attr3"],
3048
+ });
3049
+ (0, tsd_1.expectType)(magnify(parsedWithAttributes.data));
3050
+ (0, tsd_1.expectType)(magnify(parsedWithAttributesSingle.data));
3051
+ entityWithComplexShapes
3052
+ .get({ prop1: "abc", prop2: "def" })
3053
+ .go()
3054
+ .then((res) => {
3055
+ (0, tsd_1.expectType)(res);
3056
+ if (res.data === null) {
3057
+ return null;
3058
+ }
3059
+ res.data.prop3?.val1;
3060
+ let int = 0;
3061
+ if (Array.isArray(res.data.prop4)) {
3062
+ for (let value of res.data.prop4) {
3063
+ if (typeof value === "string") {
3064
+ if (isNaN(parseInt(value))) {
3065
+ int += 0;
3066
+ }
3067
+ else {
3068
+ int += parseInt(value);
3069
+ }
3070
+ }
3071
+ else if (typeof value === "number") {
3072
+ int += value;
3073
+ }
3074
+ else if (Array.isArray(value)) {
3075
+ for (let val of value) {
3076
+ int += val.val2;
3077
+ }
3078
+ }
3079
+ else {
3080
+ (0, tsd_1.expectType)(value.val2);
3081
+ int += value?.val2 ?? 0;
3082
+ }
3083
+ }
3084
+ }
3085
+ return res.data.prop3?.val1;
3086
+ });
3087
+ entityWithComplexShapes
3088
+ .get({ prop1: "abc", prop2: "def" })
3089
+ .go()
3090
+ .then((res) => {
3091
+ if (res.data !== null) {
3092
+ res.data.prop5?.map((values) => values);
3093
+ res.data.prop6?.map((values) => values);
3094
+ }
3095
+ });
3096
+ entityWithComplexShapes
3097
+ .update({ prop1: "abc", prop2: "def" })
3098
+ .set({
3099
+ prop4: [
3100
+ {
3101
+ val2: 789,
3102
+ val3: ["123"],
3103
+ val4: [123, 456],
3104
+ },
3105
+ ],
3106
+ prop5: ["abc"],
3107
+ })
3108
+ .go();
3109
+ entityWithComplexShapes
3110
+ .put({
3111
+ prop1: "abc",
3112
+ prop2: "def",
3113
+ prop4: [
3114
+ {
3115
+ val2: 789,
3116
+ val3: ["123"],
3117
+ val4: [123, 456],
3118
+ },
3119
+ ],
3120
+ prop5: ["abc"],
3121
+ })
3122
+ .go();
3123
+ entityWithComplexShapes
3124
+ .update({ prop1: "abc", prop2: "def" })
3125
+ .set({
3126
+ prop4: [
3127
+ {
3128
+ val2: 789,
3129
+ val3: ["123"],
3130
+ // val4: [1, 2, 3]
3131
+ },
3132
+ ],
3133
+ prop5: ["abc"],
3134
+ })
3135
+ .where(({ prop5 }, { eq }) => eq(prop5, ["abc"]))
3136
+ .where(({ prop1 }, { eq }) => eq(prop1, "abc"))
3137
+ .go();
3138
+ entityWithComplexShapes
3139
+ .update({ prop1: "abc", prop2: "def" })
3140
+ .append({
3141
+ prop4: [
3142
+ {
3143
+ val2: 789,
3144
+ val3: ["123"],
3145
+ val4: [1, 2, 3],
3146
+ },
3147
+ ],
3148
+ })
3149
+ .data(({ prop5, prop4 }, { add, append, remove }) => {
3150
+ add(prop5, ["abc"]);
3151
+ append(prop4[0].val3, ["123"]);
3152
+ append(prop4, [
3153
+ {
3154
+ val2: 789,
3155
+ val3: ["123"],
3156
+ val4: [1, 2, 3],
3157
+ },
3158
+ ]);
3159
+ add(prop4[0].val2, 789);
3160
+ add(prop4[0].val4, [1]);
3161
+ remove(prop4[0].val4);
3162
+ remove(prop4[0].val3);
3163
+ remove(prop4[0].val2);
3164
+ })
3165
+ .go();
3166
+ (0, tsd_1.expectError)(() => {
3167
+ entityWithComplexShapes
3168
+ .update({ prop1: "abc", prop2: "def" })
3169
+ .append({
3170
+ prop4: [
3171
+ {
3172
+ val2: 789,
3173
+ val3: ["123"],
3174
+ val4: [1, 2, 3],
3175
+ },
3176
+ ],
3177
+ prop5: ["abc"],
3178
+ })
3179
+ .go();
3180
+ });
3181
+ const updateWithWhere = entityWithComplexShapes
3182
+ .update({
3183
+ prop1: "abc",
3184
+ prop2: "def",
3185
+ })
3186
+ .data((attr, op) => { })
3187
+ .where((attr, op) => op.eq(attr.prop3.val1, "def")).go;
3188
+ const updateWithoutWhere = entityWithComplexShapes
3189
+ .update({
3190
+ prop1: "abc",
3191
+ prop2: "def",
3192
+ })
3193
+ .data((attr, op) => { }).go;
3194
+ const updateWithWhereGoOption = {};
3195
+ const updateWithOutWhereGoOptions = {};
3196
+ (0, tsd_1.expectType)(updateWithWhereGoOption);
3197
+ (0, tsd_1.expectType)(updateWithOutWhereGoOptions);
3198
+ entityWithComplexShapes
3199
+ .update({
3200
+ prop1: "abc",
3201
+ prop2: "def",
3202
+ })
3203
+ .data((attr, op) => { })
3204
+ .where((attr, op) => op.eq(attr.prop3.val1, "def"))
3205
+ .go({})
3206
+ .then((res) => {
3207
+ (0, tsd_1.expectType)(res);
3208
+ });
3209
+ entityWithComplexShapes
3210
+ .patch({
3211
+ prop1: "abc",
3212
+ prop2: "def",
3213
+ })
3214
+ .data((attr, op) => { })
3215
+ .where((attr, op) => op.eq(attr.prop3.val1, "def"))
3216
+ .go({
3217
+ response: "all_new",
3218
+ })
3219
+ .then((res) => {
3220
+ (0, tsd_1.expectType)(res.data);
3221
+ });
3222
+ entityWithComplexShapes
3223
+ .update({
3224
+ prop1: "abc",
3225
+ prop2: "def",
3226
+ })
3227
+ .set({})
3228
+ .where((attr, op) => op.eq(attr.prop3.val1, "def"))
3229
+ .go({
3230
+ originalErr: true,
3231
+ })
3232
+ .then((res) => {
3233
+ (0, tsd_1.expectType)(magnify(res.data));
3234
+ });
3235
+ entityWithComplexShapes
3236
+ .update({
3237
+ prop1: "abc",
3238
+ prop2: "def",
3239
+ })
3240
+ .set({ prop6: ["sb"] })
3241
+ .data((attr, op) => {
3242
+ op.append(attr.prop5, ["sweet"]);
3243
+ })
3244
+ .where((attr, op) => op.eq(attr.prop2, "def"))
3245
+ .go({})
3246
+ .then((res) => {
3247
+ (0, tsd_1.expectType)(res);
3248
+ });
3249
+ entityWithComplexShapes
3250
+ .remove({
3251
+ prop1: "abc",
3252
+ prop2: "def",
3253
+ })
3254
+ .where((attr, op) => op.eq(attr.prop3.val1, "def"))
3255
+ .go({
3256
+ response: "all_old",
3257
+ });
3258
+ entityWithComplexShapes
3259
+ .put({
3260
+ prop1: "abc",
3261
+ prop2: "def",
3262
+ })
3263
+ .where((attr, op) => op.eq(attr.prop3.val1, "def"))
3264
+ .go({
3265
+ response: "all_old",
3266
+ });
3267
+ (0, tsd_1.expectError)(() => {
3268
+ entityWithComplexShapes
3269
+ .update({ prop1: "abc", prop2: "def" })
3270
+ .data(({ prop1 }, { remove }) => {
3271
+ remove(prop1);
3272
+ })
3273
+ .go();
3274
+ });
3275
+ entityWithComplexShapes
3276
+ .update({ prop1: "abc", prop2: "def" })
3277
+ .set({
3278
+ prop4: [
3279
+ {
3280
+ val2: 789,
3281
+ val3: ["123"],
3282
+ val4: [1, 2, 3],
3283
+ },
3284
+ ],
3285
+ prop5: ["abc"],
3286
+ })
3287
+ .go();
3288
+ entityWithComplexShapesRequired.put({
3289
+ prop1: "abc",
3290
+ prop2: "def",
3291
+ attr3: {
3292
+ val1: "abc",
3293
+ },
3294
+ attr4: [
3295
+ {
3296
+ val2: 789,
3297
+ val3: ["123"],
3298
+ val4: [1, 2, 3],
3299
+ },
3300
+ ],
3301
+ attr5: ["abc"],
3302
+ attr6: ["abdbdb"],
3303
+ });
3304
+ (0, tsd_1.expectError)(() => {
3305
+ entityWithComplexShapesRequired.put({});
3306
+ });
3307
+ (0, tsd_1.expectError)(() => {
3308
+ entityWithComplexShapesRequired.put({ prop1: "abc", prop2: "def" });
3309
+ });
3310
+ complexShapeService.collections.mops({ prop1: "abc" }).where((a, op) => {
3311
+ op.eq(a.attr3.val1, "abd");
3312
+ (0, tsd_1.expectError)(() => op.eq(a.attr3, "abc"));
3313
+ (0, tsd_1.expectError)(() => op.eq(a.attr3.val2, "abc"));
3314
+ (0, tsd_1.expectError)(() => op.eq(a.attr3.val1, 123));
3315
+ op.between(a.attr4[0].val2, 789, 888);
3316
+ (0, tsd_1.expectError)(() => op.eq(a.attr4, "abc"));
3317
+ (0, tsd_1.expectError)(() => op.eq(a.attr4.val2, "abc"));
3318
+ (0, tsd_1.expectError)(() => op.eq(a.attr4[0].val2, "456"));
3319
+ op.between(a.attr4[0].val3[1], "xyz", "123");
3320
+ // expectNotAssignable<"abc">(a.attr4[1].val3[1]);
3321
+ // expectNotAssignable<typeof (a.attr4[1].val3)>(["abc"]);
3322
+ // expectError(() => op.eq(a.attr4[1].val3["def"], "xyz"));
3323
+ op.gte(a.attr5, ["abc"]);
3324
+ op.eq(a.attrz3.val1, "abd");
3325
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3, "abc"));
3326
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3.val2, "abc"));
3327
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3.val1, 123));
3328
+ op.between(a.attrz4[0].val2, 789, 888);
3329
+ // expectNotAssignable<"abc">(a.attrz4[1].val3[1]);
3330
+ // expectNotAssignable<["abc"]>(a.attrz4[1].val3);
3331
+ (0, tsd_1.expectError)(() => op.eq(a.attrz4[0].val2, "456"));
3332
+ op.between(a.attrz4[0].val3[1], "xyz", "123");
3333
+ // expectError(() => op.eq(a.attr4[1].val3[1], "abc"));
3334
+ // expectError(() => op.eq(a.attr4[1].val3["def"], "xyz"));
3335
+ op.gte(a.attrz5, ["abc"]);
3336
+ op.eq(a.prop3.val1, "abd");
3337
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3, "abc"));
3338
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3.val2, "abc"));
3339
+ (0, tsd_1.expectError)(() => op.eq(a.attrz3.val1, 123));
3340
+ op.between(a.prop4[0].val2, 789, 888);
3341
+ op.between(a.prop4[0].val3[1], "xyz", "123");
3342
+ op.gte(a.prop5, ["abc"]);
3343
+ op.eq(a.prop2, "def");
3344
+ op.contains(a.prop4[1].val3[2], "123");
3345
+ return "";
3346
+ });
3347
+ const complex = new _1.Entity({
3348
+ model: {
3349
+ entity: "user",
3350
+ service: "versioncontrol",
3351
+ version: "1",
3352
+ },
3353
+ attributes: {
3354
+ username: {
3355
+ type: "string",
3356
+ },
3357
+ stringVal: {
3358
+ type: "string",
3359
+ default: () => "abc",
3360
+ validate: (value) => value !== undefined,
3361
+ get: (value) => {
3362
+ return value;
3363
+ },
3364
+ set: (value) => {
3365
+ return value;
3366
+ },
3367
+ },
3368
+ enumVal: {
3369
+ type: ["abc", "def"],
3370
+ validate: (value) => value !== undefined,
3371
+ default: () => "abc",
3372
+ get: (value) => {
3373
+ return value;
3374
+ },
3375
+ set: (value) => {
3376
+ return value;
3377
+ },
3378
+ },
3379
+ numVal: {
3380
+ type: "number",
3381
+ validate: (value) => value !== undefined,
3382
+ default: () => 123,
3383
+ get: (value) => {
3384
+ return value;
3385
+ },
3386
+ set: (value) => {
3387
+ return value;
3388
+ },
3389
+ },
3390
+ boolValue: {
3391
+ type: "boolean",
3392
+ validate: (value) => value !== undefined,
3393
+ default: () => true,
3394
+ get: (value) => {
3395
+ return value;
3396
+ },
3397
+ set: (value) => {
3398
+ return value;
3399
+ },
3400
+ },
3401
+ stringSetValue: {
3402
+ type: "set",
3403
+ items: "string",
3404
+ validate: (value) => value !== undefined,
3405
+ default: () => ["abc"],
3406
+ get: (value) => {
3407
+ return value;
3408
+ },
3409
+ set: (value) => {
3410
+ return value;
3411
+ },
3412
+ },
3413
+ numberSetValue: {
3414
+ type: "set",
3415
+ items: "number",
3416
+ validate: (value) => value !== undefined,
3417
+ default: () => [1],
3418
+ get: (value) => {
3419
+ return value;
3420
+ },
3421
+ set: (value) => {
3422
+ return value;
3423
+ },
3424
+ },
3425
+ stringListValue: {
3426
+ type: "list",
3427
+ items: {
3428
+ type: "string",
3429
+ default: "abc",
3430
+ validate: (value) => value !== undefined,
3431
+ get: (value) => {
3432
+ return value;
3433
+ },
3434
+ set: (value) => {
3435
+ return value;
3436
+ },
3437
+ },
3438
+ default: ["abc"],
3439
+ validate: (value) => value !== undefined,
3440
+ get: (value) => {
3441
+ return value;
3442
+ },
3443
+ set: (value) => {
3444
+ return value;
3445
+ },
3446
+ },
3447
+ numberListValue: {
3448
+ type: "list",
3449
+ items: {
3450
+ type: "number",
3451
+ validate: (value) => value !== undefined,
3452
+ default: 0,
3453
+ get: (value) => {
3454
+ return value;
3455
+ },
3456
+ set: (value) => {
3457
+ return value;
3458
+ },
3459
+ },
3460
+ default: [],
3461
+ validate: (value) => value !== undefined,
3462
+ get: (value) => {
3463
+ return value;
3464
+ },
3465
+ set: (value) => {
3466
+ return value;
3467
+ },
3468
+ },
3469
+ mapListValue: {
3470
+ type: "list",
3471
+ items: {
3472
+ type: "map",
3473
+ properties: {
3474
+ stringVal: {
3475
+ type: "string",
3476
+ default: "def",
3477
+ validate: (value) => value !== undefined,
3478
+ get: (value) => {
3479
+ return value;
3480
+ },
3481
+ set: (value) => {
3482
+ return value;
3483
+ },
3484
+ },
3485
+ numVal: {
3486
+ type: "number",
3487
+ default: 5,
3488
+ validate: (value) => value !== undefined,
3489
+ get: (value) => {
3490
+ return value;
3491
+ },
3492
+ set: (value) => {
3493
+ return value;
3494
+ },
3495
+ },
3496
+ boolValue: {
3497
+ type: "boolean",
3498
+ default: false,
3499
+ validate: (value) => value !== undefined,
3500
+ get: (value) => {
3501
+ return value;
3502
+ },
3503
+ set: (value) => {
3504
+ return value;
3505
+ },
3506
+ },
3507
+ enumVal: {
3508
+ type: ["abc", "def"],
3509
+ validate: (value) => value !== undefined,
3510
+ default: () => "abc",
3511
+ get: (value) => {
3512
+ return value;
3513
+ },
3514
+ set: (value) => {
3515
+ return value;
3516
+ },
3517
+ },
3518
+ },
3519
+ validate: (value) => value !== undefined,
3520
+ default: {
3521
+ stringVal: "abc",
3522
+ numVal: 123,
3523
+ boolValue: false,
3524
+ },
3525
+ get: (value) => {
3526
+ return value;
3527
+ },
3528
+ set: (value) => {
3529
+ return value;
3530
+ },
3531
+ },
3532
+ get: (value) => {
3533
+ return value;
3534
+ },
3535
+ set: (value) => {
3536
+ return value;
3537
+ },
3538
+ },
3539
+ mapValue: {
3540
+ type: "map",
3541
+ properties: {
3542
+ stringVal: {
3543
+ type: "string",
3544
+ default: () => "abc",
3545
+ validate: (value) => value !== undefined,
3546
+ get: (value) => {
3547
+ return value;
3548
+ },
3549
+ set: (value) => {
3550
+ return value;
3551
+ },
3552
+ },
3553
+ numVal: {
3554
+ type: "number",
3555
+ default: () => 10,
3556
+ validate: (value) => value !== undefined,
3557
+ get: (value) => {
3558
+ return value;
3559
+ },
3560
+ set: (value) => {
3561
+ return value;
3562
+ },
3563
+ },
3564
+ boolValue: {
3565
+ type: "boolean",
3566
+ default: () => false,
3567
+ validate: (value) => value !== undefined,
3568
+ get: (value) => {
3569
+ return value;
3570
+ },
3571
+ set: (value) => {
3572
+ return value;
3573
+ },
3574
+ },
3575
+ enumVal: {
3576
+ type: ["abc", "def"],
3577
+ validate: (value) => value !== undefined,
3578
+ default: () => "abc",
3579
+ get: (value) => {
3580
+ return value;
3581
+ },
3582
+ set: (value) => {
3583
+ return value;
3584
+ },
3585
+ },
3586
+ stringListValue: {
3587
+ type: "list",
3588
+ items: {
3589
+ type: "string",
3590
+ default: "abc",
3591
+ validate: (value) => value !== undefined,
3592
+ get: (value) => {
3593
+ return value;
3594
+ },
3595
+ set: (value) => {
3596
+ return value;
3597
+ },
3598
+ },
3599
+ default: [],
3600
+ validate: (value) => value !== undefined,
3601
+ get: (value) => {
3602
+ return value;
3603
+ },
3604
+ set: (value) => {
3605
+ return value;
3606
+ },
3607
+ },
3608
+ numberListValue: {
3609
+ type: "list",
3610
+ items: {
3611
+ type: "number",
3612
+ default: () => 100,
3613
+ validate: (value) => value !== undefined,
3614
+ get: (value) => {
3615
+ return value;
3616
+ },
3617
+ set: (value) => {
3618
+ return value;
3619
+ },
3620
+ },
3621
+ default: [123, 123],
3622
+ validate: (value) => value !== undefined,
3623
+ get: (value) => {
3624
+ return value;
3625
+ },
3626
+ set: (value) => {
3627
+ return value;
3628
+ },
3629
+ },
3630
+ mapListValue: {
3631
+ type: "list",
3632
+ items: {
3633
+ type: "map",
3634
+ properties: {
3635
+ stringVal: {
3636
+ type: "string",
3637
+ default: "def",
3638
+ validate: (value) => value !== undefined,
3639
+ get: (value) => {
3640
+ return value;
3641
+ },
3642
+ set: (value) => {
3643
+ return value;
3644
+ },
3645
+ },
3646
+ numVal: {
3647
+ type: "number",
3648
+ default: 100,
3649
+ validate: (value) => value !== undefined,
3650
+ get: (value) => {
3651
+ return value;
3652
+ },
3653
+ set: (value) => {
3654
+ return value;
3655
+ },
3656
+ },
3657
+ boolValue: {
3658
+ type: "boolean",
3659
+ default: () => false,
3660
+ validate: (value) => value !== undefined,
3661
+ get: (value) => {
3662
+ return value;
3663
+ },
3664
+ set: (value) => {
3665
+ return value;
3666
+ },
3667
+ },
3668
+ stringSetValue: {
3669
+ type: "set",
3670
+ items: "string",
3671
+ default: ["abc"],
3672
+ validate: (value) => value !== undefined,
3673
+ get: (value) => {
3674
+ return value;
3675
+ },
3676
+ set: (value) => {
3677
+ return value;
3678
+ },
3679
+ },
3680
+ numberSetValue: {
3681
+ type: "set",
3682
+ items: "number",
3683
+ default: [5],
3684
+ validate: (value) => value !== undefined,
3685
+ get: (value) => {
3686
+ return value;
3687
+ },
3688
+ set: (value) => {
3689
+ return value;
3690
+ },
3691
+ },
3692
+ enumVal: {
3693
+ type: ["abc", "def"],
3694
+ validate: (value) => value !== undefined,
3695
+ default: () => "abc",
3696
+ get: (value) => {
3697
+ return value;
3698
+ },
3699
+ set: (value) => {
3700
+ return value;
3701
+ },
3702
+ },
3703
+ },
3704
+ default: () => ({
3705
+ stringVal: "anx",
3706
+ numVal: 13,
3707
+ boolValue: true,
3708
+ emumValue: "abc",
3709
+ stringSetValue: ["def"],
3710
+ numberSetValue: [10],
3711
+ }),
3712
+ validate: (value) => value !== undefined,
3713
+ get: (value) => {
3714
+ return value;
3715
+ },
3716
+ set: (value) => {
3717
+ return value;
3718
+ },
3719
+ },
3720
+ default: [],
3721
+ validate: (value) => value !== undefined,
3722
+ get: (value) => {
3723
+ return value;
3724
+ },
3725
+ set: (value) => {
3726
+ return value;
3727
+ },
3728
+ },
3729
+ },
3730
+ default: () => undefined,
3731
+ validate: (value) => value !== undefined,
3732
+ get: (value) => {
3733
+ return value;
3734
+ },
3735
+ set: (value) => {
3736
+ return value;
3737
+ },
3738
+ },
3739
+ },
3740
+ indexes: {
3741
+ user: {
3742
+ collection: "complexShapes",
3743
+ pk: {
3744
+ composite: ["username"],
3745
+ field: "pk",
3746
+ },
3747
+ sk: {
3748
+ composite: [],
3749
+ field: "sk",
3750
+ },
3751
+ },
3752
+ _: {
3753
+ collection: "owned",
3754
+ index: "gsi1pk-gsi1sk-index",
3755
+ pk: {
3756
+ composite: ["username"],
3757
+ field: "gsi1pk",
3758
+ },
3759
+ sk: {
3760
+ field: "gsi1sk",
3761
+ composite: [],
3762
+ },
3763
+ },
3764
+ },
3765
+ }, { table: "abc" });
3766
+ const mapTests = new _1.Entity({
3767
+ model: {
3768
+ entity: "mapTests",
3769
+ service: "tests",
3770
+ version: "1",
3771
+ },
3772
+ attributes: {
3773
+ username: {
3774
+ type: "string",
3775
+ },
3776
+ mapObject: {
3777
+ type: "map",
3778
+ properties: {
3779
+ minimal: {
3780
+ type: "string",
3781
+ },
3782
+ required: {
3783
+ type: "string",
3784
+ required: true,
3785
+ },
3786
+ hidden: {
3787
+ type: "string",
3788
+ hidden: true,
3789
+ },
3790
+ readOnly: {
3791
+ type: "string",
3792
+ readOnly: true,
3793
+ },
3794
+ anotherMap: {
3795
+ type: "map",
3796
+ properties: {
3797
+ minimal: {
3798
+ type: "string",
3799
+ },
3800
+ required: {
3801
+ type: "string",
3802
+ required: true,
3803
+ },
3804
+ hidden: {
3805
+ type: "string",
3806
+ hidden: true,
3807
+ },
3808
+ readOnly: {
3809
+ type: "string",
3810
+ readOnly: true,
3811
+ },
3812
+ },
3813
+ },
3814
+ },
3815
+ },
3816
+ },
3817
+ indexes: {
3818
+ user: {
3819
+ collection: "complexShapes",
3820
+ pk: {
3821
+ composite: ["username"],
3822
+ field: "pk",
3823
+ },
3824
+ sk: {
3825
+ composite: [],
3826
+ field: "sk",
3827
+ },
3828
+ },
3829
+ },
3830
+ });
3831
+ const complexAttributeService = new _1.Service({
3832
+ mapTests,
3833
+ complex,
3834
+ });
3835
+ mapTests
3836
+ .get({ username: "test" })
3837
+ .go()
3838
+ .then((res) => {
3839
+ const data = res.data;
3840
+ if (data && data.mapObject !== undefined) {
3841
+ (0, tsd_1.expectError)(() => {
3842
+ data.mapObject?.hidden;
3843
+ });
3844
+ (0, tsd_1.expectType)(data.mapObject.minimal);
3845
+ (0, tsd_1.expectType)(data.mapObject.readOnly);
3846
+ (0, tsd_1.expectType)(data.mapObject.required);
3847
+ }
3848
+ });
3849
+ // just the key is fine because `mapObject` is not required
3850
+ (0, tsd_1.expectAssignable)([{ username: "abc" }]);
3851
+ // with mapObject present, `required` is required
3852
+ mapTests.put({ username: "abc", mapObject: { required: "val" } });
3853
+ mapTests.put([{ username: "abc", mapObject: { required: "val" } }]);
3854
+ (0, tsd_1.expectError)(() => {
3855
+ mapTests.put({ username: "abc", mapObject: { minimal: "abc" } });
3856
+ });
3857
+ (0, tsd_1.expectError)(() => {
3858
+ mapTests.put([{ username: "abc", mapObject: { minimal: "abc" } }]);
3859
+ });
3860
+ // with anotherMap present, `required` is required
3861
+ mapTests.put({
3862
+ username: "abc",
3863
+ mapObject: { required: "val", anotherMap: { required: "def" } },
3864
+ });
3865
+ mapTests.put([
3866
+ {
3867
+ username: "abc",
3868
+ mapObject: { required: "val", anotherMap: { required: "def" } },
3869
+ },
3870
+ ]);
3871
+ (0, tsd_1.expectError)(() => {
3872
+ mapTests.put({
3873
+ username: "abc",
3874
+ mapObject: { minimal: "abc", required: "def", anotherMap: {} },
3875
+ });
3876
+ });
3877
+ (0, tsd_1.expectError)(() => {
3878
+ mapTests.put([
3879
+ {
3880
+ username: "abc",
3881
+ mapObject: { minimal: "abc", required: "def", anotherMap: {} },
3882
+ },
3883
+ ]);
3884
+ });
3885
+ //
3886
+ mapTests.update({ username: "abc" }).data((attr, op) => {
3887
+ (0, tsd_1.expectError)(() => op.set(attr.mapObject.readOnly, "abc"));
3888
+ (0, tsd_1.expectError)(() => op.set(attr.mapObject.anotherMap.readOnly, "abc"));
3889
+ op.set(attr.mapObject.minimal, "abc");
3890
+ op.set(attr.mapObject.anotherMap.minimal, "abc");
3891
+ op.set(attr.mapObject.hidden, "abc");
3892
+ op.set(attr.mapObject.anotherMap.hidden, "abc");
3893
+ op.set(attr.mapObject.required, "abc");
3894
+ op.set(attr.mapObject.anotherMap.required, "abc");
3895
+ // START SHOULD FAIL :(
3896
+ // expectError(() => op.remove(attr.mapObject.readOnly));
3897
+ // expectError(() => op.remove(attr.mapObject.required));
3898
+ // expectError(() => op.set(attr.mapObject, {}));
3899
+ // expectError(() => op.set(attr.mapObject, {minimal: "abc"}));
3900
+ // END SHOULD FAIL :(
3901
+ op.set(attr.mapObject, { required: "anc" });
3902
+ });
3903
+ (0, tsd_1.expectError)(() => mapTests.update({ username: "abc" }).remove(["username"]));
3904
+ complexAttributeService.collections
3905
+ .complexShapes({ username: "abc" })
3906
+ .where((attr, op) => {
3907
+ op.eq(attr.mapObject.minimal, "abc");
3908
+ op.eq(attr.numberListValue[0], 123);
3909
+ op.eq(attr.mapListValue[1].enumVal, "def");
3910
+ op.eq(attr.mapListValue[1].numVal, 345);
3911
+ return "";
3912
+ })
3913
+ .go();
3914
+ // casing property on schema
3915
+ const casingEntity = new _1.Entity({
3916
+ model: {
3917
+ service: "MallStoreDirectory",
3918
+ entity: "MallStores",
3919
+ version: "1",
3920
+ },
3921
+ attributes: {
3922
+ id: {
3923
+ type: "string",
3924
+ field: "id",
3925
+ },
3926
+ mall: {
3927
+ type: "string",
3928
+ required: true,
3929
+ field: "mall",
3930
+ },
3931
+ stores: {
3932
+ type: "number",
3933
+ },
3934
+ value: {
3935
+ type: "string",
3936
+ },
3937
+ },
3938
+ indexes: {
3939
+ store: {
3940
+ collection: ["myCollection"],
3941
+ pk: {
3942
+ field: "parition_key",
3943
+ composite: ["id"],
3944
+ casing: "lower",
3945
+ },
3946
+ sk: {
3947
+ field: "sort_key",
3948
+ composite: ["mall", "stores"],
3949
+ casing: "upper",
3950
+ },
3951
+ },
3952
+ other: {
3953
+ index: "idx1",
3954
+ collection: "otherCollection",
3955
+ pk: {
3956
+ field: "parition_key_idx1",
3957
+ composite: ["mall"],
3958
+ casing: "upper",
3959
+ },
3960
+ sk: {
3961
+ field: "sort_key_idx1",
3962
+ composite: ["id", "stores"],
3963
+ casing: "default",
3964
+ },
3965
+ },
3966
+ },
3967
+ }, { table: "StoreDirectory" });
3968
+ const allCasingOptions = "";
3969
+ (0, tsd_1.expectAssignable)(allCasingOptions);
3970
+ (0, tsd_1.expectAssignable)(allCasingOptions);
3971
+ (0, tsd_1.expectError)("not_available");
3972
+ (0, tsd_1.expectError)("not_available");
3973
+ (0, tsd_1.expectAssignable)(undefined);
3974
+ (0, tsd_1.expectAssignable)({});
3975
+ (0, tsd_1.expectAssignable)({ ignoreOwnership: true });
3976
+ (0, tsd_1.expectAssignable)({ ignoreOwnership: false });
3977
+ normalEntity2
3978
+ .update({
3979
+ prop1: "abc",
3980
+ prop2: "def",
3981
+ prop5: 123,
3982
+ })
3983
+ .set({ attr6: 456 })
3984
+ .go()
3985
+ .then((results) => {
3986
+ (0, tsd_1.expectType)(magnify(results.data));
3987
+ });
3988
+ normalEntity2
3989
+ .update({
3990
+ prop1: "abc",
3991
+ prop2: "def",
3992
+ prop5: 123,
3993
+ })
3994
+ .set({ attr6: 456 })
3995
+ .go({ response: "updated_new" })
3996
+ .then((results) => {
3997
+ (0, tsd_1.expectType)(magnify(results.data));
3998
+ });
3999
+ normalEntity2
4000
+ .update({
4001
+ prop1: "abc",
4002
+ prop2: "def",
4003
+ prop5: 123,
4004
+ })
4005
+ .set({ attr6: 456 })
4006
+ .go({ response: "all_new" })
4007
+ .then((results) => {
4008
+ (0, tsd_1.expectType)(magnify(results.data));
4009
+ });
4010
+ normalEntity2
4011
+ .patch({
4012
+ prop1: "abc",
4013
+ prop2: "def",
4014
+ prop5: 123,
4015
+ })
4016
+ .set({ attr6: 456 })
4017
+ .go()
4018
+ .then((results) => {
4019
+ (0, tsd_1.expectType)(magnify(results.data));
4020
+ });
4021
+ normalEntity2
4022
+ .patch({
4023
+ prop1: "abc",
4024
+ prop2: "def",
4025
+ prop5: 123,
4026
+ })
4027
+ .set({ attr6: 456 })
4028
+ .go({ response: "updated_new" })
4029
+ .then((results) => {
4030
+ (0, tsd_1.expectType)(magnify(results.data));
4031
+ });
4032
+ normalEntity2
4033
+ .patch({
4034
+ prop1: "abc",
4035
+ prop2: "def",
4036
+ prop5: 123,
4037
+ })
4038
+ .set({ attr6: 456 })
4039
+ .go({ response: "all_new" })
4040
+ .then((results) => {
4041
+ (0, tsd_1.expectType)(magnify(results.data));
4042
+ });
4043
+ //# sourceMappingURL=index.test-d.js.map