@resolveio/server-lib 4.2.5 → 4.2.6-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.d.ts +2 -2
- package/managers/subscription.manager.js +79 -106
- package/managers/support.manager.d.ts +2 -2
- package/managers/support.manager.js +1 -1
- package/package.json +1 -1
- package/server-app.js +6 -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<unknown>;
|
|
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<unknown>;
|
|
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<unknown>;
|
|
27
|
+
readImage(fileName: any): Promise<unknown>;
|
|
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 _this = this;
|
|
420
419
|
var _a;
|
|
420
|
+
var _this = this;
|
|
421
421
|
var methodData = [];
|
|
422
422
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
423
423
|
methodData[_i - 5] = arguments[_i];
|
|
@@ -12,8 +12,8 @@ export declare class SubscriptionManager {
|
|
|
12
12
|
constructor(mainServer: any, wss: WebSocket.Server, serverConfig: any);
|
|
13
13
|
publications(method: SubscriptionModel): void;
|
|
14
14
|
loggedInLatency(ws: WebSocket): Promise<void>;
|
|
15
|
-
subscribe(ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
16
|
-
unsubscribe(ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
15
|
+
subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
16
|
+
unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
17
17
|
unsubscribeAll(ws: WebSocket): Promise<void>;
|
|
18
18
|
private getPublicationCollections;
|
|
19
19
|
private tailOpLog;
|
|
@@ -131,13 +131,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
131
131
|
});
|
|
132
132
|
};
|
|
133
133
|
// Subscribe to publication
|
|
134
|
-
SubscriptionManager.prototype.subscribe = function (ws, messageId, publication) {
|
|
134
|
+
SubscriptionManager.prototype.subscribe = function (messageDate, ws, messageId, publication) {
|
|
135
135
|
var subscriptionData = [];
|
|
136
|
-
for (var _i =
|
|
137
|
-
subscriptionData[_i -
|
|
136
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
137
|
+
subscriptionData[_i - 4] = 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:
|
|
@@ -199,13 +200,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
199
200
|
if (!sub) {
|
|
200
201
|
sub = that._subscriptions.filter(function (a) { return a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData); })[0];
|
|
201
202
|
}
|
|
203
|
+
// console.log('Subscribe', new Date(), 'Success', sub);
|
|
202
204
|
// Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
|
|
203
205
|
that.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);
|
|
204
206
|
if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
|
|
205
|
-
|
|
206
|
-
return [4 /*yield*/, (
|
|
207
|
+
_a = sub;
|
|
208
|
+
return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
|
|
207
209
|
case 2:
|
|
208
|
-
|
|
210
|
+
_a.preSubscriptionData = _c.sent();
|
|
209
211
|
_c.label = 3;
|
|
210
212
|
case 3:
|
|
211
213
|
newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
|
|
@@ -270,10 +272,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
270
272
|
});
|
|
271
273
|
};
|
|
272
274
|
// Unsubscribe from publication
|
|
273
|
-
SubscriptionManager.prototype.unsubscribe = function (ws, messageId, publication) {
|
|
275
|
+
SubscriptionManager.prototype.unsubscribe = function (messageDate, ws, messageId, publication) {
|
|
274
276
|
var subscriptionData = [];
|
|
275
|
-
for (var _i =
|
|
276
|
-
subscriptionData[_i -
|
|
277
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
278
|
+
subscriptionData[_i - 4] = arguments[_i];
|
|
277
279
|
}
|
|
278
280
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
281
|
var that, sub, i, activeSub;
|
|
@@ -550,87 +552,50 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
550
552
|
oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
|
|
551
553
|
var _loop_3, i;
|
|
552
554
|
return __generator(this, function (_a) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (sub.preSubscriptionData) {
|
|
563
|
-
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
564
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
|
|
565
|
-
uniquePubs_1.push(sub);
|
|
566
|
-
uniqueOplog_1.push(oplog);
|
|
567
|
-
}
|
|
568
|
-
return [2 /*return*/, "continue"];
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
|
|
572
|
-
_b = sub;
|
|
573
|
-
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
574
|
-
case 1:
|
|
575
|
-
_b.preSubscriptionData = _c.sent();
|
|
576
|
-
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
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]) {
|
|
578
|
-
uniquePubs_1.push(sub);
|
|
579
|
-
uniqueOplog_1.push(oplog);
|
|
580
|
-
}
|
|
581
|
-
return [2 /*return*/, "continue"];
|
|
582
|
-
}
|
|
583
|
-
return [3 /*break*/, 3];
|
|
584
|
-
case 2:
|
|
585
|
-
if (that._publications[sub.publication].ws_specific) {
|
|
586
|
-
sub.clients.forEach(function (client) {
|
|
587
|
-
var _a;
|
|
588
|
-
if (that._publications[sub.publication].fetchFunction) {
|
|
589
|
-
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc, client.id_user].concat(sub.subscriptionData))) {
|
|
590
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
|
|
591
|
-
uniquePubs_1.push(sub);
|
|
592
|
-
uniqueOplog_1.push(oplog);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
if (that._publications[sub.publication].fetchFunction) {
|
|
600
|
-
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
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]) {
|
|
602
|
-
uniquePubs_1.push(sub);
|
|
603
|
-
uniqueOplog_1.push(oplog);
|
|
604
|
-
}
|
|
605
|
-
return [2 /*return*/, "continue"];
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
610
|
-
uniquePubs_1.push(sub);
|
|
611
|
-
uniqueOplog_1.push(oplog);
|
|
612
|
-
}
|
|
613
|
-
return [2 /*return*/, "continue"];
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
_c.label = 3;
|
|
617
|
-
case 3: return [2 /*return*/];
|
|
555
|
+
_loop_3 = function (i) {
|
|
556
|
+
var _a;
|
|
557
|
+
var sub = that._subscriptions[i];
|
|
558
|
+
if (sub.collections.includes(oplog.collection)) {
|
|
559
|
+
if (sub.preSubscriptionData) {
|
|
560
|
+
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
561
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
562
|
+
uniquePubs_1.push(sub);
|
|
563
|
+
uniqueOplog_1.push(oplog);
|
|
618
564
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
565
|
+
return "continue";
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (that._publications[sub.publication].preFunction) {
|
|
569
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
570
|
+
uniquePubs_1.push(sub);
|
|
571
|
+
uniqueOplog_1.push(oplog);
|
|
572
|
+
}
|
|
573
|
+
return "continue";
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
if (that._publications[sub.publication].fetchFunction) {
|
|
577
|
+
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
578
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
579
|
+
uniquePubs_1.push(sub);
|
|
580
|
+
uniqueOplog_1.push(oplog);
|
|
581
|
+
}
|
|
582
|
+
return "continue";
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
587
|
+
uniquePubs_1.push(sub);
|
|
588
|
+
uniqueOplog_1.push(oplog);
|
|
589
|
+
}
|
|
590
|
+
return "continue";
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
for (i = 0; i < that._subscriptions.length; i++) {
|
|
596
|
+
_loop_3(i);
|
|
633
597
|
}
|
|
598
|
+
return [2 /*return*/];
|
|
634
599
|
});
|
|
635
600
|
}); });
|
|
636
601
|
uniqueOplog_1.forEach(function (oplog) {
|
|
@@ -663,24 +628,25 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
663
628
|
var _this = this;
|
|
664
629
|
var that = this;
|
|
665
630
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
666
|
-
var _a, _b
|
|
631
|
+
var _a, _b;
|
|
632
|
+
var _c, _d;
|
|
667
633
|
return __generator(this, function (_e) {
|
|
668
634
|
switch (_e.label) {
|
|
669
635
|
case 0:
|
|
670
636
|
if (!sub.preSubscriptionData) return [3 /*break*/, 2];
|
|
671
637
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
|
|
672
638
|
that.sendPubData(sub, type, collection);
|
|
673
|
-
|
|
674
|
-
return [4 /*yield*/, (
|
|
639
|
+
_a = sub;
|
|
640
|
+
return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
|
|
675
641
|
case 1:
|
|
676
|
-
|
|
642
|
+
_a.preSubscriptionData = _e.sent();
|
|
677
643
|
_e.label = 2;
|
|
678
644
|
case 2:
|
|
679
645
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
|
|
680
|
-
|
|
646
|
+
_b = sub;
|
|
681
647
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
682
648
|
case 3:
|
|
683
|
-
|
|
649
|
+
_b.preSubscriptionData = _e.sent();
|
|
684
650
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
685
651
|
that.sendPubData(sub, type, collection);
|
|
686
652
|
}
|
|
@@ -709,7 +675,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
709
675
|
}
|
|
710
676
|
else {
|
|
711
677
|
if (that._publications[sub.publication].fetchFunction) {
|
|
712
|
-
if ((
|
|
678
|
+
if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
|
|
713
679
|
that.sendPubData(sub, type, collection);
|
|
714
680
|
}
|
|
715
681
|
}
|
|
@@ -727,7 +693,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
727
693
|
var _this = this;
|
|
728
694
|
var that = this;
|
|
729
695
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
730
|
-
var
|
|
696
|
+
var schemaErrors, _a, _b;
|
|
697
|
+
var _c, _d, _e;
|
|
731
698
|
return __generator(this, function (_f) {
|
|
732
699
|
switch (_f.label) {
|
|
733
700
|
case 0:
|
|
@@ -747,17 +714,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
747
714
|
if (!sub.preSubscriptionData) return [3 /*break*/, 4];
|
|
748
715
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
|
|
749
716
|
that.sendPubData(sub, 'support', collection);
|
|
750
|
-
|
|
751
|
-
return [4 /*yield*/, (
|
|
717
|
+
_a = sub;
|
|
718
|
+
return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
|
|
752
719
|
case 3:
|
|
753
|
-
|
|
720
|
+
_a.preSubscriptionData = _f.sent();
|
|
754
721
|
return [2 /*return*/];
|
|
755
722
|
case 4:
|
|
756
723
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
|
|
757
|
-
|
|
758
|
-
return [4 /*yield*/, (
|
|
724
|
+
_b = sub;
|
|
725
|
+
return [4 /*yield*/, (_d = that._publications[sub.publication]).preFunction.apply(_d, sub.subscriptionData)];
|
|
759
726
|
case 5:
|
|
760
|
-
|
|
727
|
+
_b.preSubscriptionData = _f.sent();
|
|
761
728
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
762
729
|
that.sendPubData(sub, 'support', collection);
|
|
763
730
|
}
|
|
@@ -786,7 +753,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
786
753
|
}
|
|
787
754
|
else {
|
|
788
755
|
if (that._publications[sub.publication].fetchFunction) {
|
|
789
|
-
if ((
|
|
756
|
+
if ((_e = that._publications[sub.publication]).fetchFunction.apply(_e, [document].concat(sub.subscriptionData))) {
|
|
790
757
|
that.sendPubData(sub, 'support', collection);
|
|
791
758
|
}
|
|
792
759
|
}
|
|
@@ -803,7 +770,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
803
770
|
// Fetch pub once, send to all clients linked to this pub
|
|
804
771
|
SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
|
|
805
772
|
return __awaiter(this, void 0, void 0, function () {
|
|
806
|
-
var
|
|
773
|
+
var that;
|
|
774
|
+
var _a, _b;
|
|
807
775
|
var _this = this;
|
|
808
776
|
return __generator(this, function (_c) {
|
|
809
777
|
that = this;
|
|
@@ -817,6 +785,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
817
785
|
hasError: false,
|
|
818
786
|
data: res
|
|
819
787
|
};
|
|
788
|
+
// console.log('Send Pub Data Once 1', new Date(), 'Success', subscription);
|
|
820
789
|
_this.sendWS(ws, serverRes);
|
|
821
790
|
}, function (err) {
|
|
822
791
|
var serverRes = {
|
|
@@ -824,6 +793,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
824
793
|
hasError: true,
|
|
825
794
|
data: err
|
|
826
795
|
};
|
|
796
|
+
// console.log('Send Pub Data Once 1', new Date(), 'Error', subscription);
|
|
827
797
|
_this.sendWS(ws, serverRes);
|
|
828
798
|
});
|
|
829
799
|
}
|
|
@@ -834,6 +804,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
834
804
|
hasError: false,
|
|
835
805
|
data: res
|
|
836
806
|
};
|
|
807
|
+
// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);
|
|
837
808
|
_this.sendWS(ws, serverRes);
|
|
838
809
|
}, function (err) {
|
|
839
810
|
var serverRes = {
|
|
@@ -841,6 +812,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
841
812
|
hasError: true,
|
|
842
813
|
data: err
|
|
843
814
|
};
|
|
815
|
+
// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);
|
|
844
816
|
_this.sendWS(ws, serverRes);
|
|
845
817
|
});
|
|
846
818
|
}
|
|
@@ -851,7 +823,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
851
823
|
// Fetch pub once, send to all clients linked to this pub
|
|
852
824
|
SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
|
|
853
825
|
return __awaiter(this, void 0, void 0, function () {
|
|
854
|
-
var
|
|
826
|
+
var that;
|
|
827
|
+
var _a;
|
|
855
828
|
var _this = this;
|
|
856
829
|
return __generator(this, function (_b) {
|
|
857
830
|
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<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];
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -254,7 +254,8 @@ 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
|
|
257
|
+
var socketData, data, messageDate, messageId, type, subType, pub;
|
|
258
|
+
var _a, _b;
|
|
258
259
|
var _this = this;
|
|
259
260
|
return __generator(this, function (_c) {
|
|
260
261
|
socketData = JSON.parse(message, common_1.dateReviver);
|
|
@@ -278,11 +279,11 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
278
279
|
pub = data.shift();
|
|
279
280
|
// Subscribe
|
|
280
281
|
if (subType === 'sub') {
|
|
281
|
-
(_a = this._subscriptionManager).subscribe.apply(_a, [ws, messageId, pub].concat(data));
|
|
282
|
+
(_a = this._subscriptionManager).subscribe.apply(_a, [messageDate, ws, messageId, pub].concat(data));
|
|
282
283
|
}
|
|
283
284
|
// Unsubscribe
|
|
284
285
|
else {
|
|
285
|
-
(_b = this._subscriptionManager).unsubscribe.apply(_b, [ws, messageId, pub].concat(data));
|
|
286
|
+
(_b = this._subscriptionManager).unsubscribe.apply(_b, [messageDate, ws, messageId, pub].concat(data));
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
else {
|
|
@@ -329,7 +330,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
329
330
|
if (!!this._msgQueueRunning) return [3 /*break*/, 5];
|
|
330
331
|
this._msgQueueRunning = true;
|
|
331
332
|
_loop_1 = function (i) {
|
|
332
|
-
var
|
|
333
|
+
var msg, data, ws, messageDate, messageId, type, method, methodLatency, serverRes, query, methodCall, supportMethod, serverRes;
|
|
334
|
+
var _a, _b;
|
|
333
335
|
return __generator(this, function (_c) {
|
|
334
336
|
switch (_c.label) {
|
|
335
337
|
case 0:
|