typia 12.0.0-dev.20260309 → 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 (134) 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/package.json +5 -5
  7. package/src/TypeGuardError.ts +145 -145
  8. package/src/executable/TypiaGenerateWizard.ts +82 -82
  9. package/src/executable/TypiaPatchWizard.ts +45 -45
  10. package/src/executable/TypiaSetupWizard.ts +171 -171
  11. package/src/executable/setup/ArgumentParser.ts +42 -42
  12. package/src/executable/setup/CommandExecutor.ts +8 -8
  13. package/src/executable/setup/FileRetriever.ts +19 -19
  14. package/src/executable/setup/PackageManager.ts +87 -87
  15. package/src/executable/setup/PluginConfigurator.ts +74 -74
  16. package/src/executable/typia.ts +55 -55
  17. package/src/functional.ts +600 -600
  18. package/src/http.ts +843 -843
  19. package/src/index.ts +4 -4
  20. package/src/internal/_IProtobufWriter.ts +18 -18
  21. package/src/internal/_ProtobufReader.ts +187 -187
  22. package/src/internal/_ProtobufSizer.ts +137 -137
  23. package/src/internal/_ProtobufWriter.ts +135 -135
  24. package/src/internal/_accessExpressionAsString.ts +46 -46
  25. package/src/internal/_assertGuard.ts +13 -13
  26. package/src/internal/_coerceLlmArguments.ts +7 -7
  27. package/src/internal/_createStandardSchema.ts +133 -133
  28. package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
  29. package/src/internal/_httpFormDataReadArray.ts +4 -4
  30. package/src/internal/_httpFormDataReadBigint.ts +18 -18
  31. package/src/internal/_httpFormDataReadBlob.ts +10 -10
  32. package/src/internal/_httpFormDataReadBoolean.ts +16 -16
  33. package/src/internal/_httpFormDataReadFile.ts +10 -10
  34. package/src/internal/_httpFormDataReadNumber.ts +15 -15
  35. package/src/internal/_httpFormDataReadString.ts +10 -10
  36. package/src/internal/_httpHeaderReadBigint.ts +10 -10
  37. package/src/internal/_httpHeaderReadBoolean.ts +8 -8
  38. package/src/internal/_httpHeaderReadNumber.ts +7 -7
  39. package/src/internal/_httpParameterReadBigint.ts +10 -10
  40. package/src/internal/_httpParameterReadBoolean.ts +8 -8
  41. package/src/internal/_httpParameterReadNumber.ts +7 -7
  42. package/src/internal/_httpParameterReadString.ts +2 -2
  43. package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
  44. package/src/internal/_httpQueryReadArray.ts +4 -4
  45. package/src/internal/_httpQueryReadBigint.ts +12 -12
  46. package/src/internal/_httpQueryReadBoolean.ts +14 -14
  47. package/src/internal/_httpQueryReadNumber.ts +9 -9
  48. package/src/internal/_httpQueryReadString.ts +4 -4
  49. package/src/internal/_isBetween.ts +2 -2
  50. package/src/internal/_isBigintString.ts +8 -8
  51. package/src/internal/_isFormatByte.ts +7 -7
  52. package/src/internal/_isFormatDate.ts +3 -3
  53. package/src/internal/_isFormatDateTime.ts +4 -4
  54. package/src/internal/_isFormatDuration.ts +4 -4
  55. package/src/internal/_isFormatEmail.ts +4 -4
  56. package/src/internal/_isFormatHostname.ts +4 -4
  57. package/src/internal/_isFormatIdnEmail.ts +4 -4
  58. package/src/internal/_isFormatIdnHostname.ts +4 -4
  59. package/src/internal/_isFormatIpv4.ts +4 -4
  60. package/src/internal/_isFormatIpv6.ts +4 -4
  61. package/src/internal/_isFormatIri.ts +3 -3
  62. package/src/internal/_isFormatIriReference.ts +4 -4
  63. package/src/internal/_isFormatJsonPointer.ts +3 -3
  64. package/src/internal/_isFormatPassword.ts +1 -1
  65. package/src/internal/_isFormatRegex.ts +8 -8
  66. package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
  67. package/src/internal/_isFormatTime.ts +4 -4
  68. package/src/internal/_isFormatUri.ts +6 -6
  69. package/src/internal/_isFormatUriReference.ts +5 -5
  70. package/src/internal/_isFormatUriTemplate.ts +4 -4
  71. package/src/internal/_isFormatUrl.ts +4 -4
  72. package/src/internal/_isFormatUuid.ts +3 -3
  73. package/src/internal/_isTypeFloat.ts +5 -5
  74. package/src/internal/_isTypeInt32.ts +5 -5
  75. package/src/internal/_isTypeInt64.ts +5 -5
  76. package/src/internal/_isTypeUint32.ts +5 -5
  77. package/src/internal/_isTypeUint64.ts +5 -5
  78. package/src/internal/_isUniqueItems.ts +159 -159
  79. package/src/internal/_jsonStringifyNumber.ts +12 -12
  80. package/src/internal/_jsonStringifyRest.ts +3 -3
  81. package/src/internal/_jsonStringifyString.ts +42 -42
  82. package/src/internal/_jsonStringifyTail.ts +2 -2
  83. package/src/internal/_llmApplicationFinalize.ts +24 -24
  84. package/src/internal/_miscCloneAny.ts +46 -46
  85. package/src/internal/_notationAny.ts +37 -37
  86. package/src/internal/_notationCamel.ts +13 -13
  87. package/src/internal/_notationPascal.ts +8 -8
  88. package/src/internal/_notationSnake.ts +43 -43
  89. package/src/internal/_parseLlmArguments.ts +7 -7
  90. package/src/internal/_randomArray.ts +21 -21
  91. package/src/internal/_randomBigint.ts +6 -6
  92. package/src/internal/_randomBoolean.ts +1 -1
  93. package/src/internal/_randomFormatByte.ts +3 -3
  94. package/src/internal/_randomFormatDate.ts +18 -18
  95. package/src/internal/_randomFormatDatetime.ts +16 -16
  96. package/src/internal/_randomFormatDuration.ts +27 -27
  97. package/src/internal/_randomFormatEmail.ts +11 -11
  98. package/src/internal/_randomFormatHostname.ts +6 -6
  99. package/src/internal/_randomFormatIdnEmail.ts +3 -3
  100. package/src/internal/_randomFormatIdnHostname.ts +3 -3
  101. package/src/internal/_randomFormatIpv4.ts +11 -11
  102. package/src/internal/_randomFormatIpv6.ts +11 -11
  103. package/src/internal/_randomFormatIri.ts +3 -3
  104. package/src/internal/_randomFormatIriReference.ts +3 -3
  105. package/src/internal/_randomFormatJsonPointer.ts +7 -7
  106. package/src/internal/_randomFormatPassword.ts +8 -8
  107. package/src/internal/_randomFormatRegex.ts +4 -4
  108. package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
  109. package/src/internal/_randomFormatTime.ts +14 -14
  110. package/src/internal/_randomFormatUri.ts +3 -3
  111. package/src/internal/_randomFormatUriReference.ts +3 -3
  112. package/src/internal/_randomFormatUriTemplate.ts +3 -3
  113. package/src/internal/_randomFormatUrl.ts +11 -11
  114. package/src/internal/_randomFormatUuid.ts +6 -6
  115. package/src/internal/_randomInteger.ts +53 -53
  116. package/src/internal/_randomNumber.ts +80 -80
  117. package/src/internal/_randomPattern.ts +10 -10
  118. package/src/internal/_randomPick.ts +9 -9
  119. package/src/internal/_randomString.ts +24 -24
  120. package/src/internal/_throwTypeGuardError.ts +5 -5
  121. package/src/internal/_validateReport.ts +21 -21
  122. package/src/internal/private/__notationCapitalize.ts +2 -2
  123. package/src/internal/private/__notationUnsnake.ts +24 -24
  124. package/src/json.ts +553 -553
  125. package/src/llm.ts +408 -408
  126. package/src/misc.ts +448 -448
  127. package/src/module.ts +811 -811
  128. package/src/notations.ts +624 -624
  129. package/src/programmers/TypiaProgrammer.ts +8 -8
  130. package/src/protobuf.ts +499 -499
  131. package/src/re-exports.ts +33 -33
  132. package/src/reflect.ts +75 -75
  133. package/src/transform.ts +5 -5
  134. package/src/transformers/NoTransformConfigurationError.ts +16 -16
