@nestia/migrate 0.7.5 → 0.7.6

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 (114) hide show
  1. package/lib/MigrateApplication.d.ts +9 -2
  2. package/lib/MigrateApplication.js +14 -8
  3. package/lib/MigrateApplication.js.map +1 -1
  4. package/lib/analyzers/MigrateAnalyzer.js +2 -2
  5. package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
  6. package/lib/analyzers/{ControllerAnalyzer.d.ts → MigrateControllerAnalyzer.d.ts} +1 -1
  7. package/lib/analyzers/{ControllerAnalyzer.js → MigrateControllerAnalyzer.js} +11 -9
  8. package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -0
  9. package/lib/analyzers/{MethodAnalyzer.d.ts → MigrateMethodAnalyzer.d.ts} +1 -1
  10. package/lib/analyzers/{MethodAnalyzer.js → MigrateMethodAnalyzer.js} +26 -25
  11. package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -0
  12. package/lib/archivers/{FileArchiver.d.ts → MigrateFileArchiver.d.ts} +1 -1
  13. package/lib/archivers/{FileArchiver.js → MigrateFileArchiver.js} +6 -6
  14. package/lib/archivers/MigrateFileArchiver.js.map +1 -0
  15. package/lib/bundles/SDK_TEMPLATE.js +0 -5
  16. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  17. package/lib/executable/bundle.js +1 -0
  18. package/lib/executable/bundle.js.map +1 -1
  19. package/lib/internal/MigrateCommander.js +3 -3
  20. package/lib/internal/MigrateCommander.js.map +1 -1
  21. package/lib/programmers/{ApiFileProgrammer.d.ts → MigrateApiFileProgrammer.d.ts} +1 -1
  22. package/lib/programmers/MigrateApiFileProgrammer.js +28 -0
  23. package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -0
  24. package/lib/programmers/{ApiFunctionProgrammer.d.ts → MigrateApiFunctionProgrammer.d.ts} +4 -4
  25. package/lib/programmers/{ApiFunctionProgrammer.js → MigrateApiFunctionProgrammer.js} +10 -10
  26. package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -0
  27. package/lib/programmers/{ApiNamespaceProgrammer.d.ts → MigrateApiNamespaceProgrammer.d.ts} +3 -3
  28. package/lib/programmers/{ApiNamespaceProgrammer.js → MigrateApiNamespaceProgrammer.js} +19 -19
  29. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -0
  30. package/lib/programmers/{ApiProgrammer.d.ts → MigrateApiProgrammer.d.ts} +1 -1
  31. package/lib/programmers/{ApiProgrammer.js → MigrateApiProgrammer.js} +25 -20
  32. package/lib/programmers/MigrateApiProgrammer.js.map +1 -0
  33. package/lib/programmers/{ApiSimulatationProgrammer.d.ts → MigrateApiSimulatationProgrammer.d.ts} +4 -4
  34. package/lib/programmers/{ApiSimulatationProgrammer.js → MigrateApiSimulatationProgrammer.js} +16 -16
  35. package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -0
  36. package/lib/programmers/{DtoProgrammer.d.ts → MigrateDtoProgrammer.d.ts} +3 -3
  37. package/lib/programmers/{DtoProgrammer.js → MigrateDtoProgrammer.js} +8 -8
  38. package/lib/programmers/MigrateDtoProgrammer.js.map +1 -0
  39. package/lib/programmers/{ImportProgrammer.d.ts → MigrateImportProgrammer.d.ts} +3 -3
  40. package/lib/programmers/{ImportProgrammer.js → MigrateImportProgrammer.js} +7 -5
  41. package/lib/programmers/MigrateImportProgrammer.js.map +1 -0
  42. package/lib/programmers/{NestControllerProgrammer.d.ts → MigrateNestControllerProgrammer.d.ts} +1 -1
  43. package/lib/programmers/{NestControllerProgrammer.js → MigrateNestControllerProgrammer.js} +11 -11
  44. package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -0
  45. package/lib/programmers/{NestMethodProgrammer.d.ts → MigrateNestMethodProgrammer.d.ts} +3 -3
  46. package/lib/programmers/{NestMethodProgrammer.js → MigrateNestMethodProgrammer.js} +13 -11
  47. package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -0
  48. package/lib/programmers/{NestModuleProgrammer.d.ts → MigrateNestModuleProgrammer.d.ts} +1 -1
  49. package/lib/programmers/{NestModuleProgrammer.js → MigrateNestModuleProgrammer.js} +8 -8
  50. package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -0
  51. package/lib/programmers/{NestProgrammer.d.ts → MigrateNestProgrammer.d.ts} +1 -1
  52. package/lib/programmers/{NestProgrammer.js → MigrateNestProgrammer.js} +17 -15
  53. package/lib/programmers/MigrateNestProgrammer.js.map +1 -0
  54. package/lib/programmers/{SchemaProgrammer.d.ts → MigrateSchemaProgrammer.d.ts} +3 -3
  55. package/lib/programmers/{SchemaProgrammer.js → MigrateSchemaProgrammer.js} +23 -23
  56. package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -0
  57. package/lib/structures/IMigrateRoute.d.ts +1 -0
  58. package/lib/utils/FilePrinter.d.ts +1 -1
  59. package/lib/utils/FilePrinter.js +1 -1
  60. package/lib/utils/FilePrinter.js.map +1 -1
  61. package/lib/utils/{JsonTypeChecker.d.ts → SwaggerTypeChecker.d.ts} +1 -1
  62. package/lib/utils/SwaggerTypeChecker.js +34 -0
  63. package/lib/utils/SwaggerTypeChecker.js.map +1 -0
  64. package/package.json +68 -68
  65. package/src/IMigrateConfig.ts +4 -4
  66. package/src/MigrateApplication.ts +48 -35
  67. package/src/analyzers/MigrateAnalyzer.ts +13 -13
  68. package/src/analyzers/{ControllerAnalyzer.ts → MigrateControllerAnalyzer.ts} +122 -123
  69. package/src/analyzers/{MethodAnalyzer.ts → MigrateMethodAnalyzer.ts} +348 -347
  70. package/src/archivers/{FileArchiver.ts → MigrateFileArchiver.ts} +38 -38
  71. package/src/bundles/SDK_TEMPLATE.ts +0 -5
  72. package/src/executable/bundle.ts +109 -108
  73. package/src/executable/migrate.ts +7 -7
  74. package/src/internal/MigrateCommander.ts +51 -52
  75. package/src/internal/MigrateInquirer.ts +79 -79
  76. package/src/module.ts +4 -4
  77. package/src/programmers/{ApiFileProgrammer.ts → MigrateApiFileProgrammer.ts} +53 -53
  78. package/src/programmers/{ApiFunctionProgrammer.ts → MigrateApiFunctionProgrammer.ts} +203 -203
  79. package/src/programmers/{ApiNamespaceProgrammer.ts → MigrateApiNamespaceProgrammer.ts} +430 -418
  80. package/src/programmers/{ApiProgrammer.ts → MigrateApiProgrammer.ts} +132 -128
  81. package/src/programmers/{ApiSimulatationProgrammer.ts → MigrateApiSimulatationProgrammer.ts} +328 -328
  82. package/src/programmers/{DtoProgrammer.ts → MigrateDtoProgrammer.ts} +78 -74
  83. package/src/programmers/{ImportProgrammer.ts → MigrateImportProgrammer.ts} +116 -114
  84. package/src/programmers/{NestControllerProgrammer.ts → MigrateNestControllerProgrammer.ts} +50 -48
  85. package/src/programmers/{NestMethodProgrammer.ts → MigrateNestMethodProgrammer.ts} +249 -243
  86. package/src/programmers/{NestModuleProgrammer.ts → MigrateNestModuleProgrammer.ts} +62 -62
  87. package/src/programmers/{NestProgrammer.ts → MigrateNestProgrammer.ts} +74 -74
  88. package/src/programmers/{SchemaProgrammer.ts → MigrateSchemaProgrammer.ts} +257 -255
  89. package/src/structures/IMigrateProgram.ts +9 -9
  90. package/src/structures/IMigrateRoute.ts +46 -45
  91. package/src/structures/ISwaggeSchema.ts +90 -90
  92. package/src/structures/ISwaggerInfo.ts +80 -80
  93. package/src/utils/FilePrinter.ts +36 -36
  94. package/src/utils/SetupWizard.ts +12 -12
  95. package/src/utils/StringUtil.ts +60 -60
  96. package/src/utils/{JsonTypeChecker.ts → SwaggerTypeChecker.ts} +67 -67
  97. package/lib/analyzers/ControllerAnalyzer.js.map +0 -1
  98. package/lib/analyzers/MethodAnalyzer.js.map +0 -1
  99. package/lib/archivers/FileArchiver.js.map +0 -1
  100. package/lib/programmers/ApiFileProgrammer.js +0 -28
  101. package/lib/programmers/ApiFileProgrammer.js.map +0 -1
  102. package/lib/programmers/ApiFunctionProgrammer.js.map +0 -1
  103. package/lib/programmers/ApiNamespaceProgrammer.js.map +0 -1
  104. package/lib/programmers/ApiProgrammer.js.map +0 -1
  105. package/lib/programmers/ApiSimulatationProgrammer.js.map +0 -1
  106. package/lib/programmers/DtoProgrammer.js.map +0 -1
  107. package/lib/programmers/ImportProgrammer.js.map +0 -1
  108. package/lib/programmers/NestControllerProgrammer.js.map +0 -1
  109. package/lib/programmers/NestMethodProgrammer.js.map +0 -1
  110. package/lib/programmers/NestModuleProgrammer.js.map +0 -1
  111. package/lib/programmers/NestProgrammer.js.map +0 -1
  112. package/lib/programmers/SchemaProgrammer.js.map +0 -1
  113. package/lib/utils/JsonTypeChecker.js +0 -34
  114. package/lib/utils/JsonTypeChecker.js.map +0 -1
