@resolveio/server-lib 4.4.5 → 4.4.7

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.
@@ -510,22 +510,16 @@ 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 oplogQueue, uniquePubs, uniqueOplog_1, needIds_1, _loop_3, i, i, oplog, _loop_4, j, state_1;
513
+ var uniquePubs, uniqueOplog_1, 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
- oplogQueue = common_1.deepCopy(this._oplogQueue);
520
519
  this._oplogQueue = [];
521
520
  uniquePubs = [];
522
- uniqueOplog_1 = [];
521
+ uniqueOplog_1 = common_1.deepCopy(this._oplogQueue);
523
522
  needIds_1 = {};
524
- oplogQueue.forEach(function (oplog) {
525
- if (!uniqueOplog_1.filter(function (a) { return JSON.stringify(a) === JSON.stringify(oplog); }).length) {
526
- uniqueOplog_1.push(oplog);
527
- }
528
- });
529
523
  uniqueOplog_1.forEach(function (oplog) {
530
524
  var schemaErrors = null;
531
525
  try {
@@ -584,11 +578,12 @@ var SubscriptionManager = /** @class */ (function () {
584
578
  if (!(i >= 0)) return [3 /*break*/, 10];
585
579
  oplog = uniqueOplog_1[i];
586
580
  _loop_4 = function (j) {
587
- var _a, sub, _b;
588
- return __generator(this, function (_c) {
589
- switch (_c.label) {
581
+ var _a, _b, sub, _c;
582
+ return __generator(this, function (_d) {
583
+ switch (_d.label) {
590
584
  case 0:
591
585
  sub = that._subscriptions[j];
586
+ if (!(oplog.type === 'update')) return [3 /*break*/, 4];
592
587
  if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
593
588
  if (sub.preSubscriptionData) {
594
589
  if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
@@ -602,10 +597,10 @@ var SubscriptionManager = /** @class */ (function () {
602
597
  }
603
598
  }
604
599
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
605
- _b = sub;
600
+ _c = sub;
606
601
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
607
602
  case 1:
608
- _b.preSubscriptionData = _c.sent();
603
+ _c.preSubscriptionData = _d.sent();
609
604
  if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
610
605
  if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
611
606
  uniquePubs.push(sub);
@@ -637,8 +632,22 @@ var SubscriptionManager = /** @class */ (function () {
637
632
  }
638
633
  return [2 /*return*/, "break"];
639
634
  }
640
- _c.label = 3;
641
- case 3: return [2 /*return*/];
635
+ _d.label = 3;
636
+ case 3: return [3 /*break*/, 5];
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*/];
642
651
  }
643
652
  });
644
653
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.4.5",
3
+ "version": "4.4.7",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {