@resolveio/server-lib 20.9.9 → 20.9.11
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.
|
@@ -64,7 +64,7 @@ export declare class SubscriptionManager {
|
|
|
64
64
|
private ensureDependencyContainers;
|
|
65
65
|
private updateSubscriptionDependencies;
|
|
66
66
|
private normalizeDocumentId;
|
|
67
|
-
private
|
|
67
|
+
private getDocumentIdQueryCandidates;
|
|
68
68
|
private documentMatchesFilter;
|
|
69
69
|
private shouldInvalidateSubscription;
|
|
70
70
|
private shouldInvalidateSubscriptionForEvents;
|
|
@@ -73,7 +73,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
73
73
|
};
|
|
74
74
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
75
|
exports.SubscriptionManager = void 0;
|
|
76
|
-
var mongodb_1 = require("mongodb");
|
|
77
76
|
var NodeCache = require("node-cache");
|
|
78
77
|
var os_1 = require("os");
|
|
79
78
|
var flag_collection_1 = require("../collections/flag.collection");
|
|
@@ -1407,28 +1406,55 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1407
1406
|
}
|
|
1408
1407
|
return null;
|
|
1409
1408
|
};
|
|
1410
|
-
SubscriptionManager.prototype.
|
|
1411
|
-
|
|
1412
|
-
|
|
1409
|
+
SubscriptionManager.prototype.getDocumentIdQueryCandidates = function (documentId) {
|
|
1410
|
+
var candidates = [];
|
|
1411
|
+
if (documentId === undefined || documentId === null) {
|
|
1412
|
+
return [documentId];
|
|
1413
1413
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
return
|
|
1414
|
+
var addCandidate = function (value) {
|
|
1415
|
+
if (value === undefined || value === null) {
|
|
1416
|
+
return;
|
|
1417
1417
|
}
|
|
1418
|
-
|
|
1418
|
+
if (!candidates.includes(value)) {
|
|
1419
|
+
candidates.push(value);
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
addCandidate(documentId);
|
|
1423
|
+
if (typeof documentId === 'object') {
|
|
1424
|
+
if (typeof documentId.toHexString === 'function') {
|
|
1425
|
+
addCandidate(documentId.toHexString());
|
|
1426
|
+
}
|
|
1427
|
+
if (typeof documentId.toString === 'function') {
|
|
1428
|
+
var str = documentId.toString();
|
|
1429
|
+
if (str && str !== '[object Object]') {
|
|
1430
|
+
addCandidate(str);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
else if (typeof documentId !== 'string') {
|
|
1435
|
+
addCandidate(String(documentId));
|
|
1419
1436
|
}
|
|
1420
|
-
return
|
|
1437
|
+
return candidates;
|
|
1421
1438
|
};
|
|
1422
1439
|
SubscriptionManager.prototype.documentMatchesFilter = function (collection, documentId, filter) {
|
|
1423
1440
|
return __awaiter(this, void 0, void 0, function () {
|
|
1424
|
-
var db, filterCopy, idValue, combinedFilter, doc, _a;
|
|
1425
|
-
|
|
1426
|
-
|
|
1441
|
+
var db, filterCopy, idCandidates, idCandidates_1, idCandidates_1_1, idValue, combinedFilter, doc, e_6_1, _a;
|
|
1442
|
+
var e_6, _b;
|
|
1443
|
+
return __generator(this, function (_c) {
|
|
1444
|
+
switch (_c.label) {
|
|
1427
1445
|
case 0:
|
|
1428
|
-
|
|
1446
|
+
_c.trys.push([0, 9, , 10]);
|
|
1429
1447
|
db = resolveio_server_app_1.ResolveIOServer.getMainDB();
|
|
1430
1448
|
filterCopy = (0, common_1.deepCopy)(filter) || {};
|
|
1431
|
-
|
|
1449
|
+
idCandidates = this.getDocumentIdQueryCandidates(documentId);
|
|
1450
|
+
_c.label = 1;
|
|
1451
|
+
case 1:
|
|
1452
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
1453
|
+
idCandidates_1 = __values(idCandidates), idCandidates_1_1 = idCandidates_1.next();
|
|
1454
|
+
_c.label = 2;
|
|
1455
|
+
case 2:
|
|
1456
|
+
if (!!idCandidates_1_1.done) return [3 /*break*/, 5];
|
|
1457
|
+
idValue = idCandidates_1_1.value;
|
|
1432
1458
|
combinedFilter = {
|
|
1433
1459
|
$and: [
|
|
1434
1460
|
{ _id: idValue },
|
|
@@ -1436,21 +1462,39 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1436
1462
|
]
|
|
1437
1463
|
};
|
|
1438
1464
|
return [4 /*yield*/, db.collection(collection).findOne(combinedFilter)];
|
|
1439
|
-
case
|
|
1440
|
-
doc =
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1465
|
+
case 3:
|
|
1466
|
+
doc = _c.sent();
|
|
1467
|
+
if (doc) {
|
|
1468
|
+
return [2 /*return*/, true];
|
|
1469
|
+
}
|
|
1470
|
+
_c.label = 4;
|
|
1471
|
+
case 4:
|
|
1472
|
+
idCandidates_1_1 = idCandidates_1.next();
|
|
1473
|
+
return [3 /*break*/, 2];
|
|
1474
|
+
case 5: return [3 /*break*/, 8];
|
|
1475
|
+
case 6:
|
|
1476
|
+
e_6_1 = _c.sent();
|
|
1477
|
+
e_6 = { error: e_6_1 };
|
|
1478
|
+
return [3 /*break*/, 8];
|
|
1479
|
+
case 7:
|
|
1480
|
+
try {
|
|
1481
|
+
if (idCandidates_1_1 && !idCandidates_1_1.done && (_b = idCandidates_1.return)) _b.call(idCandidates_1);
|
|
1482
|
+
}
|
|
1483
|
+
finally { if (e_6) throw e_6.error; }
|
|
1484
|
+
return [7 /*endfinally*/];
|
|
1485
|
+
case 8: return [2 /*return*/, false];
|
|
1486
|
+
case 9:
|
|
1487
|
+
_a = _c.sent();
|
|
1444
1488
|
return [2 /*return*/, true];
|
|
1445
|
-
case
|
|
1489
|
+
case 10: return [2 /*return*/];
|
|
1446
1490
|
}
|
|
1447
1491
|
});
|
|
1448
1492
|
});
|
|
1449
1493
|
};
|
|
1450
1494
|
SubscriptionManager.prototype.shouldInvalidateSubscription = function (sub, collection, type, documentId) {
|
|
1451
1495
|
return __awaiter(this, void 0, void 0, function () {
|
|
1452
|
-
var trackedIds, filters, filters_1, filters_1_1, filter,
|
|
1453
|
-
var
|
|
1496
|
+
var trackedIds, filters, filters_1, filters_1_1, filter, e_7_1;
|
|
1497
|
+
var e_7, _a;
|
|
1454
1498
|
return __generator(this, function (_b) {
|
|
1455
1499
|
switch (_b.label) {
|
|
1456
1500
|
case 0:
|
|
@@ -1494,14 +1538,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1494
1538
|
return [3 /*break*/, 2];
|
|
1495
1539
|
case 5: return [3 /*break*/, 8];
|
|
1496
1540
|
case 6:
|
|
1497
|
-
|
|
1498
|
-
|
|
1541
|
+
e_7_1 = _b.sent();
|
|
1542
|
+
e_7 = { error: e_7_1 };
|
|
1499
1543
|
return [3 /*break*/, 8];
|
|
1500
1544
|
case 7:
|
|
1501
1545
|
try {
|
|
1502
1546
|
if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
|
|
1503
1547
|
}
|
|
1504
|
-
finally { if (
|
|
1548
|
+
finally { if (e_7) throw e_7.error; }
|
|
1505
1549
|
return [7 /*endfinally*/];
|
|
1506
1550
|
case 8:
|
|
1507
1551
|
this.dependencyDebug('Skip invalidation after dependency checks', { publication: sub.publication, collection: collection, type: type, documentId: documentId });
|
|
@@ -1512,8 +1556,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1512
1556
|
};
|
|
1513
1557
|
SubscriptionManager.prototype.shouldInvalidateSubscriptionForEvents = function (sub, collection, events) {
|
|
1514
1558
|
return __awaiter(this, void 0, void 0, function () {
|
|
1515
|
-
var sawInsert, sawDelete, events_1, events_1_1, event_1, normalizedDocumentId,
|
|
1516
|
-
var
|
|
1559
|
+
var sawInsert, sawDelete, events_1, events_1_1, event_1, normalizedDocumentId, e_8_1, paginationMeta, paginationReasons;
|
|
1560
|
+
var e_8, _a;
|
|
1517
1561
|
return __generator(this, function (_b) {
|
|
1518
1562
|
switch (_b.label) {
|
|
1519
1563
|
case 0:
|
|
@@ -1545,14 +1589,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1545
1589
|
return [3 /*break*/, 2];
|
|
1546
1590
|
case 5: return [3 /*break*/, 8];
|
|
1547
1591
|
case 6:
|
|
1548
|
-
|
|
1549
|
-
|
|
1592
|
+
e_8_1 = _b.sent();
|
|
1593
|
+
e_8 = { error: e_8_1 };
|
|
1550
1594
|
return [3 /*break*/, 8];
|
|
1551
1595
|
case 7:
|
|
1552
1596
|
try {
|
|
1553
1597
|
if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
|
|
1554
1598
|
}
|
|
1555
|
-
finally { if (
|
|
1599
|
+
finally { if (e_8) throw e_8.error; }
|
|
1556
1600
|
return [7 /*endfinally*/];
|
|
1557
1601
|
case 8:
|
|
1558
1602
|
paginationMeta = this.getPaginationMeta(sub, collection);
|