typia 15.0.0 → 15.0.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/lib/http.d.ts +49 -24
- package/lib/http.js.map +1 -1
- package/lib/http.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadBigint.js +7 -5
- package/lib/internal/_httpFormDataReadBigint.js.map +1 -1
- package/lib/internal/_httpFormDataReadBigint.mjs +1 -1
- package/lib/internal/_httpFormDataReadBigint.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadBoolean.js +12 -10
- package/lib/internal/_httpFormDataReadBoolean.js.map +1 -1
- package/lib/internal/_httpFormDataReadBoolean.mjs +1 -1
- package/lib/internal/_httpFormDataReadBoolean.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadNumber.js +7 -5
- package/lib/internal/_httpFormDataReadNumber.js.map +1 -1
- package/lib/internal/_httpFormDataReadNumber.mjs +1 -1
- package/lib/internal/_httpFormDataReadNumber.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadString.d.ts +9 -1
- package/lib/internal/_httpFormDataReadString.js +10 -2
- package/lib/internal/_httpFormDataReadString.js.map +1 -1
- package/lib/internal/_httpFormDataReadString.mjs +9 -1
- package/lib/internal/_httpFormDataReadString.mjs.map +1 -1
- package/lib/internal/_httpHeaderReadBigint.js +5 -1
- package/lib/internal/_httpHeaderReadBigint.js.map +1 -1
- package/lib/internal/_httpHeaderReadBigint.mjs +2 -1
- package/lib/internal/_httpHeaderReadBigint.mjs.map +1 -1
- package/lib/internal/_httpHeaderReadNumber.js +5 -1
- package/lib/internal/_httpHeaderReadNumber.js.map +1 -1
- package/lib/internal/_httpHeaderReadNumber.mjs +2 -1
- package/lib/internal/_httpHeaderReadNumber.mjs.map +1 -1
- package/lib/internal/_httpParameterReadBigint.js +4 -0
- package/lib/internal/_httpParameterReadBigint.js.map +1 -1
- package/lib/internal/_httpParameterReadBigint.mjs +1 -0
- package/lib/internal/_httpParameterReadBigint.mjs.map +1 -1
- package/lib/internal/_httpParameterReadNumber.js +4 -0
- package/lib/internal/_httpParameterReadNumber.js.map +1 -1
- package/lib/internal/_httpParameterReadNumber.mjs +1 -0
- package/lib/internal/_httpParameterReadNumber.mjs.map +1 -1
- package/lib/internal/_httpParameterReadString.d.ts +9 -1
- package/lib/internal/_httpParameterReadString.js +9 -1
- package/lib/internal/_httpParameterReadString.js.map +1 -1
- package/lib/internal/_httpParameterReadString.mjs +9 -1
- package/lib/internal/_httpParameterReadString.mjs.map +1 -1
- package/lib/internal/_httpQueryReadBigint.js +8 -1
- package/lib/internal/_httpQueryReadBigint.js.map +1 -1
- package/lib/internal/_httpQueryReadBigint.mjs +1 -1
- package/lib/internal/_httpQueryReadBigint.mjs.map +1 -1
- package/lib/internal/_httpQueryReadBoolean.js +4 -1
- package/lib/internal/_httpQueryReadBoolean.js.map +1 -1
- package/lib/internal/_httpQueryReadBoolean.mjs +1 -1
- package/lib/internal/_httpQueryReadBoolean.mjs.map +1 -1
- package/lib/internal/_httpQueryReadNumber.js +8 -1
- package/lib/internal/_httpQueryReadNumber.js.map +1 -1
- package/lib/internal/_httpQueryReadNumber.mjs +1 -1
- package/lib/internal/_httpQueryReadNumber.mjs.map +1 -1
- package/lib/internal/_httpQueryReadString.d.ts +9 -1
- package/lib/internal/_httpQueryReadString.js +9 -1
- package/lib/internal/_httpQueryReadString.js.map +1 -1
- package/lib/internal/_httpQueryReadString.mjs +9 -1
- package/lib/internal/_httpQueryReadString.mjs.map +1 -1
- package/lib/internal/_randomBigint.d.ts +12 -1
- package/lib/internal/_randomBigint.js +90 -2
- package/lib/internal/_randomBigint.js.map +1 -1
- package/lib/internal/_randomBigint.mjs +70 -2
- package/lib/internal/_randomBigint.mjs.map +1 -1
- package/lib/internal/_randomInteger.js +21 -12
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_randomInteger.mjs +21 -16
- package/lib/internal/_randomInteger.mjs.map +1 -1
- package/lib/internal/_randomNumber.js +19 -10
- package/lib/internal/_randomNumber.js.map +1 -1
- package/lib/internal/_randomNumber.mjs +19 -14
- package/lib/internal/_randomNumber.mjs.map +1 -1
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_invalid_probability_test.go +9 -0
- package/native/cmd/ttsc-typia/random_recursive_min_items_diagnostic_test.go +18 -1
- package/native/core/factories/ExpressionFactory.go +16 -1
- package/native/core/factories/MetadataCommentTagFactory.go +177 -29
- package/native/core/factories/expression_factory_number_spells_non_finite_values_test.go +69 -0
- package/native/core/factories/metadata_comment_tag_factory_holds_bigint_tags_exact_test.go +168 -0
- package/native/core/factories/metadata_comment_tag_factory_reads_javascript_numbers_test.go +158 -0
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +1 -3
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +107 -9
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +1 -3
- package/native/core/programmers/http/HttpFormDataProgrammer.go +41 -2
- package/native/core/programmers/http/HttpHeadersProgrammer.go +56 -4
- package/native/core/programmers/http/HttpParameterProgrammer.go +1 -3
- package/native/core/programmers/http/HttpQueryProgrammer.go +26 -43
- package/native/core/programmers/iterate/json_schema_jsDocTags.go +10 -3
- package/native/core/programmers/iterate/json_schema_jsdoc_tags_cast_reads_javascript_numbers_test.go +64 -0
- package/native/core/programmers/llm/LlmEvaluationProgrammer.go +6 -2
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +34 -4
- package/native/core/utils/NumberUtil.go +195 -0
- package/native/core/utils/number_util_rational_keeps_written_value_test.go +62 -0
- package/native/core/utils/number_util_reads_javascript_number_grammar_test.go +147 -0
- package/package.json +3 -3
- package/src/http.ts +61 -34
- package/src/internal/_httpFormDataReadBigint.ts +3 -1
- package/src/internal/_httpFormDataReadBoolean.ts +3 -1
- package/src/internal/_httpFormDataReadNumber.ts +3 -1
- package/src/internal/_httpFormDataReadString.ts +10 -1
- package/src/internal/_httpHeaderReadBigint.ts +6 -1
- package/src/internal/_httpHeaderReadNumber.ts +6 -1
- package/src/internal/_httpParameterReadBigint.ts +3 -0
- package/src/internal/_httpParameterReadNumber.ts +3 -0
- package/src/internal/_httpParameterReadString.ts +12 -2
- package/src/internal/_httpQueryReadBigint.ts +7 -1
- package/src/internal/_httpQueryReadBoolean.ts +3 -1
- package/src/internal/_httpQueryReadNumber.ts +7 -1
- package/src/internal/_httpQueryReadString.ts +10 -1
- package/src/internal/_randomBigint.ts +111 -3
- package/src/internal/_randomInteger.ts +31 -16
- package/src/internal/_randomNumber.ts +23 -12
package/lib/http.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
4
4
|
* Decodes `FormData` into type `T`.
|
|
5
5
|
*
|
|
6
6
|
* Parses a `FormData` instance with automatic type casting. Properties typed as
|
|
7
|
-
* `boolean` or `
|
|
7
|
+
* `boolean`, `bigint`, or `number` are cast from their text, and `Blob` and
|
|
8
|
+
* `File` properties are read as given, except that the text `null` reads as
|
|
9
|
+
* `null`: as `undefined` instead for an optional single property whose type
|
|
10
|
+
* does not admit `null`, and always as `null` for an array element.
|
|
8
11
|
*
|
|
9
12
|
* Type `T` constraints:
|
|
10
13
|
*
|
|
@@ -14,6 +17,11 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
14
17
|
* types allowed
|
|
15
18
|
* 4. No union types allowed
|
|
16
19
|
*
|
|
20
|
+
* An absent key decodes a required array to `[]`, a nullable one to `null`, and
|
|
21
|
+
* an optional one to `undefined`. A string property keeps the text `null`
|
|
22
|
+
* unless its type admits `null`, and a blank numeric value decodes to
|
|
23
|
+
* `undefined`.
|
|
24
|
+
*
|
|
17
25
|
* Does not validate the decoded value. For validation, use:
|
|
18
26
|
*
|
|
19
27
|
* - {@link assertFormData} — Throws on type mismatch
|
|
@@ -112,8 +120,8 @@ export declare function validateFormData<T extends object>(input: FormData): IVa
|
|
|
112
120
|
* Decodes URL query string into type `T`.
|
|
113
121
|
*
|
|
114
122
|
* Parses a query string or `URLSearchParams` instance with automatic type
|
|
115
|
-
* casting. Properties typed as `boolean` or `number` are cast to
|
|
116
|
-
* during decoding.
|
|
123
|
+
* casting. Properties typed as `boolean`, `bigint`, or `number` are cast to
|
|
124
|
+
* expected types during decoding.
|
|
117
125
|
*
|
|
118
126
|
* Type `T` constraints:
|
|
119
127
|
*
|
|
@@ -122,6 +130,12 @@ export declare function validateFormData<T extends object>(input: FormData): IVa
|
|
|
122
130
|
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
|
|
123
131
|
* 4. No union types allowed
|
|
124
132
|
*
|
|
133
|
+
* An absent key decodes a required array to `[]`, a nullable one to `null`, and
|
|
134
|
+
* an optional one to `undefined`, since a query string has no other spelling
|
|
135
|
+
* for an empty array. An absent required non-array property throws
|
|
136
|
+
* `Error("missing <key>")`. A string property keeps the text `null` unless its
|
|
137
|
+
* type admits `null`, and a blank numeric value decodes to `undefined`.
|
|
138
|
+
*
|
|
125
139
|
* Does not validate the decoded value. For validation, use:
|
|
126
140
|
*
|
|
127
141
|
* - {@link assertQuery} — Throws on type mismatch
|
|
@@ -220,14 +234,15 @@ export declare function validateQuery<T extends object>(input: string | IReadabl
|
|
|
220
234
|
* Decodes HTTP headers into type `T`.
|
|
221
235
|
*
|
|
222
236
|
* Parses HTTP headers object with automatic type casting. Properties typed as
|
|
223
|
-
* `boolean` or `number` are cast to expected types during decoding.
|
|
224
|
-
* with Express and Fastify request headers.
|
|
237
|
+
* `boolean`, `bigint`, or `number` are cast to expected types during decoding.
|
|
238
|
+
* Compatible with Express and Fastify request headers.
|
|
225
239
|
*
|
|
226
240
|
* Type `T` constraints:
|
|
227
241
|
*
|
|
228
242
|
* 1. Must be an object type
|
|
229
243
|
* 2. No dynamic properties allowed
|
|
230
|
-
* 3. Property keys
|
|
244
|
+
* 3. Property keys are read by their lowercase name; two keys that differ only by
|
|
245
|
+
* case are not allowed
|
|
231
246
|
* 4. Property values cannot be `null` (but `undefined` is allowed)
|
|
232
247
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
|
|
233
248
|
* 6. No union types allowed
|
|
@@ -238,6 +253,10 @@ export declare function validateQuery<T extends object>(input: string | IReadabl
|
|
|
238
253
|
* `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
|
|
239
254
|
* `user-agent`
|
|
240
255
|
*
|
|
256
|
+
* An absent optional array header, or one given as an empty array, is omitted,
|
|
257
|
+
* and an absent required one decodes to `[]`. `set-cookie` values are never
|
|
258
|
+
* split. A blank numeric header decodes to `undefined`.
|
|
259
|
+
*
|
|
241
260
|
* Does not validate the decoded value. For validation, use:
|
|
242
261
|
*
|
|
243
262
|
* - {@link assertHeaders} — Throws on type mismatch
|
|
@@ -261,7 +280,8 @@ export declare function headers<T extends object>(input: Record<string, string |
|
|
|
261
280
|
*
|
|
262
281
|
* 1. Must be an object type
|
|
263
282
|
* 2. No dynamic properties allowed
|
|
264
|
-
* 3. Property keys
|
|
283
|
+
* 3. Property keys are read by their lowercase name; two keys that differ only by
|
|
284
|
+
* case are not allowed
|
|
265
285
|
* 4. Property values cannot be `null` (but `undefined` is allowed)
|
|
266
286
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
|
|
267
287
|
* 6. No union types allowed
|
|
@@ -298,7 +318,8 @@ export declare function assertHeaders<T extends object>(input: Record<string, st
|
|
|
298
318
|
*
|
|
299
319
|
* 1. Must be an object type
|
|
300
320
|
* 2. No dynamic properties allowed
|
|
301
|
-
* 3. Property keys
|
|
321
|
+
* 3. Property keys are read by their lowercase name; two keys that differ only by
|
|
322
|
+
* case are not allowed
|
|
302
323
|
* 4. Property values cannot be `null` (but `undefined` is allowed)
|
|
303
324
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
|
|
304
325
|
* 6. No union types allowed
|
|
@@ -333,7 +354,8 @@ export declare function isHeaders<T extends object>(input: Record<string, string
|
|
|
333
354
|
*
|
|
334
355
|
* 1. Must be an object type
|
|
335
356
|
* 2. No dynamic properties allowed
|
|
336
|
-
* 3. Property keys
|
|
357
|
+
* 3. Property keys are read by their lowercase name; two keys that differ only by
|
|
358
|
+
* case are not allowed
|
|
337
359
|
* 4. Property values cannot be `null` (but `undefined` is allowed)
|
|
338
360
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
|
|
339
361
|
* 6. No union types allowed
|
|
@@ -360,12 +382,15 @@ export declare function validateHeaders<T extends object>(input: Record<string,
|
|
|
360
382
|
* Decodes URL path parameter into type `T`.
|
|
361
383
|
*
|
|
362
384
|
* Parses a path parameter string with automatic type casting. When type `T` is
|
|
363
|
-
* `boolean` or `number`, casts the string value to the expected
|
|
364
|
-
* performs type assertion via {@link assert}, throwing
|
|
365
|
-
* mismatch.
|
|
385
|
+
* `boolean`, `bigint`, or `number`, casts the string value to the expected
|
|
386
|
+
* type. Also performs type assertion via {@link assert}, throwing
|
|
387
|
+
* {@link TypeGuardError} on mismatch.
|
|
388
|
+
*
|
|
389
|
+
* A blank value is not a number, and a string parameter keeps the text `null`
|
|
390
|
+
* unless `T` admits `null`.
|
|
366
391
|
*
|
|
367
|
-
* @template T Target atomic type (`boolean`, `bigint`, `number`, `string
|
|
368
|
-
* `null`
|
|
392
|
+
* @template T Target atomic type (`boolean`, `bigint`, `number`, or `string`),
|
|
393
|
+
* optionally with `null`
|
|
369
394
|
* @param input Path parameter string
|
|
370
395
|
* @returns Decoded value of type `T`
|
|
371
396
|
* @throws {TypeGuardError} When decoded value doesn't conform to type `T`
|
|
@@ -385,7 +410,7 @@ export declare function createFormData(): never;
|
|
|
385
410
|
* @template T Target object type
|
|
386
411
|
* @returns Reusable decoder function
|
|
387
412
|
*/
|
|
388
|
-
export declare function createFormData<T extends object>(): (input: FormData) => T
|
|
413
|
+
export declare function createFormData<T extends object>(): (input: FormData) => Resolved<T>;
|
|
389
414
|
/**
|
|
390
415
|
* Creates reusable {@link assertFormData} function.
|
|
391
416
|
*
|
|
@@ -403,7 +428,7 @@ export declare function createAssertFormData(errorFactory?: undefined | ((props:
|
|
|
403
428
|
* {@link TypeGuardError.IProps}
|
|
404
429
|
* @returns Reusable decoder function
|
|
405
430
|
*/
|
|
406
|
-
export declare function createAssertFormData<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: FormData, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => T
|
|
431
|
+
export declare function createAssertFormData<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: FormData, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => Resolved<T>;
|
|
407
432
|
/**
|
|
408
433
|
* Creates reusable {@link isFormData} function.
|
|
409
434
|
*
|
|
@@ -417,7 +442,7 @@ export declare function createIsFormData(): never;
|
|
|
417
442
|
* @template T Target object type
|
|
418
443
|
* @returns Reusable decoder function
|
|
419
444
|
*/
|
|
420
|
-
export declare function createIsFormData<T extends object>(): (input: FormData) => T | null;
|
|
445
|
+
export declare function createIsFormData<T extends object>(): (input: FormData) => Resolved<T> | null;
|
|
421
446
|
/**
|
|
422
447
|
* Creates reusable {@link validateFormData} function.
|
|
423
448
|
*
|
|
@@ -445,7 +470,7 @@ export declare function createQuery(): never;
|
|
|
445
470
|
* @template T Target object type
|
|
446
471
|
* @returns Reusable decoder function
|
|
447
472
|
*/
|
|
448
|
-
export declare function createQuery<T extends object>(): (input: string | IReadableURLSearchParams) => T
|
|
473
|
+
export declare function createQuery<T extends object>(): (input: string | IReadableURLSearchParams) => Resolved<T>;
|
|
449
474
|
/**
|
|
450
475
|
* Creates reusable {@link assertQuery} function.
|
|
451
476
|
*
|
|
@@ -463,7 +488,7 @@ export declare function createAssertQuery(errorFactory?: undefined | ((props: Ty
|
|
|
463
488
|
* {@link TypeGuardError.IProps}
|
|
464
489
|
* @returns Reusable decoder function
|
|
465
490
|
*/
|
|
466
|
-
export declare function createAssertQuery<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: string | IReadableURLSearchParams, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => T
|
|
491
|
+
export declare function createAssertQuery<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: string | IReadableURLSearchParams, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => Resolved<T>;
|
|
467
492
|
/**
|
|
468
493
|
* Creates reusable {@link isQuery} function.
|
|
469
494
|
*
|
|
@@ -477,7 +502,7 @@ export declare function createIsQuery(): never;
|
|
|
477
502
|
* @template T Target object type
|
|
478
503
|
* @returns Reusable decoder function
|
|
479
504
|
*/
|
|
480
|
-
export declare function createIsQuery<T extends object>(): (input: string | IReadableURLSearchParams) => T | null;
|
|
505
|
+
export declare function createIsQuery<T extends object>(): (input: string | IReadableURLSearchParams) => Resolved<T> | null;
|
|
481
506
|
/**
|
|
482
507
|
* Creates reusable {@link validateQuery} function.
|
|
483
508
|
*
|
|
@@ -505,7 +530,7 @@ export declare function createHeaders(): never;
|
|
|
505
530
|
* @template T Target object type
|
|
506
531
|
* @returns Reusable decoder function
|
|
507
532
|
*/
|
|
508
|
-
export declare function createHeaders<T extends object>(): (input: Record<string, string | string[] | undefined>) => T
|
|
533
|
+
export declare function createHeaders<T extends object>(): (input: Record<string, string | string[] | undefined>) => Resolved<T>;
|
|
509
534
|
/**
|
|
510
535
|
* Creates reusable {@link assertHeaders} function.
|
|
511
536
|
*
|
|
@@ -523,7 +548,7 @@ export declare function createAssertHeaders(errorFactory?: undefined | ((props:
|
|
|
523
548
|
* {@link TypeGuardError.IProps}
|
|
524
549
|
* @returns Reusable decoder function
|
|
525
550
|
*/
|
|
526
|
-
export declare function createAssertHeaders<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: Record<string, string | string[] | undefined>, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => T
|
|
551
|
+
export declare function createAssertHeaders<T extends object>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: Record<string, string | string[] | undefined>, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => Resolved<T>;
|
|
527
552
|
/**
|
|
528
553
|
* Creates reusable {@link isHeaders} function.
|
|
529
554
|
*
|
|
@@ -537,7 +562,7 @@ export declare function createIsHeaders(): never;
|
|
|
537
562
|
* @template T Target object type
|
|
538
563
|
* @returns Reusable decoder function
|
|
539
564
|
*/
|
|
540
|
-
export declare function createIsHeaders<T extends object>(): (input: Record<string, string | string[] | undefined>) => T | null;
|
|
565
|
+
export declare function createIsHeaders<T extends object>(): (input: Record<string, string | string[] | undefined>) => Resolved<T> | null;
|
|
541
566
|
/**
|
|
542
567
|
* Creates reusable {@link validateHeaders} function.
|
|
543
568
|
*
|
|
@@ -565,4 +590,4 @@ export declare function createParameter(): never;
|
|
|
565
590
|
* @template T Target atomic type
|
|
566
591
|
* @returns Reusable decoder function
|
|
567
592
|
*/
|
|
568
|
-
export declare function createParameter<T extends Atomic.Type | null>(): (input: string) => T
|
|
593
|
+
export declare function createParameter<T extends Atomic.Type | null>(): (input: string) => Resolved<T>;
|
package/lib/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,gGAA6F;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,gGAA6F;AA+C7F,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,eAAe,CAAC,CAAC;AACjD,CAAC;AAmCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,qBAAqB,CAAC,CAAC;AACvD,CAAC;AA+BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,iBAAiB,CAAC,CAAC;AACnD,CAAC;AAgCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAwCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,YAAY,CAAC,CAAC;AAC9C,CAAC;AAmCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AA+BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AAgCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AA+CD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA4CD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAwCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAyCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AA2BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAuBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,qBAAqB,CAAC,CAAC;AACvD,CAAC;AA6BD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,2BAA2B,CAAC,CAAC;AAC7D,CAAC;AAoBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,6BAA6B,CAAC,CAAC;AAC/D,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AA6BD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,0BAA0B,CAAC,CAAC;AAC5D,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AA6BD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,0BAA0B,CAAC,CAAC;AAC5D,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,4BAA4B,CAAC,CAAC;AAC9D,CAAC;AAoBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC"}
|
package/lib/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.mjs","names":[],"sources":["../src/http.ts"],"sourcesContent":["import {\n Atomic,\n IReadableURLSearchParams,\n IValidation,\n Resolved,\n} from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* ===========================================================\n HTTP\n - FORM-DATA\n - QUERY\n - HEADERS\n - PARAMETER\n - FACTORY FUNCTIONS\n==============================================================\n FORM-DATA\n----------------------------------------------------------- */\n/**\n * Decodes `FormData` into type `T`.\n *\n * Parses a `FormData` instance with automatic type casting. Properties typed as\n * `boolean` or `Blob` are cast to expected types during decoding.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertFormData} — Throws on type mismatch\n * - {@link isFormData} — Returns `null` on type mismatch\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function formData<T extends object>(input: FormData): Resolved<T>;\n\n/** @internal */\nexport function formData(): never {\n NoTransformConfigurationError(\"http.formData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with assertion.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link isFormData} — Returns `null` instead of throwing\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertFormData<T extends object>(\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertFormData(): never {\n NoTransformConfigurationError(\"http.assertFormData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with type checking.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link is}. Returns `null` on type mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link assertFormData} — Throws instead of returning `null`\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isFormData<T extends object>(\n input: FormData,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isFormData(): never {\n NoTransformConfigurationError(\"http.isFormData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with validation.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link validate}. Returns {@link IValidation.IFailure} with all\n * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link assertFormData} — Throws on first error\n * - {@link isFormData} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateFormData<T extends object>(\n input: FormData,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateFormData(): never {\n NoTransformConfigurationError(\"http.validateFormData\");\n}\n\n/* -----------------------------------------------------------\n QUERY\n----------------------------------------------------------- */\n/**\n * Decodes URL query string into type `T`.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting. Properties typed as `boolean` or `number` are cast to expected types\n * during decoding.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertQuery} — Throws on type mismatch\n * - {@link isQuery} — Returns `null` on type mismatch\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function query<T extends object>(\n input: string | IReadableURLSearchParams,\n): Resolved<T>;\n\n/** @internal */\nexport function query(): never {\n NoTransformConfigurationError(\"http.query\");\n}\n\n/**\n * Decodes URL query string into type `T` with assertion.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link assert}. Throws\n * {@link TypeGuardError} on mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link isQuery} — Returns `null` instead of throwing\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertQuery(): never {\n NoTransformConfigurationError(\"http.assertQuery\");\n}\n\n/**\n * Decodes URL query string into type `T` with type checking.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link is}. Returns `null` on type\n * mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link assertQuery} — Throws instead of returning `null`\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isQuery(): never {\n NoTransformConfigurationError(\"http.isQuery\");\n}\n\n/**\n * Decodes URL query string into type `T` with validation.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link validate}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with decoded value.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link assertQuery} — Throws on first error\n * - {@link isQuery} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateQuery(): never {\n NoTransformConfigurationError(\"http.validateQuery\");\n}\n\n/* -----------------------------------------------------------\n HEADERS\n----------------------------------------------------------- */\n/**\n * Decodes HTTP headers into type `T`.\n *\n * Parses HTTP headers object with automatic type casting. Properties typed as\n * `boolean` or `number` are cast to expected types during decoding. Compatible\n * with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys must be lowercase\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertHeaders} — Throws on type mismatch\n * - {@link isHeaders} — Returns `null` on type mismatch\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function headers<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): Resolved<T>;\n\n/** @internal */\nexport function headers(): never {\n NoTransformConfigurationError(\"http.headers\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with assertion.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.\n * Compatible with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys must be lowercase\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link isHeaders} — Returns `null` instead of throwing\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertHeaders(): never {\n NoTransformConfigurationError(\"http.assertHeaders\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with type checking.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link is}. Returns `null` on type mismatch. Compatible with\n * Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys must be lowercase\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link assertHeaders} — Throws instead of returning `null`\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isHeaders(): never {\n NoTransformConfigurationError(\"http.isHeaders\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with validation.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link validate}. Returns {@link IValidation.IFailure} with all\n * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.\n * Compatible with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys must be lowercase\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link assertHeaders} — Throws on first error\n * - {@link isHeaders} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateHeaders(): never {\n NoTransformConfigurationError(\"http.validateHeaders\");\n}\n\n/* -----------------------------------------------------------\n PARAMETER\n----------------------------------------------------------- */\n/**\n * Decodes URL path parameter into type `T`.\n *\n * Parses a path parameter string with automatic type casting. When type `T` is\n * `boolean` or `number`, casts the string value to the expected type. Also\n * performs type assertion via {@link assert}, throwing {@link TypeGuardError} on\n * mismatch.\n *\n * @template T Target atomic type (`boolean`, `bigint`, `number`, `string`, or\n * `null`)\n * @param input Path parameter string\n * @returns Decoded value of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function parameter<T extends Atomic.Type | null>(\n input: string,\n): Resolved<T>;\n\n/** @internal */\nexport function parameter(): never {\n NoTransformConfigurationError(\"http.parameter\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link formData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createFormData(): never;\n\n/**\n * Creates reusable {@link formData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createFormData<T extends object>(): (input: FormData) => T;\n\n/** @internal */\nexport function createFormData<T>(): (input: FormData) => T {\n NoTransformConfigurationError(\"http.createFormData\");\n}\n\n/**\n * Creates reusable {@link assertFormData} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertFormData(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertFormData} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertFormData<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssertFormData<T>(): (\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"http.createAssertFormData\");\n}\n\n/**\n * Creates reusable {@link isFormData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsFormData(): never;\n\n/**\n * Creates reusable {@link isFormData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsFormData<T extends object>(): (\n input: FormData,\n) => T | null;\n\n/** @internal */\nexport function createIsFormData<T>(): (input: FormData) => T | null {\n NoTransformConfigurationError(\"http.createIsFormData\");\n}\n\n/**\n * Creates reusable {@link validateFormData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateFormData(): never;\n\n/**\n * Creates reusable {@link validateFormData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateFormData<T extends object>(): (\n input: FormData,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateFormData<T>(): (\n input: FormData,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateFormData\");\n}\n\n/**\n * Creates reusable {@link query} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createQuery(): never;\n\n/**\n * Creates reusable {@link query} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => T;\n\n/** @internal */\nexport function createQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => T {\n NoTransformConfigurationError(\"http.createQuery\");\n}\n\n/**\n * Creates reusable {@link assertQuery} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertQuery(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertQuery} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertQuery<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssertQuery<T>(): (\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"http.createAssertQuery\");\n}\n\n/**\n * Creates reusable {@link isQuery} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsQuery(): never;\n\n/**\n * Creates reusable {@link isQuery} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => T | null;\n\n/** @internal */\nexport function createIsQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => T | null {\n NoTransformConfigurationError(\"http.createIsQuery\");\n}\n\n/**\n * Creates reusable {@link validateQuery} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateQuery(): never;\n\n/**\n * Creates reusable {@link validateQuery} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateQuery\");\n}\n\n/**\n * Creates reusable {@link headers} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createHeaders(): never;\n\n/**\n * Creates reusable {@link headers} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => T;\n\n/** @internal */\nexport function createHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => T {\n NoTransformConfigurationError(\"http.createHeaders\");\n}\n\n/**\n * Creates reusable {@link assertHeaders} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertHeaders(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertHeaders} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertHeaders<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssertHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"http.createAssertHeaders\");\n}\n\n/**\n * Creates reusable {@link isHeaders} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsHeaders(): never;\n\n/**\n * Creates reusable {@link isHeaders} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => T | null;\n\n/** @internal */\nexport function createIsHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => T | null {\n NoTransformConfigurationError(\"http.createIsHeaders\");\n}\n\n/**\n * Creates reusable {@link validateHeaders} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateHeaders(): never;\n\n/**\n * Creates reusable {@link validateHeaders} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateHeaders\");\n}\n\n/**\n * Creates reusable {@link parameter} function.\n *\n * @template T Target atomic type\n * @danger You must configure the generic argument `T`\n */\nexport function createParameter(): never;\n\n/**\n * Creates reusable {@link parameter} function.\n *\n * @template T Target atomic type\n * @returns Reusable decoder function\n */\nexport function createParameter<T extends Atomic.Type | null>(): (\n input: string,\n) => T;\n\n/** @internal */\nexport function createParameter<T extends Atomic.Type | null>(): (\n input: string,\n) => T {\n NoTransformConfigurationError(\"http.createParameter\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,WAAkB;CAChC,8BAA8B,eAAe;AAC/C;;AAoCA,SAAgB,iBAAwB;CACtC,8BAA8B,qBAAqB;AACrD;;AAgCA,SAAgB,aAAoB;CAClC,8BAA8B,iBAAiB;AACjD;;AAiCA,SAAgB,mBAA0B;CACxC,8BAA8B,uBAAuB;AACvD;;AAmCA,SAAgB,QAAe;CAC7B,8BAA8B,YAAY;AAC5C;;AAoCA,SAAgB,cAAqB;CACnC,8BAA8B,kBAAkB;AAClD;;AAgCA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AAiCA,SAAgB,gBAAuB;CACrC,8BAA8B,oBAAoB;AACpD;;AA2CA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AA4CA,SAAgB,gBAAuB;CACrC,8BAA8B,oBAAoB;AACpD;;AAwCA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AAyCA,SAAgB,kBAAyB;CACvC,8BAA8B,sBAAsB;AACtD;;AAyBA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AAsBA,SAAgB,iBAA4C;CAC1D,8BAA8B,qBAAqB;AACrD;;AA8BA,SAAgB,uBAGT;CACL,8BAA8B,2BAA2B;AAC3D;;AAqBA,SAAgB,mBAAqD;CACnE,8BAA8B,uBAAuB;AACvD;;AAqBA,SAAgB,yBAEc;CAC5B,8BAA8B,6BAA6B;AAC7D;;AAqBA,SAAgB,cAET;CACL,8BAA8B,kBAAkB;AAClD;;AA8BA,SAAgB,oBAGT;CACL,8BAA8B,wBAAwB;AACxD;;AAqBA,SAAgB,gBAEF;CACZ,8BAA8B,oBAAoB;AACpD;;AAqBA,SAAgB,sBAEc;CAC5B,8BAA8B,0BAA0B;AAC1D;;AAqBA,SAAgB,gBAET;CACL,8BAA8B,oBAAoB;AACpD;;AA8BA,SAAgB,sBAGT;CACL,8BAA8B,0BAA0B;AAC1D;;AAqBA,SAAgB,kBAEF;CACZ,8BAA8B,sBAAsB;AACtD;;AAqBA,SAAgB,wBAEc;CAC5B,8BAA8B,4BAA4B;AAC5D;;AAqBA,SAAgB,kBAET;CACL,8BAA8B,sBAAsB;AACtD"}
|
|
1
|
+
{"version":3,"file":"http.mjs","names":[],"sources":["../src/http.ts"],"sourcesContent":["import {\n Atomic,\n IReadableURLSearchParams,\n IValidation,\n Resolved,\n} from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* ===========================================================\n HTTP\n - FORM-DATA\n - QUERY\n - HEADERS\n - PARAMETER\n - FACTORY FUNCTIONS\n==============================================================\n FORM-DATA\n----------------------------------------------------------- */\n/**\n * Decodes `FormData` into type `T`.\n *\n * Parses a `FormData` instance with automatic type casting. Properties typed as\n * `boolean`, `bigint`, or `number` are cast from their text, and `Blob` and\n * `File` properties are read as given, except that the text `null` reads as\n * `null`: as `undefined` instead for an optional single property whose type\n * does not admit `null`, and always as `null` for an array element.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * An absent key decodes a required array to `[]`, a nullable one to `null`, and\n * an optional one to `undefined`. A string property keeps the text `null`\n * unless its type admits `null`, and a blank numeric value decodes to\n * `undefined`.\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertFormData} — Throws on type mismatch\n * - {@link isFormData} — Returns `null` on type mismatch\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function formData<T extends object>(input: FormData): Resolved<T>;\n\n/** @internal */\nexport function formData(): never {\n NoTransformConfigurationError(\"http.formData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with assertion.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link isFormData} — Returns `null` instead of throwing\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertFormData<T extends object>(\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertFormData(): never {\n NoTransformConfigurationError(\"http.assertFormData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with type checking.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link is}. Returns `null` on type mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link assertFormData} — Throws instead of returning `null`\n * - {@link validateFormData} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isFormData<T extends object>(\n input: FormData,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isFormData(): never {\n NoTransformConfigurationError(\"http.isFormData\");\n}\n\n/**\n * Decodes `FormData` into type `T` with validation.\n *\n * Parses a `FormData` instance with automatic type casting, then validates the\n * result via {@link validate}. Returns {@link IValidation.IFailure} with all\n * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array\n * types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link formData} — No validation\n * - {@link assertFormData} — Throws on first error\n * - {@link isFormData} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input FormData instance to decode\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateFormData<T extends object>(\n input: FormData,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateFormData(): never {\n NoTransformConfigurationError(\"http.validateFormData\");\n}\n\n/* -----------------------------------------------------------\n QUERY\n----------------------------------------------------------- */\n/**\n * Decodes URL query string into type `T`.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting. Properties typed as `boolean`, `bigint`, or `number` are cast to\n * expected types during decoding.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * An absent key decodes a required array to `[]`, a nullable one to `null`, and\n * an optional one to `undefined`, since a query string has no other spelling\n * for an empty array. An absent required non-array property throws\n * `Error(\"missing <key>\")`. A string property keeps the text `null` unless its\n * type admits `null`, and a blank numeric value decodes to `undefined`.\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertQuery} — Throws on type mismatch\n * - {@link isQuery} — Returns `null` on type mismatch\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function query<T extends object>(\n input: string | IReadableURLSearchParams,\n): Resolved<T>;\n\n/** @internal */\nexport function query(): never {\n NoTransformConfigurationError(\"http.query\");\n}\n\n/**\n * Decodes URL query string into type `T` with assertion.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link assert}. Throws\n * {@link TypeGuardError} on mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link isQuery} — Returns `null` instead of throwing\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertQuery(): never {\n NoTransformConfigurationError(\"http.assertQuery\");\n}\n\n/**\n * Decodes URL query string into type `T` with type checking.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link is}. Returns `null` on type\n * mismatch.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link assertQuery} — Throws instead of returning `null`\n * - {@link validateQuery} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isQuery(): never {\n NoTransformConfigurationError(\"http.isQuery\");\n}\n\n/**\n * Decodes URL query string into type `T` with validation.\n *\n * Parses a query string or `URLSearchParams` instance with automatic type\n * casting, then validates the result via {@link validate}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with decoded value.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 4. No union types allowed\n *\n * Related functions:\n *\n * - {@link query} — No validation\n * - {@link assertQuery} — Throws on first error\n * - {@link isQuery} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input Query string or URLSearchParams instance\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateQuery<T extends object>(\n input: string | IReadableURLSearchParams,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateQuery(): never {\n NoTransformConfigurationError(\"http.validateQuery\");\n}\n\n/* -----------------------------------------------------------\n HEADERS\n----------------------------------------------------------- */\n/**\n * Decodes HTTP headers into type `T`.\n *\n * Parses HTTP headers object with automatic type casting. Properties typed as\n * `boolean`, `bigint`, or `number` are cast to expected types during decoding.\n * Compatible with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys are read by their lowercase name; two keys that differ only by\n * case are not allowed\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * An absent optional array header, or one given as an empty array, is omitted,\n * and an absent required one decodes to `[]`. `set-cookie` values are never\n * split. A blank numeric header decodes to `undefined`.\n *\n * Does not validate the decoded value. For validation, use:\n *\n * - {@link assertHeaders} — Throws on type mismatch\n * - {@link isHeaders} — Returns `null` on type mismatch\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Decoded object of type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function headers<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): Resolved<T>;\n\n/** @internal */\nexport function headers(): never {\n NoTransformConfigurationError(\"http.headers\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with assertion.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.\n * Compatible with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys are read by their lowercase name; two keys that differ only by\n * case are not allowed\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link isHeaders} — Returns `null` instead of throwing\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Decoded object of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function assertHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Resolved<T>;\n\n/** @internal */\nexport function assertHeaders(): never {\n NoTransformConfigurationError(\"http.assertHeaders\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with type checking.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link is}. Returns `null` on type mismatch. Compatible with\n * Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys are read by their lowercase name; two keys that differ only by\n * case are not allowed\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link assertHeaders} — Throws instead of returning `null`\n * - {@link validateHeaders} — Returns detailed validation errors\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Decoded object of type `T`, or `null` if invalid\n * @danger You must configure the generic argument `T`\n */\nexport function isHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): Resolved<T> | null;\n\n/** @internal */\nexport function isHeaders(): never {\n NoTransformConfigurationError(\"http.isHeaders\");\n}\n\n/**\n * Decodes HTTP headers into type `T` with validation.\n *\n * Parses HTTP headers object with automatic type casting, then validates the\n * result via {@link validate}. Returns {@link IValidation.IFailure} with all\n * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.\n * Compatible with Express and Fastify request headers.\n *\n * Type `T` constraints:\n *\n * 1. Must be an object type\n * 2. No dynamic properties allowed\n * 3. Property keys are read by their lowercase name; two keys that differ only by\n * case are not allowed\n * 4. Property values cannot be `null` (but `undefined` is allowed)\n * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed\n * 6. No union types allowed\n * 7. Property `set-cookie` must be array type\n * 8. These properties cannot be array type: `age`, `authorization`,\n * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,\n * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,\n * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,\n * `user-agent`\n *\n * Related functions:\n *\n * - {@link headers} — No validation\n * - {@link assertHeaders} — Throws on first error\n * - {@link isHeaders} — Returns `null` instead of error details\n *\n * @template T Target object type\n * @param input Headers object from HTTP request\n * @returns Validation result containing decoded value or errors\n * @danger You must configure the generic argument `T`\n */\nexport function validateHeaders<T extends object>(\n input: Record<string, string | string[] | undefined>,\n): IValidation<Resolved<T>>;\n\n/** @internal */\nexport function validateHeaders(): never {\n NoTransformConfigurationError(\"http.validateHeaders\");\n}\n\n/* -----------------------------------------------------------\n PARAMETER\n----------------------------------------------------------- */\n/**\n * Decodes URL path parameter into type `T`.\n *\n * Parses a path parameter string with automatic type casting. When type `T` is\n * `boolean`, `bigint`, or `number`, casts the string value to the expected\n * type. Also performs type assertion via {@link assert}, throwing\n * {@link TypeGuardError} on mismatch.\n *\n * A blank value is not a number, and a string parameter keeps the text `null`\n * unless `T` admits `null`.\n *\n * @template T Target atomic type (`boolean`, `bigint`, `number`, or `string`),\n * optionally with `null`\n * @param input Path parameter string\n * @returns Decoded value of type `T`\n * @throws {TypeGuardError} When decoded value doesn't conform to type `T`\n * @danger You must configure the generic argument `T`\n */\nexport function parameter<T extends Atomic.Type | null>(\n input: string,\n): Resolved<T>;\n\n/** @internal */\nexport function parameter(): never {\n NoTransformConfigurationError(\"http.parameter\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link formData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createFormData(): never;\n\n/**\n * Creates reusable {@link formData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createFormData<T extends object>(): (\n input: FormData,\n) => Resolved<T>;\n\n/** @internal */\nexport function createFormData<T>(): (input: FormData) => Resolved<T> {\n NoTransformConfigurationError(\"http.createFormData\");\n}\n\n/**\n * Creates reusable {@link assertFormData} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertFormData(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertFormData} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertFormData<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T>;\n\n/** @internal */\nexport function createAssertFormData<T>(): (\n input: FormData,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createAssertFormData\");\n}\n\n/**\n * Creates reusable {@link isFormData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsFormData(): never;\n\n/**\n * Creates reusable {@link isFormData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsFormData<T extends object>(): (\n input: FormData,\n) => Resolved<T> | null;\n\n/** @internal */\nexport function createIsFormData<T>(): (input: FormData) => Resolved<T> | null {\n NoTransformConfigurationError(\"http.createIsFormData\");\n}\n\n/**\n * Creates reusable {@link validateFormData} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateFormData(): never;\n\n/**\n * Creates reusable {@link validateFormData} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateFormData<T extends object>(): (\n input: FormData,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateFormData<T>(): (\n input: FormData,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateFormData\");\n}\n\n/**\n * Creates reusable {@link query} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createQuery(): never;\n\n/**\n * Creates reusable {@link query} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => Resolved<T>;\n\n/** @internal */\nexport function createQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createQuery\");\n}\n\n/**\n * Creates reusable {@link assertQuery} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertQuery(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertQuery} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertQuery<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T>;\n\n/** @internal */\nexport function createAssertQuery<T>(): (\n input: string | IReadableURLSearchParams,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createAssertQuery\");\n}\n\n/**\n * Creates reusable {@link isQuery} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsQuery(): never;\n\n/**\n * Creates reusable {@link isQuery} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => Resolved<T> | null;\n\n/** @internal */\nexport function createIsQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => Resolved<T> | null {\n NoTransformConfigurationError(\"http.createIsQuery\");\n}\n\n/**\n * Creates reusable {@link validateQuery} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateQuery(): never;\n\n/**\n * Creates reusable {@link validateQuery} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateQuery<T extends object>(): (\n input: string | IReadableURLSearchParams,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateQuery<T>(): (\n input: string | IReadableURLSearchParams,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateQuery\");\n}\n\n/**\n * Creates reusable {@link headers} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createHeaders(): never;\n\n/**\n * Creates reusable {@link headers} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => Resolved<T>;\n\n/** @internal */\nexport function createHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createHeaders\");\n}\n\n/**\n * Creates reusable {@link assertHeaders} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertHeaders(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertHeaders} function.\n *\n * @template T Target object type\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable decoder function\n */\nexport function createAssertHeaders<T extends object>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T>;\n\n/** @internal */\nexport function createAssertHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createAssertHeaders\");\n}\n\n/**\n * Creates reusable {@link isHeaders} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createIsHeaders(): never;\n\n/**\n * Creates reusable {@link isHeaders} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createIsHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => Resolved<T> | null;\n\n/** @internal */\nexport function createIsHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => Resolved<T> | null {\n NoTransformConfigurationError(\"http.createIsHeaders\");\n}\n\n/**\n * Creates reusable {@link validateHeaders} function.\n *\n * @template T Target object type\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateHeaders(): never;\n\n/**\n * Creates reusable {@link validateHeaders} function.\n *\n * @template T Target object type\n * @returns Reusable decoder function\n */\nexport function createValidateHeaders<T extends object>(): (\n input: Record<string, string | string[] | undefined>,\n) => IValidation<Resolved<T>>;\n\n/** @internal */\nexport function createValidateHeaders<T>(): (\n input: Record<string, string | string[] | undefined>,\n) => IValidation<Resolved<T>> {\n NoTransformConfigurationError(\"http.createValidateHeaders\");\n}\n\n/**\n * Creates reusable {@link parameter} function.\n *\n * @template T Target atomic type\n * @danger You must configure the generic argument `T`\n */\nexport function createParameter(): never;\n\n/**\n * Creates reusable {@link parameter} function.\n *\n * @template T Target atomic type\n * @returns Reusable decoder function\n */\nexport function createParameter<T extends Atomic.Type | null>(): (\n input: string,\n) => Resolved<T>;\n\n/** @internal */\nexport function createParameter<T extends Atomic.Type | null>(): (\n input: string,\n) => Resolved<T> {\n NoTransformConfigurationError(\"http.createParameter\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,WAAkB;CAChC,8BAA8B,eAAe;AAC/C;;AAoCA,SAAgB,iBAAwB;CACtC,8BAA8B,qBAAqB;AACrD;;AAgCA,SAAgB,aAAoB;CAClC,8BAA8B,iBAAiB;AACjD;;AAiCA,SAAgB,mBAA0B;CACxC,8BAA8B,uBAAuB;AACvD;;AAyCA,SAAgB,QAAe;CAC7B,8BAA8B,YAAY;AAC5C;;AAoCA,SAAgB,cAAqB;CACnC,8BAA8B,kBAAkB;AAClD;;AAgCA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AAiCA,SAAgB,gBAAuB;CACrC,8BAA8B,oBAAoB;AACpD;;AAgDA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AA6CA,SAAgB,gBAAuB;CACrC,8BAA8B,oBAAoB;AACpD;;AAyCA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AA0CA,SAAgB,kBAAyB;CACvC,8BAA8B,sBAAsB;AACtD;;AA4BA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AAwBA,SAAgB,iBAAsD;CACpE,8BAA8B,qBAAqB;AACrD;;AA8BA,SAAgB,uBAGC;CACf,8BAA8B,2BAA2B;AAC3D;;AAqBA,SAAgB,mBAA+D;CAC7E,8BAA8B,uBAAuB;AACvD;;AAqBA,SAAgB,yBAEc;CAC5B,8BAA8B,6BAA6B;AAC7D;;AAqBA,SAAgB,cAEC;CACf,8BAA8B,kBAAkB;AAClD;;AA8BA,SAAgB,oBAGC;CACf,8BAA8B,wBAAwB;AACxD;;AAqBA,SAAgB,gBAEQ;CACtB,8BAA8B,oBAAoB;AACpD;;AAqBA,SAAgB,sBAEc;CAC5B,8BAA8B,0BAA0B;AAC1D;;AAqBA,SAAgB,gBAEC;CACf,8BAA8B,oBAAoB;AACpD;;AA8BA,SAAgB,sBAGC;CACf,8BAA8B,0BAA0B;AAC1D;;AAqBA,SAAgB,kBAEQ;CACtB,8BAA8B,sBAAsB;AACtD;;AAqBA,SAAgB,wBAEc;CAC5B,8BAA8B,4BAA4B;AAC5D;;AAqBA,SAAgB,kBAEC;CACf,8BAA8B,sBAAsB;AACtD"}
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._httpFormDataReadBigint = void 0;
|
|
4
4
|
const _httpFormDataReadBigint = (input) => input instanceof File
|
|
5
5
|
? input
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
: // Blank text is absent, as the empty string always was: `BigInt(" ")`
|
|
7
|
+
// is 0n, which would read a whitespace value as a real zero (#2448).
|
|
8
|
+
typeof input === "string" && input.trim().length !== 0
|
|
9
|
+
? input === "null"
|
|
10
|
+
? null
|
|
11
|
+
: toBigint(input)
|
|
12
|
+
: undefined;
|
|
11
13
|
exports._httpFormDataReadBigint = _httpFormDataReadBigint;
|
|
12
14
|
const toBigint = (str) => {
|
|
13
15
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadBigint.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadBigint.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CACrC,KAA2B,EACA,EAAE,CAC7B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadBigint.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadBigint.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CACrC,KAA2B,EACA,EAAE,CAC7B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,sEAAsE;QACtE,qEAAqE;QACrE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YACtD,CAAC,CAAC,KAAK,KAAK,MAAM;gBAChB,CAAC,CAAC,IAAI;gBACN,CAAC,CAAE,QAAQ,CAAC,KAAK,CAAS;YAC5B,CAAC,CAAC,SAAS,CAAC;AAXL,QAAA,uBAAuB,GAAvB,uBAAuB,CAWlB;AAElB,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;eAAO,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/internal/_httpFormDataReadBigint.ts
|
|
2
|
-
const _httpFormDataReadBigint = (input) => input instanceof File ? input :
|
|
2
|
+
const _httpFormDataReadBigint = (input) => input instanceof File ? input : typeof input === "string" && input.trim().length !== 0 ? input === "null" ? null : toBigint(input) : void 0;
|
|
3
3
|
const toBigint = (str) => {
|
|
4
4
|
try {
|
|
5
5
|
return BigInt(str);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadBigint.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadBigint.ts"],"sourcesContent":["export const _httpFormDataReadBigint = (\n input: string | File | null,\n): bigint | null | undefined =>\n input instanceof File\n ? (input as any)\n :
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadBigint.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadBigint.ts"],"sourcesContent":["export const _httpFormDataReadBigint = (\n input: string | File | null,\n): bigint | null | undefined =>\n input instanceof File\n ? (input as any)\n : // Blank text is absent, as the empty string always was: `BigInt(\" \")`\n // is 0n, which would read a whitespace value as a real zero (#2448).\n typeof input === \"string\" && input.trim().length !== 0\n ? input === \"null\"\n ? null\n : (toBigint(input) as any)\n : undefined;\n\nconst toBigint = (str: string): bigint | string => {\n try {\n return BigInt(str);\n } catch {\n return str;\n }\n};\n"],"mappings":";AAAA,MAAa,2BACX,UAEA,iBAAiB,OACZ,QAGD,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,WAAW,IACnD,UAAU,SACR,OACC,SAAS,KAAK,IACjB,KAAA;AAER,MAAM,YAAY,QAAiC;CACjD,IAAI;EACF,OAAO,OAAO,GAAG;CACnB,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -3,16 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._httpFormDataReadBoolean = void 0;
|
|
4
4
|
const _httpFormDataReadBoolean = (input) => input instanceof File
|
|
5
5
|
? input
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
?
|
|
10
|
-
: input
|
|
11
|
-
?
|
|
12
|
-
: input ===
|
|
6
|
+
: // `undefined` is as absent as `null`, which `FormData.get` returns; a
|
|
7
|
+
// stand-in that answers `undefined` must not throw on `.length`.
|
|
8
|
+
input === null || input === undefined
|
|
9
|
+
? undefined
|
|
10
|
+
: input === "null"
|
|
11
|
+
? null
|
|
12
|
+
: input.length === 0
|
|
13
13
|
? true
|
|
14
|
-
: input === "
|
|
15
|
-
?
|
|
16
|
-
: input
|
|
14
|
+
: input === "true" || input === "1"
|
|
15
|
+
? true
|
|
16
|
+
: input === "false" || input === "0"
|
|
17
|
+
? false
|
|
18
|
+
: input; // wrong type
|
|
17
19
|
exports._httpFormDataReadBoolean = _httpFormDataReadBoolean;
|
|
18
20
|
//# sourceMappingURL=_httpFormDataReadBoolean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadBoolean.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadBoolean.ts"],"names":[],"mappings":";;;AAAO,MAAM,wBAAwB,GAAG,CACtC,KAA2B,EACC,EAAE,CAC9B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,KAAK,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadBoolean.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadBoolean.ts"],"names":[],"mappings":";;;AAAO,MAAM,wBAAwB,GAAG,CACtC,KAA2B,EACC,EAAE,CAC9B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,sEAAsE;QACtE,iEAAiE;QACjE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YACrC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,KAAK,MAAM;gBAChB,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;oBAClB,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG;wBACjC,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG;4BAClC,CAAC,CAAC,KAAK;4BACP,CAAC,CAAE,KAAa,CAAC,CAAC,aAAa;AAjBhC,QAAA,wBAAwB,GAAxB,wBAAwB,CAiBN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/internal/_httpFormDataReadBoolean.ts
|
|
2
|
-
const _httpFormDataReadBoolean = (input) => input instanceof File ? input : input === null ? void 0 : input === "null" ? null : input.length === 0 ? true : input === "true" || input === "1" ? true : input === "false" || input === "0" ? false : input;
|
|
2
|
+
const _httpFormDataReadBoolean = (input) => input instanceof File ? input : input === null || input === void 0 ? void 0 : input === "null" ? null : input.length === 0 ? true : input === "true" || input === "1" ? true : input === "false" || input === "0" ? false : input;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { _httpFormDataReadBoolean };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadBoolean.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadBoolean.ts"],"sourcesContent":["export const _httpFormDataReadBoolean = (\n input: string | File | null,\n): boolean | null | undefined =>\n input instanceof File\n ? (input as any)\n : input === null\n ? undefined\n : input === \"null\"\n ? null\n : input.length === 0\n ? true\n : input === \"true\" || input === \"1\"\n ? true\n : input === \"false\" || input === \"0\"\n ? false\n : (input as any); // wrong type\n"],"mappings":";AAAA,MAAa,4BACX,UAEA,iBAAiB,OACZ,
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadBoolean.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadBoolean.ts"],"sourcesContent":["export const _httpFormDataReadBoolean = (\n input: string | File | null,\n): boolean | null | undefined =>\n input instanceof File\n ? (input as any)\n : // `undefined` is as absent as `null`, which `FormData.get` returns; a\n // stand-in that answers `undefined` must not throw on `.length`.\n input === null || input === undefined\n ? undefined\n : input === \"null\"\n ? null\n : input.length === 0\n ? true\n : input === \"true\" || input === \"1\"\n ? true\n : input === \"false\" || input === \"0\"\n ? false\n : (input as any); // wrong type\n"],"mappings":";AAAA,MAAa,4BACX,UAEA,iBAAiB,OACZ,QAGD,UAAU,QAAQ,UAAU,KAAA,IAC1B,KAAA,IACA,UAAU,SACR,OACA,MAAM,WAAW,IACf,OACA,UAAU,UAAU,UAAU,MAC5B,OACA,UAAU,WAAW,UAAU,MAC7B,QACC"}
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._httpFormDataReadNumber = void 0;
|
|
4
4
|
const _httpFormDataReadNumber = (input) => input instanceof File
|
|
5
5
|
? input
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
: // Blank text is absent, as the empty string always was: `Number(" ")`
|
|
7
|
+
// is 0, which would read a whitespace value as a real zero (#2448).
|
|
8
|
+
typeof input === "string" && input.trim().length !== 0
|
|
9
|
+
? input === "null"
|
|
10
|
+
? null
|
|
11
|
+
: toNumber(input)
|
|
12
|
+
: undefined;
|
|
11
13
|
exports._httpFormDataReadNumber = _httpFormDataReadNumber;
|
|
12
14
|
const toNumber = (str) => {
|
|
13
15
|
const value = Number(str);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadNumber.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadNumber.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CACrC,KAA2B,EACA,EAAE,CAC7B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadNumber.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadNumber.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CACrC,KAA2B,EACA,EAAE,CAC7B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,sEAAsE;QACtE,oEAAoE;QACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YACtD,CAAC,CAAC,KAAK,KAAK,MAAM;gBAChB,CAAC,CAAC,IAAI;gBACN,CAAC,CAAE,QAAQ,CAAC,KAAK,CAAS;YAC5B,CAAC,CAAC,SAAS,CAAC;AAXL,QAAA,uBAAuB,GAAvB,uBAAuB,CAWlB;AAElB,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChD,MAAM,KAAK,GAAW,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/internal/_httpFormDataReadNumber.ts
|
|
2
|
-
const _httpFormDataReadNumber = (input) => input instanceof File ? input :
|
|
2
|
+
const _httpFormDataReadNumber = (input) => input instanceof File ? input : typeof input === "string" && input.trim().length !== 0 ? input === "null" ? null : toNumber(input) : void 0;
|
|
3
3
|
const toNumber = (str) => {
|
|
4
4
|
const value = Number(str);
|
|
5
5
|
return isNaN(value) ? str : value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadNumber.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadNumber.ts"],"sourcesContent":["export const _httpFormDataReadNumber = (\n input: string | File | null,\n): number | null | undefined =>\n input instanceof File\n ? (input as any)\n :
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadNumber.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadNumber.ts"],"sourcesContent":["export const _httpFormDataReadNumber = (\n input: string | File | null,\n): number | null | undefined =>\n input instanceof File\n ? (input as any)\n : // Blank text is absent, as the empty string always was: `Number(\" \")`\n // is 0, which would read a whitespace value as a real zero (#2448).\n typeof input === \"string\" && input.trim().length !== 0\n ? input === \"null\"\n ? null\n : (toNumber(input) as any)\n : undefined;\n\nconst toNumber = (str: string): number | string => {\n const value: number = Number(str);\n return isNaN(value) ? str : value;\n};\n"],"mappings":";AAAA,MAAa,2BACX,UAEA,iBAAiB,OACZ,QAGD,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,WAAW,IACnD,UAAU,SACR,OACC,SAAS,KAAK,IACjB,KAAA;AAER,MAAM,YAAY,QAAiC;CACjD,MAAM,QAAgB,OAAO,GAAG;CAChC,OAAO,MAAM,KAAK,IAAI,MAAM;AAC9B"}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Reads one form field as a string.
|
|
3
|
+
*
|
|
4
|
+
* The text `"null"` spells `null` only where the property's type admits `null`;
|
|
5
|
+
* elsewhere it is the string `"null"` (#2450). The emitter passes `false` for a
|
|
6
|
+
* string whose type does not admit `null` and omits the argument otherwise, so
|
|
7
|
+
* code emitted before the parameter existed keeps its reading.
|
|
8
|
+
*/
|
|
9
|
+
export declare const _httpFormDataReadString: (input: string | File | null, nullable?: boolean) => string | null | undefined;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._httpFormDataReadString = void 0;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reads one form field as a string.
|
|
6
|
+
*
|
|
7
|
+
* The text `"null"` spells `null` only where the property's type admits `null`;
|
|
8
|
+
* elsewhere it is the string `"null"` (#2450). The emitter passes `false` for a
|
|
9
|
+
* string whose type does not admit `null` and omits the argument otherwise, so
|
|
10
|
+
* code emitted before the parameter existed keeps its reading.
|
|
11
|
+
*/
|
|
12
|
+
const _httpFormDataReadString = (input, nullable = true) => input instanceof File
|
|
5
13
|
? input
|
|
6
14
|
: input === null
|
|
7
15
|
? undefined
|
|
8
|
-
: input === "null"
|
|
16
|
+
: nullable === true && input === "null"
|
|
9
17
|
? null
|
|
10
18
|
: input;
|
|
11
19
|
exports._httpFormDataReadString = _httpFormDataReadString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadString.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadString.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadString.js","sourceRoot":"","sources":["../../src/internal/_httpFormDataReadString.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,CACrC,KAA2B,EAC3B,QAAQ,GAAY,IAAI,EACG,EAAE,CAC7B,KAAK,YAAY,IAAI;IACnB,CAAC,CAAE,KAAa;IAChB,CAAC,CAAC,KAAK,KAAK,IAAI;QACd,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM;YACrC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,KAAK,CAAC;AAVH,QAAA,uBAAuB,GAAvB,uBAAuB,CAUpB"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
//#region src/internal/_httpFormDataReadString.ts
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Reads one form field as a string.
|
|
4
|
+
*
|
|
5
|
+
* The text `"null"` spells `null` only where the property's type admits `null`;
|
|
6
|
+
* elsewhere it is the string `"null"` (#2450). The emitter passes `false` for a
|
|
7
|
+
* string whose type does not admit `null` and omits the argument otherwise, so
|
|
8
|
+
* code emitted before the parameter existed keeps its reading.
|
|
9
|
+
*/
|
|
10
|
+
const _httpFormDataReadString = (input, nullable = true) => input instanceof File ? input : input === null ? void 0 : nullable === true && input === "null" ? null : input;
|
|
3
11
|
//#endregion
|
|
4
12
|
export { _httpFormDataReadString };
|
|
5
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpFormDataReadString.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadString.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"_httpFormDataReadString.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadString.ts"],"sourcesContent":["/**\n * Reads one form field as a string.\n *\n * The text `\"null\"` spells `null` only where the property's type admits `null`;\n * elsewhere it is the string `\"null\"` (#2450). The emitter passes `false` for a\n * string whose type does not admit `null` and omits the argument otherwise, so\n * code emitted before the parameter existed keeps its reading.\n */\nexport const _httpFormDataReadString = (\n input: string | File | null,\n nullable: boolean = true,\n): string | null | undefined =>\n input instanceof File\n ? (input as any)\n : input === null\n ? undefined\n : nullable === true && input === \"null\"\n ? null\n : input;\n"],"mappings":";;;;;;;;;AAQA,MAAa,2BACX,OACA,WAAoB,SAEpB,iBAAiB,OACZ,QACD,UAAU,OACR,KAAA,IACA,aAAa,QAAQ,UAAU,SAC7B,OACA"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._httpHeaderReadBigint = void 0;
|
|
4
|
-
const _httpHeaderReadBigint = (value) =>
|
|
4
|
+
const _httpHeaderReadBigint = (value) =>
|
|
5
|
+
// A blank header, or a blank element of a header list, is absent: `BigInt("")`
|
|
6
|
+
// is 0n, which let validators accept an empty header as a real zero (#2448).
|
|
7
|
+
value !== undefined && isBlank(value) === false ? toBigint(value) : undefined;
|
|
5
8
|
exports._httpHeaderReadBigint = _httpHeaderReadBigint;
|
|
9
|
+
const isBlank = (value) => typeof value === "string" && value.trim().length === 0;
|
|
6
10
|
const toBigint = (str) => {
|
|
7
11
|
try {
|
|
8
12
|
return BigInt(str);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_httpHeaderReadBigint.js","sourceRoot":"","sources":["../../src/internal/_httpHeaderReadBigint.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,KAAyB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"_httpHeaderReadBigint.js","sourceRoot":"","sources":["../../src/internal/_httpHeaderReadBigint.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,KAAyB,EAAE,EAAE;AACjE,+EAA+E;AAC/E,6EAA6E;AAC7E,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAHnE,QAAA,qBAAqB,GAArB,qBAAqB,CAG8C;AAEhF,MAAM,OAAO,GAAG,CAAC,KAAa,EAAW,EAAE,CACzC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;AAEzD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;eAAO,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/internal/_httpHeaderReadBigint.ts
|
|
2
|
-
const _httpHeaderReadBigint = (value) => value !== void 0 ? toBigint(value) : void 0;
|
|
2
|
+
const _httpHeaderReadBigint = (value) => value !== void 0 && isBlank(value) === false ? toBigint(value) : void 0;
|
|
3
|
+
const isBlank = (value) => typeof value === "string" && value.trim().length === 0;
|
|
3
4
|
const toBigint = (str) => {
|
|
4
5
|
try {
|
|
5
6
|
return BigInt(str);
|