@resolveio/server-lib 4.2.9 → 4.3.0

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.
@@ -504,7 +504,7 @@ var SubscriptionManager = /** @class */ (function () {
504
504
  var _this = this;
505
505
  var that = this;
506
506
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
507
- var oplogQueue_1, uniquePubs, uniqueOplog, needIds_1, _loop_3, i;
507
+ var oplogQueue_1, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i;
508
508
  var _this = this;
509
509
  return __generator(this, function (_a) {
510
510
  switch (_a.label) {
@@ -512,8 +512,8 @@ var SubscriptionManager = /** @class */ (function () {
512
512
  if (!this._oplogQueue.length) return [3 /*break*/, 5];
513
513
  oplogQueue_1 = common_1.deepCopy(this._oplogQueue);
514
514
  this._oplogQueue = [];
515
- uniquePubs = [];
516
- uniqueOplog = [];
515
+ uniquePubs_1 = [];
516
+ uniqueOplog_1 = [];
517
517
  needIds_1 = {};
518
518
  // console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
519
519
  oplogQueue_1.forEach(function (oplog) {
@@ -550,7 +550,7 @@ var SubscriptionManager = /** @class */ (function () {
550
550
  case 1:
551
551
  docs = _a.sent();
552
552
  needIds_1[collection].forEach(function (id_doc) {
553
- oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; });
553
+ oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; })[0];
554
554
  });
555
555
  return [2 /*return*/];
556
556
  }
@@ -569,54 +569,59 @@ var SubscriptionManager = /** @class */ (function () {
569
569
  return [3 /*break*/, 1];
570
570
  case 4:
571
571
  // console.log('----------------OPLOG QUEUE START AFTER DATA--------------------', new Date(), oplogQueue.length);
572
- // oplogQueue.forEach(async (oplog) => {
573
- // // console.log('OPLOG QUEUE START - Oplog', oplog);
574
- // for (let i = 0; i < that._subscriptions.length; i++) {
575
- // let sub = that._subscriptions[i];
576
- // if (sub.collections.includes(oplog.collection)) {
577
- // if (sub.preSubscriptionData) {
578
- // if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
579
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
580
- // uniquePubs.push(sub);
581
- // uniqueOplog.push(oplog);
582
- // }
583
- // continue;
584
- // }
585
- // }
586
- // if (that._publications[sub.publication].preFunction) {
587
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
588
- // uniquePubs.push(sub);
589
- // uniqueOplog.push(oplog);
590
- // }
591
- // continue;
592
- // }
593
- // else {
594
- // if (that._publications[sub.publication].fetchFunction) {
595
- // if (that._publications[sub.publication].fetchFunction(oplog.doc, ...sub.subscriptionData)) {
596
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
597
- // uniquePubs.push(sub);
598
- // uniqueOplog.push(oplog);
599
- // }
600
- // continue;
601
- // }
602
- // }
603
- // else {
604
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
605
- // uniquePubs.push(sub);
606
- // uniqueOplog.push(oplog);
607
- // }
608
- // continue;
609
- // }
610
- // }
611
- // }
612
- // }
613
- // });
572
+ oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
573
+ var _loop_4, i;
574
+ return __generator(this, function (_a) {
575
+ _loop_4 = function (i) {
576
+ var _a;
577
+ var sub = that._subscriptions[i];
578
+ if (sub.collections.includes(oplog.collection)) {
579
+ if (sub.preSubscriptionData) {
580
+ if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
581
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
582
+ uniquePubs_1.push(sub);
583
+ uniqueOplog_1.push(oplog);
584
+ }
585
+ return "continue";
586
+ }
587
+ }
588
+ if (that._publications[sub.publication].preFunction) {
589
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
590
+ uniquePubs_1.push(sub);
591
+ uniqueOplog_1.push(oplog);
592
+ }
593
+ return "continue";
594
+ }
595
+ else {
596
+ if (that._publications[sub.publication].fetchFunction) {
597
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
598
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
599
+ uniquePubs_1.push(sub);
600
+ uniqueOplog_1.push(oplog);
601
+ }
602
+ return "continue";
603
+ }
604
+ }
605
+ else {
606
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
607
+ uniquePubs_1.push(sub);
608
+ uniqueOplog_1.push(oplog);
609
+ }
610
+ return "continue";
611
+ }
612
+ }
613
+ }
614
+ };
615
+ // console.log('OPLOG QUEUE START - Oplog', oplog);
616
+ for (i = 0; i < that._subscriptions.length; i++) {
617
+ _loop_4(i);
618
+ }
619
+ return [2 /*return*/];
620
+ });
621
+ }); });
614
622
  // // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
615
- // uniqueOplog.forEach(oplog => {
616
- // // console.log('OPLOG QUEUE END - Oplog', oplog);
617
- // this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
618
- // });
619
- oplogQueue_1.forEach(function (oplog) {
623
+ uniqueOplog_1.forEach(function (oplog) {
624
+ // console.log('OPLOG QUEUE END - Oplog', oplog);
620
625
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
621
626
  });
622
627
  _a.label = 5;
@@ -698,6 +703,7 @@ var SubscriptionManager = /** @class */ (function () {
698
703
  if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
699
704
  that.sendPubData(sub, type, collection);
700
705
  }
706
+ // else
701
707
  }
702
708
  else {
703
709
  that.sendPubData(sub, type, collection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.2.9",
3
+ "version": "4.3.0",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {