@resolveio/server-lib 4.2.3-newrole → 4.2.4

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.
@@ -21,6 +21,13 @@ var schema = {
21
21
  type: Date,
22
22
  optional: true
23
23
  },
24
+ readonly: {
25
+ type: Boolean,
26
+ optional: true
27
+ },
28
+ active: {
29
+ type: Boolean
30
+ },
24
31
  attempts: {
25
32
  type: Number,
26
33
  optional: true
@@ -57,67 +64,53 @@ var schema = {
57
64
  type: String
58
65
  },
59
66
  roles: {
60
- type: Object
61
- },
62
- 'roles.super_admin': {
63
- type: Boolean
64
- },
65
- 'roles.approvals': {
66
67
  type: Array
67
68
  },
68
- 'roles.approvals.$': {
69
- type: Object
70
- },
71
- 'roles.approvals.$.name': {
69
+ 'roles.$': {
72
70
  type: String
73
71
  },
74
- 'roles.approvals.$.type': {
75
- type: String
72
+ phonenumber: {
73
+ type: String,
74
+ optional: true
76
75
  },
77
- 'roles.approvals.$.accounting_code': {
78
- type: String
76
+ other: {
77
+ type: Object,
78
+ blackbox: true,
79
+ optional: true
79
80
  },
80
- 'roles.groups': {
81
- type: Array
81
+ assets: {
82
+ type: Array,
83
+ optional: true
82
84
  },
83
- 'roles.groups.$': {
85
+ 'assets.$': {
84
86
  type: Object
85
87
  },
86
- 'roles.groups.$.name': {
88
+ 'assets.$.type': {
87
89
  type: String
88
90
  },
89
- 'roles.groups.$.views': {
90
- type: Array
91
- },
92
- 'roles.groups.$.views.$': {
91
+ 'assets.$.id_asset': {
93
92
  type: String
94
93
  },
95
- 'roles.groups.$.yard': {
96
- type: String,
97
- optional: true
94
+ 'assets.$.asset_number': {
95
+ type: String
98
96
  },
99
- 'roles.notifications': {
100
- type: Array
97
+ 'assets.$.ownership': {
98
+ type: String
101
99
  },
102
- 'roles.notifications.$': {
100
+ 'assets.$.ownership_driver': {
103
101
  type: String
104
102
  },
105
- 'roles.miscs': {
106
- type: Array
103
+ 'assets.$.date_start': {
104
+ type: Date
107
105
  },
108
- 'roles.miscs.$': {
109
- type: String
106
+ 'assets.$.date_end': {
107
+ type: Date,
108
+ optional: true
110
109
  },
111
- active: Boolean,
112
- phonenumber: {
110
+ id_function: {
113
111
  type: String,
114
112
  optional: true
115
113
  },
116
- other: {
117
- type: Object,
118
- optional: true,
119
- blackbox: true
120
- },
121
114
  customers: {
122
115
  type: Array,
123
116
  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;
package/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare class ResolveIOServer {
8
8
  private static _clientDir;
9
9
  private static _dontRunSupport;
10
10
  constructor(serverConfig: any, client: string, clientDir: any, _dontRunSupport?: any);
11
- static connectAndRun(): Promise<unknown>;
11
+ static connectAndRun(): Promise<{}>;
12
12
  static getClientName(): string;
13
13
  static getMainServer(): ResolveIOMainServer;
14
14
  static getMainDB(): any;
@@ -16,13 +16,13 @@ export declare class MethodManager {
16
16
  getMainServer(): ResolveIOMainServer;
17
17
  methods(method: MethodModel): void;
18
18
  callMethodCron(method: string, ...methodData: any[]): void;
19
- callMethodQueue(update: QueueMethodModel): Promise<unknown>;
19
+ callMethodQueue(update: QueueMethodModel): Promise<{}>;
20
20
  callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]): void;
21
21
  callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
22
22
  callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
23
23
  private sendWS;
24
24
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string): void;
25
25
  getAWS(): aws.S3;
26
- readFile(fileName: any): Promise<unknown>;
27
- readImage(fileName: any): Promise<unknown>;
26
+ readFile(fileName: any): Promise<{}>;
27
+ readImage(fileName: any): Promise<{}>;
28
28
  }
@@ -416,8 +416,8 @@ var MethodManager = /** @class */ (function () {
416
416
  };
417
417
  // Call/run method (Emit on Socket)
418
418
  MethodManager.prototype.callMethod = function (id_methodLatency, ws, messageDate, messageId, method) {
419
- var _a;
420
419
  var _this = this;
420
+ var _a;
421
421
  var methodData = [];
422
422
  for (var _i = 5; _i < arguments.length; _i++) {
423
423
  methodData[_i - 5] = arguments[_i];
@@ -137,8 +137,7 @@ var SubscriptionManager = /** @class */ (function () {
137
137
  subscriptionData[_i - 3] = arguments[_i];
138
138
  }
139
139
  return __awaiter(this, void 0, void 0, function () {
140
- var that, pub, valObj, valKeys, rootKeys, i, sub, _a, newActiveSub, begDate, endDate, billUser;
141
- var _b;
140
+ var _a, that, pub, valObj, valKeys, rootKeys, i, sub, _b, newActiveSub, begDate, endDate, billUser;
142
141
  return __generator(this, function (_c) {
143
142
  switch (_c.label) {
144
143
  case 0:
@@ -203,10 +202,10 @@ var SubscriptionManager = /** @class */ (function () {
203
202
  // Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
204
203
  that.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);
205
204
  if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
206
- _a = sub;
207
- return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
205
+ _b = sub;
206
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
208
207
  case 2:
209
- _a.preSubscriptionData = _c.sent();
208
+ _b.preSubscriptionData = _c.sent();
210
209
  _c.label = 3;
211
210
  case 3:
212
211
  newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
@@ -554,8 +553,7 @@ var SubscriptionManager = /** @class */ (function () {
554
553
  switch (_a.label) {
555
554
  case 0:
556
555
  _loop_3 = function (i) {
557
- var sub, _a;
558
- var _b;
556
+ var _a, sub, _b;
559
557
  return __generator(this, function (_c) {
560
558
  switch (_c.label) {
561
559
  case 0:
@@ -571,10 +569,10 @@ var SubscriptionManager = /** @class */ (function () {
571
569
  }
572
570
  }
573
571
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
574
- _a = sub;
572
+ _b = sub;
575
573
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
576
574
  case 1:
577
- _a.preSubscriptionData = _c.sent();
575
+ _b.preSubscriptionData = _c.sent();
578
576
  if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
579
577
  if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
580
578
  uniquePubs_1.push(sub);
@@ -599,7 +597,7 @@ var SubscriptionManager = /** @class */ (function () {
599
597
  }
600
598
  else {
601
599
  if (that._publications[sub.publication].fetchFunction) {
602
- if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [oplog.doc].concat(sub.subscriptionData))) {
600
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
603
601
  if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
604
602
  uniquePubs_1.push(sub);
605
603
  uniqueOplog_1.push(oplog);
@@ -635,6 +633,7 @@ var SubscriptionManager = /** @class */ (function () {
635
633
  }
636
634
  });
637
635
  }); });
636
+ debugger;
638
637
  uniqueOplog_1.forEach(function (oplog) {
639
638
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
640
639
  });
@@ -661,66 +660,46 @@ var SubscriptionManager = /** @class */ (function () {
661
660
  // Document: Inserted/Modified/Deleted Document
662
661
  // Collection: Collection Document Lives In
663
662
  // Check to see if any pubs need to refetch due to Mongo operation
664
- SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type, fetchFunctionOnly, noFetchFunction) {
663
+ SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
665
664
  var _this = this;
666
- if (fetchFunctionOnly === void 0) { fetchFunctionOnly = false; }
667
- if (noFetchFunction === void 0) { noFetchFunction = false; }
668
665
  var that = this;
669
666
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
670
- var schemaErrors, _a, _b;
671
- var _c, _d;
667
+ var _a, _b, _c, _d;
672
668
  return __generator(this, function (_e) {
673
669
  switch (_e.label) {
674
670
  case 0:
675
- schemaErrors = null;
676
- try {
677
- index_1.ResolveIOServer.getMainDB().model(collection)['simplschema'].validate(document);
678
- }
679
- catch (errors) {
680
- schemaErrors = errors;
681
- }
682
- if (!schemaErrors) return [3 /*break*/, 2];
683
- return [4 /*yield*/, index_1.ResolveIOServer.getMainDB().model(collection).findById(document['_id'])];
671
+ if (!sub.preSubscriptionData) return [3 /*break*/, 2];
672
+ if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
673
+ that.sendPubData(sub, type, collection);
674
+ _c = sub;
675
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
684
676
  case 1:
685
- document = _e.sent();
677
+ _c.preSubscriptionData = _e.sent();
686
678
  _e.label = 2;
687
679
  case 2:
688
- if (!sub.preSubscriptionData) return [3 /*break*/, 4];
689
- if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
690
- that.sendPubData(sub, type, collection);
691
- _a = sub;
692
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
693
- case 3:
694
- _a.preSubscriptionData = _e.sent();
695
- _e.label = 4;
696
- case 4:
697
- if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 7];
698
- if (!!noFetchFunction) return [3 /*break*/, 6];
699
- _b = sub;
680
+ if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
681
+ _d = sub;
700
682
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
701
- case 5:
702
- _b.preSubscriptionData = _e.sent();
683
+ case 3:
684
+ _d.preSubscriptionData = _e.sent();
703
685
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
704
686
  that.sendPubData(sub, type, collection);
705
687
  }
706
- _e.label = 6;
707
- case 6: return [3 /*break*/, 8];
708
- case 7:
688
+ return [3 /*break*/, 5];
689
+ case 4:
709
690
  if (that._publications[sub.publication].ws_specific) {
710
691
  sub.clients.forEach(function (client) {
711
692
  var _a;
712
693
  if (that._publications[sub.publication].fetchFunction) {
713
- if (!noFetchFunction) {
714
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
715
- that._wss.clients.forEach(function (ws) {
716
- if (ws['id_socket'] === client.id_socket) {
717
- that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
718
- }
719
- });
720
- }
694
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
695
+ that._wss.clients.forEach(function (ws) {
696
+ if (ws['id_socket'] === client.id_socket) {
697
+ that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
698
+ }
699
+ });
721
700
  }
722
701
  }
723
- else if (!fetchFunctionOnly) {
702
+ else {
724
703
  that._wss.clients.forEach(function (ws) {
725
704
  if (ws['id_socket'] === client.id_socket) {
726
705
  that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
@@ -731,18 +710,16 @@ var SubscriptionManager = /** @class */ (function () {
731
710
  }
732
711
  else {
733
712
  if (that._publications[sub.publication].fetchFunction) {
734
- if (!noFetchFunction) {
735
- if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
736
- that.sendPubData(sub, type, collection);
737
- }
713
+ if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
714
+ that.sendPubData(sub, type, collection);
738
715
  }
739
716
  }
740
- else if (!fetchFunctionOnly) {
717
+ else {
741
718
  that.sendPubData(sub, type, collection);
742
719
  }
743
720
  }
744
- _e.label = 8;
745
- case 8: return [2 /*return*/];
721
+ _e.label = 5;
722
+ case 5: return [2 /*return*/];
746
723
  }
747
724
  });
748
725
  }); });
@@ -751,8 +728,7 @@ var SubscriptionManager = /** @class */ (function () {
751
728
  var _this = this;
752
729
  var that = this;
753
730
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
754
- var schemaErrors, _a, _b;
755
- var _c, _d, _e;
731
+ var _a, _b, _c, schemaErrors, _d, _e;
756
732
  return __generator(this, function (_f) {
757
733
  switch (_f.label) {
758
734
  case 0:
@@ -772,17 +748,17 @@ var SubscriptionManager = /** @class */ (function () {
772
748
  if (!sub.preSubscriptionData) return [3 /*break*/, 4];
773
749
  if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
774
750
  that.sendPubData(sub, 'support', collection);
775
- _a = sub;
776
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
751
+ _d = sub;
752
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
777
753
  case 3:
778
- _a.preSubscriptionData = _f.sent();
754
+ _d.preSubscriptionData = _f.sent();
779
755
  return [2 /*return*/];
780
756
  case 4:
781
757
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
782
- _b = sub;
783
- return [4 /*yield*/, (_d = that._publications[sub.publication]).preFunction.apply(_d, sub.subscriptionData)];
758
+ _e = sub;
759
+ return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
784
760
  case 5:
785
- _b.preSubscriptionData = _f.sent();
761
+ _e.preSubscriptionData = _f.sent();
786
762
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
787
763
  that.sendPubData(sub, 'support', collection);
788
764
  }
@@ -811,7 +787,7 @@ var SubscriptionManager = /** @class */ (function () {
811
787
  }
812
788
  else {
813
789
  if (that._publications[sub.publication].fetchFunction) {
814
- if ((_e = that._publications[sub.publication]).fetchFunction.apply(_e, [document].concat(sub.subscriptionData))) {
790
+ if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, [document].concat(sub.subscriptionData))) {
815
791
  that.sendPubData(sub, 'support', collection);
816
792
  }
817
793
  }
@@ -828,8 +804,7 @@ var SubscriptionManager = /** @class */ (function () {
828
804
  // Fetch pub once, send to all clients linked to this pub
829
805
  SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
830
806
  return __awaiter(this, void 0, void 0, function () {
831
- var that;
832
- var _a, _b;
807
+ var _a, _b, that;
833
808
  var _this = this;
834
809
  return __generator(this, function (_c) {
835
810
  that = this;
@@ -877,8 +852,7 @@ var SubscriptionManager = /** @class */ (function () {
877
852
  // Fetch pub once, send to all clients linked to this pub
878
853
  SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
879
854
  return __awaiter(this, void 0, void 0, function () {
880
- var that;
881
- var _a;
855
+ var _a, that;
882
856
  var _this = this;
883
857
  return __generator(this, function (_b) {
884
858
  that = this;
@@ -17,6 +17,6 @@ export declare class SupportManager {
17
17
  callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
18
18
  private sendWS;
19
19
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], from?: string): void;
20
- readFile(fileName: any): Promise<unknown>;
21
- readImage(fileName: any): Promise<unknown>;
20
+ readFile(fileName: any): Promise<{}>;
21
+ readImage(fileName: any): Promise<{}>;
22
22
  }
@@ -102,8 +102,8 @@ var SupportManager = /** @class */ (function () {
102
102
  };
103
103
  // Call/run method (Emit on Socket)
104
104
  SupportManager.prototype.callSupportMethod = function (ws, messageId, supportMethod) {
105
- var _a;
106
105
  var _this = this;
106
+ var _a;
107
107
  var methodData = [];
108
108
  for (var _i = 3; _i < arguments.length; _i++) {
109
109
  methodData[_i - 3] = arguments[_i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.2.3-newrole",
3
+ "version": "4.2.4",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.js CHANGED
@@ -254,8 +254,7 @@ var ResolveIOMainServer = /** @class */ (function () {
254
254
  }, 10000);
255
255
  // On data received (message)
256
256
  ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
257
- var socketData, data, messageDate, messageId, type, subType, pub;
258
- var _a, _b;
257
+ var _a, _b, socketData, data, messageDate, messageId, type, subType, pub;
259
258
  var _this = this;
260
259
  return __generator(this, function (_c) {
261
260
  socketData = JSON.parse(message, common_1.dateReviver);
@@ -330,8 +329,7 @@ var ResolveIOMainServer = /** @class */ (function () {
330
329
  if (!!this._msgQueueRunning) return [3 /*break*/, 5];
331
330
  this._msgQueueRunning = true;
332
331
  _loop_1 = function (i) {
333
- var msg, data, ws, messageDate, messageId, type, method, methodLatency, serverRes, query, methodCall, supportMethod, serverRes;
334
- var _a, _b;
332
+ var _a, _b, msg, data, ws, messageDate, messageId, type, method, methodLatency, serverRes, query, methodCall, supportMethod, serverRes;
335
333
  return __generator(this, function (_c) {
336
334
  switch (_c.label) {
337
335
  case 0: