node-pluginsmanager-plugin 5.0.7 → 5.0.10

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,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import Events from "events";
2
+ import { EventEmitter } from "events";
3
3
  import { OpenApiDocument } from "express-openapi-validate";
4
4
  export declare type tLogType = "data" | "debug" | "log" | "info" | "success" | "warning" | "error";
5
5
  export declare type tLogger = (type: tLogType, message: string | Error, bold?: boolean, pluginName?: string) => void;
@@ -8,7 +8,7 @@ export interface iDescriptorUserOptions {
8
8
  "descriptor"?: OpenApiDocument;
9
9
  "logger"?: tLogger;
10
10
  }
11
- export default class DescriptorUser extends Events {
11
+ export default class DescriptorUser extends EventEmitter {
12
12
  initialized: boolean;
13
13
  protected _descriptorValidated: boolean;
14
14
  protected _externalRessourcesDirectory: string;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  // deps
7
4
  // natives
8
- const events_1 = __importDefault(require("events"));
5
+ const events_1 = require("events");
9
6
  // locals
10
7
  const checkObject_1 = require("../checkers/TypeError/checkObject");
11
8
  const checkNonEmptyObject_1 = require("../checkers/RangeError/checkNonEmptyObject");
@@ -16,7 +13,7 @@ const LOG_TYPES_ALLOWED = ["log", "info", "success", "warning", "error"];
16
13
  // module
17
14
  // Please note the fact that "_initWorkSpace" and "_releaseWorkSpace" method MUST be re-writted in Mediator class, and not in MediatorUser childs.
18
15
  // Please note the fact that "init" and "release" method MUST NOT be re-writted. Each child has is own init logic.
19
- class DescriptorUser extends events_1.default {
16
+ class DescriptorUser extends events_1.EventEmitter {
20
17
  // constructor
21
18
  constructor(options) {
22
19
  super();
@@ -2,10 +2,18 @@ import { OpenApiValidator } from "express-openapi-validate";
2
2
  import { iServerResponse } from "./Server";
3
3
  import DescriptorUser, { iDescriptorUserOptions } from "./DescriptorUser";
4
4
  export interface iUrlParameters {
5
- "path": object;
6
- "query": object;
7
- "headers": object;
8
- "cookies": object;
5
+ "path": {
6
+ [key: string]: any;
7
+ };
8
+ "query": {
9
+ [key: string]: any;
10
+ };
11
+ "headers": {
12
+ [key: string]: any;
13
+ };
14
+ "cookies": {
15
+ [key: string]: any;
16
+ };
9
17
  }
10
18
  export interface iBodyParameters {
11
19
  [key: string]: any;
@@ -6,7 +6,7 @@ export interface iMediatorUserOptions extends iDescriptorUserOptions {
6
6
  export default class MediatorUser extends DescriptorUser {
7
7
  protected _Mediator: Mediator | null;
8
8
  constructor(options: iMediatorUserOptions);
9
- _initWorkSpace(...data: any): Promise<void>;
10
- _releaseWorkSpace(...data: any): Promise<void>;
9
+ protected _initWorkSpace(...data: any): Promise<void>;
10
+ protected _releaseWorkSpace(...data: any): Promise<void>;
11
11
  checkMediator(): Promise<void>;
12
12
  }
@@ -280,7 +280,16 @@ class Orchestrator extends MediatorUser_1.default {
280
280
  // load
281
281
  return new Promise((resolve, reject) => {
282
282
  try {
283
- resolve(require(this._mediatorFile));
283
+ const val = require(this._mediatorFile);
284
+ if ("object" === typeof val && "function" === typeof val.default) {
285
+ resolve(val.default);
286
+ }
287
+ else if ("function" === typeof val) {
288
+ resolve(val);
289
+ }
290
+ else {
291
+ reject(new Error("Mediator file loaded (\"" + this._mediatorFile + "\") does not contain a valid Mediator"));
292
+ }
284
293
  }
285
294
  catch (e) {
286
295
  reject(e);
@@ -306,7 +315,16 @@ class Orchestrator extends MediatorUser_1.default {
306
315
  // load
307
316
  return new Promise((resolve, reject) => {
308
317
  try {
309
- resolve(require(this._serverFile));
318
+ const val = require(this._serverFile);
319
+ if ("object" === typeof val && "function" === typeof val.default) {
320
+ resolve(val.default);
321
+ }
322
+ else if ("function" === typeof val) {
323
+ resolve(val);
324
+ }
325
+ else {
326
+ reject(new Error("Server file loaded (\"" + this._serverFile + "\") does not contain a valid Server"));
327
+ }
310
328
  }
311
329
  catch (e) {
312
330
  reject(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-pluginsmanager-plugin",
3
- "version": "5.0.7",
3
+ "version": "5.0.10",
4
4
  "description": "An abstract parent plugin for node-pluginsmanager",
5
5
 
6
6
  "type": "commonjs",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/express": "4.17.13",
61
- "@types/node": "18.0.1",
61
+ "@types/node": "18.0.4",
62
62
  "@types/socket.io": "3.0.2",
63
63
  "@types/uniqid": "5.3.2",
64
64
  "@types/ws": "8.5.3",