@nestia/sdk 12.0.0-dev.20260612.2 → 12.0.0-dev.20260619.1
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/assets/bundle/distribute/package.json +1 -1
- package/lib/factories/ExpressionFactory.d.ts +9 -0
- package/lib/factories/ExpressionFactory.js +16 -0
- package/lib/factories/ExpressionFactory.js.map +1 -0
- package/lib/factories/IdentifierFactory.d.ts +22 -0
- package/lib/factories/IdentifierFactory.js +50 -0
- package/lib/factories/IdentifierFactory.js.map +1 -0
- package/lib/factories/LiteralFactory.d.ts +9 -0
- package/lib/factories/LiteralFactory.js +48 -0
- package/lib/factories/LiteralFactory.js.map +1 -0
- package/lib/factories/StatementFactory.d.ts +14 -0
- package/lib/factories/StatementFactory.js +20 -0
- package/lib/factories/StatementFactory.js.map +1 -0
- package/lib/factories/TypeFactory.d.ts +24 -0
- package/lib/factories/TypeFactory.js +27 -0
- package/lib/factories/TypeFactory.js.map +1 -0
- package/lib/generates/CloneGenerator.js +2 -2
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +30 -29
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +2 -2
- package/lib/generates/internal/FilePrinter.js +14 -25
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +1 -1
- package/lib/generates/internal/ImportDictionary.js +10 -9
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +12 -12
- package/lib/generates/internal/SdkAliasCollection.js +23 -25
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +2 -2
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +3 -3
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +45 -48
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +61 -60
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +11 -13
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +50 -48
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +54 -53
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkTypeProgrammer.js +42 -43
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +2 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.js +7 -9
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +45 -47
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +9 -9
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +34 -40
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/transform.d.ts +5 -9
- package/lib/transform.js +8 -31
- package/lib/transform.js.map +1 -1
- package/package.json +11 -11
- package/src/factories/ExpressionFactory.ts +23 -0
- package/src/factories/IdentifierFactory.ts +84 -0
- package/src/factories/LiteralFactory.ts +54 -0
- package/src/factories/StatementFactory.ts +56 -0
- package/src/factories/TypeFactory.ts +27 -0
- package/src/generates/CloneGenerator.ts +8 -7
- package/src/generates/internal/E2eFileProgrammer.ts +59 -53
- package/src/generates/internal/FilePrinter.ts +28 -36
- package/src/generates/internal/ImportDictionary.ts +19 -21
- package/src/generates/internal/SdkAliasCollection.ts +55 -49
- package/src/generates/internal/SdkFileProgrammer.ts +4 -7
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +11 -13
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +90 -101
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +153 -166
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +15 -17
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +1 -1
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +121 -130
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +135 -140
- package/src/generates/internal/SdkTypeProgrammer.ts +389 -382
- package/src/generates/internal/SdkTypeTagProgrammer.ts +13 -17
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +124 -130
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +17 -15
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +112 -139
- package/src/transform.ts +14 -45
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
type Block,
|
|
3
|
+
type Expression,
|
|
4
|
+
type Node,
|
|
3
5
|
NodeFlags,
|
|
6
|
+
type ParameterDeclaration,
|
|
7
|
+
type Statement,
|
|
4
8
|
SyntaxKind,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ExpressionFactory,
|
|
9
|
-
IdentifierFactory,
|
|
10
|
-
LiteralFactory,
|
|
11
|
-
TypeFactory,
|
|
12
|
-
} from "@nestia/factory";
|
|
9
|
+
type TypeNode,
|
|
10
|
+
factory,
|
|
11
|
+
} from "@ttsc/factory";
|
|
13
12
|
import { NamingConvention } from "@typia/utils";
|
|
14
13
|
|
|
14
|
+
import { ExpressionFactory } from "../../factories/ExpressionFactory";
|
|
15
|
+
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
16
|
+
import { LiteralFactory } from "../../factories/LiteralFactory";
|
|
17
|
+
import { TypeFactory } from "../../factories/TypeFactory";
|
|
15
18
|
import { sizeOf } from "../../internal/legacy";
|
|
16
19
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
17
20
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
@@ -27,11 +30,11 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
27
30
|
(project: INestiaProject) =>
|
|
28
31
|
(importer: ImportDictionary) =>
|
|
29
32
|
(route: ITypedHttpRoute): Node => {
|
|
30
|
-
const types:
|
|
31
|
-
return
|
|
32
|
-
[
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const types: Statement[] = writeTypes(project)(importer)(route);
|
|
34
|
+
return factory.createModuleDeclaration(
|
|
35
|
+
[factory.createToken(SyntaxKind.ExportKeyword)],
|
|
36
|
+
factory.createIdentifier(route.name),
|
|
37
|
+
factory.createModuleBlock([
|
|
35
38
|
...types,
|
|
36
39
|
...(types.length ? [FilePrinter.enter()] : []),
|
|
37
40
|
writeMetadata(project)(importer)(route),
|
|
@@ -39,8 +42,12 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
39
42
|
writePath(project)(importer)(route),
|
|
40
43
|
...(project.config.simulate
|
|
41
44
|
? [
|
|
42
|
-
SdkHttpSimulationProgrammer.random(project)(importer)(
|
|
43
|
-
|
|
45
|
+
SdkHttpSimulationProgrammer.random(project)(importer)(
|
|
46
|
+
route,
|
|
47
|
+
) as Statement,
|
|
48
|
+
SdkHttpSimulationProgrammer.simulate(project)(importer)(
|
|
49
|
+
route,
|
|
50
|
+
) as Statement,
|
|
44
51
|
]
|
|
45
52
|
: []),
|
|
46
53
|
...(project.config.json &&
|
|
@@ -57,15 +64,15 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
57
64
|
const writeTypes =
|
|
58
65
|
(project: INestiaProject) =>
|
|
59
66
|
(importer: ImportDictionary) =>
|
|
60
|
-
(route: ITypedHttpRoute):
|
|
61
|
-
const array:
|
|
67
|
+
(route: ITypedHttpRoute): Statement[] => {
|
|
68
|
+
const array: Statement[] = [];
|
|
62
69
|
const declare = (name: string, type: Node) =>
|
|
63
70
|
array.push(
|
|
64
|
-
|
|
65
|
-
[
|
|
71
|
+
factory.createTypeAliasDeclaration(
|
|
72
|
+
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
66
73
|
name,
|
|
67
74
|
undefined,
|
|
68
|
-
type,
|
|
75
|
+
type as TypeNode,
|
|
69
76
|
),
|
|
70
77
|
);
|
|
71
78
|
if (
|
|
@@ -103,20 +110,20 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
103
110
|
const writeMetadata =
|
|
104
111
|
(project: INestiaProject) =>
|
|
105
112
|
(importer: ImportDictionary) =>
|
|
106
|
-
(route: ITypedHttpRoute):
|
|
113
|
+
(route: ITypedHttpRoute): Statement =>
|
|
107
114
|
constant("METADATA")(
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
factory.createAsExpression(
|
|
116
|
+
factory.createObjectLiteralExpression(
|
|
110
117
|
[
|
|
111
|
-
|
|
118
|
+
factory.createPropertyAssignment(
|
|
112
119
|
"method",
|
|
113
|
-
|
|
120
|
+
factory.createStringLiteral(route.method),
|
|
114
121
|
),
|
|
115
|
-
|
|
122
|
+
factory.createPropertyAssignment(
|
|
116
123
|
"path",
|
|
117
|
-
|
|
124
|
+
factory.createStringLiteral(route.path),
|
|
118
125
|
),
|
|
119
|
-
|
|
126
|
+
factory.createPropertyAssignment(
|
|
120
127
|
"request",
|
|
121
128
|
route.body
|
|
122
129
|
? LiteralFactory.write(
|
|
@@ -130,38 +137,40 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
130
137
|
encrypted: false,
|
|
131
138
|
},
|
|
132
139
|
)
|
|
133
|
-
:
|
|
140
|
+
: factory.createNull(),
|
|
134
141
|
),
|
|
135
|
-
|
|
142
|
+
factory.createPropertyAssignment(
|
|
136
143
|
"response",
|
|
137
144
|
route.method !== "HEAD"
|
|
138
145
|
? LiteralFactory.write({
|
|
139
146
|
type: route.success.contentType,
|
|
140
147
|
encrypted: !!route.success.encrypted,
|
|
141
148
|
})
|
|
142
|
-
:
|
|
149
|
+
: factory.createNull(),
|
|
143
150
|
),
|
|
144
|
-
|
|
151
|
+
factory.createPropertyAssignment(
|
|
145
152
|
"status",
|
|
146
153
|
route.success.status !== null
|
|
147
154
|
? ExpressionFactory.number(route.success.status)
|
|
148
|
-
:
|
|
155
|
+
: factory.createNull(),
|
|
149
156
|
),
|
|
150
157
|
...(route.success.contentType ===
|
|
151
158
|
"application/x-www-form-urlencoded"
|
|
152
159
|
? [
|
|
153
|
-
|
|
160
|
+
factory.createPropertyAssignment(
|
|
154
161
|
"parseQuery",
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
factory.createCallExpression(
|
|
163
|
+
factory.createIdentifier(
|
|
157
164
|
`${SdkImportWizard.typia(importer)}.http.createAssertQuery`,
|
|
158
165
|
),
|
|
159
166
|
[
|
|
160
|
-
project.config.clone === true
|
|
167
|
+
(project.config.clone === true
|
|
161
168
|
? SdkAliasCollection.from(project)(importer)(
|
|
162
169
|
route.success.metadata,
|
|
163
170
|
)
|
|
164
|
-
: SdkAliasCollection.name(
|
|
171
|
+
: SdkAliasCollection.name(
|
|
172
|
+
route.success,
|
|
173
|
+
)) as TypeNode,
|
|
165
174
|
],
|
|
166
175
|
undefined,
|
|
167
176
|
),
|
|
@@ -171,19 +180,17 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
171
180
|
],
|
|
172
181
|
true,
|
|
173
182
|
),
|
|
174
|
-
|
|
175
|
-
TypeScriptFactory.createIdentifier("const"),
|
|
176
|
-
),
|
|
183
|
+
factory.createTypeReferenceNode(factory.createIdentifier("const")),
|
|
177
184
|
),
|
|
178
185
|
);
|
|
179
186
|
|
|
180
187
|
const writePath =
|
|
181
188
|
(project: INestiaProject) =>
|
|
182
189
|
(importer: ImportDictionary) =>
|
|
183
|
-
(route: ITypedHttpRoute):
|
|
184
|
-
const out = (body:
|
|
190
|
+
(route: ITypedHttpRoute): Statement => {
|
|
191
|
+
const out = (body: Block | Expression) =>
|
|
185
192
|
constant("path")(
|
|
186
|
-
|
|
193
|
+
factory.createArrowFunction(
|
|
187
194
|
[],
|
|
188
195
|
[],
|
|
189
196
|
SdkHttpParameterProgrammer.getParameterDeclarations({
|
|
@@ -192,7 +199,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
192
199
|
route,
|
|
193
200
|
body: false,
|
|
194
201
|
prefix: false,
|
|
195
|
-
}),
|
|
202
|
+
}) as ParameterDeclaration[],
|
|
196
203
|
undefined,
|
|
197
204
|
undefined,
|
|
198
205
|
body,
|
|
@@ -203,53 +210,46 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
203
210
|
false,
|
|
204
211
|
);
|
|
205
212
|
if (parameters.length === 0)
|
|
206
|
-
return out(
|
|
213
|
+
return out(factory.createStringLiteral(route.path));
|
|
207
214
|
|
|
208
215
|
const access = (name: string) =>
|
|
209
216
|
project.config.keyword === true ? `props.${name}` : name;
|
|
210
217
|
const template = () => {
|
|
211
218
|
const split: string[] = route.path.split(":");
|
|
212
|
-
if (split.length === 1)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
TypeScriptFactory.createTemplateHead(split[0]!),
|
|
219
|
+
if (split.length === 1) return factory.createStringLiteral(route.path);
|
|
220
|
+
return factory.createTemplateExpression(
|
|
221
|
+
factory.createTemplateHead(split[0]!),
|
|
216
222
|
split.slice(1).map((s, i, arr) => {
|
|
217
223
|
const name: string = s.split("/")[0]!;
|
|
218
|
-
return
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
return factory.createTemplateSpan(
|
|
225
|
+
factory.createCallExpression(
|
|
226
|
+
factory.createIdentifier("encodeURIComponent"),
|
|
221
227
|
undefined,
|
|
222
228
|
[
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
factory.createBinaryExpression(
|
|
230
|
+
factory.createCallChain(
|
|
231
|
+
factory.createPropertyAccessChain(
|
|
232
|
+
factory.createIdentifier(
|
|
227
233
|
access(
|
|
228
234
|
route.pathParameters.find((p) => p.field === name)!
|
|
229
235
|
.name,
|
|
230
236
|
),
|
|
231
237
|
),
|
|
232
|
-
|
|
233
|
-
SyntaxKind.QuestionDotToken,
|
|
234
|
-
),
|
|
238
|
+
factory.createToken(SyntaxKind.QuestionDotToken),
|
|
235
239
|
"toString",
|
|
236
240
|
),
|
|
237
241
|
undefined,
|
|
238
242
|
undefined,
|
|
239
243
|
[],
|
|
240
244
|
),
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
),
|
|
244
|
-
TypeScriptFactory.createStringLiteral("null"),
|
|
245
|
+
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
246
|
+
factory.createStringLiteral("null"),
|
|
245
247
|
),
|
|
246
248
|
],
|
|
247
249
|
),
|
|
248
250
|
(i !== arr.length - 1
|
|
249
|
-
?
|
|
250
|
-
:
|
|
251
|
-
s.substring(name.length),
|
|
252
|
-
),
|
|
251
|
+
? factory.createTemplateMiddle
|
|
252
|
+
: factory.createTemplateTail)(s.substring(name.length)),
|
|
253
253
|
);
|
|
254
254
|
}),
|
|
255
255
|
);
|
|
@@ -257,37 +257,37 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
257
257
|
if (route.queryObject === null && route.queryParameters.length === 0)
|
|
258
258
|
return out(template());
|
|
259
259
|
|
|
260
|
-
const block = (expr:
|
|
260
|
+
const block = (expr: Expression) => {
|
|
261
261
|
const computeName = (str: string): string =>
|
|
262
262
|
parameters.find((p) => p.name === str) !== undefined
|
|
263
263
|
? computeName("_" + str)
|
|
264
264
|
: str;
|
|
265
265
|
const variables: string = computeName("variables");
|
|
266
|
-
return
|
|
266
|
+
return factory.createBlock(
|
|
267
267
|
[
|
|
268
268
|
local(variables)("URLSearchParams")(
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
factory.createNewExpression(
|
|
270
|
+
factory.createIdentifier("URLSearchParams"),
|
|
271
271
|
[],
|
|
272
272
|
[],
|
|
273
273
|
),
|
|
274
274
|
),
|
|
275
|
-
|
|
275
|
+
factory.createForOfStatement(
|
|
276
276
|
undefined,
|
|
277
|
-
|
|
277
|
+
factory.createVariableDeclarationList(
|
|
278
278
|
[
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
factory.createVariableDeclaration(
|
|
280
|
+
factory.createArrayBindingPattern([
|
|
281
|
+
factory.createBindingElement(
|
|
282
282
|
undefined,
|
|
283
283
|
undefined,
|
|
284
|
-
|
|
284
|
+
factory.createIdentifier("key"),
|
|
285
285
|
undefined,
|
|
286
286
|
),
|
|
287
|
-
|
|
287
|
+
factory.createBindingElement(
|
|
288
288
|
undefined,
|
|
289
289
|
undefined,
|
|
290
|
-
|
|
290
|
+
factory.createIdentifier("value"),
|
|
291
291
|
undefined,
|
|
292
292
|
),
|
|
293
293
|
]),
|
|
@@ -298,54 +298,49 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
298
298
|
],
|
|
299
299
|
NodeFlags.Const,
|
|
300
300
|
),
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
factory.createCallExpression(
|
|
302
|
+
factory.createIdentifier("Object.entries"),
|
|
303
303
|
undefined,
|
|
304
|
-
[
|
|
305
|
-
TypeScriptFactory.createAsExpression(
|
|
306
|
-
expr,
|
|
307
|
-
TypeFactory.keyword("any"),
|
|
308
|
-
),
|
|
309
|
-
],
|
|
304
|
+
[factory.createAsExpression(expr, TypeFactory.keyword("any"))],
|
|
310
305
|
),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
306
|
+
factory.createIfStatement(
|
|
307
|
+
factory.createStrictEquality(
|
|
308
|
+
factory.createIdentifier("undefined"),
|
|
309
|
+
factory.createIdentifier("value"),
|
|
315
310
|
),
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
311
|
+
factory.createContinueStatement(),
|
|
312
|
+
factory.createIfStatement(
|
|
313
|
+
factory.createCallExpression(
|
|
314
|
+
factory.createIdentifier("Array.isArray"),
|
|
320
315
|
undefined,
|
|
321
|
-
[
|
|
316
|
+
[factory.createIdentifier("value")],
|
|
322
317
|
),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
318
|
+
factory.createExpressionStatement(
|
|
319
|
+
factory.createCallExpression(
|
|
320
|
+
factory.createPropertyAccessExpression(
|
|
321
|
+
factory.createIdentifier("value"),
|
|
322
|
+
factory.createIdentifier("forEach"),
|
|
328
323
|
),
|
|
329
324
|
undefined,
|
|
330
325
|
[
|
|
331
|
-
|
|
326
|
+
factory.createArrowFunction(
|
|
332
327
|
undefined,
|
|
333
328
|
undefined,
|
|
334
329
|
[IdentifierFactory.parameter("elem")],
|
|
335
330
|
undefined,
|
|
336
331
|
undefined,
|
|
337
|
-
|
|
332
|
+
factory.createCallExpression(
|
|
338
333
|
IdentifierFactory.access(
|
|
339
|
-
|
|
334
|
+
factory.createIdentifier(variables),
|
|
340
335
|
"append",
|
|
341
336
|
),
|
|
342
337
|
undefined,
|
|
343
338
|
[
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
339
|
+
factory.createIdentifier("key"),
|
|
340
|
+
factory.createCallExpression(
|
|
341
|
+
factory.createIdentifier("String"),
|
|
347
342
|
undefined,
|
|
348
|
-
[
|
|
343
|
+
[factory.createIdentifier("elem")],
|
|
349
344
|
),
|
|
350
345
|
],
|
|
351
346
|
),
|
|
@@ -353,19 +348,19 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
353
348
|
],
|
|
354
349
|
),
|
|
355
350
|
),
|
|
356
|
-
|
|
357
|
-
|
|
351
|
+
factory.createExpressionStatement(
|
|
352
|
+
factory.createCallExpression(
|
|
358
353
|
IdentifierFactory.access(
|
|
359
|
-
|
|
354
|
+
factory.createIdentifier(variables),
|
|
360
355
|
"set",
|
|
361
356
|
),
|
|
362
357
|
undefined,
|
|
363
358
|
[
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
359
|
+
factory.createIdentifier("key"),
|
|
360
|
+
factory.createCallExpression(
|
|
361
|
+
factory.createIdentifier("String"),
|
|
367
362
|
undefined,
|
|
368
|
-
[
|
|
363
|
+
[factory.createIdentifier("value")],
|
|
369
364
|
),
|
|
370
365
|
],
|
|
371
366
|
),
|
|
@@ -374,35 +369,35 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
374
369
|
),
|
|
375
370
|
),
|
|
376
371
|
local("location")("string")(template()),
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
372
|
+
factory.createReturnStatement(
|
|
373
|
+
factory.createConditionalExpression(
|
|
374
|
+
factory.createStrictEquality(
|
|
380
375
|
ExpressionFactory.number(0),
|
|
381
376
|
IdentifierFactory.access(
|
|
382
|
-
|
|
377
|
+
factory.createIdentifier(variables),
|
|
383
378
|
"size",
|
|
384
379
|
),
|
|
385
380
|
),
|
|
386
381
|
undefined,
|
|
387
|
-
|
|
382
|
+
factory.createIdentifier("location"),
|
|
388
383
|
undefined,
|
|
389
|
-
|
|
390
|
-
|
|
384
|
+
factory.createTemplateExpression(
|
|
385
|
+
factory.createTemplateHead(""),
|
|
391
386
|
[
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
387
|
+
factory.createTemplateSpan(
|
|
388
|
+
factory.createIdentifier("location"),
|
|
389
|
+
factory.createTemplateMiddle("?"),
|
|
395
390
|
),
|
|
396
|
-
|
|
397
|
-
|
|
391
|
+
factory.createTemplateSpan(
|
|
392
|
+
factory.createCallExpression(
|
|
398
393
|
IdentifierFactory.access(
|
|
399
|
-
|
|
394
|
+
factory.createIdentifier(variables),
|
|
400
395
|
"toString",
|
|
401
396
|
),
|
|
402
397
|
undefined,
|
|
403
398
|
undefined,
|
|
404
399
|
),
|
|
405
|
-
|
|
400
|
+
factory.createTemplateTail(""),
|
|
406
401
|
),
|
|
407
402
|
],
|
|
408
403
|
),
|
|
@@ -416,37 +411,31 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
416
411
|
return out(
|
|
417
412
|
block(
|
|
418
413
|
route.queryObject.metadata.required === false
|
|
419
|
-
?
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
),
|
|
424
|
-
TypeScriptFactory.createObjectLiteralExpression([], false),
|
|
414
|
+
? factory.createBinaryExpression(
|
|
415
|
+
factory.createIdentifier(route.queryObject.name),
|
|
416
|
+
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
417
|
+
factory.createObjectLiteralExpression([], false),
|
|
425
418
|
)
|
|
426
|
-
:
|
|
427
|
-
access(route.queryObject.name),
|
|
428
|
-
),
|
|
419
|
+
: factory.createIdentifier(access(route.queryObject.name)),
|
|
429
420
|
),
|
|
430
421
|
);
|
|
431
422
|
return out(
|
|
432
423
|
block(
|
|
433
|
-
|
|
424
|
+
factory.createObjectLiteralExpression(
|
|
434
425
|
[
|
|
435
426
|
...(route.queryObject
|
|
436
427
|
? [
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
access(route.queryObject.name),
|
|
440
|
-
),
|
|
428
|
+
factory.createSpreadAssignment(
|
|
429
|
+
factory.createIdentifier(access(route.queryObject.name)),
|
|
441
430
|
),
|
|
442
431
|
]
|
|
443
432
|
: []),
|
|
444
433
|
...route.queryParameters.map((q) =>
|
|
445
|
-
|
|
434
|
+
factory.createPropertyAssignment(
|
|
446
435
|
NamingConvention.variable(q.field!)
|
|
447
436
|
? q.field!
|
|
448
|
-
:
|
|
449
|
-
|
|
437
|
+
: factory.createStringLiteral(q.field!),
|
|
438
|
+
factory.createIdentifier(access(q.name)),
|
|
450
439
|
),
|
|
451
440
|
),
|
|
452
441
|
],
|
|
@@ -458,57 +447,55 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
458
447
|
|
|
459
448
|
const writeStringify =
|
|
460
449
|
(project: INestiaProject) =>
|
|
461
|
-
(importer: ImportDictionary):
|
|
450
|
+
(importer: ImportDictionary): Statement =>
|
|
462
451
|
constant("stringify")(
|
|
463
|
-
|
|
452
|
+
factory.createArrowFunction(
|
|
464
453
|
[],
|
|
465
454
|
undefined,
|
|
466
455
|
[
|
|
467
456
|
IdentifierFactory.parameter(
|
|
468
457
|
"input",
|
|
469
|
-
|
|
458
|
+
factory.createTypeReferenceNode("Body"),
|
|
470
459
|
),
|
|
471
460
|
],
|
|
472
461
|
undefined,
|
|
473
462
|
undefined,
|
|
474
|
-
|
|
463
|
+
factory.createCallExpression(
|
|
475
464
|
IdentifierFactory.access(
|
|
476
465
|
IdentifierFactory.access(
|
|
477
|
-
|
|
478
|
-
SdkImportWizard.typia(importer),
|
|
479
|
-
),
|
|
466
|
+
factory.createIdentifier(SdkImportWizard.typia(importer)),
|
|
480
467
|
"json",
|
|
481
468
|
),
|
|
482
469
|
project.config.assert ? "stringify" : "assertStringify",
|
|
483
470
|
),
|
|
484
471
|
undefined,
|
|
485
|
-
[
|
|
472
|
+
[factory.createIdentifier("input")],
|
|
486
473
|
),
|
|
487
474
|
),
|
|
488
475
|
);
|
|
489
476
|
}
|
|
490
477
|
|
|
491
|
-
const local = (name: string) => (type: string) => (expression:
|
|
492
|
-
|
|
478
|
+
const local = (name: string) => (type: string) => (expression: Expression) =>
|
|
479
|
+
factory.createVariableStatement(
|
|
493
480
|
[],
|
|
494
|
-
|
|
481
|
+
factory.createVariableDeclarationList(
|
|
495
482
|
[
|
|
496
|
-
|
|
483
|
+
factory.createVariableDeclaration(
|
|
497
484
|
name,
|
|
498
485
|
undefined,
|
|
499
|
-
|
|
486
|
+
factory.createTypeReferenceNode(type),
|
|
500
487
|
expression,
|
|
501
488
|
),
|
|
502
489
|
],
|
|
503
490
|
NodeFlags.Const,
|
|
504
491
|
),
|
|
505
492
|
);
|
|
506
|
-
const constant = (name: string) => (expression:
|
|
507
|
-
|
|
508
|
-
[
|
|
509
|
-
|
|
493
|
+
const constant = (name: string) => (expression: Expression) =>
|
|
494
|
+
factory.createVariableStatement(
|
|
495
|
+
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
496
|
+
factory.createVariableDeclarationList(
|
|
510
497
|
[
|
|
511
|
-
|
|
498
|
+
factory.createVariableDeclaration(
|
|
512
499
|
name,
|
|
513
500
|
undefined,
|
|
514
501
|
undefined,
|