@nestia/migrate 0.7.1 → 0.7.3
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/MigrateApplication.js +43 -25
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MethodAnalyzer.js +25 -11
- package/lib/analyzers/MethodAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +3 -8
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/executable/bundle.js +7 -1
- package/lib/executable/bundle.js.map +1 -1
- package/lib/programmers/ApiFunctionProgrammer.js +2 -2
- package/lib/programmers/ApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/ApiNamespaceProgrammer.js +1 -1
- package/lib/programmers/ApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/NestMethodProgrammer.js +49 -37
- package/lib/programmers/NestMethodProgrammer.js.map +1 -1
- package/lib/programmers/SchemaProgrammer.js +2 -0
- package/lib/programmers/SchemaProgrammer.js.map +1 -1
- package/lib/structures/IMigrateRoute.d.ts +1 -1
- package/lib/structures/ISwaggerRoute.d.ts +3 -0
- package/package.json +68 -68
- package/src/analyzers/MethodAnalyzer.ts +37 -18
- package/src/bundles/NEST_TEMPLATE.ts +3 -8
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/executable/bundle.ts +7 -1
- package/src/programmers/ApiFunctionProgrammer.ts +2 -3
- package/src/programmers/ApiNamespaceProgrammer.ts +1 -1
- package/src/programmers/NestMethodProgrammer.ts +27 -12
- package/src/programmers/SchemaProgrammer.ts +3 -0
- package/src/structures/IMigrateRoute.ts +2 -1
- package/src/structures/ISwaggerRoute.ts +3 -0
@@ -99,8 +99,7 @@ export namespace ApiFunctionProgrammer {
|
|
99
99
|
(importer: ImportProgrammer) =>
|
100
100
|
(props: IProps): ts.Statement[] => {
|
101
101
|
const encrypted: boolean = !!props.route.success?.["x-nestia-encrypted"];
|
102
|
-
const contentType: string =
|
103
|
-
props.route.success?.type ?? "application/json";
|
102
|
+
const contentType: string = props.route.body?.type ?? "application/json";
|
104
103
|
|
105
104
|
const caller = () =>
|
106
105
|
ts.factory.createCallExpression(
|
@@ -115,7 +114,7 @@ export namespace ApiFunctionProgrammer {
|
|
115
114
|
)("fetch"),
|
116
115
|
undefined,
|
117
116
|
[
|
118
|
-
contentType
|
117
|
+
contentType && contentType !== "multipart/form-data"
|
119
118
|
? ts.factory.createObjectLiteralExpression(
|
120
119
|
[
|
121
120
|
ts.factory.createSpreadAssignment(
|
@@ -119,7 +119,7 @@ export namespace ApiNamespaceProgrammer {
|
|
119
119
|
"request",
|
120
120
|
props.route.body
|
121
121
|
? LiteralFactory.generate({
|
122
|
-
type:
|
122
|
+
type: props.route.body.type,
|
123
123
|
encrypted: !!props.route.body["x-nestia-encrypted"],
|
124
124
|
})
|
125
125
|
: ts.factory.createNull(),
|
@@ -190,9 +190,17 @@ export namespace NestMethodProgrammer {
|
|
190
190
|
...(route.body
|
191
191
|
? [
|
192
192
|
writeDtoParameter({
|
193
|
-
method: route.body
|
193
|
+
method: route.body["x-nestia-encrypted"]
|
194
194
|
? "EncryptedBody"
|
195
|
-
: "
|
195
|
+
: route.body.type === "application/json"
|
196
|
+
? "TypedBody"
|
197
|
+
: route.body.type === "application/x-www-form-urlencoded"
|
198
|
+
? ["TypedQuery", "Body"]
|
199
|
+
: route.body.type === "text/plain"
|
200
|
+
? "PlainBody"
|
201
|
+
: route.body.type === "multipart/form-data"
|
202
|
+
? ["TypedFormData", "Body"]
|
203
|
+
: "TypedBody",
|
196
204
|
variable: "body",
|
197
205
|
})(components)(importer)(route.body.schema),
|
198
206
|
]
|
@@ -200,21 +208,27 @@ export namespace NestMethodProgrammer {
|
|
200
208
|
];
|
201
209
|
|
202
210
|
const writeDtoParameter =
|
203
|
-
(accessor: { method: string; variable: string }) =>
|
211
|
+
(accessor: { method: string | [string, string]; variable: string }) =>
|
204
212
|
(components: ISwaggerComponents) =>
|
205
213
|
(importer: ImportProgrammer) =>
|
206
|
-
(schema: ISwaggerSchema): ts.ParameterDeclaration =>
|
207
|
-
ts.factory.
|
214
|
+
(schema: ISwaggerSchema): ts.ParameterDeclaration => {
|
215
|
+
const instance = ts.factory.createIdentifier(
|
216
|
+
importer.external({
|
217
|
+
type: "instance",
|
218
|
+
library: "@nestia/core",
|
219
|
+
name:
|
220
|
+
typeof accessor.method === "string"
|
221
|
+
? accessor.method
|
222
|
+
: accessor.method[0],
|
223
|
+
}),
|
224
|
+
);
|
225
|
+
return ts.factory.createParameterDeclaration(
|
208
226
|
[
|
209
227
|
ts.factory.createDecorator(
|
210
228
|
ts.factory.createCallExpression(
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
library: "@nestia/core",
|
215
|
-
name: accessor.method,
|
216
|
-
}),
|
217
|
-
),
|
229
|
+
typeof accessor.method === "string"
|
230
|
+
? instance
|
231
|
+
: IdentifierFactory.access(instance)(accessor.method[1]),
|
218
232
|
undefined,
|
219
233
|
undefined,
|
220
234
|
),
|
@@ -225,4 +239,5 @@ export namespace NestMethodProgrammer {
|
|
225
239
|
undefined,
|
226
240
|
SchemaProgrammer.write(components)(importer)(schema),
|
227
241
|
);
|
242
|
+
};
|
228
243
|
}
|
@@ -117,6 +117,9 @@ export namespace SchemaProgrammer {
|
|
117
117
|
const writeString =
|
118
118
|
(importer: ImportProgrammer) =>
|
119
119
|
(schema: ISwaggerSchema.IString): ts.TypeNode => {
|
120
|
+
if (schema.format === "binary")
|
121
|
+
return ts.factory.createTypeReferenceNode("File");
|
122
|
+
|
120
123
|
const intersection: ts.TypeNode[] = [TypeFactory.keyword("string")];
|
121
124
|
if (schema.default !== undefined)
|
122
125
|
intersection.push(importer.tag("Default", schema.default));
|
@@ -33,7 +33,8 @@ export namespace IMigrateRoute {
|
|
33
33
|
type:
|
34
34
|
| "text/plain"
|
35
35
|
| "application/json"
|
36
|
-
| "application/x-www-form-urlencoded"
|
36
|
+
| "application/x-www-form-urlencoded"
|
37
|
+
| "multipart/form-data";
|
37
38
|
schema: ISwaggerSchema;
|
38
39
|
"x-nestia-encrypted"?: boolean;
|
39
40
|
}
|