node-pluginsmanager-plugin 6.4.2 → 6.4.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/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright (c) 2024, Sébastien Vidal
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any
4
- purpose with or without fee is hereby granted, provided that the above
5
- copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ Copyright (c) 2024, Sébastien Vidal
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,48 +1,48 @@
1
- # node-pluginsmanager-plugin
2
- An abstract parent plugin for node-pluginsmanager
3
-
4
- [![Build status](https://api.travis-ci.org/Psychopoulet/node-pluginsmanager-plugin.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
5
- [![Coverage status](https://coveralls.io/repos/github/Psychopoulet/node-pluginsmanager-plugin/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
6
- [![Dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
7
- [![Dev dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/dev-status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
8
- [![Issues](https://img.shields.io/github/issues/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
9
- [![Pull requests](https://img.shields.io/github/issues-pr/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/pulls)
10
-
11
- ## Installation
12
-
13
- ```bash
14
- $ npm install node-pluginsmanager-plugin
15
- ```
16
-
17
- ## Features
18
-
19
- * inheritable parent for node-pluginsmanager's plugins
20
- * proper architecture for simple plugin creation
21
- * heritable classes for each usage
22
- * multi-files support
23
-
24
- ## Architecture
25
-
26
- ![Functional](https://github.com/Psychopoulet/node-pluginsmanager-plugin/raw/master/documentation/pictures/functional.jpg)
27
-
28
- [=> See doc](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/architecture.md)
29
-
30
- ### Resume
31
-
32
- * [Descriptor](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Descriptor.md) : OpenAPI (v3) description for Server and Mediator endpoints (this is NOT a js file, but a json/xaml/whatever OpenAPI file)
33
- * [Mediator](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Mediator.md) : contains the plugin's logic (communication with targeted device/api/whatever)
34
- * [Server](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Server.md) : expose plugin's roots to external use (API)
35
- * [Orchestrator](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Orchestrator.md) : plugin's data (extracted from plugin's package.json) and Descriptor, Mediator & Server initializer
36
-
37
- ## Tests
38
-
39
- ```bash
40
- $ git clone git://github.com/Psychopoulet/node-pluginsmanager-plugin.git
41
- $ cd ./node-pluginsmanager-plugin
42
- $ npm install
43
- $ npm run-script tests
44
- ```
45
-
46
- ## License
47
-
48
- [ISC](LICENSE)
1
+ # node-pluginsmanager-plugin
2
+ An abstract parent plugin for node-pluginsmanager
3
+
4
+ [![Build status](https://api.travis-ci.org/Psychopoulet/node-pluginsmanager-plugin.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
5
+ [![Coverage status](https://coveralls.io/repos/github/Psychopoulet/node-pluginsmanager-plugin/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
6
+ [![Dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
7
+ [![Dev dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/dev-status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
8
+ [![Issues](https://img.shields.io/github/issues/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
9
+ [![Pull requests](https://img.shields.io/github/issues-pr/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/pulls)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ $ npm install node-pluginsmanager-plugin
15
+ ```
16
+
17
+ ## Features
18
+
19
+ * inheritable parent for node-pluginsmanager's plugins
20
+ * proper architecture for simple plugin creation
21
+ * heritable classes for each usage
22
+ * multi-files support
23
+
24
+ ## Architecture
25
+
26
+ ![Functional](https://github.com/Psychopoulet/node-pluginsmanager-plugin/raw/master/documentation/pictures/functional.jpg)
27
+
28
+ [=> See doc](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/architecture.md)
29
+
30
+ ### Resume
31
+
32
+ * [Descriptor](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Descriptor.md) : OpenAPI (v3) description for Server and Mediator endpoints (this is NOT a js file, but a json/xaml/whatever OpenAPI file)
33
+ * [Mediator](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Mediator.md) : contains the plugin's logic (communication with targeted device/api/whatever)
34
+ * [Server](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Server.md) : expose plugin's roots to external use (API)
35
+ * [Orchestrator](https://github.com/Psychopoulet/node-pluginsmanager-plugin/tree/master/documentation/Orchestrator.md) : plugin's data (extracted from plugin's package.json) and Descriptor, Mediator & Server initializer
36
+
37
+ ## Tests
38
+
39
+ ```bash
40
+ $ git clone git://github.com/Psychopoulet/node-pluginsmanager-plugin.git
41
+ $ cd ./node-pluginsmanager-plugin
42
+ $ npm install
43
+ $ npm run-script tests
44
+ ```
45
+
46
+ ## License
47
+
48
+ [ISC](LICENSE)
@@ -102,7 +102,7 @@ class Mediator extends DescriptorUser_1.default {
102
102
  return resolve();
103
103
  }
104
104
  // validator cannot correctly check pure boolean return
105
- else if ("undefined" !== typeof res.body && ["true", "false"].includes(res.body)) {
105
+ else if ("undefined" !== typeof res.body && ["true", "false", true, false].includes(res.body)) {
106
106
  return resolve();
107
107
  }
108
108
  else {
@@ -38,7 +38,7 @@ export default class Server extends MediatorUser {
38
38
  enableCheckResponse(): this;
39
39
  disableCors(): this;
40
40
  enableCors(): this;
41
- appMiddleware(req: iIncomingMessage, res: iServerResponse, next: () => void): void;
41
+ appMiddleware(req: iIncomingMessage, res: iServerResponse, next: (err?: Error) => void): void;
42
42
  socketMiddleware(socketServer: WebSocketServer | SocketIOServer): void;
43
43
  push(command: string, data?: any, log?: boolean): this;
44
44
  getClients(): iClient[];
@@ -115,27 +115,37 @@ class Server extends MediatorUser_1.default {
115
115
  const { pathname, query } = (0, node_url_1.parse)(req.url, true);
116
116
  req.method = req.method ? req.method.toLowerCase() : "get";
117
117
  req.pattern = null === (0, checkNonEmptyString_1.checkNonEmptyStringSync)("pattern", req.pattern) ? req.pattern : (0, extractPattern_1.default)(this._Descriptor.paths, pathname, req.method);
118
- if (!req.pattern) {
118
+ if (0 >= req.pattern.length) {
119
119
  return next();
120
120
  }
121
- req.validatedIp = null === (0, checkNonEmptyString_1.checkNonEmptyStringSync)("ip", req.validatedIp) ? req.validatedIp : (0, extractIp_1.default)(req);
122
- // url
123
- req.params = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("params", req.params) ? req.params : (0, extractParams_1.default)(req.pattern, pathname);
124
- req.query = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("query", req.query) ? req.query : query !== null && query !== void 0 ? query : {};
125
- if (null !== (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("headers", req.headers)) {
126
- req.headers = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("header", req.header) ? req.header : {};
127
- }
128
- if (null !== (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("cookies", req.cookies)) {
129
- req.cookies = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("header", req.cookie) ? req.cookie : (0, extractCookies_1.default)(req);
130
- }
131
- // ensure content length formate
132
- if ("undefined" === typeof req.headers["content-length"]) {
133
- req.headers["content-length"] = 0;
121
+ // extract specific data
122
+ try {
123
+ // workaround for express 5
124
+ if (Object.getPrototypeOf(req).app) {
125
+ Object.defineProperty(req, "query", Object.assign(Object.assign({}, Object.getOwnPropertyDescriptor(req, "query")), { "value": req.query, "writable": true }));
126
+ }
127
+ req.validatedIp = null === (0, checkNonEmptyString_1.checkNonEmptyStringSync)("ip", req.validatedIp) ? req.validatedIp : (0, extractIp_1.default)(req);
128
+ // url
129
+ req.params = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("params", req.params) ? req.params : (0, extractParams_1.default)(req.pattern, pathname);
130
+ req.query = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("query", req.query) ? req.query : query !== null && query !== void 0 ? query : {};
131
+ if (null !== (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("headers", req.headers)) {
132
+ req.headers = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("header", req.header) ? req.header : {};
133
+ }
134
+ if (null !== (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("cookies", req.cookies)) {
135
+ req.cookies = null === (0, checkNonEmptyObject_1.checkNonEmptyObjectSync)("header", req.cookie) ? req.cookie : (0, extractCookies_1.default)(req);
136
+ }
137
+ // ensure content length formate
138
+ if ("undefined" === typeof req.headers["content-length"]) {
139
+ req.headers["content-length"] = 0;
140
+ }
141
+ else if ("string" === typeof req.headers["content-length"]) {
142
+ req.headers["content-length"] = parseInt(req.headers["content-length"], 10);
143
+ }
134
144
  }
135
- else if ("string" === typeof req.headers["content-length"]) {
136
- req.headers["content-length"] = parseInt(req.headers["content-length"], 10);
145
+ catch (e) {
146
+ return next(e);
137
147
  }
138
- if (!req.pattern || !this._Descriptor.paths[req.pattern] || !this._Descriptor.paths[req.pattern][req.method]) {
148
+ if (!this._Descriptor.paths[req.pattern] || !this._Descriptor.paths[req.pattern][req.method]) {
139
149
  return next();
140
150
  }
141
151
  const { operationId } = this._Descriptor.paths[req.pattern][req.method];
package/package.json CHANGED
@@ -1,97 +1,97 @@
1
- {
2
-
3
- "name": "node-pluginsmanager-plugin",
4
- "version": "6.4.2",
5
- "description": "An abstract parent plugin for node-pluginsmanager",
6
-
7
- "type": "commonjs",
8
- "typings": "./lib/cjs/main.d.cts",
9
- "main": "./lib/cjs/main.cjs",
10
-
11
- "exports": {
12
- ".": {
13
- "require": {
14
- "types": "./lib/cjs/main.d.cts",
15
- "default": "./lib/cjs/main.cjs"
16
- }
17
- }
18
- },
19
-
20
- "scripts": {
21
-
22
- "prepare": "npx husky",
23
-
24
- "clean": "npx rimraf lib/cjs",
25
- "build": "npm run-script clean && npx tsc --project \"./tsconfig.json\"",
26
-
27
- "lint": "npx eslint --config .eslintrc-src.js --ext .cts,.ts ./lib/src/**/* && npx eslint --config .eslintrc-tests.js ./bin/*.js ./test/**/*.js",
28
- "check-requires": "npx used-deps-analyzer \"./package.json\" \"./lib/src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
29
- "check-updates": "npx check-version-modules",
30
- "unit-tests": "npm run-script build && npx nyc --reporter=html --reporter=text mocha",
31
-
32
- "tests": "npm run-script lint && npm run-script check-requires && npm run-script check-updates && npm run-script unit-tests"
33
-
34
- },
35
-
36
- "files": [
37
- "/bin",
38
- "/lib/cjs",
39
- "/public"
40
- ],
41
- "engines": {
42
- "node": ">=16.0.0"
43
- },
44
-
45
- "dependencies": {
46
- "@apidevtools/swagger-parser": "10.1.1",
47
- "express-openapi-validate": "0.6.1",
48
- "uniqid": "5.4.0"
49
- },
50
- "devDependencies": {
51
- "@types/express": "4.17.21",
52
- "@types/node": "22.10.10",
53
- "@types/socket.io": "3.0.2",
54
- "@types/uniqid": "5.3.4",
55
- "@types/ws": "8.5.14",
56
- "check-version-modules": "2.1.3",
57
- "colors": "1.4.0",
58
- "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
59
- "express": "4.21.2",
60
- "husky": "9.1.7",
61
- "mocha": "11.1.0",
62
- "nyc": "17.1.0",
63
- "openapi-types": "12.1.3",
64
- "rimraf": "6.0.1",
65
- "socket.io": "4.8.1",
66
- "socket.io-client": "4.8.1",
67
- "typescript": "5.7.3",
68
- "used-deps-analyzer": "0.1.8",
69
- "ws": "8.18.0"
70
- },
71
- "optionalDependencies": {},
72
-
73
- "husky": {
74
- "hooks": {
75
- "pre-commit": "npm run-script lint",
76
- "pre-push": "npm run-script unit-tests",
77
- "pre-receive": "npm run-script tests"
78
- }
79
- },
80
- "keywords": [
81
- "plugin",
82
- "manage",
83
- "gestion"
84
- ],
85
- "author": "Sébastien VIDAL",
86
- "license": "ISC",
87
-
88
- "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
89
- "repository": {
90
- "type": "git",
91
- "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
92
- },
93
- "bugs": {
94
- "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
95
- }
96
-
97
- }
1
+ {
2
+
3
+ "name": "node-pluginsmanager-plugin",
4
+ "version": "6.4.4",
5
+ "description": "An abstract parent plugin for node-pluginsmanager",
6
+
7
+ "type": "commonjs",
8
+ "typings": "./lib/cjs/main.d.cts",
9
+ "main": "./lib/cjs/main.cjs",
10
+
11
+ "exports": {
12
+ ".": {
13
+ "require": {
14
+ "types": "./lib/cjs/main.d.cts",
15
+ "default": "./lib/cjs/main.cjs"
16
+ }
17
+ }
18
+ },
19
+
20
+ "scripts": {
21
+
22
+ "prepare": "npx husky",
23
+
24
+ "clean": "npx rimraf lib/cjs",
25
+ "build": "npm run-script clean && npx tsc --project \"./tsconfig.json\"",
26
+
27
+ "lint": "npx eslint --config .eslintrc-src.js --ext .cts,.ts ./lib/src/**/* && npx eslint --config .eslintrc-tests.js ./bin/*.js ./test/**/*.js",
28
+ "check-requires": "npx used-deps-analyzer \"./package.json\" \"./lib/src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
29
+ "check-updates": "npx check-version-modules",
30
+ "unit-tests": "npm run-script build && npx nyc --reporter=html --reporter=text mocha",
31
+
32
+ "tests": "npm run-script lint && npm run-script check-requires && npm run-script check-updates && npm run-script unit-tests"
33
+
34
+ },
35
+
36
+ "files": [
37
+ "/bin",
38
+ "/lib/cjs",
39
+ "/public"
40
+ ],
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ },
44
+
45
+ "dependencies": {
46
+ "@apidevtools/swagger-parser": "12.0.0",
47
+ "express-openapi-validate": "0.6.1",
48
+ "uniqid": "5.4.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/express": "5.0.3",
52
+ "@types/node": "24.3.0",
53
+ "@types/socket.io": "3.0.2",
54
+ "@types/uniqid": "5.3.4",
55
+ "@types/ws": "8.18.1",
56
+ "check-version-modules": "2.1.3",
57
+ "colors": "1.4.0",
58
+ "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
59
+ "express": "5.1.0",
60
+ "husky": "9.1.7",
61
+ "mocha": "11.7.1",
62
+ "nyc": "17.1.0",
63
+ "openapi-types": "12.1.3",
64
+ "rimraf": "6.0.1",
65
+ "socket.io": "4.8.1",
66
+ "socket.io-client": "4.8.1",
67
+ "typescript": "5.9.2",
68
+ "used-deps-analyzer": "0.1.8",
69
+ "ws": "8.18.3"
70
+ },
71
+ "optionalDependencies": {},
72
+
73
+ "husky": {
74
+ "hooks": {
75
+ "pre-commit": "npm run-script lint",
76
+ "pre-push": "npm run-script unit-tests",
77
+ "pre-receive": "npm run-script tests"
78
+ }
79
+ },
80
+ "keywords": [
81
+ "plugin",
82
+ "manage",
83
+ "gestion"
84
+ ],
85
+ "author": "Sébastien VIDAL",
86
+ "license": "ISC",
87
+
88
+ "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
89
+ "repository": {
90
+ "type": "git",
91
+ "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
92
+ },
93
+ "bugs": {
94
+ "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
95
+ }
96
+
97
+ }