typia 5.4.14 → 5.5.0-dev.20240301
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/factories/IdentifierFactory.d.ts +1 -1
- package/lib/functional/$guard.js +49 -28
- package/lib/functional/$guard.js.map +1 -1
- package/lib/functional/Namespace/index.d.ts +1 -1
- package/lib/http.d.ts +10 -493
- package/lib/http.js.map +1 -1
- package/lib/json.d.ts +9 -8
- package/lib/json.js.map +1 -1
- package/lib/misc.d.ts +9 -8
- package/lib/misc.js.map +1 -1
- package/lib/module.d.ts +17 -16
- package/lib/module.js.map +1 -1
- package/lib/notations.d.ts +13 -12
- package/lib/notations.js.map +1 -1
- package/lib/programmers/AssertProgrammer.d.ts +5 -1
- package/lib/programmers/AssertProgrammer.js +31 -22
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertFormDataProgrammer.d.ts +1 -1
- package/lib/programmers/http/HttpAssertFormDataProgrammer.js +6 -2
- package/lib/programmers/http/HttpAssertFormDataProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertHeadersProgrammer.d.ts +1 -1
- package/lib/programmers/http/HttpAssertHeadersProgrammer.js +6 -2
- package/lib/programmers/http/HttpAssertHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertQueryProgrammer.d.ts +1 -1
- package/lib/programmers/http/HttpAssertQueryProgrammer.js +6 -2
- package/lib/programmers/http/HttpAssertQueryProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.d.ts +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js +9 -3
- package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonAssertStringifyProgrammer.d.ts +1 -1
- package/lib/programmers/json/JsonAssertStringifyProgrammer.js +9 -3
- package/lib/programmers/json/JsonAssertStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.d.ts +1 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js +9 -3
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscAssertPruneProgrammer.d.ts +1 -1
- package/lib/programmers/misc/MiscAssertPruneProgrammer.js +9 -3
- package/lib/programmers/misc/MiscAssertPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationAssertGeneralProgrammer.d.ts +1 -1
- package/lib/programmers/notations/NotationAssertGeneralProgrammer.js +9 -3
- package/lib/programmers/notations/NotationAssertGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.d.ts +1 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js +6 -2
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.d.ts +1 -1
- package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.js +9 -3
- package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.js.map +1 -1
- package/lib/protobuf.d.ts +9 -8
- package/lib/protobuf.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.d.ts +1 -1
- package/lib/transformers/internal/GenericTransformer.js +3 -3
- package/lib/transformers/internal/GenericTransformer.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/IdentifierFactory.ts +1 -1
- package/src/functional/$guard.ts +33 -19
- package/src/http.ts +25 -508
- package/src/json.ts +29 -8
- package/src/misc.ts +29 -8
- package/src/module.ts +57 -16
- package/src/notations.ts +43 -12
- package/src/programmers/AssertProgrammer.ts +69 -28
- package/src/programmers/http/HttpAssertFormDataProgrammer.ts +6 -2
- package/src/programmers/http/HttpAssertHeadersProgrammer.ts +6 -2
- package/src/programmers/http/HttpAssertQueryProgrammer.ts +6 -2
- package/src/programmers/json/JsonAssertParseProgrammer.ts +9 -3
- package/src/programmers/json/JsonAssertStringifyProgrammer.ts +9 -3
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +9 -3
- package/src/programmers/misc/MiscAssertPruneProgrammer.ts +9 -3
- package/src/programmers/notations/NotationAssertGeneralProgrammer.ts +9 -3
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +6 -2
- package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +9 -3
- package/src/protobuf.ts +29 -8
- package/src/transformers/internal/GenericTransformer.ts +12 -4
package/src/http.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Atomic } from "./typings/Atomic";
|
|
|
4
4
|
|
|
5
5
|
import { IValidation } from "./IValidation";
|
|
6
6
|
import { Resolved } from "./Resolved";
|
|
7
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
7
8
|
|
|
8
9
|
/* ===========================================================
|
|
9
10
|
HTTP
|
|
@@ -15,41 +16,6 @@ import { Resolved } from "./Resolved";
|
|
|
15
16
|
==============================================================
|
|
16
17
|
FORM-DATA
|
|
17
18
|
----------------------------------------------------------- */
|
|
18
|
-
/**
|
|
19
|
-
* > You must configure the generic argument `T`.
|
|
20
|
-
*
|
|
21
|
-
* Form data decoder.
|
|
22
|
-
*
|
|
23
|
-
* `typia.http.formData()` is a function decoding `FormData` instance, with
|
|
24
|
-
* automatic type casting to the expected type. When roperty type be defined
|
|
25
|
-
* as `boolean` or `Blob` type, `typia.http.formData()` will cast the value to
|
|
26
|
-
* the expected type when decoding.
|
|
27
|
-
*
|
|
28
|
-
* By the way, as `FormData` is not enough to express complex data structures,
|
|
29
|
-
* `typia.http.formData()` function has some limitations. If target type `T` is
|
|
30
|
-
* not following those restrictions, compilation errors would be occured.
|
|
31
|
-
*
|
|
32
|
-
* 1. Type `T` must be an object type
|
|
33
|
-
* 2. Do not allow dynamic property
|
|
34
|
-
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
35
|
-
* 4. By the way, union type never be not allowed
|
|
36
|
-
*
|
|
37
|
-
* Also, `typia.http.formData()` function does not perform validation about the
|
|
38
|
-
* decoded value. Therefore, if you can't sure that input data is following the
|
|
39
|
-
* `T` type, it would better to call one of below functions intead.
|
|
40
|
-
*
|
|
41
|
-
* - {@link assertFormData}
|
|
42
|
-
* - {@link isFormData}
|
|
43
|
-
* - {@link validateFormData}
|
|
44
|
-
*
|
|
45
|
-
* @template T Expected type of decoded value
|
|
46
|
-
* @param input FormData instance
|
|
47
|
-
* @returns Decoded form FormData
|
|
48
|
-
*
|
|
49
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
50
|
-
*/
|
|
51
|
-
function formData(): never;
|
|
52
|
-
|
|
53
19
|
/**
|
|
54
20
|
* Form data decoder.
|
|
55
21
|
*
|
|
@@ -91,38 +57,6 @@ const formDataPure = /** @__PURE__ */ Object.assign<typeof formData, {}>(
|
|
|
91
57
|
);
|
|
92
58
|
export { formDataPure as formData };
|
|
93
59
|
|
|
94
|
-
/**
|
|
95
|
-
* > You must configure the generic argument `T`.
|
|
96
|
-
*
|
|
97
|
-
* Form data decoder with type assertion.
|
|
98
|
-
*
|
|
99
|
-
* `typia.http.assertFormData()` is a function decoding `FormData` instance, with
|
|
100
|
-
* automatic type casting to the expected type. When roperty type be defined
|
|
101
|
-
* as `boolean` or `Blob` type, `typia.http.assertFormData()` will cast the value
|
|
102
|
-
* to the expected type when decoding.
|
|
103
|
-
*
|
|
104
|
-
* Also, after decoding, `typia.http.assertFormData()` performs type assertion to
|
|
105
|
-
* the decoded value by combining with {@link assert} function. Therefore, when
|
|
106
|
-
* the decoded value is not following the `T` type, {@link TypeGuardError} would
|
|
107
|
-
* be thrown.
|
|
108
|
-
*
|
|
109
|
-
* By the way, as `FormData` is not enough to express complex data structures,
|
|
110
|
-
* `typia.http.assertFormData()` function has some limitations. If target type `T`
|
|
111
|
-
* is not following those restrictions, compilation errors would be occured.
|
|
112
|
-
*
|
|
113
|
-
* 1. Type `T` must be an object type
|
|
114
|
-
* 2. Do not allow dynamic property
|
|
115
|
-
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
116
|
-
* 4. By the way, union type never be not allowed
|
|
117
|
-
*
|
|
118
|
-
* @template T Expected type of decoded value
|
|
119
|
-
* @param input FormData instance
|
|
120
|
-
* @returns Decoded form FormData
|
|
121
|
-
*
|
|
122
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
123
|
-
*/
|
|
124
|
-
function assertFormData(): never;
|
|
125
|
-
|
|
126
60
|
/**
|
|
127
61
|
* Form data decoder with type assertion.
|
|
128
62
|
*
|
|
@@ -151,7 +85,10 @@ function assertFormData(): never;
|
|
|
151
85
|
*
|
|
152
86
|
* @author Jeongho Nam - https://github.com/samchon
|
|
153
87
|
*/
|
|
154
|
-
function assertFormData<T extends object>(
|
|
88
|
+
function assertFormData<T extends object>(
|
|
89
|
+
input: FormData,
|
|
90
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
91
|
+
): Resolved<T>;
|
|
155
92
|
|
|
156
93
|
/**
|
|
157
94
|
* @internal
|
|
@@ -170,37 +107,6 @@ const assertFormDataPure = /** @__PURE__ */ Object.assign<
|
|
|
170
107
|
);
|
|
171
108
|
export { assertFormDataPure as assertFormData };
|
|
172
109
|
|
|
173
|
-
/**
|
|
174
|
-
* > You must configure the generic argument `T`.
|
|
175
|
-
*
|
|
176
|
-
* Form data decoder with type checking.
|
|
177
|
-
*
|
|
178
|
-
* `typia.http.isFormData()` is a function decoding `FormData` instance, with
|
|
179
|
-
* automatic type casting to the expected type. When roperty type be defined
|
|
180
|
-
* as `boolean` or `Blob` type, `typia.http.isFormData()` will cast the value
|
|
181
|
-
* to the expected type when decoding.
|
|
182
|
-
*
|
|
183
|
-
* Also, after decoding, `typia.http.isFormData()` performs type checking to the
|
|
184
|
-
* decoded value by combining with {@link is} function. Therefore, when the
|
|
185
|
-
* decoded value is not following the `T` type, `null` value would be returned.
|
|
186
|
-
*
|
|
187
|
-
* By the way, as `FormData` is not enough to express complex data structures,
|
|
188
|
-
* `typia.http.isFormData()` function has some limitations. If target type `T` is
|
|
189
|
-
* not following those restrictions, compilation errors would be occured.
|
|
190
|
-
*
|
|
191
|
-
* 1. Type `T` must be an object type
|
|
192
|
-
* 2. Do not allow dynamic property
|
|
193
|
-
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
194
|
-
* 4. By the way, union type never be not allowed
|
|
195
|
-
*
|
|
196
|
-
* @template T Expected type of decoded value
|
|
197
|
-
* @param input FormData instance
|
|
198
|
-
* @returns Decoded form FormData or `null` value
|
|
199
|
-
*
|
|
200
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
201
|
-
*/
|
|
202
|
-
function isFormData(): never;
|
|
203
|
-
|
|
204
110
|
/**
|
|
205
111
|
* Form data decoder with type checking.
|
|
206
112
|
*
|
|
@@ -247,39 +153,6 @@ const isFormDataPure = /** @__PURE__ */ Object.assign<
|
|
|
247
153
|
);
|
|
248
154
|
export { isFormDataPure as isFormData };
|
|
249
155
|
|
|
250
|
-
/**
|
|
251
|
-
* > You must configure the generic argument `T`.
|
|
252
|
-
*
|
|
253
|
-
* Form data decoder with type validation.
|
|
254
|
-
*
|
|
255
|
-
* `typia.http.validateFormData()` is a function decoding `FormData` instance,
|
|
256
|
-
* with automatic type casting to the expected type. When roperty type be defined
|
|
257
|
-
* as `boolean` or `Blob` type, `typia.http.validateFormData()` will cast the
|
|
258
|
-
* value to the expected type when decoding.
|
|
259
|
-
*
|
|
260
|
-
* Also, after decoding, `typia.http.validateFormData()` performs type validation
|
|
261
|
-
* to the decoded value by combining with {@link validate} function. Therefore,
|
|
262
|
-
* when the decoded value is not following the `T` type,
|
|
263
|
-
* {@link IValidation.IFailure} would be returned. Otherwise,
|
|
264
|
-
* x@xxxx IValidation.ISuccess} would be returned.
|
|
265
|
-
*
|
|
266
|
-
* By the way, as `FormData` is not enough to express complex data structures,
|
|
267
|
-
* `typia.http.validateFormData()` function has some limitations. If target type
|
|
268
|
-
* `T` is not following those restrictions, compilation errors would be occured.
|
|
269
|
-
*
|
|
270
|
-
* 1. Type `T` must be an object type
|
|
271
|
-
* 2. Do not allow dynamic property
|
|
272
|
-
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
273
|
-
* 4. By the way, union type never be not allowed
|
|
274
|
-
*
|
|
275
|
-
* @template T Expected type of decoded value
|
|
276
|
-
* @param input FormData instance
|
|
277
|
-
* @returns Validation result with decoded form FormData
|
|
278
|
-
*
|
|
279
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
280
|
-
*/
|
|
281
|
-
function validateFormData(): never;
|
|
282
|
-
|
|
283
156
|
/**
|
|
284
157
|
* Form data decoder with type validation.
|
|
285
158
|
*
|
|
@@ -333,41 +206,6 @@ export { validateFormDataPure as validateFormData };
|
|
|
333
206
|
/* -----------------------------------------------------------
|
|
334
207
|
QUERY
|
|
335
208
|
----------------------------------------------------------- */
|
|
336
|
-
/**
|
|
337
|
-
* > You must configure the generic argument `T`.
|
|
338
|
-
*
|
|
339
|
-
* URL query decoder.
|
|
340
|
-
*
|
|
341
|
-
* `typia.http.query()` is a function decoding a query string or an `URLSearchParams`
|
|
342
|
-
* instance, with automatic type casting to the expected type. When property type be
|
|
343
|
-
* defined as `boolean` or `number` type, `typia.http.query()` will cast the value to
|
|
344
|
-
* the expected type when decoding.
|
|
345
|
-
*
|
|
346
|
-
* By the way, as URL query is not enough to express complex data structures,
|
|
347
|
-
* `typia.http.query()` function has some limitations. If target type `T` is not
|
|
348
|
-
* following those restrictions, compilation errors would be occured.
|
|
349
|
-
*
|
|
350
|
-
* 1. Type `T` must be an object type
|
|
351
|
-
* 2. Do not allow dynamic property
|
|
352
|
-
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
353
|
-
* 4. By the way, union type never be not allowed
|
|
354
|
-
*
|
|
355
|
-
* Also, `typia.http.query()` function does not perform validation about the decoded
|
|
356
|
-
* value. Therefore, if you can't sure that input data is following the `T` type,
|
|
357
|
-
* it would better to call one of below functions intead.
|
|
358
|
-
*
|
|
359
|
-
* - {@link assertQuery}
|
|
360
|
-
* - {@link isQuery}
|
|
361
|
-
* - {@link validateQuery}
|
|
362
|
-
*
|
|
363
|
-
* @template T Expected type of decoded value
|
|
364
|
-
* @param input Query string or URLSearchParams instance
|
|
365
|
-
* @returns Decoded query object
|
|
366
|
-
*
|
|
367
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
-
*/
|
|
369
|
-
function query(): never;
|
|
370
|
-
|
|
371
209
|
/**
|
|
372
210
|
* URL query decoder.
|
|
373
211
|
*
|
|
@@ -413,38 +251,6 @@ const queryPure = /** @__PURE__ */ Object.assign<typeof query, {}>(
|
|
|
413
251
|
);
|
|
414
252
|
export { queryPure as query };
|
|
415
253
|
|
|
416
|
-
/**
|
|
417
|
-
* > You must configure the generic argument `T`.
|
|
418
|
-
*
|
|
419
|
-
* URL query decoder with type assertion.
|
|
420
|
-
*
|
|
421
|
-
* `typia.http.assertQuery()` is a function decoding a query string or an
|
|
422
|
-
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
423
|
-
* When property type be defined as `boolean` or `number` type,
|
|
424
|
-
* `typia.http.assertQuery()` will cast the value to the expected type when decoding.
|
|
425
|
-
*
|
|
426
|
-
* Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
|
|
427
|
-
* decoded value by combining with {@link assert} function. Therefore, when the
|
|
428
|
-
* decoded value is not following the `T` type, {@link TypeGuardError} would be
|
|
429
|
-
* thrown.
|
|
430
|
-
*
|
|
431
|
-
* By the way, as URL query is not enough to express complex data structures,
|
|
432
|
-
* `typia.http.assertQuery()` function has some limitations. If target type `T` is
|
|
433
|
-
* notfollowing those restrictions, compilation errors would be occured.
|
|
434
|
-
*
|
|
435
|
-
* 1. Type `T` must be an object type
|
|
436
|
-
* 2. Do not allow dynamic property
|
|
437
|
-
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
438
|
-
* 4. By the way, union type never be not allowed
|
|
439
|
-
*
|
|
440
|
-
* @template T Expected type of decoded value
|
|
441
|
-
* @param input Query string or URLSearchParams instance
|
|
442
|
-
* @returns Decoded query object
|
|
443
|
-
*
|
|
444
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
445
|
-
*/
|
|
446
|
-
function assertQuery(): never;
|
|
447
|
-
|
|
448
254
|
/**
|
|
449
255
|
* URL query decoder with type assertion.
|
|
450
256
|
*
|
|
@@ -475,6 +281,7 @@ function assertQuery(): never;
|
|
|
475
281
|
*/
|
|
476
282
|
function assertQuery<T extends object>(
|
|
477
283
|
input: string | URLSearchParams,
|
|
284
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
478
285
|
): Resolved<T>;
|
|
479
286
|
|
|
480
287
|
/**
|
|
@@ -494,37 +301,6 @@ const assertQueryPure = /** @__PURE__ */ Object.assign<
|
|
|
494
301
|
);
|
|
495
302
|
export { assertQueryPure as assertQuery };
|
|
496
303
|
|
|
497
|
-
/**
|
|
498
|
-
* > You must configure the generic argument `T`.
|
|
499
|
-
*
|
|
500
|
-
* URL query decoder with type checking.
|
|
501
|
-
*
|
|
502
|
-
* `typia.http.isQuery()` is a function decoding a query string or an
|
|
503
|
-
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
504
|
-
* When property type be defined as `boolean` or `number` type,
|
|
505
|
-
* `typia.http.isQuery()` will cast the value to the expected type when decoding.
|
|
506
|
-
*
|
|
507
|
-
* Also, after decoding, `typia.http.isQuery()` performs type checking to the
|
|
508
|
-
* decoded value by combining with {@link is} function. Therefore, when the
|
|
509
|
-
* decoded value is not following the `T` type, `null` value would be returned.
|
|
510
|
-
*
|
|
511
|
-
* By the way, as URL query is not enough to express complex data structures,
|
|
512
|
-
* `typia.http.isQuery()` function has some limitations. If target type `T` is
|
|
513
|
-
* notfollowing those restrictions, compilation errors would be occured.
|
|
514
|
-
*
|
|
515
|
-
* 1. Type `T` must be an object type
|
|
516
|
-
* 2. Do not allow dynamic property
|
|
517
|
-
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
518
|
-
* 4. By the way, union type never be not allowed
|
|
519
|
-
*
|
|
520
|
-
* @template T Expected type of decoded value
|
|
521
|
-
* @param input Query string or URLSearchParams instance
|
|
522
|
-
* @returns Decoded query object or `null` value
|
|
523
|
-
*
|
|
524
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
525
|
-
*/
|
|
526
|
-
function isQuery(): never;
|
|
527
|
-
|
|
528
304
|
/**
|
|
529
305
|
* URL query decoder with type checking.
|
|
530
306
|
*
|
|
@@ -570,38 +346,6 @@ const isQueryPure = /** @__PURE__ */ Object.assign<typeof isQuery, {}, {}>(
|
|
|
570
346
|
);
|
|
571
347
|
export { isQueryPure as isQuery };
|
|
572
348
|
|
|
573
|
-
/**
|
|
574
|
-
* > You must configure the generic argument `T`.
|
|
575
|
-
*
|
|
576
|
-
* URL query decoder with type validation.
|
|
577
|
-
*
|
|
578
|
-
* `typia.http.validateQuery()` is a function decoding a query string or an
|
|
579
|
-
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
580
|
-
* When property type be defined as `boolean` or `number` type,
|
|
581
|
-
* `typia.http.validateQuery()` will cast the value to the expected type when decoding.
|
|
582
|
-
*
|
|
583
|
-
* Also, after decoding, `typia.http.validateQuery()` performs type validation to the
|
|
584
|
-
* decoded value by combining with {@link validate} function. Therefore, when the
|
|
585
|
-
* decoded value is not following the `T` type, {@link IValidation.IFailure} would
|
|
586
|
-
* be returned. Otherwise, {@link IValidation.ISuccess} would be returned.
|
|
587
|
-
*
|
|
588
|
-
* By the way, as URL query is not enough to express complex data structures,
|
|
589
|
-
* `typia.http.validateQuery()` function has some limitations. If target type `T` is
|
|
590
|
-
* notfollowing those restrictions, compilation errors would be occured.
|
|
591
|
-
*
|
|
592
|
-
* 1. Type `T` must be an object type
|
|
593
|
-
* 2. Do not allow dynamic property
|
|
594
|
-
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
595
|
-
* 4. By the way, union type never be not allowed
|
|
596
|
-
*
|
|
597
|
-
* @template T Expected type of decoded value
|
|
598
|
-
* @param input Query string or URLSearchParams instance
|
|
599
|
-
* @returns Validation result with decoded query object
|
|
600
|
-
*
|
|
601
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
602
|
-
*/
|
|
603
|
-
function validateQuery(): never;
|
|
604
|
-
|
|
605
349
|
/**
|
|
606
350
|
* URL query decoder with type validation.
|
|
607
351
|
*
|
|
@@ -654,62 +398,6 @@ export { validateQueryPure as validateQuery };
|
|
|
654
398
|
/* -----------------------------------------------------------
|
|
655
399
|
HEADERS
|
|
656
400
|
----------------------------------------------------------- */
|
|
657
|
-
/**
|
|
658
|
-
* > You must configure the generic argument `T`.
|
|
659
|
-
*
|
|
660
|
-
* Headers decoder (for express and fastify).
|
|
661
|
-
*
|
|
662
|
-
* `typia.http.headers()` is a function decoding an header instance, with automatic
|
|
663
|
-
* type casting to the expected type. When property type be defined as `boolean` or
|
|
664
|
-
* `number` type, `typia.http.headers()` will cast the value to the expected type.
|
|
665
|
-
*
|
|
666
|
-
* By the way, as HTTP headers are not enough to express complex data structures,
|
|
667
|
-
* `typia.http.headers()` function has some limitations. If target type `T` is not
|
|
668
|
-
* following those restrictions, compilation errors would be occured.
|
|
669
|
-
*
|
|
670
|
-
* 1. Type `T` must be an object type
|
|
671
|
-
* 2. Do not allow dynamic property
|
|
672
|
-
* 3. Property key must be lower case
|
|
673
|
-
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
674
|
-
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
675
|
-
* 6. By the way, union type never be not allowed
|
|
676
|
-
* 7. Property `set-cookie` must be array type
|
|
677
|
-
* 8. Those properties cannot be array type
|
|
678
|
-
* - age
|
|
679
|
-
* - authorization
|
|
680
|
-
* - content-length
|
|
681
|
-
* - content-type
|
|
682
|
-
* - etag
|
|
683
|
-
* - expires
|
|
684
|
-
* - from
|
|
685
|
-
* - host
|
|
686
|
-
* - if-modified-since
|
|
687
|
-
* - if-unmodified-since
|
|
688
|
-
* - last-modified
|
|
689
|
-
* - location
|
|
690
|
-
* - max-forwards
|
|
691
|
-
* - proxy-authorization
|
|
692
|
-
* - referer
|
|
693
|
-
* - retry-after
|
|
694
|
-
* - server
|
|
695
|
-
* - user-agent
|
|
696
|
-
*
|
|
697
|
-
* Also, `typia.http.headers()` function does not perform validation about the decoded
|
|
698
|
-
* value. Therefore, if you can't sure that input data is following the `T` type,
|
|
699
|
-
* it would better to call one of below functions intead.
|
|
700
|
-
*
|
|
701
|
-
* - {@link assertHeaders}
|
|
702
|
-
* - {@link isHeaders}
|
|
703
|
-
* - {@link validateHeaders}
|
|
704
|
-
*
|
|
705
|
-
* @template T Expected type of decoded value
|
|
706
|
-
* @param input Query string or URLSearchParams instance
|
|
707
|
-
* @returns Decoded headers object
|
|
708
|
-
*
|
|
709
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
710
|
-
*/
|
|
711
|
-
function headers(): never;
|
|
712
|
-
|
|
713
401
|
/**
|
|
714
402
|
* Headers decoder (for express and fastify).
|
|
715
403
|
*
|
|
@@ -779,60 +467,6 @@ const headersPure = /** @__PURE__ */ Object.assign<typeof headers, {}>(
|
|
|
779
467
|
);
|
|
780
468
|
export { headersPure as headers };
|
|
781
469
|
|
|
782
|
-
/**
|
|
783
|
-
* > You must configure the generic argument `T`.
|
|
784
|
-
*
|
|
785
|
-
* Headers decoder with type assertion (for express and fastify).
|
|
786
|
-
*
|
|
787
|
-
* `typia.http.assertHeaders()` is a function decoding an header instance, with
|
|
788
|
-
* automatic type casting to the expected type. When property type be defined as
|
|
789
|
-
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
790
|
-
* expected type.
|
|
791
|
-
*
|
|
792
|
-
* Also, after decoding, `typia.http.assertHeaders()` performs type assertion to the
|
|
793
|
-
* decoded value by combining with {@link assert} function. Therefore, when the
|
|
794
|
-
* decoded value is not following the `T` type, {@link TypeGuardError} would be
|
|
795
|
-
* thrown.
|
|
796
|
-
*
|
|
797
|
-
* By the way, as HTTP headers are not enough to express complex data structures,
|
|
798
|
-
* `typia.http.headers()` function has some limitations. If target type `T` is not
|
|
799
|
-
* following those restrictions, compilation errors would be occured.
|
|
800
|
-
*
|
|
801
|
-
* 1. Type `T` must be an object type
|
|
802
|
-
* 2. Do not allow dynamic property
|
|
803
|
-
* 3. Property key must be lower case
|
|
804
|
-
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
805
|
-
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
806
|
-
* 6. By the way, union type never be not allowed
|
|
807
|
-
* 7. Property `set-cookie` must be array type
|
|
808
|
-
* 8. Those properties cannot be array type
|
|
809
|
-
* - age
|
|
810
|
-
* - authorization
|
|
811
|
-
* - content-length
|
|
812
|
-
* - content-type
|
|
813
|
-
* - etag
|
|
814
|
-
* - expires
|
|
815
|
-
* - from
|
|
816
|
-
* - host
|
|
817
|
-
* - if-modified-since
|
|
818
|
-
* - if-unmodified-since
|
|
819
|
-
* - last-modified
|
|
820
|
-
* - location
|
|
821
|
-
* - max-forwards
|
|
822
|
-
* - proxy-authorization
|
|
823
|
-
* - referer
|
|
824
|
-
* - retry-after
|
|
825
|
-
* - server
|
|
826
|
-
* - user-agent
|
|
827
|
-
*
|
|
828
|
-
* @template T Expected type of decoded value
|
|
829
|
-
* @param input Query string or URLSearchParams instance
|
|
830
|
-
* @returns Decoded headers object
|
|
831
|
-
*
|
|
832
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
833
|
-
*/
|
|
834
|
-
function assertHeaders(): never;
|
|
835
|
-
|
|
836
470
|
/**
|
|
837
471
|
* Headers decoder with type assertion (for express and fastify).
|
|
838
472
|
*
|
|
@@ -885,6 +519,7 @@ function assertHeaders(): never;
|
|
|
885
519
|
*/
|
|
886
520
|
function assertHeaders<T extends object>(
|
|
887
521
|
input: Record<string, string | string[] | undefined>,
|
|
522
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
888
523
|
): Resolved<T>;
|
|
889
524
|
|
|
890
525
|
/**
|
|
@@ -905,59 +540,6 @@ const assertHeadersPure = /** @__PURE__ */ Object.assign<
|
|
|
905
540
|
);
|
|
906
541
|
export { assertHeadersPure as assertHeaders };
|
|
907
542
|
|
|
908
|
-
/**
|
|
909
|
-
* > You must configure the generic argument `T`.
|
|
910
|
-
*
|
|
911
|
-
* Headers decoder with type checking (for express and fastify).
|
|
912
|
-
*
|
|
913
|
-
* `typia.http.isHeaders()` is a function decoding an header instance, with
|
|
914
|
-
* automatic type casting to the expected type. When property type be defined as
|
|
915
|
-
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
916
|
-
* expected type.
|
|
917
|
-
*
|
|
918
|
-
* Also, after decoding, `typia.http.isHeaders()` performs type checking to the
|
|
919
|
-
* decoded value by combining with {@link is} function. Therefore, when the
|
|
920
|
-
* decoded value is not following the `T` type, `null` value would be returned.
|
|
921
|
-
*
|
|
922
|
-
* By the way, as HTTP headers are not enough to express complex data structures,
|
|
923
|
-
* `typia.http.headers()` function has some limitations. If target type `T` is not
|
|
924
|
-
* following those restrictions, compilation errors would be occured.
|
|
925
|
-
*
|
|
926
|
-
* 1. Type `T` must be an object type
|
|
927
|
-
* 2. Do not allow dynamic property
|
|
928
|
-
* 3. Property key must be lower case
|
|
929
|
-
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
930
|
-
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
931
|
-
* 6. By the way, union type never be not allowed
|
|
932
|
-
* 7. Property `set-cookie` must be array type
|
|
933
|
-
* 8. Those properties cannot be array type
|
|
934
|
-
* - age
|
|
935
|
-
* - authorization
|
|
936
|
-
* - content-length
|
|
937
|
-
* - content-type
|
|
938
|
-
* - etag
|
|
939
|
-
* - expires
|
|
940
|
-
* - from
|
|
941
|
-
* - host
|
|
942
|
-
* - if-modified-since
|
|
943
|
-
* - if-unmodified-since
|
|
944
|
-
* - last-modified
|
|
945
|
-
* - location
|
|
946
|
-
* - max-forwards
|
|
947
|
-
* - proxy-authorization
|
|
948
|
-
* - referer
|
|
949
|
-
* - retry-after
|
|
950
|
-
* - server
|
|
951
|
-
* - user-agent
|
|
952
|
-
*
|
|
953
|
-
* @template T Expected type of decoded value
|
|
954
|
-
* @param input Query string or URLSearchParams instance
|
|
955
|
-
* @returns Decoded headers object or `null` value
|
|
956
|
-
*
|
|
957
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
958
|
-
*/
|
|
959
|
-
function isHeaders(): never;
|
|
960
|
-
|
|
961
543
|
/**
|
|
962
544
|
* > You must configure the generic argument `T`.
|
|
963
545
|
*
|
|
@@ -1026,60 +608,6 @@ const isHeadersPure = /** @__PURE__ */ Object.assign<typeof isHeaders, {}, {}>(
|
|
|
1026
608
|
);
|
|
1027
609
|
export { isHeadersPure as isHeaders };
|
|
1028
610
|
|
|
1029
|
-
/**
|
|
1030
|
-
* > You must configure the generic argument `T`.
|
|
1031
|
-
*
|
|
1032
|
-
* Headers decoder with type validation (for express and fastify).
|
|
1033
|
-
*
|
|
1034
|
-
* `typia.http.validateHeaders()` is a function decoding an header instance, with
|
|
1035
|
-
* automatic type casting to the expected type. When property type be defined as
|
|
1036
|
-
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
1037
|
-
* expected type.
|
|
1038
|
-
*
|
|
1039
|
-
* Also, after decoding, `typia.http.validateHeaders()` performs type assertion to the
|
|
1040
|
-
* decoded value by combining with {@link validate} function. Therefore, when the
|
|
1041
|
-
* decoded value is not following the `T` type, {@link IValidation.IError} would be
|
|
1042
|
-
* returned. Otherwise, {@link IValidation.ISuccess} be returned.
|
|
1043
|
-
*
|
|
1044
|
-
* By the way, as HTTP headers are not enough to express complex data structures,
|
|
1045
|
-
* `typia.http.headers()` function has some limitations. If target type `T` is not
|
|
1046
|
-
* following those restrictions, compilation errors would be occured.
|
|
1047
|
-
*
|
|
1048
|
-
* 1. Type `T` must be an object type
|
|
1049
|
-
* 2. Do not allow dynamic property
|
|
1050
|
-
* 3. Property key must be lower case
|
|
1051
|
-
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
1052
|
-
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
1053
|
-
* 6. By the way, union type never be not allowed
|
|
1054
|
-
* 7. Property `set-cookie` must be array type
|
|
1055
|
-
* 8. Those properties cannot be array type
|
|
1056
|
-
* - age
|
|
1057
|
-
* - authorization
|
|
1058
|
-
* - content-length
|
|
1059
|
-
* - content-type
|
|
1060
|
-
* - etag
|
|
1061
|
-
* - expires
|
|
1062
|
-
* - from
|
|
1063
|
-
* - host
|
|
1064
|
-
* - if-modified-since
|
|
1065
|
-
* - if-unmodified-since
|
|
1066
|
-
* - last-modified
|
|
1067
|
-
* - location
|
|
1068
|
-
* - max-forwards
|
|
1069
|
-
* - proxy-authorization
|
|
1070
|
-
* - referer
|
|
1071
|
-
* - retry-after
|
|
1072
|
-
* - server
|
|
1073
|
-
* - user-agent
|
|
1074
|
-
*
|
|
1075
|
-
* @template T Expected type of decoded value
|
|
1076
|
-
* @param input Query string or URLSearchParams instance
|
|
1077
|
-
* @returns Decoded headers object
|
|
1078
|
-
*
|
|
1079
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
1080
|
-
*/
|
|
1081
|
-
function validateHeaders(): never;
|
|
1082
|
-
|
|
1083
611
|
/**
|
|
1084
612
|
* Headers decoder with type validation (for express and fastify).
|
|
1085
613
|
*
|
|
@@ -1155,25 +683,6 @@ export { validateHeadersPure as validateHeaders };
|
|
|
1155
683
|
/* -----------------------------------------------------------
|
|
1156
684
|
PARAMETER
|
|
1157
685
|
----------------------------------------------------------- */
|
|
1158
|
-
/**
|
|
1159
|
-
* > You must configure the generic argument `T`.
|
|
1160
|
-
*
|
|
1161
|
-
* URL path parameter decoder.
|
|
1162
|
-
*
|
|
1163
|
-
* `typia.http.parameter()` is a function decoding a path parameter, with automatic
|
|
1164
|
-
* type casting to the expected type. When type `T` has beeen defined as `boolean` or
|
|
1165
|
-
* `number` type, `typia.http.parameter()` will cast the value to the expected type.
|
|
1166
|
-
*
|
|
1167
|
-
* Also, `typia.http.parameter()` performs type assertion to the decoded value by
|
|
1168
|
-
* combining with {@link assert} function. Therefore, when the decoded value is not
|
|
1169
|
-
* following the `T` type, {@link TypeGuardError} would be thrown.
|
|
1170
|
-
*
|
|
1171
|
-
* @template T Expected type of decoded value
|
|
1172
|
-
* @param input Path parameter string
|
|
1173
|
-
* @returns Decoded path parameter value
|
|
1174
|
-
*/
|
|
1175
|
-
function parameter(): never;
|
|
1176
|
-
|
|
1177
686
|
/**
|
|
1178
687
|
* URL path parameter decoder.
|
|
1179
688
|
*
|
|
@@ -1251,7 +760,9 @@ export { createFormDataPure as createFormData };
|
|
|
1251
760
|
*
|
|
1252
761
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1253
762
|
*/
|
|
1254
|
-
function createAssertFormData(
|
|
763
|
+
function createAssertFormData(
|
|
764
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
765
|
+
): never;
|
|
1255
766
|
|
|
1256
767
|
/**
|
|
1257
768
|
* Creates a reusable {@link assertFormData} function.
|
|
@@ -1261,7 +772,9 @@ function createAssertFormData(): never;
|
|
|
1261
772
|
*
|
|
1262
773
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1263
774
|
*/
|
|
1264
|
-
function createAssertFormData<T extends object>(
|
|
775
|
+
function createAssertFormData<T extends object>(
|
|
776
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
777
|
+
): (input: FormData) => T;
|
|
1265
778
|
|
|
1266
779
|
/**
|
|
1267
780
|
* @internal
|
|
@@ -1408,7 +921,9 @@ export { createQueryPure as createQuery };
|
|
|
1408
921
|
*
|
|
1409
922
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1410
923
|
*/
|
|
1411
|
-
function createAssertQuery(
|
|
924
|
+
function createAssertQuery(
|
|
925
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
926
|
+
): never;
|
|
1412
927
|
|
|
1413
928
|
/**
|
|
1414
929
|
* Creates a reusable {@link assertQuery} function.
|
|
@@ -1418,9 +933,9 @@ function createAssertQuery(): never;
|
|
|
1418
933
|
*
|
|
1419
934
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1420
935
|
*/
|
|
1421
|
-
function createAssertQuery<T extends object>(
|
|
1422
|
-
|
|
1423
|
-
) => T;
|
|
936
|
+
function createAssertQuery<T extends object>(
|
|
937
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
938
|
+
): (input: string | URLSearchParams) => T;
|
|
1424
939
|
|
|
1425
940
|
/**
|
|
1426
941
|
* @internal
|
|
@@ -1571,7 +1086,9 @@ export { createHeadersPure as createHeaders };
|
|
|
1571
1086
|
*
|
|
1572
1087
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1573
1088
|
*/
|
|
1574
|
-
function createAssertHeaders(
|
|
1089
|
+
function createAssertHeaders(
|
|
1090
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
1091
|
+
): never;
|
|
1575
1092
|
|
|
1576
1093
|
/**
|
|
1577
1094
|
* Creates a reusable {@link assertHeaders} function.
|
|
@@ -1581,9 +1098,9 @@ function createAssertHeaders(): never;
|
|
|
1581
1098
|
*
|
|
1582
1099
|
* @author Jeongho Nam - https://github.com/samchon
|
|
1583
1100
|
*/
|
|
1584
|
-
function createAssertHeaders<T extends object>(
|
|
1585
|
-
|
|
1586
|
-
) => T;
|
|
1101
|
+
function createAssertHeaders<T extends object>(
|
|
1102
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
1103
|
+
): (input: Record<string, string | string[] | undefined>) => T;
|
|
1587
1104
|
|
|
1588
1105
|
/**
|
|
1589
1106
|
* @internal
|