@@ -1,53 +1,53 @@
1
- import ts from "typescript";
2
-
3
- import { IMigrateConfig } from "../IMigrateConfig";
4
- import { IMigrateController } from "../structures/IMigrateController";
5
- import { IMigrateRoute } from "../structures/IMigrateRoute";
6
- import { ISwaggerComponents } from "../structures/ISwaggerComponents";
7
- import { ApiFunctionProgrammer } from "./ApiFunctionProgrammer";
8
- import { ApiNamespaceProgrammer } from "./ApiNamespaceProgrammer";
9
- import { ImportProgrammer } from "./ImportProgrammer";
10
-
11
- export namespace ApiFileProgrammer {
12
- export interface IProps {
13
- namespace: string[];
14
- entries: IEntry[];
15
- children: Set<string>;
16
- }
17
- export interface IEntry {
18
- controller: IMigrateController;
19
- route: IMigrateRoute;
20
- alias: string;
21
- }
22
-
23
- export const write =
24
- (config: IMigrateConfig) =>
25
- (components: ISwaggerComponents) =>
26
- (props: IProps): ts.Statement[] => {
27
- const importer: ImportProgrammer = new ImportProgrammer();
28
- const statements: ts.Statement[] = props.entries
29
- .map((p) => [
30
- ApiFunctionProgrammer.write(config)(components)(importer)(p),
31
- ApiNamespaceProgrammer.write(config)(components)(importer)(p),
32
- ])
33
- .flat();
34
- return [
35
- ...importer.toStatements(
36
- (ref) =>
37
- `../${"../".repeat(props.namespace.length)}structures/${ref}`,
38
- ),
39
- ...[...props.children].map((child) =>
40
- ts.factory.createExportDeclaration(
41
- undefined,
42
- false,
43
- ts.factory.createNamespaceExport(
44
- ts.factory.createIdentifier(child),
45
- ),
46
- ts.factory.createStringLiteral(`./${child}`),
47
- undefined,
48
- ),
49
- ),
50
- ...statements,
51
- ];
52
- };
53
- }
1
+ import ts from "typescript";
2
+
3
+ import { IMigrateConfig } from "../IMigrateConfig";
4
+ import { IMigrateController } from "../structures/IMigrateController";
5
+ import { IMigrateRoute } from "../structures/IMigrateRoute";
6
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
7
+ import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
8
+ import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
9
+ import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
10
+
11
+ export namespace MigrateApiFileProgrammer {
12
+ export interface IProps {
13
+ namespace: string[];
14
+ entries: IEntry[];
15
+ children: Set<string>;
16
+ }
17
+ export interface IEntry {
18
+ controller: IMigrateController;
19
+ route: IMigrateRoute;
20
+ alias: string;
21
+ }
22
+
23
+ export const write =
24
+ (config: IMigrateConfig) =>
25
+ (components: ISwaggerComponents) =>
26
+ (props: IProps): ts.Statement[] => {
27
+ const importer: MigrateImportProgrammer = new MigrateImportProgrammer();
28
+ const statements: ts.Statement[] = props.entries
29
+ .map((p) => [
30
+ MigrateApiFunctionProgrammer.write(config)(components)(importer)(p),
31
+ MigrateApiNamespaceProgrammer.write(config)(components)(importer)(p),
32
+ ])
33
+ .flat();
34
+ return [
35
+ ...importer.toStatements(
36
+ (ref) =>
37
+ `../${"../".repeat(props.namespace.length)}structures/${ref}`,
38
+ ),
39
+ ...[...props.children].map((child) =>
40
+ ts.factory.createExportDeclaration(
41
+ undefined,
42
+ false,
43
+ ts.factory.createNamespaceExport(
44
+ ts.factory.createIdentifier(child),
45
+ ),
46
+ ts.factory.createStringLiteral(`./${child}`),
47
+ undefined,
48
+ ),
49
+ ),
50
+ ...statements,
51
+ ];
52
+ };
53
+ }
@@ -1,203 +1,203 @@
1
- import ts from "typescript";
2
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
-
4
- import { IMigrateConfig } from "../IMigrateConfig";
5
- import { IMigrateController } from "../structures/IMigrateController";
6
- import { IMigrateRoute } from "../structures/IMigrateRoute";
7
- import { ISwaggerComponents } from "../structures/ISwaggerComponents";
8
- import { FilePrinter } from "../utils/FilePrinter";
9
- import { ImportProgrammer } from "./ImportProgrammer";
10
- import { SchemaProgrammer } from "./SchemaProgrammer";
11
-
12
- export namespace ApiFunctionProgrammer {
13
- export interface IProps {
14
- controller: IMigrateController;
15
- route: IMigrateRoute;
16
- alias: string;
17
- }
18
-
19
- export const write =
20
- (config: IMigrateConfig) =>
21
- (components: ISwaggerComponents) =>
22
- (importer: ImportProgrammer) =>
23
- (props: IProps): ts.FunctionDeclaration =>
24
- FilePrinter.description(
25
- ts.factory.createFunctionDeclaration(
26
- [
27
- ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
28
- ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
29
- ],
30
- undefined,
31
- props.alias,
32
- undefined,
33
- writeParameterDeclarations(components)(importer)(props),
34
- ts.factory.createTypeReferenceNode("Promise", [
35
- ts.factory.createTypeReferenceNode(
36
- props.route.success === null ? "void" : `${props.alias}.Output`,
37
- ),
38
- ]),
39
- ts.factory.createBlock(writeBody(config)(importer)(props), true),
40
- ),
41
- writeDescription(props),
42
- );
43
-
44
- export const writeParameterDeclarations =
45
- (components: ISwaggerComponents) =>
46
- (importer: ImportProgrammer) =>
47
- (props: IProps): ts.ParameterDeclaration[] => [
48
- IdentifierFactory.parameter(
49
- "connection",
50
- ts.factory.createTypeReferenceNode(
51
- importer.external({
52
- type: "instance",
53
- library: "@nestia/fetcher",
54
- name: "IConnection",
55
- }),
56
- props.route.headers
57
- ? [ts.factory.createTypeReferenceNode(`${props.alias}.Headers`)]
58
- : undefined,
59
- ),
60
- ),
61
- ...props.route.parameters.map((p) =>
62
- IdentifierFactory.parameter(
63
- p.key,
64
- SchemaProgrammer.write(components)(importer)(p.schema),
65
- ),
66
- ),
67
- ...(props.route.query
68
- ? [
69
- IdentifierFactory.parameter(
70
- props.route.query.key,
71
- ts.factory.createTypeReferenceNode(`${props.alias}.Query`),
72
- ),
73
- ]
74
- : []),
75
- ...(props.route.body
76
- ? [
77
- IdentifierFactory.parameter(
78
- props.route.body.key,
79
- ts.factory.createTypeReferenceNode(`${props.alias}.Input`),
80
- ),
81
- ]
82
- : []),
83
- ];
84
-
85
- const writeDescription = (props: IProps): string =>
86
- [
87
- ...(props.route.description?.length
88
- ? [props.route.description.length, ""]
89
- : []),
90
- ...(props.route.deprecated ? ["@deprecated"] : []),
91
- ...props.route.tags.map((value) => `@tag ${value}`),
92
- `@controller ${props.controller.name}`,
93
- `@path ${props.route.path}`,
94
- "@nestia Generated by Nestia - https://github.com/samchon/nestia",
95
- ].join("\n");
96
-
97
- const writeBody =
98
- (config: IMigrateConfig) =>
99
- (importer: ImportProgrammer) =>
100
- (props: IProps): ts.Statement[] => {
101
- const encrypted: boolean = !!props.route.success?.["x-nestia-encrypted"];
102
- const contentType: string = props.route.body?.type ?? "application/json";
103
-
104
- const caller = () =>
105
- ts.factory.createCallExpression(
106
- IdentifierFactory.access(
107
- ts.factory.createIdentifier(
108
- importer.external({
109
- type: "instance",
110
- library: `@nestia/fetcher/lib/${encrypted ? "EncryptedFetcher" : "PlainFetcher"}`,
111
- name: encrypted ? "EncryptedFetcher" : "PlainFetcher",
112
- }),
113
- ),
114
- )("fetch"),
115
- undefined,
116
- [
117
- contentType && contentType !== "multipart/form-data"
118
- ? ts.factory.createObjectLiteralExpression(
119
- [
120
- ts.factory.createSpreadAssignment(
121
- ts.factory.createIdentifier("connection"),
122
- ),
123
- ts.factory.createPropertyAssignment(
124
- "headers",
125
- ts.factory.createObjectLiteralExpression(
126
- [
127
- ts.factory.createSpreadAssignment(
128
- IdentifierFactory.access(
129
- ts.factory.createIdentifier("connection"),
130
- )("headers"),
131
- ),
132
- ts.factory.createPropertyAssignment(
133
- ts.factory.createStringLiteral("Content-Type"),
134
- ts.factory.createStringLiteral(contentType),
135
- ),
136
- ],
137
- true,
138
- ),
139
- ),
140
- ],
141
- true,
142
- )
143
- : ts.factory.createIdentifier("connection"),
144
- ts.factory.createObjectLiteralExpression(
145
- [
146
- ts.factory.createSpreadAssignment(
147
- IdentifierFactory.access(
148
- ts.factory.createIdentifier(props.alias),
149
- )("METADATA"),
150
- ),
151
- ts.factory.createPropertyAssignment(
152
- "path",
153
- ts.factory.createCallExpression(
154
- IdentifierFactory.access(
155
- ts.factory.createIdentifier(props.alias),
156
- )("path"),
157
- undefined,
158
- [
159
- ...props.route.parameters.map((p) =>
160
- ts.factory.createIdentifier(p.key),
161
- ),
162
- ...(props.route.query
163
- ? [ts.factory.createIdentifier(props.route.query.key)]
164
- : []),
165
- ],
166
- ),
167
- ),
168
- ts.factory.createPropertyAssignment(
169
- "status",
170
- ts.factory.createNull(),
171
- ),
172
- ],
173
- true,
174
- ),
175
- ...(props.route.body
176
- ? [ts.factory.createIdentifier(props.route.body.key)]
177
- : []),
178
- ],
179
- );
180
- if (config.simulate !== true)
181
- return [ts.factory.createReturnStatement(caller())];
182
- return [
183
- ts.factory.createReturnStatement(
184
- ts.factory.createConditionalExpression(
185
- ts.factory.createIdentifier("!!connection.simulate"),
186
- undefined,
187
- ts.factory.createCallExpression(
188
- ts.factory.createIdentifier(`${props.alias}.simulate`),
189
- [],
190
- [
191
- "connection",
192
- ...props.route.parameters.map((p) => p.key),
193
- ...(props.route.query ? [props.route.query.key] : []),
194
- ...(props.route.body ? [props.route.body.key] : []),
195
- ].map((key) => ts.factory.createIdentifier(key)),
196
- ),
197
- undefined,
198
- caller(),
199
- ),
200
- ),
201
- ];
202
- };
203
- }
1
+ import ts from "typescript";
2
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
+
4
+ import { IMigrateConfig } from "../IMigrateConfig";
5
+ import { IMigrateController } from "../structures/IMigrateController";
6
+ import { IMigrateRoute } from "../structures/IMigrateRoute";
7
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
8
+ import { FilePrinter } from "../utils/FilePrinter";
9
+ import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
10
+ import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
11
+
12
+ export namespace MigrateApiFunctionProgrammer {
13
+ export interface IProps {
14
+ controller: IMigrateController;
15
+ route: IMigrateRoute;
16
+ alias: string;
17
+ }
18
+
19
+ export const write =
20
+ (config: IMigrateConfig) =>
21
+ (components: ISwaggerComponents) =>
22
+ (importer: MigrateImportProgrammer) =>
23
+ (props: IProps): ts.FunctionDeclaration =>
24
+ FilePrinter.description(
25
+ ts.factory.createFunctionDeclaration(
26
+ [
27
+ ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
28
+ ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
29
+ ],
30
+ undefined,
31
+ props.alias,
32
+ undefined,
33
+ writeParameterDeclarations(components)(importer)(props),
34
+ ts.factory.createTypeReferenceNode("Promise", [
35
+ ts.factory.createTypeReferenceNode(
36
+ props.route.success === null ? "void" : `${props.alias}.Output`,
37
+ ),
38
+ ]),
39
+ ts.factory.createBlock(writeBody(config)(importer)(props), true),
40
+ ),
41
+ writeDescription(props),
42
+ );
43
+
44
+ export const writeParameterDeclarations =
45
+ (components: ISwaggerComponents) =>
46
+ (importer: MigrateImportProgrammer) =>
47
+ (props: IProps): ts.ParameterDeclaration[] => [
48
+ IdentifierFactory.parameter(
49
+ "connection",
50
+ ts.factory.createTypeReferenceNode(
51
+ importer.external({
52
+ type: "instance",
53
+ library: "@nestia/fetcher",
54
+ name: "IConnection",
55
+ }),
56
+ props.route.headers
57
+ ? [ts.factory.createTypeReferenceNode(`${props.alias}.Headers`)]
58
+ : undefined,
59
+ ),
60
+ ),
61
+ ...props.route.parameters.map((p) =>
62
+ IdentifierFactory.parameter(
63
+ p.key,
64
+ MigrateSchemaProgrammer.write(components)(importer)(p.schema),
65
+ ),
66
+ ),
67
+ ...(props.route.query
68
+ ? [
69
+ IdentifierFactory.parameter(
70
+ props.route.query.key,
71
+ ts.factory.createTypeReferenceNode(`${props.alias}.Query`),
72
+ ),
73
+ ]
74
+ : []),
75
+ ...(props.route.body
76
+ ? [
77
+ IdentifierFactory.parameter(
78
+ props.route.body.key,
79
+ ts.factory.createTypeReferenceNode(`${props.alias}.Input`),
80
+ ),
81
+ ]
82
+ : []),
83
+ ];
84
+
85
+ const writeDescription = (props: IProps): string =>
86
+ [
87
+ ...(props.route.description?.length
88
+ ? [props.route.description.length, ""]
89
+ : []),
90
+ ...(props.route.deprecated ? ["@deprecated"] : []),
91
+ ...props.route.tags.map((value) => `@tag ${value}`),
92
+ `@controller ${props.controller.name}`,
93
+ `@path ${props.route.path}`,
94
+ "@nestia Generated by Nestia - https://github.com/samchon/nestia",
95
+ ].join("\n");
96
+
97
+ const writeBody =
98
+ (config: IMigrateConfig) =>
99
+ (importer: MigrateImportProgrammer) =>
100
+ (props: IProps): ts.Statement[] => {
101
+ const encrypted: boolean = !!props.route.success?.["x-nestia-encrypted"];
102
+ const contentType: string = props.route.body?.type ?? "application/json";
103
+
104
+ const caller = () =>
105
+ ts.factory.createCallExpression(
106
+ IdentifierFactory.access(
107
+ ts.factory.createIdentifier(
108
+ importer.external({
109
+ type: "instance",
110
+ library: `@nestia/fetcher/lib/${encrypted ? "EncryptedFetcher" : "PlainFetcher"}`,
111
+ name: encrypted ? "EncryptedFetcher" : "PlainFetcher",
112
+ }),
113
+ ),
114
+ )("fetch"),
115
+ undefined,
116
+ [
117
+ contentType && contentType !== "multipart/form-data"
118
+ ? ts.factory.createObjectLiteralExpression(
119
+ [
120
+ ts.factory.createSpreadAssignment(
121
+ ts.factory.createIdentifier("connection"),
122
+ ),
123
+ ts.factory.createPropertyAssignment(
124
+ "headers",
125
+ ts.factory.createObjectLiteralExpression(
126
+ [
127
+ ts.factory.createSpreadAssignment(
128
+ IdentifierFactory.access(
129
+ ts.factory.createIdentifier("connection"),
130
+ )("headers"),
131
+ ),
132
+ ts.factory.createPropertyAssignment(
133
+ ts.factory.createStringLiteral("Content-Type"),
134
+ ts.factory.createStringLiteral(contentType),
135
+ ),
136
+ ],
137
+ true,
138
+ ),
139
+ ),
140
+ ],
141
+ true,
142
+ )
143
+ : ts.factory.createIdentifier("connection"),
144
+ ts.factory.createObjectLiteralExpression(
145
+ [
146
+ ts.factory.createSpreadAssignment(
147
+ IdentifierFactory.access(
148
+ ts.factory.createIdentifier(props.alias),
149
+ )("METADATA"),
150
+ ),
151
+ ts.factory.createPropertyAssignment(
152
+ "path",
153
+ ts.factory.createCallExpression(
154
+ IdentifierFactory.access(
155
+ ts.factory.createIdentifier(props.alias),
156
+ )("path"),
157
+ undefined,
158
+ [
159
+ ...props.route.parameters.map((p) =>
160
+ ts.factory.createIdentifier(p.key),
161
+ ),
162
+ ...(props.route.query
163
+ ? [ts.factory.createIdentifier(props.route.query.key)]
164
+ : []),
165
+ ],
166
+ ),
167
+ ),
168
+ ts.factory.createPropertyAssignment(
169
+ "status",
170
+ ts.factory.createNull(),
171
+ ),
172
+ ],
173
+ true,
174
+ ),
175
+ ...(props.route.body
176
+ ? [ts.factory.createIdentifier(props.route.body.key)]
177
+ : []),
178
+ ],
179
+ );
180
+ if (config.simulate !== true)
181
+ return [ts.factory.createReturnStatement(caller())];
182
+ return [
183
+ ts.factory.createReturnStatement(
184
+ ts.factory.createConditionalExpression(
185
+ ts.factory.createIdentifier("!!connection.simulate"),
186
+ undefined,
187
+ ts.factory.createCallExpression(
188
+ ts.factory.createIdentifier(`${props.alias}.simulate`),
189
+ [],
190
+ [
191
+ "connection",
192
+ ...props.route.parameters.map((p) => p.key),
193
+ ...(props.route.query ? [props.route.query.key] : []),
194
+ ...(props.route.body ? [props.route.body.key] : []),
195
+ ].map((key) => ts.factory.createIdentifier(key)),
196
+ ),
197
+ undefined,
198
+ caller(),
199
+ ),
200
+ ),
201
+ ];
202
+ };
203
+ }