@nestia/sdk 7.0.0-dev.20250606 → 7.0.0-dev.20250608
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 +23 -12
- 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/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 +33 -48
- 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 -34
- package/lib/generates/internal/SdkHttpSimulationProgrammer.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 +46 -17
- package/src/generates/internal/SdkFileProgrammer.ts +1 -1
- package/src/generates/internal/SdkHttpCloneReferencer.ts +5 -1
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +49 -109
- 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 -77
- 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,28 +89,6 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
96
89
|
),
|
|
97
90
|
],
|
|
98
91
|
);
|
|
99
|
-
|
|
100
|
-
interface IProperty {
|
|
101
|
-
key: string;
|
|
102
|
-
type: ts.TypeNode;
|
|
103
|
-
optional: boolean;
|
|
104
|
-
}
|
|
105
|
-
const properties: IProperty[] = route.parameters
|
|
106
|
-
.filter((p) => p.category !== "headers")
|
|
107
|
-
.map((p) => ({
|
|
108
|
-
key: p.name,
|
|
109
|
-
type:
|
|
110
|
-
project.config.primitive !== false &&
|
|
111
|
-
(p === props.query || p === props.body)
|
|
112
|
-
? ts.factory.createTypeReferenceNode(
|
|
113
|
-
`${route.name}.${p === props.query ? "Query" : "Body"}`,
|
|
114
|
-
)
|
|
115
|
-
: project.config.clone === true
|
|
116
|
-
? SdkAliasCollection.from(project)(importer)(p.metadata)
|
|
117
|
-
: SdkAliasCollection.name(p),
|
|
118
|
-
optional: p.metadata.optional,
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
92
|
return constant("simulate")(
|
|
122
93
|
ts.factory.createArrowFunction(
|
|
123
94
|
undefined,
|
|
@@ -127,9 +98,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
127
98
|
"connection",
|
|
128
99
|
ts.factory.createTypeReferenceNode(
|
|
129
100
|
SdkImportWizard.IConnection(importer),
|
|
130
|
-
route.
|
|
131
|
-
(p) => p.category === "headers" && p.field === null,
|
|
132
|
-
)
|
|
101
|
+
route.headerObject
|
|
133
102
|
? [
|
|
134
103
|
ts.factory.createTypeReferenceNode(
|
|
135
104
|
`${route.name}.Headers`,
|
|
@@ -138,29 +107,15 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
138
107
|
: [],
|
|
139
108
|
),
|
|
140
109
|
),
|
|
141
|
-
...(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
ts.factory.createTypeReferenceNode("IProps"),
|
|
149
|
-
),
|
|
150
|
-
]
|
|
151
|
-
: properties.map((p) =>
|
|
152
|
-
ts.factory.createParameterDeclaration(
|
|
153
|
-
[],
|
|
154
|
-
undefined,
|
|
155
|
-
p.key,
|
|
156
|
-
p.optional === true
|
|
157
|
-
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
158
|
-
: undefined,
|
|
159
|
-
p.type,
|
|
160
|
-
),
|
|
161
|
-
)),
|
|
110
|
+
...SdkHttpParameterProgrammer.getParameterDeclarations({
|
|
111
|
+
project,
|
|
112
|
+
importer,
|
|
113
|
+
route,
|
|
114
|
+
body: true,
|
|
115
|
+
prefix: false,
|
|
116
|
+
}),
|
|
162
117
|
],
|
|
163
|
-
ts.factory.createTypeReferenceNode(output ? "
|
|
118
|
+
ts.factory.createTypeReferenceNode(output ? "Output" : "void"),
|
|
164
119
|
undefined,
|
|
165
120
|
ts.factory.createBlock(
|
|
166
121
|
[
|
|
@@ -191,7 +146,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
191
146
|
],
|
|
192
147
|
true,
|
|
193
148
|
),
|
|
194
|
-
ts.factory.createTypeReferenceNode("
|
|
149
|
+
ts.factory.createTypeReferenceNode("Output"),
|
|
195
150
|
)
|
|
196
151
|
: caller(),
|
|
197
152
|
),
|
|
@@ -206,15 +161,9 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
206
161
|
(project: INestiaProject) =>
|
|
207
162
|
(importer: ImportDictionary) =>
|
|
208
163
|
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
209
|
-
const parameters =
|
|
210
|
-
(p) => p.category !== "headers",
|
|
211
|
-
);
|
|
164
|
+
const parameters = SdkHttpParameterProgrammer.getSignificant(route, true);
|
|
212
165
|
if (parameters.length === 0) return [];
|
|
213
166
|
|
|
214
|
-
const access = (key: string) =>
|
|
215
|
-
project.config.keyword === true
|
|
216
|
-
? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
|
|
217
|
-
: ts.factory.createIdentifier(key);
|
|
218
167
|
const typia = SdkImportWizard.typia(importer);
|
|
219
168
|
const validator = StatementFactory.constant({
|
|
220
169
|
name: "assert",
|
|
@@ -246,17 +195,11 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
246
195
|
ts.factory.createCallExpression(
|
|
247
196
|
ts.factory.createIdentifier("path"),
|
|
248
197
|
undefined,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
: route.parameters
|
|
255
|
-
.filter(
|
|
256
|
-
(p) =>
|
|
257
|
-
p.category === "param" || p.category === "query",
|
|
258
|
-
)
|
|
259
|
-
.map((p) => ts.factory.createIdentifier(p.name)),
|
|
198
|
+
SdkHttpParameterProgrammer.getArguments({
|
|
199
|
+
project,
|
|
200
|
+
route,
|
|
201
|
+
body: false,
|
|
202
|
+
}),
|
|
260
203
|
),
|
|
261
204
|
),
|
|
262
205
|
ts.factory.createPropertyAssignment(
|
|
@@ -298,14 +241,17 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
298
241
|
"assert",
|
|
299
242
|
),
|
|
300
243
|
undefined,
|
|
301
|
-
[
|
|
244
|
+
[
|
|
245
|
+
project.config.keyword === true
|
|
246
|
+
? ts.factory.createIdentifier(`props.${p.name}`)
|
|
247
|
+
: ts.factory.createIdentifier(p.name),
|
|
248
|
+
],
|
|
302
249
|
),
|
|
303
250
|
),
|
|
304
251
|
],
|
|
305
252
|
),
|
|
306
253
|
)
|
|
307
254
|
.map(ts.factory.createExpressionStatement);
|
|
308
|
-
|
|
309
255
|
return [
|
|
310
256
|
validator,
|
|
311
257
|
...(project.config.propagate !== true
|