package/src/json.ts CHANGED
@@ -1,553 +1,553 @@
1
- import {
2
- IJsonSchemaApplication,
3
- IJsonSchemaCollection,
4
- IJsonSchemaUnit,
5
- IValidation,
6
- Primitive,
7
- } from "@typia/interface";
8
-
9
- import { TypeGuardError } from "./TypeGuardError";
10
- import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
11
-
12
- /* ===========================================================
13
- JSON
14
- - METADATA
15
- - PARSE
16
- - STRINGIFY
17
- - FACTORY FUNCTIONS
18
- ==============================================================
19
- METADATA
20
- ----------------------------------------------------------- */
21
- /**
22
- * Generates JSON schema for type `T`.
23
- *
24
- * @danger You must configure the generic argument `Type`
25
- */
26
- export function schema(): never;
27
-
28
- /**
29
- * Generates JSON schema for type `T`.
30
- *
31
- * Creates {@link IJsonSchemaUnit} containing a main schema and shared
32
- * components. Named types are stored in `components` for `$ref` referencing.
33
- *
34
- * Specify OpenAPI version via `Version` generic (`"3.0"` or `"3.1"`). Default
35
- * is `"3.1"`. Key difference: `"3.1"` supports tuple types.
36
- *
37
- * @template Type Target type
38
- * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
39
- * @returns JSON schema unit
40
- */
41
- export function schema<
42
- Type extends unknown,
43
- Version extends "3.0" | "3.1" = "3.1",
44
- >(): IJsonSchemaUnit<Version, Type>;
45
-
46
- /** @internal */
47
- export function schema(): never {
48
- NoTransformConfigurationError("json.schema");
49
- }
50
-
51
- /**
52
- * Generates JSON schemas for multiple types.
53
- *
54
- * @danger You must configure the generic argument `Types`
55
- */
56
- export function schemas(): never;
57
-
58
- /**
59
- * Generates JSON schemas for multiple types.
60
- *
61
- * Creates {@link IJsonSchemaCollection} containing schemas for all types in the
62
- * tuple. Named types are stored in `components` for `$ref` referencing.
63
- *
64
- * Specify OpenAPI version via `Version` generic (`"3.0"` or `"3.1"`). Default
65
- * is `"3.1"`. Key difference: `"3.1"` supports tuple types.
66
- *
67
- * @template Types Tuple of target types
68
- * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
69
- * @returns JSON schema collection
70
- */
71
- export function schemas<
72
- Types extends unknown[],
73
- Version extends "3.0" | "3.1" = "3.1",
74
- >(): IJsonSchemaCollection<Version, Types>;
75
-
76
- /** @internal */
77
- export function schemas(): never {
78
- NoTransformConfigurationError("json.schemas");
79
- }
80
-
81
- /**
82
- * Generates JSON function schema application.
83
- *
84
- * @danger You must configure the generic argument `Class`
85
- */
86
- export function application(): never;
87
-
88
- /**
89
- * Generates JSON function schema application from class/interface.
90
- *
91
- * Creates {@link IJsonSchemaApplication} from a TypeScript class or interface,
92
- * generating JSON schemas for all methods, parameters, and return types.
93
- * Designed for building custom LLM function calling schemas.
94
- *
95
- * The returned object contains:
96
- *
97
- * - `functions`: Array of function metadata with parameter/return schemas
98
- * - `components`: Shared schema components for `$ref` referencing
99
- *
100
- * Use cases:
101
- *
102
- * - Custom LLM function calling schema formats
103
- * - API documentation or code generation tools
104
- * - Alternative LLM integrations beyond built-in providers
105
- *
106
- * For standard LLM function calling, use {@link llm.application} instead, which
107
- * provides provider-specific schemas (ChatGPT, Claude, Gemini, etc.).
108
- *
109
- * @template Class Target class or interface type
110
- * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
111
- * @returns JSON function schema application
112
- */
113
- export function application<
114
- Class extends object,
115
- Version extends "3.0" | "3.1" = "3.1",
116
- >(): IJsonSchemaApplication<Version, Class>;
117
-
118
- /** @internal */
119
- export function application(): never {
120
- NoTransformConfigurationError("json.application");
121
- }
122
-
123
- /* -----------------------------------------------------------
124
- PARSE
125
- ----------------------------------------------------------- */
126
- /**
127
- * Parses JSON string with assertion.
128
- *
129
- * @danger You must configure the generic argument `T`
130
- */
131
- export function assertParse(
132
- input: string,
133
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
134
- ): never;
135
-
136
- /**
137
- * Parses JSON string with assertion.
138
- *
139
- * Combines `JSON.parse()` with {@link assert}. Throws {@link TypeGuardError} when
140
- * parsed value doesn't match type `T`.
141
- *
142
- * Related functions:
143
- *
144
- * - {@link isParse} — Returns `null` instead of throwing
145
- * - {@link validateParse} — Returns detailed validation errors
146
- *
147
- * @template T Target type for parsed value
148
- * @param input JSON string to parse
149
- * @param errorFactory Custom error factory receiving
150
- * {@link TypeGuardError.IProps}
151
- * @returns Parsed value of type `T`
152
- * @throws {TypeGuardError} When parsed value doesn't conform to type `T`
153
- */
154
- export function assertParse<T>(
155
- input: string,
156
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
157
- ): Primitive<T>;
158
-
159
- /** @internal */
160
- export function assertParse<T>(): Primitive<T> {
161
- NoTransformConfigurationError("json.assertParse");
162
- }
163
-
164
- /**
165
- * Parses JSON string with type checking.
166
- *
167
- * @danger You must configure the generic argument `T`
168
- */
169
- export function isParse(input: string): never;
170
-
171
- /**
172
- * Parses JSON string with type checking.
173
- *
174
- * Combines `JSON.parse()` with {@link is}. Returns `null` when parsed value
175
- * doesn't match type `T`.
176
- *
177
- * Related functions:
178
- *
179
- * - {@link assertParse} — Throws instead of returning `null`
180
- * - {@link validateParse} — Returns detailed validation errors
181
- *
182
- * @template T Target type for parsed value
183
- * @param input JSON string to parse
184
- * @returns Parsed value of type `T`, or `null` if invalid
185
- */
186
- export function isParse<T>(input: string): Primitive<T> | null;
187
-
188
- /** @internal */
189
- export function isParse<T>(): Primitive<T> | null {
190
- NoTransformConfigurationError("json.isParse");
191
- }
192
-
193
- /**
194
- * Parses JSON string with validation.
195
- *
196
- * @danger You must configure the generic argument `T`
197
- */
198
- export function validateParse(input: string): never;
199
-
200
- /**
201
- * Parses JSON string with validation.
202
- *
203
- * Combines `JSON.parse()` with {@link validate}. Returns
204
- * {@link IValidation.IFailure} with all errors on mismatch, or
205
- * {@link IValidation.ISuccess} with parsed value.
206
- *
207
- * Related functions:
208
- *
209
- * - {@link assertParse} — Throws on first error
210
- * - {@link isParse} — Returns `null` instead of error details
211
- *
212
- * @template T Target type for parsed value
213
- * @param input JSON string to parse
214
- * @returns Validation result containing parsed value or errors
215
- */
216
- export function validateParse<T>(input: string): IValidation<Primitive<T>>;
217
-
218
- /** @internal */
219
- export function validateParse<T>(): IValidation<Primitive<T>> {
220
- NoTransformConfigurationError("json.validateParse");
221
- }
222
-
223
- /* -----------------------------------------------------------
224
- STRINGIFY
225
- ----------------------------------------------------------- */
226
- /**
227
- * Converts value to JSON string (8x faster).
228
- *
229
- * Generates optimized JSON conversion code specific to type `T`, achieving ~8x
230
- * faster performance than native `JSON.stringify()`.
231
- *
232
- * Does not validate the input. For validation, use:
233
- *
234
- * - {@link assertStringify} — Throws on type mismatch
235
- * - {@link isStringify} — Returns `null` on type mismatch
236
- * - {@link validateStringify} — Returns detailed validation errors
237
- *
238
- * @template T Type of input value
239
- * @param input Value to stringify
240
- * @returns JSON string
241
- */
242
- export function stringify<T>(input: T): string;
243
-
244
- /** @internal */
245
- export function stringify(): never {
246
- NoTransformConfigurationError("json.stringify");
247
- }
248
-
249
- /**
250
- * Converts value to JSON string with assertion (5x faster).
251
- *
252
- * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}
253
- * when input doesn't match type `T`. Achieves ~5x faster performance than
254
- * native `JSON.stringify()`.
255
- *
256
- * Related functions:
257
- *
258
- * - {@link stringify} — No validation
259
- * - {@link isStringify} — Returns `null` instead of throwing
260
- * - {@link validateStringify} — Returns detailed validation errors
261
- *
262
- * @template T Type of input value
263
- * @param input Value to assert and stringify
264
- * @param errorFactory Custom error factory receiving
265
- * {@link TypeGuardError.IProps}
266
- * @returns JSON string
267
- * @throws {TypeGuardError} When input doesn't conform to type `T`
268
- */
269
- export function assertStringify<T>(
270
- input: T,
271
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
272
- ): string;
273
-
274
- /**
275
- * Converts value to JSON string with assertion (5x faster).
276
- *
277
- * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}
278
- * when input doesn't match type `T`. Achieves ~5x faster performance than
279
- * native `JSON.stringify()`.
280
- *
281
- * Related functions:
282
- *
283
- * - {@link stringify} — No validation
284
- * - {@link isStringify} — Returns `null` instead of throwing
285
- * - {@link validateStringify} — Returns detailed validation errors
286
- *
287
- * @template T Type of input value
288
- * @param input Value to assert and stringify
289
- * @param errorFactory Custom error factory receiving
290
- * {@link TypeGuardError.IProps}
291
- * @returns JSON string
292
- * @throws {TypeGuardError} When input doesn't conform to type `T`
293
- */
294
- export function assertStringify<T>(
295
- input: T,
296
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
297
- ): unknown;
298
-
299
- /** @internal */
300
- export function assertStringify(): string {
301
- NoTransformConfigurationError("json.assertStringify");
302
- }
303
-
304
- /**
305
- * Converts value to JSON string with type checking (7x faster).
306
- *
307
- * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't
308
- * match type `T`. Achieves ~7x faster performance than native
309
- * `JSON.stringify()`.
310
- *
311
- * Related functions:
312
- *
313
- * - {@link stringify} — No validation
314
- * - {@link assertStringify} — Throws instead of returning `null`
315
- * - {@link validateStringify} — Returns detailed validation errors
316
- *
317
- * @template T Type of input value
318
- * @param input Value to check and stringify
319
- * @returns JSON string, or `null` if type check fails
320
- */
321
- export function isStringify<T>(input: T): string | null;
322
-
323
- /**
324
- * Converts value to JSON string with type checking (7x faster).
325
- *
326
- * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't
327
- * match type `T`. Achieves ~7x faster performance than native
328
- * `JSON.stringify()`.
329
- *
330
- * Related functions:
331
- *
332
- * - {@link stringify} — No validation
333
- * - {@link assertStringify} — Throws instead of returning `null`
334
- * - {@link validateStringify} — Returns detailed validation errors
335
- *
336
- * @template T Type of input value
337
- * @param input Value to check and stringify
338
- * @returns JSON string, or `null` if type check fails
339
- */
340
- export function isStringify<T>(input: unknown): string | null;
341
-
342
- /** @internal */
343
- export function isStringify(): string | null {
344
- NoTransformConfigurationError("json.isStringify");
345
- }
346
-
347
- /**
348
- * Converts value to JSON string with validation (5x faster).
349
- *
350
- * Combines {@link validate} with {@link stringify}. Returns
351
- * {@link IValidation.IFailure} with all errors on mismatch, or
352
- * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance
353
- * than native `JSON.stringify()`.
354
- *
355
- * Related functions:
356
- *
357
- * - {@link stringify} — No validation
358
- * - {@link assertStringify} — Throws on first error
359
- * - {@link isStringify} — Returns `null` instead of error details
360
- *
361
- * @template T Type of input value
362
- * @param input Value to validate and stringify
363
- * @returns Validation result containing JSON string or errors
364
- */
365
- export function validateStringify<T>(input: T): IValidation<string>;
366
-
367
- /**
368
- * Converts value to JSON string with validation (5x faster).
369
- *
370
- * Combines {@link validate} with {@link stringify}. Returns
371
- * {@link IValidation.IFailure} with all errors on mismatch, or
372
- * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance
373
- * than native `JSON.stringify()`.
374
- *
375
- * Related functions:
376
- *
377
- * - {@link stringify} — No validation
378
- * - {@link assertStringify} — Throws on first error
379
- * - {@link isStringify} — Returns `null` instead of error details
380
- *
381
- * @template T Type of input value
382
- * @param input Value to validate and stringify
383
- * @returns Validation result containing JSON string or errors
384
- */
385
- export function validateStringify<T>(input: unknown): IValidation<string>;
386
-
387
- /** @internal */
388
- export function validateStringify(): IValidation<string> {
389
- NoTransformConfigurationError("json.validateStringify");
390
- }
391
-
392
- /* -----------------------------------------------------------
393
- FACTORY FUNCTIONS
394
- ----------------------------------------------------------- */
395
- /**
396
- * Creates reusable {@link isParse} function.
397
- *
398
- * @danger You must configure the generic argument `T`
399
- */
400
- export function createIsParse(): never;
401
-
402
- /**
403
- * Creates reusable {@link isParse} function.
404
- *
405
- * @template T Target type for parsed value
406
- * @returns Reusable parser function
407
- */
408
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
409
-
410
- /** @internal */
411
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
412
- NoTransformConfigurationError("json.createIsParse");
413
- }
414
-
415
- /**
416
- * Creates reusable {@link assertParse} function.
417
- *
418
- * @danger You must configure the generic argument `T`
419
- */
420
- export function createAssertParse(
421
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
422
- ): never;
423
-
424
- /**
425
- * Creates reusable {@link assertParse} function.
426
- *
427
- * @template T Target type for parsed value
428
- * @param errorFactory Custom error factory receiving
429
- * {@link TypeGuardError.IProps}
430
- * @returns Reusable parser function
431
- */
432
- export function createAssertParse<T>(
433
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
434
- ): (input: string) => Primitive<T>;
435
-
436
- /** @internal */
437
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
438
- NoTransformConfigurationError("json.createAssertParse");
439
- }
440
-
441
- /**
442
- * Creates reusable {@link validateParse} function.
443
- *
444
- * @danger You must configure the generic argument `T`
445
- */
446
- export function createValidateParse(): never;
447
-
448
- /**
449
- * Creates reusable {@link validateParse} function.
450
- *
451
- * @template T Target type for parsed value
452
- * @returns Reusable parser function
453
- */
454
- export function createValidateParse<T>(): (
455
- input: string,
456
- ) => IValidation<Primitive<T>>;
457
-
458
- /** @internal */
459
- export function createValidateParse<T>(): (
460
- input: string,
461
- ) => IValidation<Primitive<T>> {
462
- NoTransformConfigurationError("json.createValidateParse");
463
- }
464
-
465
- /**
466
- * Creates reusable {@link stringify} function.
467
- *
468
- * @danger You must configure the generic argument `T`
469
- */
470
- export function createStringify(): never;
471
-
472
- /**
473
- * Creates reusable {@link stringify} function.
474
- *
475
- * @template T Type of input value
476
- * @returns Reusable stringify function
477
- */
478
- export function createStringify<T>(): (input: T) => string;
479
-
480
- /** @internal */
481
- export function createStringify<T>(): (input: T) => string {
482
- NoTransformConfigurationError("json.createStringify");
483
- }
484
-
485
- /**
486
- * Creates reusable {@link assertStringify} function.
487
- *
488
- * @danger You must configure the generic argument `T`
489
- */
490
- export function createAssertStringify(
491
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
492
- ): never;
493
-
494
- /**
495
- * Creates reusable {@link assertStringify} function.
496
- *
497
- * @template T Type of input value
498
- * @param errorFactory Custom error factory receiving
499
- * {@link TypeGuardError.IProps}
500
- * @returns Reusable stringify function
501
- */
502
- export function createAssertStringify<T>(
503
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
504
- ): (input: unknown) => string;
505
-
506
- /** @internal */
507
- export function createAssertStringify(): (input: unknown) => string {
508
- NoTransformConfigurationError("json.createAssertStringify");
509
- }
510
-
511
- /**
512
- * Creates reusable {@link isStringify} function.
513
- *
514
- * @danger You must configure the generic argument `T`
515
- */
516
- export function createIsStringify(): never;
517
-
518
- /**
519
- * Creates reusable {@link isStringify} function.
520
- *
521
- * @template T Type of input value
522
- * @returns Reusable stringify function
523
- */
524
- export function createIsStringify<T>(): (input: unknown) => string | null;
525
-
526
- /** @internal */
527
- export function createIsStringify(): (input: unknown) => string | null {
528
- NoTransformConfigurationError("json.createIsStringify");
529
- }
530
-
531
- /**
532
- * Creates reusable {@link validateStringify} function.
533
- *
534
- * @danger You must configure the generic argument `T`
535
- */
536
- export function createValidateStringify(): never;
537
-
538
- /**
539
- * Creates reusable {@link validateStringify} function.
540
- *
541
- * @template T Type of input value
542
- * @returns Reusable stringify function
543
- */
544
- export function createValidateStringify<T>(): (
545
- input: unknown,
546
- ) => IValidation<string>;
547
-
548
- /** @internal */
549
- export function createValidateStringify(): (
550
- input: unknown,
551
- ) => IValidation<string> {
552
- NoTransformConfigurationError("json.createValidateStringify");
553
- }
1
+ import {
2
+ IJsonSchemaApplication,
3
+ IJsonSchemaCollection,
4
+ IJsonSchemaUnit,
5
+ IValidation,
6
+ Primitive,
7
+ } from "@typia/interface";
8
+
9
+ import { TypeGuardError } from "./TypeGuardError";
10
+ import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
11
+
12
+ /* ===========================================================
13
+ JSON
14
+ - METADATA
15
+ - PARSE
16
+ - STRINGIFY
17
+ - FACTORY FUNCTIONS
18
+ ==============================================================
19
+ METADATA
20
+ ----------------------------------------------------------- */
21
+ /**
22
+ * Generates JSON schema for type `T`.
23
+ *
24
+ * @danger You must configure the generic argument `Type`
25
+ */
26
+ export function schema(): never;
27
+
28
+ /**
29
+ * Generates JSON schema for type `T`.
30
+ *
31
+ * Creates {@link IJsonSchemaUnit} containing a main schema and shared
32
+ * components. Named types are stored in `components` for `$ref` referencing.
33
+ *
34
+ * Specify OpenAPI version via `Version` generic (`"3.0"` or `"3.1"`). Default
35
+ * is `"3.1"`. Key difference: `"3.1"` supports tuple types.
36
+ *
37
+ * @template Type Target type
38
+ * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
39
+ * @returns JSON schema unit
40
+ */
41
+ export function schema<
42
+ Type extends unknown,
43
+ Version extends "3.0" | "3.1" = "3.1",
44
+ >(): IJsonSchemaUnit<Version, Type>;
45
+
46
+ /** @internal */
47
+ export function schema(): never {
48
+ NoTransformConfigurationError("json.schema");
49
+ }
50
+
51
+ /**
52
+ * Generates JSON schemas for multiple types.
53
+ *
54
+ * @danger You must configure the generic argument `Types`
55
+ */
56
+ export function schemas(): never;
57
+
58
+ /**
59
+ * Generates JSON schemas for multiple types.
60
+ *
61
+ * Creates {@link IJsonSchemaCollection} containing schemas for all types in the
62
+ * tuple. Named types are stored in `components` for `$ref` referencing.
63
+ *
64
+ * Specify OpenAPI version via `Version` generic (`"3.0"` or `"3.1"`). Default
65
+ * is `"3.1"`. Key difference: `"3.1"` supports tuple types.
66
+ *
67
+ * @template Types Tuple of target types
68
+ * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
69
+ * @returns JSON schema collection
70
+ */
71
+ export function schemas<
72
+ Types extends unknown[],
73
+ Version extends "3.0" | "3.1" = "3.1",
74
+ >(): IJsonSchemaCollection<Version, Types>;
75
+
76
+ /** @internal */
77
+ export function schemas(): never {
78
+ NoTransformConfigurationError("json.schemas");
79
+ }
80
+
81
+ /**
82
+ * Generates JSON function schema application.
83
+ *
84
+ * @danger You must configure the generic argument `Class`
85
+ */
86
+ export function application(): never;
87
+
88
+ /**
89
+ * Generates JSON function schema application from class/interface.
90
+ *
91
+ * Creates {@link IJsonSchemaApplication} from a TypeScript class or interface,
92
+ * generating JSON schemas for all methods, parameters, and return types.
93
+ * Designed for building custom LLM function calling schemas.
94
+ *
95
+ * The returned object contains:
96
+ *
97
+ * - `functions`: Array of function metadata with parameter/return schemas
98
+ * - `components`: Shared schema components for `$ref` referencing
99
+ *
100
+ * Use cases:
101
+ *
102
+ * - Custom LLM function calling schema formats
103
+ * - API documentation or code generation tools
104
+ * - Alternative LLM integrations beyond built-in providers
105
+ *
106
+ * For standard LLM function calling, use {@link llm.application} instead, which
107
+ * provides provider-specific schemas (ChatGPT, Claude, Gemini, etc.).
108
+ *
109
+ * @template Class Target class or interface type
110
+ * @template Version OpenAPI version (`"3.0"` | `"3.1"`). Default `"3.1"`
111
+ * @returns JSON function schema application
112
+ */
113
+ export function application<
114
+ Class extends object,
115
+ Version extends "3.0" | "3.1" = "3.1",
116
+ >(): IJsonSchemaApplication<Version, Class>;
117
+
118
+ /** @internal */
119
+ export function application(): never {
120
+ NoTransformConfigurationError("json.application");
121
+ }
122
+
123
+ /* -----------------------------------------------------------
124
+ PARSE
125
+ ----------------------------------------------------------- */
126
+ /**
127
+ * Parses JSON string with assertion.
128
+ *
129
+ * @danger You must configure the generic argument `T`
130
+ */
131
+ export function assertParse(
132
+ input: string,
133
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
134
+ ): never;
135
+
136
+ /**
137
+ * Parses JSON string with assertion.
138
+ *
139
+ * Combines `JSON.parse()` with {@link assert}. Throws {@link TypeGuardError} when
140
+ * parsed value doesn't match type `T`.
141
+ *
142
+ * Related functions:
143
+ *
144
+ * - {@link isParse} — Returns `null` instead of throwing
145
+ * - {@link validateParse} — Returns detailed validation errors
146
+ *
147
+ * @template T Target type for parsed value
148
+ * @param input JSON string to parse
149
+ * @param errorFactory Custom error factory receiving
150
+ * {@link TypeGuardError.IProps}
151
+ * @returns Parsed value of type `T`
152
+ * @throws {TypeGuardError} When parsed value doesn't conform to type `T`
153
+ */
154
+ export function assertParse<T>(
155
+ input: string,
156
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
157
+ ): Primitive<T>;
158
+
159
+ /** @internal */
160
+ export function assertParse<T>(): Primitive<T> {
161
+ NoTransformConfigurationError("json.assertParse");
162
+ }
163
+
164
+ /**
165
+ * Parses JSON string with type checking.
166
+ *
167
+ * @danger You must configure the generic argument `T`
168
+ */
169
+ export function isParse(input: string): never;
170
+
171
+ /**
172
+ * Parses JSON string with type checking.
173
+ *
174
+ * Combines `JSON.parse()` with {@link is}. Returns `null` when parsed value
175
+ * doesn't match type `T`.
176
+ *
177
+ * Related functions:
178
+ *
179
+ * - {@link assertParse} — Throws instead of returning `null`
180
+ * - {@link validateParse} — Returns detailed validation errors
181
+ *
182
+ * @template T Target type for parsed value
183
+ * @param input JSON string to parse
184
+ * @returns Parsed value of type `T`, or `null` if invalid
185
+ */
186
+ export function isParse<T>(input: string): Primitive<T> | null;
187
+
188
+ /** @internal */
189
+ export function isParse<T>(): Primitive<T> | null {
190
+ NoTransformConfigurationError("json.isParse");
191
+ }
192
+
193
+ /**
194
+ * Parses JSON string with validation.
195
+ *
196
+ * @danger You must configure the generic argument `T`
197
+ */
198
+ export function validateParse(input: string): never;
199
+
200
+ /**
201
+ * Parses JSON string with validation.
202
+ *
203
+ * Combines `JSON.parse()` with {@link validate}. Returns
204
+ * {@link IValidation.IFailure} with all errors on mismatch, or
205
+ * {@link IValidation.ISuccess} with parsed value.
206
+ *
207
+ * Related functions:
208
+ *
209
+ * - {@link assertParse} — Throws on first error
210
+ * - {@link isParse} — Returns `null` instead of error details
211
+ *
212
+ * @template T Target type for parsed value
213
+ * @param input JSON string to parse
214
+ * @returns Validation result containing parsed value or errors
215
+ */
216
+ export function validateParse<T>(input: string): IValidation<Primitive<T>>;
217
+
218
+ /** @internal */
219
+ export function validateParse<T>(): IValidation<Primitive<T>> {
220
+ NoTransformConfigurationError("json.validateParse");
221
+ }
222
+
223
+ /* -----------------------------------------------------------
224
+ STRINGIFY
225
+ ----------------------------------------------------------- */
226
+ /**
227
+ * Converts value to JSON string (8x faster).
228
+ *
229
+ * Generates optimized JSON conversion code specific to type `T`, achieving ~8x
230
+ * faster performance than native `JSON.stringify()`.
231
+ *
232
+ * Does not validate the input. For validation, use:
233
+ *
234
+ * - {@link assertStringify} — Throws on type mismatch
235
+ * - {@link isStringify} — Returns `null` on type mismatch
236
+ * - {@link validateStringify} — Returns detailed validation errors
237
+ *
238
+ * @template T Type of input value
239
+ * @param input Value to stringify
240
+ * @returns JSON string
241
+ */
242
+ export function stringify<T>(input: T): string;
243
+
244
+ /** @internal */
245
+ export function stringify(): never {
246
+ NoTransformConfigurationError("json.stringify");
247
+ }
248
+
249
+ /**
250
+ * Converts value to JSON string with assertion (5x faster).
251
+ *
252
+ * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}
253
+ * when input doesn't match type `T`. Achieves ~5x faster performance than
254
+ * native `JSON.stringify()`.
255
+ *
256
+ * Related functions:
257
+ *
258
+ * - {@link stringify} — No validation
259
+ * - {@link isStringify} — Returns `null` instead of throwing
260
+ * - {@link validateStringify} — Returns detailed validation errors
261
+ *
262
+ * @template T Type of input value
263
+ * @param input Value to assert and stringify
264
+ * @param errorFactory Custom error factory receiving
265
+ * {@link TypeGuardError.IProps}
266
+ * @returns JSON string
267
+ * @throws {TypeGuardError} When input doesn't conform to type `T`
268
+ */
269
+ export function assertStringify<T>(
270
+ input: T,
271
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
272
+ ): string;
273
+
274
+ /**
275
+ * Converts value to JSON string with assertion (5x faster).
276
+ *
277
+ * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}
278
+ * when input doesn't match type `T`. Achieves ~5x faster performance than
279
+ * native `JSON.stringify()`.
280
+ *
281
+ * Related functions:
282
+ *
283
+ * - {@link stringify} — No validation
284
+ * - {@link isStringify} — Returns `null` instead of throwing
285
+ * - {@link validateStringify} — Returns detailed validation errors
286
+ *
287
+ * @template T Type of input value
288
+ * @param input Value to assert and stringify
289
+ * @param errorFactory Custom error factory receiving
290
+ * {@link TypeGuardError.IProps}
291
+ * @returns JSON string
292
+ * @throws {TypeGuardError} When input doesn't conform to type `T`
293
+ */
294
+ export function assertStringify<T>(
295
+ input: T,
296
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
297
+ ): unknown;
298
+
299
+ /** @internal */
300
+ export function assertStringify(): string {
301
+ NoTransformConfigurationError("json.assertStringify");
302
+ }
303
+
304
+ /**
305
+ * Converts value to JSON string with type checking (7x faster).
306
+ *
307
+ * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't
308
+ * match type `T`. Achieves ~7x faster performance than native
309
+ * `JSON.stringify()`.
310
+ *
311
+ * Related functions:
312
+ *
313
+ * - {@link stringify} — No validation
314
+ * - {@link assertStringify} — Throws instead of returning `null`
315
+ * - {@link validateStringify} — Returns detailed validation errors
316
+ *
317
+ * @template T Type of input value
318
+ * @param input Value to check and stringify
319
+ * @returns JSON string, or `null` if type check fails
320
+ */
321
+ export function isStringify<T>(input: T): string | null;
322
+
323
+ /**
324
+ * Converts value to JSON string with type checking (7x faster).
325
+ *
326
+ * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't
327
+ * match type `T`. Achieves ~7x faster performance than native
328
+ * `JSON.stringify()`.
329
+ *
330
+ * Related functions:
331
+ *
332
+ * - {@link stringify} — No validation
333
+ * - {@link assertStringify} — Throws instead of returning `null`
334
+ * - {@link validateStringify} — Returns detailed validation errors
335
+ *
336
+ * @template T Type of input value
337
+ * @param input Value to check and stringify
338
+ * @returns JSON string, or `null` if type check fails
339
+ */
340
+ export function isStringify<T>(input: unknown): string | null;
341
+
342
+ /** @internal */
343
+ export function isStringify(): string | null {
344
+ NoTransformConfigurationError("json.isStringify");
345
+ }
346
+
347
+ /**
348
+ * Converts value to JSON string with validation (5x faster).
349
+ *
350
+ * Combines {@link validate} with {@link stringify}. Returns
351
+ * {@link IValidation.IFailure} with all errors on mismatch, or
352
+ * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance
353
+ * than native `JSON.stringify()`.
354
+ *
355
+ * Related functions:
356
+ *
357
+ * - {@link stringify} — No validation
358
+ * - {@link assertStringify} — Throws on first error
359
+ * - {@link isStringify} — Returns `null` instead of error details
360
+ *
361
+ * @template T Type of input value
362
+ * @param input Value to validate and stringify
363
+ * @returns Validation result containing JSON string or errors
364
+ */
365
+ export function validateStringify<T>(input: T): IValidation<string>;
366
+
367
+ /**
368
+ * Converts value to JSON string with validation (5x faster).
369
+ *
370
+ * Combines {@link validate} with {@link stringify}. Returns
371
+ * {@link IValidation.IFailure} with all errors on mismatch, or
372
+ * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance
373
+ * than native `JSON.stringify()`.
374
+ *
375
+ * Related functions:
376
+ *
377
+ * - {@link stringify} — No validation
378
+ * - {@link assertStringify} — Throws on first error
379
+ * - {@link isStringify} — Returns `null` instead of error details
380
+ *
381
+ * @template T Type of input value
382
+ * @param input Value to validate and stringify
383
+ * @returns Validation result containing JSON string or errors
384
+ */
385
+ export function validateStringify<T>(input: unknown): IValidation<string>;
386
+
387
+ /** @internal */
388
+ export function validateStringify(): IValidation<string> {
389
+ NoTransformConfigurationError("json.validateStringify");
390
+ }
391
+
392
+ /* -----------------------------------------------------------
393
+ FACTORY FUNCTIONS
394
+ ----------------------------------------------------------- */
395
+ /**
396
+ * Creates reusable {@link isParse} function.
397
+ *
398
+ * @danger You must configure the generic argument `T`
399
+ */
400
+ export function createIsParse(): never;
401
+
402
+ /**
403
+ * Creates reusable {@link isParse} function.
404
+ *
405
+ * @template T Target type for parsed value
406
+ * @returns Reusable parser function
407
+ */
408
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null;
409
+
410
+ /** @internal */
411
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null {
412
+ NoTransformConfigurationError("json.createIsParse");
413
+ }
414
+
415
+ /**
416
+ * Creates reusable {@link assertParse} function.
417
+ *
418
+ * @danger You must configure the generic argument `T`
419
+ */
420
+ export function createAssertParse(
421
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
422
+ ): never;
423
+
424
+ /**
425
+ * Creates reusable {@link assertParse} function.
426
+ *
427
+ * @template T Target type for parsed value
428
+ * @param errorFactory Custom error factory receiving
429
+ * {@link TypeGuardError.IProps}
430
+ * @returns Reusable parser function
431
+ */
432
+ export function createAssertParse<T>(
433
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
434
+ ): (input: string) => Primitive<T>;
435
+
436
+ /** @internal */
437
+ export function createAssertParse<T>(): (input: string) => Primitive<T> {
438
+ NoTransformConfigurationError("json.createAssertParse");
439
+ }
440
+
441
+ /**
442
+ * Creates reusable {@link validateParse} function.
443
+ *
444
+ * @danger You must configure the generic argument `T`
445
+ */
446
+ export function createValidateParse(): never;
447
+
448
+ /**
449
+ * Creates reusable {@link validateParse} function.
450
+ *
451
+ * @template T Target type for parsed value
452
+ * @returns Reusable parser function
453
+ */
454
+ export function createValidateParse<T>(): (
455
+ input: string,
456
+ ) => IValidation<Primitive<T>>;
457
+
458
+ /** @internal */
459
+ export function createValidateParse<T>(): (
460
+ input: string,
461
+ ) => IValidation<Primitive<T>> {
462
+ NoTransformConfigurationError("json.createValidateParse");
463
+ }
464
+
465
+ /**
466
+ * Creates reusable {@link stringify} function.
467
+ *
468
+ * @danger You must configure the generic argument `T`
469
+ */
470
+ export function createStringify(): never;
471
+
472
+ /**
473
+ * Creates reusable {@link stringify} function.
474
+ *
475
+ * @template T Type of input value
476
+ * @returns Reusable stringify function
477
+ */
478
+ export function createStringify<T>(): (input: T) => string;
479
+
480
+ /** @internal */
481
+ export function createStringify<T>(): (input: T) => string {
482
+ NoTransformConfigurationError("json.createStringify");
483
+ }
484
+
485
+ /**
486
+ * Creates reusable {@link assertStringify} function.
487
+ *
488
+ * @danger You must configure the generic argument `T`
489
+ */
490
+ export function createAssertStringify(
491
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
492
+ ): never;
493
+
494
+ /**
495
+ * Creates reusable {@link assertStringify} function.
496
+ *
497
+ * @template T Type of input value
498
+ * @param errorFactory Custom error factory receiving
499
+ * {@link TypeGuardError.IProps}
500
+ * @returns Reusable stringify function
501
+ */
502
+ export function createAssertStringify<T>(
503
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
504
+ ): (input: unknown) => string;
505
+
506
+ /** @internal */
507
+ export function createAssertStringify(): (input: unknown) => string {
508
+ NoTransformConfigurationError("json.createAssertStringify");
509
+ }
510
+
511
+ /**
512
+ * Creates reusable {@link isStringify} function.
513
+ *
514
+ * @danger You must configure the generic argument `T`
515
+ */
516
+ export function createIsStringify(): never;
517
+
518
+ /**
519
+ * Creates reusable {@link isStringify} function.
520
+ *
521
+ * @template T Type of input value
522
+ * @returns Reusable stringify function
523
+ */
524
+ export function createIsStringify<T>(): (input: unknown) => string | null;
525
+
526
+ /** @internal */
527
+ export function createIsStringify(): (input: unknown) => string | null {
528
+ NoTransformConfigurationError("json.createIsStringify");
529
+ }
530
+
531
+ /**
532
+ * Creates reusable {@link validateStringify} function.
533
+ *
534
+ * @danger You must configure the generic argument `T`
535
+ */
536
+ export function createValidateStringify(): never;
537
+
538
+ /**
539
+ * Creates reusable {@link validateStringify} function.
540
+ *
541
+ * @template T Type of input value
542
+ * @returns Reusable stringify function
543
+ */
544
+ export function createValidateStringify<T>(): (
545
+ input: unknown,
546
+ ) => IValidation<string>;
547
+
548
+ /** @internal */
549
+ export function createValidateStringify(): (
550
+ input: unknown,
551
+ ) => IValidation<string> {
552
+ NoTransformConfigurationError("json.createValidateStringify");
553
+ }