@resolveio/server-lib 4.2.8 → 4.3.0-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/method.manager.d.ts +3 -3
- package/managers/method.manager.js +1 -1
- package/managers/subscription.manager.js +24 -28
- package/managers/support.manager.d.ts +2 -2
- package/managers/support.manager.js +1 -1
- package/package.json +1 -1
- package/server-app.js +2 -4
|
@@ -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<{}>;
|
|
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<
|
|
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<
|
|
27
|
-
readImage(fileName: any): Promise<
|
|
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,
|
|
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
|
-
|
|
208
|
-
return [4 /*yield*/, (
|
|
206
|
+
_b = sub;
|
|
207
|
+
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
209
208
|
case 2:
|
|
210
|
-
|
|
209
|
+
_b.preSubscriptionData = _c.sent();
|
|
211
210
|
_c.label = 3;
|
|
212
211
|
case 3:
|
|
213
212
|
newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
|
|
@@ -551,7 +550,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
551
550
|
case 1:
|
|
552
551
|
docs = _a.sent();
|
|
553
552
|
needIds_1[collection].forEach(function (id_doc) {
|
|
554
|
-
oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; });
|
|
553
|
+
oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; })[0];
|
|
555
554
|
});
|
|
556
555
|
return [2 /*return*/];
|
|
557
556
|
}
|
|
@@ -620,7 +619,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
620
619
|
return [2 /*return*/];
|
|
621
620
|
});
|
|
622
621
|
}); });
|
|
623
|
-
// console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
|
|
622
|
+
// // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
|
|
624
623
|
uniqueOplog_1.forEach(function (oplog) {
|
|
625
624
|
// console.log('OPLOG QUEUE END - Oplog', oplog);
|
|
626
625
|
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
@@ -655,25 +654,24 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
655
654
|
var _this = this;
|
|
656
655
|
var that = this;
|
|
657
656
|
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;
|
|
657
|
+
var _a, _b, _c, _d;
|
|
660
658
|
return __generator(this, function (_e) {
|
|
661
659
|
switch (_e.label) {
|
|
662
660
|
case 0:
|
|
663
661
|
if (!sub.preSubscriptionData) return [3 /*break*/, 2];
|
|
664
662
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
|
|
665
663
|
that.sendPubData(sub, type, collection);
|
|
666
|
-
|
|
667
|
-
return [4 /*yield*/, (
|
|
664
|
+
_c = sub;
|
|
665
|
+
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
668
666
|
case 1:
|
|
669
|
-
|
|
667
|
+
_c.preSubscriptionData = _e.sent();
|
|
670
668
|
_e.label = 2;
|
|
671
669
|
case 2:
|
|
672
670
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
|
|
673
|
-
|
|
671
|
+
_d = sub;
|
|
674
672
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
675
673
|
case 3:
|
|
676
|
-
|
|
674
|
+
_d.preSubscriptionData = _e.sent();
|
|
677
675
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
678
676
|
that.sendPubData(sub, type, collection);
|
|
679
677
|
}
|
|
@@ -702,9 +700,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
702
700
|
}
|
|
703
701
|
else {
|
|
704
702
|
if (that._publications[sub.publication].fetchFunction) {
|
|
705
|
-
if ((
|
|
703
|
+
if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
|
|
706
704
|
that.sendPubData(sub, type, collection);
|
|
707
705
|
}
|
|
706
|
+
// else
|
|
708
707
|
}
|
|
709
708
|
else {
|
|
710
709
|
that.sendPubData(sub, type, collection);
|
|
@@ -720,8 +719,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
720
719
|
var _this = this;
|
|
721
720
|
var that = this;
|
|
722
721
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
723
|
-
var schemaErrors,
|
|
724
|
-
var _c, _d, _e;
|
|
722
|
+
var _a, _b, _c, schemaErrors, _d, _e;
|
|
725
723
|
return __generator(this, function (_f) {
|
|
726
724
|
switch (_f.label) {
|
|
727
725
|
case 0:
|
|
@@ -741,17 +739,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
741
739
|
if (!sub.preSubscriptionData) return [3 /*break*/, 4];
|
|
742
740
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
|
|
743
741
|
that.sendPubData(sub, 'support', collection);
|
|
744
|
-
|
|
745
|
-
return [4 /*yield*/, (
|
|
742
|
+
_d = sub;
|
|
743
|
+
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
746
744
|
case 3:
|
|
747
|
-
|
|
745
|
+
_d.preSubscriptionData = _f.sent();
|
|
748
746
|
return [2 /*return*/];
|
|
749
747
|
case 4:
|
|
750
748
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
|
|
751
|
-
|
|
752
|
-
return [4 /*yield*/, (
|
|
749
|
+
_e = sub;
|
|
750
|
+
return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
|
|
753
751
|
case 5:
|
|
754
|
-
|
|
752
|
+
_e.preSubscriptionData = _f.sent();
|
|
755
753
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
756
754
|
that.sendPubData(sub, 'support', collection);
|
|
757
755
|
}
|
|
@@ -780,7 +778,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
780
778
|
}
|
|
781
779
|
else {
|
|
782
780
|
if (that._publications[sub.publication].fetchFunction) {
|
|
783
|
-
if ((
|
|
781
|
+
if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, [document].concat(sub.subscriptionData))) {
|
|
784
782
|
that.sendPubData(sub, 'support', collection);
|
|
785
783
|
}
|
|
786
784
|
}
|
|
@@ -797,8 +795,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
797
795
|
// Fetch pub once, send to all clients linked to this pub
|
|
798
796
|
SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
|
|
799
797
|
return __awaiter(this, void 0, void 0, function () {
|
|
800
|
-
var that;
|
|
801
|
-
var _a, _b;
|
|
798
|
+
var _a, _b, that;
|
|
802
799
|
var _this = this;
|
|
803
800
|
return __generator(this, function (_c) {
|
|
804
801
|
that = this;
|
|
@@ -850,8 +847,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
850
847
|
// Fetch pub once, send to all clients linked to this pub
|
|
851
848
|
SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
|
|
852
849
|
return __awaiter(this, void 0, void 0, function () {
|
|
853
|
-
var that;
|
|
854
|
-
var _a;
|
|
850
|
+
var _a, that;
|
|
855
851
|
var _this = this;
|
|
856
852
|
return __generator(this, function (_b) {
|
|
857
853
|
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<
|
|
21
|
-
readImage(fileName: any): Promise<
|
|
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
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:
|