@nestia/sdk 3.11.0-dev.20240813-11 → 3.11.0-dev.20240814
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/lib/NestiaSdkApplication.js +0 -13
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.js +2 -0
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +1 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +14 -7
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +2 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.js +3 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +60 -8
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +11 -10
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +5 -1
- package/lib/generates/internal/SdkAliasCollection.js +20 -7
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +8 -7
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +4 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js +6 -0
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +20 -13
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +15 -7
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +2 -2
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +6 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +10 -4
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.js +19 -1
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +3 -3
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/transform.js +1 -1
- package/lib/transform.js.map +1 -1
- package/lib/transformers/SdkOperationProgrammer.js +17 -11
- package/lib/transformers/SdkOperationProgrammer.js.map +1 -1
- package/lib/transformers/SdkOperationTransformer.d.ts +1 -1
- package/lib/transformers/SdkOperationTransformer.js +12 -8
- package/lib/transformers/SdkOperationTransformer.js.map +1 -1
- package/lib/validators/HttpHeadersValidator.d.ts +5 -0
- package/lib/validators/HttpHeadersValidator.js +29 -0
- package/lib/validators/HttpHeadersValidator.js.map +1 -0
- package/lib/validators/HttpQueryValidator.d.ts +5 -0
- package/lib/validators/HttpQueryValidator.js +29 -0
- package/lib/validators/HttpQueryValidator.js.map +1 -0
- package/package.json +6 -6
- package/src/NestiaSdkApplication.ts +0 -14
- package/src/analyses/ReflectControllerAnalyzer.ts +2 -0
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +1 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +37 -5
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +8 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +4 -1
- package/src/generates/SwaggerGenerator.ts +84 -10
- package/src/generates/internal/E2eFileProgrammer.ts +13 -10
- package/src/generates/internal/SdkAliasCollection.ts +28 -9
- package/src/generates/internal/SdkFileProgrammer.ts +8 -7
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +4 -1
- package/src/generates/internal/SdkHttpCloneReferencer.ts +10 -0
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +25 -16
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +248 -229
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +2 -2
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +6 -3
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +12 -8
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +1 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +25 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +3 -0
- package/src/transform.ts +1 -1
- package/src/transformers/SdkOperationProgrammer.ts +41 -36
- package/src/transformers/SdkOperationTransformer.ts +29 -8
- package/src/validators/HttpHeadersValidator.ts +34 -0
- package/src/validators/HttpQueryValidator.ts +34 -0
|
@@ -33,9 +33,9 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
33
33
|
ts.factory.createModuleBlock([
|
|
34
34
|
...types,
|
|
35
35
|
...(types.length ? [FilePrinter.enter()] : []),
|
|
36
|
-
write_metadata(importer)(route, props),
|
|
36
|
+
write_metadata(project)(importer)(route, props),
|
|
37
37
|
FilePrinter.enter(),
|
|
38
|
-
write_path(route, props.query),
|
|
38
|
+
write_path(project)(importer)(route, props.query),
|
|
39
39
|
...(project.config.simulate
|
|
40
40
|
? [
|
|
41
41
|
SdkHttpSimulationProgrammer.random(project)(importer)(route),
|
|
@@ -101,6 +101,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
const write_metadata =
|
|
104
|
+
(project: INestiaProject) =>
|
|
104
105
|
(importer: ImportDictionary) =>
|
|
105
106
|
(
|
|
106
107
|
route: ITypedHttpRoute,
|
|
@@ -162,7 +163,13 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
162
163
|
ts.factory.createIdentifier(
|
|
163
164
|
`${SdkImportWizard.typia(importer)}.http.createAssertQuery`,
|
|
164
165
|
),
|
|
165
|
-
[
|
|
166
|
+
[
|
|
167
|
+
project.config.clone === true
|
|
168
|
+
? SdkAliasCollection.from(project)(importer)(
|
|
169
|
+
route.success.metadata,
|
|
170
|
+
)
|
|
171
|
+
: SdkAliasCollection.name(route.success),
|
|
172
|
+
],
|
|
166
173
|
undefined,
|
|
167
174
|
),
|
|
168
175
|
),
|
|
@@ -177,263 +184,275 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
177
184
|
),
|
|
178
185
|
);
|
|
179
186
|
|
|
180
|
-
const write_path =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
187
|
+
const write_path =
|
|
188
|
+
(project: INestiaProject) =>
|
|
189
|
+
(importer: ImportDictionary) =>
|
|
190
|
+
(
|
|
191
|
+
route: ITypedHttpRoute,
|
|
192
|
+
query: ITypedHttpRouteParameter.IQuery | undefined,
|
|
193
|
+
): ts.VariableStatement => {
|
|
194
|
+
const g = {
|
|
195
|
+
total: [
|
|
196
|
+
...route.parameters.filter(
|
|
197
|
+
(param) => param.category === "param" || param.category === "query",
|
|
198
|
+
),
|
|
199
|
+
],
|
|
200
|
+
query: route.parameters
|
|
201
|
+
.filter((param) => param.category === "query")
|
|
202
|
+
.filter((param) => param.field !== null),
|
|
203
|
+
path: route.parameters.filter((param) => param.category === "param"),
|
|
204
|
+
};
|
|
205
|
+
const out = (body: ts.ConciseBody) =>
|
|
206
|
+
constant("path")(
|
|
207
|
+
ts.factory.createArrowFunction(
|
|
208
|
+
[],
|
|
209
|
+
[],
|
|
210
|
+
g.total.map((p) =>
|
|
211
|
+
IdentifierFactory.parameter(
|
|
212
|
+
p.name,
|
|
213
|
+
p === query
|
|
214
|
+
? p.metadata.isRequired() === false
|
|
215
|
+
? ts.factory.createUnionTypeNode([
|
|
216
|
+
ts.factory.createTypeReferenceNode(
|
|
217
|
+
`${route.name}.Query`,
|
|
218
|
+
),
|
|
219
|
+
ts.factory.createTypeReferenceNode("undefined"),
|
|
220
|
+
])
|
|
221
|
+
: ts.factory.createTypeReferenceNode(`${route.name}.Query`)
|
|
222
|
+
: project.config.clone === true
|
|
223
|
+
? SdkAliasCollection.from(project)(importer)(p.metadata)
|
|
224
|
+
: SdkAliasCollection.name(p),
|
|
225
|
+
),
|
|
211
226
|
),
|
|
227
|
+
undefined,
|
|
228
|
+
undefined,
|
|
229
|
+
body,
|
|
212
230
|
),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
),
|
|
217
|
-
);
|
|
218
|
-
if (g.total.length === 0)
|
|
219
|
-
return out(ts.factory.createStringLiteral(route.path));
|
|
231
|
+
);
|
|
232
|
+
if (g.total.length === 0)
|
|
233
|
+
return out(ts.factory.createStringLiteral(route.path));
|
|
220
234
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
const template = () => {
|
|
236
|
+
const splitted: string[] = route.path.split(":");
|
|
237
|
+
if (splitted.length === 1)
|
|
238
|
+
return ts.factory.createStringLiteral(route.path);
|
|
239
|
+
return ts.factory.createTemplateExpression(
|
|
240
|
+
ts.factory.createTemplateHead(splitted[0]),
|
|
241
|
+
splitted.slice(1).map((s, i, arr) => {
|
|
242
|
+
const name: string = s.split("/")[0];
|
|
243
|
+
return ts.factory.createTemplateSpan(
|
|
244
|
+
ts.factory.createCallExpression(
|
|
245
|
+
ts.factory.createIdentifier("encodeURIComponent"),
|
|
246
|
+
undefined,
|
|
247
|
+
[
|
|
248
|
+
ts.factory.createBinaryExpression(
|
|
249
|
+
ts.factory.createIdentifier(
|
|
250
|
+
g.path.find((p) => p.field === name)!.name,
|
|
251
|
+
),
|
|
252
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
|
|
253
|
+
ts.factory.createStringLiteral("null"),
|
|
237
254
|
),
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
);
|
|
249
|
-
};
|
|
250
|
-
if (query === undefined && g.query.length === 0) return out(template());
|
|
255
|
+
],
|
|
256
|
+
),
|
|
257
|
+
(i !== arr.length - 1
|
|
258
|
+
? ts.factory.createTemplateMiddle
|
|
259
|
+
: ts.factory.createTemplateTail)(s.substring(name.length)),
|
|
260
|
+
);
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
};
|
|
264
|
+
if (query === undefined && g.query.length === 0) return out(template());
|
|
251
265
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
),
|
|
267
|
-
ts.factory.createForOfStatement(
|
|
268
|
-
undefined,
|
|
269
|
-
ts.factory.createVariableDeclarationList(
|
|
270
|
-
[
|
|
271
|
-
ts.factory.createVariableDeclaration(
|
|
272
|
-
ts.factory.createArrayBindingPattern([
|
|
273
|
-
ts.factory.createBindingElement(
|
|
274
|
-
undefined,
|
|
275
|
-
undefined,
|
|
276
|
-
ts.factory.createIdentifier("key"),
|
|
277
|
-
undefined,
|
|
278
|
-
),
|
|
279
|
-
ts.factory.createBindingElement(
|
|
280
|
-
undefined,
|
|
281
|
-
undefined,
|
|
282
|
-
ts.factory.createIdentifier("value"),
|
|
283
|
-
undefined,
|
|
284
|
-
),
|
|
285
|
-
]),
|
|
286
|
-
undefined,
|
|
287
|
-
undefined,
|
|
288
|
-
undefined,
|
|
289
|
-
),
|
|
290
|
-
],
|
|
291
|
-
ts.NodeFlags.Const,
|
|
266
|
+
const block = (expr: ts.Expression) => {
|
|
267
|
+
const computeName = (str: string): string =>
|
|
268
|
+
g.total.find((p) => p.name === str) !== undefined
|
|
269
|
+
? computeName("_" + str)
|
|
270
|
+
: str;
|
|
271
|
+
const variables: string = computeName("variables");
|
|
272
|
+
return ts.factory.createBlock(
|
|
273
|
+
[
|
|
274
|
+
local(variables)("URLSearchParams")(
|
|
275
|
+
ts.factory.createNewExpression(
|
|
276
|
+
ts.factory.createIdentifier("URLSearchParams"),
|
|
277
|
+
[],
|
|
278
|
+
[],
|
|
279
|
+
),
|
|
292
280
|
),
|
|
293
|
-
ts.factory.
|
|
294
|
-
ts.factory.createIdentifier("Object.entries"),
|
|
281
|
+
ts.factory.createForOfStatement(
|
|
295
282
|
undefined,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
ts.factory.createIdentifier("value"),
|
|
302
|
-
),
|
|
303
|
-
ts.factory.createContinueStatement(),
|
|
304
|
-
ts.factory.createIfStatement(
|
|
305
|
-
ts.factory.createCallExpression(
|
|
306
|
-
ts.factory.createIdentifier("Array.isArray"),
|
|
307
|
-
undefined,
|
|
308
|
-
[ts.factory.createIdentifier("value")],
|
|
309
|
-
),
|
|
310
|
-
ts.factory.createExpressionStatement(
|
|
311
|
-
ts.factory.createCallExpression(
|
|
312
|
-
ts.factory.createPropertyAccessExpression(
|
|
313
|
-
ts.factory.createIdentifier("value"),
|
|
314
|
-
ts.factory.createIdentifier("forEach"),
|
|
315
|
-
),
|
|
316
|
-
undefined,
|
|
317
|
-
[
|
|
318
|
-
ts.factory.createArrowFunction(
|
|
283
|
+
ts.factory.createVariableDeclarationList(
|
|
284
|
+
[
|
|
285
|
+
ts.factory.createVariableDeclaration(
|
|
286
|
+
ts.factory.createArrayBindingPattern([
|
|
287
|
+
ts.factory.createBindingElement(
|
|
319
288
|
undefined,
|
|
320
289
|
undefined,
|
|
321
|
-
|
|
290
|
+
ts.factory.createIdentifier("key"),
|
|
322
291
|
undefined,
|
|
292
|
+
),
|
|
293
|
+
ts.factory.createBindingElement(
|
|
294
|
+
undefined,
|
|
295
|
+
undefined,
|
|
296
|
+
ts.factory.createIdentifier("value"),
|
|
323
297
|
undefined,
|
|
324
|
-
ts.factory.createCallExpression(
|
|
325
|
-
IdentifierFactory.access(
|
|
326
|
-
ts.factory.createIdentifier(variables),
|
|
327
|
-
)("append"),
|
|
328
|
-
undefined,
|
|
329
|
-
[
|
|
330
|
-
ts.factory.createIdentifier("key"),
|
|
331
|
-
ts.factory.createCallExpression(
|
|
332
|
-
ts.factory.createIdentifier("String"),
|
|
333
|
-
undefined,
|
|
334
|
-
[ts.factory.createIdentifier("elem")],
|
|
335
|
-
),
|
|
336
|
-
],
|
|
337
|
-
),
|
|
338
298
|
),
|
|
339
|
-
],
|
|
299
|
+
]),
|
|
300
|
+
undefined,
|
|
301
|
+
undefined,
|
|
302
|
+
undefined,
|
|
340
303
|
),
|
|
304
|
+
],
|
|
305
|
+
ts.NodeFlags.Const,
|
|
306
|
+
),
|
|
307
|
+
ts.factory.createCallExpression(
|
|
308
|
+
ts.factory.createIdentifier("Object.entries"),
|
|
309
|
+
undefined,
|
|
310
|
+
[
|
|
311
|
+
ts.factory.createAsExpression(
|
|
312
|
+
expr,
|
|
313
|
+
TypeFactory.keyword("any"),
|
|
314
|
+
),
|
|
315
|
+
],
|
|
316
|
+
),
|
|
317
|
+
ts.factory.createIfStatement(
|
|
318
|
+
ts.factory.createStrictEquality(
|
|
319
|
+
ts.factory.createIdentifier("undefined"),
|
|
320
|
+
ts.factory.createIdentifier("value"),
|
|
341
321
|
),
|
|
342
|
-
ts.factory.
|
|
322
|
+
ts.factory.createContinueStatement(),
|
|
323
|
+
ts.factory.createIfStatement(
|
|
343
324
|
ts.factory.createCallExpression(
|
|
344
|
-
|
|
345
|
-
ts.factory.createIdentifier(variables),
|
|
346
|
-
)("set"),
|
|
325
|
+
ts.factory.createIdentifier("Array.isArray"),
|
|
347
326
|
undefined,
|
|
348
|
-
[
|
|
349
|
-
ts.factory.createIdentifier("key"),
|
|
350
|
-
ts.factory.createCallExpression(
|
|
351
|
-
ts.factory.createIdentifier("String"),
|
|
352
|
-
undefined,
|
|
353
|
-
[ts.factory.createIdentifier("value")],
|
|
354
|
-
),
|
|
355
|
-
],
|
|
327
|
+
[ts.factory.createIdentifier("value")],
|
|
356
328
|
),
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
329
|
+
ts.factory.createExpressionStatement(
|
|
330
|
+
ts.factory.createCallExpression(
|
|
331
|
+
ts.factory.createPropertyAccessExpression(
|
|
332
|
+
ts.factory.createIdentifier("value"),
|
|
333
|
+
ts.factory.createIdentifier("forEach"),
|
|
334
|
+
),
|
|
335
|
+
undefined,
|
|
336
|
+
[
|
|
337
|
+
ts.factory.createArrowFunction(
|
|
338
|
+
undefined,
|
|
339
|
+
undefined,
|
|
340
|
+
[IdentifierFactory.parameter("elem")],
|
|
341
|
+
undefined,
|
|
342
|
+
undefined,
|
|
343
|
+
ts.factory.createCallExpression(
|
|
344
|
+
IdentifierFactory.access(
|
|
345
|
+
ts.factory.createIdentifier(variables),
|
|
346
|
+
)("append"),
|
|
347
|
+
undefined,
|
|
348
|
+
[
|
|
349
|
+
ts.factory.createIdentifier("key"),
|
|
350
|
+
ts.factory.createCallExpression(
|
|
351
|
+
ts.factory.createIdentifier("String"),
|
|
352
|
+
undefined,
|
|
353
|
+
[ts.factory.createIdentifier("elem")],
|
|
354
|
+
),
|
|
355
|
+
],
|
|
356
|
+
),
|
|
357
|
+
),
|
|
358
|
+
],
|
|
359
|
+
),
|
|
379
360
|
),
|
|
380
|
-
ts.factory.
|
|
361
|
+
ts.factory.createExpressionStatement(
|
|
381
362
|
ts.factory.createCallExpression(
|
|
382
363
|
IdentifierFactory.access(
|
|
383
364
|
ts.factory.createIdentifier(variables),
|
|
384
|
-
)("
|
|
385
|
-
undefined,
|
|
365
|
+
)("set"),
|
|
386
366
|
undefined,
|
|
367
|
+
[
|
|
368
|
+
ts.factory.createIdentifier("key"),
|
|
369
|
+
ts.factory.createCallExpression(
|
|
370
|
+
ts.factory.createIdentifier("String"),
|
|
371
|
+
undefined,
|
|
372
|
+
[ts.factory.createIdentifier("value")],
|
|
373
|
+
),
|
|
374
|
+
],
|
|
387
375
|
),
|
|
388
|
-
ts.factory.createTemplateTail(""),
|
|
389
376
|
),
|
|
390
|
-
|
|
377
|
+
),
|
|
391
378
|
),
|
|
392
379
|
),
|
|
380
|
+
local("location")("string")(template()),
|
|
381
|
+
ts.factory.createReturnStatement(
|
|
382
|
+
ts.factory.createConditionalExpression(
|
|
383
|
+
ts.factory.createStrictEquality(
|
|
384
|
+
ExpressionFactory.number(0),
|
|
385
|
+
IdentifierFactory.access(
|
|
386
|
+
ts.factory.createIdentifier(variables),
|
|
387
|
+
)("size"),
|
|
388
|
+
),
|
|
389
|
+
undefined,
|
|
390
|
+
ts.factory.createIdentifier("location"),
|
|
391
|
+
undefined,
|
|
392
|
+
ts.factory.createTemplateExpression(
|
|
393
|
+
ts.factory.createTemplateHead(""),
|
|
394
|
+
[
|
|
395
|
+
ts.factory.createTemplateSpan(
|
|
396
|
+
ts.factory.createIdentifier("location"),
|
|
397
|
+
ts.factory.createTemplateMiddle("?"),
|
|
398
|
+
),
|
|
399
|
+
ts.factory.createTemplateSpan(
|
|
400
|
+
ts.factory.createCallExpression(
|
|
401
|
+
IdentifierFactory.access(
|
|
402
|
+
ts.factory.createIdentifier(variables),
|
|
403
|
+
)("toString"),
|
|
404
|
+
undefined,
|
|
405
|
+
undefined,
|
|
406
|
+
),
|
|
407
|
+
ts.factory.createTemplateTail(""),
|
|
408
|
+
),
|
|
409
|
+
],
|
|
410
|
+
),
|
|
411
|
+
),
|
|
412
|
+
),
|
|
413
|
+
],
|
|
414
|
+
true,
|
|
415
|
+
);
|
|
416
|
+
};
|
|
417
|
+
if (query !== undefined && g.query.length === 0)
|
|
418
|
+
return out(
|
|
419
|
+
block(
|
|
420
|
+
query.metadata.isRequired() === false
|
|
421
|
+
? ts.factory.createBinaryExpression(
|
|
422
|
+
ts.factory.createIdentifier(query.name),
|
|
423
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
|
|
424
|
+
ts.factory.createObjectLiteralExpression([], false),
|
|
425
|
+
)
|
|
426
|
+
: ts.factory.createIdentifier(query.name),
|
|
393
427
|
),
|
|
394
|
-
|
|
395
|
-
true,
|
|
396
|
-
);
|
|
397
|
-
};
|
|
398
|
-
if (query !== undefined && g.query.length === 0)
|
|
428
|
+
);
|
|
399
429
|
return out(
|
|
400
430
|
block(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
431
|
+
ts.factory.createObjectLiteralExpression(
|
|
432
|
+
[
|
|
433
|
+
...(query
|
|
434
|
+
? [
|
|
435
|
+
ts.factory.createSpreadAssignment(
|
|
436
|
+
ts.factory.createIdentifier(query.name),
|
|
437
|
+
),
|
|
438
|
+
]
|
|
439
|
+
: []),
|
|
440
|
+
...g.query.map((q) =>
|
|
441
|
+
q.name === q.field
|
|
442
|
+
? ts.factory.createShorthandPropertyAssignment(q.name)
|
|
443
|
+
: ts.factory.createPropertyAssignment(
|
|
444
|
+
Escaper.variable(q.field!)
|
|
445
|
+
? q.field!
|
|
446
|
+
: ts.factory.createStringLiteral(q.field!),
|
|
447
|
+
ts.factory.createIdentifier(q.name),
|
|
448
|
+
),
|
|
449
|
+
),
|
|
450
|
+
],
|
|
451
|
+
true,
|
|
452
|
+
),
|
|
408
453
|
),
|
|
409
454
|
);
|
|
410
|
-
|
|
411
|
-
block(
|
|
412
|
-
ts.factory.createObjectLiteralExpression(
|
|
413
|
-
[
|
|
414
|
-
...(query
|
|
415
|
-
? [
|
|
416
|
-
ts.factory.createSpreadAssignment(
|
|
417
|
-
ts.factory.createIdentifier(query.name),
|
|
418
|
-
),
|
|
419
|
-
]
|
|
420
|
-
: []),
|
|
421
|
-
...g.query.map((q) =>
|
|
422
|
-
q.name === q.field
|
|
423
|
-
? ts.factory.createShorthandPropertyAssignment(q.name)
|
|
424
|
-
: ts.factory.createPropertyAssignment(
|
|
425
|
-
Escaper.variable(q.field!)
|
|
426
|
-
? q.field!
|
|
427
|
-
: ts.factory.createStringLiteral(q.field!),
|
|
428
|
-
ts.factory.createIdentifier(q.name),
|
|
429
|
-
),
|
|
430
|
-
),
|
|
431
|
-
],
|
|
432
|
-
true,
|
|
433
|
-
),
|
|
434
|
-
),
|
|
435
|
-
);
|
|
436
|
-
};
|
|
455
|
+
};
|
|
437
456
|
|
|
438
457
|
const write_stringify =
|
|
439
458
|
(project: INestiaProject) =>
|
|
@@ -16,10 +16,10 @@ export namespace SdkHttpRouteProgrammer {
|
|
|
16
16
|
const props = {
|
|
17
17
|
headers: route.parameters
|
|
18
18
|
.filter((p) => p.category === "headers")
|
|
19
|
-
.find((p) => p.field ===
|
|
19
|
+
.find((p) => p.field === null),
|
|
20
20
|
query: route.parameters
|
|
21
21
|
.filter((p) => p.category === "query")
|
|
22
|
-
.find((p) => p.field ===
|
|
22
|
+
.find((p) => p.field === null),
|
|
23
23
|
input: route.parameters.find((p) => p.category === "body"),
|
|
24
24
|
};
|
|
25
25
|
return [
|
|
@@ -68,7 +68,8 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
68
68
|
},
|
|
69
69
|
): ts.VariableStatement => {
|
|
70
70
|
const output: boolean =
|
|
71
|
-
project.config.propagate === true ||
|
|
71
|
+
project.config.propagate === true ||
|
|
72
|
+
route.success.metadata.size() !== 0;
|
|
72
73
|
const caller = () =>
|
|
73
74
|
ts.factory.createCallExpression(
|
|
74
75
|
ts.factory.createIdentifier("random"),
|
|
@@ -105,7 +106,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
105
106
|
ts.factory.createTypeReferenceNode(
|
|
106
107
|
SdkImportWizard.IConnection(importer),
|
|
107
108
|
route.parameters.some(
|
|
108
|
-
(p) => p.category === "headers" && p.field ===
|
|
109
|
+
(p) => p.category === "headers" && p.field === null,
|
|
109
110
|
)
|
|
110
111
|
? [
|
|
111
112
|
ts.factory.createTypeReferenceNode(
|
|
@@ -130,7 +131,9 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
130
131
|
? ts.factory.createTypeReferenceNode(
|
|
131
132
|
`${route.name}.${p === props.query ? "Query" : "Input"}`,
|
|
132
133
|
)
|
|
133
|
-
:
|
|
134
|
+
: project.config.clone === true
|
|
135
|
+
? SdkAliasCollection.from(project)(importer)(p.metadata)
|
|
136
|
+
: SdkAliasCollection.name(p),
|
|
134
137
|
),
|
|
135
138
|
),
|
|
136
139
|
],
|
|
@@ -82,22 +82,26 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
82
82
|
route.parameters.find((x) => x.category === "driver");
|
|
83
83
|
declare(
|
|
84
84
|
"Header",
|
|
85
|
-
SdkAliasCollection.name(
|
|
86
|
-
(route.parameters.find((x) => x.category === "header")?.type ??
|
|
85
|
+
SdkAliasCollection.name({
|
|
86
|
+
type: (route.parameters.find((x) => x.category === "header")?.type ??
|
|
87
87
|
acceptor.type.typeArguments?.[0])!,
|
|
88
|
-
),
|
|
88
|
+
}),
|
|
89
89
|
);
|
|
90
90
|
declare(
|
|
91
91
|
"Provider",
|
|
92
|
-
SdkAliasCollection.name(
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
SdkAliasCollection.name({
|
|
93
|
+
type:
|
|
94
|
+
driver?.type.typeArguments?.[0] ??
|
|
95
|
+
acceptor.type.typeArguments?.[2]!,
|
|
96
|
+
}),
|
|
95
97
|
);
|
|
96
98
|
declare(
|
|
97
99
|
"Listener",
|
|
98
|
-
SdkAliasCollection.name(
|
|
100
|
+
SdkAliasCollection.name({
|
|
101
|
+
type: acceptor.type.typeArguments?.[1]!,
|
|
102
|
+
}),
|
|
99
103
|
);
|
|
100
|
-
if (query) declare("Query", SdkAliasCollection.name(query
|
|
104
|
+
if (query) declare("Query", SdkAliasCollection.name(query));
|
|
101
105
|
return output;
|
|
102
106
|
};
|
|
103
107
|
|
|
@@ -78,7 +78,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
78
78
|
IdentifierFactory.parameter(
|
|
79
79
|
p.name,
|
|
80
80
|
p.category === "param"
|
|
81
|
-
? SdkAliasCollection.name(p
|
|
81
|
+
? SdkAliasCollection.name(p)
|
|
82
82
|
: ts.factory.createTypeReferenceNode(`${route.name}.Query`),
|
|
83
83
|
),
|
|
84
84
|
),
|
|
@@ -2,6 +2,7 @@ import { OpenApi } from "@samchon/openapi";
|
|
|
2
2
|
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
3
3
|
|
|
4
4
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
|
+
import { SecurityAnalyzer } from "../../analyses/SecurityAnalyzer";
|
|
5
6
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
6
7
|
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
7
8
|
import { SwaggerDescriptionComposer } from "./SwaggerDescriptionComposer";
|
|
@@ -44,6 +45,29 @@ export namespace SwaggerOperationComposer {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
// SECURITY
|
|
49
|
+
const security: Record<string, string[]>[] = SecurityAnalyzer.merge(
|
|
50
|
+
...props.route.controller.security,
|
|
51
|
+
...props.route.security,
|
|
52
|
+
...props.route.jsDocTags
|
|
53
|
+
.filter((tag) => tag.name === "security")
|
|
54
|
+
.map((tag) =>
|
|
55
|
+
tag.text === undefined
|
|
56
|
+
? [{}]
|
|
57
|
+
: tag.text.map((text) => {
|
|
58
|
+
const line: string[] = text.text
|
|
59
|
+
.split(" ")
|
|
60
|
+
.filter((s) => s.trim())
|
|
61
|
+
.filter((s) => !!s.length);
|
|
62
|
+
if (line.length === 0) return {};
|
|
63
|
+
return {
|
|
64
|
+
[line[0]]: line.slice(1),
|
|
65
|
+
};
|
|
66
|
+
}),
|
|
67
|
+
)
|
|
68
|
+
.flat(),
|
|
69
|
+
);
|
|
70
|
+
|
|
47
71
|
// FINALIZE
|
|
48
72
|
return {
|
|
49
73
|
...SwaggerDescriptionComposer.compose({
|
|
@@ -85,6 +109,7 @@ export namespace SwaggerOperationComposer {
|
|
|
85
109
|
schema: props.schema,
|
|
86
110
|
route: props.route,
|
|
87
111
|
}),
|
|
112
|
+
security: security.length ? security : undefined,
|
|
88
113
|
};
|
|
89
114
|
};
|
|
90
115
|
}
|