@typia/interface 12.0.0-dev.20260225

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 (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/lib/http/IHttpConnection.d.ts +163 -0
  4. package/lib/http/IHttpConnection.js +4 -0
  5. package/lib/http/IHttpConnection.js.map +1 -0
  6. package/lib/http/IHttpLlmApplication.d.ts +73 -0
  7. package/lib/http/IHttpLlmApplication.js +3 -0
  8. package/lib/http/IHttpLlmApplication.js.map +1 -0
  9. package/lib/http/IHttpLlmController.d.ts +86 -0
  10. package/lib/http/IHttpLlmController.js +3 -0
  11. package/lib/http/IHttpLlmController.js.map +1 -0
  12. package/lib/http/IHttpLlmFunction.d.ts +79 -0
  13. package/lib/http/IHttpLlmFunction.js +3 -0
  14. package/lib/http/IHttpLlmFunction.js.map +1 -0
  15. package/lib/http/IHttpMigrateApplication.d.ts +42 -0
  16. package/lib/http/IHttpMigrateApplication.js +3 -0
  17. package/lib/http/IHttpMigrateApplication.js.map +1 -0
  18. package/lib/http/IHttpMigrateRoute.d.ts +121 -0
  19. package/lib/http/IHttpMigrateRoute.js +3 -0
  20. package/lib/http/IHttpMigrateRoute.js.map +1 -0
  21. package/lib/http/IHttpResponse.d.ts +40 -0
  22. package/lib/http/IHttpResponse.js +3 -0
  23. package/lib/http/IHttpResponse.js.map +1 -0
  24. package/lib/http/index.d.ts +7 -0
  25. package/lib/http/index.js +24 -0
  26. package/lib/http/index.js.map +1 -0
  27. package/lib/index.d.ts +8 -0
  28. package/lib/index.js +48 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/metadata/IJsDocTagInfo.d.ts +23 -0
  31. package/lib/metadata/IJsDocTagInfo.js +3 -0
  32. package/lib/metadata/IJsDocTagInfo.js.map +1 -0
  33. package/lib/metadata/IMetadataComponents.d.ts +20 -0
  34. package/lib/metadata/IMetadataComponents.js +3 -0
  35. package/lib/metadata/IMetadataComponents.js.map +1 -0
  36. package/lib/metadata/IMetadataSchema.d.ts +219 -0
  37. package/lib/metadata/IMetadataSchema.js +3 -0
  38. package/lib/metadata/IMetadataSchema.js.map +1 -0
  39. package/lib/metadata/IMetadataSchemaCollection.d.ts +18 -0
  40. package/lib/metadata/IMetadataSchemaCollection.js +3 -0
  41. package/lib/metadata/IMetadataSchemaCollection.js.map +1 -0
  42. package/lib/metadata/IMetadataSchemaUnit.d.ts +18 -0
  43. package/lib/metadata/IMetadataSchemaUnit.js +3 -0
  44. package/lib/metadata/IMetadataSchemaUnit.js.map +1 -0
  45. package/lib/metadata/IMetadataTypeTag.d.ts +28 -0
  46. package/lib/metadata/IMetadataTypeTag.js +3 -0
  47. package/lib/metadata/IMetadataTypeTag.js.map +1 -0
  48. package/lib/metadata/index.d.ts +6 -0
  49. package/lib/metadata/index.js +23 -0
  50. package/lib/metadata/index.js.map +1 -0
  51. package/lib/openapi/OpenApi.d.ts +454 -0
  52. package/lib/openapi/OpenApi.js +3 -0
  53. package/lib/openapi/OpenApi.js.map +1 -0
  54. package/lib/openapi/OpenApiV3.d.ts +420 -0
  55. package/lib/openapi/OpenApiV3.js +3 -0
  56. package/lib/openapi/OpenApiV3.js.map +1 -0
  57. package/lib/openapi/OpenApiV3_1.d.ts +463 -0
  58. package/lib/openapi/OpenApiV3_1.js +3 -0
  59. package/lib/openapi/OpenApiV3_1.js.map +1 -0
  60. package/lib/openapi/SwaggerV2.d.ts +343 -0
  61. package/lib/openapi/SwaggerV2.js +3 -0
  62. package/lib/openapi/SwaggerV2.js.map +1 -0
  63. package/lib/openapi/index.d.ts +4 -0
  64. package/lib/openapi/index.js +21 -0
  65. package/lib/openapi/index.js.map +1 -0
  66. package/lib/protobuf/ProtobufWire.d.ts +46 -0
  67. package/lib/protobuf/ProtobufWire.js +3 -0
  68. package/lib/protobuf/ProtobufWire.js.map +1 -0
  69. package/lib/protobuf/index.d.ts +1 -0
  70. package/lib/protobuf/index.js +18 -0
  71. package/lib/protobuf/index.js.map +1 -0
  72. package/lib/schema/IJsonSchemaApplication.d.ts +232 -0
  73. package/lib/schema/IJsonSchemaApplication.js +3 -0
  74. package/lib/schema/IJsonSchemaApplication.js.map +1 -0
  75. package/lib/schema/IJsonSchemaAttribute.d.ts +152 -0
  76. package/lib/schema/IJsonSchemaAttribute.js +3 -0
  77. package/lib/schema/IJsonSchemaAttribute.js.map +1 -0
  78. package/lib/schema/IJsonSchemaCollection.d.ts +109 -0
  79. package/lib/schema/IJsonSchemaCollection.js +3 -0
  80. package/lib/schema/IJsonSchemaCollection.js.map +1 -0
  81. package/lib/schema/IJsonSchemaTransformError.d.ts +81 -0
  82. package/lib/schema/IJsonSchemaTransformError.js +3 -0
  83. package/lib/schema/IJsonSchemaTransformError.js.map +1 -0
  84. package/lib/schema/IJsonSchemaUnit.d.ts +106 -0
  85. package/lib/schema/IJsonSchemaUnit.js +3 -0
  86. package/lib/schema/IJsonSchemaUnit.js.map +1 -0
  87. package/lib/schema/ILlmApplication.d.ts +95 -0
  88. package/lib/schema/ILlmApplication.js +3 -0
  89. package/lib/schema/ILlmApplication.js.map +1 -0
  90. package/lib/schema/ILlmController.d.ts +53 -0
  91. package/lib/schema/ILlmController.js +3 -0
  92. package/lib/schema/ILlmController.js.map +1 -0
  93. package/lib/schema/ILlmFunction.d.ts +134 -0
  94. package/lib/schema/ILlmFunction.js +3 -0
  95. package/lib/schema/ILlmFunction.js.map +1 -0
  96. package/lib/schema/ILlmSchema.d.ts +412 -0
  97. package/lib/schema/ILlmSchema.js +3 -0
  98. package/lib/schema/ILlmSchema.js.map +1 -0
  99. package/lib/schema/IResult.d.ts +81 -0
  100. package/lib/schema/IResult.js +3 -0
  101. package/lib/schema/IResult.js.map +1 -0
  102. package/lib/schema/IValidation.d.ts +123 -0
  103. package/lib/schema/IValidation.js +3 -0
  104. package/lib/schema/IValidation.js.map +1 -0
  105. package/lib/schema/index.d.ts +11 -0
  106. package/lib/schema/index.js +28 -0
  107. package/lib/schema/index.js.map +1 -0
  108. package/lib/tags/Constant.d.ts +44 -0
  109. package/lib/tags/Constant.js +3 -0
  110. package/lib/tags/Constant.js.map +1 -0
  111. package/lib/tags/ContentMediaType.d.ts +39 -0
  112. package/lib/tags/ContentMediaType.js +3 -0
  113. package/lib/tags/ContentMediaType.js.map +1 -0
  114. package/lib/tags/Default.d.ts +42 -0
  115. package/lib/tags/Default.js +3 -0
  116. package/lib/tags/Default.js.map +1 -0
  117. package/lib/tags/Example.d.ts +38 -0
  118. package/lib/tags/Example.js +3 -0
  119. package/lib/tags/Example.js.map +1 -0
  120. package/lib/tags/Examples.d.ts +44 -0
  121. package/lib/tags/Examples.js +3 -0
  122. package/lib/tags/Examples.js.map +1 -0
  123. package/lib/tags/ExclusiveMaximum.d.ts +39 -0
  124. package/lib/tags/ExclusiveMaximum.js +3 -0
  125. package/lib/tags/ExclusiveMaximum.js.map +1 -0
  126. package/lib/tags/ExclusiveMinimum.d.ts +39 -0
  127. package/lib/tags/ExclusiveMinimum.js +3 -0
  128. package/lib/tags/ExclusiveMinimum.js.map +1 -0
  129. package/lib/tags/Format.d.ts +43 -0
  130. package/lib/tags/Format.js +3 -0
  131. package/lib/tags/Format.js.map +1 -0
  132. package/lib/tags/JsonSchemaPlugin.d.ts +44 -0
  133. package/lib/tags/JsonSchemaPlugin.js +3 -0
  134. package/lib/tags/JsonSchemaPlugin.js.map +1 -0
  135. package/lib/tags/MaxItems.d.ts +38 -0
  136. package/lib/tags/MaxItems.js +3 -0
  137. package/lib/tags/MaxItems.js.map +1 -0
  138. package/lib/tags/MaxLength.d.ts +36 -0
  139. package/lib/tags/MaxLength.js +3 -0
  140. package/lib/tags/MaxLength.js.map +1 -0
  141. package/lib/tags/Maximum.d.ts +41 -0
  142. package/lib/tags/Maximum.js +3 -0
  143. package/lib/tags/Maximum.js.map +1 -0
  144. package/lib/tags/MinItems.d.ts +38 -0
  145. package/lib/tags/MinItems.js +3 -0
  146. package/lib/tags/MinItems.js.map +1 -0
  147. package/lib/tags/MinLength.d.ts +36 -0
  148. package/lib/tags/MinLength.js +3 -0
  149. package/lib/tags/MinLength.js.map +1 -0
  150. package/lib/tags/Minimum.d.ts +41 -0
  151. package/lib/tags/Minimum.js +3 -0
  152. package/lib/tags/Minimum.js.map +1 -0
  153. package/lib/tags/MultipleOf.d.ts +49 -0
  154. package/lib/tags/MultipleOf.js +3 -0
  155. package/lib/tags/MultipleOf.js.map +1 -0
  156. package/lib/tags/Pattern.d.ts +51 -0
  157. package/lib/tags/Pattern.js +3 -0
  158. package/lib/tags/Pattern.js.map +1 -0
  159. package/lib/tags/Sequence.d.ts +42 -0
  160. package/lib/tags/Sequence.js +3 -0
  161. package/lib/tags/Sequence.js.map +1 -0
  162. package/lib/tags/TagBase.d.ts +109 -0
  163. package/lib/tags/TagBase.js +3 -0
  164. package/lib/tags/TagBase.js.map +1 -0
  165. package/lib/tags/Type.d.ts +53 -0
  166. package/lib/tags/Type.js +3 -0
  167. package/lib/tags/Type.js.map +1 -0
  168. package/lib/tags/UniqueItems.d.ts +41 -0
  169. package/lib/tags/UniqueItems.js +3 -0
  170. package/lib/tags/UniqueItems.js.map +1 -0
  171. package/lib/tags/index.d.ts +21 -0
  172. package/lib/tags/index.js +38 -0
  173. package/lib/tags/index.js.map +1 -0
  174. package/lib/typings/AssertionGuard.d.ts +12 -0
  175. package/lib/typings/AssertionGuard.js +3 -0
  176. package/lib/typings/AssertionGuard.js.map +1 -0
  177. package/lib/typings/Atomic.d.ts +19 -0
  178. package/lib/typings/Atomic.js +3 -0
  179. package/lib/typings/Atomic.js.map +1 -0
  180. package/lib/typings/CamelCase.d.ts +26 -0
  181. package/lib/typings/CamelCase.js +3 -0
  182. package/lib/typings/CamelCase.js.map +1 -0
  183. package/lib/typings/ClassProperties.d.ts +14 -0
  184. package/lib/typings/ClassProperties.js +3 -0
  185. package/lib/typings/ClassProperties.js.map +1 -0
  186. package/lib/typings/OmitNever.d.ts +11 -0
  187. package/lib/typings/OmitNever.js +3 -0
  188. package/lib/typings/OmitNever.js.map +1 -0
  189. package/lib/typings/PascalCase.d.ts +25 -0
  190. package/lib/typings/PascalCase.js +3 -0
  191. package/lib/typings/PascalCase.js.map +1 -0
  192. package/lib/typings/Primitive.d.ts +29 -0
  193. package/lib/typings/Primitive.js +3 -0
  194. package/lib/typings/Primitive.js.map +1 -0
  195. package/lib/typings/ProtobufAtomic.d.ts +15 -0
  196. package/lib/typings/ProtobufAtomic.js +3 -0
  197. package/lib/typings/ProtobufAtomic.js.map +1 -0
  198. package/lib/typings/Resolved.d.ts +23 -0
  199. package/lib/typings/Resolved.js +3 -0
  200. package/lib/typings/Resolved.js.map +1 -0
  201. package/lib/typings/SnakeCase.d.ts +31 -0
  202. package/lib/typings/SnakeCase.js +3 -0
  203. package/lib/typings/SnakeCase.js.map +1 -0
  204. package/lib/typings/SpecialFields.d.ts +13 -0
  205. package/lib/typings/SpecialFields.js +3 -0
  206. package/lib/typings/SpecialFields.js.map +1 -0
  207. package/lib/typings/ValidationPipe.d.ts +18 -0
  208. package/lib/typings/ValidationPipe.js +3 -0
  209. package/lib/typings/ValidationPipe.js.map +1 -0
  210. package/lib/typings/index.d.ts +12 -0
  211. package/lib/typings/index.js +29 -0
  212. package/lib/typings/index.js.map +1 -0
  213. package/lib/typings/internal/Equal.d.ts +11 -0
  214. package/lib/typings/internal/Equal.js +3 -0
  215. package/lib/typings/internal/Equal.js.map +1 -0
  216. package/lib/typings/internal/IsTuple.d.ts +13 -0
  217. package/lib/typings/internal/IsTuple.js +3 -0
  218. package/lib/typings/internal/IsTuple.js.map +1 -0
  219. package/lib/typings/internal/NativeClass.d.ts +9 -0
  220. package/lib/typings/internal/NativeClass.js +3 -0
  221. package/lib/typings/internal/NativeClass.js.map +1 -0
  222. package/lib/typings/internal/ValueOf.d.ts +15 -0
  223. package/lib/typings/internal/ValueOf.js +3 -0
  224. package/lib/typings/internal/ValueOf.js.map +1 -0
  225. package/lib/utils/IRandomGenerator.d.ts +68 -0
  226. package/lib/utils/IRandomGenerator.js +3 -0
  227. package/lib/utils/IRandomGenerator.js.map +1 -0
  228. package/lib/utils/IReadableURLSearchParams.d.ts +22 -0
  229. package/lib/utils/IReadableURLSearchParams.js +3 -0
  230. package/lib/utils/IReadableURLSearchParams.js.map +1 -0
  231. package/lib/utils/index.d.ts +2 -0
  232. package/lib/utils/index.js +19 -0
  233. package/lib/utils/index.js.map +1 -0
  234. package/package.json +79 -0
  235. package/src/http/IHttpConnection.ts +200 -0
  236. package/src/http/IHttpLlmApplication.ts +83 -0
  237. package/src/http/IHttpLlmController.ts +96 -0
  238. package/src/http/IHttpLlmFunction.ts +93 -0
  239. package/src/http/IHttpMigrateApplication.ts +48 -0
  240. package/src/http/IHttpMigrateRoute.ts +165 -0
  241. package/src/http/IHttpResponse.ts +42 -0
  242. package/src/http/index.ts +7 -0
  243. package/src/index.ts +9 -0
  244. package/src/metadata/IJsDocTagInfo.ts +25 -0
  245. package/src/metadata/IMetadataComponents.ts +24 -0
  246. package/src/metadata/IMetadataSchema.ts +293 -0
  247. package/src/metadata/IMetadataSchemaCollection.ts +20 -0
  248. package/src/metadata/IMetadataSchemaUnit.ts +20 -0
  249. package/src/metadata/IMetadataTypeTag.ts +39 -0
  250. package/src/metadata/index.ts +6 -0
  251. package/src/openapi/OpenApi.ts +643 -0
  252. package/src/openapi/OpenApiV3.ts +655 -0
  253. package/src/openapi/OpenApiV3_1.ts +735 -0
  254. package/src/openapi/SwaggerV2.ts +559 -0
  255. package/src/openapi/index.ts +4 -0
  256. package/src/protobuf/ProtobufWire.ts +51 -0
  257. package/src/protobuf/index.ts +1 -0
  258. package/src/schema/IJsonSchemaApplication.ts +274 -0
  259. package/src/schema/IJsonSchemaAttribute.ts +158 -0
  260. package/src/schema/IJsonSchemaCollection.ts +123 -0
  261. package/src/schema/IJsonSchemaTransformError.ts +86 -0
  262. package/src/schema/IJsonSchemaUnit.ts +120 -0
  263. package/src/schema/ILlmApplication.ts +103 -0
  264. package/src/schema/ILlmController.ts +57 -0
  265. package/src/schema/ILlmFunction.ts +144 -0
  266. package/src/schema/ILlmSchema.ts +484 -0
  267. package/src/schema/IResult.ts +84 -0
  268. package/src/schema/IValidation.ts +134 -0
  269. package/src/schema/index.ts +13 -0
  270. package/src/tags/Constant.ts +49 -0
  271. package/src/tags/ContentMediaType.ts +40 -0
  272. package/src/tags/Default.ts +50 -0
  273. package/src/tags/Example.ts +48 -0
  274. package/src/tags/Examples.ts +50 -0
  275. package/src/tags/ExclusiveMaximum.ts +46 -0
  276. package/src/tags/ExclusiveMinimum.ts +46 -0
  277. package/src/tags/Format.ts +76 -0
  278. package/src/tags/JsonSchemaPlugin.ts +45 -0
  279. package/src/tags/MaxItems.ts +39 -0
  280. package/src/tags/MaxLength.ts +37 -0
  281. package/src/tags/Maximum.ts +44 -0
  282. package/src/tags/MinItems.ts +39 -0
  283. package/src/tags/MinLength.ts +37 -0
  284. package/src/tags/Minimum.ts +44 -0
  285. package/src/tags/MultipleOf.ts +54 -0
  286. package/src/tags/Pattern.ts +59 -0
  287. package/src/tags/Sequence.ts +43 -0
  288. package/src/tags/TagBase.ts +131 -0
  289. package/src/tags/Type.ts +70 -0
  290. package/src/tags/UniqueItems.ts +44 -0
  291. package/src/tags/index.ts +21 -0
  292. package/src/typings/AssertionGuard.ts +12 -0
  293. package/src/typings/Atomic.ts +21 -0
  294. package/src/typings/CamelCase.ts +75 -0
  295. package/src/typings/ClassProperties.ts +15 -0
  296. package/src/typings/OmitNever.ts +12 -0
  297. package/src/typings/PascalCase.ts +71 -0
  298. package/src/typings/Primitive.ts +71 -0
  299. package/src/typings/ProtobufAtomic.ts +30 -0
  300. package/src/typings/Resolved.ts +58 -0
  301. package/src/typings/SnakeCase.ts +126 -0
  302. package/src/typings/SpecialFields.ts +13 -0
  303. package/src/typings/ValidationPipe.ts +20 -0
  304. package/src/typings/index.ts +13 -0
  305. package/src/typings/internal/Equal.ts +14 -0
  306. package/src/typings/internal/IsTuple.ts +17 -0
  307. package/src/typings/internal/NativeClass.ts +31 -0
  308. package/src/typings/internal/ValueOf.ts +29 -0
  309. package/src/utils/IRandomGenerator.ts +105 -0
  310. package/src/utils/IReadableURLSearchParams.ts +25 -0
  311. package/src/utils/index.ts +2 -0
@@ -0,0 +1,484 @@
1
+ import { tags } from "../index";
2
+ import { IJsonSchemaAttribute } from "./IJsonSchemaAttribute";
3
+
4
+ /**
5
+ * Type schema for LLM function calling.
6
+ *
7
+ * `ILlmSchema` is a JSON Schema subset designed for LLM function calling
8
+ * compatibility. Most LLMs (OpenAI GPT, Anthropic Claude, Google Gemini, etc.)
9
+ * do not fully support JSON Schema, so this simplified schema omits unsupported
10
+ * features like tuples, `const`, and mixed union types.
11
+ *
12
+ * Generated by `typia.llm.schema<T>()` for single types or included in
13
+ * {@link ILlmApplication} via `typia.llm.application<Class>()`. Shared type
14
+ * definitions use `$defs` with `$ref` references to reduce duplication and
15
+ * handle recursive structures.
16
+ *
17
+ * Set {@link ILlmSchema.IConfig.strict} to `true` for OpenAI's structured output
18
+ * mode, which requires all properties to be `required` and
19
+ * `additionalProperties: false`.
20
+ *
21
+ * @author Jeongho Nam - https://github.com/samchon
22
+ */
23
+ export type ILlmSchema =
24
+ | ILlmSchema.IBoolean
25
+ | ILlmSchema.IInteger
26
+ | ILlmSchema.INumber
27
+ | ILlmSchema.IString
28
+ | ILlmSchema.IArray
29
+ | ILlmSchema.IObject
30
+ | ILlmSchema.IReference
31
+ | ILlmSchema.IAnyOf
32
+ | ILlmSchema.INull
33
+ | ILlmSchema.IUnknown;
34
+ export namespace ILlmSchema {
35
+ /**
36
+ * Configuration options for LLM schema generation.
37
+ *
38
+ * Controls how TypeScript types are converted to LLM-compatible JSON schemas.
39
+ * These settings affect reference handling and OpenAI structured output
40
+ * compatibility.
41
+ */
42
+ export interface IConfig {
43
+ /**
44
+ * Whether to allow `$ref` references everywhere.
45
+ *
46
+ * When `false`, references are inlined except for recursive types.
47
+ * References reduce token cost but may cause hallucination.
48
+ *
49
+ * @default true
50
+ */
51
+ reference: boolean;
52
+
53
+ /**
54
+ * Whether to enable strict mode (OpenAI structured output).
55
+ *
56
+ * When `true`, all properties become required and `additionalProperties` is
57
+ * forced to `false`.
58
+ *
59
+ * @default false
60
+ */
61
+ strict: boolean;
62
+ }
63
+
64
+ /**
65
+ * Function parameters schema with shared type definitions.
66
+ *
67
+ * Extends the object schema to include a `$defs` map for named type
68
+ * definitions that can be referenced via `$ref`. This structure allows
69
+ * recursive types and reduces schema duplication.
70
+ *
71
+ * The `additionalProperties` is always `false` for parameters to ensure
72
+ * strict argument validation and prevent unexpected properties.
73
+ */
74
+ export interface IParameters extends Omit<IObject, "additionalProperties"> {
75
+ /**
76
+ * Named schema definitions for reference.
77
+ *
78
+ * Contains type definitions that can be referenced throughout the schema
79
+ * using `$ref: "#/$defs/TypeName"`. Essential for recursive types and
80
+ * shared structures.
81
+ */
82
+ $defs: Record<string, ILlmSchema>;
83
+
84
+ /**
85
+ * Whether additional properties are allowed.
86
+ *
87
+ * Always `false` for function parameters to ensure strict type checking.
88
+ * This prevents LLMs from hallucinating extra properties.
89
+ */
90
+ additionalProperties: false;
91
+ }
92
+
93
+ /**
94
+ * Boolean type schema.
95
+ *
96
+ * Represents a JSON Schema boolean type with optional enum constraints and
97
+ * default value. Used for true/false parameters and flags.
98
+ */
99
+ export interface IBoolean extends IJsonSchemaAttribute.IBoolean {
100
+ /**
101
+ * Allowed boolean values.
102
+ *
103
+ * Restricts the value to specific boolean literals. Typically unused since
104
+ * booleans only have two possible values, but supported for consistency
105
+ * with other types.
106
+ */
107
+ enum?: Array<boolean>;
108
+
109
+ /**
110
+ * Default value when not provided.
111
+ *
112
+ * The boolean value to use when the LLM omits this parameter.
113
+ */
114
+ default?: boolean;
115
+ }
116
+
117
+ /**
118
+ * Integer type schema.
119
+ *
120
+ * Represents a JSON Schema integer type with numeric constraints. Maps to
121
+ * TypeScript `number` with integer validation. Supports range constraints,
122
+ * enum restrictions, and divisibility checks.
123
+ */
124
+ export interface IInteger extends IJsonSchemaAttribute.IInteger {
125
+ /**
126
+ * Allowed integer values.
127
+ *
128
+ * Restricts the value to specific integer literals. Useful for representing
129
+ * enum-like integer codes or limited value sets.
130
+ */
131
+ enum?: Array<number & tags.Type<"int64">>;
132
+
133
+ /**
134
+ * Default value when not provided.
135
+ *
136
+ * The integer value to use when the LLM omits this parameter.
137
+ */
138
+ default?: number & tags.Type<"int64">;
139
+
140
+ /**
141
+ * Minimum value (inclusive).
142
+ *
143
+ * The value must be greater than or equal to this number.
144
+ */
145
+ minimum?: number & tags.Type<"int64">;
146
+
147
+ /**
148
+ * Maximum value (inclusive).
149
+ *
150
+ * The value must be less than or equal to this number.
151
+ */
152
+ maximum?: number & tags.Type<"int64">;
153
+
154
+ /**
155
+ * Exclusive minimum value.
156
+ *
157
+ * The value must be strictly greater than this number.
158
+ */
159
+ exclusiveMinimum?: number & tags.Type<"int64">;
160
+
161
+ /**
162
+ * Exclusive maximum value.
163
+ *
164
+ * The value must be strictly less than this number.
165
+ */
166
+ exclusiveMaximum?: number & tags.Type<"int64">;
167
+
168
+ /**
169
+ * Value must be divisible by this number.
170
+ *
171
+ * Used for constraints like "must be even" (multipleOf: 2) or "must be a
172
+ * multiple of 100" (multipleOf: 100).
173
+ */
174
+ multipleOf?: number & tags.Type<"uint64"> & tags.ExclusiveMinimum<0>;
175
+ }
176
+
177
+ /**
178
+ * Number (floating-point) type schema.
179
+ *
180
+ * Represents a JSON Schema number type for floating-point values. Maps to
181
+ * TypeScript `number` type. Supports range constraints, enum restrictions,
182
+ * and precision checks via multipleOf.
183
+ */
184
+ export interface INumber extends IJsonSchemaAttribute.INumber {
185
+ /**
186
+ * Allowed numeric values.
187
+ *
188
+ * Restricts the value to specific number literals. Useful for representing
189
+ * specific valid values like percentages or rates.
190
+ */
191
+ enum?: Array<number>;
192
+
193
+ /**
194
+ * Default value when not provided.
195
+ *
196
+ * The number to use when the LLM omits this parameter.
197
+ */
198
+ default?: number;
199
+
200
+ /**
201
+ * Minimum value (inclusive).
202
+ *
203
+ * The value must be greater than or equal to this number.
204
+ */
205
+ minimum?: number;
206
+
207
+ /**
208
+ * Maximum value (inclusive).
209
+ *
210
+ * The value must be less than or equal to this number.
211
+ */
212
+ maximum?: number;
213
+
214
+ /**
215
+ * Exclusive minimum value.
216
+ *
217
+ * The value must be strictly greater than this number.
218
+ */
219
+ exclusiveMinimum?: number;
220
+
221
+ /**
222
+ * Exclusive maximum value.
223
+ *
224
+ * The value must be strictly less than this number.
225
+ */
226
+ exclusiveMaximum?: number;
227
+
228
+ /**
229
+ * Value must be divisible by this number.
230
+ *
231
+ * Useful for decimal precision constraints like "two decimal places"
232
+ * (multipleOf: 0.01) or currency amounts (multipleOf: 0.01).
233
+ */
234
+ multipleOf?: number & tags.ExclusiveMinimum<0>;
235
+ }
236
+
237
+ /**
238
+ * String type schema.
239
+ *
240
+ * Represents a JSON Schema string type with format validation, pattern
241
+ * matching, and length constraints. Maps to TypeScript `string` type with
242
+ * optional semantic format annotations.
243
+ */
244
+ export interface IString extends IJsonSchemaAttribute.IString {
245
+ /**
246
+ * Allowed string values.
247
+ *
248
+ * Restricts the value to specific string literals. Maps directly to
249
+ * TypeScript string literal union types.
250
+ */
251
+ enum?: Array<string>;
252
+
253
+ /**
254
+ * Default value when not provided.
255
+ *
256
+ * The string to use when the LLM omits this parameter.
257
+ */
258
+ default?: string;
259
+
260
+ /**
261
+ * Semantic format specifier.
262
+ *
263
+ * Indicates the string represents a specific format like email, UUID, or
264
+ * date-time. LLMs may use this to generate appropriate values. Common
265
+ * formats include "email", "uri", "uuid", "date-time".
266
+ */
267
+ format?:
268
+ | "binary"
269
+ | "byte"
270
+ | "password"
271
+ | "regex"
272
+ | "uuid"
273
+ | "email"
274
+ | "hostname"
275
+ | "idn-email"
276
+ | "idn-hostname"
277
+ | "iri"
278
+ | "iri-reference"
279
+ | "ipv4"
280
+ | "ipv6"
281
+ | "uri"
282
+ | "uri-reference"
283
+ | "uri-template"
284
+ | "url"
285
+ | "date-time"
286
+ | "date"
287
+ | "time"
288
+ | "duration"
289
+ | "json-pointer"
290
+ | "relative-json-pointer"
291
+ | (string & {});
292
+
293
+ /**
294
+ * Regular expression pattern for validation.
295
+ *
296
+ * The string must match this regex pattern. Note that LLMs may struggle
297
+ * with complex regex patterns; simple patterns work best.
298
+ */
299
+ pattern?: string;
300
+
301
+ /**
302
+ * MIME type of the string content.
303
+ *
304
+ * Indicates the content type when the string contains encoded binary data,
305
+ * such as "application/json" or "image/png".
306
+ */
307
+ contentMediaType?: string;
308
+
309
+ /**
310
+ * Minimum string length.
311
+ *
312
+ * The string must have at least this many characters.
313
+ */
314
+ minLength?: number & tags.Type<"uint64">;
315
+
316
+ /**
317
+ * Maximum string length.
318
+ *
319
+ * The string must have at most this many characters.
320
+ */
321
+ maxLength?: number & tags.Type<"uint64">;
322
+ }
323
+
324
+ /**
325
+ * Array type schema.
326
+ *
327
+ * Represents a JSON Schema array type with item type validation and size
328
+ * constraints. Maps to TypeScript `T[]` or `Array<T>` types. Note: Tuple
329
+ * types are not supported by LLM schemas.
330
+ */
331
+ export interface IArray extends IJsonSchemaAttribute.IArray {
332
+ /**
333
+ * Schema for array elements.
334
+ *
335
+ * All elements in the array must conform to this schema. For heterogeneous
336
+ * arrays, use an `anyOf` schema.
337
+ */
338
+ items: ILlmSchema;
339
+
340
+ /**
341
+ * Whether elements must be unique.
342
+ *
343
+ * When `true`, no two elements may be equal. Maps to TypeScript `Set<T>`
344
+ * semantics but represented as an array.
345
+ */
346
+ uniqueItems?: boolean;
347
+
348
+ /**
349
+ * Minimum number of elements.
350
+ *
351
+ * The array must contain at least this many items.
352
+ */
353
+ minItems?: number & tags.Type<"uint64">;
354
+
355
+ /**
356
+ * Maximum number of elements.
357
+ *
358
+ * The array must contain at most this many items.
359
+ */
360
+ maxItems?: number & tags.Type<"uint64">;
361
+ }
362
+
363
+ /**
364
+ * Object type schema.
365
+ *
366
+ * Represents a JSON Schema object type with named properties. Maps to
367
+ * TypeScript interface or object type. Supports required property
368
+ * declarations and dynamic additional properties.
369
+ */
370
+ export interface IObject extends IJsonSchemaAttribute.IObject {
371
+ /**
372
+ * Property name to schema mapping.
373
+ *
374
+ * Defines the type of each named property on the object. All properties are
375
+ * defined here regardless of whether they are required or optional.
376
+ */
377
+ properties: Record<string, ILlmSchema>;
378
+
379
+ /**
380
+ * Schema for dynamic/additional properties.
381
+ *
382
+ * - `false` (default): No additional properties allowed
383
+ * - `true`: Any additional properties allowed
384
+ * - Schema: Additional properties must match this schema
385
+ *
386
+ * Note: ChatGPT and Gemini do not support `additionalProperties`. Use
387
+ * {@link ILlmSchema.IConfig.strict} mode for OpenAI compatibility.
388
+ */
389
+ additionalProperties?: ILlmSchema | boolean;
390
+
391
+ /**
392
+ * List of required property names.
393
+ *
394
+ * Properties in this array must be present in the object. In strict mode,
395
+ * all properties become required automatically.
396
+ */
397
+ required: string[];
398
+ }
399
+
400
+ /**
401
+ * Reference to a named schema definition.
402
+ *
403
+ * Points to a schema defined in the `$defs` map using a JSON pointer. Used to
404
+ * avoid schema duplication and enable recursive type definitions. The
405
+ * reference path format is `#/$defs/TypeName`.
406
+ */
407
+ export interface IReference extends IJsonSchemaAttribute {
408
+ /**
409
+ * JSON pointer to the referenced schema.
410
+ *
411
+ * Must be in the format `#/$defs/TypeName` where TypeName is a key in the
412
+ * parent schema's `$defs` map.
413
+ */
414
+ $ref: string;
415
+ }
416
+
417
+ /**
418
+ * Union type schema (A | B | C).
419
+ *
420
+ * Represents a TypeScript union type where the value can match any one of the
421
+ * member schemas. Note: Gemini does not support `anyOf`/`oneOf` schemas. Use
422
+ * discriminated unions with `x-discriminator` when possible for better LLM
423
+ * comprehension.
424
+ */
425
+ export interface IAnyOf extends IJsonSchemaAttribute {
426
+ /**
427
+ * Array of possible schemas.
428
+ *
429
+ * The value must match at least one of these schemas. Nested `anyOf`
430
+ * schemas are flattened to avoid deep nesting.
431
+ */
432
+ anyOf: Exclude<ILlmSchema, ILlmSchema.IAnyOf>[];
433
+
434
+ /**
435
+ * Discriminator for tagged/discriminated unions.
436
+ *
437
+ * Helps LLMs understand which variant to select based on a discriminating
438
+ * property value. Improves type inference accuracy.
439
+ */
440
+ "x-discriminator"?: IAnyOf.IDiscriminator;
441
+ }
442
+ export namespace IAnyOf {
443
+ /**
444
+ * Discriminator configuration for tagged unions.
445
+ *
446
+ * Specifies which property distinguishes between union variants and maps
447
+ * discriminator values to their corresponding schemas.
448
+ */
449
+ export interface IDiscriminator {
450
+ /**
451
+ * Name of the discriminating property.
452
+ *
453
+ * This property must exist on all union member object schemas and contain
454
+ * unique literal values that identify each variant.
455
+ */
456
+ propertyName: string;
457
+
458
+ /**
459
+ * Mapping from discriminator values to schema references.
460
+ *
461
+ * Keys are the literal values of the discriminator property, values are
462
+ * `$ref` paths to the corresponding schemas.
463
+ */
464
+ mapping?: Record<string, string>;
465
+ }
466
+ }
467
+
468
+ /**
469
+ * Null type schema.
470
+ *
471
+ * Represents the JSON null value. In TypeScript union types like `T | null`,
472
+ * this schema appears in an `anyOf` alongside the T schema.
473
+ */
474
+ export interface INull extends IJsonSchemaAttribute.INull {}
475
+
476
+ /**
477
+ * Unknown/any type schema.
478
+ *
479
+ * Represents TypeScript `any` or `unknown` types where no specific type
480
+ * constraint is defined. Use sparingly as LLMs may generate unexpected values
481
+ * for unconstrained types.
482
+ */
483
+ export interface IUnknown extends IJsonSchemaAttribute.IUnknown {}
484
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Result type for operations that can either succeed or fail.
3
+ *
4
+ * `IResult` is a discriminated union representing the outcome of an operation
5
+ * that may fail. This pattern (often called "Result" or "Either" monad) enables
6
+ * explicit error handling without exceptions.
7
+ *
8
+ * Check the {@link IResult.success | success} discriminator to determine the
9
+ * outcome:
10
+ *
11
+ * - `true` → {@link IResult.ISuccess} with the result in
12
+ * {@link IResult.ISuccess.value | value}
13
+ * - `false` → {@link IResult.IFailure} with the error in
14
+ * {@link IResult.IFailure.error | error}
15
+ *
16
+ * This pattern is used throughout typia for safe operations like parsing and
17
+ * transformation where errors are expected possibilities.
18
+ *
19
+ * @author Jeongho Nam - https://github.com/samchon
20
+ * @example
21
+ * const result: IResult<User, ParseError> = parseUser(json);
22
+ * if (result.success) {
23
+ * console.log(result.value.name);
24
+ * } else {
25
+ * console.error(result.error.message);
26
+ * }
27
+ *
28
+ * @template T Type of the success value
29
+ * @template E Type of the error value
30
+ */
31
+ export type IResult<T, E> = IResult.ISuccess<T> | IResult.IFailure<E>;
32
+ export namespace IResult {
33
+ /**
34
+ * Successful result variant.
35
+ *
36
+ * Indicates the operation completed successfully and contains the result
37
+ * value. Access via {@link value} after checking {@link success} is `true`.
38
+ *
39
+ * @template T Type of the success value
40
+ */
41
+ export interface ISuccess<T> {
42
+ /**
43
+ * Success discriminator.
44
+ *
45
+ * Always `true` for successful results. Use this to narrow the type before
46
+ * accessing {@link value}.
47
+ */
48
+ success: true;
49
+
50
+ /**
51
+ * The successful result value.
52
+ *
53
+ * Contains the operation's output. Only accessible when {@link success} is
54
+ * `true`.
55
+ */
56
+ value: T;
57
+ }
58
+
59
+ /**
60
+ * Failed result variant.
61
+ *
62
+ * Indicates the operation failed and contains error information. Access via
63
+ * {@link error} after checking {@link success} is `false`.
64
+ *
65
+ * @template E Type of the error value
66
+ */
67
+ export interface IFailure<E> {
68
+ /**
69
+ * Success discriminator.
70
+ *
71
+ * Always `false` for failed results. Use this to narrow the type before
72
+ * accessing {@link error}.
73
+ */
74
+ success: false;
75
+
76
+ /**
77
+ * The error information.
78
+ *
79
+ * Contains details about why the operation failed. Only accessible when
80
+ * {@link success} is `false`.
81
+ */
82
+ error: E;
83
+ }
84
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Validation result type with detailed error information.
3
+ *
4
+ * `IValidation<T>` is the return type of `typia.validate<T>()` and related
5
+ * validation functions. Unlike `typia.is<T>()` which returns a boolean, or
6
+ * `typia.assert<T>()` which throws exceptions, `typia.validate<T>()` returns
7
+ * this structured result with full error details.
8
+ *
9
+ * Check the {@link IValidation.success | success} discriminator:
10
+ *
11
+ * - `true` → {@link IValidation.ISuccess} with validated
12
+ * {@link IValidation.ISuccess.data | data}
13
+ * - `false` → {@link IValidation.IFailure} with
14
+ * {@link IValidation.IFailure.errors | errors} array
15
+ *
16
+ * This is the recommended validation function when you need to report
17
+ * validation errors to users or log them for debugging.
18
+ *
19
+ * @author Jeongho Nam - https://github.com/samchon
20
+ * @example
21
+ * const result = typia.validate<User>(input);
22
+ * if (result.success) {
23
+ * return result.data; // User type
24
+ * } else {
25
+ * result.errors.forEach((e) => console.log(e.path, e.expected));
26
+ * }
27
+ *
28
+ * @template T The expected type after successful validation
29
+ */
30
+ export type IValidation<T = unknown> =
31
+ | IValidation.ISuccess<T>
32
+ | IValidation.IFailure;
33
+
34
+ export namespace IValidation {
35
+ /**
36
+ * Successful validation result.
37
+ *
38
+ * Indicates the input matches the expected type. The validated data is
39
+ * available in {@link data} with full type information.
40
+ *
41
+ * @template T The validated type
42
+ */
43
+ export interface ISuccess<T = unknown> {
44
+ /**
45
+ * Success discriminator.
46
+ *
47
+ * Always `true` for successful validations. Use this to narrow the type
48
+ * before accessing {@link data}.
49
+ */
50
+ success: true;
51
+
52
+ /**
53
+ * The validated data with correct type.
54
+ *
55
+ * The original input after successful validation. TypeScript will narrow
56
+ * this to type `T` when {@link success} is `true`.
57
+ */
58
+ data: T;
59
+ }
60
+
61
+ /**
62
+ * Failed validation result with error details.
63
+ *
64
+ * Indicates the input did not match the expected type. Contains the original
65
+ * data and an array of all validation errors found.
66
+ */
67
+ export interface IFailure {
68
+ /**
69
+ * Success discriminator.
70
+ *
71
+ * Always `false` for failed validations. Use this to narrow the type before
72
+ * accessing {@link errors}.
73
+ */
74
+ success: false;
75
+
76
+ /**
77
+ * The original input that failed validation.
78
+ *
79
+ * Preserved as `unknown` type since it didn't match the expected type.
80
+ * Useful for debugging or logging the actual value.
81
+ */
82
+ data: unknown;
83
+
84
+ /**
85
+ * Array of validation errors.
86
+ *
87
+ * Contains one entry for each validation failure found. Multiple errors may
88
+ * exist if the input has multiple type mismatches.
89
+ */
90
+ errors: IError[];
91
+ }
92
+
93
+ /**
94
+ * Detailed information about a single validation error.
95
+ *
96
+ * Describes exactly what went wrong during validation, including the
97
+ * location, expected type, and actual value.
98
+ */
99
+ export interface IError {
100
+ /**
101
+ * Property path to the error location.
102
+ *
103
+ * A dot-notation path from the root input to the failing property. Uses
104
+ * `$input` as the root. Example: `"$input.user.email"` or
105
+ * `"$input.items[0].price"`.
106
+ */
107
+ path: string;
108
+
109
+ /**
110
+ * Expected type expression.
111
+ *
112
+ * A human-readable description of what type was expected at this location.
113
+ * Examples: `"string"`, `"number & ExclusiveMinimum<0>"`, `"(\"active\" |
114
+ * \"inactive\")"`.
115
+ */
116
+ expected: string;
117
+
118
+ /**
119
+ * The actual value that failed validation.
120
+ *
121
+ * The value found at the error path. May be `undefined` if the property was
122
+ * missing. Useful for debugging type mismatches.
123
+ */
124
+ value: unknown;
125
+
126
+ /**
127
+ * Human-readable error description.
128
+ *
129
+ * Optional additional context about the validation failure, such as
130
+ * constraint violations or custom error messages.
131
+ */
132
+ description?: string;
133
+ }
134
+ }
@@ -0,0 +1,13 @@
1
+ export * from "./IResult";
2
+ export * from "./IValidation";
3
+
4
+ export * from "./IJsonSchemaTransformError";
5
+ export * from "./IJsonSchemaApplication";
6
+ export * from "./IJsonSchemaCollection";
7
+ export * from "./IJsonSchemaUnit";
8
+ export * from "./IJsonSchemaAttribute";
9
+
10
+ export * from "./ILlmController";
11
+ export * from "./ILlmApplication";
12
+ export * from "./ILlmFunction";
13
+ export * from "./ILlmSchema";