@nestia/sdk 2.4.5 → 2.4.6
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/lib/analyses/ConfigAnalyzer.js +1 -1
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +7 -7
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +248 -248
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/analyses/AccessorAnalyzer.ts +60 -60
- package/src/analyses/ConfigAnalyzer.ts +3 -3
- package/src/analyses/ControllerAnalyzer.ts +2 -2
- package/src/analyses/ExceptionAnalyzer.ts +115 -115
- package/src/analyses/GenericAnalyzer.ts +51 -51
- package/src/analyses/ImportAnalyzer.ts +138 -138
- package/src/analyses/PathAnalyzer.ts +14 -14
- package/src/analyses/ReflectAnalyzer.ts +9 -9
- package/src/analyses/SecurityAnalyzer.ts +20 -20
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +67 -67
- package/src/executable/internal/NestiaSdkCommand.ts +60 -60
- package/src/executable/sdk.ts +73 -73
- package/src/generates/E2eGenerator.ts +64 -64
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +5 -5
- package/src/generates/internal/E2eFileProgrammer.ts +123 -123
- package/src/generates/internal/SdkDistributionComposer.ts +91 -91
- package/src/generates/internal/SdkDtoGenerator.ts +424 -424
- package/src/generates/internal/SdkFileProgrammer.ts +106 -106
- package/src/generates/internal/SdkFunctionProgrammer.ts +518 -518
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +17 -17
- package/src/generates/internal/SdkSimulationProgrammer.ts +4 -4
- package/src/generates/internal/SdkTypeDefiner.ts +119 -119
- package/src/generates/internal/SwaggerSchemaGenerator.ts +16 -16
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +91 -91
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/IRoute.ts +52 -52
- package/src/structures/ISwagger.ts +91 -91
- package/src/structures/ISwaggerComponents.ts +29 -29
- package/src/structures/ISwaggerError.ts +8 -8
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerLazyProperty.ts +7 -7
- package/src/structures/ISwaggerLazySchema.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +51 -51
- package/src/structures/ISwaggerSecurityScheme.ts +65 -65
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +125 -125
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StripEnums.ts +5 -5
package/src/utils/MapUtil.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export namespace MapUtil {
|
|
2
|
-
export function take<Key, T>(
|
|
3
|
-
dict: Map<Key, T>,
|
|
4
|
-
key: Key,
|
|
5
|
-
generator: () => T,
|
|
6
|
-
): T {
|
|
7
|
-
const oldbie: T | undefined = dict.get(key);
|
|
8
|
-
if (oldbie) return oldbie;
|
|
9
|
-
|
|
10
|
-
const value: T = generator();
|
|
11
|
-
dict.set(key, value);
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
export namespace MapUtil {
|
|
2
|
+
export function take<Key, T>(
|
|
3
|
+
dict: Map<Key, T>,
|
|
4
|
+
key: Key,
|
|
5
|
+
generator: () => T,
|
|
6
|
+
): T {
|
|
7
|
+
const oldbie: T | undefined = dict.get(key);
|
|
8
|
+
if (oldbie) return oldbie;
|
|
9
|
+
|
|
10
|
+
const value: T = generator();
|
|
11
|
+
dict.set(key, value);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/utils/PathUtil.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export namespace PathUtil {
|
|
2
|
-
export const accessors = (path: string) =>
|
|
3
|
-
path
|
|
4
|
-
.split("/")
|
|
5
|
-
.filter((str) => str.length && str[0] !== ":")
|
|
6
|
-
.map(normalize);
|
|
7
|
-
|
|
8
|
-
const normalize = (str: string) =>
|
|
9
|
-
str.split("-").join("_").split(".").join("_");
|
|
10
|
-
}
|
|
1
|
+
export namespace PathUtil {
|
|
2
|
+
export const accessors = (path: string) =>
|
|
3
|
+
path
|
|
4
|
+
.split("/")
|
|
5
|
+
.filter((str) => str.length && str[0] !== ":")
|
|
6
|
+
.map(normalize);
|
|
7
|
+
|
|
8
|
+
const normalize = (str: string) =>
|
|
9
|
+
str.split("-").join("_").split(".").join("_");
|
|
10
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import glob from "glob";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export namespace SourceFinder {
|
|
6
|
-
interface IProps {
|
|
7
|
-
exclude?: string[];
|
|
8
|
-
include: string[];
|
|
9
|
-
filter: (location: string) => Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const find = async (props: IProps): Promise<string[]> => {
|
|
13
|
-
const dict: Set<string> = new Set();
|
|
14
|
-
|
|
15
|
-
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
16
|
-
if (props.exclude?.length)
|
|
17
|
-
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
18
|
-
|
|
19
|
-
return [...dict];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const emplace =
|
|
23
|
-
(filter: (file: string) => Promise<boolean>) =>
|
|
24
|
-
(input: string[]) =>
|
|
25
|
-
async (closure: (location: string) => void): Promise<void> => {
|
|
26
|
-
for (const pattern of input) {
|
|
27
|
-
if (_Is_file(pattern)) {
|
|
28
|
-
closure(path.resolve(pattern));
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
for (const file of await _Glob(pattern)) {
|
|
32
|
-
const stats: fs.Stats = await fs.promises.stat(file);
|
|
33
|
-
if (stats.isDirectory() === true)
|
|
34
|
-
await iterate(filter)(closure)(file);
|
|
35
|
-
else if (stats.isFile() && (await filter(file))) closure(file);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const iterate =
|
|
41
|
-
(filter: (location: string) => Promise<boolean>) =>
|
|
42
|
-
(closure: (location: string) => void) =>
|
|
43
|
-
async (location: string): Promise<void> => {
|
|
44
|
-
const directory: string[] = await fs.promises.readdir(location);
|
|
45
|
-
for (const file of directory) {
|
|
46
|
-
const next: string = path.resolve(`${location}/${file}`);
|
|
47
|
-
const stats: fs.Stats = await fs.promises.stat(next);
|
|
48
|
-
|
|
49
|
-
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
50
|
-
else if (stats.isFile() && (await filter(next))) closure(next);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const _Glob = (pattern: string): Promise<string[]> =>
|
|
55
|
-
new Promise((resolve, reject) => {
|
|
56
|
-
glob(pattern, (err, matches) => {
|
|
57
|
-
if (err) reject(err);
|
|
58
|
-
else resolve(matches.map((str) => path.resolve(str)));
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const _Is_file = (pattern: string): boolean =>
|
|
63
|
-
pattern.endsWith(".ts") &&
|
|
64
|
-
!pattern.endsWith(".d.ts") &&
|
|
65
|
-
fs.existsSync(pattern);
|
|
66
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import glob from "glob";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export namespace SourceFinder {
|
|
6
|
+
interface IProps {
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
include: string[];
|
|
9
|
+
filter: (location: string) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const find = async (props: IProps): Promise<string[]> => {
|
|
13
|
+
const dict: Set<string> = new Set();
|
|
14
|
+
|
|
15
|
+
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
16
|
+
if (props.exclude?.length)
|
|
17
|
+
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
18
|
+
|
|
19
|
+
return [...dict];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const emplace =
|
|
23
|
+
(filter: (file: string) => Promise<boolean>) =>
|
|
24
|
+
(input: string[]) =>
|
|
25
|
+
async (closure: (location: string) => void): Promise<void> => {
|
|
26
|
+
for (const pattern of input) {
|
|
27
|
+
if (_Is_file(pattern)) {
|
|
28
|
+
closure(path.resolve(pattern));
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (const file of await _Glob(pattern)) {
|
|
32
|
+
const stats: fs.Stats = await fs.promises.stat(file);
|
|
33
|
+
if (stats.isDirectory() === true)
|
|
34
|
+
await iterate(filter)(closure)(file);
|
|
35
|
+
else if (stats.isFile() && (await filter(file))) closure(file);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const iterate =
|
|
41
|
+
(filter: (location: string) => Promise<boolean>) =>
|
|
42
|
+
(closure: (location: string) => void) =>
|
|
43
|
+
async (location: string): Promise<void> => {
|
|
44
|
+
const directory: string[] = await fs.promises.readdir(location);
|
|
45
|
+
for (const file of directory) {
|
|
46
|
+
const next: string = path.resolve(`${location}/${file}`);
|
|
47
|
+
const stats: fs.Stats = await fs.promises.stat(next);
|
|
48
|
+
|
|
49
|
+
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
50
|
+
else if (stats.isFile() && (await filter(next))) closure(next);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const _Glob = (pattern: string): Promise<string[]> =>
|
|
55
|
+
new Promise((resolve, reject) => {
|
|
56
|
+
glob(pattern, (err, matches) => {
|
|
57
|
+
if (err) reject(err);
|
|
58
|
+
else resolve(matches.map((str) => path.resolve(str)));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const _Is_file = (pattern: string): boolean =>
|
|
63
|
+
pattern.endsWith(".ts") &&
|
|
64
|
+
!pattern.endsWith(".d.ts") &&
|
|
65
|
+
fs.existsSync(pattern);
|
|
66
|
+
}
|
package/src/utils/StripEnums.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type StripEnums<T extends Record<string, any>> = {
|
|
2
|
-
[Key in keyof T]: T[Key] extends string | boolean | object | undefined | any[]
|
|
3
|
-
? T[Key]
|
|
4
|
-
: any;
|
|
5
|
-
};
|
|
1
|
+
export type StripEnums<T extends Record<string, any>> = {
|
|
2
|
+
[Key in keyof T]: T[Key] extends string | boolean | object | undefined | any[]
|
|
3
|
+
? T[Key]
|
|
4
|
+
: any;
|
|
5
|
+
};
|