@nestia/sdk 2.6.3-dev.20240328 → 2.6.4-dev.20240401

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.
Files changed (45) hide show
  1. package/lib/INestiaConfig.d.ts +14 -2
  2. package/lib/executable/internal/NestiaConfigLoader.js +31 -5
  3. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  4. package/lib/generates/SwaggerGenerator.d.ts +2 -0
  5. package/lib/generates/SwaggerGenerator.js +19 -3
  6. package/lib/generates/SwaggerGenerator.js.map +1 -1
  7. package/lib/structures/ISwagger.d.ts +5 -28
  8. package/lib/structures/ISwaggerServer.d.ts +15 -0
  9. package/lib/structures/ISwaggerServer.js +3 -0
  10. package/lib/structures/ISwaggerServer.js.map +1 -0
  11. package/lib/structures/ISwaggerTag.d.ts +9 -0
  12. package/lib/structures/ISwaggerTag.js +3 -0
  13. package/lib/structures/ISwaggerTag.js.map +1 -0
  14. package/package.json +3 -3
  15. package/src/INestiaConfig.ts +261 -248
  16. package/src/NestiaSdkApplication.ts +255 -255
  17. package/src/analyses/ExceptionAnalyzer.ts +148 -148
  18. package/src/analyses/ImportAnalyzer.ts +137 -137
  19. package/src/analyses/SecurityAnalyzer.ts +24 -24
  20. package/src/generates/CloneGenerator.ts +62 -62
  21. package/src/generates/E2eGenerator.ts +66 -66
  22. package/src/generates/SdkGenerator.ts +84 -84
  23. package/src/generates/SwaggerGenerator.ts +23 -3
  24. package/src/generates/internal/E2eFileProgrammer.ts +182 -182
  25. package/src/generates/internal/FilePrinter.ts +53 -53
  26. package/src/generates/internal/SdkAliasCollection.ts +152 -152
  27. package/src/generates/internal/SdkCloneProgrammer.ts +155 -155
  28. package/src/generates/internal/SdkFileProgrammer.ts +115 -115
  29. package/src/generates/internal/SdkFunctionProgrammer.ts +298 -298
  30. package/src/generates/internal/SdkImportWizard.ts +55 -55
  31. package/src/generates/internal/SdkNamespaceProgrammer.ts +510 -510
  32. package/src/generates/internal/SdkRouteProgrammer.ts +83 -83
  33. package/src/generates/internal/SdkSimulationProgrammer.ts +365 -365
  34. package/src/generates/internal/SdkTypeProgrammer.ts +385 -385
  35. package/src/generates/internal/SwaggerSchemaGenerator.ts +438 -438
  36. package/src/structures/IController.ts +94 -94
  37. package/src/structures/IRoute.ts +53 -53
  38. package/src/structures/ISwagger.ts +66 -91
  39. package/src/structures/ISwaggerRoute.ts +54 -54
  40. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  41. package/src/structures/ISwaggerServer.ts +16 -0
  42. package/src/structures/ISwaggerTag.ts +9 -0
  43. package/src/structures/ParamCategory.ts +1 -1
  44. package/src/structures/TypeEntry.ts +22 -22
  45. package/src/utils/StringUtil.ts +6 -6
