@nestia/sdk 7.0.0-dev.20250605-3 → 7.0.0-dev.20250607
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/analyses/TypedHttpRouteAnalyzer.js +12 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +4 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/generates/SdkGenerator.js +2 -1
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +3 -3
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +17 -22
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +3 -1
- package/lib/generates/internal/SdkAliasCollection.js +37 -9
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +4 -4
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js +2 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +1 -6
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +44 -53
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +1 -6
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -66
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +41 -0
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +110 -0
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +6 -18
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +1 -6
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +23 -31
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +18 -8
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +2 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +33 -27
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +22 -0
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +58 -0
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +2 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +65 -51
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.js +9 -6
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/structures/ITypedHttpRoute.d.ts +6 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +2 -2
- package/lib/structures/ITypedWebSocketRoute.d.ts +5 -1
- package/package.json +5 -5
- package/src/analyses/TypedHttpRouteAnalyzer.ts +28 -10
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +15 -0
- package/src/generates/SdkGenerator.ts +2 -1
- package/src/generates/SwaggerGenerator.ts +5 -13
- package/src/generates/internal/E2eFileProgrammer.ts +34 -43
- package/src/generates/internal/SdkAliasCollection.ts +66 -15
- package/src/generates/internal/SdkFileProgrammer.ts +1 -1
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +4 -4
- package/src/generates/internal/SdkHttpCloneReferencer.ts +5 -1
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +51 -100
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +58 -118
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +178 -0
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +9 -21
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +23 -69
- package/src/generates/internal/SdkTypeProgrammer.ts +39 -32
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +214 -210
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +87 -0
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +112 -98
- package/src/generates/internal/SwaggerOperationComposer.ts +9 -9
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +1 -1
- package/src/structures/ITypedHttpRoute.ts +12 -1
- package/src/structures/ITypedHttpRouteParameter.ts +2 -2
- package/src/structures/ITypedWebSocketRoute.ts +5 -1
|
@@ -7,9 +7,9 @@ import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
|
7
7
|
|
|
8
8
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
9
9
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
10
|
-
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
11
10
|
import { ImportDictionary } from "./ImportDictionary";
|
|
12
11
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
12
|
+
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
13
13
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
14
14
|
|
|
15
15
|
export namespace SdkHttpSimulationProgrammer {
|
|
@@ -60,14 +60,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
60
60
|
export const simulate =
|
|
61
61
|
(project: INestiaProject) =>
|
|
62
62
|
(importer: ImportDictionary) =>
|
|
63
|
-
(
|
|
64
|
-
route: ITypedHttpRoute,
|
|
65
|
-
props: {
|
|
66
|
-
headers: ITypedHttpRouteParameter.IHeaders | undefined;
|
|
67
|
-
query: ITypedHttpRouteParameter.IQuery | undefined;
|
|
68
|
-
body: ITypedHttpRouteParameter.IBody | undefined;
|
|
69
|
-
},
|
|
70
|
-
): ts.VariableStatement => {
|
|
63
|
+
(route: ITypedHttpRoute): ts.VariableStatement => {
|
|
71
64
|
const output: boolean =
|
|
72
65
|
project.config.propagate === true ||
|
|
73
66
|
route.success.metadata.size() !== 0;
|
|
@@ -96,7 +89,6 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
96
89
|
),
|
|
97
90
|
],
|
|
98
91
|
);
|
|
99
|
-
|
|
100
92
|
return constant("simulate")(
|
|
101
93
|
ts.factory.createArrowFunction(
|
|
102
94
|
undefined,
|
|
@@ -106,9 +98,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
106
98
|
"connection",
|
|
107
99
|
ts.factory.createTypeReferenceNode(
|
|
108
100
|
SdkImportWizard.IConnection(importer),
|
|
109
|
-
route.
|
|
110
|
-
(p) => p.category === "headers" && p.field === null,
|
|
111
|
-
)
|
|
101
|
+
route.headerObject
|
|
112
102
|
? [
|
|
113
103
|
ts.factory.createTypeReferenceNode(
|
|
114
104
|
`${route.name}.Headers`,
|
|
@@ -117,42 +107,15 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
117
107
|
: [],
|
|
118
108
|
),
|
|
119
109
|
),
|
|
120
|
-
...(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"props",
|
|
128
|
-
undefined,
|
|
129
|
-
ts.factory.createTypeReferenceNode("IProps"),
|
|
130
|
-
),
|
|
131
|
-
]
|
|
132
|
-
: route.parameters
|
|
133
|
-
.filter((p) => p.category !== "headers")
|
|
134
|
-
.map((p) =>
|
|
135
|
-
ts.factory.createParameterDeclaration(
|
|
136
|
-
[],
|
|
137
|
-
undefined,
|
|
138
|
-
p.name,
|
|
139
|
-
p.metadata.optional
|
|
140
|
-
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
141
|
-
: undefined,
|
|
142
|
-
project.config.primitive !== false &&
|
|
143
|
-
(p === props.query || p === props.body)
|
|
144
|
-
? ts.factory.createTypeReferenceNode(
|
|
145
|
-
`${route.name}.${p === props.query ? "Query" : "Body"}`,
|
|
146
|
-
)
|
|
147
|
-
: project.config.clone === true
|
|
148
|
-
? SdkAliasCollection.from(project)(importer)(
|
|
149
|
-
p.metadata,
|
|
150
|
-
)
|
|
151
|
-
: SdkAliasCollection.name(p),
|
|
152
|
-
),
|
|
153
|
-
)),
|
|
110
|
+
...SdkHttpParameterProgrammer.getParameterDeclarations({
|
|
111
|
+
project,
|
|
112
|
+
importer,
|
|
113
|
+
route,
|
|
114
|
+
body: true,
|
|
115
|
+
prefix: false,
|
|
116
|
+
}),
|
|
154
117
|
],
|
|
155
|
-
ts.factory.createTypeReferenceNode(output ? "
|
|
118
|
+
ts.factory.createTypeReferenceNode(output ? "Output" : "void"),
|
|
156
119
|
undefined,
|
|
157
120
|
ts.factory.createBlock(
|
|
158
121
|
[
|
|
@@ -183,7 +146,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
183
146
|
],
|
|
184
147
|
true,
|
|
185
148
|
),
|
|
186
|
-
ts.factory.createTypeReferenceNode("
|
|
149
|
+
ts.factory.createTypeReferenceNode("Output"),
|
|
187
150
|
)
|
|
188
151
|
: caller(),
|
|
189
152
|
),
|
|
@@ -198,15 +161,9 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
198
161
|
(project: INestiaProject) =>
|
|
199
162
|
(importer: ImportDictionary) =>
|
|
200
163
|
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
201
|
-
const parameters =
|
|
202
|
-
(p) => p.category !== "headers",
|
|
203
|
-
);
|
|
164
|
+
const parameters = SdkHttpParameterProgrammer.getSignificant(route, true);
|
|
204
165
|
if (parameters.length === 0) return [];
|
|
205
166
|
|
|
206
|
-
const access = (key: string) =>
|
|
207
|
-
project.config.keyword === true
|
|
208
|
-
? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
|
|
209
|
-
: ts.factory.createIdentifier(key);
|
|
210
167
|
const typia = SdkImportWizard.typia(importer);
|
|
211
168
|
const validator = StatementFactory.constant({
|
|
212
169
|
name: "assert",
|
|
@@ -238,17 +195,11 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
238
195
|
ts.factory.createCallExpression(
|
|
239
196
|
ts.factory.createIdentifier("path"),
|
|
240
197
|
undefined,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
: route.parameters
|
|
247
|
-
.filter(
|
|
248
|
-
(p) =>
|
|
249
|
-
p.category === "param" || p.category === "query",
|
|
250
|
-
)
|
|
251
|
-
.map((p) => ts.factory.createIdentifier(p.name)),
|
|
198
|
+
SdkHttpParameterProgrammer.getArguments({
|
|
199
|
+
project,
|
|
200
|
+
route,
|
|
201
|
+
body: false,
|
|
202
|
+
}),
|
|
252
203
|
),
|
|
253
204
|
),
|
|
254
205
|
ts.factory.createPropertyAssignment(
|
|
@@ -290,14 +241,17 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
290
241
|
"assert",
|
|
291
242
|
),
|
|
292
243
|
undefined,
|
|
293
|
-
[
|
|
244
|
+
[
|
|
245
|
+
project.config.keyword === true
|
|
246
|
+
? ts.factory.createIdentifier(`props.${p.name}`)
|
|
247
|
+
: ts.factory.createIdentifier(p.name),
|
|
248
|
+
],
|
|
294
249
|
),
|
|
295
250
|
),
|
|
296
251
|
],
|
|
297
252
|
),
|
|
298
253
|
)
|
|
299
254
|
.map(ts.factory.createExpressionStatement);
|
|
300
|
-
|
|
301
255
|
return [
|
|
302
256
|
validator,
|
|
303
257
|
...(project.config.propagate !== true
|
|
@@ -75,19 +75,16 @@ export namespace SdkTypeProgrammer {
|
|
|
75
75
|
(object: MetadataObjectType): ts.TypeNode => {
|
|
76
76
|
const regular = object.properties.filter((p) => p.key.isSoleLiteral());
|
|
77
77
|
const dynamic = object.properties.filter((p) => !p.key.isSoleLiteral());
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
: write_regular_property(project)(importer)(regular),
|
|
89
|
-
writeComment([])(object.description ?? null, object.jsDocTags),
|
|
90
|
-
);
|
|
78
|
+
return regular.length && dynamic.length
|
|
79
|
+
? ts.factory.createIntersectionTypeNode([
|
|
80
|
+
write_regular_property(project)(importer)(regular),
|
|
81
|
+
...dynamic.map(write_dynamic_property(project)(importer)),
|
|
82
|
+
])
|
|
83
|
+
: dynamic.length
|
|
84
|
+
? ts.factory.createIntersectionTypeNode(
|
|
85
|
+
dynamic.map(write_dynamic_property(project)(importer)),
|
|
86
|
+
)
|
|
87
|
+
: write_regular_property(project)(importer)(regular);
|
|
91
88
|
};
|
|
92
89
|
|
|
93
90
|
const write_escaped =
|
|
@@ -238,25 +235,35 @@ export namespace SdkTypeProgrammer {
|
|
|
238
235
|
(importer: ImportDictionary) =>
|
|
239
236
|
(properties: MetadataProperty[]): ts.TypeLiteralNode =>
|
|
240
237
|
ts.factory.createTypeLiteralNode(
|
|
241
|
-
properties
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
238
|
+
properties
|
|
239
|
+
.map((p) => {
|
|
240
|
+
const description: string = writeComment(p.value.atomics)(
|
|
241
|
+
p.description,
|
|
242
|
+
p.jsDocTags,
|
|
243
|
+
);
|
|
244
|
+
const signature: ts.PropertySignature =
|
|
245
|
+
ts.factory.createPropertySignature(
|
|
246
|
+
undefined,
|
|
247
|
+
Escaper.variable(String(p.key.constants[0].values[0].value))
|
|
248
|
+
? ts.factory.createIdentifier(
|
|
249
|
+
String(p.key.constants[0].values[0].value),
|
|
250
|
+
)
|
|
251
|
+
: ts.factory.createStringLiteral(
|
|
252
|
+
String(p.key.constants[0].values[0].value),
|
|
253
|
+
),
|
|
254
|
+
p.value.isRequired() === false
|
|
255
|
+
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
256
|
+
: undefined,
|
|
257
|
+
SdkTypeProgrammer.write(project)(importer)(p.value),
|
|
258
|
+
);
|
|
259
|
+
return !!description.length
|
|
260
|
+
? [
|
|
261
|
+
ts.factory.createIdentifier("\n") as any,
|
|
262
|
+
FilePrinter.description(signature, description),
|
|
263
|
+
]
|
|
264
|
+
: signature;
|
|
265
|
+
})
|
|
266
|
+
.flat(),
|
|
260
267
|
);
|
|
261
268
|
|
|
262
269
|
const write_dynamic_property =
|