@resolveio/server-lib 4.3.10 → 4.3.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.
@@ -508,15 +508,15 @@ var SubscriptionManager = /** @class */ (function () {
508
508
  var _this = this;
509
509
  var that = this;
510
510
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
511
- var oplogQueue, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i, _loop_4, i;
511
+ var oplogQueue, uniquePubs, uniqueOplog_1, needIds_1, _loop_3, i, i, oplog, _loop_4, j, state_1;
512
512
  var _this = this;
513
513
  return __generator(this, function (_a) {
514
514
  switch (_a.label) {
515
515
  case 0:
516
- if (!this._oplogQueue.length) return [3 /*break*/, 9];
516
+ if (!this._oplogQueue.length) return [3 /*break*/, 11];
517
517
  oplogQueue = common_1.deepCopy(this._oplogQueue);
518
518
  this._oplogQueue = [];
519
- uniquePubs_1 = [];
519
+ uniquePubs = [];
520
520
  uniqueOplog_1 = [];
521
521
  needIds_1 = {};
522
522
  oplogQueue.forEach(function (oplog) {
@@ -576,120 +576,92 @@ var SubscriptionManager = /** @class */ (function () {
576
576
  i++;
577
577
  return [3 /*break*/, 1];
578
578
  case 4:
579
- _loop_4 = function (i) {
580
- var oplog, _loop_5, j;
581
- return __generator(this, function (_a) {
582
- switch (_a.label) {
579
+ i = uniqueOplog_1.length - 1;
580
+ _a.label = 5;
581
+ case 5:
582
+ if (!(i >= 0)) return [3 /*break*/, 10];
583
+ oplog = uniqueOplog_1[i];
584
+ _loop_4 = function (j) {
585
+ var _a, sub, _b;
586
+ return __generator(this, function (_c) {
587
+ switch (_c.label) {
583
588
  case 0:
584
- oplog = uniqueOplog_1[i];
585
- _loop_5 = function (j) {
586
- var _a, sub, _b;
587
- return __generator(this, function (_c) {
588
- switch (_c.label) {
589
- case 0:
590
- sub = that._subscriptions[j];
591
- if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
592
- if (sub.preSubscriptionData) {
593
- if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
594
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
595
- uniquePubs_1.push(sub);
596
- }
597
- else {
598
- uniqueOplog_1.splice(i, 1);
599
- }
600
- return [2 /*return*/, "continue"];
601
- }
602
- }
603
- if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
604
- _b = sub;
605
- return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
606
- case 1:
607
- _b.preSubscriptionData = _c.sent();
608
- if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
609
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
610
- uniquePubs_1.push(sub);
611
- }
612
- else {
613
- uniqueOplog_1.splice(i, 1);
614
- }
615
- return [2 /*return*/, "continue"];
616
- }
617
- return [3 /*break*/, 3];
618
- case 2:
619
- if (that._publications[sub.publication].ws_specific) {
620
- sub.clients.forEach(function (client) {
621
- var _a;
622
- if (that._publications[sub.publication].fetchFunction) {
623
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
624
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
625
- uniquePubs_1.push(sub);
626
- }
627
- else {
628
- uniqueOplog_1.splice(i, 1);
629
- }
630
- }
631
- }
632
- });
633
- }
634
- else {
635
- if (that._publications[sub.publication].fetchFunction) {
636
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document].concat(sub.subscriptionData))) {
637
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
638
- uniquePubs_1.push(sub);
639
- }
640
- else {
641
- uniqueOplog_1.splice(i, 1);
642
- }
643
- return [2 /*return*/, "continue"];
644
- }
645
- }
646
- else {
647
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
648
- uniquePubs_1.push(sub);
649
- }
650
- else {
651
- uniqueOplog_1.splice(i, 1);
652
- }
653
- return [2 /*return*/, "continue"];
654
- }
655
- }
656
- _c.label = 3;
657
- case 3: return [2 /*return*/];
589
+ sub = that._subscriptions[j];
590
+ if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
591
+ if (sub.preSubscriptionData) {
592
+ if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
593
+ if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
594
+ uniquePubs.push(sub);
658
595
  }
659
- });
660
- };
661
- j = 0;
662
- _a.label = 1;
596
+ else {
597
+ uniqueOplog_1.splice(i, 1);
598
+ }
599
+ return [2 /*return*/, "break"];
600
+ }
601
+ }
602
+ if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
603
+ _b = sub;
604
+ return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
663
605
  case 1:
664
- if (!(j < that._subscriptions.length)) return [3 /*break*/, 4];
665
- return [5 /*yield**/, _loop_5(j)];
606
+ _b.preSubscriptionData = _c.sent();
607
+ if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
608
+ if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
609
+ uniquePubs.push(sub);
610
+ }
611
+ else {
612
+ uniqueOplog_1.splice(i, 1);
613
+ }
614
+ return [2 /*return*/, "break"];
615
+ }
616
+ return [3 /*break*/, 3];
666
617
  case 2:
667
- _a.sent();
668
- _a.label = 3;
669
- case 3:
670
- j++;
671
- return [3 /*break*/, 1];
672
- case 4: return [2 /*return*/];
618
+ if (that._publications[sub.publication].fetchFunction) {
619
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document].concat(sub.subscriptionData))) {
620
+ if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
621
+ uniquePubs.push(sub);
622
+ }
623
+ else {
624
+ uniqueOplog_1.splice(i, 1);
625
+ }
626
+ return [2 /*return*/, "break"];
627
+ }
628
+ }
629
+ else {
630
+ if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
631
+ uniquePubs.push(sub);
632
+ }
633
+ else {
634
+ uniqueOplog_1.splice(i, 1);
635
+ }
636
+ return [2 /*return*/, "break"];
637
+ }
638
+ _c.label = 3;
639
+ case 3: return [2 /*return*/];
673
640
  }
