node-pluginsmanager-plugin 5.0.11 → 5.0.13

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 declare type tLogType = "data" | "debug" | "log" | "info" | "success" | "warning" | "error";
5
- export declare type tLogger = (type: tLogType, message: string | Error, bold?: boolean, pluginName?: string) => void;
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.forEach((s) => {
441
- result.push({
442
- "id": s.id,
443
- "status": s.connected ? "CONNECTED" : "DISCONNECTED"
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
- if (this._socketServer.sockets.sockets.has(clientId)) {
486
- const socket = this._socketServer.sockets.sockets.get(clientId);
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);
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // module
4
4
  function cleanSendedError(data) {
5
5
  if ("object" === typeof data) {
6
- if (data instanceof Error) {
6
+ if (null === data) {
7
+ return data;
8
+ }
9
+ else if (data instanceof Error) {
7
10
  return data.message;
8
11
  }
9
12
  else {
@@ -1,5 +1,5 @@
1
1
  import { OpenApiDocument } from "express-openapi-validate";
2
- export declare type tMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
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.11",
3
+ "version": "5.0.13",
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.13",
61
- "@types/node": "18.0.6",
60
+ "@types/express": "4.17.17",
61
+ "@types/node": "18.15.1",
62
62
  "@types/socket.io": "3.0.2",
63
63
  "@types/uniqid": "5.3.2",
64
- "@types/ws": "8.5.3",
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.1",
69
- "husky": "8.0.1",
70
- "mocha": "10.0.0",
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.5.1",
73
- "socket.io-client": "4.5.1",
74
- "typescript": "4.7.4",
75
- "ws": "8.8.1"
72
+ "socket.io": "4.6.1",
73
+ "socket.io-client": "4.6.1",
74
+ "typescript": "4.9.5",
75
+ "ws": "8.13.0"
76
76
  },
77
77
  "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
78
78
  "engines": {