@nestia/sdk 2.3.0-dev.20231018 → 2.3.0-dev.20231020
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/assets/config/nestia.config.ts +15 -10
- package/lib/INestiaConfig.d.ts +8 -8
- package/lib/NestiaSdkApplication.js +41 -4
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ControllerAnalyzer.d.ts +2 -2
- package/lib/analyses/ControllerAnalyzer.js +107 -65
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +2 -1
- package/lib/analyses/ExceptionAnalyzer.js +23 -9
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectAnalyzer.d.ts +2 -1
- package/lib/analyses/ReflectAnalyzer.js +51 -37
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +96 -96
- package/lib/executable/sdk.js +1 -0
- package/lib/executable/sdk.js.map +1 -1
- package/lib/structures/IErrorReport.d.ts +6 -0
- package/lib/structures/IErrorReport.js +3 -0
- package/lib/structures/IErrorReport.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +10 -0
- package/lib/structures/INestiaProject.js +3 -0
- package/lib/structures/INestiaProject.js.map +1 -0
- package/package.json +5 -5
- package/src/INestiaConfig.ts +11 -11
- package/src/NestiaSdkApplication.ts +45 -9
- package/src/analyses/ControllerAnalyzer.ts +336 -307
- package/src/analyses/ExceptionAnalyzer.ts +31 -15
- package/src/analyses/ReflectAnalyzer.ts +235 -211
- package/src/executable/sdk.ts +1 -0
- package/src/structures/IErrorReport.ts +6 -0
- package/src/structures/INestiaProject.ts +12 -0
|
@@ -11,7 +11,10 @@ import { E2eGenerator } from "./generates/E2eGenerator";
|
|
|
11
11
|
import { SdkGenerator } from "./generates/SdkGenerator";
|
|
12
12
|
import { SwaggerGenerator } from "./generates/SwaggerGenerator";
|
|
13
13
|
import { IController } from "./structures/IController";
|
|
14
|
+
import { IErrorReport } from "./structures/IErrorReport";
|
|
15
|
+
import { INestiaProject } from "./structures/INestiaProject";
|
|
14
16
|
import { IRoute } from "./structures/IRoute";
|
|
17
|
+
import { MapUtil } from "./utils/MapUtil";
|
|
15
18
|
|
|
16
19
|
export class NestiaSdkApplication {
|
|
17
20
|
public constructor(
|
|
@@ -104,11 +107,17 @@ export class NestiaSdkApplication {
|
|
|
104
107
|
// ANALYZE REFLECTS
|
|
105
108
|
const unique: WeakSet<any> = new WeakSet();
|
|
106
109
|
const controllers: IController[] = [];
|
|
110
|
+
const project: INestiaProject = {
|
|
111
|
+
config: this.config,
|
|
112
|
+
input: await ConfigAnalyzer.input(this.config),
|
|
113
|
+
checker: null!,
|
|
114
|
+
errors: [],
|
|
115
|
+
};
|
|
107
116
|
|
|
108
117
|
console.log("Analyzing reflections");
|
|
109
118
|
for (const include of (await ConfigAnalyzer.input(this.config)).include)
|
|
110
119
|
controllers.push(
|
|
111
|
-
...(await ReflectAnalyzer.analyze(
|
|
120
|
+
...(await ReflectAnalyzer.analyze(project)(
|
|
112
121
|
unique,
|
|
113
122
|
include.file,
|
|
114
123
|
include.paths,
|
|
@@ -146,7 +155,7 @@ export class NestiaSdkApplication {
|
|
|
146
155
|
controllers.map((c) => c.file),
|
|
147
156
|
this.compilerOptions,
|
|
148
157
|
);
|
|
149
|
-
|
|
158
|
+
project.checker = program.getTypeChecker();
|
|
150
159
|
|
|
151
160
|
const routeList: IRoute[] = [];
|
|
152
161
|
for (const c of controllers) {
|
|
@@ -155,15 +164,16 @@ export class NestiaSdkApplication {
|
|
|
155
164
|
);
|
|
156
165
|
if (file === undefined) continue;
|
|
157
166
|
routeList.push(
|
|
158
|
-
...(await ControllerAnalyzer.analyze(
|
|
159
|
-
this.config,
|
|
160
|
-
checker,
|
|
161
|
-
file,
|
|
162
|
-
c,
|
|
163
|
-
)),
|
|
167
|
+
...(await ControllerAnalyzer.analyze(project)(file, c)),
|
|
164
168
|
);
|
|
165
169
|
}
|
|
166
170
|
|
|
171
|
+
// REPORT ERRORS
|
|
172
|
+
if (project.errors.length) {
|
|
173
|
+
report_errors(project.errors);
|
|
174
|
+
process.exit(-1);
|
|
175
|
+
}
|
|
176
|
+
|
|
167
177
|
// FIND IMPLICIT TYPES
|
|
168
178
|
const implicit: IRoute[] = routeList.filter(is_implicit_return_typed);
|
|
169
179
|
if (implicit.length > 0)
|
|
@@ -181,7 +191,7 @@ export class NestiaSdkApplication {
|
|
|
181
191
|
|
|
182
192
|
// DO GENERATE
|
|
183
193
|
AccessorAnalyzer.analyze(routeList);
|
|
184
|
-
await archiver(checker)(config(this.config))(routeList);
|
|
194
|
+
await archiver(project.checker)(config(this.config))(routeList);
|
|
185
195
|
}
|
|
186
196
|
}
|
|
187
197
|
|
|
@@ -207,4 +217,30 @@ const is_implicit_return_typed = (route: IRoute): boolean => {
|
|
|
207
217
|
return true;
|
|
208
218
|
};
|
|
209
219
|
|
|
220
|
+
const report_errors = (errors: IErrorReport[]): void => {
|
|
221
|
+
// key: file
|
|
222
|
+
// key: controller
|
|
223
|
+
// key: function
|
|
224
|
+
// value: message
|
|
225
|
+
const map: Map<string, Map<string, Map<string, Set<string>>>> = new Map();
|
|
226
|
+
for (const e of errors) {
|
|
227
|
+
const file = MapUtil.take(map, e.file, () => new Map());
|
|
228
|
+
const controller = MapUtil.take(file, e.controller, () => new Map());
|
|
229
|
+
const func = MapUtil.take(controller, e.function, () => new Set());
|
|
230
|
+
func.add(e.message);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
console.log("");
|
|
234
|
+
title("Nestia Error Report");
|
|
235
|
+
for (const [file, cMap] of map) {
|
|
236
|
+
for (const [controller, fMap] of cMap)
|
|
237
|
+
for (const [func, messages] of fMap) {
|
|
238
|
+
const location: string = path.relative(process.cwd(), file);
|
|
239
|
+
console.log(`${location} - error on ${controller}.${func}()`);
|
|
240
|
+
for (const msg of messages) console.log(` - ${msg}`);
|
|
241
|
+
console.log("");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
210
246
|
const VARIABLE = /[a-zA-Z_$0-9]/;
|