retold-data-service 2.0.20 → 2.0.22
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/package.json +3 -3
- package/test/RetoldDataService_tests.js +222 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retold-data-service",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.22",
|
|
4
4
|
"description": "Serve up a whole model!",
|
|
5
5
|
"main": "source/Retold-Data-Service.js",
|
|
6
6
|
"bin": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"meadow-connection-sqlite": "^1.0.18",
|
|
63
63
|
"puppeteer": "^24.38.0",
|
|
64
|
-
"quackage": "^1.0.
|
|
64
|
+
"quackage": "^1.0.64",
|
|
65
65
|
"stricture": "^4.0.2",
|
|
66
66
|
"supertest": "^7.2.2"
|
|
67
67
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"meadow": "^2.0.33",
|
|
73
73
|
"meadow-connection-mysql": "^1.0.14",
|
|
74
74
|
"meadow-endpoints": "^4.0.14",
|
|
75
|
-
"meadow-integration": "^1.0.
|
|
75
|
+
"meadow-integration": "^1.0.18",
|
|
76
76
|
"meadow-migrationmanager": "^0.0.4",
|
|
77
77
|
"orator": "^6.0.4",
|
|
78
78
|
"orator-http-proxy": "^1.0.5",
|
|
@@ -1509,5 +1509,227 @@ suite
|
|
|
1509
1509
|
);
|
|
1510
1510
|
}
|
|
1511
1511
|
);
|
|
1512
|
+
|
|
1513
|
+
suite
|
|
1514
|
+
(
|
|
1515
|
+
'Sync with Standard Pagination',
|
|
1516
|
+
function()
|
|
1517
|
+
{
|
|
1518
|
+
let _SyncFable;
|
|
1519
|
+
let _SyncDB;
|
|
1520
|
+
|
|
1521
|
+
suiteSetup
|
|
1522
|
+
(
|
|
1523
|
+
function(fDone)
|
|
1524
|
+
{
|
|
1525
|
+
this.timeout(15000);
|
|
1526
|
+
|
|
1527
|
+
let tmpSyncSettings = {
|
|
1528
|
+
Product: 'SyncTestStandard',
|
|
1529
|
+
ProductVersion: '1.0.0',
|
|
1530
|
+
LogStreams: [{ streamtype: 'console', level: 'fatal' }],
|
|
1531
|
+
SQLite: { SQLiteFilePath: ':memory:' }
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
_SyncFable = new libFable(tmpSyncSettings);
|
|
1535
|
+
|
|
1536
|
+
// Register SQLite provider for destination
|
|
1537
|
+
_SyncFable.serviceManager.addServiceType('MeadowSQLiteProvider', libMeadowConnectionSQLite);
|
|
1538
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowSQLiteProvider');
|
|
1539
|
+
|
|
1540
|
+
_SyncFable.MeadowSQLiteProvider.connectAsync(
|
|
1541
|
+
(pError) =>
|
|
1542
|
+
{
|
|
1543
|
+
if (pError) return fDone(pError);
|
|
1544
|
+
|
|
1545
|
+
_SyncDB = _SyncFable.MeadowSQLiteProvider.db;
|
|
1546
|
+
|
|
1547
|
+
// Set up MeadowCloneRestClient pointed at the test server
|
|
1548
|
+
const libMeadowCloneRestClient = require('../node_modules/meadow-integration/source/services/clone/Meadow-Service-RestClient.js');
|
|
1549
|
+
_SyncFable.serviceManager.addServiceType('MeadowCloneRestClient', libMeadowCloneRestClient);
|
|
1550
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowCloneRestClient',
|
|
1551
|
+
{
|
|
1552
|
+
ServerURL: `${_BaseURL}1.0/`,
|
|
1553
|
+
UserID: false,
|
|
1554
|
+
Password: false
|
|
1555
|
+
});
|
|
1556
|
+
|
|
1557
|
+
// Set up Meadow prototype (required by sync entities)
|
|
1558
|
+
const libMeadow = require('meadow');
|
|
1559
|
+
_SyncFable._MeadowPrototype = libMeadow;
|
|
1560
|
+
_SyncFable.Meadow = libMeadow.new(_SyncFable, 'SyncTest-Prototype');
|
|
1561
|
+
|
|
1562
|
+
// Set up MeadowSync
|
|
1563
|
+
_SyncFable.ProgramConfiguration = {};
|
|
1564
|
+
const libMeadowSync = require('../node_modules/meadow-integration/source/services/clone/Meadow-Service-Sync.js');
|
|
1565
|
+
_SyncFable.serviceManager.addServiceType('MeadowSync', libMeadowSync);
|
|
1566
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowSync',
|
|
1567
|
+
{
|
|
1568
|
+
SyncEntityList: ['Author'],
|
|
1569
|
+
PageSize: 2,
|
|
1570
|
+
SyncDeletedRecords: false,
|
|
1571
|
+
UseAdvancedIDPagination: false
|
|
1572
|
+
});
|
|
1573
|
+
|
|
1574
|
+
// Load the test schema into MeadowSync
|
|
1575
|
+
let tmpFullModel = require('./model/MeadowModel-Extended.json');
|
|
1576
|
+
_SyncFable.MeadowSync.loadMeadowSchema(tmpFullModel,
|
|
1577
|
+
(pSchemaError) =>
|
|
1578
|
+
{
|
|
1579
|
+
if (pSchemaError)
|
|
1580
|
+
{
|
|
1581
|
+
return fDone(pSchemaError);
|
|
1582
|
+
}
|
|
1583
|
+
return fDone();
|
|
1584
|
+
});
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
);
|
|
1588
|
+
|
|
1589
|
+
test
|
|
1590
|
+
(
|
|
1591
|
+
'Should sync Author records using standard offset pagination',
|
|
1592
|
+
function(fDone)
|
|
1593
|
+
{
|
|
1594
|
+
this.timeout(15000);
|
|
1595
|
+
|
|
1596
|
+
_SyncFable.MeadowSync.syncAll(
|
|
1597
|
+
(pSyncError) =>
|
|
1598
|
+
{
|
|
1599
|
+
Expect(pSyncError).to.not.exist;
|
|
1600
|
+
|
|
1601
|
+
// Query the destination database to verify records were copied
|
|
1602
|
+
let tmpRows = _SyncDB.prepare('SELECT * FROM Author WHERE Deleted = 0 ORDER BY IDAuthor').all();
|
|
1603
|
+
Expect(tmpRows.length).to.be.greaterThan(0);
|
|
1604
|
+
Expect(tmpRows[0].IDAuthor).to.equal(1);
|
|
1605
|
+
|
|
1606
|
+
let tmpSyncEntity = _SyncFable.MeadowSync.MeadowSyncEntities['Author'];
|
|
1607
|
+
Expect(tmpSyncEntity.syncResults).to.be.an('object');
|
|
1608
|
+
Expect(tmpSyncEntity.syncResults.Created).to.be.greaterThan(0);
|
|
1609
|
+
|
|
1610
|
+
fDone();
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
);
|
|
1616
|
+
|
|
1617
|
+
suite
|
|
1618
|
+
(
|
|
1619
|
+
'Sync with Advanced ID Pagination',
|
|
1620
|
+
function()
|
|
1621
|
+
{
|
|
1622
|
+
let _SyncFable;
|
|
1623
|
+
let _SyncDB;
|
|
1624
|
+
|
|
1625
|
+
suiteSetup
|
|
1626
|
+
(
|
|
1627
|
+
function(fDone)
|
|
1628
|
+
{
|
|
1629
|
+
this.timeout(15000);
|
|
1630
|
+
|
|
1631
|
+
let tmpSyncSettings = {
|
|
1632
|
+
Product: 'SyncTestAdvanced',
|
|
1633
|
+
ProductVersion: '1.0.0',
|
|
1634
|
+
LogStreams: [{ streamtype: 'console', level: 'fatal' }],
|
|
1635
|
+
SQLite: { SQLiteFilePath: ':memory:' }
|
|
1636
|
+
};
|
|
1637
|
+
|
|
1638
|
+
_SyncFable = new libFable(tmpSyncSettings);
|
|
1639
|
+
|
|
1640
|
+
// Register SQLite provider for destination
|
|
1641
|
+
_SyncFable.serviceManager.addServiceType('MeadowSQLiteProvider', libMeadowConnectionSQLite);
|
|
1642
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowSQLiteProvider');
|
|
1643
|
+
|
|
1644
|
+
_SyncFable.MeadowSQLiteProvider.connectAsync(
|
|
1645
|
+
(pError) =>
|
|
1646
|
+
{
|
|
1647
|
+
if (pError) return fDone(pError);
|
|
1648
|
+
|
|
1649
|
+
_SyncDB = _SyncFable.MeadowSQLiteProvider.db;
|
|
1650
|
+
|
|
1651
|
+
// Set up MeadowCloneRestClient pointed at the test server
|
|
1652
|
+
const libMeadowCloneRestClient = require('../node_modules/meadow-integration/source/services/clone/Meadow-Service-RestClient.js');
|
|
1653
|
+
_SyncFable.serviceManager.addServiceType('MeadowCloneRestClient', libMeadowCloneRestClient);
|
|
1654
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowCloneRestClient',
|
|
1655
|
+
{
|
|
1656
|
+
ServerURL: `${_BaseURL}1.0/`,
|
|
1657
|
+
UserID: false,
|
|
1658
|
+
Password: false
|
|
1659
|
+
});
|
|
1660
|
+
|
|
1661
|
+
// Set up Meadow prototype (required by sync entities)
|
|
1662
|
+
const libMeadow = require('meadow');
|
|
1663
|
+
_SyncFable._MeadowPrototype = libMeadow;
|
|
1664
|
+
_SyncFable.Meadow = libMeadow.new(_SyncFable, 'SyncTest-Prototype');
|
|
1665
|
+
|
|
1666
|
+
// Set up MeadowSync with advanced ID pagination enabled
|
|
1667
|
+
const libMeadowSync = require('../node_modules/meadow-integration/source/services/clone/Meadow-Service-Sync.js');
|
|
1668
|
+
_SyncFable.serviceManager.addServiceType('MeadowSync', libMeadowSync);
|
|
1669
|
+
_SyncFable.serviceManager.instantiateServiceProvider('MeadowSync',
|
|
1670
|
+
{
|
|
1671
|
+
SyncEntityList: ['Author'],
|
|
1672
|
+
PageSize: 2,
|
|
1673
|
+
SyncDeletedRecords: false,
|
|
1674
|
+
UseAdvancedIDPagination: true
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1677
|
+
// Load the test schema into MeadowSync
|
|
1678
|
+
let tmpFullModel = require('./model/MeadowModel-Extended.json');
|
|
1679
|
+
_SyncFable.MeadowSync.loadMeadowSchema(tmpFullModel,
|
|
1680
|
+
(pSchemaError) =>
|
|
1681
|
+
{
|
|
1682
|
+
if (pSchemaError)
|
|
1683
|
+
{
|
|
1684
|
+
return fDone(pSchemaError);
|
|
1685
|
+
}
|
|
1686
|
+
return fDone();
|
|
1687
|
+
});
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
);
|
|
1691
|
+
|
|
1692
|
+
test
|
|
1693
|
+
(
|
|
1694
|
+
'Should sync Author records using advanced ID (keyset) pagination',
|
|
1695
|
+
function(fDone)
|
|
1696
|
+
{
|
|
1697
|
+
this.timeout(15000);
|
|
1698
|
+
|
|
1699
|
+
_SyncFable.MeadowSync.syncAll(
|
|
1700
|
+
(pSyncError) =>
|
|
1701
|
+
{
|
|
1702
|
+
Expect(pSyncError).to.not.exist;
|
|
1703
|
+
|
|
1704
|
+
// Query the destination database to verify records were copied
|
|
1705
|
+
let tmpRows = _SyncDB.prepare('SELECT * FROM Author WHERE Deleted = 0 ORDER BY IDAuthor').all();
|
|
1706
|
+
Expect(tmpRows.length).to.be.greaterThan(0);
|
|
1707
|
+
Expect(tmpRows[0].IDAuthor).to.equal(1);
|
|
1708
|
+
|
|
1709
|
+
let tmpSyncEntity = _SyncFable.MeadowSync.MeadowSyncEntities['Author'];
|
|
1710
|
+
Expect(tmpSyncEntity.syncResults).to.be.an('object');
|
|
1711
|
+
Expect(tmpSyncEntity.syncResults.Created).to.be.greaterThan(0);
|
|
1712
|
+
|
|
1713
|
+
// Verify that UseAdvancedIDPagination was set on the entity
|
|
1714
|
+
Expect(tmpSyncEntity.UseAdvancedIDPagination).to.equal(true);
|
|
1715
|
+
|
|
1716
|
+
fDone();
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
);
|
|
1720
|
+
|
|
1721
|
+
test
|
|
1722
|
+
(
|
|
1723
|
+
'Should produce the same record count as standard pagination',
|
|
1724
|
+
function(fDone)
|
|
1725
|
+
{
|
|
1726
|
+
// The advanced pagination destination should have the same records
|
|
1727
|
+
let tmpRows = _SyncDB.prepare('SELECT COUNT(*) as cnt FROM Author WHERE Deleted = 0').get();
|
|
1728
|
+
Expect(tmpRows.cnt).to.be.greaterThan(0);
|
|
1729
|
+
fDone();
|
|
1730
|
+
}
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
);
|
|
1512
1734
|
}
|
|
1513
1735
|
);
|