node-pluginsmanager-plugin 6.5.0 → 7.0.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 +53 -48
- package/lib/@types/socket.io-v2.d.ts +988 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.d.ts +2 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyObject.d.ts +2 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyString.d.ts +2 -2
- package/lib/cjs/checkers/ReferenceError/checkExists.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkFunction.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkInteger.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkNumber.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkObject.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkString.d.ts +2 -2
- package/lib/cjs/components/DescriptorUser.d.ts +10 -11
- package/lib/cjs/components/DescriptorUser.js +51 -40
- package/lib/cjs/components/Mediator.d.ts +12 -17
- package/lib/cjs/components/Mediator.js +59 -39
- package/lib/cjs/components/MediatorUser.d.ts +2 -2
- package/lib/cjs/components/MediatorUser.js +12 -5
- package/lib/cjs/components/Orchestrator.d.ts +13 -13
- package/lib/cjs/components/Orchestrator.js +123 -69
- package/lib/cjs/components/Server.d.ts +22 -19
- package/lib/cjs/components/Server.js +279 -238
- package/lib/cjs/main.cjs +1 -40
- package/lib/cjs/main.d.cts +3 -15
- package/lib/cjs/openAPITypes.d.ts +5 -0
- package/lib/cjs/openAPITypes.js +3 -0
- package/lib/cjs/utils/cleanSendedError.d.ts +1 -1
- package/lib/cjs/utils/cleanSendedError.js +2 -4
- package/lib/cjs/utils/descriptor/extractParams.d.ts +1 -1
- package/lib/cjs/utils/descriptor/extractParams.js +1 -1
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.d.ts +2 -3
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.js +14 -14
- package/lib/cjs/utils/descriptor/extractPattern.d.ts +2 -2
- package/lib/cjs/utils/descriptor/extractPattern.js +5 -5
- package/lib/cjs/utils/descriptor/extractSchemaType.d.ts +1 -1
- package/lib/cjs/utils/descriptor/extractSchemaType.js +13 -8
- package/lib/cjs/utils/file/readJSONFile.d.ts +1 -1
- package/lib/cjs/utils/request/extractBody.js +9 -5
- package/lib/cjs/utils/request/extractCookies.d.ts +1 -1
- package/lib/cjs/utils/request/extractCookies.js +6 -6
- package/lib/cjs/utils/request/extractIp.d.ts +1 -1
- package/lib/cjs/utils/request/extractIp.js +19 -10
- package/lib/cjs/utils/request/extractMime.d.ts +1 -4
- package/lib/cjs/utils/request/extractMime.js +15 -11
- package/lib/cjs/utils/send.d.ts +4 -4
- package/lib/cjs/utils/send.js +27 -29
- package/lib/cjs/utils/server/getServerTypeFromServer.d.ts +4 -0
- package/lib/cjs/utils/server/getServerTypeFromServer.js +23 -0
- package/lib/cjs/utils/server/getSocketIOVersionFromServer.d.ts +4 -0
- package/lib/cjs/utils/server/getSocketIOVersionFromServer.js +19 -0
- package/package.json +101 -97
- package/lib/cjs/checkers/RangeError/checkArrayLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkArrayLength.js +0 -23
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.js +0 -30
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.js +0 -29
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.js +0 -19
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.js +0 -19
- package/lib/cjs/checkers/RangeError/checkNumberBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNumberBetween.js +0 -29
- package/lib/cjs/checkers/RangeError/checkObjectLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkObjectLength.js +0 -28
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.js +0 -33
- package/lib/cjs/checkers/RangeError/checkStringLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkStringLength.js +0 -23
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.js +0 -30
- package/lib/cjs/checkers/TypeError/checkArray.d.ts +0 -2
- package/lib/cjs/checkers/TypeError/checkArray.js +0 -19
- package/lib/cjs/checkers/TypeError/checkBoolean.d.ts +0 -2
- package/lib/cjs/checkers/TypeError/checkBoolean.js +0 -19
- package/lib/cjs/utils/jsonParser.d.ts +0 -1
- package/lib/cjs/utils/jsonParser.js +0 -16
package/lib/cjs/main.cjs
CHANGED
|
@@ -4,15 +4,12 @@ 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.
|
|
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;
|
|
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; } });
|
|
11
11
|
Object.defineProperty(exports, "checkExistsSync", { enumerable: true, get: function () { return checkExists_1.checkExistsSync; } });
|
|
12
12
|
// native
|
|
13
|
-
const checkBoolean_1 = require("./checkers/TypeError/checkBoolean");
|
|
14
|
-
Object.defineProperty(exports, "checkBoolean", { enumerable: true, get: function () { return checkBoolean_1.checkBoolean; } });
|
|
15
|
-
Object.defineProperty(exports, "checkBooleanSync", { enumerable: true, get: function () { return checkBoolean_1.checkBooleanSync; } });
|
|
16
13
|
const checkFunction_1 = require("./checkers/TypeError/checkFunction");
|
|
17
14
|
Object.defineProperty(exports, "checkFunction", { enumerable: true, get: function () { return checkFunction_1.checkFunction; } });
|
|
18
15
|
Object.defineProperty(exports, "checkFunctionSync", { enumerable: true, get: function () { return checkFunction_1.checkFunctionSync; } });
|
|
@@ -26,19 +23,10 @@ const checkString_1 = require("./checkers/TypeError/checkString");
|
|
|
26
23
|
Object.defineProperty(exports, "checkString", { enumerable: true, get: function () { return checkString_1.checkString; } });
|
|
27
24
|
Object.defineProperty(exports, "checkStringSync", { enumerable: true, get: function () { return checkString_1.checkStringSync; } });
|
|
28
25
|
// abstract
|
|
29
|
-
const checkArray_1 = require("./checkers/TypeError/checkArray");
|
|
30
|
-
Object.defineProperty(exports, "checkArray", { enumerable: true, get: function () { return checkArray_1.checkArray; } });
|
|
31
|
-
Object.defineProperty(exports, "checkArraySync", { enumerable: true, get: function () { return checkArray_1.checkArraySync; } });
|
|
32
26
|
const checkInteger_1 = require("./checkers/TypeError/checkInteger");
|
|
33
27
|
Object.defineProperty(exports, "checkInteger", { enumerable: true, get: function () { return checkInteger_1.checkInteger; } });
|
|
34
28
|
Object.defineProperty(exports, "checkIntegerSync", { enumerable: true, get: function () { return checkInteger_1.checkIntegerSync; } });
|
|
35
29
|
// empty
|
|
36
|
-
const checkNonEmptyArray_1 = require("./checkers/RangeError/checkNonEmptyArray");
|
|
37
|
-
Object.defineProperty(exports, "checkNonEmptyArray", { enumerable: true, get: function () { return checkNonEmptyArray_1.checkNonEmptyArray; } });
|
|
38
|
-
Object.defineProperty(exports, "checkNonEmptyArraySync", { enumerable: true, get: function () { return checkNonEmptyArray_1.checkNonEmptyArraySync; } });
|
|
39
|
-
const checkNonEmptyInteger_1 = require("./checkers/RangeError/checkNonEmptyInteger");
|
|
40
|
-
Object.defineProperty(exports, "checkNonEmptyInteger", { enumerable: true, get: function () { return checkNonEmptyInteger_1.checkNonEmptyInteger; } });
|
|
41
|
-
Object.defineProperty(exports, "checkNonEmptyIntegerSync", { enumerable: true, get: function () { return checkNonEmptyInteger_1.checkNonEmptyIntegerSync; } });
|
|
42
30
|
const checkNonEmptyNumber_1 = require("./checkers/RangeError/checkNonEmptyNumber");
|
|
43
31
|
Object.defineProperty(exports, "checkNonEmptyNumber", { enumerable: true, get: function () { return checkNonEmptyNumber_1.checkNonEmptyNumber; } });
|
|
44
32
|
Object.defineProperty(exports, "checkNonEmptyNumberSync", { enumerable: true, get: function () { return checkNonEmptyNumber_1.checkNonEmptyNumberSync; } });
|
|
@@ -48,33 +36,6 @@ Object.defineProperty(exports, "checkNonEmptyObjectSync", { enumerable: true, ge
|
|
|
48
36
|
const checkNonEmptyString_1 = require("./checkers/RangeError/checkNonEmptyString");
|
|
49
37
|
Object.defineProperty(exports, "checkNonEmptyString", { enumerable: true, get: function () { return checkNonEmptyString_1.checkNonEmptyString; } });
|
|
50
38
|
Object.defineProperty(exports, "checkNonEmptyStringSync", { enumerable: true, get: function () { return checkNonEmptyString_1.checkNonEmptyStringSync; } });
|
|
51
|
-
// range
|
|
52
|
-
// native
|
|
53
|
-
const checkNumberBetween_1 = require("./checkers/RangeError/checkNumberBetween");
|
|
54
|
-
Object.defineProperty(exports, "checkNumberBetween", { enumerable: true, get: function () { return checkNumberBetween_1.checkNumberBetween; } });
|
|
55
|
-
Object.defineProperty(exports, "checkNumberBetweenSync", { enumerable: true, get: function () { return checkNumberBetween_1.checkNumberBetweenSync; } });
|
|
56
|
-
const checkObjectLength_1 = require("./checkers/RangeError/checkObjectLength");
|
|
57
|
-
Object.defineProperty(exports, "checkObjectLength", { enumerable: true, get: function () { return checkObjectLength_1.checkObjectLength; } });
|
|
58
|
-
Object.defineProperty(exports, "checkObjectLengthSync", { enumerable: true, get: function () { return checkObjectLength_1.checkObjectLengthSync; } });
|
|
59
|
-
const checkObjectLengthBetween_1 = require("./checkers/RangeError/checkObjectLengthBetween");
|
|
60
|
-
Object.defineProperty(exports, "checkObjectLengthBetween", { enumerable: true, get: function () { return checkObjectLengthBetween_1.checkObjectLengthBetween; } });
|
|
61
|
-
Object.defineProperty(exports, "checkObjectLengthBetweenSync", { enumerable: true, get: function () { return checkObjectLengthBetween_1.checkObjectLengthBetweenSync; } });
|
|
62
|
-
const checkStringLength_1 = require("./checkers/RangeError/checkStringLength");
|
|
63
|
-
Object.defineProperty(exports, "checkStringLength", { enumerable: true, get: function () { return checkStringLength_1.checkStringLength; } });
|
|
64
|
-
Object.defineProperty(exports, "checkStringLengthSync", { enumerable: true, get: function () { return checkStringLength_1.checkStringLengthSync; } });
|
|
65
|
-
const checkStringLengthBetween_1 = require("./checkers/RangeError/checkStringLengthBetween");
|
|
66
|
-
Object.defineProperty(exports, "checkStringLengthBetween", { enumerable: true, get: function () { return checkStringLengthBetween_1.checkStringLengthBetween; } });
|
|
67
|
-
Object.defineProperty(exports, "checkStringLengthBetweenSync", { enumerable: true, get: function () { return checkStringLengthBetween_1.checkStringLengthBetweenSync; } });
|
|
68
|
-
// abstract
|
|
69
|
-
const checkIntegerBetween_1 = require("./checkers/RangeError/checkIntegerBetween");
|
|
70
|
-
Object.defineProperty(exports, "checkIntegerBetween", { enumerable: true, get: function () { return checkIntegerBetween_1.checkIntegerBetween; } });
|
|
71
|
-
Object.defineProperty(exports, "checkIntegerBetweenSync", { enumerable: true, get: function () { return checkIntegerBetween_1.checkIntegerBetweenSync; } });
|
|
72
|
-
const checkArrayLength_1 = require("./checkers/RangeError/checkArrayLength");
|
|
73
|
-
Object.defineProperty(exports, "checkArrayLength", { enumerable: true, get: function () { return checkArrayLength_1.checkArrayLength; } });
|
|
74
|
-
Object.defineProperty(exports, "checkArrayLengthSync", { enumerable: true, get: function () { return checkArrayLength_1.checkArrayLengthSync; } });
|
|
75
|
-
const checkArrayLengthBetween_1 = require("./checkers/RangeError/checkArrayLengthBetween");
|
|
76
|
-
Object.defineProperty(exports, "checkArrayLengthBetween", { enumerable: true, get: function () { return checkArrayLengthBetween_1.checkArrayLengthBetween; } });
|
|
77
|
-
Object.defineProperty(exports, "checkArrayLengthBetweenSync", { enumerable: true, get: function () { return checkArrayLengthBetween_1.checkArrayLengthBetweenSync; } });
|
|
78
39
|
// components
|
|
79
40
|
const DescriptorUser_1 = __importDefault(require("./components/DescriptorUser"));
|
|
80
41
|
exports.DescriptorUser = DescriptorUser_1.default;
|
package/lib/cjs/main.d.cts
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
import { checkExists, checkExistsSync } from "./checkers/ReferenceError/checkExists";
|
|
2
|
-
import { checkBoolean, checkBooleanSync } from "./checkers/TypeError/checkBoolean";
|
|
3
2
|
import { checkFunction, checkFunctionSync } from "./checkers/TypeError/checkFunction";
|
|
4
3
|
import { checkNumber, checkNumberSync } from "./checkers/TypeError/checkNumber";
|
|
5
4
|
import { checkObject, checkObjectSync } from "./checkers/TypeError/checkObject";
|
|
6
5
|
import { checkString, checkStringSync } from "./checkers/TypeError/checkString";
|
|
7
|
-
import { checkArray, checkArraySync } from "./checkers/TypeError/checkArray";
|
|
8
6
|
import { checkInteger, checkIntegerSync } from "./checkers/TypeError/checkInteger";
|
|
9
|
-
import { checkNonEmptyArray, checkNonEmptyArraySync } from "./checkers/RangeError/checkNonEmptyArray";
|
|
10
|
-
import { checkNonEmptyInteger, checkNonEmptyIntegerSync } from "./checkers/RangeError/checkNonEmptyInteger";
|
|
11
7
|
import { checkNonEmptyNumber, checkNonEmptyNumberSync } from "./checkers/RangeError/checkNonEmptyNumber";
|
|
12
8
|
import { checkNonEmptyObject, checkNonEmptyObjectSync } from "./checkers/RangeError/checkNonEmptyObject";
|
|
13
9
|
import { checkNonEmptyString, checkNonEmptyStringSync } from "./checkers/RangeError/checkNonEmptyString";
|
|
14
|
-
|
|
15
|
-
import { checkObjectLength, checkObjectLengthSync } from "./checkers/RangeError/checkObjectLength";
|
|
16
|
-
import { checkObjectLengthBetween, checkObjectLengthBetweenSync } from "./checkers/RangeError/checkObjectLengthBetween";
|
|
17
|
-
import { checkStringLength, checkStringLengthSync } from "./checkers/RangeError/checkStringLength";
|
|
18
|
-
import { checkStringLengthBetween, checkStringLengthBetweenSync } from "./checkers/RangeError/checkStringLengthBetween";
|
|
19
|
-
import { checkIntegerBetween, checkIntegerBetweenSync } from "./checkers/RangeError/checkIntegerBetween";
|
|
20
|
-
import { checkArrayLength, checkArrayLengthSync } from "./checkers/RangeError/checkArrayLength";
|
|
21
|
-
import { checkArrayLengthBetween, checkArrayLengthBetweenSync } from "./checkers/RangeError/checkArrayLengthBetween";
|
|
22
|
-
export { checkExists, checkExistsSync, checkBoolean, checkBooleanSync, checkFunction, checkFunctionSync, checkNumber, checkNumberSync, checkObject, checkObjectSync, checkString, checkStringSync, checkArray, checkArraySync, checkInteger, checkIntegerSync, checkNonEmptyArray, checkNonEmptyArraySync, checkNonEmptyInteger, checkNonEmptyIntegerSync, checkNonEmptyNumber, checkNonEmptyNumberSync, checkNonEmptyObject, checkNonEmptyObjectSync, checkNonEmptyString, checkNonEmptyStringSync, checkNumberBetween, checkNumberBetweenSync, checkObjectLength, checkObjectLengthSync, checkObjectLengthBetween, checkObjectLengthBetweenSync, checkStringLength, checkStringLengthSync, checkStringLengthBetween, checkStringLengthBetweenSync, checkIntegerBetween, checkIntegerBetweenSync, checkArrayLength, checkArrayLengthSync, checkArrayLengthBetween, checkArrayLengthBetweenSync };
|
|
10
|
+
export { checkExists, checkExistsSync, checkFunction, checkFunctionSync, checkNumber, checkNumberSync, checkObject, checkObjectSync, checkString, checkStringSync, checkInteger, checkIntegerSync, checkNonEmptyNumber, checkNonEmptyNumberSync, checkNonEmptyObject, checkNonEmptyObjectSync, checkNonEmptyString, checkNonEmptyStringSync };
|
|
23
11
|
import DescriptorUser, { type iDescriptorUserOptions, type tLogType, type tLogger, type iEventsMinimal } from "./components/DescriptorUser";
|
|
24
12
|
import Mediator, { type iUrlAllowedParameters } from "./components/Mediator";
|
|
25
13
|
import MediatorUser, { type iMediatorUserOptions } from "./components/MediatorUser";
|
|
26
14
|
import Orchestrator, { type iOrchestratorOptions } from "./components/Orchestrator";
|
|
27
|
-
import Server, { type iClient
|
|
15
|
+
import Server, { type iClient } from "./components/Server";
|
|
28
16
|
import UnauthorizedError from "./components/errors/UnauthorizedError";
|
|
29
17
|
import NotFoundError from "./components/errors/NotFoundError";
|
|
30
18
|
import LockedError from "./components/errors/LockedError";
|
|
31
|
-
export type { tLogType, tLogger, iEventsMinimal, iUrlAllowedParameters, iClient
|
|
19
|
+
export type { tLogType, tLogger, iEventsMinimal, iUrlAllowedParameters, iClient };
|
|
32
20
|
export { DescriptorUser, type iDescriptorUserOptions, Mediator, MediatorUser, type iMediatorUserOptions, Orchestrator, type iOrchestratorOptions, Server, UnauthorizedError, NotFoundError, LockedError };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OpenApiDocument } from "express-openapi-validate";
|
|
2
|
+
export type PathsObject = OpenApiDocument["paths"];
|
|
3
|
+
export type PathItemObject = PathsObject[string];
|
|
4
|
+
export type tMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
5
|
+
export type OperationObject = NonNullable<PathItemObject[tMethod]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function cleanSendedError(data:
|
|
1
|
+
export default function cleanSendedError(data: unknown): unknown;
|
|
@@ -12,12 +12,10 @@ function cleanSendedError(data) {
|
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
Object.keys(data).forEach((key) => {
|
|
15
|
-
data[key] = cleanSendedError(data[key]);
|
|
15
|
+
data[key] = cleanSendedError(data[key]); // in practice, it's unknown, had to specify the type for linter
|
|
16
16
|
});
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
20
|
+
return data;
|
|
23
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function extractParams(patternPath: string, realPath: string): Record<string,
|
|
1
|
+
export default function extractParams(patternPath: string, realPath: string): Record<string, string | number | boolean>;
|
|
@@ -12,7 +12,7 @@ function extractParams(patternPath, realPath) {
|
|
|
12
12
|
const params = {};
|
|
13
13
|
const patternPathSplitted = (0, removeFirstSlash_1.default)(patternPath).split("/");
|
|
14
14
|
(0, removeFirstSlash_1.default)(realPath).split("/").forEach((p, i) => {
|
|
15
|
-
if ("{" === patternPathSplitted[i][0]) {
|
|
15
|
+
if (i < patternPathSplitted.length && "{" === patternPathSplitted[i][0]) {
|
|
16
16
|
params[patternPathSplitted[i].replace("{", "").replace("}", "")] = decodeURI(p);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type tMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
1
|
+
import type { PathsObject, tMethod } from "../../openAPITypes";
|
|
3
2
|
export interface iPathMethod {
|
|
4
3
|
"path": string;
|
|
5
4
|
"method": tMethod;
|
|
6
5
|
"operationId": string;
|
|
7
6
|
}
|
|
8
|
-
export default function extractPathMethodByOperationId(paths:
|
|
7
|
+
export default function extractPathMethodByOperationId(paths: PathsObject | null | undefined, operationId: string): iPathMethod | undefined;
|
|
@@ -6,28 +6,28 @@ exports.default = extractPathMethodByOperationId;
|
|
|
6
6
|
function extractPathMethodByOperationId(paths, operationId) {
|
|
7
7
|
// no paths in this Descriptor
|
|
8
8
|
if ("object" !== typeof paths || null === paths) {
|
|
9
|
-
return
|
|
9
|
+
return undefined;
|
|
10
10
|
}
|
|
11
11
|
// no operationId given
|
|
12
12
|
else if ("string" !== typeof operationId || "" === operationId.trim()) {
|
|
13
|
-
return
|
|
13
|
+
return undefined;
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
let result = null;
|
|
17
16
|
for (let i = 0, pathnames = Object.keys(paths); i < pathnames.length; ++i) {
|
|
18
17
|
const pathname = pathnames[i];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
if ("object" === typeof paths[pathname]) {
|
|
19
|
+
const method = Object.keys(paths[pathname]).find((m) => {
|
|
20
|
+
return paths[pathname][m]?.operationId === operationId;
|
|
21
|
+
});
|
|
22
|
+
if ("undefined" !== typeof method) {
|
|
23
|
+
return {
|
|
24
|
+
"path": pathname,
|
|
25
|
+
method,
|
|
26
|
+
operationId
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return undefined;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function extractPattern(paths:
|
|
1
|
+
import type { PathsObject, PathItemObject } from "../../openAPITypes";
|
|
2
|
+
export default function extractPattern(paths: PathsObject, pathname: string, method: keyof PathItemObject): string;
|
|
@@ -9,10 +9,10 @@ exports.default = extractPattern;
|
|
|
9
9
|
const removeFirstSlash_1 = __importDefault(require("../removeFirstSlash"));
|
|
10
10
|
// module
|
|
11
11
|
function extractPattern(paths, pathname, method) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return "object" !== typeof paths ? "" : Object.keys(paths).find((p) => {
|
|
13
|
+
if ("undefined" === typeof paths[p][method]) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
16
|
const pathnameSplitted = (0, removeFirstSlash_1.default)(pathname).split("/");
|
|
17
17
|
const pathSplitted = (0, removeFirstSlash_1.default)(p).split("/");
|
|
18
18
|
if (pathnameSplitted.length !== pathSplitted.length) {
|
|
@@ -24,5 +24,5 @@ function extractPattern(paths, pathname, method) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return true;
|
|
27
|
-
})
|
|
27
|
+
}) ?? "";
|
|
28
28
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from "openapi-types";
|
|
2
|
-
export default function extractSchemaType(schema:
|
|
2
|
+
export default function extractSchemaType(schema: unknown, schemas: Record<string, OpenAPIV3_1.SchemaObject>): OpenAPIV3_1.SchemaObject["type"];
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
eslint-disable camelcase
|
|
4
|
+
*/
|
|
5
|
+
// => camelcase is disabled because of "openapi-types" types
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.default = extractSchemaType;
|
|
5
8
|
// module
|
|
6
9
|
function extractSchemaType(schema, schemas) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
result = schema.type;
|
|
10
|
+
if ("object" !== typeof schema || null === schema) {
|
|
11
|
+
return "string";
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
if ("string" === typeof schema.type) {
|
|
14
|
+
return schema.type;
|
|
15
|
+
}
|
|
16
|
+
if ("string" === typeof schema.$ref) {
|
|
12
17
|
const ref = schema.$ref.replace("#/components/schemas/", "");
|
|
13
|
-
if (schemas[ref] && schemas[ref].type) {
|
|
14
|
-
|
|
18
|
+
if ("object" === typeof schemas[ref] && "string" === typeof schemas[ref].type) {
|
|
19
|
+
return schemas[ref].type;
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
|
-
return
|
|
22
|
+
return "string";
|
|
18
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function readJSONFile(file: string): Promise<
|
|
1
|
+
export default function readJSONFile(file: string): Promise<unknown>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
eslint-disable @typescript-eslint/unbound-method
|
|
4
|
+
*/
|
|
5
|
+
// => @typescript-eslint/unbound-method is disabled to allow check on req.headers (no need for js context)
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.default = extractBody;
|
|
8
|
+
// deps
|
|
5
9
|
// locals
|
|
6
|
-
const
|
|
10
|
+
const checkString_1 = require("../../checkers/TypeError/checkString");
|
|
7
11
|
const checkFunction_1 = require("../../checkers/TypeError/checkFunction");
|
|
8
12
|
const checkNonEmptyObject_1 = require("../../checkers/RangeError/checkNonEmptyObject");
|
|
9
13
|
// module
|
|
@@ -13,7 +17,7 @@ function extractBody(req) {
|
|
|
13
17
|
}).then(() => {
|
|
14
18
|
return (0, checkNonEmptyObject_1.checkNonEmptyObject)("req.headers", req.headers);
|
|
15
19
|
}).then(() => {
|
|
16
|
-
return (0,
|
|
20
|
+
return (0, checkString_1.checkString)("req.headers[\"content-length\"]", req.headers["content-length"]);
|
|
17
21
|
}).then(() => {
|
|
18
22
|
return new Promise((resolve, reject) => {
|
|
19
23
|
let queryData = "";
|
|
@@ -24,8 +28,8 @@ function extractBody(req) {
|
|
|
24
28
|
resolve("");
|
|
25
29
|
}
|
|
26
30
|
else {
|
|
27
|
-
|
|
28
|
-
if (
|
|
31
|
+
const contentLength = Number.parseInt(req.headers["content-length"], 10);
|
|
32
|
+
if (contentLength !== Buffer.byteLength(queryData)) {
|
|
29
33
|
reject(new Error("\"Content-Length\" header (" + Buffer.byteLength(queryData) + ")"
|
|
30
34
|
+ " is not as expected (" + req.headers["content-length"] + ")."
|
|
31
35
|
+ " Do not forget the fact that it is a 8-bit bytes number."));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { iIncomingMessage } from "../../components/Server";
|
|
2
|
-
export default function extractCookies(req: iIncomingMessage): Record<string,
|
|
2
|
+
export default function extractCookies(req: iIncomingMessage): Record<string, unknown>;
|
|
@@ -17,7 +17,7 @@ function _parseCookies(cookies) {
|
|
|
17
17
|
const result = {};
|
|
18
18
|
cookies.split(";").forEach((cookie) => {
|
|
19
19
|
const parts = cookie.split("=");
|
|
20
|
-
result[parts[0]] = decodeURI(parts[1]);
|
|
20
|
+
result[parts[0]] = parts[1] ? decodeURI(parts[1]) : "";
|
|
21
21
|
});
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
@@ -30,17 +30,17 @@ function extractCookies(req) {
|
|
|
30
30
|
else if ("object" === typeof req.cookies) {
|
|
31
31
|
return req.cookies;
|
|
32
32
|
}
|
|
33
|
-
else if (req.headers) {
|
|
34
|
-
if (req.headers.cookie) {
|
|
33
|
+
else if ("object" === typeof req.headers) {
|
|
34
|
+
if ("undefined" !== typeof req.headers.cookie) {
|
|
35
35
|
return _parseCookies(req.headers.cookie);
|
|
36
36
|
}
|
|
37
|
-
else if (req.headers.Cookie) {
|
|
37
|
+
else if ("undefined" !== typeof req.headers.Cookie) {
|
|
38
38
|
return _parseCookies(req.headers.Cookie);
|
|
39
39
|
}
|
|
40
|
-
else if (req.headers.cookies) {
|
|
40
|
+
else if ("undefined" !== typeof req.headers.cookies) {
|
|
41
41
|
return _parseCookies(req.headers.cookies);
|
|
42
42
|
}
|
|
43
|
-
else if (req.headers.Cookies) {
|
|
43
|
+
else if ("undefined" !== typeof req.headers.Cookies) {
|
|
44
44
|
return _parseCookies(req.headers.Cookies);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function extractIp(
|
|
1
|
+
export default function extractIp(_req: unknown): string;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
2
|
+
// types & interfaces
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.default = extractIp;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// module
|
|
6
|
+
function extractIp(_req) {
|
|
7
|
+
if ("object" !== typeof _req || null === _req) {
|
|
7
8
|
return "";
|
|
8
9
|
}
|
|
9
10
|
else {
|
|
11
|
+
const req = _req;
|
|
10
12
|
let result = "";
|
|
11
13
|
if (req.ip) {
|
|
12
14
|
result = req.ip;
|
|
13
15
|
}
|
|
14
|
-
else if (req.headers && req.headers["x-forwarded-for"]) {
|
|
16
|
+
else if ("object" === typeof req.headers && "string" === typeof req.headers["x-forwarded-for"]) {
|
|
15
17
|
result = req.headers["x-forwarded-for"].split(",").pop();
|
|
16
18
|
}
|
|
17
|
-
else if (req.socket && req.socket.remoteAddress) {
|
|
19
|
+
else if ("object" === typeof req.socket && "string" === typeof req.socket.remoteAddress) {
|
|
18
20
|
result = req.socket.remoteAddress;
|
|
19
21
|
}
|
|
20
|
-
else if (req.connection) {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
else if ("object" === typeof req.connection) {
|
|
23
|
+
const { connection } = req;
|
|
24
|
+
if ("string" === typeof connection.remoteAddress) {
|
|
25
|
+
result = connection.remoteAddress;
|
|
23
26
|
}
|
|
24
|
-
else if (
|
|
25
|
-
|
|
27
|
+
else if ("object" === typeof connection.socket) {
|
|
28
|
+
const { socket } = connection;
|
|
29
|
+
if (socket.remoteAddress) {
|
|
30
|
+
result = socket.remoteAddress;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
result = "";
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
else {
|
|
28
37
|
result = "";
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export default function extractMime(contentType: string, code: number, responses:
|
|
2
|
-
"description": string;
|
|
3
|
-
"content"?: Record<string, any>;
|
|
4
|
-
}>): string;
|
|
1
|
+
export default function extractMime(contentType: string, code: number, responses: unknown): string;
|
|
@@ -10,30 +10,34 @@ const checkObject_1 = require("../../checkers/TypeError/checkObject");
|
|
|
10
10
|
const DEFAULT_MIME = "text/plain";
|
|
11
11
|
// module
|
|
12
12
|
function extractMime(contentType, code, responses) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const err = (0, checkString_1.checkStringSync)("contentType", contentType)
|
|
14
|
+
?? (0, checkNonEmptyNumber_1.checkNonEmptyNumberSync)("code", code)
|
|
15
|
+
?? (0, checkObject_1.checkObjectSync)("responses", responses);
|
|
15
16
|
if (err) {
|
|
16
17
|
throw err;
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
20
|
const stringifiedCode = String(code);
|
|
20
|
-
|
|
21
|
+
const res = responses; // mandatory for typing, convert "unknown" response to controlled and typed one
|
|
22
|
+
if ("undefined" === typeof res[stringifiedCode] && "undefined" === typeof res.default && "" !== contentType.trim()) {
|
|
21
23
|
return contentType;
|
|
22
24
|
}
|
|
23
25
|
else {
|
|
24
|
-
let descriptorContent;
|
|
25
|
-
if (
|
|
26
|
-
if (
|
|
27
|
-
descriptorContent =
|
|
26
|
+
let descriptorContent = {};
|
|
27
|
+
if ("object" === typeof res[stringifiedCode]) {
|
|
28
|
+
if ("object" === typeof res[stringifiedCode].content) {
|
|
29
|
+
descriptorContent = res[stringifiedCode].content;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
else if (
|
|
31
|
-
|
|
32
|
+
else if ("object" === typeof res.default) {
|
|
33
|
+
if ("object" === typeof res.default.content) {
|
|
34
|
+
descriptorContent = res.default.content;
|
|
35
|
+
}
|
|
32
36
|
}
|
|
33
37
|
else {
|
|
34
38
|
return DEFAULT_MIME;
|
|
35
39
|
}
|
|
36
|
-
const possibleMimes =
|
|
40
|
+
const possibleMimes = Object.keys(descriptorContent);
|
|
37
41
|
const [mimeRequest, charsetRequest] = contentType.split(";").map((content) => {
|
|
38
42
|
return content.trim().toLowerCase();
|
|
39
43
|
});
|
|
@@ -47,7 +51,7 @@ function extractMime(contentType, code, responses) {
|
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
else if (1 === possibleMimes.length) { // only one possible option
|
|
50
|
-
result = possibleMimes
|
|
54
|
+
[result] = possibleMimes;
|
|
51
55
|
}
|
|
52
56
|
else {
|
|
53
57
|
result = mimeRequest && possibleMimes.includes(mimeRequest) ? mimeRequest : DEFAULT_MIME;
|
package/lib/cjs/utils/send.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import type {
|
|
3
|
-
export default function send(req: IncomingMessage, res:
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { iFormatedServerResponseForValidation } from "../components/Server";
|
|
3
|
+
export default function send(req: IncomingMessage, res: ServerResponse, code: number, content: unknown, options: {
|
|
4
4
|
"apiVersion": string;
|
|
5
5
|
"cors": boolean;
|
|
6
6
|
"mime": string;
|
|
7
|
-
}): Promise<
|
|
7
|
+
}): Promise<iFormatedServerResponseForValidation>;
|
package/lib/cjs/utils/send.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
eslint-disable @typescript-eslint/no-base-to-string
|
|
4
|
+
*/
|
|
5
|
+
// => @typescript-eslint/no-base-to-string is disabled to allow stringification of unattented content ('[object Object]' for example)
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.default = send;
|
|
5
8
|
// module
|
|
@@ -14,45 +17,39 @@ function send(req, res, code, content, options) {
|
|
|
14
17
|
else if ("string" === typeof content && "" === content) {
|
|
15
18
|
return "";
|
|
16
19
|
}
|
|
17
|
-
else {
|
|
20
|
+
else if (options.mime.includes("application/json")) {
|
|
18
21
|
let result = "";
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
result = content; // yes => valid JSON string, send it as it is
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
result = JSON.stringify(content); // no => not JSON string, send formatted one
|
|
27
|
-
}
|
|
22
|
+
if ("string" === typeof content) {
|
|
23
|
+
try {
|
|
24
|
+
JSON.parse(content); // is content json & parseable ?
|
|
25
|
+
result = content; // yes => valid JSON string, send it as it is
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (stringified !== content) {
|
|
32
|
-
result = stringified;
|
|
33
|
-
}
|
|
27
|
+
catch {
|
|
28
|
+
result = JSON.stringify(content); // no => not JSON string, send formatted one
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
31
|
else {
|
|
37
|
-
|
|
32
|
+
const stringified = JSON.stringify(content);
|
|
33
|
+
if (stringified !== content) {
|
|
34
|
+
result = stringified;
|
|
35
|
+
}
|
|
38
36
|
}
|
|
39
37
|
return result;
|
|
40
38
|
}
|
|
39
|
+
return String(content);
|
|
41
40
|
}).then((formattedContent) => {
|
|
42
41
|
return new Promise((resolve) => {
|
|
43
42
|
// force data for checking
|
|
44
43
|
res.statusCode = code;
|
|
45
|
-
res.headers =
|
|
44
|
+
res.headers = {
|
|
46
45
|
"Content-Type": options.mime,
|
|
47
46
|
"Content-Length": 0 < formattedContent.length ? Buffer.byteLength(formattedContent) : 0,
|
|
48
47
|
"Status-Code-Url-Cat": "https://http.cat/" + code,
|
|
49
|
-
"API-Version": options.apiVersion
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
? req.headers["access-control-request-method"]
|
|
55
|
-
: [
|
|
48
|
+
"API-Version": options.apiVersion,
|
|
49
|
+
...options.cors ? {
|
|
50
|
+
"Access-Control-Allow-Origin": "*",
|
|
51
|
+
"Access-Control-Allow-Credentials": true,
|
|
52
|
+
"Access-Control-Allow-Methods": req.headers["access-control-request-method"] ?? [
|
|
56
53
|
"GET",
|
|
57
54
|
"POST",
|
|
58
55
|
"PUT",
|
|
@@ -60,9 +57,7 @@ function send(req, res, code, content, options) {
|
|
|
60
57
|
"PATCH",
|
|
61
58
|
"OPTIONS"
|
|
62
59
|
].join(", "),
|
|
63
|
-
|
|
64
|
-
? req.headers["access-control-request-headers"]
|
|
65
|
-
: [
|
|
60
|
+
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] ?? [
|
|
66
61
|
"Origin",
|
|
67
62
|
"Accept",
|
|
68
63
|
"Accept-Version",
|
|
@@ -75,7 +70,8 @@ function send(req, res, code, content, options) {
|
|
|
75
70
|
"X-CSRF-Token",
|
|
76
71
|
"X-Requested-With"
|
|
77
72
|
].join(", ")
|
|
78
|
-
|
|
73
|
+
} : {}
|
|
74
|
+
};
|
|
79
75
|
// send data
|
|
80
76
|
res.writeHead(res.statusCode, res.headers);
|
|
81
77
|
if ("string" === typeof formattedContent) {
|
|
@@ -95,5 +91,7 @@ function send(req, res, code, content, options) {
|
|
|
95
91
|
});
|
|
96
92
|
}
|
|
97
93
|
});
|
|
94
|
+
}).then(() => {
|
|
95
|
+
return res;
|
|
98
96
|
});
|
|
99
97
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Server as WebSocketServer } from "ws";
|
|
2
|
+
import type { Server as SocketIOServer } from "socket.io";
|
|
3
|
+
import type { Server as SocketIOServerV2 } from "../../../@types/socket.io-v2";
|
|
4
|
+
export default function getServerTypeFromServer(server: WebSocketServer | SocketIOServer | SocketIOServerV2 | null | undefined): "NO_SERVER" | "WEBSOCKET" | "SOCKETIO" | "UNKNOWN";
|