node-pluginsmanager-plugin 7.1.0 → 7.3.0

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,9 +1,13 @@
1
1
  "use strict";
2
- // deps
2
+ /*
3
+ eslint-disable @typescript-eslint/no-base-to-string
4
+ */
5
+ // => @typescript-eslint/no-base-to-string is disabled to allow strinfication of unknown errors
3
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
8
  };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ // deps
7
11
  // externals
8
12
  const express_openapi_validate_1 = require("express-openapi-validate");
9
13
  // locals
@@ -73,7 +77,7 @@ class Mediator extends DescriptorUser_1.default {
73
77
  }
74
78
  return reject(new Error(err));
75
79
  }
76
- return reject(new Error(String(err)));
80
+ return reject(new Error(String(err))); // unknown err type
77
81
  });
78
82
  });
79
83
  }).catch((err) => {
@@ -27,10 +27,8 @@ const extractMime_1 = __importDefault(require("../utils/request/extractMime"));
27
27
  const send_1 = __importDefault(require("../utils/send"));
28
28
  const cleanSendedError_1 = __importDefault(require("../utils/cleanSendedError"));
29
29
  const MediatorUser_1 = __importDefault(require("./MediatorUser"));
30
- const UnauthorizedError_1 = __importDefault(require("./errors/UnauthorizedError"));
31
- const NotFoundError_1 = __importDefault(require("./errors/NotFoundError"));
32
- const LockedError_1 = __importDefault(require("./errors/LockedError"));
33
30
  const serverCodes_1 = __importDefault(require("../utils/serverCodes"));
31
+ const formateError_1 = __importDefault(require("../utils/server/formateError"));
34
32
  const getServerTypeFromServer_1 = __importDefault(require("../utils/server/getServerTypeFromServer"));
35
33
  const getSocketIOVersionFromServer_1 = __importDefault(require("../utils/server/getSocketIOVersionFromServer"));
36
34
  // consts
@@ -416,104 +414,19 @@ class Server extends MediatorUser_1.default {
416
414
  }).then((response) => {
417
415
  return this._checkResponse ? this._Mediator.checkResponse(operationId, response) : Promise.resolve();
418
416
  }).catch((err) => {
419
- return Promise.resolve().then(() => {
420
- if (err instanceof ReferenceError) {
421
- const result = JSON.stringify({
422
- "code": "MISSING_PARAMETER",
423
- "message": (0, cleanSendedError_1.default)(err)
424
- });
425
- this._log("error", "<= [" + req.validatedIp + "] " + result);
426
- return (0, send_1.default)(req, res, serverCodes_1.default.MISSING_PARAMETER, result, {
427
- "apiVersion": apiVersion,
428
- "cors": this._cors,
429
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.MISSING_PARAMETER, responses)
430
- });
431
- }
432
- else if (err instanceof TypeError) {
433
- const result = JSON.stringify({
434
- "code": "WRONG_TYPE_PARAMETER",
435
- "message": (0, cleanSendedError_1.default)(err)
436
- });
437
- this._log("error", "<= [" + req.validatedIp + "] " + result);
438
- return (0, send_1.default)(req, res, serverCodes_1.default.WRONG_TYPE_PARAMETER, result, {
439
- "apiVersion": apiVersion,
440
- "cors": this._cors,
441
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.WRONG_TYPE_PARAMETER, responses)
442
- });
443
- }
444
- else if (err instanceof RangeError) {
445
- const result = JSON.stringify({
446
- "code": "EMPTY_OR_RANGE_OR_ENUM_PARAMETER",
447
- "message": (0, cleanSendedError_1.default)(err)
448
- });
449
- this._log("error", "<= [" + req.validatedIp + "] " + result);
450
- return (0, send_1.default)(req, res, serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER, result, {
451
- "apiVersion": apiVersion,
452
- "cors": this._cors,
453
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER, responses)
454
- });
455
- }
456
- else if (err instanceof SyntaxError) {
457
- const result = JSON.stringify({
458
- "code": "JSON_PARSE",
459
- "message": (0, cleanSendedError_1.default)(err)
460
- });
461
- this._log("error", "<= [" + req.validatedIp + "] " + result);
462
- return (0, send_1.default)(req, res, serverCodes_1.default.JSON_PARSE, result, {
463
- "apiVersion": apiVersion,
464
- "cors": this._cors,
465
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.JSON_PARSE, responses)
466
- });
467
- }
468
- else if (err instanceof UnauthorizedError_1.default) {
469
- const result = JSON.stringify({
470
- "code": "UNAUTHORIZED",
471
- "message": (0, cleanSendedError_1.default)(err)
472
- });
473
- this._log("error", "<= [" + req.validatedIp + "] " + result);
474
- return (0, send_1.default)(req, res, serverCodes_1.default.UNAUTHORIZED, result, {
475
- "apiVersion": apiVersion,
476
- "cors": this._cors,
477
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.UNAUTHORIZED, responses)
478
- });
479
- }
480
- else if (err instanceof NotFoundError_1.default) {
481
- const result = JSON.stringify({
482
- "code": "NOT_FOUND",
483
- "message": (0, cleanSendedError_1.default)(err)
484
- });
485
- this._log("error", "<= [" + req.validatedIp + "] " + result);
486
- return (0, send_1.default)(req, res, serverCodes_1.default.NOT_FOUND, result, {
487
- "apiVersion": apiVersion,
488
- "cors": this._cors,
489
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.NOT_FOUND, responses)
490
- });
491
- }
492
- else if (err instanceof LockedError_1.default) {
493
- const result = JSON.stringify({
494
- "code": "LOCKED",
495
- "message": (0, cleanSendedError_1.default)(err)
496
- });
497
- this._log("error", "<= [" + req.validatedIp + "] " + result);
498
- return (0, send_1.default)(req, res, serverCodes_1.default.LOCKED, result, {
499
- "apiVersion": apiVersion,
500
- "cors": this._cors,
501
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.LOCKED, responses)
502
- });
503
- }
504
- else {
505
- this._log("error", err);
506
- const result = JSON.stringify({
507
- "code": "INTERNAL_SERVER_ERROR",
508
- "message": (0, cleanSendedError_1.default)(err)
509
- });
510
- this._log("error", "<= [" + req.validatedIp + "] " + result);
511
- return (0, send_1.default)(req, res, serverCodes_1.default.INTERNAL_SERVER_ERROR, result, {
512
- "apiVersion": apiVersion,
513
- "cors": this._cors,
514
- "mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.INTERNAL_SERVER_ERROR, responses)
515
- });
516
- }
417
+ const formattedError = (0, formateError_1.default)(err);
418
+ const result = JSON.stringify({
419
+ "code": formattedError.code,
420
+ "message": formattedError.message
421
+ });
422
+ if (formattedError.httpCode === serverCodes_1.default.INTERNAL_SERVER_ERROR) {
423
+ this._log("error", err);
424
+ }
425
+ this._log("error", "<= [" + req.validatedIp + "] " + result);
426
+ return (0, send_1.default)(req, res, formattedError.httpCode, result, {
427
+ "apiVersion": apiVersion,
428
+ "cors": this._cors,
429
+ "mime": (0, extractMime_1.default)(contentType, formattedError.httpCode, responses)
517
430
  // still check response for errors
518
431
  }).then((response) => {
519
432
  return this._checkResponse ? this._Mediator.checkResponse(operationId, response) : Promise.resolve();
package/lib/cjs/main.cjs CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LockedError = exports.NotFoundError = exports.UnauthorizedError = exports.Server = exports.Orchestrator = exports.MediatorUser = exports.Mediator = exports.DescriptorUser = exports.checkNonEmptyStringSync = exports.checkNonEmptyString = exports.checkNonEmptyObjectSync = exports.checkNonEmptyObject = exports.checkNonEmptyNumberSync = exports.checkNonEmptyNumber = exports.checkIntegerSync = exports.checkInteger = exports.checkStringSync = exports.checkString = exports.checkObjectSync = exports.checkObject = exports.checkNumberSync = exports.checkNumber = exports.checkFunctionSync = exports.checkFunction = exports.checkExistsSync = exports.checkExists = void 0;
7
+ exports.formateError = exports.LockedError = exports.NotFoundError = exports.UnauthorizedError = exports.Server = exports.Orchestrator = exports.MediatorUser = exports.Mediator = exports.DescriptorUser = exports.checkNonEmptyStringSync = exports.checkNonEmptyString = exports.checkNonEmptyObjectSync = exports.checkNonEmptyObject = exports.checkNonEmptyNumberSync = exports.checkNonEmptyNumber = exports.checkIntegerSync = exports.checkInteger = exports.checkStringSync = exports.checkString = exports.checkObjectSync = exports.checkObject = exports.checkNumberSync = exports.checkNumber = exports.checkFunctionSync = exports.checkFunction = exports.checkExistsSync = exports.checkExists = void 0;
8
8
  // undefined
9
9
  const checkExists_1 = require("./checkers/ReferenceError/checkExists");
10
10
  Object.defineProperty(exports, "checkExists", { enumerable: true, get: function () { return checkExists_1.checkExists; } });
@@ -53,3 +53,5 @@ const NotFoundError_1 = __importDefault(require("./components/errors/NotFoundErr
53
53
  exports.NotFoundError = NotFoundError_1.default;
54
54
  const LockedError_1 = __importDefault(require("./components/errors/LockedError"));
55
55
  exports.LockedError = LockedError_1.default;
56
+ const formateError_1 = __importDefault(require("./utils/server/formateError"));
57
+ exports.formateError = formateError_1.default;
@@ -16,5 +16,6 @@ import Server, { type iClient } from "./components/Server";
16
16
  import UnauthorizedError from "./components/errors/UnauthorizedError";
17
17
  import NotFoundError from "./components/errors/NotFoundError";
18
18
  import LockedError from "./components/errors/LockedError";
19
+ import formateError, { type iFormattedError } from "./utils/server/formateError";
19
20
  export type { tLogType, tLogger, iEventsMinimal, iUrlAllowedParameters, iClient };
20
- export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError };
21
+ export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError, formateError, type iFormattedError };
@@ -0,0 +1,6 @@
1
+ export interface iFormattedError {
2
+ "httpCode": number;
3
+ "code": string;
4
+ "message": string;
5
+ }
6
+ export default function formateError(err: Error): iFormattedError;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ // deps
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.default = formateError;
8
+ // locals
9
+ const LockedError_1 = __importDefault(require("../../components/errors/LockedError"));
10
+ const NotFoundError_1 = __importDefault(require("../../components/errors/NotFoundError"));
11
+ const UnauthorizedError_1 = __importDefault(require("../../components/errors/UnauthorizedError"));
12
+ const cleanSendedError_1 = __importDefault(require("../cleanSendedError"));
13
+ const serverCodes_1 = __importDefault(require("../serverCodes"));
14
+ // module
15
+ function formateError(err) {
16
+ if (err instanceof ReferenceError) {
17
+ return {
18
+ "httpCode": serverCodes_1.default.MISSING_PARAMETER,
19
+ "code": "MISSING_PARAMETER",
20
+ "message": (0, cleanSendedError_1.default)(err)
21
+ };
22
+ }
23
+ else if (err instanceof TypeError) {
24
+ return {
25
+ "httpCode": serverCodes_1.default.WRONG_TYPE_PARAMETER,
26
+ "code": "WRONG_TYPE_PARAMETER",
27
+ "message": (0, cleanSendedError_1.default)(err)
28
+ };
29
+ }
30
+ else if (err instanceof RangeError) {
31
+ return {
32
+ "httpCode": serverCodes_1.default.EMPTY_OR_RANGE_OR_ENUM_PARAMETER,
33
+ "code": "EMPTY_OR_RANGE_OR_ENUM_PARAMETER",
34
+ "message": (0, cleanSendedError_1.default)(err)
35
+ };
36
+ }
37
+ else if (err instanceof SyntaxError) {
38
+ return {
39
+ "httpCode": serverCodes_1.default.JSON_PARSE,
40
+ "code": "JSON_PARSE",
41
+ "message": (0, cleanSendedError_1.default)(err)
42
+ };
43
+ }
44
+ else if (err instanceof UnauthorizedError_1.default) {
45
+ return {
46
+ "httpCode": serverCodes_1.default.UNAUTHORIZED,
47
+ "code": "UNAUTHORIZED",
48
+ "message": (0, cleanSendedError_1.default)(err)
49
+ };
50
+ }
51
+ else if (err instanceof NotFoundError_1.default) {
52
+ return {
53
+ "httpCode": serverCodes_1.default.NOT_FOUND,
54
+ "code": "NOT_FOUND",
55
+ "message": (0, cleanSendedError_1.default)(err)
56
+ };
57
+ }
58
+ else if (err instanceof LockedError_1.default) {
59
+ return {
60
+ "httpCode": serverCodes_1.default.LOCKED,
61
+ "code": "LOCKED",
62
+ "message": (0, cleanSendedError_1.default)(err)
63
+ };
64
+ }
65
+ return {
66
+ "httpCode": serverCodes_1.default.INTERNAL_SERVER_ERROR,
67
+ "code": "INTERNAL_SERVER_ERROR",
68
+ "message": (0, cleanSendedError_1.default)(err)
69
+ };
70
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager-plugin",
4
- "version": "7.1.0",
4
+ "version": "7.3.0",
5
5
  "description": "An abstract parent plugin for node-pluginsmanager.",
6
6
 
7
7
  "type": "commonjs",
@@ -19,8 +19,6 @@
19
19
 
20
20
  "scripts": {
21
21
 
22
- "prepare": "npx husky || true",
23
-
24
22
  "lint-back": "npx eslint --config .eslintrc-back.js --ext .ts,.cts,.mts ./lib/src/**/*",
25
23
  "lint-tests": "npx eslint --config .eslintrc-tests.js --ext .js,.cjs,.mjs ./test/**/*",
26
24
  "lint": "npm run lint-back && npm run lint-tests",
@@ -31,12 +29,13 @@
31
29
  "build-back": "npm run clean-back && npx tsc --project ./tsconfig.json",
32
30
  "build": "npm run build-back",
33
31
 
32
+ "check-node-engine": "npx check-node-engine",
34
33
  "check-requires": "npx used-deps-analyzer ./package.json ./lib/src --no-dev --misscalled \"{ \\\"module\\\": \\\"@types/socket.io-v2\\\", \\\"call\\\": \\\"socket.io-v2\\\" }\"",
35
34
  "check-updates": "npx check-version-modules --no-fail-at-major --fail-at-minor --fail-at-patch",
36
35
  "unit-tests": "npx mocha",
37
36
  "unit-tests-local": "npx nyc --reporter=html --reporter=text mocha",
38
37
 
39
- "tests": "npm run lint && npm run check-requires && npm run check-updates && npm run build && npm run unit-tests-local"
38
+ "tests": "npm run lint && npm run check-node-engine && npm run check-requires && npm run check-updates && npm run build && npm run unit-tests-local"
40
39
 
41
40
  },
42
41
 
@@ -45,7 +44,7 @@
45
44
  "lib/@types"
46
45
  ],
47
46
  "engines": {
48
- "node": ">=22.22.0"
47
+ "node": ">=22.22.3"
49
48
  },
50
49
 
51
50
  "dependencies": {
@@ -55,31 +54,25 @@
55
54
  },
56
55
  "devDependencies": {
57
56
  "@types/express": "5.0.6",
58
- "@types/node": "25.6.0",
57
+ "@types/node": "25.9.1",
59
58
  "@types/socket.io": "3.0.2",
60
59
  "@types/uniqid": "5.3.4",
61
60
  "@types/ws": "8.18.1",
62
- "check-version-modules": "2.3.0",
61
+ "check-node-engine": "1.1.0",
62
+ "check-version-modules": "2.5.0",
63
63
  "colors": "1.4.0",
64
64
  "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
65
65
  "express": "5.2.1",
66
66
  "husky": "9.1.7",
67
- "mocha": "11.7.5",
67
+ "mocha": "11.7.6",
68
68
  "nyc": "18.0.0",
69
69
  "openapi-types": "12.1.3",
70
70
  "rimraf": "6.1.3",
71
71
  "socket.io": "4.8.3",
72
72
  "socket.io-client": "4.8.3",
73
73
  "typescript": "5.9.3",
74
- "used-deps-analyzer": "0.3.0",
75
- "ws": "8.20.0"
76
- },
77
-
78
- "husky": {
79
- "hooks": {
80
- "pre-commit": "npm run lint",
81
- "pre-push": "npm run build && npm run unit-tests-local"
82
- }
74
+ "used-deps-analyzer": "0.4.0",
75
+ "ws": "8.21.0"
83
76
  },
84
77
 
85
78
  "keywords": [