@nestia/sdk 3.1.0-dev.20240426 → 3.1.0-dev.20240430
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/TypedWebSocketOperationAnalyzer.js +1 -1
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js +1 -1
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +18 -20
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +30 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/structures/ITypedWebSocketRoute.d.ts +1 -0
- package/package.json +4 -4
- package/src/NestiaSdkApplication.ts +257 -257
- package/src/analyses/AccessorAnalyzer.ts +67 -67
- package/src/analyses/ConfigAnalyzer.ts +147 -147
- package/src/analyses/GenericAnalyzer.ts +51 -51
- package/src/analyses/PathAnalyzer.ts +69 -69
- package/src/analyses/SecurityAnalyzer.ts +25 -25
- package/src/analyses/TypedWebSocketOperationAnalyzer.ts +1 -0
- 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/CloneGenerator.ts +64 -64
- package/src/generates/E2eGenerator.ts +64 -64
- package/src/generates/SdkGenerator.ts +91 -91
- package/src/generates/SwaggerGenerator.ts +1 -1
- package/src/generates/internal/E2eFileProgrammer.ts +178 -178
- package/src/generates/internal/FilePrinter.ts +53 -53
- package/src/generates/internal/SdkAliasCollection.ts +157 -157
- package/src/generates/internal/SdkDistributionComposer.ts +100 -100
- package/src/generates/internal/SdkFileProgrammer.ts +119 -119
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +154 -154
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +298 -299
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +505 -505
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +82 -82
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +363 -363
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +18 -18
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +42 -1
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/IReflectController.ts +17 -17
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/ITypedHttpRoute.ts +55 -55
- package/src/structures/ITypedWebSocketRoute.ts +1 -0
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StringUtil.ts +6 -6
- package/src/utils/StripEnums.ts +5 -5
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IJsDocTagInfo } from "typia";
|
|
3
|
-
|
|
4
|
-
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
|
-
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
6
|
-
import { FilePrinter } from "./FilePrinter";
|
|
7
|
-
import { ImportDictionary } from "./ImportDictionary";
|
|
8
|
-
import { SdkHttpFunctionProgrammer } from "./SdkHttpFunctionProgrammer";
|
|
9
|
-
import { SdkHttpNamespaceProgrammer } from "./SdkHttpNamespaceProgrammer";
|
|
10
|
-
|
|
11
|
-
export namespace SdkHttpRouteProgrammer {
|
|
12
|
-
export const write =
|
|
13
|
-
(project: INestiaProject) =>
|
|
14
|
-
(importer: ImportDictionary) =>
|
|
15
|
-
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
16
|
-
const props = {
|
|
17
|
-
headers: route.parameters.find(
|
|
18
|
-
(p) => p.category === "headers" && p.field === undefined,
|
|
19
|
-
),
|
|
20
|
-
query: route.parameters.find(
|
|
21
|
-
(p) => p.category === "query" && p.field === undefined,
|
|
22
|
-
),
|
|
23
|
-
input: route.parameters.find((p) => p.category === "body"),
|
|
24
|
-
};
|
|
25
|
-
return [
|
|
26
|
-
FilePrinter.description(
|
|
27
|
-
SdkHttpFunctionProgrammer.write(project)(importer)(route, props),
|
|
28
|
-
describe(route),
|
|
29
|
-
),
|
|
30
|
-
SdkHttpNamespaceProgrammer.write(project)(importer)(route, props),
|
|
31
|
-
];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const describe = (route: ITypedHttpRoute): string => {
|
|
35
|
-
// MAIN DESCRIPTION
|
|
36
|
-
const comments: string[] = route.description
|
|
37
|
-
? route.description.split("\n")
|
|
38
|
-
: [];
|
|
39
|
-
|
|
40
|
-
// COMMENT TAGS
|
|
41
|
-
const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
|
|
42
|
-
(tag) =>
|
|
43
|
-
tag.name !== "param" ||
|
|
44
|
-
route.parameters
|
|
45
|
-
.filter((p) => p.category !== "headers")
|
|
46
|
-
.some((p) => p.name === tag.text?.[0]?.text),
|
|
47
|
-
);
|
|
48
|
-
if (tags.length !== 0) {
|
|
49
|
-
const content: string[] = tags.map((t) =>
|
|
50
|
-
t.text?.length
|
|
51
|
-
? `@${t.name} ${t.text.map((e) => e.text).join("")}`
|
|
52
|
-
: `@${t.name}`,
|
|
53
|
-
);
|
|
54
|
-
comments.push("", ...new Set(content));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// EXCEPTIONS
|
|
58
|
-
for (const [key, value] of Object.entries(route.exceptions)) {
|
|
59
|
-
if (
|
|
60
|
-
comments.some(
|
|
61
|
-
(str) =>
|
|
62
|
-
str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
continue;
|
|
66
|
-
comments.push(
|
|
67
|
-
value.description?.length
|
|
68
|
-
? `@throws ${key} ${value.description.split("\n")[0]}`
|
|
69
|
-
: `@throws ${key}`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// POSTFIX
|
|
74
|
-
if (!!comments.length) comments.push("");
|
|
75
|
-
comments.push(
|
|
76
|
-
`@controller ${route.controller.name}.${route.name}`,
|
|
77
|
-
`@path ${route.method} ${route.path}`,
|
|
78
|
-
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
79
|
-
);
|
|
80
|
-
return comments.join("\n");
|
|
81
|
-
};
|
|
82
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IJsDocTagInfo } from "typia";
|
|
3
|
+
|
|
4
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
6
|
+
import { FilePrinter } from "./FilePrinter";
|
|
7
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
8
|
+
import { SdkHttpFunctionProgrammer } from "./SdkHttpFunctionProgrammer";
|
|
9
|
+
import { SdkHttpNamespaceProgrammer } from "./SdkHttpNamespaceProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace SdkHttpRouteProgrammer {
|
|
12
|
+
export const write =
|
|
13
|
+
(project: INestiaProject) =>
|
|
14
|
+
(importer: ImportDictionary) =>
|
|
15
|
+
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
16
|
+
const props = {
|
|
17
|
+
headers: route.parameters.find(
|
|
18
|
+
(p) => p.category === "headers" && p.field === undefined,
|
|
19
|
+
),
|
|
20
|
+
query: route.parameters.find(
|
|
21
|
+
(p) => p.category === "query" && p.field === undefined,
|
|
22
|
+
),
|
|
23
|
+
input: route.parameters.find((p) => p.category === "body"),
|
|
24
|
+
};
|
|
25
|
+
return [
|
|
26
|
+
FilePrinter.description(
|
|
27
|
+
SdkHttpFunctionProgrammer.write(project)(importer)(route, props),
|
|
28
|
+
describe(route),
|
|
29
|
+
),
|
|
30
|
+
SdkHttpNamespaceProgrammer.write(project)(importer)(route, props),
|
|
31
|
+
];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const describe = (route: ITypedHttpRoute): string => {
|
|
35
|
+
// MAIN DESCRIPTION
|
|
36
|
+
const comments: string[] = route.description
|
|
37
|
+
? route.description.split("\n")
|
|
38
|
+
: [];
|
|
39
|
+
|
|
40
|
+
// COMMENT TAGS
|
|
41
|
+
const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
|
|
42
|
+
(tag) =>
|
|
43
|
+
tag.name !== "param" ||
|
|
44
|
+
route.parameters
|
|
45
|
+
.filter((p) => p.category !== "headers")
|
|
46
|
+
.some((p) => p.name === tag.text?.[0]?.text),
|
|
47
|
+
);
|
|
48
|
+
if (tags.length !== 0) {
|
|
49
|
+
const content: string[] = tags.map((t) =>
|
|
50
|
+
t.text?.length
|
|
51
|
+
? `@${t.name} ${t.text.map((e) => e.text).join("")}`
|
|
52
|
+
: `@${t.name}`,
|
|
53
|
+
);
|
|
54
|
+
comments.push("", ...new Set(content));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// EXCEPTIONS
|
|
58
|
+
for (const [key, value] of Object.entries(route.exceptions)) {
|
|
59
|
+
if (
|
|
60
|
+
comments.some(
|
|
61
|
+
(str) =>
|
|
62
|
+
str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
continue;
|
|
66
|
+
comments.push(
|
|
67
|
+
value.description?.length
|
|
68
|
+
? `@throws ${key} ${value.description.split("\n")[0]}`
|
|
69
|
+
: `@throws ${key}`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// POSTFIX
|
|
74
|
+
if (!!comments.length) comments.push("");
|
|
75
|
+
comments.push(
|
|
76
|
+
`@controller ${route.controller.name}.${route.name}`,
|
|
77
|
+
`@path ${route.method} ${route.path}`,
|
|
78
|
+
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
79
|
+
);
|
|
80
|
+
return comments.join("\n");
|
|
81
|
+
};
|
|
82
|
+
}
|