@nestia/sdk 2.5.0-dev.20240130 → 2.5.0-dev.20240130-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.
- package/lib/INestiaConfig.d.ts +0 -6
- package/lib/executable/internal/NestiaConfigLoader.js +2 -6
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +8 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +8 -3
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/structures/ISwagger.d.ts +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +248 -255
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/generates/E2eGenerator.ts +66 -66
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +376 -378
- package/src/generates/internal/E2eFileProgrammer.ts +191 -191
- package/src/generates/internal/SdkAliasCollection.ts +145 -145
- package/src/generates/internal/SdkFileProgrammer.ts +135 -135
- package/src/generates/internal/SdkFunctionProgrammer.ts +219 -219
- package/src/generates/internal/SdkNamespaceProgrammer.ts +507 -507
- package/src/generates/internal/SdkRouteProgrammer.ts +86 -86
- package/src/generates/internal/SdkSimulationProgrammer.ts +357 -357
- package/src/generates/internal/SdkTypeProgrammer.ts +8 -7
- package/src/structures/ISwagger.ts +91 -91
- package/src/utils/FormatUtil.ts +31 -31
- package/src/utils/ImportDictionary.ts +197 -197
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IJsDocTagInfo } from "typia";
|
|
3
|
-
|
|
4
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
|
-
import { IRoute } from "../../structures/IRoute";
|
|
6
|
-
import { FormatUtil } from "../../utils/FormatUtil";
|
|
7
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
8
|
-
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
9
|
-
import { SdkNamespaceProgrammer } from "./SdkNamespaceProgrammer";
|
|
10
|
-
|
|
11
|
-
export namespace SdkRouteProgrammer {
|
|
12
|
-
export const generate =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(config: INestiaConfig) =>
|
|
15
|
-
(importer: ImportDictionary) =>
|
|
16
|
-
(route: IRoute): ts.Statement[] => {
|
|
17
|
-
const props = {
|
|
18
|
-
headers: route.parameters.find(
|
|
19
|
-
(p) => p.category === "headers" && p.field === undefined,
|
|
20
|
-
),
|
|
21
|
-
query: route.parameters.find(
|
|
22
|
-
(p) => p.category === "query" && p.field === undefined,
|
|
23
|
-
),
|
|
24
|
-
input: route.parameters.find((p) => p.category === "body"),
|
|
25
|
-
};
|
|
26
|
-
return [
|
|
27
|
-
FormatUtil.description(
|
|
28
|
-
SdkFunctionProgrammer.generate(config)(importer)(route, props),
|
|
29
|
-
describe(route),
|
|
30
|
-
),
|
|
31
|
-
SdkNamespaceProgrammer.generate(checker)(config)(importer)(
|
|
32
|
-
route,
|
|
33
|
-
props,
|
|
34
|
-
),
|
|
35
|
-
];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const describe = (route: IRoute): string => {
|
|
39
|
-
// MAIN DESCRIPTION
|
|
40
|
-
const comments: string[] = route.description
|
|
41
|
-
? route.description.split("\n")
|
|
42
|
-
: [];
|
|
43
|
-
|
|
44
|
-
// COMMENT TAGS
|
|
45
|
-
const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
|
|
46
|
-
(tag) =>
|
|
47
|
-
tag.name !== "param" ||
|
|
48
|
-
route.parameters
|
|
49
|
-
.filter((p) => p.category !== "headers")
|
|
50
|
-
.some((p) => p.name === tag.text?.[0]?.text),
|
|
51
|
-
);
|
|
52
|
-
if (tags.length !== 0) {
|
|
53
|
-
const content: string[] = tags.map((t) =>
|
|
54
|
-
t.text?.length
|
|
55
|
-
? `@${t.name} ${t.text.map((e) => e.text).join("")}`
|
|
56
|
-
: `@${t.name}`,
|
|
57
|
-
);
|
|
58
|
-
comments.push("", ...new Set(content));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// EXCEPTIONS
|
|
62
|
-
for (const [key, value] of Object.entries(route.exceptions)) {
|
|
63
|
-
if (
|
|
64
|
-
comments.some(
|
|
65
|
-
(str) =>
|
|
66
|
-
str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
|
|
67
|
-
)
|
|
68
|
-
)
|
|
69
|
-
continue;
|
|
70
|
-
comments.push(
|
|
71
|
-
value.description?.length
|
|
72
|
-
? `@throws ${key} ${value.description.split("\n")[0]}`
|
|
73
|
-
: `@throws ${key}`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// POSTFIX
|
|
78
|
-
if (!!comments.length) comments.push("");
|
|
79
|
-
comments.push(
|
|
80
|
-
`@controller ${route.symbol.class}.${route.symbol.function}`,
|
|
81
|
-
`@path ${route.method} ${route.path}`,
|
|
82
|
-
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
83
|
-
);
|
|
84
|
-
return comments.join("\n");
|
|
85
|
-
};
|
|
86
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IJsDocTagInfo } from "typia";
|
|
3
|
+
|
|
4
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
|
+
import { IRoute } from "../../structures/IRoute";
|
|
6
|
+
import { FormatUtil } from "../../utils/FormatUtil";
|
|
7
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
8
|
+
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
9
|
+
import { SdkNamespaceProgrammer } from "./SdkNamespaceProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace SdkRouteProgrammer {
|
|
12
|
+
export const generate =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(config: INestiaConfig) =>
|
|
15
|
+
(importer: ImportDictionary) =>
|
|
16
|
+
(route: IRoute): ts.Statement[] => {
|
|
17
|
+
const props = {
|
|
18
|
+
headers: route.parameters.find(
|
|
19
|
+
(p) => p.category === "headers" && p.field === undefined,
|
|
20
|
+
),
|
|
21
|
+
query: route.parameters.find(
|
|
22
|
+
(p) => p.category === "query" && p.field === undefined,
|
|
23
|
+
),
|
|
24
|
+
input: route.parameters.find((p) => p.category === "body"),
|
|
25
|
+
};
|
|
26
|
+
return [
|
|
27
|
+
FormatUtil.description(
|
|
28
|
+
SdkFunctionProgrammer.generate(config)(importer)(route, props),
|
|
29
|
+
describe(route),
|
|
30
|
+
),
|
|
31
|
+
SdkNamespaceProgrammer.generate(checker)(config)(importer)(
|
|
32
|
+
route,
|
|
33
|
+
props,
|
|
34
|
+
),
|
|
35
|
+
];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const describe = (route: IRoute): string => {
|
|
39
|
+
// MAIN DESCRIPTION
|
|
40
|
+
const comments: string[] = route.description
|
|
41
|
+
? route.description.split("\n")
|
|
42
|
+
: [];
|
|
43
|
+
|
|
44
|
+
// COMMENT TAGS
|
|
45
|
+
const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
|
|
46
|
+
(tag) =>
|
|
47
|
+
tag.name !== "param" ||
|
|
48
|
+
route.parameters
|
|
49
|
+
.filter((p) => p.category !== "headers")
|
|
50
|
+
.some((p) => p.name === tag.text?.[0]?.text),
|
|
51
|
+
);
|
|
52
|
+
if (tags.length !== 0) {
|
|
53
|
+
const content: string[] = tags.map((t) =>
|
|
54
|
+
t.text?.length
|
|
55
|
+
? `@${t.name} ${t.text.map((e) => e.text).join("")}`
|
|
56
|
+
: `@${t.name}`,
|
|
57
|
+
);
|
|
58
|
+
comments.push("", ...new Set(content));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// EXCEPTIONS
|
|
62
|
+
for (const [key, value] of Object.entries(route.exceptions)) {
|
|
63
|
+
if (
|
|
64
|
+
comments.some(
|
|
65
|
+
(str) =>
|
|
66
|
+
str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
continue;
|
|
70
|
+
comments.push(
|
|
71
|
+
value.description?.length
|
|
72
|
+
? `@throws ${key} ${value.description.split("\n")[0]}`
|
|
73
|
+
: `@throws ${key}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// POSTFIX
|
|
78
|
+
if (!!comments.length) comments.push("");
|
|
79
|
+
comments.push(
|
|
80
|
+
`@controller ${route.symbol.class}.${route.symbol.function}`,
|
|
81
|
+
`@path ${route.method} ${route.path}`,
|
|
82
|
+
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
83
|
+
);
|
|
84
|
+
return comments.join("\n");
|
|
85
|
+
};
|
|
86
|
+
}
|