@resolveio/server-lib 4.2.8-newrole → 4.2.9

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 - 4] = 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:
@@ -204,10 +203,10 @@ var SubscriptionManager = /** @class */ (function () {
204
203
  // Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
205
204
  that.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);
206
205
  if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
207
- _a = sub;
208
- return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
206
+ _b = sub;
207
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
209
208
  case 2:
210
- _a.preSubscriptionData = _c.sent();
209
+ _b.preSubscriptionData = _c.sent();
211
210
  _c.label = 3;
212
211
  case 3:
213
212
  newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
@@ -505,7 +504,7 @@ var SubscriptionManager = /** @class */ (function () {
505
504
  var _this = this;
506
505
  var that = this;
507
506
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
508
- var oplogQueue_1, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i;
507
+ var oplogQueue_1, uniquePubs, uniqueOplog, needIds_1, _loop_3, i;
509
508
  var _this = this;
510
509
  return __generator(this, function (_a) {
511
510
  switch (_a.label) {
@@ -513,8 +512,8 @@ var SubscriptionManager = /** @class */ (function () {
513
512
  if (!this._oplogQueue.length) return [3 /*break*/, 5];
514
513
  oplogQueue_1 = common_1.deepCopy(this._oplogQueue);
515
514
  this._oplogQueue = [];
516
- uniquePubs_1 = [];
517
- uniqueOplog_1 = [];
515
+ uniquePubs = [];
516
+ uniqueOplog = [];
518
517
  needIds_1 = {};
519
518
  // console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
520
519
  oplogQueue_1.forEach(function (oplog) {
@@ -570,59 +569,54 @@ var SubscriptionManager = /** @class */ (function () {
570
569
  return [3 /*break*/, 1];
571
570
  case 4:
572
571
  // console.log('----------------OPLOG QUEUE START AFTER DATA--------------------', new Date(), oplogQueue.length);
573
- oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
574
- var _loop_4, i;
575
- return __generator(this, function (_a) {
576
- _loop_4 = function (i) {
577
- var _a;
578
- var sub = that._subscriptions[i];
579
- if (sub.collections.includes(oplog.collection)) {
580
- if (sub.preSubscriptionData) {
581
- if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
582
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
583
- uniquePubs_1.push(sub);
584
- uniqueOplog_1.push(oplog);
585
- }
586
- return "continue";
587
- }
588
- }
589
- if (that._publications[sub.publication].preFunction) {
590
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
591
- uniquePubs_1.push(sub);
592
- uniqueOplog_1.push(oplog);
593
- }
594
- return "continue";
595
- }
596
- else {
597
- if (that._publications[sub.publication].fetchFunction) {
598
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
599
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
600
- uniquePubs_1.push(sub);
601
- uniqueOplog_1.push(oplog);
602
- }
603
- return "continue";
604
- }
605
- }
606
- else {
607
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
608
- uniquePubs_1.push(sub);
609
- uniqueOplog_1.push(oplog);
610
- }
611
- return "continue";
612
- }
613
- }
614
- }
615
- };
616
- // console.log('OPLOG QUEUE START - Oplog', oplog);
617
- for (i = 0; i < that._subscriptions.length; i++) {
618
- _loop_4(i);
619
- }
620
- return [2 /*return*/];
621
- });
622
- }); });
623
- // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
624
- uniqueOplog_1.forEach(function (oplog) {
625
- // console.log('OPLOG QUEUE END - Oplog', oplog);
572
+ // oplogQueue.forEach(async (oplog) => {
573
+ // // console.log('OPLOG QUEUE START - Oplog', oplog);
574
+ // for (let i = 0; i < that._subscriptions.length; i++) {
575
+ // let sub = that._subscriptions[i];
576
+ // if (sub.collections.includes(oplog.collection)) {
577
+ // if (sub.preSubscriptionData) {
578
+ // if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
579
+ // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
580
+ // uniquePubs.push(sub);
581
+ // uniqueOplog.push(oplog);
582
+ // }
583
+ // continue;
584
+ // }
585
+ // }
586
+ // if (that._publications[sub.publication].preFunction) {
587
+ // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
588
+ // uniquePubs.push(sub);
589
+ // uniqueOplog.push(oplog);
590
+ // }
591
+ // continue;
592
+ // }
593
+ // else {
594
+ // if (that._publications[sub.publication].fetchFunction) {
595
+ // if (that._publications[sub.publication].fetchFunction(oplog.doc, ...sub.subscriptionData)) {
596
+ // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
597
+ // uniquePubs.push(sub);
598
+ // uniqueOplog.push(oplog);
599
+ // }
600
+ // continue;
601
+ // }
602
+ // }
603
+ // else {
604
+ // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
605
+ // uniquePubs.push(sub);
606
+ // uniqueOplog.push(oplog);
607
+ // }
608
+ // continue;
609
+ // }
610
+ // }
611
+ // }
612
+ // }
613
+ // });
614
+ // // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
615
+ // uniqueOplog.forEach(oplog => {
616
+ // // console.log('OPLOG QUEUE END - Oplog', oplog);
617
+ // this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
618
+ // });
619
+ oplogQueue_1.forEach(function (oplog) {
626
620
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
627
621
  });
628
622
  _a.label = 5;
@@ -655,25 +649,24 @@ var SubscriptionManager = /** @class */ (function () {
655
649
  var _this = this;
656
650
  var that = this;
657
651
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
658
- var _a, _b;
659
- var _c, _d;
652
+ var _a, _b, _c, _d;
660
653
  return __generator(this, function (_e) {
661
654
  switch (_e.label) {
662
655
  case 0:
663
656
  if (!sub.preSubscriptionData) return [3 /*break*/, 2];
664
657
  if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
665
658
  that.sendPubData(sub, type, collection);
666
- _a = sub;
667
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
659
+ _c = sub;
660
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
668
661
  case 1:
669
- _a.preSubscriptionData = _e.sent();
662
+ _c.preSubscriptionData = _e.sent();
670
663
  _e.label = 2;
671
664
  case 2:
672
665
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
673
- _b = sub;
666
+ _d = sub;
674
667
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
675
668
  case 3:
676
- _b.preSubscriptionData = _e.sent();
669
+ _d.preSubscriptionData = _e.sent();
677
670
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
678
671
  that.sendPubData(sub, type, collection);
679
672
  }
@@ -702,7 +695,7 @@ var SubscriptionManager = /** @class */ (function () {
702
695
  }
703
696
  else {
704
697
  if (that._publications[sub.publication].fetchFunction) {
705
- if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
698
+ if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
706
699
  that.sendPubData(sub, type, collection);
707
700
  }
708
701
  }
@@ -720,8 +713,7 @@ var SubscriptionManager = /** @class */ (function () {
720
713
  var _this = this;
721
714
  var that = this;
722
715
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
723
- var schemaErrors, _a, _b;
724
- var _c, _d, _e;
716
+ var _a, _b, _c, schemaErrors, _d, _e;
725
717
  return __generator(this, function (_f) {
726
718
  switch (_f.label) {
727
719
  case 0:
@@ -741,17 +733,17 @@ var SubscriptionManager = /** @class */ (function () {
741
733
  if (!sub.preSubscriptionData) return [3 /*break*/, 4];
742
734
  if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
743
735
  that.sendPubData(sub, 'support', collection);
744
- _a = sub;
745
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
736
+ _d = sub;
737
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
746
738
  case 3:
747
- _a.preSubscriptionData = _f.sent();
739
+ _d.preSubscriptionData = _f.sent();
748
740
  return [2 /*return*/];
749
741
  case 4:
750
742
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
751
- _b = sub;
752
- return [4 /*yield*/, (_d = that._publications[sub.publication]).preFunction.apply(_d, sub.subscriptionData)];
743
+ _e = sub;
744
+ return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
753
745
  case 5:
754
- _b.preSubscriptionData = _f.sent();
746
+ _e.preSubscriptionData = _f.sent();
755
747
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
756
748
  that.sendPubData(sub, 'support', collection);
757
749
  }
@@ -780,7 +772,7 @@ var SubscriptionManager = /** @class */ (function () {
780
772
  }
781
773
  else {
782
774
  if (that._publications[sub.publication].fetchFunction) {
783
- if ((_e = that._publications[sub.publication]).fetchFunction.apply(_e, [document].concat(sub.subscriptionData))) {
775
+ if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, [document].concat(sub.subscriptionData))) {
784
776
  that.sendPubData(sub, 'support', collection);
785
777
  }
786
778
  }
@@ -797,8 +789,7 @@ var SubscriptionManager = /** @class */ (function () {
797
789
  // Fetch pub once, send to all clients linked to this pub
798
790
  SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
799
791
  return __awaiter(this, void 0, void 0, function () {
800
- var that;
801
- var _a, _b;
792
+ var _a, _b, that;
802
793
  var _this = this;
803
794
  return __generator(this, function (_c) {
804
795
  that = this;
@@ -850,8 +841,7 @@ var SubscriptionManager = /** @class */ (function () {
850
841
  // Fetch pub once, send to all clients linked to this pub
851
842
  SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
852
843
  return __awaiter(this, void 0, void 0, function () {
853
- var that;
854
- var _a;
844
+ var _a, that;
855
845
  var _this = this;
856
846
  return __generator(this, function (_b) {
857
847
  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.8-newrole",
3
+ "version": "4.2.9",
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: