@resolveio/server-lib 4.3.4 → 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.
|
@@ -409,7 +409,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
409
409
|
else if (collection === 'support-tickets') {
|
|
410
410
|
_this._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);
|
|
411
411
|
}
|
|
412
|
-
if (!collection.endsWith('.versions')) {
|
|
412
|
+
if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
|
|
413
413
|
_this._oplogQueue.push({
|
|
414
414
|
type: 'insert',
|
|
415
415
|
collection: collection,
|
|
@@ -427,7 +427,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
427
427
|
if (collection === 'cron-jobs') {
|
|
428
428
|
_this._mainServer.getCronManager().checkCronJobsForUpdates();
|
|
429
429
|
}
|
|
430
|
-
if (!collection.endsWith('.versions')) {
|
|
430
|
+
if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
|
|
431
431
|
_this._oplogQueue.push({
|
|
432
432
|
type: 'update',
|
|
433
433
|
collection: collection,
|
|
@@ -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;
|
|
@@ -761,7 +778,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
761
778
|
return __generator(this, function (_c) {
|
|
762
779
|
that = this;
|
|
763
780
|
if (subscription.publication !== 'superadminAPM') {
|
|
764
|
-
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection);
|
|
781
|
+
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, subscription.subscriptionData);
|
|
765
782
|
}
|
|
766
783
|
if (!that._publications[subscription.publication].ws_specific) { // Same pub for all users
|
|
767
784
|
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
@@ -814,7 +831,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
814
831
|
return __generator(this, function (_b) {
|
|
815
832
|
that = this;
|
|
816
833
|
if (subscription.publication !== 'superadminAPM') {
|
|
817
|
-
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection);
|
|
834
|
+
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, subscription.subscriptionData);
|
|
818
835
|
}
|
|
819
836
|
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
820
837
|
subscription.clients.forEach(function (client) {
|
package/methods/logs.js
CHANGED
|
@@ -28,14 +28,15 @@ function loadLogMethods(methodManager) {
|
|
|
28
28
|
},
|
|
29
29
|
insertSubscriptionLog: {
|
|
30
30
|
skipQueue: true,
|
|
31
|
-
function: function (type, subscription, collection_name) {
|
|
31
|
+
function: function (type, subscription, collection_name, subData) {
|
|
32
32
|
return log_subscription_collection_1.LogSubscriptions.create({
|
|
33
33
|
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
34
34
|
__v: 0,
|
|
35
35
|
date: new Date(),
|
|
36
36
|
type: type,
|
|
37
37
|
subscription: subscription,
|
|
38
|
-
collection_name: collection_name
|
|
38
|
+
collection_name: collection_name,
|
|
39
|
+
subData: subData
|
|
39
40
|
});
|
|
40
41
|
},
|
|
41
42
|
skipValidation: true
|