typia 5.2.0 → 5.2.1

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/src/http.ts CHANGED
@@ -1,1149 +1,1149 @@
1
- import { Namespace } from "./functional/Namespace";
2
-
3
- import { Atomic } from "./typings/Atomic";
4
-
5
- import { IValidation } from "./IValidation";
6
- import { Resolved } from "./Resolved";
7
-
8
- /* ===========================================================
9
- HTTP
10
- - QUERY
11
- - HEADERS
12
- - PARAMETER
13
- - FACTORY FUNCTIONS
14
- ==============================================================
15
- QUERY
16
- ----------------------------------------------------------- */
17
- /**
18
- * > You must configure the generic argument `T`.
19
- *
20
- * URL query decoder.
21
- *
22
- * `typia.http.query()` is a function decoding a query string or an `URLSearchParams`
23
- * instance, with automatic type casting to the expected type. When property type be
24
- * defined as `boolean` or `number` type, `typia.http.query()` will cast the value to
25
- * the expected type when decoding.
26
- *
27
- * By the way, as URL query is not enough to express complex data structures,
28
- * `typia.http.query()` function has some limitations. If target type `T` is not
29
- * following those restrictions, compilation errors would be occured.
30
- *
31
- * 1. Type `T` must be an object type
32
- * 2. Do not allow dynamic property
33
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
34
- * 4. By the way, union type never be not allowed
35
- *
36
- * Also, `typia.http.query()` function does not perform validation about the decoded
37
- * value. Therefore, if you can't sure that input data is following the `T` type,
38
- * it would better to call one of below functions intead.
39
- *
40
- * - {@link assertQuery}
41
- * - {@link isQuery}
42
- * - {@link validateQuery}
43
- *
44
- * @template T Expected type of decoded value
45
- * @param input Query string or URLSearchParams instance
46
- * @returns Decoded query object
47
- *
48
- * @author Jeongho Nam - https://github.com/samchon
49
- */
50
- export function query(): never;
51
-
52
- /**
53
- * URL query decoder.
54
- *
55
- * `typia.http.query()` is a function decoding a query string or an `URLSearchParams`
56
- * instance, with automatic type casting to the expected type. When property type be
57
- * defined as `boolean` or `number` type, `typia.http.query()` will cast the value to
58
- * the expected type when decoding.
59
- *
60
- * By the way, as URL query is not enough to express complex data structures,
61
- * `typia.http.query()` function has some limitations. If target type `T` is not
62
- * following those restrictions, compilation errors would be occured.
63
- *
64
- * 1. Type `T` must be an object type
65
- * 2. Do not allow dynamic property
66
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
67
- * 4. By the way, union type never be not allowed
68
- *
69
- * Also, `typia.http.query()` function does not perform validation about the decoded
70
- * value. Therefore, if you can't sure that input data is following the `T` type,
71
- * it would better to call one of below functions intead.
72
- *
73
- * - {@link assertQuery}
74
- * - {@link isQuery}
75
- * - {@link validateQuery}
76
- *
77
- * @template T Expected type of decoded value
78
- * @param input Query string or URLSearchParams instance
79
- * @returns Decoded query object
80
- *
81
- * @author Jeongho Nam - https://github.com/samchon
82
- */
83
- export function query<T extends object>(
84
- input: string | URLSearchParams,
85
- ): Resolved<T>;
86
-
87
- /**
88
- * @internal
89
- */
90
- export function query(): never {
91
- halt("query");
92
- }
93
- Object.assign(query, Namespace.http.query());
94
-
95
- /**
96
- * > You must configure the generic argument `T`.
97
- *
98
- * URL query decoder with type assertion.
99
- *
100
- * `typia.http.assertQuery()` is a function decoding a query string or an
101
- * `URLSearchParams` instance, with automatic type casting to the expected type.
102
- * When property type be defined as `boolean` or `number` type,
103
- * `typia.http.assertQuery()` will cast the value to the expected type when decoding.
104
- *
105
- * Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
106
- * decoded value by combining with {@link assert} function. Therefore, when the
107
- * decoded value is not following the `T` type, {@link TypeGuardError} would be
108
- * thrown.
109
- *
110
- * By the way, as URL query is not enough to express complex data structures,
111
- * `typia.http.assertQuery()` function has some limitations. If target type `T` is
112
- * notfollowing those restrictions, compilation errors would be occured.
113
- *
114
- * 1. Type `T` must be an object type
115
- * 2. Do not allow dynamic property
116
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
117
- * 4. By the way, union type never be not allowed
118
- *
119
- * @template T Expected type of decoded value
120
- * @param input Query string or URLSearchParams instance
121
- * @returns Decoded query object
122
- *
123
- * @author Jeongho Nam - https://github.com/samchon
124
- */
125
- export function assertQuery(): never;
126
-
127
- /**
128
- * URL query decoder with type assertion.
129
- *
130
- * `typia.http.assertQuery()` is a function decoding a query string or an
131
- * `URLSearchParams` instance, with automatic type casting to the expected type.
132
- * When property type be defined as `boolean` or `number` type,
133
- * `typia.http.assertQuery()` will cast the value to the expected type when decoding.
134
- *
135
- * Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
136
- * decoded value by combining with {@link assert} function. Therefore, when the
137
- * decoded value is not following the `T` type, {@link TypeGuardError} would be
138
- * thrown.
139
- *
140
- * By the way, as URL query is not enough to express complex data structures,
141
- * `typia.http.assertQuery()` function has some limitations. If target type `T` is
142
- * notfollowing those restrictions, compilation errors would be occured.
143
- *
144
- * 1. Type `T` must be an object type
145
- * 2. Do not allow dynamic property
146
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
147
- * 4. By the way, union type never be not allowed
148
- *
149
- * @template T Expected type of decoded value
150
- * @param input Query string or URLSearchParams instance
151
- * @returns Decoded query object
152
- *
153
- * @author Jeongho Nam - https://github.com/samchon
154
- */
155
- export function assertQuery<T extends object>(
156
- input: string | URLSearchParams,
157
- ): Resolved<T>;
158
-
159
- /**
160
- * @internal
161
- */
162
- export function assertQuery(): never {
163
- halt("assertQuery");
164
- }
165
- Object.assign(assertQuery, Namespace.http.query());
166
- Object.assign(assertQuery, Namespace.assert("http.assertQuery"));
167
-
168
- /**
169
- * > You must configure the generic argument `T`.
170
- *
171
- * URL query decoder with type checking.
172
- *
173
- * `typia.http.isQuery()` is a function decoding a query string or an
174
- * `URLSearchParams` instance, with automatic type casting to the expected type.
175
- * When property type be defined as `boolean` or `number` type,
176
- * `typia.http.isQuery()` will cast the value to the expected type when decoding.
177
- *
178
- * Also, after decoding, `typia.http.isQuery()` performs type checking to the
179
- * decoded value by combining with {@link is} function. Therefore, when the
180
- * decoded value is not following the `T` type, `null` value would be returned.
181
- *
182
- * By the way, as URL query is not enough to express complex data structures,
183
- * `typia.http.isQuery()` function has some limitations. If target type `T` is
184
- * notfollowing those restrictions, compilation errors would be occured.
185
- *
186
- * 1. Type `T` must be an object type
187
- * 2. Do not allow dynamic property
188
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
189
- * 4. By the way, union type never be not allowed
190
- *
191
- * @template T Expected type of decoded value
192
- * @param input Query string or URLSearchParams instance
193
- * @returns Decoded query object or `null` value
194
- *
195
- * @author Jeongho Nam - https://github.com/samchon
196
- */
197
- export function isQuery(): never;
198
-
199
- /**
200
- * URL query decoder with type checking.
201
- *
202
- * `typia.http.isQuery()` is a function decoding a query string or an
203
- * `URLSearchParams` instance, with automatic type casting to the expected type.
204
- * When property type be defined as `boolean` or `number` type,
205
- * `typia.http.isQuery()` will cast the value to the expected type when decoding.
206
- *
207
- * Also, after decoding, `typia.http.isQuery()` performs type checking to the
208
- * decoded value by combining with {@link is} function. Therefore, when the
209
- * decoded value is not following the `T` type, `null` value would be returned.
210
- *
211
- * By the way, as URL query is not enough to express complex data structures,
212
- * `typia.http.isQuery()` function has some limitations. If target type `T` is
213
- * notfollowing those restrictions, compilation errors would be occured.
214
- *
215
- * 1. Type `T` must be an object type
216
- * 2. Do not allow dynamic property
217
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
218
- * 4. By the way, union type never be not allowed
219
- *
220
- * @template T Expected type of decoded value
221
- * @param input Query string or URLSearchParams instance
222
- * @returns Decoded query object or `null` value
223
- *
224
- * @author Jeongho Nam - https://github.com/samchon
225
- */
226
- export function isQuery<T extends object>(
227
- input: string | URLSearchParams,
228
- ): Resolved<T> | null;
229
-
230
- /**
231
- * @internal
232
- */
233
- export function isQuery(): never {
234
- halt("isQuery");
235
- }
236
- Object.assign(isQuery, Namespace.http.query());
237
- Object.assign(isQuery, Namespace.is());
238
-
239
- /**
240
- * > You must configure the generic argument `T`.
241
- *
242
- * URL query decoder with type validation.
243
- *
244
- * `typia.http.validateQuery()` is a function decoding a query string or an
245
- * `URLSearchParams` instance, with automatic type casting to the expected type.
246
- * When property type be defined as `boolean` or `number` type,
247
- * `typia.http.validateQuery()` will cast the value to the expected type when decoding.
248
- *
249
- * Also, after decoding, `typia.http.validateQuery()` performs type validation to the
250
- * decoded value by combining with {@link validate} function. Therefore, when the
251
- * decoded value is not following the `T` type, {@link IValidation.IFailure} would
252
- * be returned. Otherwise, {@link IValidation.ISuccess} would be returned.
253
- *
254
- * By the way, as URL query is not enough to express complex data structures,
255
- * `typia.http.validateQuery()` function has some limitations. If target type `T` is
256
- * notfollowing those restrictions, compilation errors would be occured.
257
- *
258
- * 1. Type `T` must be an object type
259
- * 2. Do not allow dynamic property
260
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
261
- * 4. By the way, union type never be not allowed
262
- *
263
- * @template T Expected type of decoded value
264
- * @param input Query string or URLSearchParams instance
265
- * @returns Validation result with decoded query object
266
- *
267
- * @author Jeongho Nam - https://github.com/samchon
268
- */
269
- export function validateQuery(): never;
270
-
271
- /**
272
- * URL query decoder with type validation.
273
- *
274
- * `typia.http.validateQuery()` is a function decoding a query string or an
275
- * `URLSearchParams` instance, with automatic type casting to the expected type.
276
- * When property type be defined as `boolean` or `number` type,
277
- * `typia.http.validateQuery()` will cast the value to the expected type when decoding.
278
- *
279
- * Also, after decoding, `typia.http.validateQuery()` performs type validation to the
280
- * decoded value by combining with {@link validate} function. Therefore, when the
281
- * decoded value is not following the `T` type, {@link IValidation.IFailure} would
282
- * be returned. Otherwise, {@link IValidation.ISuccess} would be returned.
283
- *
284
- * By the way, as URL query is not enough to express complex data structures,
285
- * `typia.http.validateQuery()` function has some limitations. If target type `T` is
286
- * notfollowing those restrictions, compilation errors would be occured.
287
- *
288
- * 1. Type `T` must be an object type
289
- * 2. Do not allow dynamic property
290
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
291
- * 4. By the way, union type never be not allowed
292
- *
293
- * @template T Expected type of decoded value
294
- * @param input Query string or URLSearchParams instance
295
- * @returns Validation result with decoded query object
296
- *
297
- * @author Jeongho Nam - https://github.com/samchon
298
- */
299
- export function validateQuery<T extends object>(
300
- input: string | URLSearchParams,
301
- ): IValidation<Resolved<T>>;
302
-
303
- /**
304
- * @internal
305
- */
306
- export function validateQuery(): never {
307
- halt("validateQuery");
308
- }
309
- Object.assign(validateQuery, Namespace.http.query());
310
- Object.assign(validateQuery, Namespace.validate());
311
-
312
- /* -----------------------------------------------------------
313
- HEADERS
314
- ----------------------------------------------------------- */
315
- /**
316
- * > You must configure the generic argument `T`.
317
- *
318
- * Headers decoder (for express and fastify).
319
- *
320
- * `typia.http.headers()` is a function decoding an header instance, with automatic
321
- * type casting to the expected type. When property type be defined as `boolean` or
322
- * `number` type, `typia.http.headers()` will cast the value to the expected type.
323
- *
324
- * By the way, as HTTP headers are not enough to express complex data structures,
325
- * `typia.http.headers()` function has some limitations. If target type `T` is not
326
- * following those restrictions, compilation errors would be occured.
327
- *
328
- * 1. Type `T` must be an object type
329
- * 2. Do not allow dynamic property
330
- * 3. Property key must be lower case
331
- * 4. Property value cannot be `null`, but `undefined` is possible
332
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
333
- * 6. By the way, union type never be not allowed
334
- * 7. Property `set-cookie` must be array type
335
- * 8. Those properties cannot be array type
336
- * - age
337
- * - authorization
338
- * - content-length
339
- * - content-type
340
- * - etag
341
- * - expires
342
- * - from
343
- * - host
344
- * - if-modified-since
345
- * - if-unmodified-since
346
- * - last-modified
347
- * - location
348
- * - max-forwards
349
- * - proxy-authorization
350
- * - referer
351
- * - retry-after
352
- * - server
353
- * - user-agent
354
- *
355
- * Also, `typia.http.headers()` 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 assertHeaders}
360
- * - {@link isHeaders}
361
- * - {@link validateHeaders}
362
- *
363
- * @template T Expected type of decoded value
364
- * @param input Query string or URLSearchParams instance
365
- * @returns Decoded headers object
366
- *
367
- * @author Jeongho Nam - https://github.com/samchon
368
- */
369
- export function headers(): never;
370
-
371
- /**
372
- * Headers decoder (for express and fastify).
373
- *
374
- * `typia.http.headers()` is a function decoding an header instance, with automatic
375
- * type casting to the expected type. When property type be defined as `boolean` or
376
- * `number` type, `typia.http.headers()` will cast the value to the expected type.
377
- *
378
- * By the way, as HTTP headers are not enough to express complex data structures,
379
- * `typia.http.headers()` function has some limitations. If target type `T` is not
380
- * following those restrictions, compilation errors would be occured.
381
- *
382
- * 1. Type `T` must be an object type
383
- * 2. Do not allow dynamic property
384
- * 3. Property key must be lower case
385
- * 4. Property value cannot be `null`, but `undefined` is possible
386
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
387
- * 6. By the way, union type never be not allowed
388
- * 7. Property `set-cookie` must be array type
389
- * 8. Those properties cannot be array type
390
- * - age
391
- * - authorization
392
- * - content-length
393
- * - content-type
394
- * - etag
395
- * - expires
396
- * - from
397
- * - host
398
- * - if-modified-since
399
- * - if-unmodified-since
400
- * - last-modified
401
- * - location
402
- * - max-forwards
403
- * - proxy-authorization
404
- * - referer
405
- * - retry-after
406
- * - server
407
- * - user-agent
408
- *
409
- * Also, `typia.http.headers()` function does not perform validation about the decoded
410
- * value. Therefore, if you can't sure that input data is following the `T` type,
411
- * it would better to call one of below functions intead.
412
- *
413
- * - {@link assertHeaders}
414
- * - {@link isHeaders}
415
- * - {@link validateHeaders}
416
- *
417
- * @template T Expected type of decoded value
418
- * @param input Query string or URLSearchParams instance
419
- * @returns Decoded headers object
420
- *
421
- * @author Jeongho Nam - https://github.com/samchon
422
- */
423
- export function headers<T extends object>(
424
- input: Record<string, string | string[] | undefined>,
425
- ): Resolved<T>;
426
-
427
- /**
428
- * @internal
429
- */
430
- export function headers(): never {
431
- halt("headers");
432
- }
433
- Object.assign(headers, Namespace.http.headers());
434
-
435
- /**
436
- * > You must configure the generic argument `T`.
437
- *
438
- * Headers decoder with type assertion (for express and fastify).
439
- *
440
- * `typia.http.assertHeaders()` is a function decoding an header instance, with
441
- * automatic type casting to the expected type. When property type be defined as
442
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
443
- * expected type.
444
- *
445
- * Also, after decoding, `typia.http.assertHeaders()` performs type assertion to the
446
- * decoded value by combining with {@link assert} function. Therefore, when the
447
- * decoded value is not following the `T` type, {@link TypeGuardError} would be
448
- * thrown.
449
- *
450
- * By the way, as HTTP headers are not enough to express complex data structures,
451
- * `typia.http.headers()` function has some limitations. If target type `T` is not
452
- * following those restrictions, compilation errors would be occured.
453
- *
454
- * 1. Type `T` must be an object type
455
- * 2. Do not allow dynamic property
456
- * 3. Property key must be lower case
457
- * 4. Property value cannot be `null`, but `undefined` is possible
458
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
459
- * 6. By the way, union type never be not allowed
460
- * 7. Property `set-cookie` must be array type
461
- * 8. Those properties cannot be array type
462
- * - age
463
- * - authorization
464
- * - content-length
465
- * - content-type
466
- * - etag
467
- * - expires
468
- * - from
469
- * - host
470
- * - if-modified-since
471
- * - if-unmodified-since
472
- * - last-modified
473
- * - location
474
- * - max-forwards
475
- * - proxy-authorization
476
- * - referer
477
- * - retry-after
478
- * - server
479
- * - user-agent
480
- *
481
- * @template T Expected type of decoded value
482
- * @param input Query string or URLSearchParams instance
483
- * @returns Decoded headers object
484
- *
485
- * @author Jeongho Nam - https://github.com/samchon
486
- */
487
- export function assertHeaders(): never;
488
-
489
- /**
490
- * Headers decoder with type assertion (for express and fastify).
491
- *
492
- * `typia.http.assertHeaders()` is a function decoding an header instance, with
493
- * automatic type casting to the expected type. When property type be defined as
494
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
495
- * expected type.
496
- *
497
- * Also, after decoding, `typia.http.assertHeaders()` performs type assertion to the
498
- * decoded value by combining with {@link assert} function. Therefore, when the
499
- * decoded value is not following the `T` type, {@link TypeGuardError} would be
500
- * thrown.
501
- *
502
- * By the way, as HTTP headers are not enough to express complex data structures,
503
- * `typia.http.headers()` function has some limitations. If target type `T` is not
504
- * following those restrictions, compilation errors would be occured.
505
- *
506
- * 1. Type `T` must be an object type
507
- * 2. Do not allow dynamic property
508
- * 3. Property key must be lower case
509
- * 4. Property value cannot be `null`, but `undefined` is possible
510
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
511
- * 6. By the way, union type never be not allowed
512
- * 7. Property `set-cookie` must be array type
513
- * 8. Those properties cannot be array type
514
- * - age
515
- * - authorization
516
- * - content-length
517
- * - content-type
518
- * - etag
519
- * - expires
520
- * - from
521
- * - host
522
- * - if-modified-since
523
- * - if-unmodified-since
524
- * - last-modified
525
- * - location
526
- * - max-forwards
527
- * - proxy-authorization
528
- * - referer
529
- * - retry-after
530
- * - server
531
- * - user-agent
532
- *
533
- * @template T Expected type of decoded value
534
- * @param input Query string or URLSearchParams instance
535
- * @returns Decoded headers object
536
- *
537
- * @author Jeongho Nam - https://github.com/samchon
538
- */
539
- export function assertHeaders<T extends object>(
540
- input: Record<string, string | string[] | undefined>,
541
- ): Resolved<T>;
542
-
543
- /**
544
- * @internal
545
- */
546
- export function assertHeaders(): never {
547
- halt("assertHeaders");
548
- }
549
- Object.assign(assertHeaders, Namespace.http.headers());
550
- Object.assign(assertHeaders, Namespace.assert("http.assertHeaders"));
551
-
552
- /**
553
- * > You must configure the generic argument `T`.
554
- *
555
- * Headers decoder with type checking (for express and fastify).
556
- *
557
- * `typia.http.isHeaders()` is a function decoding an header instance, with
558
- * automatic type casting to the expected type. When property type be defined as
559
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
560
- * expected type.
561
- *
562
- * Also, after decoding, `typia.http.isHeaders()` performs type checking to the
563
- * decoded value by combining with {@link is} function. Therefore, when the
564
- * decoded value is not following the `T` type, `null` value would be returned.
565
- *
566
- * By the way, as HTTP headers are not enough to express complex data structures,
567
- * `typia.http.headers()` function has some limitations. If target type `T` is not
568
- * following those restrictions, compilation errors would be occured.
569
- *
570
- * 1. Type `T` must be an object type
571
- * 2. Do not allow dynamic property
572
- * 3. Property key must be lower case
573
- * 4. Property value cannot be `null`, but `undefined` is possible
574
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
575
- * 6. By the way, union type never be not allowed
576
- * 7. Property `set-cookie` must be array type
577
- * 8. Those properties cannot be array type
578
- * - age
579
- * - authorization
580
- * - content-length
581
- * - content-type
582
- * - etag
583
- * - expires
584
- * - from
585
- * - host
586
- * - if-modified-since
587
- * - if-unmodified-since
588
- * - last-modified
589
- * - location
590
- * - max-forwards
591
- * - proxy-authorization
592
- * - referer
593
- * - retry-after
594
- * - server
595
- * - user-agent
596
- *
597
- * @template T Expected type of decoded value
598
- * @param input Query string or URLSearchParams instance
599
- * @returns Decoded headers object or `null` value
600
- *
601
- * @author Jeongho Nam - https://github.com/samchon
602
- */
603
- export function isHeaders(): never;
604
-
605
- /**
606
- * > You must configure the generic argument `T`.
607
- *
608
- * Headers decoder with type checking (for express and fastify).
609
- *
610
- * `typia.http.isHeaders()` is a function decoding an header instance, with
611
- * automatic type casting to the expected type. When property type be defined as
612
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
613
- * expected type.
614
- *
615
- * Also, after decoding, `typia.http.isHeaders()` performs type checking to the
616
- * decoded value by combining with {@link is} function. Therefore, when the
617
- * decoded value is not following the `T` type, `null` value would be returned.
618
- *
619
- * By the way, as HTTP headers are not enough to express complex data structures,
620
- * `typia.http.headers()` function has some limitations. If target type `T` is not
621
- * following those restrictions, compilation errors would be occured.
622
- *
623
- * 1. Type `T` must be an object type
624
- * 2. Do not allow dynamic property
625
- * 3. Property key must be lower case
626
- * 4. Property value cannot be `null`, but `undefined` is possible
627
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
628
- * 6. By the way, union type never be not allowed
629
- * 7. Property `set-cookie` must be array type
630
- * 8. Those properties cannot be array type
631
- * - age
632
- * - authorization
633
- * - content-length
634
- * - content-type
635
- * - etag
636
- * - expires
637
- * - from
638
- * - host
639
- * - if-modified-since
640
- * - if-unmodified-since
641
- * - last-modified
642
- * - location
643
- * - max-forwards
644
- * - proxy-authorization
645
- * - referer
646
- * - retry-after
647
- * - server
648
- * - user-agent
649
- *
650
- * @template T Expected type of decoded value
651
- * @param input Query string or URLSearchParams instance
652
- * @returns Decoded headers object or `null` value
653
- *
654
- * @author Jeongho Nam - https://github.com/samchon
655
- */
656
- export function isHeaders<T extends object>(
657
- input: Record<string, string | string[] | undefined>,
658
- ): Resolved<T> | null;
659
-
660
- /**
661
- * @internal
662
- */
663
- export function isHeaders(): never {
664
- halt("isHeaders");
665
- }
666
- Object.assign(isHeaders, Namespace.http.headers());
667
- Object.assign(isHeaders, Namespace.is());
668
-
669
- /**
670
- * > You must configure the generic argument `T`.
671
- *
672
- * Headers decoder with type validation (for express and fastify).
673
- *
674
- * `typia.http.validateHeaders()` is a function decoding an header instance, with
675
- * automatic type casting to the expected type. When property type be defined as
676
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
677
- * expected type.
678
- *
679
- * Also, after decoding, `typia.http.validateHeaders()` performs type assertion to the
680
- * decoded value by combining with {@link validate} function. Therefore, when the
681
- * decoded value is not following the `T` type, {@link IValidation.IError} would be
682
- * returned. Otherwise, {@link IValidation.ISuccess} be returned.
683
- *
684
- * By the way, as HTTP headers are not enough to express complex data structures,
685
- * `typia.http.headers()` function has some limitations. If target type `T` is not
686
- * following those restrictions, compilation errors would be occured.
687
- *
688
- * 1. Type `T` must be an object type
689
- * 2. Do not allow dynamic property
690
- * 3. Property key must be lower case
691
- * 4. Property value cannot be `null`, but `undefined` is possible
692
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
693
- * 6. By the way, union type never be not allowed
694
- * 7. Property `set-cookie` must be array type
695
- * 8. Those properties cannot be array type
696
- * - age
697
- * - authorization
698
- * - content-length
699
- * - content-type
700
- * - etag
701
- * - expires
702
- * - from
703
- * - host
704
- * - if-modified-since
705
- * - if-unmodified-since
706
- * - last-modified
707
- * - location
708
- * - max-forwards
709
- * - proxy-authorization
710
- * - referer
711
- * - retry-after
712
- * - server
713
- * - user-agent
714
- *
715
- * @template T Expected type of decoded value
716
- * @param input Query string or URLSearchParams instance
717
- * @returns Decoded headers object
718
- *
719
- * @author Jeongho Nam - https://github.com/samchon
720
- */
721
- export function validateHeaders(): never;
722
-
723
- /**
724
- * Headers decoder with type validation (for express and fastify).
725
- *
726
- * `typia.http.validateHeaders()` is a function decoding an header instance, with
727
- * automatic type casting to the expected type. When property type be defined as
728
- * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
729
- * expected type.
730
- *
731
- * Also, after decoding, `typia.http.validateHeaders()` performs type assertion to the
732
- * decoded value by combining with {@link validate} function. Therefore, when the
733
- * decoded value is not following the `T` type, {@link IValidation.IError} would be
734
- * returned. Otherwise, {@link IValidation.ISuccess} be returned.
735
- *
736
- * By the way, as HTTP headers are not enough to express complex data structures,
737
- * `typia.http.headers()` function has some limitations. If target type `T` is not
738
- * following those restrictions, compilation errors would be occured.
739
- *
740
- * 1. Type `T` must be an object type
741
- * 2. Do not allow dynamic property
742
- * 3. Property key must be lower case
743
- * 4. Property value cannot be `null`, but `undefined` is possible
744
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
745
- * 6. By the way, union type never be not allowed
746
- * 7. Property `set-cookie` must be array type
747
- * 8. Those properties cannot be array type
748
- * - age
749
- * - authorization
750
- * - content-length
751
- * - content-type
752
- * - etag
753
- * - expires
754
- * - from
755
- * - host
756
- * - if-modified-since
757
- * - if-unmodified-since
758
- * - last-modified
759
- * - location
760
- * - max-forwards
761
- * - proxy-authorization
762
- * - referer
763
- * - retry-after
764
- * - server
765
- * - user-agent
766
- *
767
- * @template T Expected type of decoded value
768
- * @param input Query string or URLSearchParams instance
769
- * @returns Decoded headers object
770
- *
771
- * @author Jeongho Nam - https://github.com/samchon
772
- */
773
- export function validateHeaders<T extends object>(
774
- input: Record<string, string | string[] | undefined>,
775
- ): IValidation<Resolved<T>>;
776
-
777
- /**
778
- * @internal
779
- */
780
- export function validateHeaders(): never {
781
- halt("validateHeaders");
782
- }
783
- Object.assign(validateHeaders, Namespace.http.headers());
784
- Object.assign(validateHeaders, Namespace.validate());
785
-
786
- /* -----------------------------------------------------------
787
- PARAMETER
788
- ----------------------------------------------------------- */
789
- /**
790
- * > You must configure the generic argument `T`.
791
- *
792
- * URL path parameter decoder.
793
- *
794
- * `typia.http.parameter()` is a function decoding a path parameter, with automatic
795
- * type casting to the expected type. When type `T` has beeen defined as `boolean` or
796
- * `number` type, `typia.http.parameter()` will cast the value to the expected type.
797
- *
798
- * Also, `typia.http.parameter()` performs type assertion to the decoded value by
799
- * combining with {@link assert} function. Therefore, when the decoded value is not
800
- * following the `T` type, {@link TypeGuardError} would be thrown.
801
- *
802
- * @template T Expected type of decoded value
803
- * @param input Path parameter string
804
- * @returns Decoded path parameter value
805
- */
806
- export function parameter(): never;
807
-
808
- /**
809
- * URL path parameter decoder.
810
- *
811
- * `typia.http.parameter()` is a function decoding a path parameter, with automatic
812
- * type casting to the expected type. When type `T` has beeen defined as `boolean` or
813
- * `number` type, `typia.http.parameter()` will cast the value to the expected type.
814
- *
815
- * Also, `typia.http.parameter()` performs type assertion to the decoded value by
816
- * combining with {@link assert} function. Therefore, when the decoded value is not
817
- * following the `T` type, {@link TypeGuardError} would be thrown.
818
- *
819
- * @template T Expected type of decoded value
820
- * @param input Path parameter string
821
- * @returns Decoded path parameter value
822
- */
823
- export function parameter<T extends Atomic.Type | null>(
824
- input: string,
825
- ): Resolved<T>;
826
-
827
- /**
828
- * @internal
829
- */
830
- export function parameter(): never {
831
- halt("parameter");
832
- }
833
- Object.assign(parameter, Namespace.http.parameter());
834
- Object.assign(parameter, Namespace.assert("http.parameter"));
835
-
836
- /* -----------------------------------------------------------
837
- FACTORY FUNCTIONS
838
- ----------------------------------------------------------- */
839
- /**
840
- * Creates a reusable {@link query} function.
841
- *
842
- * @danger You must configure the generic argument `T`
843
- * @template T The type of the query object
844
- * @throws compile error
845
- *
846
- * @author Jeongho Nam - https://github.com/samchon
847
- */
848
- export function createQuery(): never;
849
-
850
- /**
851
- * Creates a reusable {@link query} function.
852
- *
853
- * @template T The type of the query object
854
- * @returns A reusable `query` function
855
- *
856
- * @author Jeongho Nam - https://github.com/samchon
857
- */
858
- export function createQuery<T extends object>(): (
859
- input: string | URLSearchParams,
860
- ) => T;
861
-
862
- /**
863
- * @internal
864
- */
865
- export function createQuery<T>(): (input: string | URLSearchParams) => T {
866
- halt("createQuery");
867
- }
868
- Object.assign(createQuery, Namespace.http.query());
869
-
870
- /**
871
- * Creates a reusable {@link assertQuery} function.
872
- *
873
- * @danger You must configure the generic argument `T`
874
- * @template T The type of the query object
875
- * @throws compile error
876
- *
877
- * @author Jeongho Nam - https://github.com/samchon
878
- */
879
- export function createAssertQuery(): never;
880
-
881
- /**
882
- * Creates a reusable {@link assertQuery} function.
883
- *
884
- * @template T The type of the query object
885
- * @returns A reusable `assertQuery` function
886
- *
887
- * @author Jeongho Nam - https://github.com/samchon
888
- */
889
- export function createAssertQuery<T extends object>(): (
890
- input: string | URLSearchParams,
891
- ) => T;
892
-
893
- /**
894
- * @internal
895
- */
896
- export function createAssertQuery<T>(): (input: string | URLSearchParams) => T {
897
- halt("createAssertQuery");
898
- }
899
- Object.assign(createAssertQuery, Namespace.http.query());
900
- Object.assign(createAssertQuery, Namespace.assert("http.createAssertQuery"));
901
-
902
- /**
903
- * Creates a reusable {@link isQuery} function.
904
- *
905
- * @danger You must configure the generic argument `T`
906
- * @template T The type of the query object
907
- * @throws compile error
908
- *
909
- * @author Jeongho Nam - https://github.com/samchon
910
- */
911
- export function createIsQuery(): never;
912
-
913
- /**
914
- * Creates a reusable {@link isQuery} function.
915
- *
916
- * @template T The type of the query object
917
- * @returns A reusable `isQuery` function
918
- *
919
- * @author Jeongho Nam - https://github.com/samchon
920
- */
921
- export function createIsQuery<T extends object>(): (
922
- input: string | URLSearchParams,
923
- ) => T | null;
924
-
925
- /**
926
- * @internal
927
- */
928
- export function createIsQuery<T>(): (
929
- input: string | URLSearchParams,
930
- ) => T | null {
931
- halt("createIsQuery");
932
- }
933
- Object.assign(createIsQuery, Namespace.http.query());
934
- Object.assign(createIsQuery, Namespace.is());
935
-
936
- /**
937
- * Creates a reusable {@link validateQuery} function.
938
- *
939
- * @danger You must configure the generic argument `T`
940
- * @template T The type of the query object
941
- * @throws compile error
942
- *
943
- * @author Jeongho Nam - https://github.com/samchon
944
- */
945
- export function createValidateQuery(): never;
946
-
947
- /**
948
- * Creates a reusable {@link validateQuery} function.
949
- *
950
- * @template T The type of the query object
951
- * @returns A reusable `validateQuery` function
952
- *
953
- * @author Jeongho Nam - https://github.com/samchon
954
- */
955
- export function createValidateQuery<T extends object>(): (
956
- input: string | URLSearchParams,
957
- ) => IValidation<Resolved<T>>;
958
-
959
- /**
960
- * @internal
961
- */
962
- export function createValidateQuery<T>(): (
963
- input: string | URLSearchParams,
964
- ) => IValidation<Resolved<T>> {
965
- halt("createValidateQuery");
966
- }
967
- Object.assign(createValidateQuery, Namespace.http.query());
968
- Object.assign(createValidateQuery, Namespace.validate());
969
-
970
- /**
971
- * Creates a reusable {@link headers} function.
972
- *
973
- * @danger You must configure the generic argument `T`
974
- * @template T The type of the headers object
975
- * @throws compile error
976
- *
977
- * @author Jeongho Nam - https://github.com/samchon
978
- */
979
- export function createHeaders(): never;
980
-
981
- /**
982
- * Creates a reusable {@link headers} function.
983
- *
984
- * @template T The type of the headers object
985
- * @returns A reusable `headers` function
986
- *
987
- * @author Jeongho Nam - https://github.com/samchon
988
- */
989
- export function createHeaders<T extends object>(): (
990
- input: Record<string, string | string[] | undefined>,
991
- ) => T;
992
-
993
- /**
994
- * @internal
995
- */
996
- export function createHeaders<T>(): (
997
- input: Record<string, string | string[] | undefined>,
998
- ) => T {
999
- halt("createHeaders");
1000
- }
1001
- Object.assign(createHeaders, Namespace.http.headers());
1002
-
1003
- /**
1004
- * Creates a reusable {@link assertHeaders} function.
1005
- *
1006
- * @danger You must configure the generic argument `T`
1007
- * @template T The type of the headers object
1008
- * @throws compile error
1009
- *
1010
- * @author Jeongho Nam - https://github.com/samchon
1011
- */
1012
- export function createAssertHeaders(): never;
1013
-
1014
- /**
1015
- * Creates a reusable {@link assertHeaders} function.
1016
- *
1017
- * @template T The type of the headers object
1018
- * @returns A reusable `assertHeaders` function
1019
- *
1020
- * @author Jeongho Nam - https://github.com/samchon
1021
- */
1022
- export function createAssertHeaders<T extends object>(): (
1023
- input: Record<string, string | string[] | undefined>,
1024
- ) => T;
1025
-
1026
- /**
1027
- * @internal
1028
- */
1029
- export function createAssertHeaders<T>(): (
1030
- input: Record<string, string | string[] | undefined>,
1031
- ) => T {
1032
- halt("createAssertHeaders");
1033
- }
1034
- Object.assign(createAssertHeaders, Namespace.http.headers());
1035
- Object.assign(
1036
- createAssertHeaders,
1037
- Namespace.assert("http.createAssertHeaders"),
1038
- );
1039
-
1040
- /**
1041
- * Creates a reusable {@link isHeaders} function.
1042
- *
1043
- * @danger You must configure the generic argument `T`
1044
- * @template T The type of the headers object
1045
- * @throws compile error
1046
- *
1047
- * @author Jeongho Nam - https://github.com/samchon
1048
- */
1049
- export function createIsHeaders(): never;
1050
-
1051
- /**
1052
- * Creates a reusable {@link isHeaders} function.
1053
- *
1054
- * @template T The type of the headers object
1055
- * @returns A reusable `isHeaders` function
1056
- *
1057
- * @author Jeongho Nam - https://github.com/samchon
1058
- */
1059
- export function createIsHeaders<T extends object>(): (
1060
- input: Record<string, string | string[] | undefined>,
1061
- ) => T | null;
1062
-
1063
- /**
1064
- * @internal
1065
- */
1066
- export function createIsHeaders<T>(): (
1067
- input: Record<string, string | string[] | undefined>,
1068
- ) => T | null {
1069
- halt("createIsHeaders");
1070
- }
1071
- Object.assign(createIsHeaders, Namespace.http.headers());
1072
- Object.assign(createIsHeaders, Namespace.is());
1073
-
1074
- /**
1075
- * Creates a reusable {@link validateHeaders} function.
1076
- *
1077
- * @danger You must configure the generic argument `T`
1078
- * @template T The type of the headers object
1079
- * @throws compile error
1080
- *
1081
- * @author Jeongho Nam - https://github.com/samchon
1082
- */
1083
- export function createValidateHeaders(): never;
1084
-
1085
- /**
1086
- * Creates a reusable {@link validateHeaders} function.
1087
- *
1088
- * @template T The type of the headers object
1089
- * @returns A reusable `validateHeaders` function
1090
- *
1091
- * @author Jeongho Nam - https://github.com/samchon
1092
- */
1093
- export function createValidateHeaders<T extends object>(): (
1094
- input: Record<string, string | string[] | undefined>,
1095
- ) => IValidation<Resolved<T>>;
1096
-
1097
- /**
1098
- * @internal
1099
- */
1100
- export function createValidateHeaders<T>(): (
1101
- input: Record<string, string | string[] | undefined>,
1102
- ) => IValidation<Resolved<T>> {
1103
- halt("createValidateHeaders");
1104
- }
1105
- Object.assign(createValidateHeaders, Namespace.http.headers());
1106
- Object.assign(createValidateHeaders, Namespace.validate());
1107
-
1108
- /**
1109
- * Creates a reusable {@link parameter} function.
1110
- *
1111
- * @danger You must configure the generic argument `T`
1112
- * @template T The type of the parameter value
1113
- * @throws compile error
1114
- *
1115
- * @author Jeongho Nam - https://github.com/samchon
1116
- */
1117
- export function createParameter(): never;
1118
-
1119
- /**
1120
- * Creates a reusable {@link parameter} function.
1121
- *
1122
- * @template T The type of the parameter value
1123
- * @returns A reusable `parameter` function
1124
- *
1125
- * @author Jeongho Nam - https://github.com/samchon
1126
- */
1127
- export function createParameter<T extends Atomic.Type | null>(): (
1128
- input: string,
1129
- ) => T;
1130
-
1131
- /**
1132
- * @internal
1133
- */
1134
- export function createParameter<T extends Atomic.Type | null>(): (
1135
- input: string,
1136
- ) => T {
1137
- halt("createParameter");
1138
- }
1139
- Object.assign(createParameter, Namespace.http.parameter());
1140
- Object.assign(createParameter, Namespace.assert("http.createParameter"));
1141
-
1142
- /**
1143
- * @internal
1144
- */
1145
- function halt(name: string): never {
1146
- throw new Error(
1147
- `Error on typia.http.${name}(): no transform has been configured. Read and follow https://typia.misc.io/docs/setup please.`,
1148
- );
1149
- }
1
+ import { Namespace } from "./functional/Namespace";
2
+
3
+ import { Atomic } from "./typings/Atomic";
4
+
5
+ import { IValidation } from "./IValidation";
6
+ import { Resolved } from "./Resolved";
7
+
8
+ /* ===========================================================
9
+ HTTP
10
+ - QUERY
11
+ - HEADERS
12
+ - PARAMETER
13
+ - FACTORY FUNCTIONS
14
+ ==============================================================
15
+ QUERY
16
+ ----------------------------------------------------------- */
17
+ /**
18
+ * > You must configure the generic argument `T`.
19
+ *
20
+ * URL query decoder.
21
+ *
22
+ * `typia.http.query()` is a function decoding a query string or an `URLSearchParams`
23
+ * instance, with automatic type casting to the expected type. When property type be
24
+ * defined as `boolean` or `number` type, `typia.http.query()` will cast the value to
25
+ * the expected type when decoding.
26
+ *
27
+ * By the way, as URL query is not enough to express complex data structures,
28
+ * `typia.http.query()` function has some limitations. If target type `T` is not
29
+ * following those restrictions, compilation errors would be occured.
30
+ *
31
+ * 1. Type `T` must be an object type
32
+ * 2. Do not allow dynamic property
33
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
34
+ * 4. By the way, union type never be not allowed
35
+ *
36
+ * Also, `typia.http.query()` function does not perform validation about the decoded
37
+ * value. Therefore, if you can't sure that input data is following the `T` type,
38
+ * it would better to call one of below functions intead.
39
+ *
40
+ * - {@link assertQuery}
41
+ * - {@link isQuery}
42
+ * - {@link validateQuery}
43
+ *
44
+ * @template T Expected type of decoded value
45
+ * @param input Query string or URLSearchParams instance
46
+ * @returns Decoded query object
47
+ *
48
+ * @author Jeongho Nam - https://github.com/samchon
49
+ */
50
+ export function query(): never;
51
+
52
+ /**
53
+ * URL query decoder.
54
+ *
55
+ * `typia.http.query()` is a function decoding a query string or an `URLSearchParams`
56
+ * instance, with automatic type casting to the expected type. When property type be
57
+ * defined as `boolean` or `number` type, `typia.http.query()` will cast the value to
58
+ * the expected type when decoding.
59
+ *
60
+ * By the way, as URL query is not enough to express complex data structures,
61
+ * `typia.http.query()` function has some limitations. If target type `T` is not
62
+ * following those restrictions, compilation errors would be occured.
63
+ *
64
+ * 1. Type `T` must be an object type
65
+ * 2. Do not allow dynamic property
66
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
67
+ * 4. By the way, union type never be not allowed
68
+ *
69
+ * Also, `typia.http.query()` function does not perform validation about the decoded
70
+ * value. Therefore, if you can't sure that input data is following the `T` type,
71
+ * it would better to call one of below functions intead.
72
+ *
73
+ * - {@link assertQuery}
74
+ * - {@link isQuery}
75
+ * - {@link validateQuery}
76
+ *
77
+ * @template T Expected type of decoded value
78
+ * @param input Query string or URLSearchParams instance
79
+ * @returns Decoded query object
80
+ *
81
+ * @author Jeongho Nam - https://github.com/samchon
82
+ */
83
+ export function query<T extends object>(
84
+ input: string | URLSearchParams,
85
+ ): Resolved<T>;
86
+
87
+ /**
88
+ * @internal
89
+ */
90
+ export function query(): never {
91
+ halt("query");
92
+ }
93
+ Object.assign(query, Namespace.http.query());
94
+
95
+ /**
96
+ * > You must configure the generic argument `T`.
97
+ *
98
+ * URL query decoder with type assertion.
99
+ *
100
+ * `typia.http.assertQuery()` is a function decoding a query string or an
101
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
102
+ * When property type be defined as `boolean` or `number` type,
103
+ * `typia.http.assertQuery()` will cast the value to the expected type when decoding.
104
+ *
105
+ * Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
106
+ * decoded value by combining with {@link assert} function. Therefore, when the
107
+ * decoded value is not following the `T` type, {@link TypeGuardError} would be
108
+ * thrown.
109
+ *
110
+ * By the way, as URL query is not enough to express complex data structures,
111
+ * `typia.http.assertQuery()` function has some limitations. If target type `T` is
112
+ * notfollowing those restrictions, compilation errors would be occured.
113
+ *
114
+ * 1. Type `T` must be an object type
115
+ * 2. Do not allow dynamic property
116
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
117
+ * 4. By the way, union type never be not allowed
118
+ *
119
+ * @template T Expected type of decoded value
120
+ * @param input Query string or URLSearchParams instance
121
+ * @returns Decoded query object
122
+ *
123
+ * @author Jeongho Nam - https://github.com/samchon
124
+ */
125
+ export function assertQuery(): never;
126
+
127
+ /**
128
+ * URL query decoder with type assertion.
129
+ *
130
+ * `typia.http.assertQuery()` is a function decoding a query string or an
131
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
132
+ * When property type be defined as `boolean` or `number` type,
133
+ * `typia.http.assertQuery()` will cast the value to the expected type when decoding.
134
+ *
135
+ * Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
136
+ * decoded value by combining with {@link assert} function. Therefore, when the
137
+ * decoded value is not following the `T` type, {@link TypeGuardError} would be
138
+ * thrown.
139
+ *
140
+ * By the way, as URL query is not enough to express complex data structures,
141
+ * `typia.http.assertQuery()` function has some limitations. If target type `T` is
142
+ * notfollowing those restrictions, compilation errors would be occured.
143
+ *
144
+ * 1. Type `T` must be an object type
145
+ * 2. Do not allow dynamic property
146
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
147
+ * 4. By the way, union type never be not allowed
148
+ *
149
+ * @template T Expected type of decoded value
150
+ * @param input Query string or URLSearchParams instance
151
+ * @returns Decoded query object
152
+ *
153
+ * @author Jeongho Nam - https://github.com/samchon
154
+ */
155
+ export function assertQuery<T extends object>(
156
+ input: string | URLSearchParams,
157
+ ): Resolved<T>;
158
+
159
+ /**
160
+ * @internal
161
+ */
162
+ export function assertQuery(): never {
163
+ halt("assertQuery");
164
+ }
165
+ Object.assign(assertQuery, Namespace.http.query());
166
+ Object.assign(assertQuery, Namespace.assert("http.assertQuery"));
167
+
168
+ /**
169
+ * > You must configure the generic argument `T`.
170
+ *
171
+ * URL query decoder with type checking.
172
+ *
173
+ * `typia.http.isQuery()` is a function decoding a query string or an
174
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
175
+ * When property type be defined as `boolean` or `number` type,
176
+ * `typia.http.isQuery()` will cast the value to the expected type when decoding.
177
+ *
178
+ * Also, after decoding, `typia.http.isQuery()` performs type checking to the
179
+ * decoded value by combining with {@link is} function. Therefore, when the
180
+ * decoded value is not following the `T` type, `null` value would be returned.
181
+ *
182
+ * By the way, as URL query is not enough to express complex data structures,
183
+ * `typia.http.isQuery()` function has some limitations. If target type `T` is
184
+ * notfollowing those restrictions, compilation errors would be occured.
185
+ *
186
+ * 1. Type `T` must be an object type
187
+ * 2. Do not allow dynamic property
188
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
189
+ * 4. By the way, union type never be not allowed
190
+ *
191
+ * @template T Expected type of decoded value
192
+ * @param input Query string or URLSearchParams instance
193
+ * @returns Decoded query object or `null` value
194
+ *
195
+ * @author Jeongho Nam - https://github.com/samchon
196
+ */
197
+ export function isQuery(): never;
198
+
199
+ /**
200
+ * URL query decoder with type checking.
201
+ *
202
+ * `typia.http.isQuery()` is a function decoding a query string or an
203
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
204
+ * When property type be defined as `boolean` or `number` type,
205
+ * `typia.http.isQuery()` will cast the value to the expected type when decoding.
206
+ *
207
+ * Also, after decoding, `typia.http.isQuery()` performs type checking to the
208
+ * decoded value by combining with {@link is} function. Therefore, when the
209
+ * decoded value is not following the `T` type, `null` value would be returned.
210
+ *
211
+ * By the way, as URL query is not enough to express complex data structures,
212
+ * `typia.http.isQuery()` function has some limitations. If target type `T` is
213
+ * notfollowing those restrictions, compilation errors would be occured.
214
+ *
215
+ * 1. Type `T` must be an object type
216
+ * 2. Do not allow dynamic property
217
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
218
+ * 4. By the way, union type never be not allowed
219
+ *
220
+ * @template T Expected type of decoded value
221
+ * @param input Query string or URLSearchParams instance
222
+ * @returns Decoded query object or `null` value
223
+ *
224
+ * @author Jeongho Nam - https://github.com/samchon
225
+ */
226
+ export function isQuery<T extends object>(
227
+ input: string | URLSearchParams,
228
+ ): Resolved<T> | null;
229
+
230
+ /**
231
+ * @internal
232
+ */
233
+ export function isQuery(): never {
234
+ halt("isQuery");
235
+ }
236
+ Object.assign(isQuery, Namespace.http.query());
237
+ Object.assign(isQuery, Namespace.is());
238
+
239
+ /**
240
+ * > You must configure the generic argument `T`.
241
+ *
242
+ * URL query decoder with type validation.
243
+ *
244
+ * `typia.http.validateQuery()` is a function decoding a query string or an
245
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
246
+ * When property type be defined as `boolean` or `number` type,
247
+ * `typia.http.validateQuery()` will cast the value to the expected type when decoding.
248
+ *
249
+ * Also, after decoding, `typia.http.validateQuery()` performs type validation to the
250
+ * decoded value by combining with {@link validate} function. Therefore, when the
251
+ * decoded value is not following the `T` type, {@link IValidation.IFailure} would
252
+ * be returned. Otherwise, {@link IValidation.ISuccess} would be returned.
253
+ *
254
+ * By the way, as URL query is not enough to express complex data structures,
255
+ * `typia.http.validateQuery()` function has some limitations. If target type `T` is
256
+ * notfollowing those restrictions, compilation errors would be occured.
257
+ *
258
+ * 1. Type `T` must be an object type
259
+ * 2. Do not allow dynamic property
260
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
261
+ * 4. By the way, union type never be not allowed
262
+ *
263
+ * @template T Expected type of decoded value
264
+ * @param input Query string or URLSearchParams instance
265
+ * @returns Validation result with decoded query object
266
+ *
267
+ * @author Jeongho Nam - https://github.com/samchon
268
+ */
269
+ export function validateQuery(): never;
270
+
271
+ /**
272
+ * URL query decoder with type validation.
273
+ *
274
+ * `typia.http.validateQuery()` is a function decoding a query string or an
275
+ * `URLSearchParams` instance, with automatic type casting to the expected type.
276
+ * When property type be defined as `boolean` or `number` type,
277
+ * `typia.http.validateQuery()` will cast the value to the expected type when decoding.
278
+ *
279
+ * Also, after decoding, `typia.http.validateQuery()` performs type validation to the
280
+ * decoded value by combining with {@link validate} function. Therefore, when the
281
+ * decoded value is not following the `T` type, {@link IValidation.IFailure} would
282
+ * be returned. Otherwise, {@link IValidation.ISuccess} would be returned.
283
+ *
284
+ * By the way, as URL query is not enough to express complex data structures,
285
+ * `typia.http.validateQuery()` function has some limitations. If target type `T` is
286
+ * notfollowing those restrictions, compilation errors would be occured.
287
+ *
288
+ * 1. Type `T` must be an object type
289
+ * 2. Do not allow dynamic property
290
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
291
+ * 4. By the way, union type never be not allowed
292
+ *
293
+ * @template T Expected type of decoded value
294
+ * @param input Query string or URLSearchParams instance
295
+ * @returns Validation result with decoded query object
296
+ *
297
+ * @author Jeongho Nam - https://github.com/samchon
298
+ */
299
+ export function validateQuery<T extends object>(
300
+ input: string | URLSearchParams,
301
+ ): IValidation<Resolved<T>>;
302
+
303
+ /**
304
+ * @internal
305
+ */
306
+ export function validateQuery(): never {
307
+ halt("validateQuery");
308
+ }
309
+ Object.assign(validateQuery, Namespace.http.query());
310
+ Object.assign(validateQuery, Namespace.validate());
311
+
312
+ /* -----------------------------------------------------------
313
+ HEADERS
314
+ ----------------------------------------------------------- */
315
+ /**
316
+ * > You must configure the generic argument `T`.
317
+ *
318
+ * Headers decoder (for express and fastify).
319
+ *
320
+ * `typia.http.headers()` is a function decoding an header instance, with automatic
321
+ * type casting to the expected type. When property type be defined as `boolean` or
322
+ * `number` type, `typia.http.headers()` will cast the value to the expected type.
323
+ *
324
+ * By the way, as HTTP headers are not enough to express complex data structures,
325
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
326
+ * following those restrictions, compilation errors would be occured.
327
+ *
328
+ * 1. Type `T` must be an object type
329
+ * 2. Do not allow dynamic property
330
+ * 3. Property key must be lower case
331
+ * 4. Property value cannot be `null`, but `undefined` is possible
332
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
333
+ * 6. By the way, union type never be not allowed
334
+ * 7. Property `set-cookie` must be array type
335
+ * 8. Those properties cannot be array type
336
+ * - age
337
+ * - authorization
338
+ * - content-length
339
+ * - content-type
340
+ * - etag
341
+ * - expires
342
+ * - from
343
+ * - host
344
+ * - if-modified-since
345
+ * - if-unmodified-since
346
+ * - last-modified
347
+ * - location
348
+ * - max-forwards
349
+ * - proxy-authorization
350
+ * - referer
351
+ * - retry-after
352
+ * - server
353
+ * - user-agent
354
+ *
355
+ * Also, `typia.http.headers()` 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 assertHeaders}
360
+ * - {@link isHeaders}
361
+ * - {@link validateHeaders}
362
+ *
363
+ * @template T Expected type of decoded value
364
+ * @param input Query string or URLSearchParams instance
365
+ * @returns Decoded headers object
366
+ *
367
+ * @author Jeongho Nam - https://github.com/samchon
368
+ */
369
+ export function headers(): never;
370
+
371
+ /**
372
+ * Headers decoder (for express and fastify).
373
+ *
374
+ * `typia.http.headers()` is a function decoding an header instance, with automatic
375
+ * type casting to the expected type. When property type be defined as `boolean` or
376
+ * `number` type, `typia.http.headers()` will cast the value to the expected type.
377
+ *
378
+ * By the way, as HTTP headers are not enough to express complex data structures,
379
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
380
+ * following those restrictions, compilation errors would be occured.
381
+ *
382
+ * 1. Type `T` must be an object type
383
+ * 2. Do not allow dynamic property
384
+ * 3. Property key must be lower case
385
+ * 4. Property value cannot be `null`, but `undefined` is possible
386
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
387
+ * 6. By the way, union type never be not allowed
388
+ * 7. Property `set-cookie` must be array type
389
+ * 8. Those properties cannot be array type
390
+ * - age
391
+ * - authorization
392
+ * - content-length
393
+ * - content-type
394
+ * - etag
395
+ * - expires
396
+ * - from
397
+ * - host
398
+ * - if-modified-since
399
+ * - if-unmodified-since
400
+ * - last-modified
401
+ * - location
402
+ * - max-forwards
403
+ * - proxy-authorization
404
+ * - referer
405
+ * - retry-after
406
+ * - server
407
+ * - user-agent
408
+ *
409
+ * Also, `typia.http.headers()` function does not perform validation about the decoded
410
+ * value. Therefore, if you can't sure that input data is following the `T` type,
411
+ * it would better to call one of below functions intead.
412
+ *
413
+ * - {@link assertHeaders}
414
+ * - {@link isHeaders}
415
+ * - {@link validateHeaders}
416
+ *
417
+ * @template T Expected type of decoded value
418
+ * @param input Query string or URLSearchParams instance
419
+ * @returns Decoded headers object
420
+ *
421
+ * @author Jeongho Nam - https://github.com/samchon
422
+ */
423
+ export function headers<T extends object>(
424
+ input: Record<string, string | string[] | undefined>,
425
+ ): Resolved<T>;
426
+
427
+ /**
428
+ * @internal
429
+ */
430
+ export function headers(): never {
431
+ halt("headers");
432
+ }
433
+ Object.assign(headers, Namespace.http.headers());
434
+
435
+ /**
436
+ * > You must configure the generic argument `T`.
437
+ *
438
+ * Headers decoder with type assertion (for express and fastify).
439
+ *
440
+ * `typia.http.assertHeaders()` is a function decoding an header instance, with
441
+ * automatic type casting to the expected type. When property type be defined as
442
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
443
+ * expected type.
444
+ *
445
+ * Also, after decoding, `typia.http.assertHeaders()` performs type assertion to the
446
+ * decoded value by combining with {@link assert} function. Therefore, when the
447
+ * decoded value is not following the `T` type, {@link TypeGuardError} would be
448
+ * thrown.
449
+ *
450
+ * By the way, as HTTP headers are not enough to express complex data structures,
451
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
452
+ * following those restrictions, compilation errors would be occured.
453
+ *
454
+ * 1. Type `T` must be an object type
455
+ * 2. Do not allow dynamic property
456
+ * 3. Property key must be lower case
457
+ * 4. Property value cannot be `null`, but `undefined` is possible
458
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
459
+ * 6. By the way, union type never be not allowed
460
+ * 7. Property `set-cookie` must be array type
461
+ * 8. Those properties cannot be array type
462
+ * - age
463
+ * - authorization
464
+ * - content-length
465
+ * - content-type
466
+ * - etag
467
+ * - expires
468
+ * - from
469
+ * - host
470
+ * - if-modified-since
471
+ * - if-unmodified-since
472
+ * - last-modified
473
+ * - location
474
+ * - max-forwards
475
+ * - proxy-authorization
476
+ * - referer
477
+ * - retry-after
478
+ * - server
479
+ * - user-agent
480
+ *
481
+ * @template T Expected type of decoded value
482
+ * @param input Query string or URLSearchParams instance
483
+ * @returns Decoded headers object
484
+ *
485
+ * @author Jeongho Nam - https://github.com/samchon
486
+ */
487
+ export function assertHeaders(): never;
488
+
489
+ /**
490
+ * Headers decoder with type assertion (for express and fastify).
491
+ *
492
+ * `typia.http.assertHeaders()` is a function decoding an header instance, with
493
+ * automatic type casting to the expected type. When property type be defined as
494
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
495
+ * expected type.
496
+ *
497
+ * Also, after decoding, `typia.http.assertHeaders()` performs type assertion to the
498
+ * decoded value by combining with {@link assert} function. Therefore, when the
499
+ * decoded value is not following the `T` type, {@link TypeGuardError} would be
500
+ * thrown.
501
+ *
502
+ * By the way, as HTTP headers are not enough to express complex data structures,
503
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
504
+ * following those restrictions, compilation errors would be occured.
505
+ *
506
+ * 1. Type `T` must be an object type
507
+ * 2. Do not allow dynamic property
508
+ * 3. Property key must be lower case
509
+ * 4. Property value cannot be `null`, but `undefined` is possible
510
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
511
+ * 6. By the way, union type never be not allowed
512
+ * 7. Property `set-cookie` must be array type
513
+ * 8. Those properties cannot be array type
514
+ * - age
515
+ * - authorization
516
+ * - content-length
517
+ * - content-type
518
+ * - etag
519
+ * - expires
520
+ * - from
521
+ * - host
522
+ * - if-modified-since
523
+ * - if-unmodified-since
524
+ * - last-modified
525
+ * - location
526
+ * - max-forwards
527
+ * - proxy-authorization
528
+ * - referer
529
+ * - retry-after
530
+ * - server
531
+ * - user-agent
532
+ *
533
+ * @template T Expected type of decoded value
534
+ * @param input Query string or URLSearchParams instance
535
+ * @returns Decoded headers object
536
+ *
537
+ * @author Jeongho Nam - https://github.com/samchon
538
+ */
539
+ export function assertHeaders<T extends object>(
540
+ input: Record<string, string | string[] | undefined>,
541
+ ): Resolved<T>;
542
+
543
+ /**
544
+ * @internal
545
+ */
546
+ export function assertHeaders(): never {
547
+ halt("assertHeaders");
548
+ }
549
+ Object.assign(assertHeaders, Namespace.http.headers());
550
+ Object.assign(assertHeaders, Namespace.assert("http.assertHeaders"));
551
+
552
+ /**
553
+ * > You must configure the generic argument `T`.
554
+ *
555
+ * Headers decoder with type checking (for express and fastify).
556
+ *
557
+ * `typia.http.isHeaders()` is a function decoding an header instance, with
558
+ * automatic type casting to the expected type. When property type be defined as
559
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
560
+ * expected type.
561
+ *
562
+ * Also, after decoding, `typia.http.isHeaders()` performs type checking to the
563
+ * decoded value by combining with {@link is} function. Therefore, when the
564
+ * decoded value is not following the `T` type, `null` value would be returned.
565
+ *
566
+ * By the way, as HTTP headers are not enough to express complex data structures,
567
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
568
+ * following those restrictions, compilation errors would be occured.
569
+ *
570
+ * 1. Type `T` must be an object type
571
+ * 2. Do not allow dynamic property
572
+ * 3. Property key must be lower case
573
+ * 4. Property value cannot be `null`, but `undefined` is possible
574
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
575
+ * 6. By the way, union type never be not allowed
576
+ * 7. Property `set-cookie` must be array type
577
+ * 8. Those properties cannot be array type
578
+ * - age
579
+ * - authorization
580
+ * - content-length
581
+ * - content-type
582
+ * - etag
583
+ * - expires
584
+ * - from
585
+ * - host
586
+ * - if-modified-since
587
+ * - if-unmodified-since
588
+ * - last-modified
589
+ * - location
590
+ * - max-forwards
591
+ * - proxy-authorization
592
+ * - referer
593
+ * - retry-after
594
+ * - server
595
+ * - user-agent
596
+ *
597
+ * @template T Expected type of decoded value
598
+ * @param input Query string or URLSearchParams instance
599
+ * @returns Decoded headers object or `null` value
600
+ *
601
+ * @author Jeongho Nam - https://github.com/samchon
602
+ */
603
+ export function isHeaders(): never;
604
+
605
+ /**
606
+ * > You must configure the generic argument `T`.
607
+ *
608
+ * Headers decoder with type checking (for express and fastify).
609
+ *
610
+ * `typia.http.isHeaders()` is a function decoding an header instance, with
611
+ * automatic type casting to the expected type. When property type be defined as
612
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
613
+ * expected type.
614
+ *
615
+ * Also, after decoding, `typia.http.isHeaders()` performs type checking to the
616
+ * decoded value by combining with {@link is} function. Therefore, when the
617
+ * decoded value is not following the `T` type, `null` value would be returned.
618
+ *
619
+ * By the way, as HTTP headers are not enough to express complex data structures,
620
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
621
+ * following those restrictions, compilation errors would be occured.
622
+ *
623
+ * 1. Type `T` must be an object type
624
+ * 2. Do not allow dynamic property
625
+ * 3. Property key must be lower case
626
+ * 4. Property value cannot be `null`, but `undefined` is possible
627
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
628
+ * 6. By the way, union type never be not allowed
629
+ * 7. Property `set-cookie` must be array type
630
+ * 8. Those properties cannot be array type
631
+ * - age
632
+ * - authorization
633
+ * - content-length
634
+ * - content-type
635
+ * - etag
636
+ * - expires
637
+ * - from
638
+ * - host
639
+ * - if-modified-since
640
+ * - if-unmodified-since
641
+ * - last-modified
642
+ * - location
643
+ * - max-forwards
644
+ * - proxy-authorization
645
+ * - referer
646
+ * - retry-after
647
+ * - server
648
+ * - user-agent
649
+ *
650
+ * @template T Expected type of decoded value
651
+ * @param input Query string or URLSearchParams instance
652
+ * @returns Decoded headers object or `null` value
653
+ *
654
+ * @author Jeongho Nam - https://github.com/samchon
655
+ */
656
+ export function isHeaders<T extends object>(
657
+ input: Record<string, string | string[] | undefined>,
658
+ ): Resolved<T> | null;
659
+
660
+ /**
661
+ * @internal
662
+ */
663
+ export function isHeaders(): never {
664
+ halt("isHeaders");
665
+ }
666
+ Object.assign(isHeaders, Namespace.http.headers());
667
+ Object.assign(isHeaders, Namespace.is());
668
+
669
+ /**
670
+ * > You must configure the generic argument `T`.
671
+ *
672
+ * Headers decoder with type validation (for express and fastify).
673
+ *
674
+ * `typia.http.validateHeaders()` is a function decoding an header instance, with
675
+ * automatic type casting to the expected type. When property type be defined as
676
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
677
+ * expected type.
678
+ *
679
+ * Also, after decoding, `typia.http.validateHeaders()` performs type assertion to the
680
+ * decoded value by combining with {@link validate} function. Therefore, when the
681
+ * decoded value is not following the `T` type, {@link IValidation.IError} would be
682
+ * returned. Otherwise, {@link IValidation.ISuccess} be returned.
683
+ *
684
+ * By the way, as HTTP headers are not enough to express complex data structures,
685
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
686
+ * following those restrictions, compilation errors would be occured.
687
+ *
688
+ * 1. Type `T` must be an object type
689
+ * 2. Do not allow dynamic property
690
+ * 3. Property key must be lower case
691
+ * 4. Property value cannot be `null`, but `undefined` is possible
692
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
693
+ * 6. By the way, union type never be not allowed
694
+ * 7. Property `set-cookie` must be array type
695
+ * 8. Those properties cannot be array type
696
+ * - age
697
+ * - authorization
698
+ * - content-length
699
+ * - content-type
700
+ * - etag
701
+ * - expires
702
+ * - from
703
+ * - host
704
+ * - if-modified-since
705
+ * - if-unmodified-since
706
+ * - last-modified
707
+ * - location
708
+ * - max-forwards
709
+ * - proxy-authorization
710
+ * - referer
711
+ * - retry-after
712
+ * - server
713
+ * - user-agent
714
+ *
715
+ * @template T Expected type of decoded value
716
+ * @param input Query string or URLSearchParams instance
717
+ * @returns Decoded headers object
718
+ *
719
+ * @author Jeongho Nam - https://github.com/samchon
720
+ */
721
+ export function validateHeaders(): never;
722
+
723
+ /**
724
+ * Headers decoder with type validation (for express and fastify).
725
+ *
726
+ * `typia.http.validateHeaders()` is a function decoding an header instance, with
727
+ * automatic type casting to the expected type. When property type be defined as
728
+ * `boolean` or `number` type, `typia.http.headers()` will cast the value to the
729
+ * expected type.
730
+ *
731
+ * Also, after decoding, `typia.http.validateHeaders()` performs type assertion to the
732
+ * decoded value by combining with {@link validate} function. Therefore, when the
733
+ * decoded value is not following the `T` type, {@link IValidation.IError} would be
734
+ * returned. Otherwise, {@link IValidation.ISuccess} be returned.
735
+ *
736
+ * By the way, as HTTP headers are not enough to express complex data structures,
737
+ * `typia.http.headers()` function has some limitations. If target type `T` is not
738
+ * following those restrictions, compilation errors would be occured.
739
+ *
740
+ * 1. Type `T` must be an object type
741
+ * 2. Do not allow dynamic property
742
+ * 3. Property key must be lower case
743
+ * 4. Property value cannot be `null`, but `undefined` is possible
744
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
745
+ * 6. By the way, union type never be not allowed
746
+ * 7. Property `set-cookie` must be array type
747
+ * 8. Those properties cannot be array type
748
+ * - age
749
+ * - authorization
750
+ * - content-length
751
+ * - content-type
752
+ * - etag
753
+ * - expires
754
+ * - from
755
+ * - host
756
+ * - if-modified-since
757
+ * - if-unmodified-since
758
+ * - last-modified
759
+ * - location
760
+ * - max-forwards
761
+ * - proxy-authorization
762
+ * - referer
763
+ * - retry-after
764
+ * - server
765
+ * - user-agent
766
+ *
767
+ * @template T Expected type of decoded value
768
+ * @param input Query string or URLSearchParams instance
769
+ * @returns Decoded headers object
770
+ *
771
+ * @author Jeongho Nam - https://github.com/samchon
772
+ */
773
+ export function validateHeaders<T extends object>(
774
+ input: Record<string, string | string[] | undefined>,
775
+ ): IValidation<Resolved<T>>;
776
+
777
+ /**
778
+ * @internal
779
+ */
780
+ export function validateHeaders(): never {
781
+ halt("validateHeaders");
782
+ }
783
+ Object.assign(validateHeaders, Namespace.http.headers());
784
+ Object.assign(validateHeaders, Namespace.validate());
785
+
786
+ /* -----------------------------------------------------------
787
+ PARAMETER
788
+ ----------------------------------------------------------- */
789
+ /**
790
+ * > You must configure the generic argument `T`.
791
+ *
792
+ * URL path parameter decoder.
793
+ *
794
+ * `typia.http.parameter()` is a function decoding a path parameter, with automatic
795
+ * type casting to the expected type. When type `T` has beeen defined as `boolean` or
796
+ * `number` type, `typia.http.parameter()` will cast the value to the expected type.
797
+ *
798
+ * Also, `typia.http.parameter()` performs type assertion to the decoded value by
799
+ * combining with {@link assert} function. Therefore, when the decoded value is not
800
+ * following the `T` type, {@link TypeGuardError} would be thrown.
801
+ *
802
+ * @template T Expected type of decoded value
803
+ * @param input Path parameter string
804
+ * @returns Decoded path parameter value
805
+ */
806
+ export function parameter(): never;
807
+
808
+ /**
809
+ * URL path parameter decoder.
810
+ *
811
+ * `typia.http.parameter()` is a function decoding a path parameter, with automatic
812
+ * type casting to the expected type. When type `T` has beeen defined as `boolean` or
813
+ * `number` type, `typia.http.parameter()` will cast the value to the expected type.
814
+ *
815
+ * Also, `typia.http.parameter()` performs type assertion to the decoded value by
816
+ * combining with {@link assert} function. Therefore, when the decoded value is not
817
+ * following the `T` type, {@link TypeGuardError} would be thrown.
818
+ *
819
+ * @template T Expected type of decoded value
820
+ * @param input Path parameter string
821
+ * @returns Decoded path parameter value
822
+ */
823
+ export function parameter<T extends Atomic.Type | null>(
824
+ input: string,
825
+ ): Resolved<T>;
826
+
827
+ /**
828
+ * @internal
829
+ */
830
+ export function parameter(): never {
831
+ halt("parameter");
832
+ }
833
+ Object.assign(parameter, Namespace.http.parameter());
834
+ Object.assign(parameter, Namespace.assert("http.parameter"));
835
+
836
+ /* -----------------------------------------------------------
837
+ FACTORY FUNCTIONS
838
+ ----------------------------------------------------------- */
839
+ /**
840
+ * Creates a reusable {@link query} function.
841
+ *
842
+ * @danger You must configure the generic argument `T`
843
+ * @template T The type of the query object
844
+ * @throws compile error
845
+ *
846
+ * @author Jeongho Nam - https://github.com/samchon
847
+ */
848
+ export function createQuery(): never;
849
+
850
+ /**
851
+ * Creates a reusable {@link query} function.
852
+ *
853
+ * @template T The type of the query object
854
+ * @returns A reusable `query` function
855
+ *
856
+ * @author Jeongho Nam - https://github.com/samchon
857
+ */
858
+ export function createQuery<T extends object>(): (
859
+ input: string | URLSearchParams,
860
+ ) => T;
861
+
862
+ /**
863
+ * @internal
864
+ */
865
+ export function createQuery<T>(): (input: string | URLSearchParams) => T {
866
+ halt("createQuery");
867
+ }
868
+ Object.assign(createQuery, Namespace.http.query());
869
+
870
+ /**
871
+ * Creates a reusable {@link assertQuery} function.
872
+ *
873
+ * @danger You must configure the generic argument `T`
874
+ * @template T The type of the query object
875
+ * @throws compile error
876
+ *
877
+ * @author Jeongho Nam - https://github.com/samchon
878
+ */
879
+ export function createAssertQuery(): never;
880
+
881
+ /**
882
+ * Creates a reusable {@link assertQuery} function.
883
+ *
884
+ * @template T The type of the query object
885
+ * @returns A reusable `assertQuery` function
886
+ *
887
+ * @author Jeongho Nam - https://github.com/samchon
888
+ */
889
+ export function createAssertQuery<T extends object>(): (
890
+ input: string | URLSearchParams,
891
+ ) => T;
892
+
893
+ /**
894
+ * @internal
895
+ */
896
+ export function createAssertQuery<T>(): (input: string | URLSearchParams) => T {
897
+ halt("createAssertQuery");
898
+ }
899
+ Object.assign(createAssertQuery, Namespace.http.query());
900
+ Object.assign(createAssertQuery, Namespace.assert("http.createAssertQuery"));
901
+
902
+ /**
903
+ * Creates a reusable {@link isQuery} function.
904
+ *
905
+ * @danger You must configure the generic argument `T`
906
+ * @template T The type of the query object
907
+ * @throws compile error
908
+ *
909
+ * @author Jeongho Nam - https://github.com/samchon
910
+ */
911
+ export function createIsQuery(): never;
912
+
913
+ /**
914
+ * Creates a reusable {@link isQuery} function.
915
+ *
916
+ * @template T The type of the query object
917
+ * @returns A reusable `isQuery` function
918
+ *
919
+ * @author Jeongho Nam - https://github.com/samchon
920
+ */
921
+ export function createIsQuery<T extends object>(): (
922
+ input: string | URLSearchParams,
923
+ ) => T | null;
924
+
925
+ /**
926
+ * @internal
927
+ */
928
+ export function createIsQuery<T>(): (
929
+ input: string | URLSearchParams,
930
+ ) => T | null {
931
+ halt("createIsQuery");
932
+ }
933
+ Object.assign(createIsQuery, Namespace.http.query());
934
+ Object.assign(createIsQuery, Namespace.is());
935
+
936
+ /**
937
+ * Creates a reusable {@link validateQuery} function.
938
+ *
939
+ * @danger You must configure the generic argument `T`
940
+ * @template T The type of the query object
941
+ * @throws compile error
942
+ *
943
+ * @author Jeongho Nam - https://github.com/samchon
944
+ */
945
+ export function createValidateQuery(): never;
946
+
947
+ /**
948
+ * Creates a reusable {@link validateQuery} function.
949
+ *
950
+ * @template T The type of the query object
951
+ * @returns A reusable `validateQuery` function
952
+ *
953
+ * @author Jeongho Nam - https://github.com/samchon
954
+ */
955
+ export function createValidateQuery<T extends object>(): (
956
+ input: string | URLSearchParams,
957
+ ) => IValidation<Resolved<T>>;
958
+
959
+ /**
960
+ * @internal
961
+ */
962
+ export function createValidateQuery<T>(): (
963
+ input: string | URLSearchParams,
964
+ ) => IValidation<Resolved<T>> {
965
+ halt("createValidateQuery");
966
+ }
967
+ Object.assign(createValidateQuery, Namespace.http.query());
968
+ Object.assign(createValidateQuery, Namespace.validate());
969
+
970
+ /**
971
+ * Creates a reusable {@link headers} function.
972
+ *
973
+ * @danger You must configure the generic argument `T`
974
+ * @template T The type of the headers object
975
+ * @throws compile error
976
+ *
977
+ * @author Jeongho Nam - https://github.com/samchon
978
+ */
979
+ export function createHeaders(): never;
980
+
981
+ /**
982
+ * Creates a reusable {@link headers} function.
983
+ *
984
+ * @template T The type of the headers object
985
+ * @returns A reusable `headers` function
986
+ *
987
+ * @author Jeongho Nam - https://github.com/samchon
988
+ */
989
+ export function createHeaders<T extends object>(): (
990
+ input: Record<string, string | string[] | undefined>,
991
+ ) => T;
992
+
993
+ /**
994
+ * @internal
995
+ */
996
+ export function createHeaders<T>(): (
997
+ input: Record<string, string | string[] | undefined>,
998
+ ) => T {
999
+ halt("createHeaders");
1000
+ }
1001
+ Object.assign(createHeaders, Namespace.http.headers());
1002
+
1003
+ /**
1004
+ * Creates a reusable {@link assertHeaders} function.
1005
+ *
1006
+ * @danger You must configure the generic argument `T`
1007
+ * @template T The type of the headers object
1008
+ * @throws compile error
1009
+ *
1010
+ * @author Jeongho Nam - https://github.com/samchon
1011
+ */
1012
+ export function createAssertHeaders(): never;
1013
+
1014
+ /**
1015
+ * Creates a reusable {@link assertHeaders} function.
1016
+ *
1017
+ * @template T The type of the headers object
1018
+ * @returns A reusable `assertHeaders` function
1019
+ *
1020
+ * @author Jeongho Nam - https://github.com/samchon
1021
+ */
1022
+ export function createAssertHeaders<T extends object>(): (
1023
+ input: Record<string, string | string[] | undefined>,
1024
+ ) => T;
1025
+
1026
+ /**
1027
+ * @internal
1028
+ */
1029
+ export function createAssertHeaders<T>(): (
1030
+ input: Record<string, string | string[] | undefined>,
1031
+ ) => T {
1032
+ halt("createAssertHeaders");
1033
+ }
1034
+ Object.assign(createAssertHeaders, Namespace.http.headers());
1035
+ Object.assign(
1036
+ createAssertHeaders,
1037
+ Namespace.assert("http.createAssertHeaders"),
1038
+ );
1039
+
1040
+ /**
1041
+ * Creates a reusable {@link isHeaders} function.
1042
+ *
1043
+ * @danger You must configure the generic argument `T`
1044
+ * @template T The type of the headers object
1045
+ * @throws compile error
1046
+ *
1047
+ * @author Jeongho Nam - https://github.com/samchon
1048
+ */
1049
+ export function createIsHeaders(): never;
1050
+
1051
+ /**
1052
+ * Creates a reusable {@link isHeaders} function.
1053
+ *
1054
+ * @template T The type of the headers object
1055
+ * @returns A reusable `isHeaders` function
1056
+ *
1057
+ * @author Jeongho Nam - https://github.com/samchon
1058
+ */
1059
+ export function createIsHeaders<T extends object>(): (
1060
+ input: Record<string, string | string[] | undefined>,
1061
+ ) => T | null;
1062
+
1063
+ /**
1064
+ * @internal
1065
+ */
1066
+ export function createIsHeaders<T>(): (
1067
+ input: Record<string, string | string[] | undefined>,
1068
+ ) => T | null {
1069
+ halt("createIsHeaders");
1070
+ }
1071
+ Object.assign(createIsHeaders, Namespace.http.headers());
1072
+ Object.assign(createIsHeaders, Namespace.is());
1073
+
1074
+ /**
1075
+ * Creates a reusable {@link validateHeaders} function.
1076
+ *
1077
+ * @danger You must configure the generic argument `T`
1078
+ * @template T The type of the headers object
1079
+ * @throws compile error
1080
+ *
1081
+ * @author Jeongho Nam - https://github.com/samchon
1082
+ */
1083
+ export function createValidateHeaders(): never;
1084
+
1085
+ /**
1086
+ * Creates a reusable {@link validateHeaders} function.
1087
+ *
1088
+ * @template T The type of the headers object
1089
+ * @returns A reusable `validateHeaders` function
1090
+ *
1091
+ * @author Jeongho Nam - https://github.com/samchon
1092
+ */
1093
+ export function createValidateHeaders<T extends object>(): (
1094
+ input: Record<string, string | string[] | undefined>,
1095
+ ) => IValidation<Resolved<T>>;
1096
+
1097
+ /**
1098
+ * @internal
1099
+ */
1100
+ export function createValidateHeaders<T>(): (
1101
+ input: Record<string, string | string[] | undefined>,
1102
+ ) => IValidation<Resolved<T>> {
1103
+ halt("createValidateHeaders");
1104
+ }
1105
+ Object.assign(createValidateHeaders, Namespace.http.headers());
1106
+ Object.assign(createValidateHeaders, Namespace.validate());
1107
+
1108
+ /**
1109
+ * Creates a reusable {@link parameter} function.
1110
+ *
1111
+ * @danger You must configure the generic argument `T`
1112
+ * @template T The type of the parameter value
1113
+ * @throws compile error
1114
+ *
1115
+ * @author Jeongho Nam - https://github.com/samchon
1116
+ */
1117
+ export function createParameter(): never;
1118
+
1119
+ /**
1120
+ * Creates a reusable {@link parameter} function.
1121
+ *
1122
+ * @template T The type of the parameter value
1123
+ * @returns A reusable `parameter` function
1124
+ *
1125
+ * @author Jeongho Nam - https://github.com/samchon
1126
+ */
1127
+ export function createParameter<T extends Atomic.Type | null>(): (
1128
+ input: string,
1129
+ ) => T;
1130
+
1131
+ /**
1132
+ * @internal
1133
+ */
1134
+ export function createParameter<T extends Atomic.Type | null>(): (
1135
+ input: string,
1136
+ ) => T {
1137
+ halt("createParameter");
1138
+ }
1139
+ Object.assign(createParameter, Namespace.http.parameter());
1140
+ Object.assign(createParameter, Namespace.assert("http.createParameter"));
1141
+
1142
+ /**
1143
+ * @internal
1144
+ */
1145
+ function halt(name: string): never {
1146
+ throw new Error(
1147
+ `Error on typia.http.${name}(): no transform has been configured. Read and follow https://typia.misc.io/docs/setup please.`,
1148
+ );
1149
+ }