@resolveio/server-lib 4.0.6 → 4.0.8-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.
- package/collections/user.collection.js +39 -32
- package/fixtures/init.js +1 -1
- package/index.d.ts +1 -1
- package/managers/cron.manager.js +11 -11
- package/managers/method.manager.d.ts +3 -3
- package/managers/method.manager.js +1 -1
- package/managers/subscription.manager.js +26 -21
- package/managers/support.manager.d.ts +3 -3
- package/managers/support.manager.js +3 -3
- package/package.json +1 -1
- package/server-app.js +4 -2
|
@@ -21,13 +21,6 @@ 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
|
-
},
|
|
31
24
|
attempts: {
|
|
32
25
|
type: Number,
|
|
33
26
|
optional: true
|
|
@@ -64,53 +57,67 @@ var schema = {
|
|
|
64
57
|
type: String
|
|
65
58
|
},
|
|
66
59
|
roles: {
|
|
60
|
+
type: Object
|
|
61
|
+
},
|
|
62
|
+
'roles.super_admin': {
|
|
63
|
+
type: Boolean
|
|
64
|
+
},
|
|
65
|
+
'roles.approvals': {
|
|
67
66
|
type: Array
|
|
68
67
|
},
|
|
69
|
-
'roles.$': {
|
|
68
|
+
'roles.approvals.$': {
|
|
69
|
+
type: Object
|
|
70
|
+
},
|
|
71
|
+
'roles.approvals.$.name': {
|
|
70
72
|
type: String
|
|
71
73
|
},
|
|
72
|
-
|
|
73
|
-
type: String
|
|
74
|
-
optional: true
|
|
74
|
+
'roles.approvals.$.type': {
|
|
75
|
+
type: String
|
|
75
76
|
},
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
blackbox: true,
|
|
79
|
-
optional: true
|
|
77
|
+
'roles.approvals.$.accounting_code': {
|
|
78
|
+
type: String
|
|
80
79
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
83
|
-
optional: true
|
|
80
|
+
'roles.groups': {
|
|
81
|
+
type: Array
|
|
84
82
|
},
|
|
85
|
-
'
|
|
83
|
+
'roles.groups.$': {
|
|
86
84
|
type: Object
|
|
87
85
|
},
|
|
88
|
-
'
|
|
86
|
+
'roles.groups.$.name': {
|
|
89
87
|
type: String
|
|
90
88
|
},
|
|
91
|
-
'
|
|
92
|
-
type:
|
|
89
|
+
'roles.groups.$.views': {
|
|
90
|
+
type: Array
|
|
93
91
|
},
|
|
94
|
-
'
|
|
92
|
+
'roles.groups.$.views.$': {
|
|
95
93
|
type: String
|
|
96
94
|
},
|
|
97
|
-
'
|
|
98
|
-
type: String
|
|
95
|
+
'roles.groups.$.yard': {
|
|
96
|
+
type: String,
|
|
97
|
+
optional: true
|
|
98
|
+
},
|
|
99
|
+
'roles.notifications': {
|
|
100
|
+
type: Array
|
|
99
101
|
},
|
|
100
|
-
'
|
|
102
|
+
'roles.notifications.$': {
|
|
101
103
|
type: String
|
|
102
104
|
},
|
|
103
|
-
'
|
|
104
|
-
type:
|
|
105
|
+
'roles.miscs': {
|
|
106
|
+
type: Array
|
|
105
107
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
108
|
-
optional: true
|
|
108
|
+
'roles.miscs.$': {
|
|
109
|
+
type: String
|
|
109
110
|
},
|
|
110
|
-
|
|
111
|
+
active: Boolean,
|
|
112
|
+
phonenumber: {
|
|
111
113
|
type: String,
|
|
112
114
|
optional: true
|
|
113
115
|
},
|
|
116
|
+
other: {
|
|
117
|
+
type: Object,
|
|
118
|
+
optional: true,
|
|
119
|
+
blackbox: true
|
|
120
|
+
},
|
|
114
121
|
customers: {
|
|
115
122
|
type: Array,
|
|
116
123
|
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;
|
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<
|
|
11
|
+
static connectAndRun(): Promise<unknown>;
|
|
12
12
|
static getClientName(): string;
|
|
13
13
|
static getMainServer(): ResolveIOMainServer;
|
|
14
14
|
static getMainDB(): any;
|
package/managers/cron.manager.js
CHANGED
|
@@ -157,38 +157,38 @@ var CronManager = /** @class */ (function () {
|
|
|
157
157
|
switch (_a.label) {
|
|
158
158
|
case 0:
|
|
159
159
|
if (!res) return [3 /*break*/, 9];
|
|
160
|
-
if (!
|
|
161
|
-
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(
|
|
160
|
+
if (!res.method_run_data) return [3 /*break*/, 2];
|
|
161
|
+
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(res.method_run, res.method_run_data)];
|
|
162
162
|
case 1:
|
|
163
163
|
_a.sent();
|
|
164
164
|
return [3 /*break*/, 4];
|
|
165
|
-
case 2: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(
|
|
165
|
+
case 2: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(res.method_run)];
|
|
166
166
|
case 3:
|
|
167
167
|
_a.sent();
|
|
168
168
|
_a.label = 4;
|
|
169
169
|
case 4:
|
|
170
|
-
if (!
|
|
171
|
-
if (!
|
|
172
|
-
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(
|
|
170
|
+
if (!res.method_complete) return [3 /*break*/, 8];
|
|
171
|
+
if (!res.method_complete_data) return [3 /*break*/, 6];
|
|
172
|
+
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(res.method_complete, res.method_complete_data)];
|
|
173
173
|
case 5:
|
|
174
174
|
_a.sent();
|
|
175
175
|
return [3 /*break*/, 8];
|
|
176
|
-
case 6: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(
|
|
176
|
+
case 6: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(res.method_complete)];
|
|
177
177
|
case 7:
|
|
178
178
|
_a.sent();
|
|
179
179
|
_a.label = 8;
|
|
180
180
|
case 8:
|
|
181
|
-
if (
|
|
182
|
-
nextDate = (this._cronManager.getJob(
|
|
181
|
+
if (res.repeat) {
|
|
182
|
+
nextDate = (this._cronManager.getJob(res.name).nextDates().toDate()).setSeconds(0, 0);
|
|
183
183
|
cron_job_collection_1.CronJobs.updateOne({
|
|
184
184
|
$and: [
|
|
185
|
-
{ _id:
|
|
185
|
+
{ _id: res._id },
|
|
186
186
|
{ running: true }
|
|
187
187
|
]
|
|
188
188
|
}, { $set: { running: false, next_run: nextDate } }).exec();
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
191
|
-
cron_job_collection_1.CronJobs.deleteOne({ _id:
|
|
191
|
+
cron_job_collection_1.CronJobs.deleteOne({ _id: res._id }).exec();
|
|
192
192
|
}
|
|
193
193
|
_a.label = 9;
|
|
194
194
|
case 9: return [2 /*return*/];
|
|
@@ -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<
|
|
19
|
+
callMethodQueue(update: QueueMethodModel): Promise<unknown>;
|
|
20
20
|
callMethod(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<
|
|
27
|
-
readImage(fileName: any): Promise<
|
|
26
|
+
readFile(fileName: any): Promise<unknown>;
|
|
27
|
+
readImage(fileName: any): Promise<unknown>;
|
|
28
28
|
}
|
|
@@ -361,8 +361,8 @@ var MethodManager = /** @class */ (function () {
|
|
|
361
361
|
};
|
|
362
362
|
// Call/run method (Emit on Socket)
|
|
363
363
|
MethodManager.prototype.callMethod = function (ws, messageDate, messageId, method) {
|
|
364
|
-
var _this = this;
|
|
365
364
|
var _a;
|
|
365
|
+
var _this = this;
|
|
366
366
|
var methodData = [];
|
|
367
367
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
368
368
|
methodData[_i - 4] = arguments[_i];
|
|
@@ -137,7 +137,8 @@ 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
|
|
140
|
+
var that, pub, valObj, valKeys, rootKeys, i, sub, _a, newActiveSub, begDate, endDate, billUser;
|
|
141
|
+
var _b;
|
|
141
142
|
return __generator(this, function (_c) {
|
|
142
143
|
switch (_c.label) {
|
|
143
144
|
case 0:
|
|
@@ -202,10 +203,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
202
203
|
// Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
|
|
203
204
|
that.sendPubDataOnce(ws, messageId, sub);
|
|
204
205
|
if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
|
|
205
|
-
|
|
206
|
-
return [4 /*yield*/, (
|
|
206
|
+
_a = sub;
|
|
207
|
+
return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
|
|
207
208
|
case 2:
|
|
208
|
-
|
|
209
|
+
_a.preSubscriptionData = _c.sent();
|
|
209
210
|
_c.label = 3;
|
|
210
211
|
case 3:
|
|
211
212
|
newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
|
|
@@ -553,7 +554,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
553
554
|
if (noFetchFunction === void 0) { noFetchFunction = false; }
|
|
554
555
|
var that = this;
|
|
555
556
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
556
|
-
var
|
|
557
|
+
var schemaErrors, _a, _b;
|
|
558
|
+
var _c, _d;
|
|
557
559
|
return __generator(this, function (_e) {
|
|
558
560
|
switch (_e.label) {
|
|
559
561
|
case 0:
|
|
@@ -573,18 +575,18 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
573
575
|
if (!sub.preSubscriptionData) return [3 /*break*/, 4];
|
|
574
576
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
|
|
575
577
|
that.sendPubData(sub);
|
|
576
|
-
|
|
577
|
-
return [4 /*yield*/, (
|
|
578
|
+
_a = sub;
|
|
579
|
+
return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
|
|
578
580
|
case 3:
|
|
579
|
-
|
|
581
|
+
_a.preSubscriptionData = _e.sent();
|
|
580
582
|
return [2 /*return*/];
|
|
581
583
|
case 4:
|
|
582
584
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 7];
|
|
583
585
|
if (!!noFetchFunction) return [3 /*break*/, 6];
|
|
584
|
-
|
|
586
|
+
_b = sub;
|
|
585
587
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
586
588
|
case 5:
|
|
587
|
-
|
|
589
|
+
_b.preSubscriptionData = _e.sent();
|
|
588
590
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
589
591
|
that.sendPubData(sub);
|
|
590
592
|
}
|
|
@@ -617,7 +619,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
617
619
|
else {
|
|
618
620
|
if (that._publications[sub.publication].fetchFunction) {
|
|
619
621
|
if (!noFetchFunction) {
|
|
620
|
-
if ((
|
|
622
|
+
if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
|
|
621
623
|
that.sendPubData(sub);
|
|
622
624
|
}
|
|
623
625
|
}
|
|
@@ -636,7 +638,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
636
638
|
var _this = this;
|
|
637
639
|
var that = this;
|
|
638
640
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
639
|
-
var
|
|
641
|
+
var schemaErrors, _a, _b;
|
|
642
|
+
var _c, _d, _e;
|
|
640
643
|
return __generator(this, function (_f) {
|
|
641
644
|
switch (_f.label) {
|
|
642
645
|
case 0:
|
|
@@ -656,17 +659,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
656
659
|
if (!sub.preSubscriptionData) return [3 /*break*/, 4];
|
|
657
660
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
|
|
658
661
|
that.sendPubData(sub);
|
|
659
|
-
|
|
660
|
-
return [4 /*yield*/, (
|
|
662
|
+
_a = sub;
|
|
663
|
+
return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
|
|
661
664
|
case 3:
|
|
662
|
-
|
|
665
|
+
_a.preSubscriptionData = _f.sent();
|
|
663
666
|
return [2 /*return*/];
|
|
664
667
|
case 4:
|
|
665
668
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
|
|
666
|
-
|
|
667
|
-
return [4 /*yield*/, (
|
|
669
|
+
_b = sub;
|
|
670
|
+
return [4 /*yield*/, (_d = that._publications[sub.publication]).preFunction.apply(_d, sub.subscriptionData)];
|
|
668
671
|
case 5:
|
|
669
|
-
|
|
672
|
+
_b.preSubscriptionData = _f.sent();
|
|
670
673
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
671
674
|
that.sendPubData(sub);
|
|
672
675
|
}
|
|
@@ -695,7 +698,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
695
698
|
}
|
|
696
699
|
else {
|
|
697
700
|
if (that._publications[sub.publication].fetchFunction) {
|
|
698
|
-
if ((
|
|
701
|
+
if ((_e = that._publications[sub.publication]).fetchFunction.apply(_e, [document].concat(sub.subscriptionData))) {
|
|
699
702
|
that.sendPubData(sub);
|
|
700
703
|
}
|
|
701
704
|
}
|
|
@@ -712,7 +715,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
712
715
|
// Fetch pub once, send to all clients linked to this pub
|
|
713
716
|
SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription) {
|
|
714
717
|
return __awaiter(this, void 0, void 0, function () {
|
|
715
|
-
var
|
|
718
|
+
var that;
|
|
719
|
+
var _a, _b;
|
|
716
720
|
var _this = this;
|
|
717
721
|
return __generator(this, function (_c) {
|
|
718
722
|
that = this;
|
|
@@ -757,7 +761,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
757
761
|
// Fetch pub once, send to all clients linked to this pub
|
|
758
762
|
SubscriptionManager.prototype.sendPubData = function (subscription) {
|
|
759
763
|
return __awaiter(this, void 0, void 0, function () {
|
|
760
|
-
var
|
|
764
|
+
var that;
|
|
765
|
+
var _a;
|
|
761
766
|
var _this = this;
|
|
762
767
|
return __generator(this, function (_b) {
|
|
763
768
|
that = this;
|
|
@@ -16,7 +16,7 @@ export declare class SupportManager {
|
|
|
16
16
|
callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
|
|
17
17
|
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
18
18
|
private sendWS;
|
|
19
|
-
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
|
|
20
|
-
readFile(fileName: any): Promise<
|
|
21
|
-
readImage(fileName: any): Promise<
|
|
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>;
|
|
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 _this = this;
|
|
106
105
|
var _a;
|
|
106
|
+
var _this = this;
|
|
107
107
|
var methodData = [];
|
|
108
108
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
109
109
|
methodData[_i - 3] = arguments[_i];
|
|
@@ -246,10 +246,10 @@ var SupportManager = /** @class */ (function () {
|
|
|
246
246
|
data: data
|
|
247
247
|
});
|
|
248
248
|
};
|
|
249
|
-
SupportManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments) {
|
|
249
|
+
SupportManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments, from) {
|
|
250
250
|
this._mailer.sendMail({
|
|
251
251
|
replyTo: undefined,
|
|
252
|
-
from: this.serverConfig.MAIL_FROM,
|
|
252
|
+
from: from ? from : this.serverConfig.MAIL_FROM,
|
|
253
253
|
to: sendTo,
|
|
254
254
|
subject: subject,
|
|
255
255
|
text: text,
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -251,7 +251,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
251
251
|
}, 10000);
|
|
252
252
|
// On data received (message)
|
|
253
253
|
ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
254
|
-
var
|
|
254
|
+
var socketData, data, messageDate, messageId, type, subType, pub;
|
|
255
|
+
var _a, _b;
|
|
255
256
|
var _this = this;
|
|
256
257
|
return __generator(this, function (_c) {
|
|
257
258
|
socketData = JSON.parse(message, common_1.dateReviver);
|
|
@@ -326,7 +327,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
326
327
|
if (!!this._msgQueueRunning) return [3 /*break*/, 5];
|
|
327
328
|
this._msgQueueRunning = true;
|
|
328
329
|
_loop_1 = function (i) {
|
|
329
|
-
var
|
|
330
|
+
var msg, data, ws, messageDate, messageId, type, method, serverRes, query, methodCall, supportMethod, serverRes;
|
|
331
|
+
var _a, _b;
|
|
330
332
|
return __generator(this, function (_c) {
|
|
331
333
|
switch (_c.label) {
|
|
332
334
|
case 0:
|