@resolveio/server-lib 3.0.2 → 3.0.4
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/method-response.collection.js +0 -3
- package/collections/queue-method.collection.js +3 -0
- package/managers/method.manager.d.ts +1 -1
- package/managers/method.manager.js +14 -13
- package/managers/queue-method.manager.d.ts +1 -1
- package/managers/queue-method.manager.js +7 -5
- package/models/method-response.model.d.ts +0 -1
- package/models/queue-method.model.d.ts +1 -0
- package/package.json +1 -1
- package/server-app.js +5 -9
|
@@ -17,7 +17,7 @@ export declare class MethodManager {
|
|
|
17
17
|
methods(method: MethodModel): void;
|
|
18
18
|
callMethodCron(method: string, ...methodData: any[]): void;
|
|
19
19
|
callMethodQueue(update: QueueMethodModel): Promise<{}>;
|
|
20
|
-
callMethod(ws: WebSocket, messageId:
|
|
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;
|
|
@@ -182,9 +182,9 @@ var MethodManager = /** @class */ (function () {
|
|
|
182
182
|
__v: 0,
|
|
183
183
|
id_user: ws['id_user'],
|
|
184
184
|
message_id: sendItem.data.messageId,
|
|
185
|
-
data: JSON.stringify(sendItem.methodData),
|
|
186
185
|
response: sendItem.data,
|
|
187
|
-
method: sendItem.method
|
|
186
|
+
method: sendItem.method,
|
|
187
|
+
messageDate: sendItem.messageDate
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
@@ -373,11 +373,11 @@ var MethodManager = /** @class */ (function () {
|
|
|
373
373
|
});
|
|
374
374
|
};
|
|
375
375
|
// Call/run method (Emit on Socket)
|
|
376
|
-
MethodManager.prototype.callMethod = function (ws, messageId, method) {
|
|
376
|
+
MethodManager.prototype.callMethod = function (ws, messageDate, messageId, method) {
|
|
377
377
|
var _this = this;
|
|
378
378
|
var methodData = [];
|
|
379
|
-
for (var _i =
|
|
380
|
-
methodData[_i -
|
|
379
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
380
|
+
methodData[_i - 4] = arguments[_i];
|
|
381
381
|
}
|
|
382
382
|
var _a;
|
|
383
383
|
var that = this;
|
|
@@ -389,7 +389,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
389
389
|
hasError: true,
|
|
390
390
|
data: 'Internal Error'
|
|
391
391
|
};
|
|
392
|
-
this.sendWS(ws, method, methodData, serverRes);
|
|
392
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
if ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {
|
|
@@ -401,7 +401,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
401
401
|
hasError: true,
|
|
402
402
|
data: 'Internal Error'
|
|
403
403
|
};
|
|
404
|
-
this.sendWS(ws, method, methodData, serverRes);
|
|
404
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
407
|
else if (!that._methods[method].check._schema) {
|
|
@@ -412,7 +412,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
412
412
|
hasError: true,
|
|
413
413
|
data: 'Internal Error'
|
|
414
414
|
};
|
|
415
|
-
this.sendWS(ws, method, methodData, serverRes);
|
|
415
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
418
|
else {
|
|
@@ -434,7 +434,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
434
434
|
hasError: true,
|
|
435
435
|
data: 'Internal Error'
|
|
436
436
|
};
|
|
437
|
-
this.sendWS(ws, method, methodData, serverRes);
|
|
437
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
@@ -446,14 +446,14 @@ var MethodManager = /** @class */ (function () {
|
|
|
446
446
|
hasError: false,
|
|
447
447
|
data: res
|
|
448
448
|
};
|
|
449
|
-
_this.sendWS(ws, method, methodData, serverRes);
|
|
449
|
+
_this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
450
450
|
}, function (err) {
|
|
451
451
|
var serverRes = {
|
|
452
452
|
messageId: messageId,
|
|
453
453
|
hasError: true,
|
|
454
454
|
data: err
|
|
455
455
|
};
|
|
456
|
-
_this.sendWS(ws, method, methodData, serverRes);
|
|
456
|
+
_this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
457
457
|
});
|
|
458
458
|
};
|
|
459
459
|
// Call/run method internal (No Emit on Socket)
|
|
@@ -511,12 +511,13 @@ var MethodManager = /** @class */ (function () {
|
|
|
511
511
|
}
|
|
512
512
|
return promise;
|
|
513
513
|
};
|
|
514
|
-
MethodManager.prototype.sendWS = function (ws, method, methodData, data) {
|
|
514
|
+
MethodManager.prototype.sendWS = function (ws, messageDate, method, methodData, data) {
|
|
515
515
|
this._sendQueue.splice(0, 0, {
|
|
516
516
|
id_ws: ws['id_socket'],
|
|
517
517
|
method: method,
|
|
518
518
|
methodData: methodData,
|
|
519
|
-
data: data
|
|
519
|
+
data: data,
|
|
520
|
+
messageDate: messageDate
|
|
520
521
|
});
|
|
521
522
|
};
|
|
522
523
|
MethodManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments, send_from) {
|
|
@@ -6,7 +6,7 @@ export declare class QueueMethodManager {
|
|
|
6
6
|
private _runningQueue;
|
|
7
7
|
private _runningMethodResponse;
|
|
8
8
|
constructor(mainServer: any);
|
|
9
|
-
addMethodToQueue(id_ws: string, id_user: string, user: string, messageId: string, method: string, data: any[]): void;
|
|
9
|
+
addMethodToQueue(id_ws: string, id_user: string, user: string, messageDate: Date, messageId: string, method: string, data: any[]): void;
|
|
10
10
|
runMethodQueue(count?: number): Promise<void>;
|
|
11
11
|
addMethodResponse(update: QueueMethodModel, response: ServerResponseModel): void;
|
|
12
12
|
runMethodResponse(): Promise<void>;
|
|
@@ -81,9 +81,9 @@ var QueueMethodManager = /** @class */ (function () {
|
|
|
81
81
|
__v: 0,
|
|
82
82
|
id_user: sendItem.id_user,
|
|
83
83
|
message_id: sendItem.messageId,
|
|
84
|
-
data: JSON.stringify(sendItem.method_data),
|
|
85
84
|
response: sendItem.response,
|
|
86
|
-
method: sendItem.method
|
|
85
|
+
method: sendItem.method,
|
|
86
|
+
messageDate: sendItem.messageDate
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
@@ -124,7 +124,7 @@ var QueueMethodManager = /** @class */ (function () {
|
|
|
124
124
|
}
|
|
125
125
|
}, 50);
|
|
126
126
|
}
|
|
127
|
-
QueueMethodManager.prototype.addMethodToQueue = function (id_ws, id_user, user, messageId, method, data) {
|
|
127
|
+
QueueMethodManager.prototype.addMethodToQueue = function (id_ws, id_user, user, messageDate, messageId, method, data) {
|
|
128
128
|
// console.log('Add Method To Queue', method);
|
|
129
129
|
queue_method_collection_1.QueueMethods.create({
|
|
130
130
|
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
@@ -134,7 +134,8 @@ var QueueMethodManager = /** @class */ (function () {
|
|
|
134
134
|
method: method,
|
|
135
135
|
method_data: data,
|
|
136
136
|
id_user: id_user,
|
|
137
|
-
user: user
|
|
137
|
+
user: user,
|
|
138
|
+
messageDate: messageDate
|
|
138
139
|
});
|
|
139
140
|
};
|
|
140
141
|
QueueMethodManager.prototype.runMethodQueue = function (count) {
|
|
@@ -209,7 +210,8 @@ var QueueMethodManager = /** @class */ (function () {
|
|
|
209
210
|
messageId: update.messageId,
|
|
210
211
|
method_data: update.method_data,
|
|
211
212
|
response: response,
|
|
212
|
-
method: update.method
|
|
213
|
+
method: update.method,
|
|
214
|
+
messageDate: update.messageDate
|
|
213
215
|
});
|
|
214
216
|
};
|
|
215
217
|
QueueMethodManager.prototype.runMethodResponse = function () {
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -406,7 +406,6 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
406
406
|
query = { $and: [
|
|
407
407
|
{ id_user: ws['id_user'] },
|
|
408
408
|
{ message_id: messageId },
|
|
409
|
-
{ data: JSON.stringify(data) },
|
|
410
409
|
{ date: messageDate }
|
|
411
410
|
] };
|
|
412
411
|
if (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {
|
|
@@ -440,17 +439,16 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
440
439
|
id_user: ws['id_user'],
|
|
441
440
|
message_id: messageId,
|
|
442
441
|
method: method,
|
|
443
|
-
data: JSON.stringify(data),
|
|
444
442
|
date: messageDate
|
|
445
443
|
})];
|
|
446
444
|
case 2:
|
|
447
445
|
_c.sent();
|
|
448
446
|
if (this_1._methodManager._methods[method]) {
|
|
449
447
|
if (this_1._methodManager._methods[method].skipQueue) {
|
|
450
|
-
(_a = this_1._methodManager).callMethod.apply(_a, [ws, messageId, method].concat(data));
|
|
448
|
+
(_a = this_1._methodManager).callMethod.apply(_a, [ws, messageDate, messageId, method].concat(data));
|
|
451
449
|
}
|
|
452
450
|
else {
|
|
453
|
-
this_1._queueManager.addMethodToQueue(ws['id_socket'], ws['id_user'], ws['user'], messageId, method, data);
|
|
451
|
+
this_1._queueManager.addMethodToQueue(ws['id_socket'], ws['id_user'], ws['user'], messageDate, messageId, method, data);
|
|
454
452
|
}
|
|
455
453
|
}
|
|
456
454
|
else {
|
|
@@ -461,8 +459,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
461
459
|
method_response_collection_1.MethodResponses.findOne({ $and: [
|
|
462
460
|
{ id_user: ws['id_user'] },
|
|
463
461
|
{ message_id: messageId },
|
|
464
|
-
{ method: method }
|
|
465
|
-
{ data: JSON.stringify(data) }
|
|
462
|
+
{ method: method }
|
|
466
463
|
] }).exec(function (err, res) {
|
|
467
464
|
if (res) {
|
|
468
465
|
if (ws && ws.readyState === ws.OPEN) {
|
|
@@ -529,7 +526,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
529
526
|
{ id_user: ws['id_user'] },
|
|
530
527
|
{ message_id: messageId },
|
|
531
528
|
{ method: method },
|
|
532
|
-
{
|
|
529
|
+
{ date: messageDate }
|
|
533
530
|
] }).exec(function (err, res) {
|
|
534
531
|
if (res) {
|
|
535
532
|
var serverRes = {
|
|
@@ -609,8 +606,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
609
606
|
method_response_collection_1.MethodResponses.findOne({ $and: [
|
|
610
607
|
{ id_user: ws['id_user'] },
|
|
611
608
|
{ message_id: messageId },
|
|
612
|
-
{ method: method }
|
|
613
|
-
{ data: JSON.stringify(data) }
|
|
609
|
+
{ method: method }
|
|
614
610
|
] }).exec(function (err, res) {
|
|
615
611
|
if (res) {
|
|
616
612
|
if (ws && ws.readyState === ws.OPEN) {
|