@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
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
-
import { IRoute } from "../../structures/IRoute";
|
|
5
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
-
import { MapUtil } from "../../utils/MapUtil";
|
|
7
|
-
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
8
|
-
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
9
|
-
|
|
10
|
-
export namespace SdkFileProgrammer {
|
|
11
|
-
/* ---------------------------------------------------------
|
|
12
|
-
CONSTRUCTOR
|
|
13
|
-
--------------------------------------------------------- */
|
|
14
|
-
export const generate =
|
|
15
|
-
(config: INestiaConfig) =>
|
|
16
|
-
async (routeList: IRoute[]): Promise<void> => {
|
|
17
|
-
// CONSTRUCT FOLDER TREE
|
|
18
|
-
const root: SdkRouteDirectory = new SdkRouteDirectory(null, "functional");
|
|
19
|
-
for (const route of routeList) emplace(root)(route);
|
|
20
|
-
|
|
21
|
-
// ITERATE FILES
|
|
22
|
-
await iterate(config)(root)(config.output + "/functional");
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const emplace =
|
|
26
|
-
(directory: SdkRouteDirectory) =>
|
|
27
|
-
(route: IRoute): void => {
|
|
28
|
-
// OPEN DIRECTORIES
|
|
29
|
-
for (const key of route.accessors.slice(0, -1)) {
|
|
30
|
-
directory = MapUtil.take(
|
|
31
|
-
directory.children,
|
|
32
|
-
key,
|
|
33
|
-
() => new SdkRouteDirectory(directory, key),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ADD ROUTE
|
|
38
|
-
directory.routes.push(route);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/* ---------------------------------------------------------
|
|
42
|
-
FILE ITERATOR
|
|
43
|
-
--------------------------------------------------------- */
|
|
44
|
-
const iterate =
|
|
45
|
-
(config: INestiaConfig) =>
|
|
46
|
-
(directory: SdkRouteDirectory) =>
|
|
47
|
-
async (outDir: string): Promise<void> => {
|
|
48
|
-
// CREATE A NEW DIRECTORY
|
|
49
|
-
try {
|
|
50
|
-
await fs.promises.mkdir(outDir);
|
|
51
|
-
} catch {}
|
|
52
|
-
|
|
53
|
-
// ITERATE CHILDREN
|
|
54
|
-
const content: string[] = [];
|
|
55
|
-
for (const [key, value] of directory.children) {
|
|
56
|
-
await iterate(config)(value)(`${outDir}/${key}`);
|
|
57
|
-
content.push(`export * as ${key} from "./${key}";`);
|
|
58
|
-
}
|
|
59
|
-
if (content.length && directory.routes.length) content.push("");
|
|
60
|
-
|
|
61
|
-
// ITERATE ROUTES
|
|
62
|
-
const importer: ImportDictionary = new ImportDictionary(
|
|
63
|
-
`${outDir}/index.ts`,
|
|
64
|
-
);
|
|
65
|
-
if (
|
|
66
|
-
config.simulate === true &&
|
|
67
|
-
directory.routes.some((r) => !!r.parameters.length)
|
|
68
|
-
)
|
|
69
|
-
importer.internal({
|
|
70
|
-
file: `${config.output}/utils/NestiaSimulator.ts`,
|
|
71
|
-
instance: "NestiaSimulator",
|
|
72
|
-
type: false,
|
|
73
|
-
});
|
|
74
|
-
directory.routes.forEach((route, i) => {
|
|
75
|
-
if (config.clone !== true)
|
|
76
|
-
for (const tuple of route.imports)
|
|
77
|
-
for (const instance of tuple[1])
|
|
78
|
-
importer.internal({
|
|
79
|
-
file: tuple[0],
|
|
80
|
-
instance,
|
|
81
|
-
type: true,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
content.push(SdkFunctionProgrammer.generate(config)(importer)(route));
|
|
85
|
-
if (i !== directory.routes.length - 1) content.push("");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// FINALIZE THE CONTENT
|
|
89
|
-
if (directory.routes.length !== 0)
|
|
90
|
-
content.push(
|
|
91
|
-
importer.toScript(outDir),
|
|
92
|
-
"",
|
|
93
|
-
...content.splice(0, content.length),
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const script: string =
|
|
97
|
-
"/**\n" +
|
|
98
|
-
" * @packageDocumentation\n" +
|
|
99
|
-
` * @module ${directory.module}\n` +
|
|
100
|
-
" * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
|
|
101
|
-
" */\n" +
|
|
102
|
-
"//================================================================\n" +
|
|
103
|
-
content.join("\n");
|
|
104
|
-
await fs.promises.writeFile(importer.file, script, "utf8");
|
|
105
|
-
};
|
|
106
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
+
import { IRoute } from "../../structures/IRoute";
|
|
5
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
+
import { MapUtil } from "../../utils/MapUtil";
|
|
7
|
+
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
8
|
+
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
9
|
+
|
|
10
|
+
export namespace SdkFileProgrammer {
|
|
11
|
+
/* ---------------------------------------------------------
|
|
12
|
+
CONSTRUCTOR
|
|
13
|
+
--------------------------------------------------------- */
|
|
14
|
+
export const generate =
|
|
15
|
+
(config: INestiaConfig) =>
|
|
16
|
+
async (routeList: IRoute[]): Promise<void> => {
|
|
17
|
+
// CONSTRUCT FOLDER TREE
|
|
18
|
+
const root: SdkRouteDirectory = new SdkRouteDirectory(null, "functional");
|
|
19
|
+
for (const route of routeList) emplace(root)(route);
|
|
20
|
+
|
|
21
|
+
// ITERATE FILES
|
|
22
|
+
await iterate(config)(root)(config.output + "/functional");
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const emplace =
|
|
26
|
+
(directory: SdkRouteDirectory) =>
|
|
27
|
+
(route: IRoute): void => {
|
|
28
|
+
// OPEN DIRECTORIES
|
|
29
|
+
for (const key of route.accessors.slice(0, -1)) {
|
|
30
|
+
directory = MapUtil.take(
|
|
31
|
+
directory.children,
|
|
32
|
+
key,
|
|
33
|
+
() => new SdkRouteDirectory(directory, key),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ADD ROUTE
|
|
38
|
+
directory.routes.push(route);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/* ---------------------------------------------------------
|
|
42
|
+
FILE ITERATOR
|
|
43
|
+
--------------------------------------------------------- */
|
|
44
|
+
const iterate =
|
|
45
|
+
(config: INestiaConfig) =>
|
|
46
|
+
(directory: SdkRouteDirectory) =>
|
|
47
|
+
async (outDir: string): Promise<void> => {
|
|
48
|
+
// CREATE A NEW DIRECTORY
|
|
49
|
+
try {
|
|
50
|
+
await fs.promises.mkdir(outDir);
|
|
51
|
+
} catch {}
|
|
52
|
+
|
|
53
|
+
// ITERATE CHILDREN
|
|
54
|
+
const content: string[] = [];
|
|
55
|
+
for (const [key, value] of directory.children) {
|
|
56
|
+
await iterate(config)(value)(`${outDir}/${key}`);
|
|
57
|
+
content.push(`export * as ${key} from "./${key}";`);
|
|
58
|
+
}
|
|
59
|
+
if (content.length && directory.routes.length) content.push("");
|
|
60
|
+
|
|
61
|
+
// ITERATE ROUTES
|
|
62
|
+
const importer: ImportDictionary = new ImportDictionary(
|
|
63
|
+
`${outDir}/index.ts`,
|
|
64
|
+
);
|
|
65
|
+
if (
|
|
66
|
+
config.simulate === true &&
|
|
67
|
+
directory.routes.some((r) => !!r.parameters.length)
|
|
68
|
+
)
|
|
69
|
+
importer.internal({
|
|
70
|
+
file: `${config.output}/utils/NestiaSimulator.ts`,
|
|
71
|
+
instance: "NestiaSimulator",
|
|
72
|
+
type: false,
|
|
73
|
+
});
|
|
74
|
+
directory.routes.forEach((route, i) => {
|
|
75
|
+
if (config.clone !== true)
|
|
76
|
+
for (const tuple of route.imports)
|
|
77
|
+
for (const instance of tuple[1])
|
|
78
|
+
importer.internal({
|
|
79
|
+
file: tuple[0],
|
|
80
|
+
instance,
|
|
81
|
+
type: true,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
content.push(SdkFunctionProgrammer.generate(config)(importer)(route));
|
|
85
|
+
if (i !== directory.routes.length - 1) content.push("");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// FINALIZE THE CONTENT
|
|
89
|
+
if (directory.routes.length !== 0)
|
|
90
|
+
content.push(
|
|
91
|
+
importer.toScript(outDir),
|
|
92
|
+
"",
|
|
93
|
+
...content.splice(0, content.length),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const script: string =
|
|
97
|
+
"/**\n" +
|
|
98
|
+
" * @packageDocumentation\n" +
|
|
99
|
+
` * @module ${directory.module}\n` +
|
|
100
|
+
" * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
|
|
101
|
+
" */\n" +
|
|
102
|
+
"//================================================================\n" +
|
|
103
|
+
content.join("\n");
|
|
104
|
+
await fs.promises.writeFile(importer.file, script, "utf8");
|
|
105
|
+
};
|
|
106
|
+
}
|