@resolveio/server-lib 4.3.3 → 4.3.5

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.
@@ -30,6 +30,13 @@ var schema = {
30
30
  },
31
31
  collection_name: {
32
32
  type: String
33
+ },
34
+ subData: {
35
+ type: Array
36
+ },
37
+ 'subData.$': {
38
+ type: Object,
39
+ blackbox: true
33
40
  }
34
41
  };
35
42
  var DefaultSchema = new mongoose_1.Schema(schema, {
@@ -409,11 +409,13 @@ var SubscriptionManager = /** @class */ (function () {
409
409
  else if (collection === 'support-tickets') {
410
410
  _this._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);
411
411
  }
412
- _this._oplogQueue.push({
413
- type: 'insert',
414
- collection: collection,
415
- doc: doc.o
416
- });
412
+ if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
413
+ _this._oplogQueue.push({
414
+ type: 'insert',
415
+ collection: collection,
416
+ doc: doc.o
417
+ });
418
+ }
417
419
  });
418
420
  oplog.on('update', function (doc) {
419
421
  var nsArray = doc.ns.split('.');
@@ -425,11 +427,13 @@ var SubscriptionManager = /** @class */ (function () {
425
427
  if (collection === 'cron-jobs') {
426
428
  _this._mainServer.getCronManager().checkCronJobsForUpdates();
427
429
  }
428
- _this._oplogQueue.push({
429
- type: 'update',
430
- collection: collection,
431
- doc: doc.o
432
- });
430
+ if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
431
+ _this._oplogQueue.push({
432
+ type: 'update',
433
+ collection: collection,
434
+ doc: doc.o
435
+ });
436
+ }
433
437
  });
434
438
  oplog.on('delete', function (doc) {
435
439
  var nsArray = doc.ns.split('.');
@@ -515,7 +519,7 @@ var SubscriptionManager = /** @class */ (function () {
515
519
  this._oplogQueue = [];
516
520
  uniqueOplog_1 = [];
517
521
  needIds_1 = {};
518
- console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
522
+ // console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
519
523
  oplogQueue.forEach(function (oplog) {
520
524
  if (!uniqueOplog_1.filter(function (a) { return JSON.stringify(a) === JSON.stringify(oplog); }).length) {
521
525
  uniqueOplog_1.push(oplog);
@@ -550,7 +554,12 @@ var SubscriptionManager = /** @class */ (function () {
550
554
  case 1:
551
555
  docs = _a.sent();
552
556
  needIds_1[collection].forEach(function (id_doc) {
553
- uniqueOplog_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; })[0];
557
+ if (uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; })[0]) {
558
+ uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; })[0];
559
+ }
560
+ else {
561
+ console.log('PROBLEMAAAAAAAA');
562
+ }
554
563
  });
555
564
  return [2 /*return*/];
556
565
  }
@@ -568,7 +577,7 @@ var SubscriptionManager = /** @class */ (function () {
568
577
  i++;
569
578
  return [3 /*break*/, 1];
570
579
  case 4:
571
- console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog_1.length);
580
+ // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
572
581
  uniqueOplog_1.forEach(function (oplog) {
573
582
  // console.log('OPLOG QUEUE END - Oplog', oplog);
574
583
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
@@ -752,7 +761,7 @@ var SubscriptionManager = /** @class */ (function () {
752
761
  return __generator(this, function (_c) {
753
762
  that = this;
754
763
  if (subscription.publication !== 'superadminAPM') {
755
- that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection);
764
+ that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, subscription.subscriptionData);
756
765
  }
757
766
  if (!that._publications[subscription.publication].ws_specific) { // Same pub for all users
758
767
  (_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
@@ -805,7 +814,7 @@ var SubscriptionManager = /** @class */ (function () {
805
814
  return __generator(this, function (_b) {
806
815
  that = this;
807
816
  if (subscription.publication !== 'superadminAPM') {
808
- that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection);
817
+ that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, subscription.subscriptionData);
809
818
  }
810
819
  (_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
811
820
  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
@@ -4,5 +4,6 @@ export interface LogSubscriptionModel extends CollectionDocument {
4
4
  type: LogSubscriptionType;
5
5
  subscription: string;
6
6
  collection_name: string;
7
+ subData: any[];
7
8
  }
8
9
  export declare type LogSubscriptionType = 'insert' | 'update' | 'delete';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.3.3",
3
+ "version": "4.3.5",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {