@resolveio/server-lib 5.2.36 → 5.2.37-newrole

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,13 +22,6 @@ 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
- },
32
25
  attempts: {
33
26
  type: Number,
34
27
  optional: true
@@ -65,53 +58,67 @@ var schema = {
65
58
  type: String
66
59
  },
67
60
  roles: {
61
+ type: Object
62
+ },
63
+ 'roles.super_admin': {
64
+ type: Boolean
65
+ },
66
+ 'roles.approvals': {
68
67
  type: Array
69
68
  },
70
- 'roles.$': {
69
+ 'roles.approvals.$': {
70
+ type: Object
71
+ },
72
+ 'roles.approvals.$.name': {
71
73
  type: String
72
74
  },
73
- phonenumber: {
74
- type: String,
75
- optional: true
75
+ 'roles.approvals.$.type': {
76
+ type: String
76
77
  },
77
- other: {
78
- type: Object,
79
- blackbox: true,
80
- optional: true
78
+ 'roles.approvals.$.accounting_code': {
79
+ type: String
81
80
  },
82
- assets: {
83
- type: Array,
84
- optional: true
81
+ 'roles.groups': {
82
+ type: Array
85
83
  },
86
- 'assets.$': {
84
+ 'roles.groups.$': {
87
85
  type: Object
88
86
  },
89
- 'assets.$.type': {
87
+ 'roles.groups.$.name': {
90
88
  type: String
91
89
  },
92
- 'assets.$.id_asset': {
93
- type: String
90
+ 'roles.groups.$.views': {
91
+ type: Array
94
92
  },
95
- 'assets.$.asset_number': {
93
+ 'roles.groups.$.views.$': {
96
94
  type: String
97
95
  },
98
- 'assets.$.ownership': {
99
- type: String
96
+ 'roles.groups.$.yard': {
97
+ type: String,
98
+ optional: true
99
+ },
100
+ 'roles.notifications': {
101
+ type: Array
100
102
  },
101
- 'assets.$.ownership_driver': {
103
+ 'roles.notifications.$': {
102
104
  type: String
103
105
  },
104
- 'assets.$.date_start': {
105
- type: Date
106
+ 'roles.miscs': {
107
+ type: Array
106
108
  },
107
- 'assets.$.date_end': {
108
- type: Date,
109
- optional: true
109
+ 'roles.miscs.$': {
110
+ type: String
110
111
  },
111
- id_function: {
112
+ active: Boolean,
113
+ phonenumber: {
112
114
  type: String,
113
115
  optional: true
114
116
  },
117
+ other: {
118
+ type: Object,
119
+ optional: true,
120
+ blackbox: true
121
+ },
115
122
  customers: {
116
123
  type: Array,
117
124
  optional: true,
@@ -131,34 +131,57 @@ var SubscriptionManager = /** @class */ (function () {
131
131
  console.log(err);
132
132
  });
133
133
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
134
- var userCopy, i, loggedInUser;
134
+ var userCopy, _loop_2, this_1, i;
135
135
  return __generator(this, function (_a) {
136
136
  switch (_a.label) {
137
137
  case 0:
138
138
  userCopy = common_1.deepCopy(this._loggedInUsers);
139
+ _loop_2 = function (i) {
140
+ var loggedInUser;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0:
144
+ loggedInUser = userCopy[i];
145
+ if (!(!loggedInUser.date || moment().diff(moment(loggedInUser.date), 'seconds') >= 60)) return [3 /*break*/, 5];
146
+ if (!this_1._mainServer.getWS(loggedInUser.id_ws)) return [3 /*break*/, 1];
147
+ this_1.unsubscribeAll(this_1._mainServer.getWS(loggedInUser.id_ws));
148
+ return [3 /*break*/, 5];
149
+ case 1:
150
+ this_1._subscriptions.forEach(function (sub) {
151
+ for (var j = sub.clients.length - 1; j >= 0; j--) {
152
+ var client = sub.clients[j];
153
+ if (client.id_socket === loggedInUser.id_ws) {
154
+ sub.clients.splice(j, 1);
155
+ }
156
+ }
157
+ });
158
+ return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.findById(loggedInUser._id)];
159
+ case 2:
160
+ if (!_a.sent()) return [3 /*break*/, 4];
161
+ return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id }).exec()];
162
+ case 3:
163
+ _a.sent();
164
+ _a.label = 4;
165
+ case 4:
166
+ this_1._loggedInUsers.splice(i, 1);
167
+ _a.label = 5;
168
+ case 5: return [2 /*return*/];
169
+ }
170
+ });
171
+ };
172
+ this_1 = this;
139
173
  i = this._loggedInUsers.length - 1;
140
174
  _a.label = 1;
141
175
  case 1:
142
- if (!(i >= 0)) return [3 /*break*/, 7];
143
- loggedInUser = userCopy[i];
144
- if (!(!loggedInUser.date || moment().diff(moment(loggedInUser.date), 'seconds') >= 60)) return [3 /*break*/, 6];
145
- if (!this._mainServer.getWS(loggedInUser.id_ws)) return [3 /*break*/, 2];
146
- this.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));
147
- return [3 /*break*/, 6];
148
- case 2: return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.findById(loggedInUser._id)];
149
- case 3:
150
- if (!_a.sent()) return [3 /*break*/, 5];
151
- return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id }).exec()];
152
- case 4:
176
+ if (!(i >= 0)) return [3 /*break*/, 4];
177
+ return [5 /*yield**/, _loop_2(i)];
178
+ case 2:
153
179
  _a.sent();
154
- _a.label = 5;
155
- case 5:
156
- this._loggedInUsers.splice(i, 1);
157
- _a.label = 6;
158
- case 6:
180
+ _a.label = 3;
181
+ case 3:
159
182
  i--;
160
183
  return [3 /*break*/, 1];
161
- case 7: return [2 /*return*/];
184
+ case 4: return [2 /*return*/];
162
185
  }
163
186
  });
164
187
  }); }, 60000);
