typia 12.0.0-dev.20260307-2 → 12.0.0-dev.20260310

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.
Files changed (155) hide show
  1. package/lib/executable/setup/PluginConfigurator.js +3 -3
  2. package/lib/executable/setup/PluginConfigurator.mjs +3 -3
  3. package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/executable/typia.mjs +15 -15
  6. package/lib/internal/_coerceLlmArguments.d.ts +2 -0
  7. package/lib/internal/_coerceLlmArguments.js +7 -0
  8. package/lib/internal/_coerceLlmArguments.js.map +1 -0
  9. package/lib/internal/_coerceLlmArguments.mjs +6 -0
  10. package/lib/internal/_coerceLlmArguments.mjs.map +1 -0
  11. package/lib/internal/_llmApplicationFinalize.js +1 -1
  12. package/lib/internal/_llmApplicationFinalize.js.map +1 -1
  13. package/lib/internal/_llmApplicationFinalize.mjs +1 -0
  14. package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
  15. package/lib/internal/_parseLlmArguments.d.ts +2 -0
  16. package/lib/internal/_parseLlmArguments.js +7 -0
  17. package/lib/internal/_parseLlmArguments.js.map +1 -0
  18. package/lib/internal/_parseLlmArguments.mjs +6 -0
  19. package/lib/internal/_parseLlmArguments.mjs.map +1 -0
  20. package/lib/llm.d.ts +154 -1
  21. package/lib/llm.js +20 -0
  22. package/lib/llm.js.map +1 -1
  23. package/lib/llm.mjs +17 -1
  24. package/lib/llm.mjs.map +1 -1
  25. package/lib/re-exports.d.ts +1 -1
  26. package/lib/re-exports.js.map +1 -1
  27. package/package.json +5 -5
  28. package/src/TypeGuardError.ts +145 -145
  29. package/src/executable/TypiaGenerateWizard.ts +82 -82
  30. package/src/executable/TypiaPatchWizard.ts +45 -45
  31. package/src/executable/TypiaSetupWizard.ts +171 -171
  32. package/src/executable/setup/ArgumentParser.ts +42 -42
  33. package/src/executable/setup/CommandExecutor.ts +8 -8
  34. package/src/executable/setup/FileRetriever.ts +19 -19
  35. package/src/executable/setup/PackageManager.ts +87 -87
  36. package/src/executable/setup/PluginConfigurator.ts +74 -74
  37. package/src/executable/typia.ts +55 -55
  38. package/src/functional.ts +600 -600
  39. package/src/http.ts +843 -843
  40. package/src/index.ts +4 -4
  41. package/src/internal/_IProtobufWriter.ts +18 -18
  42. package/src/internal/_ProtobufReader.ts +187 -187
  43. package/src/internal/_ProtobufSizer.ts +137 -137
  44. package/src/internal/_ProtobufWriter.ts +135 -135
  45. package/src/internal/_accessExpressionAsString.ts +46 -46
  46. package/src/internal/_assertGuard.ts +13 -13
  47. package/src/internal/_coerceLlmArguments.ts +7 -0
  48. package/src/internal/_createStandardSchema.ts +133 -133
  49. package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
  50. package/src/internal/_httpFormDataReadArray.ts +4 -4
  51. package/src/internal/_httpFormDataReadBigint.ts +18 -18
  52. package/src/internal/_httpFormDataReadBlob.ts +10 -10
  53. package/src/internal/_httpFormDataReadBoolean.ts +16 -16
  54. package/src/internal/_httpFormDataReadFile.ts +10 -10
  55. package/src/internal/_httpFormDataReadNumber.ts +15 -15
  56. package/src/internal/_httpFormDataReadString.ts +10 -10
  57. package/src/internal/_httpHeaderReadBigint.ts +10 -10
  58. package/src/internal/_httpHeaderReadBoolean.ts +8 -8
  59. package/src/internal/_httpHeaderReadNumber.ts +7 -7
  60. package/src/internal/_httpParameterReadBigint.ts +10 -10
  61. package/src/internal/_httpParameterReadBoolean.ts +8 -8
  62. package/src/internal/_httpParameterReadNumber.ts +7 -7
  63. package/src/internal/_httpParameterReadString.ts +2 -2
  64. package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
  65. package/src/internal/_httpQueryReadArray.ts +4 -4
  66. package/src/internal/_httpQueryReadBigint.ts +12 -12
  67. package/src/internal/_httpQueryReadBoolean.ts +14 -14
  68. package/src/internal/_httpQueryReadNumber.ts +9 -9
  69. package/src/internal/_httpQueryReadString.ts +4 -4
  70. package/src/internal/_isBetween.ts +2 -2
  71. package/src/internal/_isBigintString.ts +8 -8
  72. package/src/internal/_isFormatByte.ts +7 -7
  73. package/src/internal/_isFormatDate.ts +3 -3
  74. package/src/internal/_isFormatDateTime.ts +4 -4
  75. package/src/internal/_isFormatDuration.ts +4 -4
  76. package/src/internal/_isFormatEmail.ts +4 -4
  77. package/src/internal/_isFormatHostname.ts +4 -4
  78. package/src/internal/_isFormatIdnEmail.ts +4 -4
  79. package/src/internal/_isFormatIdnHostname.ts +4 -4
  80. package/src/internal/_isFormatIpv4.ts +4 -4
  81. package/src/internal/_isFormatIpv6.ts +4 -4
  82. package/src/internal/_isFormatIri.ts +3 -3
  83. package/src/internal/_isFormatIriReference.ts +4 -4
  84. package/src/internal/_isFormatJsonPointer.ts +3 -3
  85. package/src/internal/_isFormatPassword.ts +1 -1
  86. package/src/internal/_isFormatRegex.ts +8 -8
  87. package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
  88. package/src/internal/_isFormatTime.ts +4 -4
  89. package/src/internal/_isFormatUri.ts +6 -6
  90. package/src/internal/_isFormatUriReference.ts +5 -5
  91. package/src/internal/_isFormatUriTemplate.ts +4 -4
  92. package/src/internal/_isFormatUrl.ts +4 -4
  93. package/src/internal/_isFormatUuid.ts +3 -3
  94. package/src/internal/_isTypeFloat.ts +5 -5
  95. package/src/internal/_isTypeInt32.ts +5 -5
  96. package/src/internal/_isTypeInt64.ts +5 -5
  97. package/src/internal/_isTypeUint32.ts +5 -5
  98. package/src/internal/_isTypeUint64.ts +5 -5
  99. package/src/internal/_isUniqueItems.ts +159 -159
  100. package/src/internal/_jsonStringifyNumber.ts +12 -12
  101. package/src/internal/_jsonStringifyRest.ts +3 -3
  102. package/src/internal/_jsonStringifyString.ts +42 -42
  103. package/src/internal/_jsonStringifyTail.ts +2 -2
  104. package/src/internal/_llmApplicationFinalize.ts +24 -23
  105. package/src/internal/_miscCloneAny.ts +46 -46
  106. package/src/internal/_notationAny.ts +37 -37
  107. package/src/internal/_notationCamel.ts +13 -13
  108. package/src/internal/_notationPascal.ts +8 -8
  109. package/src/internal/_notationSnake.ts +43 -43
  110. package/src/internal/_parseLlmArguments.ts +7 -0
  111. package/src/internal/_randomArray.ts +21 -21
  112. package/src/internal/_randomBigint.ts +6 -6
  113. package/src/internal/_randomBoolean.ts +1 -1
  114. package/src/internal/_randomFormatByte.ts +3 -3
  115. package/src/internal/_randomFormatDate.ts +18 -18
  116. package/src/internal/_randomFormatDatetime.ts +16 -16
  117. package/src/internal/_randomFormatDuration.ts +27 -27
  118. package/src/internal/_randomFormatEmail.ts +11 -11
  119. package/src/internal/_randomFormatHostname.ts +6 -6
  120. package/src/internal/_randomFormatIdnEmail.ts +3 -3
  121. package/src/internal/_randomFormatIdnHostname.ts +3 -3
  122. package/src/internal/_randomFormatIpv4.ts +11 -11
  123. package/src/internal/_randomFormatIpv6.ts +11 -11
  124. package/src/internal/_randomFormatIri.ts +3 -3
  125. package/src/internal/_randomFormatIriReference.ts +3 -3
  126. package/src/internal/_randomFormatJsonPointer.ts +7 -7
  127. package/src/internal/_randomFormatPassword.ts +8 -8
  128. package/src/internal/_randomFormatRegex.ts +4 -4
  129. package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
  130. package/src/internal/_randomFormatTime.ts +14 -14
  131. package/src/internal/_randomFormatUri.ts +3 -3
  132. package/src/internal/_randomFormatUriReference.ts +3 -3
  133. package/src/internal/_randomFormatUriTemplate.ts +3 -3
  134. package/src/internal/_randomFormatUrl.ts +11 -11
  135. package/src/internal/_randomFormatUuid.ts +6 -6
  136. package/src/internal/_randomInteger.ts +53 -53
  137. package/src/internal/_randomNumber.ts +80 -80
  138. package/src/internal/_randomPattern.ts +10 -10
  139. package/src/internal/_randomPick.ts +9 -9
  140. package/src/internal/_randomString.ts +24 -24
  141. package/src/internal/_throwTypeGuardError.ts +5 -5
  142. package/src/internal/_validateReport.ts +21 -21
  143. package/src/internal/private/__notationCapitalize.ts +2 -2
  144. package/src/internal/private/__notationUnsnake.ts +24 -24
  145. package/src/json.ts +553 -553
  146. package/src/llm.ts +408 -211
  147. package/src/misc.ts +448 -448
  148. package/src/module.ts +811 -811
  149. package/src/notations.ts +624 -624
  150. package/src/programmers/TypiaProgrammer.ts +8 -8
  151. package/src/protobuf.ts +499 -499
  152. package/src/re-exports.ts +33 -32
  153. package/src/reflect.ts +75 -75
  154. package/src/transform.ts +5 -5
  155. package/src/transformers/NoTransformConfigurationError.ts +16 -16