674
641
  });
675
642
  };
676
- i = uniqueOplog_1.length - 1;
677
- _a.label = 5;
678
- case 5:
679
- if (!(i >= 0)) return [3 /*break*/, 8];
680
- return [5 /*yield**/, _loop_4(i)];
643
+ j = 0;
644
+ _a.label = 6;
681
645
  case 6:
682
- _a.sent();
683
- _a.label = 7;
646
+ if (!(j < that._subscriptions.length)) return [3 /*break*/, 9];
647
+ return [5 /*yield**/, _loop_4(j)];
684
648
  case 7:
649
+ state_1 = _a.sent();
650
+ if (state_1 === "break")
651
+ return [3 /*break*/, 9];
652
+ _a.label = 8;
653
+ case 8:
654
+ j++;
655
+ return [3 /*break*/, 6];
656
+ case 9:
685
657
  i--;
686
658
  return [3 /*break*/, 5];
687
- case 8:
659
+ case 10:
688
660
  uniqueOplog_1.forEach(function (oplog) {
689
661
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
690
662
  });
691
- _a.label = 9;
692
- case 9: return [2 /*return*/];
663
+ _a.label = 11;
664
+ case 11: return [2 /*return*/];
693
665
  }
694
666
  });
695
667
  }); }, 500);
@@ -716,12 +688,12 @@ var SubscriptionManager = /** @class */ (function () {
716
688
  // Check to see if any pubs need to refetch due to Mongo operation
717
689
  SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
718
690
  return __awaiter(this, void 0, void 0, function () {
719
- var that, _loop_6, i;
691
+ var that, _loop_5, i;
720
692
  return __generator(this, function (_a) {
721
693
  switch (_a.label) {
722
694
  case 0:
723
695
  that = this;
724
- _loop_6 = function (i) {
696
+ _loop_5 = function (i) {
725
697
  var _a, _b, sub, _c, _d;
726
698
  return __generator(this, function (_e) {
727
699
  switch (_e.label) {
@@ -787,7 +759,7 @@ var SubscriptionManager = /** @class */ (function () {
787
759
  _a.label = 1;
788
760
  case 1:
789
761
  if (!(i < that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length)) return [3 /*break*/, 4];
790
- return [5 /*yield**/, _loop_6(i)];
762
+ return [5 /*yield**/, _loop_5(i)];
791
763
  case 2:
792
764
  _a.sent();
793
765
  _a.label = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.3.10",
3
+ "version": "4.3.11",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {