@nestia/core 4.0.0-dev.20241116 → 4.0.0-dev.20241129
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/decorators/PlainBody.js +5 -1
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/TypedBody.js +4 -1
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedFormData.d.ts +17 -6
- package/lib/decorators/TypedFormData.js +9 -71
- package/lib/decorators/TypedFormData.js.map +1 -1
- package/lib/decorators/internal/is_request_body_undefined.d.ts +1 -0
- package/lib/decorators/internal/is_request_body_undefined.js +13 -0
- package/lib/decorators/internal/is_request_body_undefined.js.map +1 -0
- package/lib/programmers/PlainBodyProgrammer.js +0 -2
- package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
- package/lib/transformers/ParameterDecoratorTransformer.js +8 -3
- package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
- package/package.json +8 -10
- package/src/decorators/PlainBody.ts +7 -1
- package/src/decorators/TypedBody.ts +4 -1
- package/src/decorators/TypedFormData.ts +38 -66
- package/src/decorators/internal/is_request_body_undefined.ts +14 -0
- package/src/programmers/PlainBodyProgrammer.ts +0 -1
- package/src/transformers/ParameterDecoratorTransformer.ts +8 -3
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PlainBody = PlainBody;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const get_text_body_1 = require("./internal/get_text_body");
|
|
15
|
+
const is_request_body_undefined_1 = require("./internal/is_request_body_undefined");
|
|
15
16
|
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
16
17
|
/**
|
|
17
18
|
* @internal
|
|
@@ -28,7 +29,10 @@ function PlainBody(assert) {
|
|
|
28
29
|
const request = context
|
|
29
30
|
.switchToHttp()
|
|
30
31
|
.getRequest();
|
|
31
|
-
if (
|
|
32
|
+
if ((0, is_request_body_undefined_1.is_request_body_undefined)(request) &&
|
|
33
|
+
(checker !== null && checker !== void 0 ? checker : (() => null))(undefined) === null)
|
|
34
|
+
return undefined;
|
|
35
|
+
else if (!isTextPlain(request.headers["content-type"]))
|
|
32
36
|
throw new common_1.BadRequestException(`Request body type is not "text/plain".`);
|
|
33
37
|
const value = yield (0, get_text_body_1.get_text_body)(request);
|
|
34
38
|
if (checker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainBody.js","sourceRoot":"","sources":["../../src/decorators/PlainBody.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PlainBody.js","sourceRoot":"","sources":["../../src/decorators/PlainBody.ts"],"names":[],"mappings":";;;;;;;;;;;AAsCA,8BA8BC;AApED,2CAIwB;AAIxB,4DAAyD;AACzD,oFAAiF;AACjF,4EAAyE;AAyBzE;;GAEG;AACH,SAAgB,SAAS,CACvB,MAAmC;IAEnC,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC;YACjC,IAAI,EAAE,QAAQ;YACd,MAAM;SACP,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;IACT,OAAO,IAAA,6BAAoB,EAAC,SAAe,SAAS,CAClD,KAAU,EACV,OAAyB;;YAEzB,MAAM,OAAO,GAAqC,OAAO;iBACtD,YAAY,EAAE;iBACd,UAAU,EAAE,CAAC;YAChB,IACE,IAAA,qDAAyB,EAAC,OAAO,CAAC;gBAClC,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAgB,CAAC,KAAK,IAAI;gBAEpD,OAAO,SAAS,CAAC;iBACd,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBACpD,MAAM,IAAI,4BAAmB,CAAC,wCAAwC,CAAC,CAAC;YAC1E,MAAM,KAAK,GAAW,MAAM,IAAA,6BAAa,EAAC,OAAO,CAAC,CAAC;YACnD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAiB,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC3C,IAAI,KAAK,KAAK,IAAI;oBAAE,MAAM,KAAK,CAAC;YAClC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KAAA,CAAC,EAAE,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,IAAa,EAAW,EAAE,CAC7C,IAAI,KAAK,SAAS;IAClB,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,YAAY,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedBody = TypedBody;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
+
const is_request_body_undefined_1 = require("./internal/is_request_body_undefined");
|
|
5
6
|
const validate_request_body_1 = require("./internal/validate_request_body");
|
|
6
7
|
/**
|
|
7
8
|
* Type safe body decorator.
|
|
@@ -23,7 +24,9 @@ function TypedBody(validator) {
|
|
|
23
24
|
const request = context
|
|
24
25
|
.switchToHttp()
|
|
25
26
|
.getRequest();
|
|
26
|
-
if (
|
|
27
|
+
if ((0, is_request_body_undefined_1.is_request_body_undefined)(request) && checker(undefined) === null)
|
|
28
|
+
return undefined;
|
|
29
|
+
else if (isApplicationJson(request.headers["content-type"]) === false)
|
|
27
30
|
throw new common_1.BadRequestException(`Request body type is not "application/json".`);
|
|
28
31
|
const error = checker(request.body);
|
|
29
32
|
if (error !== null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"TypedBody.js","sourceRoot":"","sources":["../../src/decorators/TypedBody.ts"],"names":[],"mappings":";;AA0BA,8BAsBC;AAhDD,2CAIwB;AAKxB,oFAAiF;AACjF,4EAAyE;AAEzE;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,SAAoC;IAEpC,MAAM,OAAO,GAAG,IAAA,6CAAqB,EAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9D,OAAO,IAAA,6BAAoB,EAAC,SAAS,SAAS,CAC5C,QAAa,EACb,OAAyB;QAEzB,MAAM,OAAO,GAAqC,OAAO;aACtD,YAAY,EAAE;aACd,UAAU,EAAE,CAAC;QAChB,IAAI,IAAA,qDAAyB,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,SAAc,CAAC,KAAK,IAAI;YACxE,OAAO,SAAS,CAAC;aACd,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,KAAK;YACnE,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QAEJ,MAAM,KAAK,GAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,KAAK,CAAC;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC;IACtB,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAAW,EAAE,CACnD,IAAI,KAAK,SAAS;IAClB,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IRequestFormDataProps } from "../options/IRequestFormDataProps";
|
|
2
1
|
/**
|
|
3
2
|
* Type safe multipart/form-data decorator.
|
|
4
3
|
*
|
|
@@ -20,13 +19,13 @@ import type { IRequestFormDataProps } from "../options/IRequestFormDataProps";
|
|
|
20
19
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
21
20
|
* 4. By the way, union type never be not allowed
|
|
22
21
|
*
|
|
23
|
-
* By the way, if you're using `fastify`, you have to setup
|
|
22
|
+
* By the way, if you're using `fastify`, you have to setup `fastify-multer`
|
|
24
23
|
* and configure like below when composing the NestJS application. If you don't do
|
|
25
24
|
* that, `@TypedFormData.Body()` will not work properly, and throw 500 internal
|
|
26
25
|
* server error when `Blob` or `File` type being utilized.
|
|
27
26
|
*
|
|
28
27
|
* ```typescript
|
|
29
|
-
* import
|
|
28
|
+
* import fastifyMulter from "fastify-multer";
|
|
30
29
|
* import { NestFactory } from "@nestjs/core";
|
|
31
30
|
* import {
|
|
32
31
|
* FastifyAdapter,
|
|
@@ -38,7 +37,7 @@ import type { IRequestFormDataProps } from "../options/IRequestFormDataProps";
|
|
|
38
37
|
* AppModule,
|
|
39
38
|
* new FastifyAdapter(),
|
|
40
39
|
* );
|
|
41
|
-
* app.register(
|
|
40
|
+
* app.register(fastifyMulter.contentParser);
|
|
42
41
|
* await app.listen(3000);
|
|
43
42
|
* }
|
|
44
43
|
* ```
|
|
@@ -54,7 +53,19 @@ export declare namespace TypedFormData {
|
|
|
54
53
|
*
|
|
55
54
|
* Much easier and type safer than `@nest.UploadFile()` decorator.
|
|
56
55
|
*
|
|
57
|
-
* @param
|
|
56
|
+
* @param factory Factory function ncreating the `multer` or `fastify-multer`
|
|
57
|
+
* instance. In the factory function, you also can specify the
|
|
58
|
+
* multer composition options like `storage` engine.
|
|
58
59
|
*/
|
|
59
|
-
function Body<
|
|
60
|
+
function Body<Multer extends IMulterBase>(factory: () => Multer | Promise<Multer>): ParameterDecorator;
|
|
61
|
+
/**
|
|
62
|
+
* Base type of the `multer` or `fastify-multer`.
|
|
63
|
+
*/
|
|
64
|
+
interface IMulterBase {
|
|
65
|
+
single(fieldName: string): any;
|
|
66
|
+
array(fieldName: string, maxCount?: number): any;
|
|
67
|
+
fields(fields: readonly object[]): any;
|
|
68
|
+
any(): any;
|
|
69
|
+
none(): any;
|
|
70
|
+
}
|
|
60
71
|
}
|
|
@@ -8,20 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
12
|
exports.TypedFormData = void 0;
|
|
23
13
|
const common_1 = require("@nestjs/common");
|
|
24
|
-
const multer_1 = __importDefault(require("multer"));
|
|
25
14
|
const Singleton_1 = require("../utils/Singleton");
|
|
26
15
|
const validate_request_form_data_1 = require("./internal/validate_request_form_data");
|
|
27
16
|
/**
|
|
@@ -45,13 +34,13 @@ const validate_request_form_data_1 = require("./internal/validate_request_form_d
|
|
|
45
34
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
46
35
|
* 4. By the way, union type never be not allowed
|
|
47
36
|
*
|
|
48
|
-
* By the way, if you're using `fastify`, you have to setup
|
|
37
|
+
* By the way, if you're using `fastify`, you have to setup `fastify-multer`
|
|
49
38
|
* and configure like below when composing the NestJS application. If you don't do
|
|
50
39
|
* that, `@TypedFormData.Body()` will not work properly, and throw 500 internal
|
|
51
40
|
* server error when `Blob` or `File` type being utilized.
|
|
52
41
|
*
|
|
53
42
|
* ```typescript
|
|
54
|
-
* import
|
|
43
|
+
* import fastifyMulter from "fastify-multer";
|
|
55
44
|
* import { NestFactory } from "@nestjs/core";
|
|
56
45
|
* import {
|
|
57
46
|
* FastifyAdapter,
|
|
@@ -63,7 +52,7 @@ const validate_request_form_data_1 = require("./internal/validate_request_form_d
|
|
|
63
52
|
* AppModule,
|
|
64
53
|
* new FastifyAdapter(),
|
|
65
54
|
* );
|
|
66
|
-
* app.register(
|
|
55
|
+
* app.register(fastifyMulter.contentParser);
|
|
67
56
|
* await app.listen(3000);
|
|
68
57
|
* }
|
|
69
58
|
* ```
|
|
@@ -74,29 +63,20 @@ const validate_request_form_data_1 = require("./internal/validate_request_form_d
|
|
|
74
63
|
var TypedFormData;
|
|
75
64
|
(function (TypedFormData) {
|
|
76
65
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* Request body decorator for the `multipart/form-data` type.
|
|
80
|
-
*
|
|
81
|
-
* Much easier and type safer than `@nest.UploadFile()` decorator.
|
|
82
|
-
*
|
|
83
|
-
* @param props Automatically filled by transformer
|
|
66
|
+
* @internal
|
|
84
67
|
*/
|
|
85
|
-
function Body(props) {
|
|
68
|
+
function Body(factory, props) {
|
|
86
69
|
if (typeof File === "undefined")
|
|
87
70
|
throw new Error("Error on TypedFormData.Body(): 'File' class is not supported in the older version of NodeJS. Upgrade the NodeJS to the modern.");
|
|
88
71
|
const checker = (0, validate_request_form_data_1.validate_request_form_data)(props);
|
|
89
|
-
const
|
|
72
|
+
const uploader = new Singleton_1.Singleton(() => __awaiter(this, void 0, void 0, function* () { return decode((yield factory()), props); }));
|
|
90
73
|
return (0, common_1.createParamDecorator)(function TypedFormDataBody(_unknown, context) {
|
|
91
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
75
|
const http = context.switchToHttp();
|
|
93
76
|
const request = http.getRequest();
|
|
94
77
|
if (isMultipartFormData(request.headers["content-type"]) === false)
|
|
95
78
|
throw new common_1.BadRequestException(`Request body type is not "multipart/form-data".`);
|
|
96
|
-
const
|
|
97
|
-
? predicator("express").get()
|
|
98
|
-
: predicator("fastify").get();
|
|
99
|
-
const data = yield decoder({
|
|
79
|
+
const data = yield (yield uploader.get())({
|
|
100
80
|
request: request,
|
|
101
81
|
response: http.getResponse(),
|
|
102
82
|
});
|
|
@@ -112,8 +92,8 @@ var TypedFormData;
|
|
|
112
92
|
/**
|
|
113
93
|
* @internal
|
|
114
94
|
*/
|
|
115
|
-
const
|
|
116
|
-
const upload =
|
|
95
|
+
const decode = (multer, props) => {
|
|
96
|
+
const upload = multer.fields(props.files.map((file) => (Object.assign({ name: file.name }, (file.limit === 1 ? { maxCount: 1 } : {})))));
|
|
117
97
|
const interceptor = (request, response) => new Promise((resolve, reject) => upload(request, response, (error) => {
|
|
118
98
|
if (error)
|
|
119
99
|
reject(error);
|
|
@@ -134,40 +114,6 @@ const decodeExpress = (props) => {
|
|
|
134
114
|
return data;
|
|
135
115
|
});
|
|
136
116
|
};
|
|
137
|
-
/**
|
|
138
|
-
* @internal
|
|
139
|
-
*/
|
|
140
|
-
const decodeFastify = (_props) => (socket) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
var _a, e_1, _b, _c;
|
|
142
|
-
if (socket.request.files === undefined ||
|
|
143
|
-
typeof socket.request.files !== "function")
|
|
144
|
-
throw new common_1.InternalServerErrorException("Have not configured the `fastify-multipart` plugin yet. Inquiry to the backend developer.");
|
|
145
|
-
const data = new FormData();
|
|
146
|
-
try {
|
|
147
|
-
for (var _d = true, _e = __asyncValues(socket.request.parts()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
148
|
-
_c = _f.value;
|
|
149
|
-
_d = false;
|
|
150
|
-
const part = _c;
|
|
151
|
-
if (part.type === "file")
|
|
152
|
-
data.append(part.fieldname, new File([yield part.toBuffer()], part.filename, {
|
|
153
|
-
type: part.mimetype,
|
|
154
|
-
}));
|
|
155
|
-
else if (Array.isArray(part.value))
|
|
156
|
-
for (const elem of part.value)
|
|
157
|
-
data.append(part.fieldname, String(elem));
|
|
158
|
-
else
|
|
159
|
-
data.append(part.fieldname, String(part.value));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
163
|
-
finally {
|
|
164
|
-
try {
|
|
165
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
166
|
-
}
|
|
167
|
-
finally { if (e_1) throw e_1.error; }
|
|
168
|
-
}
|
|
169
|
-
return data;
|
|
170
|
-
});
|
|
171
117
|
/**
|
|
172
118
|
* @internal
|
|
173
119
|
*/
|
|
@@ -192,12 +138,4 @@ const isMultipartFormData = (text) => text !== undefined &&
|
|
|
192
138
|
.split(";")
|
|
193
139
|
.map((str) => str.trim())
|
|
194
140
|
.some((str) => str === "multipart/form-data");
|
|
195
|
-
/**
|
|
196
|
-
* @internal
|
|
197
|
-
*/
|
|
198
|
-
const isExpressRequest = (request) => request.app !== undefined;
|
|
199
|
-
/**
|
|
200
|
-
* @internal
|
|
201
|
-
*/
|
|
202
|
-
const multerApplication = new Singleton_1.Singleton(() => (0, multer_1.default)());
|
|
203
141
|
//# sourceMappingURL=TypedFormData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedFormData.js","sourceRoot":"","sources":["../../src/decorators/TypedFormData.ts"],"names":[],"mappings":"
|
|
1
|
+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AE,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.is_request_body_undefined = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
const is_request_body_undefined = (request) => request.headers["content-type"] === undefined &&
|
|
8
|
+
(request.body === undefined ||
|
|
9
|
+
(typeof request.body === "object" &&
|
|
10
|
+
request.body !== null &&
|
|
11
|
+
Object.keys(request.body).length === 0));
|
|
12
|
+
exports.is_request_body_undefined = is_request_body_undefined;
|
|
13
|
+
//# sourceMappingURL=is_request_body_undefined.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_request_body_undefined.js","sourceRoot":"","sources":["../../../src/decorators/internal/is_request_body_undefined.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,OAAyC,EAChC,EAAE,CACX,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,SAAS;IAC7C,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;QACzB,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;YAC/B,OAAO,CAAC,IAAI,KAAK,IAAI;YACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;AAPlC,QAAA,yBAAyB,6BAOS"}
|
|
@@ -52,8 +52,6 @@ const validate = (metadata) => {
|
|
|
52
52
|
.reduce((a, b) => a + b, 0);
|
|
53
53
|
if (expected === 0 || expected !== metadata.size())
|
|
54
54
|
insert(`only string type is allowed`);
|
|
55
|
-
if (metadata.isRequired() === false)
|
|
56
|
-
insert(`do not allow undefindable type`);
|
|
57
55
|
if (metadata.nullable === true)
|
|
58
56
|
insert(`do not allow nullable type`);
|
|
59
57
|
else if (metadata.any === true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainBodyProgrammer.js","sourceRoot":"","sources":["../../src/programmers/PlainBodyProgrammer.ts"],"names":[],"mappings":";;;AACA,+EAA4E;AAC5E,yEAAsE;AACtE,6EAA0E;AAE1E,8EAA2E;AAI3E,IAAiB,mBAAmB,CAyCnC;AAzCD,WAAiB,mBAAmB;IACrB,4BAAQ,GAAG,CAAC,KAIxB,EAAiB,EAAE;QAClB,MAAM,MAAM,GAAG,iCAAe,CAAC,OAAO,CAAC;YACrC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO;YAC9B,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW;YACtC,OAAO,EAAE;gBACP,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,IAAI;gBACZ,QAAQ;aACT;YACD,UAAU,EAAE,IAAI,uCAAkB,EAAE;YACpC,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;YAC1B,MAAM,mCAAgB,CAAC,IAAI,CAAC;gBAC1B,IAAI,EAAE,wBAAwB;gBAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC,CAAC;QACL,OAAO,mCAAgB,CAAC,KAAK,CAAC;YAC5B,OAAO,kCACF,KAAK,CAAC,OAAO,KAChB,OAAO,EAAE;oBACP,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,KAAK;iBAClB,GACF;YACD,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE;gBACN,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,KAAK;aACb;YACD,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CA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,CAAC,CAAC;QAC3D,QAAQ,CAAC,SAAS,CAAC,MAAM;QACzB,QAAQ,CAAC,SAAS;aACf,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;aAClC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;aAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,IAAI,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,QAAQ,CAAC,IAAI,EAAE;QAChD,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI;QAAE,MAAM,CAAC,4BAA4B,CAAC,CAAC;SAChE,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI;QAAE,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -70,9 +70,14 @@ const FUNCTORS = {
|
|
|
70
70
|
"TypedQuery.Body": (props) => props.arguments.length
|
|
71
71
|
? props.arguments
|
|
72
72
|
: [TypedQueryBodyProgrammer_1.TypedQueryBodyProgrammer.generate(props)],
|
|
73
|
-
"TypedFormData.Body": (props) => props.arguments.length
|
|
74
|
-
?
|
|
75
|
-
|
|
73
|
+
"TypedFormData.Body": (props) => props.arguments.length === 0
|
|
74
|
+
? [
|
|
75
|
+
typescript_1.default.factory.createIdentifier("undefined"),
|
|
76
|
+
TypedFormDataBodyProgrammer_1.TypedFormDataBodyProgrammer.generate(props),
|
|
77
|
+
]
|
|
78
|
+
: props.arguments.length === 1
|
|
79
|
+
? [props.arguments[0], TypedFormDataBodyProgrammer_1.TypedFormDataBodyProgrammer.generate(props)]
|
|
80
|
+
: props.arguments,
|
|
76
81
|
PlainBody: (props) => props.arguments.length
|
|
77
82
|
? props.arguments
|
|
78
83
|
: [PlainBodyProgrammer_1.PlainBodyProgrammer.generate(props)],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterDecoratorTransformer.js","sourceRoot":"","sources":["../../src/transformers/ParameterDecoratorTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4DAA4B;AAG5B,4EAAyE;AACzE,4EAAyE;AACzE,4FAAyF;AACzF,kFAA+E;AAC/E,8EAA2E;AAC3E,sFAAmF;AACnF,8EAA2E;AAE3E,IAAiB,6BAA6B,CAuD7C;AAvDD,WAAiB,6BAA6B;IAC/B,uCAAS,GAAG,CAAC,KAIzB,EAAgB,EAAE;;QACjB,MAAM;QACN,cAAc;QACd,MAAM;QACN,kBAAkB;QAClB,IAAI,CAAC,oBAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC;YAClD,OAAO,KAAK,CAAC,SAAS,CAAC;QAEzB,wBAAwB;QACxB,MAAM,WAAW,GACf,MAAA,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CACxC,KAAK,CAAC,SAAS,CAAC,UAAU,CAC3B,0CAAE,WAAW,CAAC;QACjB,IAAI,WAAW,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,SAAS,CAAC;QAEtD,YAAY;QACZ,MAAM,IAAI,GAAW,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChE,OAAO,KAAK,CAAC,SAAS,CAAC;QAEzB,MAAM;QACN,iBAAiB;QACjB,MAAM;QACN,kBAAkB;QAClB,MAAM,UAAU,GACd,QAAQ,CACN,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC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
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.20241129",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -36,38 +36,36 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://nestia.io",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nestia/fetcher": "^4.0.0-dev.
|
|
39
|
+
"@nestia/fetcher": "^4.0.0-dev.20241129",
|
|
40
40
|
"@nestjs/common": ">=7.0.1",
|
|
41
41
|
"@nestjs/core": ">=7.0.1",
|
|
42
|
-
"@samchon/openapi": "^
|
|
42
|
+
"@samchon/openapi": "^2.0.0-dev.20241129-8",
|
|
43
43
|
"detect-ts-node": "^1.0.5",
|
|
44
44
|
"get-function-location": "^2.0.0",
|
|
45
45
|
"glob": "^7.2.0",
|
|
46
|
-
"multer": "1.4.5-lts.1",
|
|
47
46
|
"path-parser": "^6.1.0",
|
|
48
47
|
"raw-body": "^2.0.0",
|
|
49
48
|
"reflect-metadata": ">=0.1.12",
|
|
50
49
|
"rxjs": ">=6.0.3",
|
|
51
50
|
"tgrid": "^1.0.0",
|
|
52
|
-
"typia": "
|
|
51
|
+
"typia": ">=7.0.0-dev.20241029 <8.0.0",
|
|
53
52
|
"ws": "^7.5.3"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
|
-
"@nestia/fetcher": ">=4.0.0-dev.
|
|
55
|
+
"@nestia/fetcher": ">=4.0.0-dev.20241129",
|
|
57
56
|
"@nestjs/common": ">=7.0.1",
|
|
58
57
|
"@nestjs/core": ">=7.0.1",
|
|
59
58
|
"reflect-metadata": ">=0.1.12",
|
|
60
59
|
"rxjs": ">=6.0.3",
|
|
61
|
-
"typia": ">=7.0.0-dev.
|
|
60
|
+
"typia": ">=7.0.0-dev.20241029 <8.0.0"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@fastify/multipart": "^8.1.0",
|
|
65
63
|
"@nestjs/common": "^10.3.3",
|
|
66
64
|
"@nestjs/core": "^10.3.3",
|
|
67
65
|
"@types/express": "^4.17.15",
|
|
68
66
|
"@types/glob": "^7.2.0",
|
|
69
67
|
"@types/inquirer": "^9.0.3",
|
|
70
|
-
"@types/multer": "^1.4.
|
|
68
|
+
"@types/multer": "^1.4.12",
|
|
71
69
|
"@types/ts-expose-internals": "npm:ts-expose-internals@5.4.5",
|
|
72
70
|
"@types/ws": "^8.5.10",
|
|
73
71
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
@@ -75,7 +73,7 @@
|
|
|
75
73
|
"commander": "^10.0.0",
|
|
76
74
|
"comment-json": "^4.2.3",
|
|
77
75
|
"eslint-plugin-deprecation": "^1.4.1",
|
|
78
|
-
"fastify": "^4.
|
|
76
|
+
"fastify": "^4.28.1",
|
|
79
77
|
"git-last-commit": "^1.0.1",
|
|
80
78
|
"inquirer": "^8.2.5",
|
|
81
79
|
"rimraf": "^3.0.2",
|
|
@@ -7,6 +7,7 @@ import type express from "express";
|
|
|
7
7
|
import type { FastifyRequest } from "fastify";
|
|
8
8
|
|
|
9
9
|
import { get_text_body } from "./internal/get_text_body";
|
|
10
|
+
import { is_request_body_undefined } from "./internal/is_request_body_undefined";
|
|
10
11
|
import { validate_request_body } from "./internal/validate_request_body";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -51,7 +52,12 @@ export function PlainBody(
|
|
|
51
52
|
const request: express.Request | FastifyRequest = context
|
|
52
53
|
.switchToHttp()
|
|
53
54
|
.getRequest();
|
|
54
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
is_request_body_undefined(request) &&
|
|
57
|
+
(checker ?? (() => null))(undefined as any) === null
|
|
58
|
+
)
|
|
59
|
+
return undefined;
|
|
60
|
+
else if (!isTextPlain(request.headers["content-type"]))
|
|
55
61
|
throw new BadRequestException(`Request body type is not "text/plain".`);
|
|
56
62
|
const value: string = await get_text_body(request);
|
|
57
63
|
if (checker) {
|
|
@@ -7,6 +7,7 @@ import type express from "express";
|
|
|
7
7
|
import type { FastifyRequest } from "fastify";
|
|
8
8
|
|
|
9
9
|
import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
|
|
10
|
+
import { is_request_body_undefined } from "./internal/is_request_body_undefined";
|
|
10
11
|
import { validate_request_body } from "./internal/validate_request_body";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -34,7 +35,9 @@ export function TypedBody<T>(
|
|
|
34
35
|
const request: express.Request | FastifyRequest = context
|
|
35
36
|
.switchToHttp()
|
|
36
37
|
.getRequest();
|
|
37
|
-
if (
|
|
38
|
+
if (is_request_body_undefined(request) && checker(undefined as T) === null)
|
|
39
|
+
return undefined;
|
|
40
|
+
else if (isApplicationJson(request.headers["content-type"]) === false)
|
|
38
41
|
throw new BadRequestException(
|
|
39
42
|
`Request body type is not "application/json".`,
|
|
40
43
|
);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type { Multipart } from "@fastify/multipart";
|
|
2
1
|
import {
|
|
3
2
|
BadRequestException,
|
|
4
3
|
ExecutionContext,
|
|
5
|
-
InternalServerErrorException,
|
|
6
4
|
createParamDecorator,
|
|
7
5
|
} from "@nestjs/common";
|
|
8
6
|
import type { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
9
7
|
import type express from "express";
|
|
10
|
-
import type
|
|
11
|
-
import multer from "multer";
|
|
8
|
+
import type ExpressMulter from "multer";
|
|
12
9
|
|
|
13
10
|
import type { IRequestFormDataProps } from "../options/IRequestFormDataProps";
|
|
14
11
|
import { Singleton } from "../utils/Singleton";
|
|
@@ -35,13 +32,13 @@ import { validate_request_form_data } from "./internal/validate_request_form_dat
|
|
|
35
32
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
36
33
|
* 4. By the way, union type never be not allowed
|
|
37
34
|
*
|
|
38
|
-
* By the way, if you're using `fastify`, you have to setup
|
|
35
|
+
* By the way, if you're using `fastify`, you have to setup `fastify-multer`
|
|
39
36
|
* and configure like below when composing the NestJS application. If you don't do
|
|
40
37
|
* that, `@TypedFormData.Body()` will not work properly, and throw 500 internal
|
|
41
38
|
* server error when `Blob` or `File` type being utilized.
|
|
42
39
|
*
|
|
43
40
|
* ```typescript
|
|
44
|
-
* import
|
|
41
|
+
* import fastifyMulter from "fastify-multer";
|
|
45
42
|
* import { NestFactory } from "@nestjs/core";
|
|
46
43
|
* import {
|
|
47
44
|
* FastifyAdapter,
|
|
@@ -53,7 +50,7 @@ import { validate_request_form_data } from "./internal/validate_request_form_dat
|
|
|
53
50
|
* AppModule,
|
|
54
51
|
* new FastifyAdapter(),
|
|
55
52
|
* );
|
|
56
|
-
* app.register(
|
|
53
|
+
* app.register(fastifyMulter.contentParser);
|
|
57
54
|
* await app.listen(3000);
|
|
58
55
|
* }
|
|
59
56
|
* ```
|
|
@@ -69,20 +66,29 @@ export namespace TypedFormData {
|
|
|
69
66
|
*
|
|
70
67
|
* Much easier and type safer than `@nest.UploadFile()` decorator.
|
|
71
68
|
*
|
|
72
|
-
* @param
|
|
69
|
+
* @param factory Factory function ncreating the `multer` or `fastify-multer`
|
|
70
|
+
* instance. In the factory function, you also can specify the
|
|
71
|
+
* multer composition options like `storage` engine.
|
|
72
|
+
*/
|
|
73
|
+
export function Body<Multer extends IMulterBase>(
|
|
74
|
+
factory: () => Multer | Promise<Multer>,
|
|
75
|
+
): ParameterDecorator;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
73
79
|
*/
|
|
74
80
|
export function Body<T extends object>(
|
|
75
|
-
|
|
81
|
+
factory: () => Promise<IMulterBase>,
|
|
82
|
+
props?: IRequestFormDataProps<T> | undefined,
|
|
76
83
|
): ParameterDecorator {
|
|
77
84
|
if (typeof File === "undefined")
|
|
78
85
|
throw new Error(
|
|
79
86
|
"Error on TypedFormData.Body(): 'File' class is not supported in the older version of NodeJS. Upgrade the NodeJS to the modern.",
|
|
80
87
|
);
|
|
81
88
|
const checker = validate_request_form_data(props);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
89
|
+
const uploader = new Singleton(async () =>
|
|
90
|
+
decode((await factory()) as ExpressMulter.Multer, props!),
|
|
91
|
+
);
|
|
86
92
|
return createParamDecorator(async function TypedFormDataBody(
|
|
87
93
|
_unknown: any,
|
|
88
94
|
context: ExecutionContext,
|
|
@@ -93,11 +99,9 @@ export namespace TypedFormData {
|
|
|
93
99
|
throw new BadRequestException(
|
|
94
100
|
`Request body type is not "multipart/form-data".`,
|
|
95
101
|
);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
: predicator("fastify").get();
|
|
100
|
-
const data: FormData = await decoder({
|
|
102
|
+
const data: FormData = await (
|
|
103
|
+
await uploader.get()
|
|
104
|
+
)({
|
|
101
105
|
request: request as any,
|
|
102
106
|
response: http.getResponse(),
|
|
103
107
|
});
|
|
@@ -106,13 +110,27 @@ export namespace TypedFormData {
|
|
|
106
110
|
return output;
|
|
107
111
|
})();
|
|
108
112
|
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Base type of the `multer` or `fastify-multer`.
|
|
116
|
+
*/
|
|
117
|
+
export interface IMulterBase {
|
|
118
|
+
single(fieldName: string): any;
|
|
119
|
+
array(fieldName: string, maxCount?: number): any;
|
|
120
|
+
fields(fields: readonly object[]): any;
|
|
121
|
+
any(): any;
|
|
122
|
+
none(): any;
|
|
123
|
+
}
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
/**
|
|
112
127
|
* @internal
|
|
113
128
|
*/
|
|
114
|
-
const
|
|
115
|
-
|
|
129
|
+
const decode = <T>(
|
|
130
|
+
multer: ExpressMulter.Multer,
|
|
131
|
+
props: IRequestFormDataProps<T>,
|
|
132
|
+
) => {
|
|
133
|
+
const upload = multer.fields(
|
|
116
134
|
props!.files.map((file) => ({
|
|
117
135
|
name: file.name,
|
|
118
136
|
...(file.limit === 1 ? { maxCount: 1 } : {}),
|
|
@@ -141,40 +159,6 @@ const decodeExpress = <T>(props: IRequestFormDataProps<T>) => {
|
|
|
141
159
|
};
|
|
142
160
|
};
|
|
143
161
|
|
|
144
|
-
/**
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
const decodeFastify =
|
|
148
|
-
<T>(_props: IRequestFormDataProps<T>) =>
|
|
149
|
-
async (socket: {
|
|
150
|
-
request: FastifyRequest & {
|
|
151
|
-
parts?(): AsyncIterableIterator<Multipart>;
|
|
152
|
-
};
|
|
153
|
-
response: FastifyReply;
|
|
154
|
-
}): Promise<FormData> => {
|
|
155
|
-
if (
|
|
156
|
-
socket.request.files === undefined ||
|
|
157
|
-
typeof socket.request.files !== "function"
|
|
158
|
-
)
|
|
159
|
-
throw new InternalServerErrorException(
|
|
160
|
-
"Have not configured the `fastify-multipart` plugin yet. Inquiry to the backend developer.",
|
|
161
|
-
);
|
|
162
|
-
const data: FormData = new FormData();
|
|
163
|
-
for await (const part of socket.request.parts())
|
|
164
|
-
if (part.type === "file")
|
|
165
|
-
data.append(
|
|
166
|
-
part.fieldname,
|
|
167
|
-
new File([await part.toBuffer()], part.filename, {
|
|
168
|
-
type: part.mimetype,
|
|
169
|
-
}),
|
|
170
|
-
);
|
|
171
|
-
else if (Array.isArray(part.value))
|
|
172
|
-
for (const elem of part.value)
|
|
173
|
-
data.append(part.fieldname, String(elem));
|
|
174
|
-
else data.append(part.fieldname, String(part.value));
|
|
175
|
-
return data;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
162
|
/**
|
|
179
163
|
* @internal
|
|
180
164
|
*/
|
|
@@ -209,15 +193,3 @@ const isMultipartFormData = (text?: string): boolean =>
|
|
|
209
193
|
.split(";")
|
|
210
194
|
.map((str) => str.trim())
|
|
211
195
|
.some((str) => str === "multipart/form-data");
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
|
-
const isExpressRequest = (
|
|
217
|
-
request: express.Request | FastifyRequest,
|
|
218
|
-
): request is express.Request => (request as express.Request).app !== undefined;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @internal
|
|
222
|
-
*/
|
|
223
|
-
const multerApplication = new Singleton(() => multer());
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type express from "express";
|
|
2
|
+
import type { FastifyRequest } from "fastify";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export const is_request_body_undefined = (
|
|
8
|
+
request: express.Request | FastifyRequest,
|
|
9
|
+
): boolean =>
|
|
10
|
+
request.headers["content-type"] === undefined &&
|
|
11
|
+
(request.body === undefined ||
|
|
12
|
+
(typeof request.body === "object" &&
|
|
13
|
+
request.body !== null &&
|
|
14
|
+
Object.keys(request.body).length === 0));
|
|
@@ -63,7 +63,6 @@ const validate = (metadata: Metadata): string[] => {
|
|
|
63
63
|
.reduce((a, b) => a + b, 0);
|
|
64
64
|
if (expected === 0 || expected !== metadata.size())
|
|
65
65
|
insert(`only string type is allowed`);
|
|
66
|
-
if (metadata.isRequired() === false) insert(`do not allow undefindable type`);
|
|
67
66
|
if (metadata.nullable === true) insert(`do not allow nullable type`);
|
|
68
67
|
else if (metadata.any === true) insert(`do not allow any type`);
|
|
69
68
|
|
|
@@ -100,9 +100,14 @@ const FUNCTORS: Record<string, Programmer> = {
|
|
|
100
100
|
? props.arguments
|
|
101
101
|
: [TypedQueryBodyProgrammer.generate(props)],
|
|
102
102
|
"TypedFormData.Body": (props) =>
|
|
103
|
-
props.arguments.length
|
|
104
|
-
?
|
|
105
|
-
|
|
103
|
+
props.arguments.length === 0
|
|
104
|
+
? [
|
|
105
|
+
ts.factory.createIdentifier("undefined"),
|
|
106
|
+
TypedFormDataBodyProgrammer.generate(props),
|
|
107
|
+
]
|
|
108
|
+
: props.arguments.length === 1
|
|
109
|
+
? [props.arguments[0], TypedFormDataBodyProgrammer.generate(props)]
|
|
110
|
+
: props.arguments,
|
|
106
111
|
PlainBody: (props) =>
|
|
107
112
|
props.arguments.length
|
|
108
113
|
? props.arguments
|