@nestia/sdk 2.4.7 → 2.5.0-dev.20240128
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/generates/internal/SdkFileProgrammer.js +23 -10
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.d.ts +6 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +73 -323
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkNamespaceProgrammer.d.ts +11 -0
- package/lib/generates/internal/SdkNamespaceProgrammer.js +175 -0
- package/lib/generates/internal/SdkNamespaceProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkRouteProgrammer.d.ts +7 -0
- package/lib/generates/internal/SdkRouteProgrammer.js +55 -0
- package/lib/generates/internal/SdkRouteProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkSimulationProgrammer.d.ts +7 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js +98 -88
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/utils/ImportDictionary.d.ts +2 -0
- package/lib/utils/ImportDictionary.js +45 -0
- package/lib/utils/ImportDictionary.js.map +1 -1
- package/lib/utils/NodeUtil.d.ts +5 -0
- package/lib/utils/NodeUtil.js +16 -0
- package/lib/utils/NodeUtil.js.map +1 -0
- package/package.json +6 -3
- package/src/analyses/ConfigAnalyzer.ts +147 -147
- package/src/analyses/ControllerAnalyzer.ts +390 -390
- package/src/analyses/PathAnalyzer.ts +110 -110
- package/src/analyses/ReflectAnalyzer.ts +464 -464
- package/src/generates/SwaggerGenerator.ts +376 -376
- package/src/generates/internal/SdkFileProgrammer.ts +42 -13
- package/src/generates/internal/SdkFunctionProgrammer.ts +176 -475
- package/src/generates/internal/SdkNamespaceProgrammer.ts +495 -0
- package/src/generates/internal/SdkRouteProgrammer.ts +82 -0
- package/src/generates/internal/SdkSimulationProgrammer.ts +359 -133
- package/src/generates/internal/SwaggerSchemaGenerator.ts +444 -444
- package/src/utils/ImportDictionary.ts +72 -0
- package/src/utils/NodeUtil.ts +19 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
+
import { format } from "prettier";
|
|
3
|
+
import ts from "typescript";
|
|
2
4
|
|
|
3
5
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
6
|
import { IRoute } from "../../structures/IRoute";
|
|
5
7
|
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
8
|
import { MapUtil } from "../../utils/MapUtil";
|
|
7
|
-
import {
|
|
9
|
+
import { NodeUtil } from "../../utils/NodeUtil";
|
|
8
10
|
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
11
|
+
import { SdkRouteProgrammer } from "./SdkRouteProgrammer";
|
|
9
12
|
|
|
10
13
|
export namespace SdkFileProgrammer {
|
|
11
14
|
/* ---------------------------------------------------------
|
|
@@ -51,12 +54,21 @@ export namespace SdkFileProgrammer {
|
|
|
51
54
|
} catch {}
|
|
52
55
|
|
|
53
56
|
// ITERATE CHILDREN
|
|
54
|
-
const
|
|
57
|
+
const statements: ts.Statement[] = [];
|
|
55
58
|
for (const [key, value] of directory.children) {
|
|
56
59
|
await iterate(config)(value)(`${outDir}/${key}`);
|
|
57
|
-
|
|
60
|
+
statements.push(
|
|
61
|
+
ts.factory.createExportDeclaration(
|
|
62
|
+
undefined,
|
|
63
|
+
false,
|
|
64
|
+
ts.factory.createNamespaceExport(ts.factory.createIdentifier(key)),
|
|
65
|
+
ts.factory.createStringLiteral(`./${key}`),
|
|
66
|
+
undefined,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
58
69
|
}
|
|
59
|
-
if (
|
|
70
|
+
if (statements.length && directory.routes.length)
|
|
71
|
+
statements.push(NodeUtil.enter());
|
|
60
72
|
|
|
61
73
|
// ITERATE ROUTES
|
|
62
74
|
const importer: ImportDictionary = new ImportDictionary(
|
|
@@ -80,17 +92,19 @@ export namespace SdkFileProgrammer {
|
|
|
80
92
|
instance,
|
|
81
93
|
type: true,
|
|
82
94
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
statements.push(
|
|
96
|
+
...SdkRouteProgrammer.generate(config)(importer)(route),
|
|
97
|
+
);
|
|
98
|
+
if (i !== directory.routes.length - 1)
|
|
99
|
+
statements.push(NodeUtil.enter());
|
|
86
100
|
});
|
|
87
101
|
|
|
88
102
|
// FINALIZE THE CONTENT
|
|
89
103
|
if (directory.routes.length !== 0)
|
|
90
|
-
|
|
91
|
-
importer.
|
|
92
|
-
|
|
93
|
-
...
|
|
104
|
+
statements.push(
|
|
105
|
+
...importer.toStatements(outDir),
|
|
106
|
+
...(!importer.empty() && statements.length ? [NodeUtil.enter()] : []),
|
|
107
|
+
...statements.splice(0, statements.length),
|
|
94
108
|
);
|
|
95
109
|
|
|
96
110
|
const script: string =
|
|
@@ -100,7 +114,22 @@ export namespace SdkFileProgrammer {
|
|
|
100
114
|
" * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
|
|
101
115
|
" */\n" +
|
|
102
116
|
"//================================================================\n" +
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
ts
|
|
118
|
+
.createPrinter()
|
|
119
|
+
.printFile(
|
|
120
|
+
ts.factory.createSourceFile(
|
|
121
|
+
statements,
|
|
122
|
+
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
|
123
|
+
ts.NodeFlags.None,
|
|
124
|
+
),
|
|
125
|
+
);
|
|
126
|
+
const beautify = async () => {
|
|
127
|
+
try {
|
|
128
|
+
return await format(script, { parser: "typescript" });
|
|
129
|
+
} catch {
|
|
130
|
+
return script;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
await fs.promises.writeFile(importer.file, await beautify(), "utf8");
|
|
105
134
|
};
|
|
106
135
|
}
|