@resolveio/server-lib 4.3.14 → 4.3.15
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/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 +25 -31
- package/managers/support.manager.d.ts +2 -2
- package/managers/support.manager.js +1 -1
- package/package.json +1 -1
- package/server-app.d.ts +2 -0
- package/server-app.js +5 -4
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({
|
|
@@ -583,8 +582,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
583
582
|
if (!(i >= 0)) return [3 /*break*/, 10];
|
|
584
583
|
oplog = uniqueOplog_1[i];
|
|
585
584
|
_loop_4 = function (j) {
|
|
586
|
-
var sub,
|
|
587
|
-
var _b;
|
|
585
|
+
var _a, sub, _b;
|
|
588
586
|
return __generator(this, function (_c) {
|
|
589
587
|
switch (_c.label) {
|
|
590
588
|
case 0:
|
|
@@ -602,10 +600,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
602
600
|
}
|
|
603
601
|
}
|
|
604
602
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
|
|
605
|
-
|
|
603
|
+
_b = sub;
|
|
606
604
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
607
605
|
case 1:
|
|
608
|
-
|
|
606
|
+
_b.preSubscriptionData = _c.sent();
|
|
609
607
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
610
608
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
611
609
|
uniquePubs.push(sub);
|
|
@@ -618,7 +616,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
618
616
|
return [3 /*break*/, 3];
|
|
619
617
|
case 2:
|
|
620
618
|
if (that._publications[sub.publication].fetchFunction) {
|
|
621
|
-
if ((
|
|
619
|
+
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
622
620
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
623
621
|
uniquePubs.push(sub);
|
|
624
622
|
}
|
|
@@ -696,8 +694,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
696
694
|
case 0:
|
|
697
695
|
that = this;
|
|
698
696
|
_loop_5 = function (i) {
|
|
699
|
-
var sub,
|
|
700
|
-
var _c, _d;
|
|
697
|
+
var _a, _b, sub, _c, _d;
|
|
701
698
|
return __generator(this, function (_e) {
|
|
702
699
|
switch (_e.label) {
|
|
703
700
|
case 0:
|
|
@@ -705,17 +702,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
705
702
|
if (!sub.preSubscriptionData) return [3 /*break*/, 2];
|
|
706
703
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
|
|
707
704
|
that.sendPubData(sub, type, collection);
|
|
708
|
-
|
|
709
|
-
return [4 /*yield*/, (
|
|
705
|
+
_c = sub;
|
|
706
|
+
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
710
707
|
case 1:
|
|
711
|
-
|
|
708
|
+
_c.preSubscriptionData = _e.sent();
|
|
712
709
|
return [2 /*return*/, "continue"];
|
|
713
710
|
case 2:
|
|
714
711
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
|
|
715
|
-
|
|
712
|
+
_d = sub;
|
|
716
713
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
717
714
|
case 3:
|
|
718
|
-
|
|
715
|
+
_d.preSubscriptionData = _e.sent();
|
|
719
716
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
720
717
|
that.sendPubData(sub, type, collection);
|
|
721
718
|
}
|
|
@@ -744,7 +741,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
744
741
|
}
|
|
745
742
|
else {
|
|
746
743
|
if (that._publications[sub.publication].fetchFunction) {
|
|
747
|
-
if ((
|
|
744
|
+
if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
|
|
748
745
|
that.sendPubData(sub, type, collection);
|
|
749
746
|
}
|
|
750
747
|
// else
|
|
@@ -778,8 +775,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
778
775
|
var _this = this;
|
|
779
776
|
var that = this;
|
|
780
777
|
that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
|
|
781
|
-
var schemaErrors,
|
|
782
|
-
var _c, _d, _e;
|
|
778
|
+
var _a, _b, _c, schemaErrors, _d, _e;
|
|
783
779
|
return __generator(this, function (_f) {
|
|
784
780
|
switch (_f.label) {
|
|
785
781
|
case 0:
|
|
@@ -799,17 +795,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
799
795
|
if (!sub.preSubscriptionData) return [3 /*break*/, 4];
|
|
800
796
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
|
|
801
797
|
that.sendPubData(sub, 'support', collection);
|
|
802
|
-
|
|
803
|
-
return [4 /*yield*/, (
|
|
798
|
+
_d = sub;
|
|
799
|
+
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
804
800
|
case 3:
|
|
805
|
-
|
|
801
|
+
_d.preSubscriptionData = _f.sent();
|
|
806
802
|
return [2 /*return*/];
|
|
807
803
|
case 4:
|
|
808
804
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
|
|
809
|
-
|
|
810
|
-
return [4 /*yield*/, (
|
|
805
|
+
_e = sub;
|
|
806
|
+
return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
|
|
811
807
|
case 5:
|
|
812
|
-
|
|
808
|
+
_e.preSubscriptionData = _f.sent();
|
|
813
809
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
814
810
|
that.sendPubData(sub, 'support', collection);
|
|
815
811
|
}
|
|
@@ -838,7 +834,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
838
834
|
}
|
|
839
835
|
else {
|
|
840
836
|
if (that._publications[sub.publication].fetchFunction) {
|
|
841
|
-
if ((
|
|
837
|
+
if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, [document].concat(sub.subscriptionData))) {
|
|
842
838
|
that.sendPubData(sub, 'support', collection);
|
|
843
839
|
}
|
|
844
840
|
}
|
|
@@ -855,8 +851,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
855
851
|
// Fetch pub once, send to all clients linked to this pub
|
|
856
852
|
SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
|
|
857
853
|
return __awaiter(this, void 0, void 0, function () {
|
|
858
|
-
var that;
|
|
859
|
-
var _a, _b;
|
|
854
|
+
var _a, _b, that;
|
|
860
855
|
var _this = this;
|
|
861
856
|
return __generator(this, function (_c) {
|
|
862
857
|
that = this;
|
|
@@ -908,8 +903,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
908
903
|
// Fetch pub once, send to all clients linked to this pub
|
|
909
904
|
SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
|
|
910
905
|
return __awaiter(this, void 0, void 0, function () {
|
|
911
|
-
var that;
|
|
912
|
-
var _a;
|
|
906
|
+
var _a, that;
|
|
913
907
|
var _this = this;
|
|
914
908
|
return __generator(this, function (_b) {
|
|
915
909
|
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.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as express from 'express';
|
|
1
2
|
import * as WebSocket from 'ws';
|
|
2
3
|
import { CronManager } from './managers/cron.manager';
|
|
3
4
|
import { MethodManager } from './managers/method.manager';
|
|
@@ -32,4 +33,5 @@ export default class ResolveIOMainServer {
|
|
|
32
33
|
private setUpPassport;
|
|
33
34
|
private listen;
|
|
34
35
|
unsubscribeWS(ws: WebSocket): void;
|
|
36
|
+
getApp(): express.Application;
|
|
35
37
|
}
|
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:
|
|
@@ -649,6 +647,9 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
649
647
|
ResolveIOMainServer.prototype.unsubscribeWS = function (ws) {
|
|
650
648
|
this._subscriptionManager.unsubscribeAll(ws);
|
|
651
649
|
};
|
|
650
|
+
ResolveIOMainServer.prototype.getApp = function () {
|
|
651
|
+
return this._app;
|
|
652
|
+
};
|
|
652
653
|
return ResolveIOMainServer;
|
|
653
654
|
}());
|
|
654
655
|
exports.default = ResolveIOMainServer;
|