@nestia/sdk 2.6.2 → 2.6.3

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 (46) hide show
  1. package/lib/analyses/ControllerAnalyzer.js +3 -3
  2. package/lib/analyses/ControllerAnalyzer.js.map +1 -1
  3. package/lib/analyses/ImportAnalyzer.d.ts +1 -2
  4. package/lib/analyses/ImportAnalyzer.js +2 -2
  5. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  6. package/lib/analyses/ReflectAnalyzer.js +2 -2
  7. package/lib/analyses/ReflectAnalyzer.js.map +1 -1
  8. package/lib/generates/SwaggerGenerator.js +4 -4
  9. package/lib/generates/SwaggerGenerator.js.map +1 -1
  10. package/lib/generates/internal/ImportDictionary.js +6 -8
  11. package/lib/generates/internal/ImportDictionary.js.map +1 -1
  12. package/lib/structures/TypeEntry.js +2 -2
  13. package/lib/structures/TypeEntry.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/INestiaConfig.ts +248 -248
  16. package/src/NestiaSdkApplication.ts +255 -255
  17. package/src/analyses/ControllerAnalyzer.ts +402 -402
  18. package/src/analyses/ExceptionAnalyzer.ts +148 -148
  19. package/src/analyses/ImportAnalyzer.ts +1 -2
  20. package/src/analyses/ReflectAnalyzer.ts +463 -463
  21. package/src/analyses/SecurityAnalyzer.ts +24 -24
  22. package/src/generates/CloneGenerator.ts +62 -62
  23. package/src/generates/E2eGenerator.ts +66 -66
  24. package/src/generates/SdkGenerator.ts +84 -84
  25. package/src/generates/SwaggerGenerator.ts +446 -446
  26. package/src/generates/internal/E2eFileProgrammer.ts +182 -182
  27. package/src/generates/internal/FilePrinter.ts +53 -53
  28. package/src/generates/internal/ImportDictionary.ts +147 -149
  29. package/src/generates/internal/SdkAliasCollection.ts +152 -152
  30. package/src/generates/internal/SdkCloneProgrammer.ts +155 -155
  31. package/src/generates/internal/SdkFileProgrammer.ts +115 -115
  32. package/src/generates/internal/SdkFunctionProgrammer.ts +298 -298
  33. package/src/generates/internal/SdkImportWizard.ts +55 -55
  34. package/src/generates/internal/SdkNamespaceProgrammer.ts +510 -510
  35. package/src/generates/internal/SdkRouteProgrammer.ts +83 -83
  36. package/src/generates/internal/SdkSimulationProgrammer.ts +365 -365
  37. package/src/generates/internal/SdkTypeProgrammer.ts +385 -385
  38. package/src/generates/internal/SwaggerSchemaGenerator.ts +438 -438
  39. package/src/structures/IController.ts +94 -94
  40. package/src/structures/IRoute.ts +53 -53
  41. package/src/structures/ISwagger.ts +91 -91
  42. package/src/structures/ISwaggerRoute.ts +54 -54
  43. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  44. package/src/structures/ParamCategory.ts +1 -1
  45. package/src/structures/TypeEntry.ts +1 -1
  46. package/src/utils/StringUtil.ts +6 -6
