node-pluginsmanager-plugin 5.0.10 → 5.0.12
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { OpenApiDocument } from "express-openapi-validate";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type tLogType = "data" | "debug" | "log" | "info" | "success" | "warning" | "error";
|
|
5
|
+
export type tLogger = (type: tLogType, message: string | Error, bold?: boolean, pluginName?: string) => void;
|
|
6
6
|
export interface iDescriptorUserOptions {
|
|
7
7
|
"externalRessourcesDirectory": string;
|
|
8
8
|
"descriptor"?: OpenApiDocument;
|
|
@@ -422,8 +422,9 @@ class Server extends MediatorUser_1.default {
|
|
|
422
422
|
return this;
|
|
423
423
|
}
|
|
424
424
|
getClients() {
|
|
425
|
+
var _a, _b;
|
|
425
426
|
switch (this._serverType()) {
|
|
426
|
-
case "WEBSOCKET":
|
|
427
|
+
case "WEBSOCKET": {
|
|
427
428
|
const result = [];
|
|
428
429
|
this._socketServer.clients.forEach((s) => {
|
|
429
430
|
if (!s.id) {
|
|
@@ -435,14 +436,26 @@ class Server extends MediatorUser_1.default {
|
|
|
435
436
|
};
|
|
436
437
|
});
|
|
437
438
|
return result;
|
|
439
|
+
}
|
|
438
440
|
case "SOCKETIO": {
|
|
439
441
|
const result = [];
|
|
440
|
-
this._socketServer.sockets.sockets.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
if ("function" !== typeof ((_b = (_a = this._socketServer.sockets) === null || _a === void 0 ? void 0 : _a.sockets) === null || _b === void 0 ? void 0 : _b.has)) { // SocketIO V2
|
|
443
|
+
for (const key in this._socketServer.sockets.sockets) {
|
|
444
|
+
const s = this._socketServer.sockets.sockets[key];
|
|
445
|
+
result.push({
|
|
446
|
+
"id": s.id,
|
|
447
|
+
"status": s.connected ? "CONNECTED" : "DISCONNECTED"
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
this._socketServer.sockets.sockets.forEach((s) => {
|
|
453
|
+
result.push({
|
|
454
|
+
"id": s.id,
|
|
455
|
+
"status": s.connected ? "CONNECTED" : "DISCONNECTED"
|
|
456
|
+
});
|
|
444
457
|
});
|
|
445
|
-
}
|
|
458
|
+
}
|
|
446
459
|
return result;
|
|
447
460
|
}
|
|
448
461
|
default:
|
|
@@ -467,6 +480,7 @@ class Server extends MediatorUser_1.default {
|
|
|
467
480
|
return Promise.resolve(JSON.stringify(result));
|
|
468
481
|
// log & send data
|
|
469
482
|
}).then((result) => {
|
|
483
|
+
var _a, _b;
|
|
470
484
|
switch (serverType) {
|
|
471
485
|
case "WEBSOCKET":
|
|
472
486
|
this._socketServer.clients.forEach((client) => {
|
|
@@ -482,8 +496,19 @@ class Server extends MediatorUser_1.default {
|
|
|
482
496
|
});
|
|
483
497
|
break;
|
|
484
498
|
case "SOCKETIO":
|
|
485
|
-
|
|
486
|
-
|
|
499
|
+
{
|
|
500
|
+
let socket = null;
|
|
501
|
+
if ("function" !== typeof ((_b = (_a = this._socketServer.sockets) === null || _a === void 0 ? void 0 : _a.sockets) === null || _b === void 0 ? void 0 : _b.has)) { // SocketIO V2
|
|
502
|
+
for (const key in this._socketServer.sockets.sockets) {
|
|
503
|
+
if (key === clientId) {
|
|
504
|
+
socket = this._socketServer.sockets.sockets[key];
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else if (this._socketServer.sockets.sockets.has(clientId)) { // SocketIO V3&4
|
|
510
|
+
socket = this._socketServer.sockets.sockets.get(clientId);
|
|
511
|
+
}
|
|
487
512
|
if (socket && socket.connected) {
|
|
488
513
|
if (log) {
|
|
489
514
|
this._log("info", "<= [PUSH|" + clientId + "] " + result);
|
|
@@ -6,32 +6,10 @@ function cleanSendedError(data) {
|
|
|
6
6
|
if (data instanceof Error) {
|
|
7
7
|
return data.message;
|
|
8
8
|
}
|
|
9
|
-
else if (data.message) {
|
|
10
|
-
return data.message instanceof Error ? data.message.message : data.message;
|
|
11
|
-
}
|
|
12
|
-
else if (data.error) { // 1 level recursive for "error" data (avoid too deep recursive analyse)
|
|
13
|
-
if (data.error instanceof Error) {
|
|
14
|
-
return data.error.message;
|
|
15
|
-
}
|
|
16
|
-
else if (data.error.message) {
|
|
17
|
-
return data.error.message instanceof Error ? data.error.message.message : data.error.message;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return data.error;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else if (data.err) { // 1 level recursive for "err" data (avoid too deep recursive analyse)
|
|
24
|
-
if (data.err instanceof Error) {
|
|
25
|
-
return data.err.message;
|
|
26
|
-
}
|
|
27
|
-
else if (data.err.message) {
|
|
28
|
-
return data.err.message instanceof Error ? data.err.message.message : data.err.message;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return data.err;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
9
|
else {
|
|
10
|
+
Object.keys(data).forEach((key) => {
|
|
11
|
+
data[key] = cleanSendedError(data[key]);
|
|
12
|
+
});
|
|
35
13
|
return data;
|
|
36
14
|
}
|
|
37
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenApiDocument } from "express-openapi-validate";
|
|
2
|
-
export
|
|
2
|
+
export type tMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
3
3
|
export interface iPathMethod {
|
|
4
4
|
"path": string;
|
|
5
5
|
"method": tMethod;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-pluginsmanager-plugin",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.12",
|
|
4
4
|
"description": "An abstract parent plugin for node-pluginsmanager",
|
|
5
5
|
|
|
6
6
|
"type": "commonjs",
|
|
@@ -57,22 +57,22 @@
|
|
|
57
57
|
"uniqid": "5.4.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/express": "4.17.
|
|
61
|
-
"@types/node": "18.0
|
|
60
|
+
"@types/express": "4.17.17",
|
|
61
|
+
"@types/node": "18.14.0",
|
|
62
62
|
"@types/socket.io": "3.0.2",
|
|
63
63
|
"@types/uniqid": "5.3.2",
|
|
64
|
-
"@types/ws": "8.5.
|
|
64
|
+
"@types/ws": "8.5.4",
|
|
65
65
|
"check-version-modules": "1.3.5",
|
|
66
66
|
"coveralls": "3.1.1",
|
|
67
67
|
"colors": "1.4.0",
|
|
68
|
-
"express": "4.18.
|
|
69
|
-
"husky": "8.0.
|
|
70
|
-
"mocha": "10.
|
|
68
|
+
"express": "4.18.2",
|
|
69
|
+
"husky": "8.0.3",
|
|
70
|
+
"mocha": "10.2.0",
|
|
71
71
|
"nyc": "15.1.0",
|
|
72
|
-
"socket.io": "4.
|
|
73
|
-
"socket.io-client": "4.
|
|
74
|
-
"typescript": "4.
|
|
75
|
-
"ws": "8.
|
|
72
|
+
"socket.io": "4.6.1",
|
|
73
|
+
"socket.io-client": "4.6.1",
|
|
74
|
+
"typescript": "4.9.5",
|
|
75
|
+
"ws": "8.12.1"
|
|
76
76
|
},
|
|
77
77
|
"homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
|
|
78
78
|
"engines": {
|