@@ -1,83 +1,83 @@
1
- import ts from "typescript";
2
- import { IJsDocTagInfo } from "typia";
3
-
4
- import { INestiaConfig } from "../../INestiaConfig";
5
- import { IRoute } from "../../structures/IRoute";
6
- import { FilePrinter } from "./FilePrinter";
7
- import { ImportDictionary } from "./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
- FilePrinter.description(
28
- SdkFunctionProgrammer.write(config)(importer)(route, props),
29
- describe(route),
30
- ),
31
- SdkNamespaceProgrammer.write(checker)(config)(importer)(route, props),
32
- ];
33
- };
34
-
35
- const describe = (route: IRoute): string => {
36
- // MAIN DESCRIPTION
37
- const comments: string[] = route.description
38
- ? route.description.split("\n")
39
- : [];
40
-
41
- // COMMENT TAGS
42
- const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
43
- (tag) =>
44
- tag.name !== "param" ||
45
- route.parameters
46
- .filter((p) => p.category !== "headers")
47
- .some((p) => p.name === tag.text?.[0]?.text),
48
- );
49
- if (tags.length !== 0) {
50
- const content: string[] = tags.map((t) =>
51
- t.text?.length
52
- ? `@${t.name} ${t.text.map((e) => e.text).join("")}`
53
- : `@${t.name}`,
54
- );
55
- comments.push("", ...new Set(content));
56
- }
57
-
58
- // EXCEPTIONS
59
- for (const [key, value] of Object.entries(route.exceptions)) {
60
- if (
61
- comments.some(
62
- (str) =>
63
- str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
64
- )
65
- )
66
- continue;
67
- comments.push(
68
- value.description?.length
69
- ? `@throws ${key} ${value.description.split("\n")[0]}`
70
- : `@throws ${key}`,
71
- );
72
- }
73
-
74
- // POSTFIX
75
- if (!!comments.length) comments.push("");
76
- comments.push(
77
- `@controller ${route.target.class.name}.${route.target.function.name}`,
78
- `@path ${route.method} ${route.path}`,
79
- `@nestia Generated by Nestia - https://github.com/samchon/nestia`,
80
- );
81
- return comments.join("\n");
82
- };
83
- }
1
+ import ts from "typescript";
2
+ import { IJsDocTagInfo } from "typia";
3
+
4
+ import { INestiaConfig } from "../../INestiaConfig";
5
+ import { IRoute } from "../../structures/IRoute";
6
+ import { FilePrinter } from "./FilePrinter";
7
+ import { ImportDictionary } from "./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
+ FilePrinter.description(
28
+ SdkFunctionProgrammer.write(config)(importer)(route, props),
29
+ describe(route),
30
+ ),
31
+ SdkNamespaceProgrammer.write(checker)(config)(importer)(route, props),
32
+ ];
33
+ };
34
+
35
+ const describe = (route: IRoute): string => {
36
+ // MAIN DESCRIPTION
37
+ const comments: string[] = route.description
38
+ ? route.description.split("\n")
39
+ : [];
40
+
41
+ // COMMENT TAGS
42
+ const tags: IJsDocTagInfo[] = route.jsDocTags.filter(
43
+ (tag) =>
44
+ tag.name !== "param" ||
45
+ route.parameters
46
+ .filter((p) => p.category !== "headers")
47
+ .some((p) => p.name === tag.text?.[0]?.text),
48
+ );
49
+ if (tags.length !== 0) {
50
+ const content: string[] = tags.map((t) =>
51
+ t.text?.length
52
+ ? `@${t.name} ${t.text.map((e) => e.text).join("")}`
53
+ : `@${t.name}`,
54
+ );
55
+ comments.push("", ...new Set(content));
56
+ }
57
+
58
+ // EXCEPTIONS
59
+ for (const [key, value] of Object.entries(route.exceptions)) {
60
+ if (
61
+ comments.some(
62
+ (str) =>
63
+ str.startsWith(`@throw ${key}`) || str.startsWith(`@throws ${key}`),
64
+ )
65
+ )
66
+ continue;
67
+ comments.push(
68
+ value.description?.length
69
+ ? `@throws ${key} ${value.description.split("\n")[0]}`
70
+ : `@throws ${key}`,
71
+ );
72
+ }
73
+
74
+ // POSTFIX
75
+ if (!!comments.length) comments.push("");
76
+ comments.push(
77
+ `@controller ${route.target.class.name}.${route.target.function.name}`,
78
+ `@path ${route.method} ${route.path}`,
79
+ `@nestia Generated by Nestia - https://github.com/samchon/nestia`,
80
+ );
81
+ return comments.join("\n");
82
+ };
83
+ }