@model-ts/dynamodb 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/__test__/client-with-cursor-encryption.test.js +298 -183
- package/dist/cjs/__test__/client-with-cursor-encryption.test.js.map +1 -1
- package/dist/cjs/__test__/client.test.js +101 -0
- package/dist/cjs/__test__/client.test.js.map +1 -1
- package/dist/cjs/client.d.ts +6 -1
- package/dist/cjs/client.js +7 -2
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/dynamodb-model.d.ts +33 -8
- package/dist/cjs/gsi.d.ts +4 -0
- package/dist/cjs/gsi.js +24 -0
- package/dist/cjs/gsi.js.map +1 -0
- package/dist/cjs/operations.d.ts +4 -8
- package/dist/cjs/operations.js.map +1 -1
- package/dist/cjs/pagination.d.ts +48 -59
- package/dist/cjs/pagination.js +18 -26
- package/dist/cjs/pagination.js.map +1 -1
- package/dist/cjs/provider.d.ts +135 -17
- package/dist/cjs/provider.js +5 -12
- package/dist/cjs/provider.js.map +1 -1
- package/dist/cjs/sandbox.js +10 -43
- package/dist/cjs/sandbox.js.map +1 -1
- package/dist/esm/__test__/client-with-cursor-encryption.test.js +298 -183
- package/dist/esm/__test__/client-with-cursor-encryption.test.js.map +1 -1
- package/dist/esm/__test__/client.test.js +101 -0
- package/dist/esm/__test__/client.test.js.map +1 -1
- package/dist/esm/client.d.ts +6 -1
- package/dist/esm/client.js +7 -2
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/dynamodb-model.d.ts +33 -8
- package/dist/esm/gsi.d.ts +4 -0
- package/dist/esm/gsi.js +21 -0
- package/dist/esm/gsi.js.map +1 -0
- package/dist/esm/operations.d.ts +4 -8
- package/dist/esm/operations.js.map +1 -1
- package/dist/esm/pagination.d.ts +48 -59
- package/dist/esm/pagination.js +19 -26
- package/dist/esm/pagination.js.map +1 -1
- package/dist/esm/provider.d.ts +135 -17
- package/dist/esm/provider.js +5 -12
- package/dist/esm/provider.js.map +1 -1
- package/dist/esm/sandbox.js +10 -43
- package/dist/esm/sandbox.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/client-with-cursor-encryption.test.ts +365 -183
- package/src/__test__/client.test.ts +168 -0
- package/src/client.ts +20 -19
- package/src/dynamodb-model.ts +31 -9
- package/src/gsi.ts +25 -0
- package/src/operations.ts +4 -10
- package/src/pagination.ts +37 -46
- package/src/provider.ts +9 -9
- package/src/sandbox.ts +10 -43
- package/tsconfig.esm.json +14 -4
- package/tsconfig.json +14 -4
|
@@ -69,6 +69,12 @@ class MultiGSI extends core_1.model("MultiGSI", SIMPLE_CODEC, provider) {
|
|
|
69
69
|
get GSI5SK() {
|
|
70
70
|
return `GSI5SK#${this.bar}${this.bar}`;
|
|
71
71
|
}
|
|
72
|
+
get GSI19PK() {
|
|
73
|
+
return `GSI19PK#FIXED`;
|
|
74
|
+
}
|
|
75
|
+
get GSI19SK() {
|
|
76
|
+
return `GSI19SK#${this.bar}${this.bar}`;
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
class A extends core_1.model("A", t.type({ pk: t.string, sk: t.string, a: t.number }), provider) {
|
|
74
80
|
get PK() {
|
|
@@ -108,6 +114,9 @@ let sandbox;
|
|
|
108
114
|
beforeEach(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
109
115
|
sandbox = yield sandbox_1.createSandbox(client);
|
|
110
116
|
}));
|
|
117
|
+
afterEach(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
yield sandbox.destroy();
|
|
119
|
+
}));
|
|
111
120
|
describe("put", () => {
|
|
112
121
|
describe("via instance", () => {
|
|
113
122
|
test("it inserts a simple model", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -165,6 +174,8 @@ describe("put", () => {
|
|
|
165
174
|
- Object {}
|
|
166
175
|
+ Object {
|
|
167
176
|
+ "PK#yes__SK#42": Object {
|
|
177
|
+
+ "GSI19PK": "GSI19PK#FIXED",
|
|
178
|
+
+ "GSI19SK": "GSI19SK#4242",
|
|
168
179
|
+ "GSI2PK": "GSI2PK#yesyes",
|
|
169
180
|
+ "GSI2SK": "GSI2SK#FIXED",
|
|
170
181
|
+ "GSI3PK": "GSI3PK#FIXED",
|
|
@@ -248,6 +259,8 @@ describe("put", () => {
|
|
|
248
259
|
- Object {}
|
|
249
260
|
+ Object {
|
|
250
261
|
+ "PK#yes__SK#42": Object {
|
|
262
|
+
+ "GSI19PK": "GSI19PK#FIXED",
|
|
263
|
+
+ "GSI19SK": "GSI19SK#4242",
|
|
251
264
|
+ "GSI2PK": "GSI2PK#yesyes",
|
|
252
265
|
+ "GSI2SK": "GSI2SK#FIXED",
|
|
253
266
|
+ "GSI3PK": "GSI3PK#FIXED",
|
|
@@ -436,9 +449,11 @@ describe("softDelete", () => {
|
|
|
436
449
|
- First value
|
|
437
450
|
+ Second value
|
|
438
451
|
|
|
439
|
-
@@ -1,
|
|
452
|
+
@@ -1,27 +1,29 @@
|
|
440
453
|
Object {
|
|
441
454
|
- "PK#hello__SK#42": Object {
|
|
455
|
+
- "GSI19PK": "GSI19PK#FIXED",
|
|
456
|
+
- "GSI19SK": "GSI19SK#4242",
|
|
442
457
|
- "GSI2PK": "GSI2PK#hellohello",
|
|
443
458
|
- "GSI2SK": "GSI2SK#FIXED",
|
|
444
459
|
- "GSI3PK": "GSI3PK#FIXED",
|
|
@@ -450,6 +465,8 @@ describe("softDelete", () => {
|
|
|
450
465
|
- "PK": "PK#hello",
|
|
451
466
|
- "SK": "SK#42",
|
|
452
467
|
+ "$$DELETED$$PK#hello__$$DELETED$$SK#42": Object {
|
|
468
|
+
+ "GSI19PK": "$$DELETED$$GSI19PK#FIXED",
|
|
469
|
+
+ "GSI19SK": "$$DELETED$$GSI19SK#4242",
|
|
453
470
|
+ "GSI2PK": "$$DELETED$$GSI2PK#hellohello",
|
|
454
471
|
+ "GSI2SK": "$$DELETED$$GSI2SK#FIXED",
|
|
455
472
|
+ "GSI3PK": "$$DELETED$$GSI3PK#FIXED",
|
|
@@ -1459,13 +1476,13 @@ describe("paginate", () => {
|
|
|
1459
1476
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1460
1477
|
});
|
|
1461
1478
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1462
|
-
Object {
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
}
|
|
1468
|
-
`);
|
|
1479
|
+
Object {
|
|
1480
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1481
|
+
"hasNextPage": true,
|
|
1482
|
+
"hasPreviousPage": false,
|
|
1483
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1484
|
+
}
|
|
1485
|
+
`);
|
|
1469
1486
|
expect(page1.edges.length).toBe(20);
|
|
1470
1487
|
expect(page1.edges[0].node.c).toBe("0");
|
|
1471
1488
|
expect(page1.edges[19].node.c).toBe("19");
|
|
@@ -1474,13 +1491,13 @@ Object {
|
|
|
1474
1491
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1475
1492
|
});
|
|
1476
1493
|
expect(page2.pageInfo).toMatchInlineSnapshot(`
|
|
1477
|
-
Object {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
`);
|
|
1494
|
+
Object {
|
|
1495
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1496
|
+
"hasNextPage": true,
|
|
1497
|
+
"hasPreviousPage": false,
|
|
1498
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1499
|
+
}
|
|
1500
|
+
`);
|
|
1484
1501
|
expect(page2.edges.length).toBe(20);
|
|
1485
1502
|
expect(page2.edges[0].node.c).toBe("20");
|
|
1486
1503
|
expect(page2.edges[19].node.c).toBe("39");
|
|
@@ -1489,13 +1506,13 @@ Object {
|
|
|
1489
1506
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1490
1507
|
});
|
|
1491
1508
|
expect(page3.pageInfo).toMatchInlineSnapshot(`
|
|
1492
|
-
Object {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
}
|
|
1498
|
-
`);
|
|
1509
|
+
Object {
|
|
1510
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoLvfn9aOeA8=",
|
|
1511
|
+
"hasNextPage": false,
|
|
1512
|
+
"hasPreviousPage": false,
|
|
1513
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKv1n9aOeA8=",
|
|
1514
|
+
}
|
|
1515
|
+
`);
|
|
1499
1516
|
expect(page3.edges.length).toBe(20);
|
|
1500
1517
|
expect(page3.edges[0].node.c).toBe("40");
|
|
1501
1518
|
expect(page3.edges[19].node.c).toBe("59");
|
|
@@ -1505,13 +1522,13 @@ Object {
|
|
|
1505
1522
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1506
1523
|
});
|
|
1507
1524
|
expect(backwardsPage2.pageInfo).toMatchInlineSnapshot(`
|
|
1508
|
-
Object {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1514
|
-
`);
|
|
1525
|
+
Object {
|
|
1526
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1527
|
+
"hasNextPage": false,
|
|
1528
|
+
"hasPreviousPage": true,
|
|
1529
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1530
|
+
}
|
|
1531
|
+
`);
|
|
1515
1532
|
expect(backwardsPage2.edges.length).toBe(20);
|
|
1516
1533
|
expect(backwardsPage2.edges[0].node.c).toBe("20");
|
|
1517
1534
|
expect(backwardsPage2.edges[19].node.c).toBe("39");
|
|
@@ -1520,13 +1537,13 @@ Object {
|
|
|
1520
1537
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1521
1538
|
});
|
|
1522
1539
|
expect(backwardsPage1.pageInfo).toMatchInlineSnapshot(`
|
|
1523
|
-
Object {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
}
|
|
1529
|
-
`);
|
|
1540
|
+
Object {
|
|
1541
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1542
|
+
"hasNextPage": false,
|
|
1543
|
+
"hasPreviousPage": false,
|
|
1544
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1545
|
+
}
|
|
1546
|
+
`);
|
|
1530
1547
|
expect(backwardsPage1.edges.length).toBe(20);
|
|
1531
1548
|
expect(backwardsPage1.edges[0].node.c).toBe("0");
|
|
1532
1549
|
expect(backwardsPage1.edges[19].node.c).toBe("19");
|
|
@@ -1542,13 +1559,13 @@ Object {
|
|
|
1542
1559
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1543
1560
|
});
|
|
1544
1561
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1545
|
-
Object {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1551
|
-
`);
|
|
1562
|
+
Object {
|
|
1563
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1564
|
+
"hasNextPage": true,
|
|
1565
|
+
"hasPreviousPage": false,
|
|
1566
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1567
|
+
}
|
|
1568
|
+
`);
|
|
1552
1569
|
expect(page1.edges.length).toBe(20);
|
|
1553
1570
|
expect(page1.edges[0].node.SK).toBe("000");
|
|
1554
1571
|
expect(page1.edges[19].node.SK).toBe("019");
|
|
@@ -1557,13 +1574,13 @@ Object {
|
|
|
1557
1574
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1558
1575
|
});
|
|
1559
1576
|
expect(page2.pageInfo).toMatchInlineSnapshot(`
|
|
1560
|
-
Object {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
}
|
|
1566
|
-
`);
|
|
1577
|
+
Object {
|
|
1578
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1579
|
+
"hasNextPage": true,
|
|
1580
|
+
"hasPreviousPage": false,
|
|
1581
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1582
|
+
}
|
|
1583
|
+
`);
|
|
1567
1584
|
expect(page2.edges.length).toBe(20);
|
|
1568
1585
|
expect(page2.edges[0].node.SK).toBe("020");
|
|
1569
1586
|
expect(page2.edges[19].node.SK).toBe("039");
|
|
@@ -1572,13 +1589,13 @@ Object {
|
|
|
1572
1589
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1573
1590
|
});
|
|
1574
1591
|
expect(page3.pageInfo).toMatchInlineSnapshot(`
|
|
1575
|
-
Object {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
}
|
|
1581
|
-
`);
|
|
1592
|
+
Object {
|
|
1593
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoLvfn9aOeA8=",
|
|
1594
|
+
"hasNextPage": false,
|
|
1595
|
+
"hasPreviousPage": false,
|
|
1596
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKv1n9aOeA8=",
|
|
1597
|
+
}
|
|
1598
|
+
`);
|
|
1582
1599
|
expect(page3.edges.length).toBe(20);
|
|
1583
1600
|
expect(page3.edges[0].node.SK).toBe("040");
|
|
1584
1601
|
expect(page3.edges[19].node.SK).toBe("059");
|
|
@@ -1588,13 +1605,13 @@ Object {
|
|
|
1588
1605
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1589
1606
|
});
|
|
1590
1607
|
expect(backwardsPage2.pageInfo).toMatchInlineSnapshot(`
|
|
1591
|
-
Object {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
}
|
|
1597
|
-
`);
|
|
1608
|
+
Object {
|
|
1609
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1610
|
+
"hasNextPage": false,
|
|
1611
|
+
"hasPreviousPage": true,
|
|
1612
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1613
|
+
}
|
|
1614
|
+
`);
|
|
1598
1615
|
expect(backwardsPage2.edges.length).toBe(20);
|
|
1599
1616
|
expect(backwardsPage2.edges[0].node.SK).toBe("020");
|
|
1600
1617
|
expect(backwardsPage2.edges[19].node.SK).toBe("039");
|
|
@@ -1603,13 +1620,13 @@ Object {
|
|
|
1603
1620
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1604
1621
|
});
|
|
1605
1622
|
expect(backwardsPage1.pageInfo).toMatchInlineSnapshot(`
|
|
1606
|
-
Object {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
}
|
|
1612
|
-
`);
|
|
1623
|
+
Object {
|
|
1624
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1625
|
+
"hasNextPage": false,
|
|
1626
|
+
"hasPreviousPage": false,
|
|
1627
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1628
|
+
}
|
|
1629
|
+
`);
|
|
1613
1630
|
expect(backwardsPage1.edges.length).toBe(20);
|
|
1614
1631
|
expect(backwardsPage1.edges[0].node.SK).toBe("000");
|
|
1615
1632
|
expect(backwardsPage1.edges[19].node.SK).toBe("019");
|
|
@@ -1623,13 +1640,13 @@ Object {
|
|
|
1623
1640
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1624
1641
|
});
|
|
1625
1642
|
expect(page.pageInfo).toMatchInlineSnapshot(`
|
|
1626
|
-
Object {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
}
|
|
1632
|
-
`);
|
|
1643
|
+
Object {
|
|
1644
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6vfn9aOeA8=",
|
|
1645
|
+
"hasNextPage": true,
|
|
1646
|
+
"hasPreviousPage": false,
|
|
1647
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1648
|
+
}
|
|
1649
|
+
`);
|
|
1633
1650
|
expect(page.edges.length).toBe(10);
|
|
1634
1651
|
expect(page.edges[0].node.c).toBe("0");
|
|
1635
1652
|
expect(page.edges[9].node.c).toBe("9");
|
|
@@ -1643,17 +1660,43 @@ Object {
|
|
|
1643
1660
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1644
1661
|
});
|
|
1645
1662
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1646
|
-
Object {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1652
|
-
`);
|
|
1663
|
+
Object {
|
|
1664
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKvfn9aOeA8=",
|
|
1665
|
+
"hasNextPage": true,
|
|
1666
|
+
"hasPreviousPage": false,
|
|
1667
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1668
|
+
}
|
|
1669
|
+
`);
|
|
1653
1670
|
expect(page1.edges.length).toBe(50);
|
|
1654
1671
|
expect(page1.edges[0].node.c).toBe("0");
|
|
1655
1672
|
expect(page1.edges[49].node.c).toBe("49");
|
|
1656
1673
|
}));
|
|
1674
|
+
test("it respects custom pagination default", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
1675
|
+
client.paginationOptions = {
|
|
1676
|
+
default: 40
|
|
1677
|
+
};
|
|
1678
|
+
const items = Array.from({ length: 50 }).map((_, i) => new C({ pk: "PK", sk: String(i).padStart(3, "0"), c: String(i) }));
|
|
1679
|
+
yield sandbox.seed(...items);
|
|
1680
|
+
const page = yield client.paginate(C, {}, {
|
|
1681
|
+
KeyConditionExpression: "PK = :pk",
|
|
1682
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1683
|
+
});
|
|
1684
|
+
expect(page.edges.length).toBe(40);
|
|
1685
|
+
delete client.paginationOptions;
|
|
1686
|
+
}));
|
|
1687
|
+
test("it respects custom pagination limit", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
1688
|
+
client.paginationOptions = {
|
|
1689
|
+
limit: 100
|
|
1690
|
+
};
|
|
1691
|
+
const items = Array.from({ length: 120 }).map((_, i) => new C({ pk: "PK", sk: String(i).padStart(3, "0"), c: String(i) }));
|
|
1692
|
+
yield sandbox.seed(...items);
|
|
1693
|
+
const page = yield client.paginate(C, { first: 110 }, {
|
|
1694
|
+
KeyConditionExpression: "PK = :pk",
|
|
1695
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1696
|
+
});
|
|
1697
|
+
expect(page.edges.length).toBe(100);
|
|
1698
|
+
delete client.paginationOptions;
|
|
1699
|
+
}));
|
|
1657
1700
|
});
|
|
1658
1701
|
describe("model", () => {
|
|
1659
1702
|
test("it paginates a regular model", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1665,13 +1708,13 @@ Object {
|
|
|
1665
1708
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1666
1709
|
});
|
|
1667
1710
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1668
|
-
Object {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
}
|
|
1674
|
-
`);
|
|
1711
|
+
Object {
|
|
1712
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1713
|
+
"hasNextPage": true,
|
|
1714
|
+
"hasPreviousPage": false,
|
|
1715
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1716
|
+
}
|
|
1717
|
+
`);
|
|
1675
1718
|
expect(page1.edges.length).toBe(20);
|
|
1676
1719
|
expect(page1.edges[0].node.c).toBe("0");
|
|
1677
1720
|
expect(page1.edges[19].node.c).toBe("19");
|
|
@@ -1680,13 +1723,13 @@ Object {
|
|
|
1680
1723
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1681
1724
|
});
|
|
1682
1725
|
expect(page2.pageInfo).toMatchInlineSnapshot(`
|
|
1683
|
-
Object {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
}
|
|
1689
|
-
`);
|
|
1726
|
+
Object {
|
|
1727
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1728
|
+
"hasNextPage": true,
|
|
1729
|
+
"hasPreviousPage": false,
|
|
1730
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1731
|
+
}
|
|
1732
|
+
`);
|
|
1690
1733
|
expect(page2.edges.length).toBe(20);
|
|
1691
1734
|
expect(page2.edges[0].node.c).toBe("20");
|
|
1692
1735
|
expect(page2.edges[19].node.c).toBe("39");
|
|
@@ -1695,13 +1738,13 @@ Object {
|
|
|
1695
1738
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1696
1739
|
});
|
|
1697
1740
|
expect(page3.pageInfo).toMatchInlineSnapshot(`
|
|
1698
|
-
Object {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
}
|
|
1704
|
-
`);
|
|
1741
|
+
Object {
|
|
1742
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoLvfn9aOeA8=",
|
|
1743
|
+
"hasNextPage": false,
|
|
1744
|
+
"hasPreviousPage": false,
|
|
1745
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKv1n9aOeA8=",
|
|
1746
|
+
}
|
|
1747
|
+
`);
|
|
1705
1748
|
expect(page3.edges.length).toBe(20);
|
|
1706
1749
|
expect(page3.edges[0].node.c).toBe("40");
|
|
1707
1750
|
expect(page3.edges[19].node.c).toBe("59");
|
|
@@ -1711,13 +1754,13 @@ Object {
|
|
|
1711
1754
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1712
1755
|
});
|
|
1713
1756
|
expect(backwardsPage2.pageInfo).toMatchInlineSnapshot(`
|
|
1714
|
-
Object {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
}
|
|
1720
|
-
`);
|
|
1757
|
+
Object {
|
|
1758
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1759
|
+
"hasNextPage": false,
|
|
1760
|
+
"hasPreviousPage": true,
|
|
1761
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1762
|
+
}
|
|
1763
|
+
`);
|
|
1721
1764
|
expect(backwardsPage2.edges.length).toBe(20);
|
|
1722
1765
|
expect(backwardsPage2.edges[0].node.c).toBe("20");
|
|
1723
1766
|
expect(backwardsPage2.edges[19].node.c).toBe("39");
|
|
@@ -1726,13 +1769,13 @@ Object {
|
|
|
1726
1769
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1727
1770
|
});
|
|
1728
1771
|
expect(backwardsPage1.pageInfo).toMatchInlineSnapshot(`
|
|
1729
|
-
Object {
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
}
|
|
1735
|
-
`);
|
|
1772
|
+
Object {
|
|
1773
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1774
|
+
"hasNextPage": false,
|
|
1775
|
+
"hasPreviousPage": false,
|
|
1776
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1777
|
+
}
|
|
1778
|
+
`);
|
|
1736
1779
|
expect(backwardsPage1.edges.length).toBe(20);
|
|
1737
1780
|
expect(backwardsPage1.edges[0].node.c).toBe("0");
|
|
1738
1781
|
expect(backwardsPage1.edges[19].node.c).toBe("19");
|
|
@@ -1746,13 +1789,13 @@ Object {
|
|
|
1746
1789
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1747
1790
|
});
|
|
1748
1791
|
expect(page.pageInfo).toMatchInlineSnapshot(`
|
|
1749
|
-
Object {
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
}
|
|
1755
|
-
`);
|
|
1792
|
+
Object {
|
|
1793
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6vfn9aOeA8=",
|
|
1794
|
+
"hasNextPage": true,
|
|
1795
|
+
"hasPreviousPage": false,
|
|
1796
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1797
|
+
}
|
|
1798
|
+
`);
|
|
1756
1799
|
expect(page.edges.length).toBe(10);
|
|
1757
1800
|
expect(page.edges[0].node.c).toBe("0");
|
|
1758
1801
|
expect(page.edges[9].node.c).toBe("9");
|
|
@@ -1766,17 +1809,43 @@ Object {
|
|
|
1766
1809
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1767
1810
|
});
|
|
1768
1811
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1769
|
-
Object {
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
}
|
|
1775
|
-
`);
|
|
1812
|
+
Object {
|
|
1813
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKvfn9aOeA8=",
|
|
1814
|
+
"hasNextPage": true,
|
|
1815
|
+
"hasPreviousPage": false,
|
|
1816
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1817
|
+
}
|
|
1818
|
+
`);
|
|
1776
1819
|
expect(page1.edges.length).toBe(50);
|
|
1777
1820
|
expect(page1.edges[0].node.c).toBe("0");
|
|
1778
1821
|
expect(page1.edges[49].node.c).toBe("49");
|
|
1779
1822
|
}));
|
|
1823
|
+
test("it respects custom pagination default", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
1824
|
+
client.paginationOptions = {
|
|
1825
|
+
default: 40
|
|
1826
|
+
};
|
|
1827
|
+
const items = Array.from({ length: 50 }).map((_, i) => new C({ pk: "PK", sk: String(i).padStart(3, "0"), c: String(i) }));
|
|
1828
|
+
yield sandbox.seed(...items);
|
|
1829
|
+
const page = yield C.paginate({}, {
|
|
1830
|
+
KeyConditionExpression: "PK = :pk",
|
|
1831
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1832
|
+
});
|
|
1833
|
+
expect(page.edges.length).toBe(40);
|
|
1834
|
+
delete client.paginationOptions;
|
|
1835
|
+
}));
|
|
1836
|
+
test("it respects custom pagination limit", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
1837
|
+
client.paginationOptions = {
|
|
1838
|
+
limit: 100
|
|
1839
|
+
};
|
|
1840
|
+
const items = Array.from({ length: 120 }).map((_, i) => new C({ pk: "PK", sk: String(i).padStart(3, "0"), c: String(i) }));
|
|
1841
|
+
yield sandbox.seed(...items);
|
|
1842
|
+
const page = yield C.paginate({ first: 110 }, {
|
|
1843
|
+
KeyConditionExpression: "PK = :pk",
|
|
1844
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1845
|
+
});
|
|
1846
|
+
expect(page.edges.length).toBe(100);
|
|
1847
|
+
delete client.paginationOptions;
|
|
1848
|
+
}));
|
|
1780
1849
|
});
|
|
1781
1850
|
describe("union", () => {
|
|
1782
1851
|
test("it paginates a union model", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1790,13 +1859,13 @@ Object {
|
|
|
1790
1859
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1791
1860
|
});
|
|
1792
1861
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1793
|
-
Object {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
}
|
|
1799
|
-
`);
|
|
1862
|
+
Object {
|
|
1863
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1864
|
+
"hasNextPage": true,
|
|
1865
|
+
"hasPreviousPage": false,
|
|
1866
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1867
|
+
}
|
|
1868
|
+
`);
|
|
1800
1869
|
expect(page1.edges.length).toBe(20);
|
|
1801
1870
|
expect(page1.edges[0].node.SK).toBe("000");
|
|
1802
1871
|
expect(page1.edges[19].node.SK).toBe("019");
|
|
@@ -1805,13 +1874,13 @@ Object {
|
|
|
1805
1874
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1806
1875
|
});
|
|
1807
1876
|
expect(page2.pageInfo).toMatchInlineSnapshot(`
|
|
1808
|
-
Object {
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
`);
|
|
1877
|
+
Object {
|
|
1878
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1879
|
+
"hasNextPage": true,
|
|
1880
|
+
"hasPreviousPage": false,
|
|
1881
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1882
|
+
}
|
|
1883
|
+
`);
|
|
1815
1884
|
expect(page2.edges.length).toBe(20);
|
|
1816
1885
|
expect(page2.edges[0].node.SK).toBe("020");
|
|
1817
1886
|
expect(page2.edges[19].node.SK).toBe("039");
|
|
@@ -1820,13 +1889,13 @@ Object {
|
|
|
1820
1889
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1821
1890
|
});
|
|
1822
1891
|
expect(page3.pageInfo).toMatchInlineSnapshot(`
|
|
1823
|
-
Object {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
}
|
|
1829
|
-
`);
|
|
1892
|
+
Object {
|
|
1893
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoLvfn9aOeA8=",
|
|
1894
|
+
"hasNextPage": false,
|
|
1895
|
+
"hasPreviousPage": false,
|
|
1896
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKv1n9aOeA8=",
|
|
1897
|
+
}
|
|
1898
|
+
`);
|
|
1830
1899
|
expect(page3.edges.length).toBe(20);
|
|
1831
1900
|
expect(page3.edges[0].node.SK).toBe("040");
|
|
1832
1901
|
expect(page3.edges[19].node.SK).toBe("059");
|
|
@@ -1836,13 +1905,13 @@ Object {
|
|
|
1836
1905
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1837
1906
|
});
|
|
1838
1907
|
expect(backwardsPage2.pageInfo).toMatchInlineSnapshot(`
|
|
1839
|
-
Object {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1845
|
-
`);
|
|
1908
|
+
Object {
|
|
1909
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo5Xfn9aOeA8=",
|
|
1910
|
+
"hasNextPage": false,
|
|
1911
|
+
"hasPreviousPage": true,
|
|
1912
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo4X1n9aOeA8=",
|
|
1913
|
+
}
|
|
1914
|
+
`);
|
|
1846
1915
|
expect(backwardsPage2.edges.length).toBe(20);
|
|
1847
1916
|
expect(backwardsPage2.edges[0].node.SK).toBe("020");
|
|
1848
1917
|
expect(backwardsPage2.edges[19].node.SK).toBe("039");
|
|
@@ -1851,13 +1920,13 @@ Object {
|
|
|
1851
1920
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1852
1921
|
});
|
|
1853
1922
|
expect(backwardsPage1.pageInfo).toMatchInlineSnapshot(`
|
|
1854
|
-
Object {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
}
|
|
1860
|
-
`);
|
|
1923
|
+
Object {
|
|
1924
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo7vfn9aOeA8=",
|
|
1925
|
+
"hasNextPage": false,
|
|
1926
|
+
"hasPreviousPage": false,
|
|
1927
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1928
|
+
}
|
|
1929
|
+
`);
|
|
1861
1930
|
expect(backwardsPage1.edges.length).toBe(20);
|
|
1862
1931
|
expect(backwardsPage1.edges[0].node.SK).toBe("000");
|
|
1863
1932
|
expect(backwardsPage1.edges[19].node.SK).toBe("019");
|
|
@@ -1873,13 +1942,13 @@ Object {
|
|
|
1873
1942
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1874
1943
|
});
|
|
1875
1944
|
expect(page.pageInfo).toMatchInlineSnapshot(`
|
|
1876
|
-
Object {
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
}
|
|
1882
|
-
`);
|
|
1945
|
+
Object {
|
|
1946
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6vfn9aOeA8=",
|
|
1947
|
+
"hasNextPage": true,
|
|
1948
|
+
"hasPreviousPage": false,
|
|
1949
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1950
|
+
}
|
|
1951
|
+
`);
|
|
1883
1952
|
expect(page.edges.length).toBe(10);
|
|
1884
1953
|
expect(page.edges[0].node.SK).toBe("000");
|
|
1885
1954
|
expect(page.edges[9].node.SK).toBe("009");
|
|
@@ -1895,17 +1964,63 @@ Object {
|
|
|
1895
1964
|
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1896
1965
|
});
|
|
1897
1966
|
expect(page1.pageInfo).toMatchInlineSnapshot(`
|
|
1898
|
-
Object {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
`);
|
|
1967
|
+
Object {
|
|
1968
|
+
"endCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOoKvfn9aOeA8=",
|
|
1969
|
+
"hasNextPage": true,
|
|
1970
|
+
"hasPreviousPage": false,
|
|
1971
|
+
"startCursor": "cC4wNVXawu0oBvB8vqW4J/RG6hbr3ndOo6v1n9aOeA8=",
|
|
1972
|
+
}
|
|
1973
|
+
`);
|
|
1905
1974
|
expect(page1.edges.length).toBe(50);
|
|
1906
1975
|
expect(page1.edges[0].node.SK).toBe("000");
|
|
1907
1976
|
expect(page1.edges[49].node.SK).toBe("049");
|
|
1908
1977
|
}));
|
|
1978
|
+
test("it respects custom pagination default", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
1979
|
+
client.paginationOptions = {
|
|
1980
|
+
default: 40
|
|
1981
|
+
};
|
|
1982
|
+
const items = Array.from({ length: 50 }).map((_, i) => i > 30
|
|
1983
|
+
? new C({
|
|
1984
|
+
pk: "PK",
|
|
1985
|
+
sk: String(i).padStart(3, "0"),
|
|
1986
|
+
c: String(i)
|
|
1987
|
+
})
|
|
1988
|
+
: new D({
|
|
1989
|
+
pk: "PK",
|
|
1990
|
+
sk: String(i).padStart(3, "0"),
|
|
1991
|
+
d: String(i)
|
|
1992
|
+
}));
|
|
1993
|
+
yield sandbox.seed(...items);
|
|
1994
|
+
const page = yield Union.paginate({}, {
|
|
1995
|
+
KeyConditionExpression: "PK = :pk",
|
|
1996
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
1997
|
+
});
|
|
1998
|
+
expect(page.edges.length).toBe(40);
|
|
1999
|
+
delete client.paginationOptions;
|
|
2000
|
+
}));
|
|
2001
|
+
test("it respects custom pagination limit", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
2002
|
+
client.paginationOptions = {
|
|
2003
|
+
limit: 100
|
|
2004
|
+
};
|
|
2005
|
+
const items = Array.from({ length: 110 }).map((_, i) => i > 30
|
|
2006
|
+
? new C({
|
|
2007
|
+
pk: "PK",
|
|
2008
|
+
sk: String(i).padStart(3, "0"),
|
|
2009
|
+
c: String(i)
|
|
2010
|
+
})
|
|
2011
|
+
: new D({
|
|
2012
|
+
pk: "PK",
|
|
2013
|
+
sk: String(i).padStart(3, "0"),
|
|
2014
|
+
d: String(i)
|
|
2015
|
+
}));
|
|
2016
|
+
yield sandbox.seed(...items);
|
|
2017
|
+
const page = yield Union.paginate({ first: 110 }, {
|
|
2018
|
+
KeyConditionExpression: "PK = :pk",
|
|
2019
|
+
ExpressionAttributeValues: { ":pk": "PK" }
|
|
2020
|
+
});
|
|
2021
|
+
expect(page.edges.length).toBe(100);
|
|
2022
|
+
delete client.paginationOptions;
|
|
2023
|
+
}));
|
|
1909
2024
|
});
|
|
1910
2025
|
});
|
|
1911
2026
|
//# sourceMappingURL=client-with-cursor-encryption.test.js.map
|