package/src/http.ts CHANGED
@@ -1,843 +1,843 @@
1
- import {
2
- Atomic,
3
- IReadableURLSearchParams,
4
- IValidation,
5
- Resolved,
6
- } from "@typia/interface";
7
-
8
- import { TypeGuardError } from "./TypeGuardError";
9
- import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
10
-
11
- /* ===========================================================
12
- HTTP
13
- - FORM-DATA
14
- - QUERY
15
- - HEADERS
16
- - PARAMETER
17
- - FACTORY FUNCTIONS
18
- ==============================================================
19
- FORM-DATA
20
- ----------------------------------------------------------- */
21
- /**
22
- * Decodes `FormData` into type `T`.
23
- *
24
- * Parses a `FormData` instance with automatic type casting. Properties typed as
25
- * `boolean` or `Blob` are cast to expected types during decoding.
26
- *
27
- * Type `T` constraints:
28
- *
29
- * 1. Must be an object type
30
- * 2. No dynamic properties allowed
31
- * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
32
- * types allowed
33
- * 4. No union types allowed
34
- *
35
- * Does not validate the decoded value. For validation, use:
36
- *
37
- * - {@link assertFormData} — Throws on type mismatch
38
- * - {@link isFormData} — Returns `null` on type mismatch
39
- * - {@link validateFormData} — Returns detailed validation errors
40
- *
41
- * @template T Target object type
42
- * @param input FormData instance to decode
43
- * @returns Decoded object of type `T`
44
- * @danger You must configure the generic argument `T`
45
- */
46
- export function formData<T extends object>(input: FormData): Resolved<T>;
47
-
48
- /** @internal */
49
- export function formData(): never {
50
- NoTransformConfigurationError("http.formData");
51
- }
52
-
53
- /**
54
- * Decodes `FormData` into type `T` with assertion.
55
- *
56
- * Parses a `FormData` instance with automatic type casting, then validates the
57
- * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.
58
- *
59
- * Type `T` constraints:
60
- *
61
- * 1. Must be an object type
62
- * 2. No dynamic properties allowed
63
- * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
64
- * types allowed
65
- * 4. No union types allowed
66
- *
67
- * Related functions:
68
- *
69
- * - {@link formData} — No validation
70
- * - {@link isFormData} — Returns `null` instead of throwing
71
- * - {@link validateFormData} — Returns detailed validation errors
72
- *
73
- * @template T Target object type
74
- * @param input FormData instance to decode
75
- * @param errorFactory Custom error factory receiving
76
- * {@link TypeGuardError.IProps}
77
- * @returns Decoded object of type `T`
78
- * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
79
- * @danger You must configure the generic argument `T`
80
- */
81
- export function assertFormData<T extends object>(
82
- input: FormData,
83
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
84
- ): Resolved<T>;
85
-
86
- /** @internal */
87
- export function assertFormData(): never {
88
- NoTransformConfigurationError("http.assertFormData");
89
- }
90
-
91
- /**
92
- * Decodes `FormData` into type `T` with type checking.
93
- *
94
- * Parses a `FormData` instance with automatic type casting, then validates the
95
- * result via {@link is}. Returns `null` on type mismatch.
96
- *
97
- * Type `T` constraints:
98
- *
99
- * 1. Must be an object type
100
- * 2. No dynamic properties allowed
101
- * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
102
- * types allowed
103
- * 4. No union types allowed
104
- *
105
- * Related functions:
106
- *
107
- * - {@link formData} — No validation
108
- * - {@link assertFormData} — Throws instead of returning `null`
109
- * - {@link validateFormData} — Returns detailed validation errors
110
- *
111
- * @template T Target object type
112
- * @param input FormData instance to decode
113
- * @returns Decoded object of type `T`, or `null` if invalid
114
- * @danger You must configure the generic argument `T`
115
- */
116
- export function isFormData<T extends object>(
117
- input: FormData,
118
- ): Resolved<T> | null;
119
-
120
- /** @internal */
121
- export function isFormData(): never {
122
- NoTransformConfigurationError("http.isFormData");
123
- }
124
-
125
- /**
126
- * Decodes `FormData` into type `T` with validation.
127
- *
128
- * Parses a `FormData` instance with automatic type casting, then validates the
129
- * result via {@link validate}. Returns {@link IValidation.IFailure} with all
130
- * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.
131
- *
132
- * Type `T` constraints:
133
- *
134
- * 1. Must be an object type
135
- * 2. No dynamic properties allowed
136
- * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
137
- * types allowed
138
- * 4. No union types allowed
139
- *
140
- * Related functions:
141
- *
142
- * - {@link formData} — No validation
143
- * - {@link assertFormData} — Throws on first error
144
- * - {@link isFormData} — Returns `null` instead of error details
145
- *
146
- * @template T Target object type
147
- * @param input FormData instance to decode
148
- * @returns Validation result containing decoded value or errors
149
- * @danger You must configure the generic argument `T`
150
- */
151
- export function validateFormData<T extends object>(
152
- input: FormData,
153
- ): IValidation<Resolved<T>>;
154
-
155
- /** @internal */
156
- export function validateFormData(): never {
157
- NoTransformConfigurationError("http.validateFormData");
158
- }
159
-
160
- /* -----------------------------------------------------------
161
- QUERY
162
- ----------------------------------------------------------- */
163
- /**
164
- * Decodes URL query string into type `T`.
165
- *
166
- * Parses a query string or `URLSearchParams` instance with automatic type
167
- * casting. Properties typed as `boolean` or `number` are cast to expected types
168
- * during decoding.
169
- *
170
- * Type `T` constraints:
171
- *
172
- * 1. Must be an object type
173
- * 2. No dynamic properties allowed
174
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
175
- * 4. No union types allowed
176
- *
177
- * Does not validate the decoded value. For validation, use:
178
- *
179
- * - {@link assertQuery} — Throws on type mismatch
180
- * - {@link isQuery} — Returns `null` on type mismatch
181
- * - {@link validateQuery} — Returns detailed validation errors
182
- *
183
- * @template T Target object type
184
- * @param input Query string or URLSearchParams instance
185
- * @returns Decoded object of type `T`
186
- * @danger You must configure the generic argument `T`
187
- */
188
- export function query<T extends object>(
189
- input: string | IReadableURLSearchParams,
190
- ): Resolved<T>;
191
-
192
- /** @internal */
193
- export function query(): never {
194
- NoTransformConfigurationError("http.query");
195
- }
196
-
197
- /**
198
- * Decodes URL query string into type `T` with assertion.
199
- *
200
- * Parses a query string or `URLSearchParams` instance with automatic type
201
- * casting, then validates the result via {@link assert}. Throws
202
- * {@link TypeGuardError} on mismatch.
203
- *
204
- * Type `T` constraints:
205
- *
206
- * 1. Must be an object type
207
- * 2. No dynamic properties allowed
208
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
209
- * 4. No union types allowed
210
- *
211
- * Related functions:
212
- *
213
- * - {@link query} — No validation
214
- * - {@link isQuery} — Returns `null` instead of throwing
215
- * - {@link validateQuery} — Returns detailed validation errors
216
- *
217
- * @template T Target object type
218
- * @param input Query string or URLSearchParams instance
219
- * @param errorFactory Custom error factory receiving
220
- * {@link TypeGuardError.IProps}
221
- * @returns Decoded object of type `T`
222
- * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
223
- * @danger You must configure the generic argument `T`
224
- */
225
- export function assertQuery<T extends object>(
226
- input: string | IReadableURLSearchParams,
227
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
228
- ): Resolved<T>;
229
-
230
- /** @internal */
231
- export function assertQuery(): never {
232
- NoTransformConfigurationError("http.assertQuery");
233
- }
234
-
235
- /**
236
- * Decodes URL query string into type `T` with type checking.
237
- *
238
- * Parses a query string or `URLSearchParams` instance with automatic type
239
- * casting, then validates the result via {@link is}. Returns `null` on type
240
- * mismatch.
241
- *
242
- * Type `T` constraints:
243
- *
244
- * 1. Must be an object type
245
- * 2. No dynamic properties allowed
246
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
247
- * 4. No union types allowed
248
- *
249
- * Related functions:
250
- *
251
- * - {@link query} — No validation
252
- * - {@link assertQuery} — Throws instead of returning `null`
253
- * - {@link validateQuery} — Returns detailed validation errors
254
- *
255
- * @template T Target object type
256
- * @param input Query string or URLSearchParams instance
257
- * @returns Decoded object of type `T`, or `null` if invalid
258
- * @danger You must configure the generic argument `T`
259
- */
260
- export function isQuery<T extends object>(
261
- input: string | IReadableURLSearchParams,
262
- ): Resolved<T> | null;
263
-
264
- /** @internal */
265
- export function isQuery(): never {
266
- NoTransformConfigurationError("http.isQuery");
267
- }
268
-
269
- /**
270
- * Decodes URL query string into type `T` with validation.
271
- *
272
- * Parses a query string or `URLSearchParams` instance with automatic type
273
- * casting, then validates the result via {@link validate}. Returns
274
- * {@link IValidation.IFailure} with all errors on mismatch, or
275
- * {@link IValidation.ISuccess} with decoded value.
276
- *
277
- * Type `T` constraints:
278
- *
279
- * 1. Must be an object type
280
- * 2. No dynamic properties allowed
281
- * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
282
- * 4. No union types allowed
283
- *
284
- * Related functions:
285
- *
286
- * - {@link query} — No validation
287
- * - {@link assertQuery} — Throws on first error
288
- * - {@link isQuery} — Returns `null` instead of error details
289
- *
290
- * @template T Target object type
291
- * @param input Query string or URLSearchParams instance
292
- * @returns Validation result containing decoded value or errors
293
- * @danger You must configure the generic argument `T`
294
- */
295
- export function validateQuery<T extends object>(
296
- input: string | IReadableURLSearchParams,
297
- ): IValidation<Resolved<T>>;
298
-
299
- /** @internal */
300
- export function validateQuery(): never {
301
- NoTransformConfigurationError("http.validateQuery");
302
- }
303
-
304
- /* -----------------------------------------------------------
305
- HEADERS
306
- ----------------------------------------------------------- */
307
- /**
308
- * Decodes HTTP headers into type `T`.
309
- *
310
- * Parses HTTP headers object with automatic type casting. Properties typed as
311
- * `boolean` or `number` are cast to expected types during decoding. Compatible
312
- * with Express and Fastify request headers.
313
- *
314
- * Type `T` constraints:
315
- *
316
- * 1. Must be an object type
317
- * 2. No dynamic properties allowed
318
- * 3. Property keys must be lowercase
319
- * 4. Property values cannot be `null` (but `undefined` is allowed)
320
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
321
- * 6. No union types allowed
322
- * 7. Property `set-cookie` must be array type
323
- * 8. These properties cannot be array type: `age`, `authorization`,
324
- * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
325
- * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
326
- * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
327
- * `user-agent`
328
- *
329
- * Does not validate the decoded value. For validation, use:
330
- *
331
- * - {@link assertHeaders} — Throws on type mismatch
332
- * - {@link isHeaders} — Returns `null` on type mismatch
333
- * - {@link validateHeaders} — Returns detailed validation errors
334
- *
335
- * @template T Target object type
336
- * @param input Headers object from HTTP request
337
- * @returns Decoded object of type `T`
338
- * @danger You must configure the generic argument `T`
339
- */
340
- export function headers<T extends object>(
341
- input: Record<string, string | string[] | undefined>,
342
- ): Resolved<T>;
343
-
344
- /** @internal */
345
- export function headers(): never {
346
- NoTransformConfigurationError("http.headers");
347
- }
348
-
349
- /**
350
- * Decodes HTTP headers into type `T` with assertion.
351
- *
352
- * Parses HTTP headers object with automatic type casting, then validates the
353
- * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.
354
- * Compatible with Express and Fastify request headers.
355
- *
356
- * Type `T` constraints:
357
- *
358
- * 1. Must be an object type
359
- * 2. No dynamic properties allowed
360
- * 3. Property keys must be lowercase
361
- * 4. Property values cannot be `null` (but `undefined` is allowed)
362
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
363
- * 6. No union types allowed
364
- * 7. Property `set-cookie` must be array type
365
- * 8. These properties cannot be array type: `age`, `authorization`,
366
- * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
367
- * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
368
- * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
369
- * `user-agent`
370
- *
371
- * Related functions:
372
- *
373
- * - {@link headers} — No validation
374
- * - {@link isHeaders} — Returns `null` instead of throwing
375
- * - {@link validateHeaders} — Returns detailed validation errors
376
- *
377
- * @template T Target object type
378
- * @param input Headers object from HTTP request
379
- * @param errorFactory Custom error factory receiving
380
- * {@link TypeGuardError.IProps}
381
- * @returns Decoded object of type `T`
382
- * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
383
- * @danger You must configure the generic argument `T`
384
- */
385
- export function assertHeaders<T extends object>(
386
- input: Record<string, string | string[] | undefined>,
387
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
388
- ): Resolved<T>;
389
-
390
- /** @internal */
391
- export function assertHeaders(): never {
392
- NoTransformConfigurationError("http.assertHeaders");
393
- }
394
-
395
- /**
396
- * Decodes HTTP headers into type `T` with type checking.
397
- *
398
- * Parses HTTP headers object with automatic type casting, then validates the
399
- * result via {@link is}. Returns `null` on type mismatch. Compatible with
400
- * Express and Fastify request headers.
401
- *
402
- * Type `T` constraints:
403
- *
404
- * 1. Must be an object type
405
- * 2. No dynamic properties allowed
406
- * 3. Property keys must be lowercase
407
- * 4. Property values cannot be `null` (but `undefined` is allowed)
408
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
409
- * 6. No union types allowed
410
- * 7. Property `set-cookie` must be array type
411
- * 8. These properties cannot be array type: `age`, `authorization`,
412
- * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
413
- * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
414
- * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
415
- * `user-agent`
416
- *
417
- * Related functions:
418
- *
419
- * - {@link headers} — No validation
420
- * - {@link assertHeaders} — Throws instead of returning `null`
421
- * - {@link validateHeaders} — Returns detailed validation errors
422
- *
423
- * @template T Target object type
424
- * @param input Headers object from HTTP request
425
- * @returns Decoded object of type `T`, or `null` if invalid
426
- * @danger You must configure the generic argument `T`
427
- */
428
- export function isHeaders<T extends object>(
429
- input: Record<string, string | string[] | undefined>,
430
- ): Resolved<T> | null;
431
-
432
- /** @internal */
433
- export function isHeaders(): never {
434
- NoTransformConfigurationError("http.isHeaders");
435
- }
436
-
437
- /**
438
- * Decodes HTTP headers into type `T` with validation.
439
- *
440
- * Parses HTTP headers object with automatic type casting, then validates the
441
- * result via {@link validate}. Returns {@link IValidation.IFailure} with all
442
- * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.
443
- * Compatible with Express and Fastify request headers.
444
- *
445
- * Type `T` constraints:
446
- *
447
- * 1. Must be an object type
448
- * 2. No dynamic properties allowed
449
- * 3. Property keys must be lowercase
450
- * 4. Property values cannot be `null` (but `undefined` is allowed)
451
- * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
452
- * 6. No union types allowed
453
- * 7. Property `set-cookie` must be array type
454
- * 8. These properties cannot be array type: `age`, `authorization`,
455
- * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
456
- * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
457
- * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
458
- * `user-agent`
459
- *
460
- * Related functions:
461
- *
462
- * - {@link headers} — No validation
463
- * - {@link assertHeaders} — Throws on first error
464
- * - {@link isHeaders} — Returns `null` instead of error details
465
- *
466
- * @template T Target object type
467
- * @param input Headers object from HTTP request
468
- * @returns Validation result containing decoded value or errors
469
- * @danger You must configure the generic argument `T`
470
- */
471
- export function validateHeaders<T extends object>(
472
- input: Record<string, string | string[] | undefined>,
473
- ): IValidation<Resolved<T>>;
474
-
475
- /** @internal */
476
- export function validateHeaders(): never {
477
- NoTransformConfigurationError("http.validateHeaders");
478
- }
479
-
480
- /* -----------------------------------------------------------
481
- PARAMETER
482
- ----------------------------------------------------------- */
483
- /**
484
- * Decodes URL path parameter into type `T`.
485
- *
486
- * Parses a path parameter string with automatic type casting. When type `T` is
487
- * `boolean` or `number`, casts the string value to the expected type. Also
488
- * performs type assertion via {@link assert}, throwing {@link TypeGuardError} on
489
- * mismatch.
490
- *
491
- * @template T Target atomic type (`boolean`, `bigint`, `number`, `string`, or
492
- * `null`)
493
- * @param input Path parameter string
494
- * @returns Decoded value of type `T`
495
- * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
496
- * @danger You must configure the generic argument `T`
497
- */
498
- export function parameter<T extends Atomic.Type | null>(
499
- input: string,
500
- ): Resolved<T>;
501
-
502
- /** @internal */
503
- export function parameter(): never {
504
- NoTransformConfigurationError("http.parameter");
505
- }
506
-
507
- /* -----------------------------------------------------------
508
- FACTORY FUNCTIONS
509
- ----------------------------------------------------------- */
510
- /**
511
- * Creates reusable {@link formData} function.
512
- *
513
- * @template T Target object type
514
- * @danger You must configure the generic argument `T`
515
- */
516
- export function createFormData(): never;
517
-
518
- /**
519
- * Creates reusable {@link formData} function.
520
- *
521
- * @template T Target object type
522
- * @returns Reusable decoder function
523
- */
524
- export function createFormData<T extends object>(): (input: FormData) => T;
525
-
526
- /** @internal */
527
- export function createFormData<T>(): (input: FormData) => T {
528
- NoTransformConfigurationError("http.createFormData");
529
- }
530
-
531
- /**
532
- * Creates reusable {@link assertFormData} function.
533
- *
534
- * @template T Target object type
535
- * @param errorFactory Custom error factory receiving
536
- * {@link TypeGuardError.IProps}
537
- * @danger You must configure the generic argument `T`
538
- */
539
- export function createAssertFormData(
540
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
541
- ): never;
542
-
543
- /**
544
- * Creates reusable {@link assertFormData} function.
545
- *
546
- * @template T Target object type
547
- * @param errorFactory Custom error factory receiving
548
- * {@link TypeGuardError.IProps}
549
- * @returns Reusable decoder function
550
- */
551
- export function createAssertFormData<T extends object>(
552
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
553
- ): (input: FormData) => T;
554
-
555
- /** @internal */
556
- export function createAssertFormData<T>(): (input: FormData) => T {
557
- NoTransformConfigurationError("http.createAssertFormData");
558
- }
559
-
560
- /**
561
- * Creates reusable {@link isFormData} function.
562
- *
563
- * @template T Target object type
564
- * @danger You must configure the generic argument `T`
565
- */
566
- export function createIsFormData(): never;
567
-
568
- /**
569
- * Creates reusable {@link isFormData} function.
570
- *
571
- * @template T Target object type
572
- * @returns Reusable decoder function
573
- */
574
- export function createIsFormData<T extends object>(): (
575
- input: FormData,
576
- ) => T | null;
577
-
578
- /** @internal */
579
- export function createIsFormData<T>(): (input: FormData) => T | null {
580
- NoTransformConfigurationError("http.createIsFormData");
581
- }
582
-
583
- /**
584
- * Creates reusable {@link validateFormData} function.
585
- *
586
- * @template T Target object type
587
- * @danger You must configure the generic argument `T`
588
- */
589
- export function createValidateFormData(): never;
590
-
591
- /**
592
- * Creates reusable {@link validateFormData} function.
593
- *
594
- * @template T Target object type
595
- * @returns Reusable decoder function
596
- */
597
- export function createValidateFormData<T extends object>(): (
598
- input: FormData,
599
- ) => IValidation<Resolved<T>>;
600
-
601
- /** @internal */
602
- export function createValidateFormData<T>(): (
603
- input: FormData,
604
- ) => IValidation<Resolved<T>> {
605
- NoTransformConfigurationError("http.createValidateFormData");
606
- }
607
-
608
- /**
609
- * Creates reusable {@link query} function.
610
- *
611
- * @template T Target object type
612
- * @danger You must configure the generic argument `T`
613
- */
614
- export function createQuery(): never;
615
-
616
- /**
617
- * Creates reusable {@link query} function.
618
- *
619
- * @template T Target object type
620
- * @returns Reusable decoder function
621
- */
622
- export function createQuery<T extends object>(): (
623
- input: string | IReadableURLSearchParams,
624
- ) => T;
625
-
626
- /** @internal */
627
- export function createQuery<T>(): (
628
- input: string | IReadableURLSearchParams,
629
- ) => T {
630
- NoTransformConfigurationError("http.createQuery");
631
- }
632
-
633
- /**
634
- * Creates reusable {@link assertQuery} function.
635
- *
636
- * @template T Target object type
637
- * @param errorFactory Custom error factory receiving
638
- * {@link TypeGuardError.IProps}
639
- * @danger You must configure the generic argument `T`
640
- */
641
- export function createAssertQuery(
642
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
643
- ): never;
644
-
645
- /**
646
- * Creates reusable {@link assertQuery} function.
647
- *
648
- * @template T Target object type
649
- * @param errorFactory Custom error factory receiving
650
- * {@link TypeGuardError.IProps}
651
- * @returns Reusable decoder function
652
- */
653
- export function createAssertQuery<T extends object>(
654
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
655
- ): (input: string | IReadableURLSearchParams) => T;
656
-
657
- /** @internal */
658
- export function createAssertQuery<T>(): (
659
- input: string | IReadableURLSearchParams,
660
- ) => T {
661
- NoTransformConfigurationError("http.createAssertQuery");
662
- }
663
-
664
- /**
665
- * Creates reusable {@link isQuery} function.
666
- *
667
- * @template T Target object type
668
- * @danger You must configure the generic argument `T`
669
- */
670
- export function createIsQuery(): never;
671
-
672
- /**
673
- * Creates reusable {@link isQuery} function.
674
- *
675
- * @template T Target object type
676
- * @returns Reusable decoder function
677
- */
678
- export function createIsQuery<T extends object>(): (
679
- input: string | IReadableURLSearchParams,
680
- ) => T | null;
681
-
682
- /** @internal */
683
- export function createIsQuery<T>(): (
684
- input: string | IReadableURLSearchParams,
685
- ) => T | null {
686
- NoTransformConfigurationError("http.createIsQuery");
687
- }
688
-
689
- /**
690
- * Creates reusable {@link validateQuery} function.
691
- *
692
- * @template T Target object type
693
- * @danger You must configure the generic argument `T`
694
- */
695
- export function createValidateQuery(): never;
696
-
697
- /**
698
- * Creates reusable {@link validateQuery} function.
699
- *
700
- * @template T Target object type
701
- * @returns Reusable decoder function
702
- */
703
- export function createValidateQuery<T extends object>(): (
704
- input: string | IReadableURLSearchParams,
705
- ) => IValidation<Resolved<T>>;
706
-
707
- /** @internal */
708
- export function createValidateQuery<T>(): (
709
- input: string | IReadableURLSearchParams,
710
- ) => IValidation<Resolved<T>> {
711
- NoTransformConfigurationError("http.createValidateQuery");
712
- }
713
-
714
- /**
715
- * Creates reusable {@link headers} function.
716
- *
717
- * @template T Target object type
718
- * @danger You must configure the generic argument `T`
719
- */
720
- export function createHeaders(): never;
721
-
722
- /**
723
- * Creates reusable {@link headers} function.
724
- *
725
- * @template T Target object type
726
- * @returns Reusable decoder function
727
- */
728
- export function createHeaders<T extends object>(): (
729
- input: Record<string, string | string[] | undefined>,
730
- ) => T;
731
-
732
- /** @internal */
733
- export function createHeaders<T>(): (
734
- input: Record<string, string | string[] | undefined>,
735
- ) => T {
736
- NoTransformConfigurationError("http.createHeaders");
737
- }
738
-
739
- /**
740
- * Creates reusable {@link assertHeaders} function.
741
- *
742
- * @template T Target object type
743
- * @param errorFactory Custom error factory receiving
744
- * {@link TypeGuardError.IProps}
745
- * @danger You must configure the generic argument `T`
746
- */
747
- export function createAssertHeaders(
748
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
749
- ): never;
750
-
751
- /**
752
- * Creates reusable {@link assertHeaders} function.
753
- *
754
- * @template T Target object type
755
- * @param errorFactory Custom error factory receiving
756
- * {@link TypeGuardError.IProps}
757
- * @returns Reusable decoder function
758
- */
759
- export function createAssertHeaders<T extends object>(
760
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
761
- ): (input: Record<string, string | string[] | undefined>) => T;
762
-
763
- /** @internal */
764
- export function createAssertHeaders<T>(): (
765
- input: Record<string, string | string[] | undefined>,
766
- ) => T {
767
- NoTransformConfigurationError("http.createAssertHeaders");
768
- }
769
-
770
- /**
771
- * Creates reusable {@link isHeaders} function.
772
- *
773
- * @template T Target object type
774
- * @danger You must configure the generic argument `T`
775
- */
776
- export function createIsHeaders(): never;
777
-
778
- /**
779
- * Creates reusable {@link isHeaders} function.
780
- *
781
- * @template T Target object type
782
- * @returns Reusable decoder function
783
- */
784
- export function createIsHeaders<T extends object>(): (
785
- input: Record<string, string | string[] | undefined>,
786
- ) => T | null;
787
-
788
- /** @internal */
789
- export function createIsHeaders<T>(): (
790
- input: Record<string, string | string[] | undefined>,
791
- ) => T | null {
792
- NoTransformConfigurationError("http.createIsHeaders");
793
- }
794
-
795
- /**
796
- * Creates reusable {@link validateHeaders} function.
797
- *
798
- * @template T Target object type
799
- * @danger You must configure the generic argument `T`
800
- */
801
- export function createValidateHeaders(): never;
802
-
803
- /**
804
- * Creates reusable {@link validateHeaders} function.
805
- *
806
- * @template T Target object type
807
- * @returns Reusable decoder function
808
- */
809
- export function createValidateHeaders<T extends object>(): (
810
- input: Record<string, string | string[] | undefined>,
811
- ) => IValidation<Resolved<T>>;
812
-
813
- /** @internal */
814
- export function createValidateHeaders<T>(): (
815
- input: Record<string, string | string[] | undefined>,
816
- ) => IValidation<Resolved<T>> {
817
- NoTransformConfigurationError("http.createValidateHeaders");
818
- }
819
-
820
- /**
821
- * Creates reusable {@link parameter} function.
822
- *
823
- * @template T Target atomic type
824
- * @danger You must configure the generic argument `T`
825
- */
826
- export function createParameter(): never;
827
-
828
- /**
829
- * Creates reusable {@link parameter} function.
830
- *
831
- * @template T Target atomic type
832
- * @returns Reusable decoder function
833
- */
834
- export function createParameter<T extends Atomic.Type | null>(): (
835
- input: string,
836
- ) => T;
837
-
838
- /** @internal */
839
- export function createParameter<T extends Atomic.Type | null>(): (
840
- input: string,
841
- ) => T {
842
- NoTransformConfigurationError("http.createParameter");
843
- }
1
+ import {
2
+ Atomic,
3
+ IReadableURLSearchParams,
4
+ IValidation,
5
+ Resolved,
6
+ } from "@typia/interface";
7
+
8
+ import { TypeGuardError } from "./TypeGuardError";
9
+ import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
10
+
11
+ /* ===========================================================
12
+ HTTP
13
+ - FORM-DATA
14
+ - QUERY
15
+ - HEADERS
16
+ - PARAMETER
17
+ - FACTORY FUNCTIONS
18
+ ==============================================================
19
+ FORM-DATA
20
+ ----------------------------------------------------------- */
21
+ /**
22
+ * Decodes `FormData` into type `T`.
23
+ *
24
+ * Parses a `FormData` instance with automatic type casting. Properties typed as
25
+ * `boolean` or `Blob` are cast to expected types during decoding.
26
+ *
27
+ * Type `T` constraints:
28
+ *
29
+ * 1. Must be an object type
30
+ * 2. No dynamic properties allowed
31
+ * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
32
+ * types allowed
33
+ * 4. No union types allowed
34
+ *
35
+ * Does not validate the decoded value. For validation, use:
36
+ *
37
+ * - {@link assertFormData} — Throws on type mismatch
38
+ * - {@link isFormData} — Returns `null` on type mismatch
39
+ * - {@link validateFormData} — Returns detailed validation errors
40
+ *
41
+ * @template T Target object type
42
+ * @param input FormData instance to decode
43
+ * @returns Decoded object of type `T`
44
+ * @danger You must configure the generic argument `T`
45
+ */
46
+ export function formData<T extends object>(input: FormData): Resolved<T>;
47
+
48
+ /** @internal */
49
+ export function formData(): never {
50
+ NoTransformConfigurationError("http.formData");
51
+ }
52
+
53
+ /**
54
+ * Decodes `FormData` into type `T` with assertion.
55
+ *
56
+ * Parses a `FormData` instance with automatic type casting, then validates the
57
+ * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.
58
+ *
59
+ * Type `T` constraints:
60
+ *
61
+ * 1. Must be an object type
62
+ * 2. No dynamic properties allowed
63
+ * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
64
+ * types allowed
65
+ * 4. No union types allowed
66
+ *
67
+ * Related functions:
68
+ *
69
+ * - {@link formData} — No validation
70
+ * - {@link isFormData} — Returns `null` instead of throwing
71
+ * - {@link validateFormData} — Returns detailed validation errors
72
+ *
73
+ * @template T Target object type
74
+ * @param input FormData instance to decode
75
+ * @param errorFactory Custom error factory receiving
76
+ * {@link TypeGuardError.IProps}
77
+ * @returns Decoded object of type `T`
78
+ * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
79
+ * @danger You must configure the generic argument `T`
80
+ */
81
+ export function assertFormData<T extends object>(
82
+ input: FormData,
83
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
84
+ ): Resolved<T>;
85
+
86
+ /** @internal */
87
+ export function assertFormData(): never {
88
+ NoTransformConfigurationError("http.assertFormData");
89
+ }
90
+
91
+ /**
92
+ * Decodes `FormData` into type `T` with type checking.
93
+ *
94
+ * Parses a `FormData` instance with automatic type casting, then validates the
95
+ * result via {@link is}. Returns `null` on type mismatch.
96
+ *
97
+ * Type `T` constraints:
98
+ *
99
+ * 1. Must be an object type
100
+ * 2. No dynamic properties allowed
101
+ * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
102
+ * types allowed
103
+ * 4. No union types allowed
104
+ *
105
+ * Related functions:
106
+ *
107
+ * - {@link formData} — No validation
108
+ * - {@link assertFormData} — Throws instead of returning `null`
109
+ * - {@link validateFormData} — Returns detailed validation errors
110
+ *
111
+ * @template T Target object type
112
+ * @param input FormData instance to decode
113
+ * @returns Decoded object of type `T`, or `null` if invalid
114
+ * @danger You must configure the generic argument `T`
115
+ */
116
+ export function isFormData<T extends object>(
117
+ input: FormData,
118
+ ): Resolved<T> | null;
119
+
120
+ /** @internal */
121
+ export function isFormData(): never {
122
+ NoTransformConfigurationError("http.isFormData");
123
+ }
124
+
125
+ /**
126
+ * Decodes `FormData` into type `T` with validation.
127
+ *
128
+ * Parses a `FormData` instance with automatic type casting, then validates the
129
+ * result via {@link validate}. Returns {@link IValidation.IFailure} with all
130
+ * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.
131
+ *
132
+ * Type `T` constraints:
133
+ *
134
+ * 1. Must be an object type
135
+ * 2. No dynamic properties allowed
136
+ * 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array
137
+ * types allowed
138
+ * 4. No union types allowed
139
+ *
140
+ * Related functions:
141
+ *
142
+ * - {@link formData} — No validation
143
+ * - {@link assertFormData} — Throws on first error
144
+ * - {@link isFormData} — Returns `null` instead of error details
145
+ *
146
+ * @template T Target object type
147
+ * @param input FormData instance to decode
148
+ * @returns Validation result containing decoded value or errors
149
+ * @danger You must configure the generic argument `T`
150
+ */
151
+ export function validateFormData<T extends object>(
152
+ input: FormData,
153
+ ): IValidation<Resolved<T>>;
154
+
155
+ /** @internal */
156
+ export function validateFormData(): never {
157
+ NoTransformConfigurationError("http.validateFormData");
158
+ }
159
+
160
+ /* -----------------------------------------------------------
161
+ QUERY
162
+ ----------------------------------------------------------- */
163
+ /**
164
+ * Decodes URL query string into type `T`.
165
+ *
166
+ * Parses a query string or `URLSearchParams` instance with automatic type
167
+ * casting. Properties typed as `boolean` or `number` are cast to expected types
168
+ * during decoding.
169
+ *
170
+ * Type `T` constraints:
171
+ *
172
+ * 1. Must be an object type
173
+ * 2. No dynamic properties allowed
174
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
175
+ * 4. No union types allowed
176
+ *
177
+ * Does not validate the decoded value. For validation, use:
178
+ *
179
+ * - {@link assertQuery} — Throws on type mismatch
180
+ * - {@link isQuery} — Returns `null` on type mismatch
181
+ * - {@link validateQuery} — Returns detailed validation errors
182
+ *
183
+ * @template T Target object type
184
+ * @param input Query string or URLSearchParams instance
185
+ * @returns Decoded object of type `T`
186
+ * @danger You must configure the generic argument `T`
187
+ */
188
+ export function query<T extends object>(
189
+ input: string | IReadableURLSearchParams,
190
+ ): Resolved<T>;
191
+
192
+ /** @internal */
193
+ export function query(): never {
194
+ NoTransformConfigurationError("http.query");
195
+ }
196
+
197
+ /**
198
+ * Decodes URL query string into type `T` with assertion.
199
+ *
200
+ * Parses a query string or `URLSearchParams` instance with automatic type
201
+ * casting, then validates the result via {@link assert}. Throws
202
+ * {@link TypeGuardError} on mismatch.
203
+ *
204
+ * Type `T` constraints:
205
+ *
206
+ * 1. Must be an object type
207
+ * 2. No dynamic properties allowed
208
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
209
+ * 4. No union types allowed
210
+ *
211
+ * Related functions:
212
+ *
213
+ * - {@link query} — No validation
214
+ * - {@link isQuery} — Returns `null` instead of throwing
215
+ * - {@link validateQuery} — Returns detailed validation errors
216
+ *
217
+ * @template T Target object type
218
+ * @param input Query string or URLSearchParams instance
219
+ * @param errorFactory Custom error factory receiving
220
+ * {@link TypeGuardError.IProps}
221
+ * @returns Decoded object of type `T`
222
+ * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
223
+ * @danger You must configure the generic argument `T`
224
+ */
225
+ export function assertQuery<T extends object>(
226
+ input: string | IReadableURLSearchParams,
227
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
228
+ ): Resolved<T>;
229
+
230
+ /** @internal */
231
+ export function assertQuery(): never {
232
+ NoTransformConfigurationError("http.assertQuery");
233
+ }
234
+
235
+ /**
236
+ * Decodes URL query string into type `T` with type checking.
237
+ *
238
+ * Parses a query string or `URLSearchParams` instance with automatic type
239
+ * casting, then validates the result via {@link is}. Returns `null` on type
240
+ * mismatch.
241
+ *
242
+ * Type `T` constraints:
243
+ *
244
+ * 1. Must be an object type
245
+ * 2. No dynamic properties allowed
246
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
247
+ * 4. No union types allowed
248
+ *
249
+ * Related functions:
250
+ *
251
+ * - {@link query} — No validation
252
+ * - {@link assertQuery} — Throws instead of returning `null`
253
+ * - {@link validateQuery} — Returns detailed validation errors
254
+ *
255
+ * @template T Target object type
256
+ * @param input Query string or URLSearchParams instance
257
+ * @returns Decoded object of type `T`, or `null` if invalid
258
+ * @danger You must configure the generic argument `T`
259
+ */
260
+ export function isQuery<T extends object>(
261
+ input: string | IReadableURLSearchParams,
262
+ ): Resolved<T> | null;
263
+
264
+ /** @internal */
265
+ export function isQuery(): never {
266
+ NoTransformConfigurationError("http.isQuery");
267
+ }
268
+
269
+ /**
270
+ * Decodes URL query string into type `T` with validation.
271
+ *
272
+ * Parses a query string or `URLSearchParams` instance with automatic type
273
+ * casting, then validates the result via {@link validate}. Returns
274
+ * {@link IValidation.IFailure} with all errors on mismatch, or
275
+ * {@link IValidation.ISuccess} with decoded value.
276
+ *
277
+ * Type `T` constraints:
278
+ *
279
+ * 1. Must be an object type
280
+ * 2. No dynamic properties allowed
281
+ * 3. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
282
+ * 4. No union types allowed
283
+ *
284
+ * Related functions:
285
+ *
286
+ * - {@link query} — No validation
287
+ * - {@link assertQuery} — Throws on first error
288
+ * - {@link isQuery} — Returns `null` instead of error details
289
+ *
290
+ * @template T Target object type
291
+ * @param input Query string or URLSearchParams instance
292
+ * @returns Validation result containing decoded value or errors
293
+ * @danger You must configure the generic argument `T`
294
+ */
295
+ export function validateQuery<T extends object>(
296
+ input: string | IReadableURLSearchParams,
297
+ ): IValidation<Resolved<T>>;
298
+
299
+ /** @internal */
300
+ export function validateQuery(): never {
301
+ NoTransformConfigurationError("http.validateQuery");
302
+ }
303
+
304
+ /* -----------------------------------------------------------
305
+ HEADERS
306
+ ----------------------------------------------------------- */
307
+ /**
308
+ * Decodes HTTP headers into type `T`.
309
+ *
310
+ * Parses HTTP headers object with automatic type casting. Properties typed as
311
+ * `boolean` or `number` are cast to expected types during decoding. Compatible
312
+ * with Express and Fastify request headers.
313
+ *
314
+ * Type `T` constraints:
315
+ *
316
+ * 1. Must be an object type
317
+ * 2. No dynamic properties allowed
318
+ * 3. Property keys must be lowercase
319
+ * 4. Property values cannot be `null` (but `undefined` is allowed)
320
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
321
+ * 6. No union types allowed
322
+ * 7. Property `set-cookie` must be array type
323
+ * 8. These properties cannot be array type: `age`, `authorization`,
324
+ * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
325
+ * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
326
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
327
+ * `user-agent`
328
+ *
329
+ * Does not validate the decoded value. For validation, use:
330
+ *
331
+ * - {@link assertHeaders} — Throws on type mismatch
332
+ * - {@link isHeaders} — Returns `null` on type mismatch
333
+ * - {@link validateHeaders} — Returns detailed validation errors
334
+ *
335
+ * @template T Target object type
336
+ * @param input Headers object from HTTP request
337
+ * @returns Decoded object of type `T`
338
+ * @danger You must configure the generic argument `T`
339
+ */
340
+ export function headers<T extends object>(
341
+ input: Record<string, string | string[] | undefined>,
342
+ ): Resolved<T>;
343
+
344
+ /** @internal */
345
+ export function headers(): never {
346
+ NoTransformConfigurationError("http.headers");
347
+ }
348
+
349
+ /**
350
+ * Decodes HTTP headers into type `T` with assertion.
351
+ *
352
+ * Parses HTTP headers object with automatic type casting, then validates the
353
+ * result via {@link assert}. Throws {@link TypeGuardError} on mismatch.
354
+ * Compatible with Express and Fastify request headers.
355
+ *
356
+ * Type `T` constraints:
357
+ *
358
+ * 1. Must be an object type
359
+ * 2. No dynamic properties allowed
360
+ * 3. Property keys must be lowercase
361
+ * 4. Property values cannot be `null` (but `undefined` is allowed)
362
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
363
+ * 6. No union types allowed
364
+ * 7. Property `set-cookie` must be array type
365
+ * 8. These properties cannot be array type: `age`, `authorization`,
366
+ * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
367
+ * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
368
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
369
+ * `user-agent`
370
+ *
371
+ * Related functions:
372
+ *
373
+ * - {@link headers} — No validation
374
+ * - {@link isHeaders} — Returns `null` instead of throwing
375
+ * - {@link validateHeaders} — Returns detailed validation errors
376
+ *
377
+ * @template T Target object type
378
+ * @param input Headers object from HTTP request
379
+ * @param errorFactory Custom error factory receiving
380
+ * {@link TypeGuardError.IProps}
381
+ * @returns Decoded object of type `T`
382
+ * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
383
+ * @danger You must configure the generic argument `T`
384
+ */
385
+ export function assertHeaders<T extends object>(
386
+ input: Record<string, string | string[] | undefined>,
387
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
388
+ ): Resolved<T>;
389
+
390
+ /** @internal */
391
+ export function assertHeaders(): never {
392
+ NoTransformConfigurationError("http.assertHeaders");
393
+ }
394
+
395
+ /**
396
+ * Decodes HTTP headers into type `T` with type checking.
397
+ *
398
+ * Parses HTTP headers object with automatic type casting, then validates the
399
+ * result via {@link is}. Returns `null` on type mismatch. Compatible with
400
+ * Express and Fastify request headers.
401
+ *
402
+ * Type `T` constraints:
403
+ *
404
+ * 1. Must be an object type
405
+ * 2. No dynamic properties allowed
406
+ * 3. Property keys must be lowercase
407
+ * 4. Property values cannot be `null` (but `undefined` is allowed)
408
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
409
+ * 6. No union types allowed
410
+ * 7. Property `set-cookie` must be array type
411
+ * 8. These properties cannot be array type: `age`, `authorization`,
412
+ * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
413
+ * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
414
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
415
+ * `user-agent`
416
+ *
417
+ * Related functions:
418
+ *
419
+ * - {@link headers} — No validation
420
+ * - {@link assertHeaders} — Throws instead of returning `null`
421
+ * - {@link validateHeaders} — Returns detailed validation errors
422
+ *
423
+ * @template T Target object type
424
+ * @param input Headers object from HTTP request
425
+ * @returns Decoded object of type `T`, or `null` if invalid
426
+ * @danger You must configure the generic argument `T`
427
+ */
428
+ export function isHeaders<T extends object>(
429
+ input: Record<string, string | string[] | undefined>,
430
+ ): Resolved<T> | null;
431
+
432
+ /** @internal */
433
+ export function isHeaders(): never {
434
+ NoTransformConfigurationError("http.isHeaders");
435
+ }
436
+
437
+ /**
438
+ * Decodes HTTP headers into type `T` with validation.
439
+ *
440
+ * Parses HTTP headers object with automatic type casting, then validates the
441
+ * result via {@link validate}. Returns {@link IValidation.IFailure} with all
442
+ * errors on mismatch, or {@link IValidation.ISuccess} with decoded value.
443
+ * Compatible with Express and Fastify request headers.
444
+ *
445
+ * Type `T` constraints:
446
+ *
447
+ * 1. Must be an object type
448
+ * 2. No dynamic properties allowed
449
+ * 3. Property keys must be lowercase
450
+ * 4. Property values cannot be `null` (but `undefined` is allowed)
451
+ * 5. Only `boolean`, `bigint`, `number`, `string` or their array types allowed
452
+ * 6. No union types allowed
453
+ * 7. Property `set-cookie` must be array type
454
+ * 8. These properties cannot be array type: `age`, `authorization`,
455
+ * `content-length`, `content-type`, `etag`, `expires`, `from`, `host`,
456
+ * `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
457
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`,
458
+ * `user-agent`
459
+ *
460
+ * Related functions:
461
+ *
462
+ * - {@link headers} — No validation
463
+ * - {@link assertHeaders} — Throws on first error
464
+ * - {@link isHeaders} — Returns `null` instead of error details
465
+ *
466
+ * @template T Target object type
467
+ * @param input Headers object from HTTP request
468
+ * @returns Validation result containing decoded value or errors
469
+ * @danger You must configure the generic argument `T`
470
+ */
471
+ export function validateHeaders<T extends object>(
472
+ input: Record<string, string | string[] | undefined>,
473
+ ): IValidation<Resolved<T>>;
474
+
475
+ /** @internal */
476
+ export function validateHeaders(): never {
477
+ NoTransformConfigurationError("http.validateHeaders");
478
+ }
479
+
480
+ /* -----------------------------------------------------------
481
+ PARAMETER
482
+ ----------------------------------------------------------- */
483
+ /**
484
+ * Decodes URL path parameter into type `T`.
485
+ *
486
+ * Parses a path parameter string with automatic type casting. When type `T` is
487
+ * `boolean` or `number`, casts the string value to the expected type. Also
488
+ * performs type assertion via {@link assert}, throwing {@link TypeGuardError} on
489
+ * mismatch.
490
+ *
491
+ * @template T Target atomic type (`boolean`, `bigint`, `number`, `string`, or
492
+ * `null`)
493
+ * @param input Path parameter string
494
+ * @returns Decoded value of type `T`
495
+ * @throws {TypeGuardError} When decoded value doesn't conform to type `T`
496
+ * @danger You must configure the generic argument `T`
497
+ */
498
+ export function parameter<T extends Atomic.Type | null>(
499
+ input: string,
500
+ ): Resolved<T>;
501
+
502
+ /** @internal */
503
+ export function parameter(): never {
504
+ NoTransformConfigurationError("http.parameter");
505
+ }
506
+
507
+ /* -----------------------------------------------------------
508
+ FACTORY FUNCTIONS
509
+ ----------------------------------------------------------- */
510
+ /**
511
+ * Creates reusable {@link formData} function.
512
+ *
513
+ * @template T Target object type
514
+ * @danger You must configure the generic argument `T`
515
+ */
516
+ export function createFormData(): never;
517
+
518
+ /**
519
+ * Creates reusable {@link formData} function.
520
+ *
521
+ * @template T Target object type
522
+ * @returns Reusable decoder function
523
+ */
524
+ export function createFormData<T extends object>(): (input: FormData) => T;
525
+
526
+ /** @internal */
527
+ export function createFormData<T>(): (input: FormData) => T {
528
+ NoTransformConfigurationError("http.createFormData");
529
+ }
530
+
531
+ /**
532
+ * Creates reusable {@link assertFormData} function.
533
+ *
534
+ * @template T Target object type
535
+ * @param errorFactory Custom error factory receiving
536
+ * {@link TypeGuardError.IProps}
537
+ * @danger You must configure the generic argument `T`
538
+ */
539
+ export function createAssertFormData(
540
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
541
+ ): never;
542
+
543
+ /**
544
+ * Creates reusable {@link assertFormData} function.
545
+ *
546
+ * @template T Target object type
547
+ * @param errorFactory Custom error factory receiving
548
+ * {@link TypeGuardError.IProps}
549
+ * @returns Reusable decoder function
550
+ */
551
+ export function createAssertFormData<T extends object>(
552
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
553
+ ): (input: FormData) => T;
554
+
555
+ /** @internal */
556
+ export function createAssertFormData<T>(): (input: FormData) => T {
557
+ NoTransformConfigurationError("http.createAssertFormData");
558
+ }
559
+
560
+ /**
561
+ * Creates reusable {@link isFormData} function.
562
+ *
563
+ * @template T Target object type
564
+ * @danger You must configure the generic argument `T`
565
+ */
566
+ export function createIsFormData(): never;
567
+
568
+ /**
569
+ * Creates reusable {@link isFormData} function.
570
+ *
571
+ * @template T Target object type
572
+ * @returns Reusable decoder function
573
+ */
574
+ export function createIsFormData<T extends object>(): (
575
+ input: FormData,
576
+ ) => T | null;
577
+
578
+ /** @internal */
579
+ export function createIsFormData<T>(): (input: FormData) => T | null {
580
+ NoTransformConfigurationError("http.createIsFormData");
581
+ }
582
+
583
+ /**
584
+ * Creates reusable {@link validateFormData} function.
585
+ *
586
+ * @template T Target object type
587
+ * @danger You must configure the generic argument `T`
588
+ */
589
+ export function createValidateFormData(): never;
590
+
591
+ /**
592
+ * Creates reusable {@link validateFormData} function.
593
+ *
594
+ * @template T Target object type
595
+ * @returns Reusable decoder function
596
+ */
597
+ export function createValidateFormData<T extends object>(): (
598
+ input: FormData,
599
+ ) => IValidation<Resolved<T>>;
600
+
601
+ /** @internal */
602
+ export function createValidateFormData<T>(): (
603
+ input: FormData,
604
+ ) => IValidation<Resolved<T>> {
605
+ NoTransformConfigurationError("http.createValidateFormData");
606
+ }
607
+
608
+ /**
609
+ * Creates reusable {@link query} function.
610
+ *
611
+ * @template T Target object type
612
+ * @danger You must configure the generic argument `T`
613
+ */
614
+ export function createQuery(): never;
615
+
616
+ /**
617
+ * Creates reusable {@link query} function.
618
+ *
619
+ * @template T Target object type
620
+ * @returns Reusable decoder function
621
+ */
622
+ export function createQuery<T extends object>(): (
623
+ input: string | IReadableURLSearchParams,
624
+ ) => T;
625
+
626
+ /** @internal */
627
+ export function createQuery<T>(): (
628
+ input: string | IReadableURLSearchParams,
629
+ ) => T {
630
+ NoTransformConfigurationError("http.createQuery");
631
+ }
632
+
633
+ /**
634
+ * Creates reusable {@link assertQuery} function.
635
+ *
636
+ * @template T Target object type
637
+ * @param errorFactory Custom error factory receiving
638
+ * {@link TypeGuardError.IProps}
639
+ * @danger You must configure the generic argument `T`
640
+ */
641
+ export function createAssertQuery(
642
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
643
+ ): never;
644
+
645
+ /**
646
+ * Creates reusable {@link assertQuery} function.
647
+ *
648
+ * @template T Target object type
649
+ * @param errorFactory Custom error factory receiving
650
+ * {@link TypeGuardError.IProps}
651
+ * @returns Reusable decoder function
652
+ */
653
+ export function createAssertQuery<T extends object>(
654
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
655
+ ): (input: string | IReadableURLSearchParams) => T;
656
+
657
+ /** @internal */
658
+ export function createAssertQuery<T>(): (
659
+ input: string | IReadableURLSearchParams,
660
+ ) => T {
661
+ NoTransformConfigurationError("http.createAssertQuery");
662
+ }
663
+
664
+ /**
665
+ * Creates reusable {@link isQuery} function.
666
+ *
667
+ * @template T Target object type
668
+ * @danger You must configure the generic argument `T`
669
+ */
670
+ export function createIsQuery(): never;
671
+
672
+ /**
673
+ * Creates reusable {@link isQuery} function.
674
+ *
675
+ * @template T Target object type
676
+ * @returns Reusable decoder function
677
+ */
678
+ export function createIsQuery<T extends object>(): (
679
+ input: string | IReadableURLSearchParams,
680
+ ) => T | null;
681
+
682
+ /** @internal */
683
+ export function createIsQuery<T>(): (
684
+ input: string | IReadableURLSearchParams,
685
+ ) => T | null {
686
+ NoTransformConfigurationError("http.createIsQuery");
687
+ }
688
+
689
+ /**
690
+ * Creates reusable {@link validateQuery} function.
691
+ *
692
+ * @template T Target object type
693
+ * @danger You must configure the generic argument `T`
694
+ */
695
+ export function createValidateQuery(): never;
696
+
697
+ /**
698
+ * Creates reusable {@link validateQuery} function.
699
+ *
700
+ * @template T Target object type
701
+ * @returns Reusable decoder function
702
+ */
703
+ export function createValidateQuery<T extends object>(): (
704
+ input: string | IReadableURLSearchParams,
705
+ ) => IValidation<Resolved<T>>;
706
+
707
+ /** @internal */
708
+ export function createValidateQuery<T>(): (
709
+ input: string | IReadableURLSearchParams,
710
+ ) => IValidation<Resolved<T>> {
711
+ NoTransformConfigurationError("http.createValidateQuery");
712
+ }
713
+
714
+ /**
715
+ * Creates reusable {@link headers} function.
716
+ *
717
+ * @template T Target object type
718
+ * @danger You must configure the generic argument `T`
719
+ */
720
+ export function createHeaders(): never;
721
+
722
+ /**
723
+ * Creates reusable {@link headers} function.
724
+ *
725
+ * @template T Target object type
726
+ * @returns Reusable decoder function
727
+ */
728
+ export function createHeaders<T extends object>(): (
729
+ input: Record<string, string | string[] | undefined>,
730
+ ) => T;
731
+
732
+ /** @internal */
733
+ export function createHeaders<T>(): (
734
+ input: Record<string, string | string[] | undefined>,
735
+ ) => T {
736
+ NoTransformConfigurationError("http.createHeaders");
737
+ }
738
+
739
+ /**
740
+ * Creates reusable {@link assertHeaders} function.
741
+ *
742
+ * @template T Target object type
743
+ * @param errorFactory Custom error factory receiving
744
+ * {@link TypeGuardError.IProps}
745
+ * @danger You must configure the generic argument `T`
746
+ */
747
+ export function createAssertHeaders(
748
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
749
+ ): never;
750
+
751
+ /**
752
+ * Creates reusable {@link assertHeaders} function.
753
+ *
754
+ * @template T Target object type
755
+ * @param errorFactory Custom error factory receiving
756
+ * {@link TypeGuardError.IProps}
757
+ * @returns Reusable decoder function
758
+ */
759
+ export function createAssertHeaders<T extends object>(
760
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
761
+ ): (input: Record<string, string | string[] | undefined>) => T;
762
+
763
+ /** @internal */
764
+ export function createAssertHeaders<T>(): (
765
+ input: Record<string, string | string[] | undefined>,
766
+ ) => T {
767
+ NoTransformConfigurationError("http.createAssertHeaders");
768
+ }
769
+
770
+ /**
771
+ * Creates reusable {@link isHeaders} function.
772
+ *
773
+ * @template T Target object type
774
+ * @danger You must configure the generic argument `T`
775
+ */
776
+ export function createIsHeaders(): never;
777
+
778
+ /**
779
+ * Creates reusable {@link isHeaders} function.
780
+ *
781
+ * @template T Target object type
782
+ * @returns Reusable decoder function
783
+ */
784
+ export function createIsHeaders<T extends object>(): (
785
+ input: Record<string, string | string[] | undefined>,
786
+ ) => T | null;
787
+
788
+ /** @internal */
789
+ export function createIsHeaders<T>(): (
790
+ input: Record<string, string | string[] | undefined>,
791
+ ) => T | null {
792
+ NoTransformConfigurationError("http.createIsHeaders");
793
+ }
794
+
795
+ /**
796
+ * Creates reusable {@link validateHeaders} function.
797
+ *
798
+ * @template T Target object type
799
+ * @danger You must configure the generic argument `T`
800
+ */
801
+ export function createValidateHeaders(): never;
802
+
803
+ /**
804
+ * Creates reusable {@link validateHeaders} function.
805
+ *
806
+ * @template T Target object type
807
+ * @returns Reusable decoder function
808
+ */
809
+ export function createValidateHeaders<T extends object>(): (
810
+ input: Record<string, string | string[] | undefined>,
811
+ ) => IValidation<Resolved<T>>;
812
+
813
+ /** @internal */
814
+ export function createValidateHeaders<T>(): (
815
+ input: Record<string, string | string[] | undefined>,
816
+ ) => IValidation<Resolved<T>> {
817
+ NoTransformConfigurationError("http.createValidateHeaders");
818
+ }
819
+
820
+ /**
821
+ * Creates reusable {@link parameter} function.
822
+ *
823
+ * @template T Target atomic type
824
+ * @danger You must configure the generic argument `T`
825
+ */
826
+ export function createParameter(): never;
827
+
828
+ /**
829
+ * Creates reusable {@link parameter} function.
830
+ *
831
+ * @template T Target atomic type
832
+ * @returns Reusable decoder function
833
+ */
834
+ export function createParameter<T extends Atomic.Type | null>(): (
835
+ input: string,
836
+ ) => T;
837
+
838
+ /** @internal */
839
+ export function createParameter<T extends Atomic.Type | null>(): (
840
+ input: string,
841
+ ) => T {
842
+ NoTransformConfigurationError("http.createParameter");
843
+ }