@@ -564,7 +587,7 @@ var SubscriptionManager = /** @class */ (function () {
564
587
  var _this = this;
565
588
  var that = this;
566
589
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
567
- var uniqueOplog_1, uniquePubs, needIds_1, _loop_2, i, _loop_3, i, _loop_4, this_1, i, i, pub;
590
+ var uniqueOplog_1, uniquePubs, needIds_1, _loop_3, i, _loop_4, i, _loop_5, this_2, i, i, pub;
568
591
  var _this = this;
569
592
  return __generator(this, function (_a) {
570
593
  switch (_a.label) {
@@ -574,13 +597,13 @@ var SubscriptionManager = /** @class */ (function () {
574
597
  this._oplogQueue = [];
575
598
  uniquePubs = [];
576
599
  needIds_1 = {};
577
- _loop_2 = function (i) {
600
+ _loop_3 = function (i) {
578
601
  if (!that._subscriptions.some(function (a) { return a.collections.includes(uniqueOplog_1[i].collection); })) {
579
602
  uniqueOplog_1.splice(i, 1);
580
603
  }
581
604
  };
582
605
  for (i = uniqueOplog_1.length - 1; i >= 0; i--) {
583
- _loop_2(i);
606
+ _loop_3(i);
584
607
  }
585
608
  uniqueOplog_1.forEach(function (oplog) {
586
609
  var schemaErrors = null;
@@ -601,7 +624,7 @@ var SubscriptionManager = /** @class */ (function () {
601
624
  }
602
625
  }
603
626
  });
604
- _loop_3 = function (i) {
627
+ _loop_4 = function (i) {
605
628
  var collection, docs;
606
629
  return __generator(this, function (_a) {
607
630
  switch (_a.label) {
@@ -628,7 +651,7 @@ var SubscriptionManager = /** @class */ (function () {
628
651
  _a.label = 1;
629
652
  case 1:
630
653
  if (!(i < Object.keys(needIds_1).length)) return [3 /*break*/, 4];
631
- return [5 /*yield**/, _loop_3(i)];
654
+ return [5 /*yield**/, _loop_4(i)];
632
655
  case 2:
633
656
  _a.sent();
634
657
  _a.label = 3;
@@ -636,13 +659,13 @@ var SubscriptionManager = /** @class */ (function () {
636
659
  i++;
637
660
  return [3 /*break*/, 1];
638
661
  case 4:
639
- _loop_4 = function (i) {
640
- var oplog, _loop_5, j;
662
+ _loop_5 = function (i) {
663
+ var oplog, _loop_6, j;
641
664
  return __generator(this, function (_a) {
642
665
  switch (_a.label) {
643
666
  case 0:
644
667
  oplog = uniqueOplog_1[i];
645
- _loop_5 = function (j) {
668
+ _loop_6 = function (j) {
646
669
  var _a, sub;
647
670
  return __generator(this, function (_b) {
648
671
  switch (_b.label) {
@@ -668,9 +691,9 @@ var SubscriptionManager = /** @class */ (function () {
668
691
  uniquePubs.push(common_1.deepCopy(sub));
669
692
  _b.label = 3;
670
693
  case 3:
671
- if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
672
- this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
673
- this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
694
+ if (this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
695
+ this_2._nodeCache.del(this_2._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
696
+ this_2._subCache.splice(this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
674
697
  }
675
698
  _b.label = 4;
676
699
  case 4: return [2 /*return*/, "continue"];
@@ -686,9 +709,9 @@ var SubscriptionManager = /** @class */ (function () {
686
709
  }).exec()];
687
710
  case 6:
688
711
  _b.sent();
689
- if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
690
- this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
691
- this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
712
+ if (this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
713
+ this_2._nodeCache.del(this_2._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
714
+ this_2._subCache.splice(this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
692
715
  }
693
716
  return [3 /*break*/, 8];
694
717
  case 7:
@@ -712,9 +735,9 @@ var SubscriptionManager = /** @class */ (function () {
712
735
  }).exec()];
713
736
  case 10:
714
737
  _b.sent();
715
- if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
716
- this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
717
- this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
738
+ if (this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
739
+ this_2._nodeCache.del(this_2._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
740
+ this_2._subCache.splice(this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
718
741
  }
719
742
  return [3 /*break*/, 12];
720
743
  case 11:
@@ -734,9 +757,9 @@ var SubscriptionManager = /** @class */ (function () {
734
757
  }).exec()];
735
758
  case 14:
736
759
  _b.sent();
737
- if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
738
- this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
739
- this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
760
+ if (this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
761
+ this_2._nodeCache.del(this_2._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
762
+ this_2._subCache.splice(this_2._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
740
763
  }
741
764
  return [3 /*break*/, 16];
742
765
  case 15:
@@ -751,7 +774,7 @@ var SubscriptionManager = /** @class */ (function () {
751
774
  _a.label = 1;
752
775
  case 1:
753
776
  if (!(j >= 0)) return [3 /*break*/, 4];
754
- return [5 /*yield**/, _loop_5(j)];
777
+ return [5 /*yield**/, _loop_6(j)];
755
778
  case 2:
756
779
  _a.sent();
757
780
  _a.label = 3;
@@ -762,12 +785,12 @@ var SubscriptionManager = /** @class */ (function () {
762
785
  }
763
786
  });
764
787
  };
765
- this_1 = this;
788
+ this_2 = this;
766
789
  i = uniqueOplog_1.length - 1;
767
790
  _a.label = 5;
768
791
  case 5:
769
792
  if (!(i >= 0)) return [3 /*break*/, 8];
770
- return [5 /*yield**/, _loop_4(i)];
793
+ return [5 /*yield**/, _loop_5(i)];
771
794
  case 6:
772
795
  _a.sent();
773
796
  _a.label = 7;
@@ -794,24 +817,24 @@ var SubscriptionManager = /** @class */ (function () {
794
817
  };
795
818
  SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
796
819
  return __awaiter(this, void 0, void 0, function () {
797
- var that, subCopy, _loop_6, this_2, jj, _loop_7, zz;
820
+ var that, subCopy, _loop_7, this_3, jj, _loop_8, zz;
798
821
  var _this = this;
799
822
  return __generator(this, function (_a) {
800
823
  switch (_a.label) {
801
824
  case 0:
802
825
  that = this;
803
826
  subCopy = common_1.deepCopy(that._subscriptions.filter(function (a) { return a.collections.includes(collection); }));
804
- _loop_6 = function (jj) {
805
- if (this_2._subCache[jj].collection === collection || subCopy.some(function (a) { return a.publication === _this._subCache[jj].publication; })) {
806
- this_2._nodeCache.del(this_2._subCache[jj].id);
807
- this_2._subCache.splice(jj, 1);
827
+ _loop_7 = function (jj) {
828
+ if (this_3._subCache[jj].collection === collection || subCopy.some(function (a) { return a.publication === _this._subCache[jj].publication; })) {
829
+ this_3._nodeCache.del(this_3._subCache[jj].id);
830
+ this_3._subCache.splice(jj, 1);
808
831
  }
809
832
  };
810
- this_2 = this;
833
+ this_3 = this;
811
834
  for (jj = this._subCache.length - 1; jj >= 0; jj--) {
812
- _loop_6(jj);
835
+ _loop_7(jj);
813
836
  }
814
- _loop_7 = function (zz) {
837
+ _loop_8 = function (zz) {
815
838
  var sub;
816
839
  return __generator(this, function (_a) {
817
840
  switch (_a.label) {
@@ -855,7 +878,7 @@ var SubscriptionManager = /** @class */ (function () {
855
878
  _a.label = 1;
856
879
  case 1:
857
880
  if (!(zz >= 0)) return [3 /*break*/, 4];
858
- return [5 /*yield**/, _loop_7(zz)];
881
+ return [5 /*yield**/, _loop_8(zz)];
859
882
  case 2:
860
883
  _a.sent();
861
884
  _a.label = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "5.2.36",
3
+ "version": "5.2.37-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {