@resolveio/server-lib 4.4.7 → 4.4.9
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/managers/subscription.manager.js +15 -26
- package/package.json +1 -1
|
@@ -510,15 +510,15 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
510
510
|
var _this = this;
|
|
511
511
|
var that = this;
|
|
512
512
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
513
|
-
var
|
|
513
|
+
var uniqueOplog_1, uniquePubs, needIds_1, _loop_3, i, i, oplog, _loop_4, j, state_1;
|
|
514
514
|
var _this = this;
|
|
515
515
|
return __generator(this, function (_a) {
|
|
516
516
|
switch (_a.label) {
|
|
517
517
|
case 0:
|
|
518
518
|
if (!this._oplogQueue.length) return [3 /*break*/, 11];
|
|
519
|
+
uniqueOplog_1 = common_1.deepCopy(this._oplogQueue);
|
|
519
520
|
this._oplogQueue = [];
|
|
520
521
|
uniquePubs = [];
|
|
521
|
-
uniqueOplog_1 = common_1.deepCopy(this._oplogQueue);
|
|
522
522
|
needIds_1 = {};
|
|
523
523
|
uniqueOplog_1.forEach(function (oplog) {
|
|
524
524
|
var schemaErrors = null;
|
|
@@ -578,16 +578,16 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
578
578
|
if (!(i >= 0)) return [3 /*break*/, 10];
|
|
579
579
|
oplog = uniqueOplog_1[i];
|
|
580
580
|
_loop_4 = function (j) {
|
|
581
|
-
var _a,
|
|
582
|
-
return __generator(this, function (
|
|
583
|
-
switch (
|
|
581
|
+
var _a, sub, _b;
|
|
582
|
+
return __generator(this, function (_c) {
|
|
583
|
+
switch (_c.label) {
|
|
584
584
|
case 0:
|
|
585
585
|
sub = that._subscriptions[j];
|
|
586
|
-
if (!(oplog.type === 'update')) return [3 /*break*/, 4];
|
|
587
586
|
if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
|
|
588
587
|
if (sub.preSubscriptionData) {
|
|
589
588
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
590
589
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
590
|
+
sub['oplog'] = oplog;
|
|
591
591
|
uniquePubs.push(sub);
|
|
592
592
|
}
|
|
593
593
|
else {
|
|
@@ -597,12 +597,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
|
|
600
|
-
|
|
600
|
+
_b = sub;
|
|
601
601
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
602
602
|
case 1:
|
|
603
|
-
|
|
603
|
+
_b.preSubscriptionData = _c.sent();
|
|
604
604
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
605
605
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
606
|
+
sub['oplog'] = oplog;
|
|
606
607
|
uniquePubs.push(sub);
|
|
607
608
|
}
|
|
608
609
|
else {
|
|
@@ -615,6 +616,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
615
616
|
if (that._publications[sub.publication].fetchFunction) {
|
|
616
617
|
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
617
618
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
619
|
+
sub['oplog'] = oplog;
|
|
618
620
|
uniquePubs.push(sub);
|
|
619
621
|
}
|
|
620
622
|
else {
|
|
@@ -625,6 +627,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
625
627
|
}
|
|
626
628
|
else {
|
|
627
629
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
630
|
+
sub['oplog'] = oplog;
|
|
628
631
|
uniquePubs.push(sub);
|
|
629
632
|
}
|
|
630
633
|
else {
|
|
@@ -632,22 +635,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
632
635
|
}
|
|
633
636
|
return [2 /*return*/, "break"];
|
|
634
637
|
}
|
|
635
|
-
|
|
636
|
-
case 3: return [
|
|
637
|
-
case 4:
|
|
638
|
-
if (oplog.type === 'insert') {
|
|
639
|
-
if (sub.collections.includes(oplog.collection) && (that._publications[sub.publication].preFunction || !that._publications[sub.publication].fetchFunction || (_b = that._publications[sub.publication]).fetchFunction.apply(_b, [oplog.doc].concat(sub.subscriptionData)))) {
|
|
640
|
-
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
641
|
-
uniquePubs.push(sub);
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
uniqueOplog_1.splice(i, 1);
|
|
645
|
-
}
|
|
646
|
-
return [2 /*return*/, "break"];
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
_d.label = 5;
|
|
650
|
-
case 5: return [2 /*return*/];
|
|
638
|
+
_c.label = 3;
|
|
639
|
+
case 3: return [2 /*return*/];
|
|
651
640
|
}
|
|
652
641
|
});
|
|
653
642
|
};
|
|
@@ -668,8 +657,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
668
657
|
i--;
|
|
669
658
|
return [3 /*break*/, 5];
|
|
670
659
|
case 10:
|
|
671
|
-
|
|
672
|
-
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
660
|
+
uniquePubs.forEach(function (pub) {
|
|
661
|
+
_this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type);
|
|
673
662
|
});
|
|
674
663
|
_a.label = 11;
|
|
675
664
|
case 11: return [2 /*return*/];
|