@resolveio/server-lib 5.2.18-newrole → 5.2.19

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.
@@ -22,6 +22,13 @@ var schema = {
22
22
  type: Date,
23
23
  optional: true
24
24
  },
25
+ readonly: {
26
+ type: Boolean,
27
+ optional: true
28
+ },
29
+ active: {
30
+ type: Boolean
31
+ },
25
32
  attempts: {
26
33
  type: Number,
27
34
  optional: true
@@ -58,67 +65,53 @@ var schema = {
58
65
  type: String
59
66
  },
60
67
  roles: {
61
- type: Object
62
- },
63
- 'roles.super_admin': {
64
- type: Boolean
65
- },
66
- 'roles.approvals': {
67
68
  type: Array
68
69
  },
69
- 'roles.approvals.$': {
70
- type: Object
71
- },
72
- 'roles.approvals.$.name': {
70
+ 'roles.$': {
73
71
  type: String
74
72
  },
75
- 'roles.approvals.$.type': {
76
- type: String
73
+ phonenumber: {
74
+ type: String,
75
+ optional: true
77
76
  },
78
- 'roles.approvals.$.accounting_code': {
79
- type: String
77
+ other: {
78
+ type: Object,
79
+ blackbox: true,
80
+ optional: true
80
81
  },
81
- 'roles.groups': {
82
- type: Array
82
+ assets: {
83
+ type: Array,
84
+ optional: true
83
85
  },
84
- 'roles.groups.$': {
86
+ 'assets.$': {
85
87
  type: Object
86
88
  },
87
- 'roles.groups.$.name': {
89
+ 'assets.$.type': {
88
90
  type: String
89
91
  },
90
- 'roles.groups.$.views': {
91
- type: Array
92
- },
93
- 'roles.groups.$.views.$': {
92
+ 'assets.$.id_asset': {
94
93
  type: String
95
94
  },
96
- 'roles.groups.$.yard': {
97
- type: String,
98
- optional: true
95
+ 'assets.$.asset_number': {
96
+ type: String
99
97
  },
100
- 'roles.notifications': {
101
- type: Array
98
+ 'assets.$.ownership': {
99
+ type: String
102
100
  },
103
- 'roles.notifications.$': {
101
+ 'assets.$.ownership_driver': {
104
102
  type: String
105
103
  },
106
- 'roles.miscs': {
107
- type: Array
104
+ 'assets.$.date_start': {
105
+ type: Date
108
106
  },
109
- 'roles.miscs.$': {
110
- type: String
107
+ 'assets.$.date_end': {
108
+ type: Date,
109
+ optional: true
111
110
  },
112
- active: Boolean,
113
- phonenumber: {
111
+ id_function: {
114
112
  type: String,
115
113
  optional: true
116
114
  },
117
- other: {
118
- type: Object,
119
- optional: true,
120
- blackbox: true
121
- },
122
115
  customers: {
123
116
  type: Array,
124
117
  optional: true,
package/fixtures/init.js CHANGED
@@ -37,8 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  var app_version_collection_1 = require("../collections/app-version.collection");
39
39
  var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
40
- var mongoose_1 = require("mongoose");
41
40
  var active_subscription_collection_1 = require("../collections/active-subscription.collection");
41
+ var mongoose_1 = require("mongoose");
42
42
  function loadServerInit() {
43
43
  return __awaiter(this, void 0, void 0, function () {
44
44
  var appVersion;
@@ -189,11 +189,16 @@ var SubscriptionManager = /** @class */ (function () {
189
189
  sub = that._subscriptions.filter(function (a) { return a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData); })[0];
190
190
  // If sub found (another user watching same data), add client to same sub
191
191
  if (sub) {
192
- sub.clients.push({
193
- id_user: ws['id_user'],
194
- messageId: messageId,
195
- id_socket: ws['id_socket']
196
- });
192
+ if (!sub.clients.some(function (a) { return a.id_user === ws['id_user'] && a.id_socket === ws['id_socket']; })) {
193
+ sub.clients.push({
194
+ id_user: ws['id_user'],
195
+ messageId: messageId,
196
+ id_socket: ws['id_socket']
197
+ });
198
+ }
199
+ else {
200
+ this._mainServer.getMethodManager().callMethodInternal('sendEmail', 'dev@resolveio.com', 'SERVER - Subscription Error Detected (Same socket and user) - ' + that.serverConfig['CLIENT_NAME'], 'Pub: ' + sub.publication + ', id_user: ' + ws['id_user']);
201
+ }
197
202
  }
198
203
  // If sub not found, create new sub
199
204
  else {
@@ -510,12 +515,12 @@ var SubscriptionManager = /** @class */ (function () {
510
515
  var _this = this;
511
516
  var that = this;
512
517
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
513
- var uniqueOplog_1, uniquePubs, needIds_1, _loop_2, i, _loop_3, i, i, oplog, _loop_4, this_1, j;
518
+ var uniqueOplog_1, uniquePubs, needIds_1, _loop_2, i, _loop_3, i, i, oplog, _loop_4, this_1, j, i, pub;
514
519
  var _this = this;
515
520
  return __generator(this, function (_a) {
516
521
  switch (_a.label) {
517
522
  case 0:
518
- if (!this._oplogQueue.length) return [3 /*break*/, 11];
523
+ if (!this._oplogQueue.length) return [3 /*break*/, 14];
519
524
  uniqueOplog_1 = common_1.deepCopy(this._oplogQueue);
520
525
  this._oplogQueue = [];
521
526
  uniquePubs = [];
@@ -563,7 +568,7 @@ var SubscriptionManager = /** @class */ (function () {
563
568
  });
564
569
  }
565
570
  else {
566
- console.log('PROBLEMAAAAAAAA');
571
+ _this._mainServer.getMethodManager().callMethodInternal('sendEmail', 'dev@resolveio.com', 'SERVER - Oplog Doc Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'id_doc: ' + id_doc + ', UniqueOplogs: ' + JSON.stringify(uniqueOplog_1, null, 2));
567
572
  }
568
573
  });
569
574
  return [2 /*return*/];
@@ -708,11 +713,19 @@ var SubscriptionManager = /** @class */ (function () {
708
713
  i--;
709
714
  return [3 /*break*/, 5];
710
715
  case 10:
711
- uniquePubs.forEach(function (pub) {
712
- _this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type, pub);
713
- });
716
+ i = 0;
714
717
  _a.label = 11;
715
- case 11: return [2 /*return*/];
718
+ case 11:
719
+ if (!(i < uniquePubs.length)) return [3 /*break*/, 14];
720
+ pub = uniquePubs[i];
721
+ return [4 /*yield*/, this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type, pub)];
722
+ case 12:
723
+ _a.sent();
724
+ _a.label = 13;
725
+ case 13:
726
+ i++;
727
+ return [3 /*break*/, 11];
728
+ case 14: return [2 /*return*/];
716
729
  }
717
730
  });
718
731
  }); }, 500);
@@ -792,34 +805,31 @@ var SubscriptionManager = /** @class */ (function () {
792
805
  });
793
806
  });
794
807
  };
795
- // Document: Inserted/Modified/Deleted Document
808
+ // Document: Inserted/Modified Document
796
809
  // Collection: Collection Document Lives In
797
810
  // Check to see if any pubs need to refetch due to Mongo operation
798
811
  SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type, sub) {
799
812
  return __awaiter(this, void 0, void 0, function () {
800
- var _a, _b, that, _c, _d;
801
- return __generator(this, function (_e) {
802
- switch (_e.label) {
813
+ var _a, that, _b;
814
+ return __generator(this, function (_c) {
815
+ switch (_c.label) {
803
816
  case 0:
804
817
  that = this;
805
- if (!sub.preSubscriptionData) return [3 /*break*/, 2];
806
- if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
807
- if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
808
- this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
809
- this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
818
+ if (!sub.preSubscriptionData) return [3 /*break*/, 1];
819
+ if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
820
+ if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
821
+ this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
822
+ this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
823
+ }
824
+ that.sendPubData(sub, type, collection);
810
825
  }
811
- that.sendPubData(sub, type, collection);
812
- _c = sub;
813
- return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
826
+ return [3 /*break*/, 4];
814
827
  case 1:
815
- _c.preSubscriptionData = _e.sent();
816
- return [2 /*return*/];
817
- case 2:
818
- if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
819
- _d = sub;
828
+ if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 3];
829
+ _b = sub;
820
830
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
821
- case 3:
822
- _d.preSubscriptionData = _e.sent();
831
+ case 2:
832
+ _b.preSubscriptionData = _c.sent();
823
833
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
824
834
  if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
825
835
  this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
@@ -827,8 +837,8 @@ var SubscriptionManager = /** @class */ (function () {
827
837
  }
828
838
  that.sendPubData(sub, type, collection);
829
839
  }
830
- return [3 /*break*/, 5];
831
- case 4:
840
+ return [3 /*break*/, 4];
841
+ case 3:
832
842
  if (that._publications[sub.publication].ws_specific) {
833
843
  sub.clients.forEach(function (client) {
834
844
  var _a;
@@ -852,7 +862,7 @@ var SubscriptionManager = /** @class */ (function () {
852
862
  }
853
863
  else {
854
864
  if (that._publications[sub.publication].fetchFunction) {
855
- if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
865
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document].concat(sub.subscriptionData))) {
856
866
  if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
857
867
  this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
858
868
  this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
@@ -869,8 +879,8 @@ var SubscriptionManager = /** @class */ (function () {
869
879
  that.sendPubData(sub, type, collection);
870
880
  }
871
881
  }
872
- _e.label = 5;
873
- case 5: return [2 /*return*/];
882
+ _c.label = 4;
883
+ case 4: return [2 /*return*/];
874
884
  }
875
885
  });
876
886
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "5.2.18-newrole",
3
+ "version": "5.2.19",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {