@nestia/migrate 0.7.6 → 0.7.7

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 (68) hide show
  1. package/lib/MigrateApplication.js +7 -4
  2. package/lib/MigrateApplication.js.map +1 -1
  3. package/lib/analyzers/MigrateAnalyzer.d.ts +2 -3
  4. package/lib/analyzers/MigrateAnalyzer.js +1 -5
  5. package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
  6. package/lib/analyzers/MigrateControllerAnalyzer.d.ts +2 -2
  7. package/lib/analyzers/MigrateControllerAnalyzer.js +22 -13
  8. package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/MigrateMethodAnalyzer.d.ts +2 -2
  10. package/lib/analyzers/MigrateMethodAnalyzer.js +16 -16
  11. package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
  12. package/lib/module.d.ts +8 -0
  13. package/lib/module.js +8 -0
  14. package/lib/module.js.map +1 -1
  15. package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
  16. package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
  17. package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +2 -2
  18. package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
  19. package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
  20. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
  21. package/lib/programmers/MigrateApiProgrammer.js +3 -3
  22. package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
  23. package/lib/programmers/MigrateImportProgrammer.js +5 -5
  24. package/lib/programmers/MigrateImportProgrammer.js.map +1 -1
  25. package/lib/programmers/MigrateSchemaProgrammer.d.ts +1 -1
  26. package/lib/structures/IMigrateDto.d.ts +1 -1
  27. package/lib/structures/IMigrateProgram.d.ts +20 -4
  28. package/lib/structures/IMigrateRoute.d.ts +1 -1
  29. package/lib/structures/ISwaggerComponents.d.ts +1 -1
  30. package/lib/structures/ISwaggerRoute.d.ts +1 -1
  31. package/lib/structures/{ISwaggeSchema.js → ISwaggerSchema.js} +1 -1
  32. package/lib/structures/ISwaggerSchema.js.map +1 -0
  33. package/lib/utils/SwaggerTypeChecker.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/src/MigrateApplication.ts +54 -48
  36. package/src/analyzers/MigrateAnalyzer.ts +9 -13
  37. package/src/analyzers/MigrateControllerAnalyzer.ts +139 -122
  38. package/src/analyzers/MigrateMethodAnalyzer.ts +350 -348
  39. package/src/archivers/MigrateFileArchiver.ts +38 -38
  40. package/src/executable/bundle.ts +109 -109
  41. package/src/internal/MigrateCommander.ts +51 -51
  42. package/src/module.ts +10 -0
  43. package/src/programmers/MigrateApiFileProgrammer.ts +53 -53
  44. package/src/programmers/MigrateApiFunctionProgrammer.ts +203 -203
  45. package/src/programmers/MigrateApiNamespaceProgrammer.ts +430 -430
  46. package/src/programmers/MigrateApiProgrammer.ts +132 -132
  47. package/src/programmers/MigrateApiSimulatationProgrammer.ts +328 -328
  48. package/src/programmers/MigrateDtoProgrammer.ts +78 -78
  49. package/src/programmers/MigrateImportProgrammer.ts +114 -116
  50. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  51. package/src/programmers/MigrateNestMethodProgrammer.ts +249 -249
  52. package/src/programmers/MigrateNestModuleProgrammer.ts +62 -62
  53. package/src/programmers/MigrateNestProgrammer.ts +74 -74
  54. package/src/programmers/MigrateSchemaProgrammer.ts +257 -257
  55. package/src/structures/IMigrateDto.ts +1 -1
  56. package/src/structures/IMigrateProgram.ts +20 -4
  57. package/src/structures/IMigrateRoute.ts +46 -46
  58. package/src/structures/ISwaggerComponents.ts +1 -1
  59. package/src/structures/ISwaggerRoute.ts +1 -1
  60. package/src/utils/FilePrinter.ts +36 -36
  61. package/src/utils/SwaggerTypeChecker.ts +67 -67
  62. package/lib/IMigrateConfig.d.ts +0 -4
  63. package/lib/IMigrateConfig.js +0 -3
  64. package/lib/IMigrateConfig.js.map +0 -1
  65. package/lib/structures/ISwaggeSchema.js.map +0 -1
  66. package/src/IMigrateConfig.ts +0 -4
  67. /package/lib/structures/{ISwaggeSchema.d.ts → ISwaggerSchema.d.ts} +0 -0
  68. /package/src/structures/{ISwaggeSchema.ts → ISwaggerSchema.ts} +0 -0
@@ -1,328 +1,328 @@
1
- import ts from "typescript";
2
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
4
- import { TypeFactory } from "typia/lib/factories/TypeFactory";
5
-
6
- import { IMigrateController } from "../structures/IMigrateController";
7
- import { IMigrateRoute } from "../structures/IMigrateRoute";
8
- import { ISwaggerComponents } from "../structures/ISwaggerComponents";
9
- import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
10
- import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
11
- import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
12
- import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
13
-
14
- export namespace MigrateApiSimulatationProgrammer {
15
- export interface IProps {
16
- controller: IMigrateController;
17
- route: IMigrateRoute;
18
- alias: string;
19
- }
20
- export const random =
21
- (components: ISwaggerComponents) =>
22
- (importer: MigrateImportProgrammer) =>
23
- (props: IProps) =>
24
- constant("random")(
25
- ts.factory.createArrowFunction(
26
- undefined,
27
- undefined,
28
- [
29
- ts.factory.createParameterDeclaration(
30
- undefined,
31
- undefined,
32
- "g",
33
- ts.factory.createToken(ts.SyntaxKind.QuestionToken),
34
- ts.factory.createTypeReferenceNode(
35
- ts.factory.createIdentifier("Partial"),
36
- [
37
- ts.factory.createTypeReferenceNode(
38
- `${importer.external({
39
- type: "default",
40
- library: "typia",
41
- name: "typia",
42
- })}.IRandomGenerator`,
43
- ),
44
- ],
45
- ),
46
- ),
47
- ],
48
- undefined,
49
- undefined,
50
- ts.factory.createCallExpression(
51
- IdentifierFactory.access(
52
- ts.factory.createIdentifier(
53
- importer.external({
54
- type: "default",
55
- library: "typia",
56
- name: "typia",
57
- }),
58
- ),
59
- )("random"),
60
- [
61
- props.route.success
62
- ? MigrateSchemaProgrammer.write(components)(importer)(
63
- props.route.success.schema,
64
- )
65
- : TypeFactory.keyword("void"),
66
- ],
67
- [ts.factory.createIdentifier("g")],
68
- ),
69
- ),
70
- );
71
-
72
- export const simulate =
73
- (components: ISwaggerComponents) =>
74
- (importer: MigrateImportProgrammer) =>
75
- (props: IProps): ts.VariableStatement => {
76
- const caller = () =>
77
- ts.factory.createCallExpression(
78
- ts.factory.createIdentifier("random"),
79
- undefined,
80
- [
81
- ts.factory.createConditionalExpression(
82
- ts.factory.createLogicalAnd(
83
- ts.factory.createStrictEquality(
84
- ts.factory.createStringLiteral("object"),
85
- ts.factory.createTypeOfExpression(
86
- ts.factory.createIdentifier("connection.simulate"),
87
- ),
88
- ),
89
- ts.factory.createStrictInequality(
90
- ts.factory.createNull(),
91
- ts.factory.createIdentifier("connection.simulate"),
92
- ),
93
- ),
94
- undefined,
95
- ts.factory.createIdentifier("connection.simulate"),
96
- undefined,
97
- ts.factory.createIdentifier("undefined"),
98
- ),
99
- ],
100
- );
101
- assert;
102
- return constant("simulate")(
103
- ts.factory.createArrowFunction(
104
- undefined,
105
- undefined,
106
- MigrateApiFunctionProgrammer.writeParameterDeclarations(components)(
107
- importer,
108
- )(props),
109
- ts.factory.createTypeReferenceNode(
110
- props.route.success ? "Output" : "void",
111
- ),
112
- undefined,
113
- ts.factory.createBlock(
114
- [
115
- ...assert(components)(importer)(props),
116
- ts.factory.createReturnStatement(caller()),
117
- ],
118
- true,
119
- ),
120
- ),
121
- );
122
- };
123
-
124
- const assert =
125
- (components: ISwaggerComponents) =>
126
- (importer: MigrateImportProgrammer) =>
127
- (props: IProps): ts.Statement[] => {
128
- const parameters = [
129
- ...props.route.parameters.map((p) => ({
130
- category: "param",
131
- name: p.key,
132
- schema: MigrateSchemaProgrammer.write(components)(importer)(p.schema),
133
- })),
134
- ...(props.route.query
135
- ? [
136
- {
137
- category: "query",
138
- name: props.route.query.key,
139
- schema: MigrateSchemaProgrammer.write(components)(importer)(
140
- props.route.query.schema,
141
- ),
142
- },
143
- ]
144
- : []),
145
- ...(props.route.body
146
- ? [
147
- {
148
- category: "body",
149
- name: props.route.body.key,
150
- schema: MigrateSchemaProgrammer.write(components)(importer)(
151
- props.route.body.schema,
152
- ),
153
- },
154
- ]
155
- : []),
156
- ];
157
- if (parameters.length === 0) return [];
158
-
159
- const validator = StatementFactory.constant(
160
- "assert",
161
- ts.factory.createCallExpression(
162
- IdentifierFactory.access(
163
- ts.factory.createIdentifier(
164
- importer.external({
165
- type: "instance",
166
- library: `@nestia/fetcher/lib/NestiaSimulator`,
167
- name: "NestiaSimulator",
168
- }),
169
- ),
170
- )("assert"),
171
- undefined,
172
- [
173
- ts.factory.createObjectLiteralExpression(
174
- [
175
- ts.factory.createPropertyAssignment(
176
- "method",
177
- ts.factory.createIdentifier("METADATA.method"),
178
- ),
179
- ts.factory.createPropertyAssignment(
180
- "host",
181
- ts.factory.createIdentifier("connection.host"),
182
- ),
183
- ts.factory.createPropertyAssignment(
184
- "path",
185
- MigrateApiNamespaceProgrammer.writePathCallExpression(props),
186
- ),
187
- ts.factory.createPropertyAssignment(
188
- "contentType",
189
- ts.factory.createStringLiteral(
190
- props.route.success?.type ?? "application/json",
191
- ),
192
- ),
193
- ],
194
- true,
195
- ),
196
- ],
197
- ),
198
- );
199
- const individual = parameters
200
- .map((p) =>
201
- ts.factory.createCallExpression(
202
- (() => {
203
- const base = IdentifierFactory.access(
204
- ts.factory.createIdentifier("assert"),
205
- )(p.category);
206
- if (p.category !== "param") return base;
207
- return ts.factory.createCallExpression(base, undefined, [
208
- ts.factory.createStringLiteral(p.name),
209
- ]);
210
- })(),
211
- undefined,
212
- [
213
- ts.factory.createArrowFunction(
214
- undefined,
215
- undefined,
216
- [],
217
- undefined,
218
- undefined,
219
- ts.factory.createCallExpression(
220
- IdentifierFactory.access(
221
- ts.factory.createIdentifier(
222
- importer.external({
223
- type: "default",
224
- library: "typia",
225
- name: "typia",
226
- }),
227
- ),
228
- )("assert"),
229
- undefined,
230
- [
231
- ts.factory.createIdentifier(
232
- p.category === "headers" ? "connection.headers" : p.name,
233
- ),
234
- ],
235
- ),
236
- ),
237
- ],
238
- ),
239
- )
240
- .map(ts.factory.createExpressionStatement);
241
- return [validator, tryAndCatch(importer)(individual)];
242
- };
243
-
244
- const tryAndCatch =
245
- (importer: MigrateImportProgrammer) => (individual: ts.Statement[]) =>
246
- ts.factory.createTryStatement(
247
- ts.factory.createBlock(individual, true),
248
- ts.factory.createCatchClause(
249
- "exp",
250
- ts.factory.createBlock(
251
- [
252
- ts.factory.createIfStatement(
253
- ts.factory.createLogicalNot(
254
- ts.factory.createCallExpression(
255
- IdentifierFactory.access(
256
- ts.factory.createIdentifier(
257
- importer.external({
258
- type: "default",
259
- library: "typia",
260
- name: "typia",
261
- }),
262
- ),
263
- )("is"),
264
- [
265
- ts.factory.createTypeReferenceNode(
266
- importer.external({
267
- type: "instance",
268
- library: "@nestia/fetcher",
269
- name: "HttpError",
270
- }),
271
- ),
272
- ],
273
- [ts.factory.createIdentifier("exp")],
274
- ),
275
- ),
276
- ts.factory.createThrowStatement(
277
- ts.factory.createIdentifier("exp"),
278
- ),
279
- ),
280
- ts.factory.createReturnStatement(
281
- ts.factory.createAsExpression(
282
- ts.factory.createObjectLiteralExpression(
283
- [
284
- ts.factory.createPropertyAssignment(
285
- "success",
286
- ts.factory.createFalse(),
287
- ),
288
- ts.factory.createPropertyAssignment(
289
- "status",
290
- ts.factory.createIdentifier("exp.status"),
291
- ),
292
- ts.factory.createPropertyAssignment(
293
- "headers",
294
- ts.factory.createIdentifier("exp.headers"),
295
- ),
296
- ts.factory.createPropertyAssignment(
297
- "data",
298
- ts.factory.createIdentifier("exp.toJSON().message"),
299
- ),
300
- ],
301
- true,
302
- ),
303
- TypeFactory.keyword("any"),
304
- ),
305
- ),
306
- ],
307
- true,
308
- ),
309
- ),
310
- undefined,
311
- );
312
- }
313
-
314
- const constant = (name: string) => (expression: ts.Expression) =>
315
- ts.factory.createVariableStatement(
316
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
317
- ts.factory.createVariableDeclarationList(
318
- [
319
- ts.factory.createVariableDeclaration(
320
- ts.factory.createIdentifier(name),
321
- undefined,
322
- undefined,
323
- expression,
324
- ),
325
- ],
326
- ts.NodeFlags.Const,
327
- ),
328
- );
1
+ import ts from "typescript";
2
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
+ import { StatementFactory } from "typia/lib/factories/StatementFactory";
4
+ import { TypeFactory } from "typia/lib/factories/TypeFactory";
5
+
6
+ import { IMigrateController } from "../structures/IMigrateController";
7
+ import { IMigrateRoute } from "../structures/IMigrateRoute";
8
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
9
+ import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
10
+ import { MigrateApiNamespaceProgrammer } from "./MigrateApiNamespaceProgrammer";
11
+ import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
12
+ import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
13
+
14
+ export namespace MigrateApiSimulatationProgrammer {
15
+ export interface IProps {
16
+ controller: IMigrateController;
17
+ route: IMigrateRoute;
18
+ alias: string;
19
+ }
20
+ export const random =
21
+ (components: ISwaggerComponents) =>
22
+ (importer: MigrateImportProgrammer) =>
23
+ (props: IProps) =>
24
+ constant("random")(
25
+ ts.factory.createArrowFunction(
26
+ undefined,
27
+ undefined,
28
+ [
29
+ ts.factory.createParameterDeclaration(
30
+ undefined,
31
+ undefined,
32
+ "g",
33
+ ts.factory.createToken(ts.SyntaxKind.QuestionToken),
34
+ ts.factory.createTypeReferenceNode(
35
+ ts.factory.createIdentifier("Partial"),
36
+ [
37
+ ts.factory.createTypeReferenceNode(
38
+ `${importer.external({
39
+ type: "default",
40
+ library: "typia",
41
+ name: "typia",
42
+ })}.IRandomGenerator`,
43
+ ),
44
+ ],
45
+ ),
46
+ ),
47
+ ],
48
+ undefined,
49
+ undefined,
50
+ ts.factory.createCallExpression(
51
+ IdentifierFactory.access(
52
+ ts.factory.createIdentifier(
53
+ importer.external({
54
+ type: "default",
55
+ library: "typia",
56
+ name: "typia",
57
+ }),
58
+ ),
59
+ )("random"),
60
+ [
61
+ props.route.success
62
+ ? MigrateSchemaProgrammer.write(components)(importer)(
63
+ props.route.success.schema,
64
+ )
65
+ : TypeFactory.keyword("void"),
66
+ ],
67
+ [ts.factory.createIdentifier("g")],
68
+ ),
69
+ ),
70
+ );
71
+
72
+ export const simulate =
73
+ (components: ISwaggerComponents) =>
74
+ (importer: MigrateImportProgrammer) =>
75
+ (props: IProps): ts.VariableStatement => {
76
+ const caller = () =>
77
+ ts.factory.createCallExpression(
78
+ ts.factory.createIdentifier("random"),
79
+ undefined,
80
+ [
81
+ ts.factory.createConditionalExpression(
82
+ ts.factory.createLogicalAnd(
83
+ ts.factory.createStrictEquality(
84
+ ts.factory.createStringLiteral("object"),
85
+ ts.factory.createTypeOfExpression(
86
+ ts.factory.createIdentifier("connection.simulate"),
87
+ ),
88
+ ),
89
+ ts.factory.createStrictInequality(
90
+ ts.factory.createNull(),
91
+ ts.factory.createIdentifier("connection.simulate"),
92
+ ),
93
+ ),
94
+ undefined,
95
+ ts.factory.createIdentifier("connection.simulate"),
96
+ undefined,
97
+ ts.factory.createIdentifier("undefined"),
98
+ ),
99
+ ],
100
+ );
101
+ assert;
102
+ return constant("simulate")(
103
+ ts.factory.createArrowFunction(
104
+ undefined,
105
+ undefined,
106
+ MigrateApiFunctionProgrammer.writeParameterDeclarations(components)(
107
+ importer,
108
+ )(props),
109
+ ts.factory.createTypeReferenceNode(
110
+ props.route.success ? "Output" : "void",
111
+ ),
112
+ undefined,
113
+ ts.factory.createBlock(
114
+ [
115
+ ...assert(components)(importer)(props),
116
+ ts.factory.createReturnStatement(caller()),
117
+ ],
118
+ true,
119
+ ),
120
+ ),
121
+ );
122
+ };
123
+
124
+ const assert =
125
+ (components: ISwaggerComponents) =>
126
+ (importer: MigrateImportProgrammer) =>
127
+ (props: IProps): ts.Statement[] => {
128
+ const parameters = [
129
+ ...props.route.parameters.map((p) => ({
130
+ category: "param",
131
+ name: p.key,
132
+ schema: MigrateSchemaProgrammer.write(components)(importer)(p.schema),
133
+ })),
134
+ ...(props.route.query
135
+ ? [
136
+ {
137
+ category: "query",
138
+ name: props.route.query.key,
139
+ schema: MigrateSchemaProgrammer.write(components)(importer)(
140
+ props.route.query.schema,
141
+ ),
142
+ },
143
+ ]
144
+ : []),
145
+ ...(props.route.body
146
+ ? [
147
+ {
148
+ category: "body",
149
+ name: props.route.body.key,
150
+ schema: MigrateSchemaProgrammer.write(components)(importer)(
151
+ props.route.body.schema,
152
+ ),
153
+ },
154
+ ]
155
+ : []),
156
+ ];
157
+ if (parameters.length === 0) return [];
158
+
159
+ const validator = StatementFactory.constant(
160
+ "assert",
161
+ ts.factory.createCallExpression(
162
+ IdentifierFactory.access(
163
+ ts.factory.createIdentifier(
164
+ importer.external({
165
+ type: "instance",
166
+ library: `@nestia/fetcher/lib/NestiaSimulator`,
167
+ name: "NestiaSimulator",
168
+ }),
169
+ ),
170
+ )("assert"),
171
+ undefined,
172
+ [
173
+ ts.factory.createObjectLiteralExpression(
174
+ [
175
+ ts.factory.createPropertyAssignment(
176
+ "method",
177
+ ts.factory.createIdentifier("METADATA.method"),
178
+ ),
179
+ ts.factory.createPropertyAssignment(
180
+ "host",
181
+ ts.factory.createIdentifier("connection.host"),
182
+ ),
183
+ ts.factory.createPropertyAssignment(
184
+ "path",
185
+ MigrateApiNamespaceProgrammer.writePathCallExpression(props),
186
+ ),
187
+ ts.factory.createPropertyAssignment(
188
+ "contentType",
189
+ ts.factory.createStringLiteral(
190
+ props.route.success?.type ?? "application/json",
191
+ ),
192
+ ),
193
+ ],
194
+ true,
195
+ ),
196
+ ],
197
+ ),
198
+ );
199
+ const individual = parameters
200
+ .map((p) =>
201
+ ts.factory.createCallExpression(
202
+ (() => {
203
+ const base = IdentifierFactory.access(
204
+ ts.factory.createIdentifier("assert"),
205
+ )(p.category);
206
+ if (p.category !== "param") return base;
207
+ return ts.factory.createCallExpression(base, undefined, [
208
+ ts.factory.createStringLiteral(p.name),
209
+ ]);
210
+ })(),
211
+ undefined,
212
+ [
213
+ ts.factory.createArrowFunction(
214
+ undefined,
215
+ undefined,
216
+ [],
217
+ undefined,
218
+ undefined,
219
+ ts.factory.createCallExpression(
220
+ IdentifierFactory.access(
221
+ ts.factory.createIdentifier(
222
+ importer.external({
223
+ type: "default",
224
+ library: "typia",
225
+ name: "typia",
226
+ }),
227
+ ),
228
+ )("assert"),
229
+ undefined,
230
+ [
231
+ ts.factory.createIdentifier(
232
+ p.category === "headers" ? "connection.headers" : p.name,
233
+ ),
234
+ ],
235
+ ),
236
+ ),
237
+ ],
238
+ ),
239
+ )
240
+ .map(ts.factory.createExpressionStatement);
241
+ return [validator, tryAndCatch(importer)(individual)];
242
+ };
243
+
244
+ const tryAndCatch =
245
+ (importer: MigrateImportProgrammer) => (individual: ts.Statement[]) =>
246
+ ts.factory.createTryStatement(
247
+ ts.factory.createBlock(individual, true),
248
+ ts.factory.createCatchClause(
249
+ "exp",
250
+ ts.factory.createBlock(
251
+ [
252
+ ts.factory.createIfStatement(
253
+ ts.factory.createLogicalNot(
254
+ ts.factory.createCallExpression(
255
+ IdentifierFactory.access(
256
+ ts.factory.createIdentifier(
257
+ importer.external({
258
+ type: "default",
259
+ library: "typia",
260
+ name: "typia",
261
+ }),
262
+ ),
263
+ )("is"),
264
+ [
265
+ ts.factory.createTypeReferenceNode(
266
+ importer.external({
267
+ type: "instance",
268
+ library: "@nestia/fetcher",
269
+ name: "HttpError",
270
+ }),
271
+ ),
272
+ ],
273
+ [ts.factory.createIdentifier("exp")],
274
+ ),
275
+ ),
276
+ ts.factory.createThrowStatement(
277
+ ts.factory.createIdentifier("exp"),
278
+ ),
279
+ ),
280
+ ts.factory.createReturnStatement(
281
+ ts.factory.createAsExpression(
282
+ ts.factory.createObjectLiteralExpression(
283
+ [
284
+ ts.factory.createPropertyAssignment(
285
+ "success",
286
+ ts.factory.createFalse(),
287
+ ),
288
+ ts.factory.createPropertyAssignment(
289
+ "status",
290
+ ts.factory.createIdentifier("exp.status"),
291
+ ),
292
+ ts.factory.createPropertyAssignment(
293
+ "headers",
294
+ ts.factory.createIdentifier("exp.headers"),
295
+ ),
296
+ ts.factory.createPropertyAssignment(
297
+ "data",
298
+ ts.factory.createIdentifier("exp.toJSON().message"),
299
+ ),
300
+ ],
301
+ true,
302
+ ),
303
+ TypeFactory.keyword("any"),
304
+ ),
305
+ ),
306
+ ],
307
+ true,
308
+ ),
309
+ ),
310
+ undefined,
311
+ );
312
+ }
313
+
314
+ const constant = (name: string) => (expression: ts.Expression) =>
315
+ ts.factory.createVariableStatement(
316
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
317
+ ts.factory.createVariableDeclarationList(
318
+ [
319
+ ts.factory.createVariableDeclaration(
320
+ ts.factory.createIdentifier(name),
321
+ undefined,
322
+ undefined,
323
+ expression,
324
+ ),
325
+ ],
326
+ ts.NodeFlags.Const,
327
+ ),
328
+ );