@@ -1,365 +1,365 @@
1
- import ts from "typescript";
2
- import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
5
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
6
- import { TypeFactory } from "typia/lib/factories/TypeFactory";
7
-
8
- import { INestiaConfig } from "../../INestiaConfig";
9
- import { IRoute } from "../../structures/IRoute";
10
- import { ImportDictionary } from "./ImportDictionary";
11
- import { SdkAliasCollection } from "./SdkAliasCollection";
12
- import { SdkImportWizard } from "./SdkImportWizard";
13
- import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
14
-
15
- export namespace SdkSimulationProgrammer {
16
- export const random =
17
- (checker: ts.TypeChecker) =>
18
- (config: INestiaConfig) =>
19
- (importer: ImportDictionary) =>
20
- (route: IRoute): ts.VariableStatement => {
21
- const output =
22
- SdkAliasCollection.responseBody(checker)(config)(importer)(route);
23
- return constant("random")(
24
- ts.factory.createArrowFunction(
25
- undefined,
26
- undefined,
27
- [
28
- ts.factory.createParameterDeclaration(
29
- undefined,
30
- undefined,
31
- "g",
32
- ts.factory.createToken(ts.SyntaxKind.QuestionToken),
33
- ts.factory.createTypeReferenceNode(
34
- ts.factory.createIdentifier("Partial"),
35
- [
36
- ts.factory.createTypeReferenceNode(
37
- `${SdkImportWizard.typia(importer)}.IRandomGenerator`,
38
- ),
39
- ],
40
- ),
41
- ),
42
- ],
43
- config.primitive === false
44
- ? output
45
- : ts.factory.createTypeReferenceNode(
46
- SdkImportWizard.Resolved(importer),
47
- [output],
48
- ),
49
- undefined,
50
- ts.factory.createCallExpression(
51
- IdentifierFactory.access(
52
- ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
53
- )("random"),
54
- [output],
55
- [ts.factory.createIdentifier("g")],
56
- ),
57
- ),
58
- );
59
- };
60
-
61
- export const simulate =
62
- (config: INestiaConfig) =>
63
- (importer: ImportDictionary) =>
64
- (
65
- route: IRoute,
66
- props: {
67
- headers: IRoute.IParameter | undefined;
68
- query: IRoute.IParameter | undefined;
69
- input: IRoute.IParameter | undefined;
70
- },
71
- ): ts.VariableStatement => {
72
- const output: boolean =
73
- config.propagate === true || route.output.typeName !== "void";
74
- const caller = () =>
75
- ts.factory.createCallExpression(
76
- ts.factory.createIdentifier("random"),
77
- undefined,
78
- [
79
- ts.factory.createConditionalExpression(
80
- ts.factory.createLogicalAnd(
81
- ts.factory.createStrictEquality(
82
- ts.factory.createStringLiteral("object"),
83
- ts.factory.createTypeOfExpression(
84
- ts.factory.createIdentifier("connection.simulate"),
85
- ),
86
- ),
87
- ts.factory.createStrictInequality(
88
- ts.factory.createNull(),
89
- ts.factory.createIdentifier("connection.simulate"),
90
- ),
91
- ),
92
- undefined,
93
- ts.factory.createIdentifier("connection.simulate"),
94
- undefined,
95
- ts.factory.createIdentifier("undefined"),
96
- ),
97
- ],
98
- );
99
-
100
- return constant("simulate")(
101
- ts.factory.createArrowFunction(
102
- undefined,
103
- undefined,
104
- [
105
- IdentifierFactory.parameter(
106
- "connection",
107
- ts.factory.createTypeReferenceNode(
108
- SdkImportWizard.IConnection(importer),
109
- route.parameters.some(
110
- (p) => p.category === "headers" && p.field === undefined,
111
- )
112
- ? [
113
- ts.factory.createTypeReferenceNode(
114
- `${route.name}.Headers`,
115
- ),
116
- ]
117
- : [],
118
- ),
119
- ),
120
- ...route.parameters
121
- .filter((p) => p.category !== "headers")
122
- .map((p) =>
123
- ts.factory.createParameterDeclaration(
124
- [],
125
- undefined,
126
- p.name,
127
- p.optional
128
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
129
- : undefined,
130
- config.primitive !== false &&
131
- (p === props.query || p === props.input)
132
- ? ts.factory.createTypeReferenceNode(
133
- `${route.name}.${p === props.query ? "Query" : "Input"}`,
134
- )
135
- : getTypeName(config)(importer)(p),
136
- ),
137
- ),
138
- ],
139
- ts.factory.createTypeReferenceNode(output ? "Output" : "void"),
140
- undefined,
141
- ts.factory.createBlock(
142
- [
143
- ...assert(config)(importer)(route),
144
- ts.factory.createReturnStatement(
145
- config.propagate
146
- ? ts.factory.createObjectLiteralExpression(
147
- [
148
- ts.factory.createPropertyAssignment(
149
- "success",
150
- ts.factory.createTrue(),
151
- ),
152
- ts.factory.createPropertyAssignment(
153
- "status",
154
- ExpressionFactory.number(
155
- route.status ??
156
- (route.method === "POST" ? 201 : 200),
157
- ),
158
- ),
159
- ts.factory.createPropertyAssignment(
160
- "headers",
161
- LiteralFactory.generate({
162
- "Content-Type": route.output.contentType,
163
- }),
164
- ),
165
- ts.factory.createPropertyAssignment("data", caller()),
166
- ],
167
- true,
168
- )
169
- : caller(),
170
- ),
171
- ],
172
- true,
173
- ),
174
- ),
175
- );
176
- };
177
-
178
- const assert =
179
- (config: INestiaConfig) =>
180
- (importer: ImportDictionary) =>
181
- (route: IRoute): ts.Statement[] => {
182
- const parameters = route.parameters.filter(
183
- (p) => p.category !== "headers",
184
- );
185
- if (parameters.length === 0) return [];
186
-
187
- const typia = SdkImportWizard.typia(importer);
188
- const validator = StatementFactory.constant(
189
- "assert",
190
- ts.factory.createCallExpression(
191
- IdentifierFactory.access(
192
- ts.factory.createIdentifier(
193
- importer.external({
194
- type: false,
195
- library: `@nestia/fetcher/lib/NestiaSimulator`,
196
- instance: "NestiaSimulator",
197
- }),
198
- ),
199
- )("assert"),
200
- undefined,
201
- [
202
- ts.factory.createObjectLiteralExpression(
203
- [
204
- ts.factory.createPropertyAssignment(
205
- "method",
206
- ts.factory.createIdentifier("METADATA.method"),
207
- ),
208
- ts.factory.createPropertyAssignment(
209
- "host",
210
- ts.factory.createIdentifier("connection.host"),
211
- ),
212
- ts.factory.createPropertyAssignment(
213
- "path",
214
- ts.factory.createCallExpression(
215
- ts.factory.createIdentifier("path"),
216
- undefined,
217
- route.parameters
218
- .filter(
219
- (p) => p.category === "param" || p.category === "query",
220
- )
221
- .map((p) => ts.factory.createIdentifier(p.name)),
222
- ),
223
- ),
224
- ts.factory.createPropertyAssignment(
225
- "contentType",
226
- ts.factory.createIdentifier(
227
- JSON.stringify(route.output.contentType),
228
- ),
229
- ),
230
- ],
231
- true,
232
- ),
233
- ],
234
- ),
235
- );
236
- const individual = parameters
237
- .map((p) =>
238
- ts.factory.createCallExpression(
239
- (() => {
240
- const base = IdentifierFactory.access(
241
- ts.factory.createIdentifier("assert"),
242
- )(p.category);
243
- if (p.category !== "param") return base;
244
- return ts.factory.createCallExpression(base, undefined, [
245
- ts.factory.createStringLiteral(p.name),
246
- ]);
247
- })(),
248
- undefined,
249
- [
250
- ts.factory.createArrowFunction(
251
- undefined,
252
- undefined,
253
- [],
254
- undefined,
255
- undefined,
256
- ts.factory.createCallExpression(
257
- IdentifierFactory.access(ts.factory.createIdentifier(typia))(
258
- "assert",
259
- ),
260
- undefined,
261
- [
262
- ts.factory.createIdentifier(
263
- p.category === "headers" ? "connection.headers" : p.name,
264
- ),
265
- ],
266
- ),
267
- ),
268
- ],
269
- ),
270
- )
271
- .map(ts.factory.createExpressionStatement);
272
-
273
- return [
274
- validator,
275
- ...(config.propagate !== true
276
- ? individual
277
- : [tryAndCatch(importer)(individual)]),
278
- ];
279
- };
280
-
281
- const tryAndCatch =
282
- (importer: ImportDictionary) => (individual: ts.Statement[]) =>
283
- ts.factory.createTryStatement(
284
- ts.factory.createBlock(individual, true),
285
- ts.factory.createCatchClause(
286
- "exp",
287
- ts.factory.createBlock(
288
- [
289
- ts.factory.createIfStatement(
290
- ts.factory.createLogicalNot(
291
- ts.factory.createCallExpression(
292
- IdentifierFactory.access(
293
- ts.factory.createIdentifier(
294
- SdkImportWizard.typia(importer),
295
- ),
296
- )("is"),
297
- [
298
- ts.factory.createTypeReferenceNode(
299
- SdkImportWizard.HttpError(importer),
300
- ),
301
- ],
302
- [ts.factory.createIdentifier("exp")],
303
- ),
304
- ),
305
- ts.factory.createThrowStatement(
306
- ts.factory.createIdentifier("exp"),
307
- ),
308
- ),
309
- ts.factory.createReturnStatement(
310
- ts.factory.createAsExpression(
311
- ts.factory.createObjectLiteralExpression(
312
- [
313
- ts.factory.createPropertyAssignment(
314
- "success",
315
- ts.factory.createFalse(),
316
- ),
317
- ts.factory.createPropertyAssignment(
318
- "status",
319
- ts.factory.createIdentifier("exp.status"),
320
- ),
321
- ts.factory.createPropertyAssignment(
322
- "headers",
323
- ts.factory.createIdentifier("exp.headers"),
324
- ),
325
- ts.factory.createPropertyAssignment(
326
- "data",
327
- ts.factory.createIdentifier("exp.toJSON().message"),
328
- ),
329
- ],
330
- true,
331
- ),
332
- TypeFactory.keyword("any"),
333
- ),
334
- ),
335
- ],
336
- true,
337
- ),
338
- ),
339
- undefined,
340
- );
341
- }
342
-
343
- const constant = (name: string) => (expression: ts.Expression) =>
344
- ts.factory.createVariableStatement(
345
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
346
- ts.factory.createVariableDeclarationList(
347
- [
348
- ts.factory.createVariableDeclaration(
349
- ts.factory.createIdentifier(name),
350
- undefined,
351
- undefined,
352
- expression,
353
- ),
354
- ],
355
- ts.NodeFlags.Const,
356
- ),
357
- );
358
-
359
- const getTypeName =
360
- (config: INestiaConfig) =>
361
- (importer: ImportDictionary) =>
362
- (p: IRoute.IParameter | IRoute.IOutput) =>
363
- p.metadata
364
- ? SdkTypeProgrammer.write(config)(importer)(p.metadata)
365
- : ts.factory.createTypeReferenceNode(p.typeName);
1
+ import ts from "typescript";
2
+ import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
3
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
+ import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
5
+ import { StatementFactory } from "typia/lib/factories/StatementFactory";
6
+ import { TypeFactory } from "typia/lib/factories/TypeFactory";
7
+
8
+ import { INestiaConfig } from "../../INestiaConfig";
9
+ import { IRoute } from "../../structures/IRoute";
10
+ import { ImportDictionary } from "./ImportDictionary";
11
+ import { SdkAliasCollection } from "./SdkAliasCollection";
12
+ import { SdkImportWizard } from "./SdkImportWizard";
13
+ import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
14
+
15
+ export namespace SdkSimulationProgrammer {
16
+ export const random =
17
+ (checker: ts.TypeChecker) =>
18
+ (config: INestiaConfig) =>
19
+ (importer: ImportDictionary) =>
20
+ (route: IRoute): ts.VariableStatement => {
21
+ const output =
22
+ SdkAliasCollection.responseBody(checker)(config)(importer)(route);
23
+ return constant("random")(
24
+ ts.factory.createArrowFunction(
25
+ undefined,
26
+ undefined,
27
+ [
28
+ ts.factory.createParameterDeclaration(
29
+ undefined,
30
+ undefined,
31
+ "g",
32
+ ts.factory.createToken(ts.SyntaxKind.QuestionToken),
33
+ ts.factory.createTypeReferenceNode(
34
+ ts.factory.createIdentifier("Partial"),
35
+ [
36
+ ts.factory.createTypeReferenceNode(
37
+ `${SdkImportWizard.typia(importer)}.IRandomGenerator`,
38
+ ),
39
+ ],
40
+ ),
41
+ ),
42
+ ],
43
+ config.primitive === false
44
+ ? output
45
+ : ts.factory.createTypeReferenceNode(
46
+ SdkImportWizard.Resolved(importer),
47
+ [output],
48
+ ),
49
+ undefined,
50
+ ts.factory.createCallExpression(
51
+ IdentifierFactory.access(
52
+ ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
53
+ )("random"),
54
+ [output],
55
+ [ts.factory.createIdentifier("g")],
56
+ ),
57
+ ),
58
+ );
59
+ };
60
+
61
+ export const simulate =
62
+ (config: INestiaConfig) =>
63
+ (importer: ImportDictionary) =>
64
+ (
65
+ route: IRoute,
66
+ props: {
67
+ headers: IRoute.IParameter | undefined;
68
+ query: IRoute.IParameter | undefined;
69
+ input: IRoute.IParameter | undefined;
70
+ },
71
+ ): ts.VariableStatement => {
72
+ const output: boolean =
73
+ config.propagate === true || route.output.typeName !== "void";
74
+ const caller = () =>
75
+ ts.factory.createCallExpression(
76
+ ts.factory.createIdentifier("random"),
77
+ undefined,
78
+ [
79
+ ts.factory.createConditionalExpression(
80
+ ts.factory.createLogicalAnd(
81
+ ts.factory.createStrictEquality(
82
+ ts.factory.createStringLiteral("object"),
83
+ ts.factory.createTypeOfExpression(
84
+ ts.factory.createIdentifier("connection.simulate"),
85
+ ),
86
+ ),
87
+ ts.factory.createStrictInequality(
88
+ ts.factory.createNull(),
89
+ ts.factory.createIdentifier("connection.simulate"),
90
+ ),
91
+ ),
92
+ undefined,
93
+ ts.factory.createIdentifier("connection.simulate"),
94
+ undefined,
95
+ ts.factory.createIdentifier("undefined"),
96
+ ),
97
+ ],
98
+ );
99
+
100
+ return constant("simulate")(
101
+ ts.factory.createArrowFunction(
102
+ undefined,
103
+ undefined,
104
+ [
105
+ IdentifierFactory.parameter(
106
+ "connection",
107
+ ts.factory.createTypeReferenceNode(
108
+ SdkImportWizard.IConnection(importer),
109
+ route.parameters.some(
110
+ (p) => p.category === "headers" && p.field === undefined,
111
+ )
112
+ ? [
113
+ ts.factory.createTypeReferenceNode(
114
+ `${route.name}.Headers`,
115
+ ),
116
+ ]
117
+ : [],
118
+ ),
119
+ ),
120
+ ...route.parameters
121
+ .filter((p) => p.category !== "headers")
122
+ .map((p) =>
123
+ ts.factory.createParameterDeclaration(
124
+ [],
125
+ undefined,
126
+ p.name,
127
+ p.optional
128
+ ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
129
+ : undefined,
130
+ config.primitive !== false &&
131
+ (p === props.query || p === props.input)
132
+ ? ts.factory.createTypeReferenceNode(
133
+ `${route.name}.${p === props.query ? "Query" : "Input"}`,
134
+ )
135
+ : getTypeName(config)(importer)(p),
136
+ ),
137
+ ),
138
+ ],
139
+ ts.factory.createTypeReferenceNode(output ? "Output" : "void"),
140
+ undefined,
141
+ ts.factory.createBlock(
142
+ [
143
+ ...assert(config)(importer)(route),
144
+ ts.factory.createReturnStatement(
145
+ config.propagate
146
+ ? ts.factory.createObjectLiteralExpression(
147
+ [
148
+ ts.factory.createPropertyAssignment(
149
+ "success",
150
+ ts.factory.createTrue(),
151
+ ),
152
+ ts.factory.createPropertyAssignment(
153
+ "status",
154
+ ExpressionFactory.number(
155
+ route.status ??
156
+ (route.method === "POST" ? 201 : 200),
157
+ ),
158
+ ),
159
+ ts.factory.createPropertyAssignment(
160
+ "headers",
161
+ LiteralFactory.generate({
162
+ "Content-Type": route.output.contentType,
163
+ }),
164
+ ),
165
+ ts.factory.createPropertyAssignment("data", caller()),
166
+ ],
167
+ true,
168
+ )
169
+ : caller(),
170
+ ),
171
+ ],
172
+ true,
173
+ ),
174
+ ),
175
+ );
176
+ };
177
+
178
+ const assert =
179
+ (config: INestiaConfig) =>
180
+ (importer: ImportDictionary) =>
181
+ (route: IRoute): ts.Statement[] => {
182
+ const parameters = route.parameters.filter(
183
+ (p) => p.category !== "headers",
184
+ );
185
+ if (parameters.length === 0) return [];
186
+
187
+ const typia = SdkImportWizard.typia(importer);
188
+ const validator = StatementFactory.constant(
189
+ "assert",
190
+ ts.factory.createCallExpression(
191
+ IdentifierFactory.access(
192
+ ts.factory.createIdentifier(
193
+ importer.external({
194
+ type: false,
195
+ library: `@nestia/fetcher/lib/NestiaSimulator`,
196
+ instance: "NestiaSimulator",
197
+ }),
198
+ ),
199
+ )("assert"),
200
+ undefined,
201
+ [
202
+ ts.factory.createObjectLiteralExpression(
203
+ [
204
+ ts.factory.createPropertyAssignment(
205
+ "method",
206
+ ts.factory.createIdentifier("METADATA.method"),
207
+ ),
208
+ ts.factory.createPropertyAssignment(
209
+ "host",
210
+ ts.factory.createIdentifier("connection.host"),
211
+ ),
212
+ ts.factory.createPropertyAssignment(
213
+ "path",
214
+ ts.factory.createCallExpression(
215
+ ts.factory.createIdentifier("path"),
216
+ undefined,
217
+ route.parameters
218
+ .filter(
219
+ (p) => p.category === "param" || p.category === "query",
220
+ )
221
+ .map((p) => ts.factory.createIdentifier(p.name)),
222
+ ),
223
+ ),
224
+ ts.factory.createPropertyAssignment(
225
+ "contentType",
226
+ ts.factory.createIdentifier(
227
+ JSON.stringify(route.output.contentType),
228
+ ),
229
+ ),
230
+ ],
231
+ true,
232
+ ),
233
+ ],
234
+ ),
235
+ );
236
+ const individual = parameters
237
+ .map((p) =>
238
+ ts.factory.createCallExpression(
239
+ (() => {
240
+ const base = IdentifierFactory.access(
241
+ ts.factory.createIdentifier("assert"),
242
+ )(p.category);
243
+ if (p.category !== "param") return base;
244
+ return ts.factory.createCallExpression(base, undefined, [
245
+ ts.factory.createStringLiteral(p.name),
246
+ ]);
247
+ })(),
248
+ undefined,
249
+ [
250
+ ts.factory.createArrowFunction(
251
+ undefined,
252
+ undefined,
253
+ [],
254
+ undefined,
255
+ undefined,
256
+ ts.factory.createCallExpression(
257
+ IdentifierFactory.access(ts.factory.createIdentifier(typia))(
258
+ "assert",
259
+ ),
260
+ undefined,
261
+ [
262
+ ts.factory.createIdentifier(
263
+ p.category === "headers" ? "connection.headers" : p.name,
264
+ ),
265
+ ],
266
+ ),
267
+ ),
268
+ ],
269
+ ),
270
+ )
271
+ .map(ts.factory.createExpressionStatement);
272
+
273
+ return [
274
+ validator,
275
+ ...(config.propagate !== true
276
+ ? individual
277
+ : [tryAndCatch(importer)(individual)]),
278
+ ];
279
+ };
280
+
281
+ const tryAndCatch =
282
+ (importer: ImportDictionary) => (individual: ts.Statement[]) =>
283
+ ts.factory.createTryStatement(
284
+ ts.factory.createBlock(individual, true),
285
+ ts.factory.createCatchClause(
286
+ "exp",
287
+ ts.factory.createBlock(
288
+ [
289
+ ts.factory.createIfStatement(
290
+ ts.factory.createLogicalNot(
291
+ ts.factory.createCallExpression(
292
+ IdentifierFactory.access(
293
+ ts.factory.createIdentifier(
294
+ SdkImportWizard.typia(importer),
295
+ ),
296
+ )("is"),
297
+ [
298
+ ts.factory.createTypeReferenceNode(
299
+ SdkImportWizard.HttpError(importer),
300
+ ),
301
+ ],
302
+ [ts.factory.createIdentifier("exp")],
303
+ ),
304
+ ),
305
+ ts.factory.createThrowStatement(
306
+ ts.factory.createIdentifier("exp"),
307
+ ),
308
+ ),
309
+ ts.factory.createReturnStatement(
310
+ ts.factory.createAsExpression(
311
+ ts.factory.createObjectLiteralExpression(
312
+ [
313
+ ts.factory.createPropertyAssignment(
314
+ "success",
315
+ ts.factory.createFalse(),
316
+ ),
317
+ ts.factory.createPropertyAssignment(
318
+ "status",
319
+ ts.factory.createIdentifier("exp.status"),
320
+ ),
321
+ ts.factory.createPropertyAssignment(
322
+ "headers",
323
+ ts.factory.createIdentifier("exp.headers"),
324
+ ),
325
+ ts.factory.createPropertyAssignment(
326
+ "data",
327
+ ts.factory.createIdentifier("exp.toJSON().message"),
328
+ ),
329
+ ],
330
+ true,
331
+ ),
332
+ TypeFactory.keyword("any"),
333
+ ),
334
+ ),
335
+ ],
336
+ true,
337
+ ),
338
+ ),
339
+ undefined,
340
+ );
341
+ }
342
+
343
+ const constant = (name: string) => (expression: ts.Expression) =>
344
+ ts.factory.createVariableStatement(
345
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
346
+ ts.factory.createVariableDeclarationList(
347
+ [
348
+ ts.factory.createVariableDeclaration(
349
+ ts.factory.createIdentifier(name),
350
+ undefined,
351
+ undefined,
352
+ expression,
353
+ ),
354
+ ],
355
+ ts.NodeFlags.Const,
356
+ ),
357
+ );
358
+
359
+ const getTypeName =
360
+ (config: INestiaConfig) =>
361
+ (importer: ImportDictionary) =>
362
+ (p: IRoute.IParameter | IRoute.IOutput) =>
363
+ p.metadata
364
+ ? SdkTypeProgrammer.write(config)(importer)(p.metadata)
365
+ : ts.factory.createTypeReferenceNode(p.typeName);