@resolveio/server-lib 5.0.12-debug-2 → 5.0.12-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
|
-
|
|
74
|
-
type: String
|
|
75
|
-
optional: true
|
|
75
|
+
'roles.approvals.$.type': {
|
|
76
|
+
type: String
|
|
76
77
|
},
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
blackbox: true,
|
|
80
|
-
optional: true
|
|
78
|
+
'roles.approvals.$.accounting_code': {
|
|
79
|
+
type: String
|
|
81
80
|
},
|
|
82
|
-
|
|
83
|
-
type: Array
|
|
84
|
-
optional: true
|
|
81
|
+
'roles.groups': {
|
|
82
|
+
type: Array
|
|
85
83
|
},
|
|
86
|
-
'
|
|
84
|
+
'roles.groups.$': {
|
|
87
85
|
type: Object
|
|
88
86
|
},
|
|
89
|
-
'
|
|
87
|
+
'roles.groups.$.name': {
|
|
90
88
|
type: String
|
|
91
89
|
},
|
|
92
|
-
'
|
|
93
|
-
type:
|
|
90
|
+
'roles.groups.$.views': {
|
|
91
|
+
type: Array
|
|
94
92
|
},
|
|
95
|
-
'
|
|
93
|
+
'roles.groups.$.views.$': {
|
|
96
94
|
type: String
|
|
97
95
|
},
|
|
98
|
-
'
|
|
99
|
-
type: String
|
|
96
|
+
'roles.groups.$.yard': {
|
|
97
|
+
type: String,
|
|
98
|
+
optional: true
|
|
99
|
+
},
|
|
100
|
+
'roles.notifications': {
|
|
101
|
+
type: Array
|
|
100
102
|
},
|
|
101
|
-
'
|
|
103
|
+
'roles.notifications.$': {
|
|
102
104
|
type: String
|
|
103
105
|
},
|
|
104
|
-
'
|
|
105
|
-
type:
|
|
106
|
+
'roles.miscs': {
|
|
107
|
+
type: Array
|
|
106
108
|
},
|
|
107
|
-
'
|
|
108
|
-
type:
|
|
109
|
-
optional: true
|
|
109
|
+
'roles.miscs.$': {
|
|
110
|
+
type: String
|
|
110
111
|
},
|
|
111
|
-
|
|
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,
|
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 active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
40
|
var mongoose_1 = require("mongoose");
|
|
41
|
+
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
42
42
|
function loadServerInit() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var appVersion;
|
|
@@ -56,7 +56,6 @@ var billing_logged_in_users_collection_1 = require("../collections/billing-logge
|
|
|
56
56
|
var moment = require("moment");
|
|
57
57
|
var billing_logged_in_users_1 = require("../publications/billing-logged-in-users");
|
|
58
58
|
var report_builder_reports_1 = require("../publications/report-builder-reports");
|
|
59
|
-
var NodeCache = require("node-cache");
|
|
60
59
|
var SubscriptionManager = /** @class */ (function () {
|
|
61
60
|
function SubscriptionManager(mainServer, wss, serverConfig) {
|
|
62
61
|
var _this = this;
|
|
@@ -64,11 +63,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
64
63
|
this._subscriptions = [];
|
|
65
64
|
this._oplogQueue = [];
|
|
66
65
|
this._subCache = [];
|
|
67
|
-
this._cacheId = 0;
|
|
68
66
|
this._sendQueue = [];
|
|
69
67
|
this._runningQueue = false;
|
|
70
68
|
this._mainServer = mainServer;
|
|
71
|
-
this._nodeCache = new NodeCache({ stdTTL: 0, checkperiod: 120 });
|
|
72
69
|
this.serverConfig = serverConfig;
|
|
73
70
|
this._wss = wss;
|
|
74
71
|
// Publications
|
|
@@ -674,7 +671,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
674
671
|
var that = this;
|
|
675
672
|
for (var jj = this._subCache.length - 1; jj >= 0; jj--) {
|
|
676
673
|
if (this._subCache[jj].collection === collection) {
|
|
677
|
-
this._nodeCache.del(this._subCache[jj].id);
|
|
678
674
|
this._subCache.splice(jj, 1);
|
|
679
675
|
}
|
|
680
676
|
}
|
|
@@ -723,7 +719,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
723
719
|
}).exec();
|
|
724
720
|
removed = true;
|
|
725
721
|
}
|
|
726
|
-
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);
|
|
727
722
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
728
723
|
}
|
|
729
724
|
if (!!removed) return [3 /*break*/, 2];
|
|
@@ -753,7 +748,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
753
748
|
}).exec();
|
|
754
749
|
removed = true;
|
|
755
750
|
}
|
|
756
|
-
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);
|
|
757
751
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
758
752
|
}
|
|
759
753
|
if (!removed) {
|
|
@@ -798,7 +792,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
798
792
|
}).exec();
|
|
799
793
|
removed = true;
|
|
800
794
|
}
|
|
801
|
-
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);
|
|
802
795
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
803
796
|
}
|
|
804
797
|
if (!removed) {
|
|
@@ -820,7 +813,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
820
813
|
}).exec();
|
|
821
814
|
removed = true;
|
|
822
815
|
}
|
|
823
|
-
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);
|
|
824
816
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
825
817
|
}
|
|
826
818
|
if (!removed) {
|
|
@@ -939,7 +931,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
939
931
|
serverRes = {
|
|
940
932
|
messageId: messageId,
|
|
941
933
|
hasError: false,
|
|
942
|
-
data: this.
|
|
934
|
+
data: this._subCache.filter(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })[0].res
|
|
943
935
|
};
|
|
944
936
|
this.sendWS(ws, serverRes);
|
|
945
937
|
}
|
|
@@ -948,23 +940,19 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
948
940
|
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
|
|
949
941
|
}
|
|
950
942
|
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
951
|
-
|
|
952
|
-
|
|
943
|
+
if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 500000000) {
|
|
944
|
+
var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 500000000;
|
|
953
945
|
var neededSizeIndex = 0;
|
|
954
946
|
for (var zz = 0; zz < _this._subCache.length; zz++) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
947
|
+
neededSize -= (common_1.getBinarySize(JSON.stringify(_this._subCache[zz])));
|
|
948
|
+
neededSizeIndex++;
|
|
949
|
+
if (neededSize < 0) {
|
|
958
950
|
break;
|
|
959
951
|
}
|
|
960
952
|
}
|
|
961
|
-
console.log('Cache1: ' + 'Too Big - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
|
|
962
953
|
_this._subCache.splice(0, neededSizeIndex);
|
|
963
954
|
}
|
|
964
|
-
|
|
965
|
-
_this._nodeCache.set(cacheId, res);
|
|
966
|
-
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId });
|
|
967
|
-
console.log('Cache1: ' + 'Create - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
|
|
955
|
+
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, res: res });
|
|
968
956
|
var serverRes = {
|
|
969
957
|
messageId: messageId,
|
|
970
958
|
hasError: false,
|
|
@@ -1018,9 +1006,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1018
1006
|
var serverRes = {
|
|
1019
1007
|
messageId: client.messageId,
|
|
1020
1008
|
hasError: false,
|
|
1021
|
-
data: _this.
|
|
1009
|
+
data: _this._subCache.filter(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })[0].res
|
|
1022
1010
|
};
|
|
1023
|
-
console.log('Cache: ' + 'Found - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
|
|
1024
1011
|
_this.sendWS(ws, serverRes);
|
|
1025
1012
|
}
|
|
1026
1013
|
});
|
|
@@ -1031,23 +1018,19 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1031
1018
|
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
|
|
1032
1019
|
}
|
|
1033
1020
|
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1021
|
+
if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 500000000) {
|
|
1022
|
+
var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 500000000;
|
|
1036
1023
|
var neededSizeIndex = 0;
|
|
1037
1024
|
for (var zz = 0; zz < _this._subCache.length; zz++) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1025
|
+
neededSize -= (common_1.getBinarySize(JSON.stringify(_this._subCache[zz])));
|
|
1026
|
+
neededSizeIndex++;
|
|
1027
|
+
if (neededSize < 0) {
|
|
1041
1028
|
break;
|
|
1042
1029
|
}
|
|
1043
1030
|
}
|
|
1044
|
-
console.log('Cache: ' + 'Too Big - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
|
|
1045
1031
|
_this._subCache.splice(0, neededSizeIndex);
|
|
1046
1032
|
}
|
|
1047
|
-
|
|
1048
|
-
_this._nodeCache.set(cacheId, res);
|
|
1049
|
-
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId });
|
|
1050
|
-
console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
|
|
1033
|
+
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, res: res });
|
|
1051
1034
|
subscription.clients.forEach(function (client) {
|
|
1052
1035
|
that._wss.clients.forEach(function (ws) {
|
|
1053
1036
|
if (ws['id_socket'] === client.id_socket) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolveio/server-lib",
|
|
3
|
-
"version": "5.0.12-
|
|
3
|
+
"version": "5.0.12-newrole",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"mongo-oplog": "2.1.4",
|
|
28
28
|
"mongoose": "5.6.0",
|
|
29
29
|
"node-google-timezone": "0.1.1",
|
|
30
|
-
"node-cache": "5.0.1",
|
|
31
30
|
"nodemailer": "6.2.1",
|
|
32
31
|
"passport": "0.4.0",
|
|
33
32
|
"passport-local": "1.0.0",
|