@resolveio/server-lib 4.3.5 → 4.3.6
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 +77 -60
- package/package.json +1 -1
|
@@ -519,7 +519,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
519
519
|
this._oplogQueue = [];
|
|
520
520
|
uniqueOplog_1 = [];
|
|
521
521
|
needIds_1 = {};
|
|
522
|
-
// console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
|
|
523
522
|
oplogQueue.forEach(function (oplog) {
|
|
524
523
|
if (!uniqueOplog_1.filter(function (a) { return JSON.stringify(a) === JSON.stringify(oplog); }).length) {
|
|
525
524
|
uniqueOplog_1.push(oplog);
|
|
@@ -577,9 +576,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
577
576
|
i++;
|
|
578
577
|
return [3 /*break*/, 1];
|
|
579
578
|
case 4:
|
|
580
|
-
// console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
|
|
581
579
|
uniqueOplog_1.forEach(function (oplog) {
|
|
582
|
-
// console.log('OPLOG QUEUE END - Oplog', oplog);
|
|
583
580
|
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
584
581
|
});
|
|
585
582
|
_a.label = 5;
|
|
@@ -609,70 +606,90 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
609
606
|
// Collection: Collection Document Lives In
|
|
610
607
|
// Check to see if any pubs need to refetch due to Mongo operation
|
|
611
608
|
SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
var _c, _d;
|
|
617
|
-
return __generator(this, function (_e) {
|
|
618
|
-
switch (_e.label) {
|
|
609
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
610
|
+
var that, _loop_4, i;
|
|
611
|
+
return __generator(this, function (_a) {
|
|
612
|
+
switch (_a.label) {
|
|
619
613
|
case 0:
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
614
|
+
that = this;
|
|
615
|
+
_loop_4 = function (i) {
|
|
616
|
+
var sub, _a, _b;
|
|
617
|
+
var _c, _d;
|
|
618
|
+
return __generator(this, function (_e) {
|
|
619
|
+
switch (_e.label) {
|
|
620
|
+
case 0:
|
|
621
|
+
sub = that._subscriptions.filter(function (a) { return a.collections.includes(collection); })[i];
|
|
622
|
+
if (!sub.preSubscriptionData) return [3 /*break*/, 2];
|
|
623
|
+
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
|
|
624
|
+
that.sendPubData(sub, type, collection);
|
|
625
|
+
_a = sub;
|
|
626
|
+
return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
|
|
627
|
+
case 1:
|
|
628
|
+
_a.preSubscriptionData = _e.sent();
|
|
629
|
+
_e.label = 2;
|
|
630
|
+
case 2:
|
|
631
|
+
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
|
|
632
|
+
_b = sub;
|
|
633
|
+
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
634
|
+
case 3:
|
|
635
|
+
_b.preSubscriptionData = _e.sent();
|
|
636
|
+
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
637
|
+
that.sendPubData(sub, type, collection);
|
|
638
|
+
}
|
|
639
|
+
return [3 /*break*/, 5];
|
|
640
|
+
case 4:
|
|
641
|
+
if (that._publications[sub.publication].ws_specific) {
|
|
642
|
+
sub.clients.forEach(function (client) {
|
|
643
|
+
var _a;
|
|
644
|
+
if (that._publications[sub.publication].fetchFunction) {
|
|
645
|
+
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
|
|
646
|
+
that._wss.clients.forEach(function (ws) {
|
|
647
|
+
if (ws['id_socket'] === client.id_socket) {
|
|
648
|
+
that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
that._wss.clients.forEach(function (ws) {
|
|
655
|
+
if (ws['id_socket'] === client.id_socket) {
|
|
656
|
+
that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
if (that._publications[sub.publication].fetchFunction) {
|
|
664
|
+
if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
|
|
665
|
+
that.sendPubData(sub, type, collection);
|
|
666
|
+
}
|
|
667
|
+
// else
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
that.sendPubData(sub, type, collection);
|
|
647
671
|
}
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
else {
|
|
652
|
-
that._wss.clients.forEach(function (ws) {
|
|
653
|
-
if (ws['id_socket'] === client.id_socket) {
|
|
654
|
-
that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
|
|
655
672
|
}
|
|
656
|
-
|
|
673
|
+
_e.label = 5;
|
|
674
|
+
case 5: return [2 /*return*/];
|
|
657
675
|
}
|
|
658
676
|
});
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
case 5: return [2 /*return*/];
|
|
677
|
+
};
|
|
678
|
+
i = 0;
|
|
679
|
+
_a.label = 1;
|
|
680
|
+
case 1:
|
|
681
|
+
if (!(i < that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length)) return [3 /*break*/, 4];
|
|
682
|
+
return [5 /*yield**/, _loop_4(i)];
|
|
683
|
+
case 2:
|
|
684
|
+
_a.sent();
|
|
685
|
+
_a.label = 3;
|
|
686
|
+
case 3:
|
|
687
|
+
i++;
|
|
688
|
+
return [3 /*break*/, 1];
|
|
689
|
+
case 4: return [2 /*return*/];
|
|
673
690
|
}
|
|
674
691
|
});
|
|
675
|
-
});
|
|
692
|
+
});
|
|
676
693
|
};
|
|
677
694
|
SubscriptionManager.prototype.checkSupportPubsForChanges = function (collection, document) {
|
|
678
695
|
var _this = this;
|