node-pluginsmanager-plugin 4.8.8 → 5.0.2

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.
Files changed (136) hide show
  1. package/lib/cjs/checkers/RangeError/checkArrayLength.d.ts +2 -0
  2. package/lib/cjs/checkers/RangeError/checkArrayLength.js +26 -0
  3. package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.d.ts +2 -0
  4. package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.js +33 -0
  5. package/lib/cjs/checkers/RangeError/checkIntegerBetween.d.ts +2 -0
  6. package/lib/cjs/checkers/RangeError/checkIntegerBetween.js +32 -0
  7. package/lib/cjs/checkers/RangeError/checkNonEmptyArray.d.ts +2 -0
  8. package/lib/cjs/checkers/RangeError/checkNonEmptyArray.js +22 -0
  9. package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.d.ts +2 -0
  10. package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.js +22 -0
  11. package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.d.ts +2 -0
  12. package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.js +22 -0
  13. package/lib/cjs/checkers/RangeError/checkNonEmptyObject.d.ts +2 -0
  14. package/lib/cjs/checkers/RangeError/checkNonEmptyObject.js +22 -0
  15. package/lib/cjs/checkers/RangeError/checkNonEmptyString.d.ts +2 -0
  16. package/lib/cjs/checkers/RangeError/checkNonEmptyString.js +22 -0
  17. package/lib/cjs/checkers/RangeError/checkNumberBetween.d.ts +2 -0
  18. package/lib/cjs/checkers/RangeError/checkNumberBetween.js +32 -0
  19. package/lib/cjs/checkers/RangeError/checkObjectLength.d.ts +2 -0
  20. package/lib/cjs/checkers/RangeError/checkObjectLength.js +31 -0
  21. package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.d.ts +2 -0
  22. package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.js +36 -0
  23. package/lib/cjs/checkers/RangeError/checkStringLength.d.ts +2 -0
  24. package/lib/cjs/checkers/RangeError/checkStringLength.js +26 -0
  25. package/lib/cjs/checkers/RangeError/checkStringLengthBetween.d.ts +2 -0
  26. package/lib/cjs/checkers/RangeError/checkStringLengthBetween.js +33 -0
  27. package/lib/cjs/checkers/ReferenceError/checkExists.d.ts +2 -0
  28. package/lib/cjs/checkers/ReferenceError/checkExists.js +19 -0
  29. package/lib/cjs/checkers/TypeError/checkArray.d.ts +2 -0
  30. package/lib/cjs/checkers/TypeError/checkArray.js +22 -0
  31. package/lib/cjs/checkers/TypeError/checkBoolean.d.ts +2 -0
  32. package/lib/cjs/checkers/TypeError/checkBoolean.js +22 -0
  33. package/lib/cjs/checkers/TypeError/checkFunction.d.ts +2 -0
  34. package/lib/cjs/checkers/TypeError/checkFunction.js +22 -0
  35. package/lib/cjs/checkers/TypeError/checkInteger.d.ts +2 -0
  36. package/lib/cjs/checkers/TypeError/checkInteger.js +22 -0
  37. package/lib/cjs/checkers/TypeError/checkNumber.d.ts +2 -0
  38. package/lib/cjs/checkers/TypeError/checkNumber.js +22 -0
  39. package/lib/cjs/checkers/TypeError/checkObject.d.ts +2 -0
  40. package/lib/cjs/checkers/TypeError/checkObject.js +22 -0
  41. package/lib/cjs/checkers/TypeError/checkString.d.ts +2 -0
  42. package/lib/cjs/checkers/TypeError/checkString.js +22 -0
  43. package/lib/cjs/components/DescriptorUser.d.ts +27 -0
  44. package/lib/cjs/components/DescriptorUser.js +120 -0
  45. package/lib/cjs/components/Mediator.d.ts +20 -0
  46. package/lib/cjs/components/Mediator.js +145 -0
  47. package/lib/cjs/components/MediatorUser.d.ts +12 -0
  48. package/lib/cjs/components/MediatorUser.js +40 -0
  49. package/lib/cjs/components/NotFoundError.d.ts +2 -0
  50. package/lib/cjs/components/NotFoundError.js +7 -0
  51. package/lib/cjs/components/Orchestrator.d.ts +55 -0
  52. package/lib/cjs/components/Orchestrator.js +386 -0
  53. package/lib/cjs/components/Server.d.ts +55 -0
  54. package/lib/cjs/components/Server.js +535 -0
  55. package/lib/cjs/main.cjs +90 -0
  56. package/lib/cjs/main.d.cts +30 -0
  57. package/lib/cjs/utils/cleanSendedError.d.ts +1 -0
  58. package/lib/cjs/utils/cleanSendedError.js +43 -0
  59. package/lib/cjs/utils/descriptor/extractParams.d.ts +3 -0
  60. package/lib/cjs/utils/descriptor/extractParams.js +21 -0
  61. package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.d.ts +8 -0
  62. package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.js +34 -0
  63. package/lib/cjs/utils/descriptor/extractPattern.d.ts +2 -0
  64. package/lib/cjs/utils/descriptor/extractPattern.js +28 -0
  65. package/lib/cjs/utils/descriptor/extractSchemaType.d.ts +4 -0
  66. package/lib/cjs/utils/descriptor/extractSchemaType.js +18 -0
  67. package/lib/cjs/utils/file/checkFile.d.ts +1 -0
  68. package/lib/cjs/utils/file/checkFile.js +17 -0
  69. package/lib/cjs/utils/file/isFile.d.ts +1 -0
  70. package/lib/cjs/utils/file/isFile.js +19 -0
  71. package/lib/cjs/utils/file/readJSONFile.d.ts +1 -0
  72. package/lib/cjs/utils/file/readJSONFile.js +24 -0
  73. package/lib/cjs/utils/getUniqueID.d.ts +1 -0
  74. package/lib/cjs/utils/getUniqueID.js +16 -0
  75. package/lib/cjs/utils/removeFirstSlash.d.ts +1 -0
  76. package/lib/cjs/utils/removeFirstSlash.js +8 -0
  77. package/lib/cjs/utils/request/extractBody.d.ts +7 -0
  78. package/lib/cjs/utils/request/extractBody.js +52 -0
  79. package/lib/cjs/utils/request/extractCookies.d.ts +4 -0
  80. package/lib/cjs/utils/request/extractCookies.js +53 -0
  81. package/lib/cjs/utils/request/extractIp.d.ts +1 -0
  82. package/lib/cjs/utils/request/extractIp.js +40 -0
  83. package/lib/cjs/utils/send.d.ts +2 -0
  84. package/lib/cjs/utils/send.js +57 -0
  85. package/lib/cjs/utils/serverCodes.d.ts +14 -0
  86. package/lib/cjs/utils/serverCodes.js +15 -0
  87. package/package.json +32 -13
  88. package/lib/checkers/RangeError/checkArrayLength.js +0 -74
  89. package/lib/checkers/RangeError/checkArrayLengthBetween.js +0 -97
  90. package/lib/checkers/RangeError/checkIntegerBetween.js +0 -96
  91. package/lib/checkers/RangeError/checkNonEmptyArray.js +0 -61
  92. package/lib/checkers/RangeError/checkNonEmptyInteger.js +0 -61
  93. package/lib/checkers/RangeError/checkNonEmptyNumber.js +0 -61
  94. package/lib/checkers/RangeError/checkNonEmptyObject.js +0 -61
  95. package/lib/checkers/RangeError/checkNonEmptyString.js +0 -61
  96. package/lib/checkers/RangeError/checkNumberBetween.js +0 -96
  97. package/lib/checkers/RangeError/checkObjectLength.js +0 -78
  98. package/lib/checkers/RangeError/checkObjectLengthBetween.js +0 -101
  99. package/lib/checkers/RangeError/checkStringLength.js +0 -70
  100. package/lib/checkers/RangeError/checkStringLengthBetween.js +0 -97
  101. package/lib/checkers/ReferenceError/checkExists.js +0 -49
  102. package/lib/checkers/TypeError/checkArray.js +0 -61
  103. package/lib/checkers/TypeError/checkBoolean.js +0 -61
  104. package/lib/checkers/TypeError/checkFunction.js +0 -61
  105. package/lib/checkers/TypeError/checkInteger.js +0 -61
  106. package/lib/checkers/TypeError/checkNumber.js +0 -61
  107. package/lib/checkers/TypeError/checkObject.js +0 -61
  108. package/lib/checkers/TypeError/checkString.js +0 -61
  109. package/lib/checkers/main.js +0 -76
  110. package/lib/components/DescriptorUser.js +0 -179
  111. package/lib/components/Mediator.js +0 -220
  112. package/lib/components/MediatorUser.js +0 -63
  113. package/lib/components/NotFoundError.js +0 -5
  114. package/lib/components/Orchestrator.js +0 -634
  115. package/lib/components/Server.js +0 -777
  116. package/lib/components/main.js +0 -25
  117. package/lib/index.d.ts +0 -279
  118. package/lib/main.js +0 -17
  119. package/lib/utils/cleanSendedError.js +0 -47
  120. package/lib/utils/descriptor/extractParams.js +0 -29
  121. package/lib/utils/descriptor/extractPathMethodByOperationId.js +0 -47
  122. package/lib/utils/descriptor/extractPattern.js +0 -38
  123. package/lib/utils/descriptor/extractSchemaType.js +0 -24
  124. package/lib/utils/descriptor/main.js +0 -21
  125. package/lib/utils/file/checkFile.js +0 -22
  126. package/lib/utils/file/isFile.js +0 -29
  127. package/lib/utils/file/main.js +0 -19
  128. package/lib/utils/file/readJSONFile.js +0 -30
  129. package/lib/utils/getUniqueID.js +0 -20
  130. package/lib/utils/removeFirstSlash.js +0 -7
  131. package/lib/utils/request/extractBody.js +0 -79
  132. package/lib/utils/request/extractCookies.js +0 -68
  133. package/lib/utils/request/extractIp.js +0 -47
  134. package/lib/utils/request/main.js +0 -19
  135. package/lib/utils/send.js +0 -75
  136. package/lib/utils/serverCodes.json +0 -17
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const DescriptorUser = require(join(__dirname, "DescriptorUser.js"));
10
- const Mediator = require(join(__dirname, "Mediator.js"));
11
- const MediatorUser = require(join(__dirname, "MediatorUser.js"));
12
- const Orchestrator = require(join(__dirname, "Orchestrator.js"));
13
- const Server = require(join(__dirname, "Server.js"));
14
- const NotFoundError = require(join(__dirname, "NotFoundError.js"));
15
-
16
- // module
17
-
18
- module.exports = {
19
- DescriptorUser,
20
- Mediator,
21
- MediatorUser,
22
- Orchestrator,
23
- Server,
24
- NotFoundError
25
- };
package/lib/index.d.ts DELETED
@@ -1,279 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="ws" />
3
- /// <reference types="socket.io" />
4
-
5
- declare module "node-pluginsmanager-plugin" {
6
-
7
- import { EventEmitter } from "events";
8
- import { Server as WebSocketServer } from "ws";
9
- import { Server as SocketIOServer } from "socket.io";
10
-
11
- // checkers
12
-
13
- // undefined
14
- export function checkExists (dataName: string, data: any, async?: boolean): Promise<void>;
15
- export function checkExists (dataName: string, data: any, async: boolean): null | ReferenceError;
16
-
17
- // native
18
- export function checkBoolean (dataName: string, data: any, async?: boolean): Promise<void>;
19
- export function checkBoolean (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
20
-
21
- export function checkFunction (dataName: string, data: any, async?: boolean): Promise<void>;
22
- export function checkFunction (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
23
-
24
- export function checkNumber (dataName: string, data: any, async?: boolean): Promise<void>;
25
- export function checkNumber (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
26
-
27
- export function checkObject (dataName: string, data: any, async?: boolean): Promise<void>;
28
- export function checkObject (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
29
-
30
- export function checkString (dataName: string, data: any, async?: boolean): Promise<void>;
31
- export function checkString (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
32
-
33
- // abstract
34
- export function checkArray (dataName: string, data: any, async?: boolean): Promise<void>;
35
- export function checkArray (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
36
-
37
- export function checkInteger (dataName: string, data: any, async?: boolean): Promise<void>;
38
- export function checkInteger (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError;
39
-
40
- // empty
41
- export function checkNonEmptyArray (dataName: string, data: any, async?: boolean): Promise<void>;
42
- export function checkNonEmptyArray (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError | RangeError;
43
-
44
- export function checkNonEmptyInteger (dataName: string, data: any, async?: boolean): Promise<void>;
45
- export function checkNonEmptyInteger (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError | RangeError;
46
-
47
- export function checkNonEmptyNumber (dataName: string, data: any, async?: boolean): Promise<void>;
48
- export function checkNonEmptyNumber (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError | RangeError;
49
-
50
- export function checkNonEmptyObject (dataName: string, data: any, async?: boolean): Promise<void>;
51
- export function checkNonEmptyObject (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError | RangeError;
52
-
53
- export function checkNonEmptyString (dataName: string, data: any, async?: boolean): Promise<void>;
54
- export function checkNonEmptyString (dataName: string, data: any, async: boolean): null | ReferenceError | TypeError | RangeError;
55
-
56
- // range
57
- export function checkArrayLength (dataName: string, data: any, length: number, async?: boolean): Promise<void>;
58
- export function checkArrayLength (dataName: string, data: any, length: number, async: boolean): null | ReferenceError | TypeError | RangeError;
59
-
60
- export function checkArrayLengthBetween (dataName: string, data: any, min: number, max: number, async?: boolean): Promise<void>;
61
- export function checkArrayLengthBetween (dataName: string, data: any, min: number, max: number, async: boolean): null | ReferenceError | TypeError | RangeError;
62
-
63
- export function checkIntegerBetween (dataName: string, data: any, min: number, max: number, async?: boolean): Promise<void>;
64
- export function checkIntegerBetween (dataName: string, data: any, min: number, max: number, async: boolean): null | ReferenceError | TypeError | RangeError;
65
-
66
- export function checkNumberBetween (dataName: string, data: any, min: number, max: number, async?: boolean): Promise<void>;
67
- export function checkNumberBetween (dataName: string, data: any, min: number, max: number, async: boolean): null | ReferenceError | TypeError | RangeError;
68
-
69
- export function checkObjectLength (dataName: string, data: any, length: number, async?: boolean): Promise<void>;
70
- export function checkObjectLength (dataName: string, data: any, length: number, async: boolean): null | ReferenceError | TypeError | RangeError;
71
-
72
- export function checkObjectLengthBetween (dataName: string, data: any, min: number, max: number, async?: boolean): Promise<void>;
73
- export function checkObjectLengthBetween (dataName: string, data: any, min: number, max: number, async: boolean): null | ReferenceError | TypeError | RangeError;
74
-
75
- export function checkStringLength (dataName: string, data: any, length: number, async?: boolean): Promise<void>;
76
- export function checkStringLength (dataName: string, data: any, length: number, async: boolean): null | ReferenceError | TypeError | RangeError;
77
-
78
- export function checkStringLengthBetween (dataName: string, data: any, min: number, max: number, async?: boolean): Promise<void>;
79
- export function checkStringLengthBetween (dataName: string, data: any, min: number, max: number, async: boolean): null | ReferenceError | TypeError | RangeError;
80
-
81
- // components
82
-
83
- export type tLogType = "log" | "info" | "warning" | "error" | "debug";
84
-
85
- export interface iDescriptorUserOptions {
86
- "descriptor": { [key:string]: any };
87
- "externalRessourcesDirectory": string;
88
- "logger"?: (type: tLogType, message: string, bold?: boolean) => void;
89
- }
90
-
91
- export interface iMediatorUserOptions extends iDescriptorUserOptions {
92
- "mediator": Mediator | null;
93
- }
94
-
95
- export interface iUrlParameters {
96
- "url": {
97
- "path": object;
98
- "query": object;
99
- "headers": object;
100
- "cookies": object;
101
- };
102
- }
103
-
104
- export interface iOrchestratorOptions {
105
- "externalRessourcesDirectory": string;
106
- "packageFile": string;
107
- "descriptorFile": string;
108
- "mediatorFile": string;
109
- "serverFile": string;
110
- }
111
-
112
- export class DescriptorUser extends EventEmitter {
113
-
114
- // attributes
115
-
116
- // public
117
-
118
- public initialized: boolean;
119
-
120
- // protected
121
-
122
- protected _descriptorValidated: boolean;
123
-
124
- protected _externalRessourcesDirectory: string;
125
-
126
- protected _Descriptor: object | null;
127
- protected _Logger: Function | null;
128
-
129
- // constructor
130
-
131
- constructor (options: iDescriptorUserOptions);
132
-
133
- // methods
134
-
135
- // protected
136
-
137
- protected _initWorkSpace(data?: any): Promise<void>;
138
- protected _releaseWorkSpace(data?: any): Promise<void>;
139
- protected _log(type: tLogType, message: string, bold?: boolean): this;
140
-
141
- // public
142
-
143
- public checkDescriptor(): Promise<void>;
144
- public init(data?: any): Promise<void>;
145
- public release(data?: any): Promise<void>;
146
-
147
- }
148
-
149
- export class Mediator extends DescriptorUser {
150
-
151
- // attributes
152
-
153
- public _validator: null | object;
154
-
155
- // methods
156
-
157
- public checkParameters(operationId: string, urlParams: iUrlParameters, bodyParams: object): Promise<void>;
158
- public checkResponse(operationId: string, res: Response): Promise<void>;
159
-
160
- }
161
-
162
- export class MediatorUser extends DescriptorUser {
163
-
164
- // attributes
165
-
166
- protected _Mediator: Mediator | null;
167
-
168
- // constructor
169
-
170
- constructor (options: iMediatorUserOptions);
171
-
172
- // methods
173
-
174
- public checkMediator(): Promise<void>;
175
-
176
- }
177
-
178
- export class Server extends MediatorUser {
179
-
180
- // attributes
181
-
182
- protected _socketServer: WebSocketServer | SocketIOServer | null;
183
- protected _checkParameters: boolean;
184
- protected _checkResponse: boolean;
185
- protected _cors: boolean;
186
-
187
- // methods
188
-
189
- public disableCheckParameters(): this;
190
- public enableCheckParameters(): this;
191
- public disableCheckResponse(): this;
192
- public enableCheckResponse(): this;
193
-
194
- public disableCors(): this;
195
- public enableCors(): this;
196
-
197
- public appMiddleware(req: Request, res: Response, next: Function): void;
198
- public socketMiddleware(server: WebSocketServer | SocketIOServer): void;
199
- public push(command: string, data?: any): this;
200
-
201
- }
202
-
203
- export class Orchestrator extends MediatorUser {
204
-
205
- // attributes
206
-
207
- // protected
208
-
209
- protected _Server: Server | null;
210
- protected _socketServer: WebSocketServer | SocketIOServer | null;
211
- protected _checkParameters: boolean;
212
- protected _checkResponse: boolean;
213
-
214
- // params
215
- protected _packageFile: string;
216
- protected _descriptorFile: string;
217
- protected _mediatorFile: string;
218
- protected _serverFile: string;
219
-
220
- protected _extended: Array<string>;
221
-
222
- // public
223
-
224
- public enabled: boolean;
225
-
226
- // native
227
- public authors: Array<string> | null;
228
- public description: string;
229
- public dependencies: object | null;
230
- public devDependencies: object | null;
231
- public engines: object | null;
232
- public license: string;
233
- public main: string;
234
- public name: string;
235
- public scripts: object | null;
236
- public version: string;
237
-
238
- // constructor
239
-
240
- constructor (options: iOrchestratorOptions);
241
-
242
- // methods
243
-
244
- // checkers
245
-
246
- public checkConf(): Promise<void>;
247
- public isEnable(): Promise<void>;
248
- public checkFiles(): Promise<void>;
249
- public checkServer(): Promise<void>;
250
-
251
- // middleware
252
-
253
- public disableCheckParameters(): this;
254
- public enableCheckParameters(): this;
255
- public disableCheckResponse(): this;
256
- public enableCheckResponse(): this;
257
-
258
- public disableCors(): this;
259
- public enableCors(): this;
260
-
261
- public appMiddleware(req: Request, res: Response, next: Function): void;
262
- public socketMiddleware(server: WebSocketServer | SocketIOServer): void;
263
-
264
- // init / release
265
-
266
- public load(data?: any): Promise<void>;
267
- public destroy(data?: any): Promise<void>;
268
-
269
- // write
270
-
271
- public install(data?: any): Promise<void>;
272
- public update(data?: any): Promise<void>;
273
- public uninstall(data?: any): Promise<void>;
274
-
275
- }
276
-
277
- export class NotFoundError extends Error {}
278
-
279
- }
package/lib/main.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const checkers = require(join(__dirname, "checkers", "main.js"));
10
- const components = require(join(__dirname, "components", "main.js"));
11
-
12
- // module
13
-
14
- module.exports = {
15
- ...checkers,
16
- ...components
17
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- // module
4
-
5
- module.exports = function cleanSendedError (data) {
6
-
7
- if ("object" === typeof data) {
8
-
9
- if (data instanceof Error) {
10
- return data.message ? data.message : data;
11
- }
12
- else if (data.message && data.message instanceof Error) {
13
-
14
- data.message = data.message.message ? data.message.message : data.message;
15
-
16
- return data;
17
-
18
- }
19
- else if (data.error) { // 1 level recursive for "error" data (avoid too deep recursive analyse)
20
-
21
- if (data.error instanceof Error) {
22
- data.error = data.error.message ? data.error.message : data.error;
23
- }
24
- else if (data.error.message && data.error.message instanceof Error) {
25
- data.error.message = data.error.message.message ? data.error.message.message : data.error.message;
26
- }
27
-
28
- return data;
29
-
30
- }
31
- else if (data.err && data.err instanceof Error) { // 1 level recursive for "err" data (avoid too deep recursive analyse)
32
-
33
- data.err = data.err.message ? data.err.message : data.err;
34
-
35
- return data;
36
-
37
- }
38
- else {
39
- return data;
40
- }
41
-
42
- }
43
- else {
44
- return data;
45
- }
46
-
47
- };
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const removeFirstSlash = require(join(__dirname, "..", "removeFirstSlash.js"));
10
-
11
- // module
12
-
13
- module.exports = function extractParams (patternPath, realPath) {
14
-
15
- const params = {};
16
-
17
- const patternPathSplitted = removeFirstSlash(patternPath).split("/");
18
-
19
- removeFirstSlash(realPath).split("/").forEach((p, i) => {
20
-
21
- if ("{" === patternPathSplitted[i][0]) {
22
- params[patternPathSplitted[i].replace("{", "").replace("}", "")] = decodeURI(p);
23
- }
24
-
25
- });
26
-
27
- return params;
28
-
29
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- // module
4
-
5
- module.exports = function extractPathMethodByOperationId (paths, operationId) {
6
-
7
- // no paths in this Descriptor
8
- if ("object" !== typeof paths || null === paths) {
9
- return null;
10
- }
11
-
12
- // no operationId given
13
- else if ("string" !== typeof operationId || "" === operationId.trim()) {
14
- return null;
15
- }
16
-
17
- else {
18
-
19
- let result = null;
20
-
21
- for (let i = 0, pathnames = Object.keys(paths); i < pathnames.length; ++i) {
22
-
23
- const pathname = pathnames[i];
24
-
25
- const method = Object.keys(paths[pathname]).find((m) => {
26
- return paths[pathname][m].operationId === operationId;
27
- });
28
-
29
- if ("undefined" !== typeof method) {
30
-
31
- result = {
32
- "path": pathname,
33
- method,
34
- operationId
35
- };
36
-
37
- break;
38
-
39
- }
40
-
41
- }
42
-
43
- return result;
44
-
45
- }
46
-
47
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const removeFirstSlash = require(join(__dirname, "..", "removeFirstSlash.js"));
10
-
11
- // module
12
-
13
- module.exports = function extractPattern (paths, pathname, method) {
14
-
15
- return "object" !== typeof paths ? "" : Object.keys(paths).filter((p) => {
16
- return "undefined" !== typeof paths[p][method];
17
- }).find((p) => {
18
-
19
- const pathnameSplitted = removeFirstSlash(pathname).split("/");
20
- const pathSplitted = removeFirstSlash(p).split("/");
21
-
22
- if (pathnameSplitted.length !== pathSplitted.length) {
23
- return false;
24
- }
25
-
26
- for (let i = 0; i < pathnameSplitted.length; ++i) {
27
-
28
- if ("{" !== pathSplitted[i][0] && pathSplitted[i] !== pathnameSplitted[i]) {
29
- return false;
30
- }
31
-
32
- }
33
-
34
- return true;
35
-
36
- }) || "";
37
-
38
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- // module
4
-
5
- module.exports = function extractSchemaType (schema, schemas) {
6
-
7
- let result = "string";
8
-
9
- if (schema.type) {
10
- result = schema.type;
11
- }
12
- else if (schema.$ref) {
13
-
14
- const ref = schema.$ref.replace("#/components/schemas/", "");
15
-
16
- if (schemas[ref] && schemas[ref].type) {
17
- result = schemas[ref].type;
18
- }
19
-
20
- }
21
-
22
- return result;
23
-
24
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const extractParams = require(join(__dirname, "extractParams.js"));
10
- const extractPattern = require(join(__dirname, "extractPattern.js"));
11
- const extractPathMethodByOperationId = require(join(__dirname, "extractPathMethodByOperationId.js"));
12
- const extractSchemaType = require(join(__dirname, "extractSchemaType.js"));
13
-
14
- // module
15
-
16
- module.exports = {
17
- extractParams,
18
- extractPattern,
19
- extractPathMethodByOperationId,
20
- extractSchemaType
21
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const isFile = require(join(__dirname, "isFile.js"));
10
-
11
- // module
12
-
13
- module.exports = function checkFile (file) {
14
-
15
- return isFile(file).then((exists) => {
16
-
17
- return exists ? Promise.resolve() :
18
- Promise.reject(new Error("\"" + file + "\" does not exist."));
19
-
20
- });
21
-
22
- };
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
- const { lstat } = require("fs");
8
-
9
- // locals
10
-
11
- const { checkNonEmptyString } = require(join(__dirname, "..", "..", "checkers", "main.js"));
12
-
13
- // module
14
-
15
- module.exports = function isFile (file) {
16
-
17
- return checkNonEmptyString("file", file).then(() => {
18
-
19
- return new Promise((resolve) => {
20
-
21
- lstat(file, (err, stats) => {
22
- return resolve(Boolean(!err && stats.isFile()));
23
- });
24
-
25
- });
26
-
27
- });
28
-
29
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
-
8
- // locals
9
- const checkFile = require(join(__dirname, "checkFile.js"));
10
- const isFile = require(join(__dirname, "isFile.js"));
11
- const readJSONFile = require(join(__dirname, "readJSONFile.js"));
12
-
13
- // module
14
-
15
- module.exports = {
16
- checkFile,
17
- isFile,
18
- readJSONFile
19
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
- const { readFile } = require("fs");
8
-
9
- // locals
10
- const checkFile = require(join(__dirname, "checkFile.js"));
11
-
12
- // module
13
-
14
- module.exports = function readJSONFile (file) {
15
-
16
- return checkFile(file).then(() => {
17
-
18
- return new Promise((resolve, reject) => {
19
-
20
- readFile(file, "utf8", (err, content) => {
21
- return err ? reject(err) : resolve(content);
22
- });
23
-
24
- });
25
-
26
- }).then((content) => {
27
- return Promise.resolve(JSON.parse(content));
28
- });
29
-
30
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- // private
4
-
5
- // methods
6
-
7
- /**
8
- * @return {string} formated random id fragment
9
- */
10
- function _s4 () {
11
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
12
- }
13
-
14
- // module
15
-
16
- module.exports = function getUniqueID () {
17
-
18
- return _s4() + _s4() + "-" + _s4();
19
-
20
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- // module
4
-
5
- module.exports = function removeFirstSlash (path) {
6
- return "string" === typeof path && "/" === path[0] ? path.substring(1, path.length) : String(path);
7
- };