node-pluginsmanager-plugin 6.2.4 → 6.3.1
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 +13 -13
- package/README.md +48 -48
- package/lib/cjs/components/Mediator.js +1 -0
- package/lib/cjs/components/Server.js +27 -1
- package/lib/cjs/components/errors/LockedError.d.ts +2 -0
- package/lib/cjs/components/errors/LockedError.js +6 -0
- package/lib/cjs/components/errors/UnauthorizedError.d.ts +2 -0
- package/lib/cjs/components/errors/UnauthorizedError.js +6 -0
- package/lib/cjs/main.cjs +7 -3
- package/lib/cjs/main.d.cts +4 -2
- package/lib/cjs/utils/serverCodes.d.ts +2 -0
- package/lib/cjs/utils/serverCodes.js +2 -0
- package/package.json +1 -1
- /package/lib/cjs/components/{NotFoundError.d.ts → errors/NotFoundError.d.ts} +0 -0
- /package/lib/cjs/components/{NotFoundError.js → errors/NotFoundError.js} +0 -0
package/LICENSE
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Copyright (c) 2023, 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) 2023, 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
|
-
[](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
|
|
5
|
-
[](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
|
|
6
|
-
[](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
|
|
7
|
-
[](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
|
|
8
|
-
[](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
|
|
9
|
-
[](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
|
-

|
|
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
|
+
[](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
|
|
5
|
+
[](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
|
|
6
|
+
[](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
|
|
7
|
+
[](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
|
|
8
|
+
[](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
|
|
9
|
+
[](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
|
+

|
|
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)
|
|
@@ -24,7 +24,9 @@ const jsonParser_1 = __importDefault(require("../utils/jsonParser"));
|
|
|
24
24
|
const send_1 = __importDefault(require("../utils/send"));
|
|
25
25
|
const cleanSendedError_1 = __importDefault(require("../utils/cleanSendedError"));
|
|
26
26
|
const MediatorUser_1 = __importDefault(require("./MediatorUser"));
|
|
27
|
-
const
|
|
27
|
+
const UnauthorizedError_1 = __importDefault(require("./errors/UnauthorizedError"));
|
|
28
|
+
const NotFoundError_1 = __importDefault(require("./errors/NotFoundError"));
|
|
29
|
+
const LockedError_1 = __importDefault(require("./errors/LockedError"));
|
|
28
30
|
const serverCodes_1 = __importDefault(require("../utils/serverCodes"));
|
|
29
31
|
// consts
|
|
30
32
|
const WEBSOCKET_STATE_OPEN = 1;
|
|
@@ -409,6 +411,18 @@ class Server extends MediatorUser_1.default {
|
|
|
409
411
|
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.JSON_PARSE, responses)
|
|
410
412
|
});
|
|
411
413
|
}
|
|
414
|
+
else if (err instanceof UnauthorizedError_1.default) {
|
|
415
|
+
const result = JSON.stringify({
|
|
416
|
+
"code": "UNAUTHORIZED",
|
|
417
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
418
|
+
});
|
|
419
|
+
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
420
|
+
return (0, send_1.default)(req, res, serverCodes_1.default.UNAUTHORIZED, result, {
|
|
421
|
+
"apiVersion": apiVersion,
|
|
422
|
+
"cors": this._cors,
|
|
423
|
+
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.UNAUTHORIZED, responses)
|
|
424
|
+
});
|
|
425
|
+
}
|
|
412
426
|
else if (err instanceof NotFoundError_1.default) {
|
|
413
427
|
const result = JSON.stringify({
|
|
414
428
|
"code": "NOT_FOUND",
|
|
@@ -421,6 +435,18 @@ class Server extends MediatorUser_1.default {
|
|
|
421
435
|
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.NOT_FOUND, responses)
|
|
422
436
|
});
|
|
423
437
|
}
|
|
438
|
+
else if (err instanceof LockedError_1.default) {
|
|
439
|
+
const result = JSON.stringify({
|
|
440
|
+
"code": "LOCKED",
|
|
441
|
+
"message": (0, cleanSendedError_1.default)(err)
|
|
442
|
+
});
|
|
443
|
+
this._log("error", "<= [" + req.validatedIp + "] " + result);
|
|
444
|
+
return (0, send_1.default)(req, res, serverCodes_1.default.LOCKED, result, {
|
|
445
|
+
"apiVersion": apiVersion,
|
|
446
|
+
"cors": this._cors,
|
|
447
|
+
"mime": (0, extractMime_1.default)(contentType, serverCodes_1.default.LOCKED, responses)
|
|
448
|
+
});
|
|
449
|
+
}
|
|
424
450
|
else {
|
|
425
451
|
this._log("error", err);
|
|
426
452
|
const result = JSON.stringify({
|
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.
|
|
7
|
+
exports.LockedError = exports.NotFoundError = exports.UnauthorizedError = exports.Server = exports.Orchestrator = exports.MediatorUser = exports.Mediator = exports.DescriptorUser = exports.checkArrayLengthBetweenSync = exports.checkArrayLengthBetween = exports.checkArrayLengthSync = exports.checkArrayLength = exports.checkIntegerBetweenSync = exports.checkIntegerBetween = exports.checkStringLengthBetweenSync = exports.checkStringLengthBetween = exports.checkStringLengthSync = exports.checkStringLength = exports.checkObjectLengthBetweenSync = exports.checkObjectLengthBetween = exports.checkObjectLengthSync = exports.checkObjectLength = exports.checkNumberBetweenSync = exports.checkNumberBetween = exports.checkNonEmptyStringSync = exports.checkNonEmptyString = exports.checkNonEmptyObjectSync = exports.checkNonEmptyObject = exports.checkNonEmptyNumberSync = exports.checkNonEmptyNumber = exports.checkNonEmptyIntegerSync = exports.checkNonEmptyInteger = exports.checkNonEmptyArraySync = exports.checkNonEmptyArray = exports.checkIntegerSync = exports.checkInteger = exports.checkArraySync = exports.checkArray = exports.checkStringSync = exports.checkString = exports.checkObjectSync = exports.checkObject = exports.checkNumberSync = exports.checkNumber = exports.checkFunctionSync = exports.checkFunction = exports.checkBooleanSync = exports.checkBoolean = 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; } });
|
|
@@ -82,9 +82,13 @@ const Mediator_1 = __importDefault(require("./components/Mediator"));
|
|
|
82
82
|
exports.Mediator = Mediator_1.default;
|
|
83
83
|
const MediatorUser_1 = __importDefault(require("./components/MediatorUser"));
|
|
84
84
|
exports.MediatorUser = MediatorUser_1.default;
|
|
85
|
-
const NotFoundError_1 = __importDefault(require("./components/NotFoundError"));
|
|
86
|
-
exports.NotFoundError = NotFoundError_1.default;
|
|
87
85
|
const Orchestrator_1 = __importDefault(require("./components/Orchestrator"));
|
|
88
86
|
exports.Orchestrator = Orchestrator_1.default;
|
|
89
87
|
const Server_1 = __importDefault(require("./components/Server"));
|
|
90
88
|
exports.Server = Server_1.default;
|
|
89
|
+
const UnauthorizedError_1 = __importDefault(require("./components/errors/UnauthorizedError"));
|
|
90
|
+
exports.UnauthorizedError = UnauthorizedError_1.default;
|
|
91
|
+
const NotFoundError_1 = __importDefault(require("./components/errors/NotFoundError"));
|
|
92
|
+
exports.NotFoundError = NotFoundError_1.default;
|
|
93
|
+
const LockedError_1 = __importDefault(require("./components/errors/LockedError"));
|
|
94
|
+
exports.LockedError = LockedError_1.default;
|
package/lib/cjs/main.d.cts
CHANGED
|
@@ -23,8 +23,10 @@ export { checkExists, checkExistsSync, checkBoolean, checkBooleanSync, checkFunc
|
|
|
23
23
|
import DescriptorUser, { type iDescriptorUserOptions, type tLogType, type tLogger } from "./components/DescriptorUser";
|
|
24
24
|
import Mediator, { type iUrlParameters } from "./components/Mediator";
|
|
25
25
|
import MediatorUser, { type iMediatorUserOptions } from "./components/MediatorUser";
|
|
26
|
-
import NotFoundError from "./components/NotFoundError";
|
|
27
26
|
import Orchestrator, { type iOrchestratorOptions } from "./components/Orchestrator";
|
|
28
27
|
import Server, { type iClient, type iIncomingMessage, type iServerResponse } from "./components/Server";
|
|
28
|
+
import UnauthorizedError from "./components/errors/UnauthorizedError";
|
|
29
|
+
import NotFoundError from "./components/errors/NotFoundError";
|
|
30
|
+
import LockedError from "./components/errors/LockedError";
|
|
29
31
|
export type { tLogType, tLogger, iUrlParameters, iClient, iIncomingMessage, iServerResponse };
|
|
30
|
-
export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions,
|
|
32
|
+
export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError };
|
|
@@ -6,8 +6,10 @@ declare const _default: {
|
|
|
6
6
|
WRONG_TYPE_PARAMETER: number;
|
|
7
7
|
EMPTY_OR_RANGE_OR_ENUM_PARAMETER: number;
|
|
8
8
|
JSON_PARSE: number;
|
|
9
|
+
UNAUTHORIZED: number;
|
|
9
10
|
NOT_FOUND: number;
|
|
10
11
|
MISSING_HEADER: number;
|
|
12
|
+
LOCKED: number;
|
|
11
13
|
INTERNAL_SERVER_ERROR: number;
|
|
12
14
|
NOT_IMPLEMENTED: number;
|
|
13
15
|
};
|
|
@@ -8,8 +8,10 @@ exports.default = {
|
|
|
8
8
|
"WRONG_TYPE_PARAMETER": 400,
|
|
9
9
|
"EMPTY_OR_RANGE_OR_ENUM_PARAMETER": 400,
|
|
10
10
|
"JSON_PARSE": 400,
|
|
11
|
+
"UNAUTHORIZED": 401,
|
|
11
12
|
"NOT_FOUND": 404,
|
|
12
13
|
"MISSING_HEADER": 411,
|
|
14
|
+
"LOCKED": 423,
|
|
13
15
|
"INTERNAL_SERVER_ERROR": 500,
|
|
14
16
|
"NOT_IMPLEMENTED": 501
|
|
15
17
|
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|