@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,71 @@
1
+ import { Format } from "../tags/Format";
2
+ import { Equal } from "./internal/Equal";
3
+ import { IsTuple } from "./internal/IsTuple";
4
+ import { NativeClass } from "./internal/NativeClass";
5
+ import { ValueOf } from "./internal/ValueOf";
6
+
7
+ /**
8
+ * Converts a type to its JSON-serializable primitive form.
9
+ *
10
+ * `Primitive<T>` transforms types for JSON serialization: boxed primitives
11
+ * become primitives (Boolean→boolean), classes become plain objects with
12
+ * methods removed, Date becomes `string & Format<"date-time">`, and types with
13
+ * `toJSON()` use their return type. Native classes (except Date) and bigint
14
+ * become `never` as they're not JSON-serializable.
15
+ *
16
+ * @author Jeongho Nam - https://github.com/samchon
17
+ * @author Kyungsu Kang - https://github.com/kakasoo
18
+ * @author Michael - https://github.com/8471919
19
+ * @template T Target type to convert
20
+ */
21
+ export type Primitive<T> =
22
+ Equal<T, PrimitiveMain<T>> extends true ? T : PrimitiveMain<T>;
23
+
24
+ type PrimitiveMain<Instance> = Instance extends [never]
25
+ ? never // (special trick for jsonable | null) type
26
+ : ValueOf<Instance> extends bigint
27
+ ? never
28
+ : ValueOf<Instance> extends boolean | number | string
29
+ ? ValueOf<Instance>
30
+ : Instance extends Function
31
+ ? never
32
+ : ValueOf<Instance> extends object
33
+ ? Instance extends object
34
+ ? Instance extends Date
35
+ ? string & Format<"date-time">
36
+ : Instance extends IJsonable<infer Raw>
37
+ ? ValueOf<Raw> extends object
38
+ ? Raw extends object
39
+ ? PrimitiveObject<Raw> // object would be primitified
40
+ : never // cannot be
41
+ : ValueOf<Raw> // atomic value
42
+ : Instance extends Exclude<NativeClass, Date>
43
+ ? never
44
+ : PrimitiveObject<Instance> // object would be primitified
45
+ : never // cannot be
46
+ : ValueOf<Instance>;
47
+
48
+ type PrimitiveObject<Instance extends object> =
49
+ Instance extends Array<infer T>
50
+ ? IsTuple<Instance> extends true
51
+ ? PrimitiveTuple<Instance>
52
+ : PrimitiveMain<T>[]
53
+ : {
54
+ [P in keyof Instance]: PrimitiveMain<Instance[P]>;
55
+ };
56
+
57
+ type PrimitiveTuple<T extends readonly any[]> = T extends []
58
+ ? []
59
+ : T extends [infer F]
60
+ ? [PrimitiveMain<F>]
61
+ : T extends [infer F, ...infer Rest extends readonly any[]]
62
+ ? [PrimitiveMain<F>, ...PrimitiveTuple<Rest>]
63
+ : T extends [(infer F)?]
64
+ ? [PrimitiveMain<F>?]
65
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
66
+ ? [PrimitiveMain<F>?, ...PrimitiveTuple<Rest>]
67
+ : [];
68
+
69
+ interface IJsonable<T> {
70
+ toJSON(): T;
71
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Protocol Buffers atomic (scalar) type names.
3
+ *
4
+ * Union of all primitive type identifiers used in Protocol Buffers wire format
5
+ * encoding/decoding.
6
+ *
7
+ * @author Jeongho Nam - https://github.com/samchon
8
+ */
9
+ export type ProtobufAtomic =
10
+ | "bool"
11
+ | "int32"
12
+ | "uint32"
13
+ | "int64"
14
+ | "uint64"
15
+ | "float"
16
+ | "double"
17
+ | "string";
18
+ export namespace ProtobufAtomic {
19
+ /** Numeric protobuf types (integers and floats). */
20
+ export type Numeric =
21
+ | "int32"
22
+ | "uint32"
23
+ | "int64"
24
+ | "uint64"
25
+ | "float"
26
+ | "double";
27
+
28
+ /** 64-bit integer types that map to JavaScript `bigint`. */
29
+ export type BigNumeric = "int64" | "uint64";
30
+ }
@@ -0,0 +1,58 @@
1
+ import { Equal } from "./internal/Equal";
2
+ import { IsTuple } from "./internal/IsTuple";
3
+ import { NativeClass } from "./internal/NativeClass";
4
+ import { ValueOf } from "./internal/ValueOf";
5
+
6
+ /**
7
+ * Converts a type to its resolved form by erasing all methods.
8
+ *
9
+ * `Resolved<T>` transforms classes to plain objects, extracts primitive values
10
+ * from boxed types (Boolean→boolean, Number→number, String→string), and
11
+ * recursively processes nested structures. Native classes (Date, Set, Map,
12
+ * etc.) are preserved unchanged.
13
+ *
14
+ * @author Jeongho Nam - https://github.com/samchon
15
+ * @author Kyungsu Kang - https://github.com/kakasoo
16
+ * @template T Target type to resolve
17
+ */
18
+ export type Resolved<T> =
19
+ Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
20
+
21
+ type ResolvedMain<T> = T extends [never]
22
+ ? never // (special trick for jsonable | null) type
23
+ : ValueOf<T> extends boolean | number | bigint | string
24
+ ? ValueOf<T>
25
+ : T extends Function
26
+ ? never
27
+ : T extends object
28
+ ? ResolvedObject<T>
29
+ : ValueOf<T>;
30
+
31
+ type ResolvedObject<T extends object> =
32
+ T extends Array<infer U>
33
+ ? IsTuple<T> extends true
34
+ ? ResolvedTuple<T>
35
+ : ResolvedMain<U>[]
36
+ : T extends Set<infer U>
37
+ ? Set<ResolvedMain<U>>
38
+ : T extends Map<infer K, infer V>
39
+ ? Map<ResolvedMain<K>, ResolvedMain<V>>
40
+ : T extends WeakSet<any> | WeakMap<any, any>
41
+ ? never
42
+ : T extends NativeClass
43
+ ? T
44
+ : {
45
+ [P in keyof T]: ResolvedMain<T[P]>;
46
+ };
47
+
48
+ type ResolvedTuple<T extends readonly any[]> = T extends []
49
+ ? []
50
+ : T extends [infer F]
51
+ ? [ResolvedMain<F>]
52
+ : T extends [infer F, ...infer Rest extends readonly any[]]
53
+ ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
54
+ : T extends [(infer F)?]
55
+ ? [ResolvedMain<F>?]
56
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
57
+ ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
58
+ : [];
@@ -0,0 +1,126 @@
1
+ import { Equal } from "./internal/Equal";
2
+ import { NativeClass } from "./internal/NativeClass";
3
+ import { ValueOf } from "./internal/ValueOf";
4
+
5
+ /**
6
+ * Converts all object keys to snake_case.
7
+ *
8
+ * `SnakeCase<T>` transforms object property names to snake_case format and
9
+ * erases methods like {@link Resolved}. Recursively processes nested
10
+ * structures.
11
+ *
12
+ * @author Jeongho Nam - https://github.com/samchon
13
+ * @template T Target type to transform
14
+ */
15
+ export type SnakeCase<T> =
16
+ Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
17
+
18
+ /* -----------------------------------------------------------
19
+ OBJECT CONVERSION
20
+ ----------------------------------------------------------- */
21
+
22
+ type SnakageMain<T> = T extends [never]
23
+ ? never // special trick for (jsonable | null) type
24
+ : T extends { valueOf(): boolean | bigint | number | string }
25
+ ? ValueOf<T>
26
+ : T extends Function
27
+ ? never
28
+ : T extends object
29
+ ? SnakageObject<T>
30
+ : T;
31
+
32
+ type SnakageObject<T extends object> =
33
+ T extends Array<infer U>
34
+ ? IsTuple<T> extends true
35
+ ? SnakageTuple<T>
36
+ : SnakageMain<U>[]
37
+ : T extends Set<infer U>
38
+ ? Set<SnakageMain<U>>
39
+ : T extends Map<infer K, infer V>
40
+ ? Map<SnakageMain<K>, SnakageMain<V>>
41
+ : T extends WeakSet<any> | WeakMap<any, any>
42
+ ? never
43
+ : T extends NativeClass
44
+ ? T
45
+ : {
46
+ [Key in keyof T as SnakageString<Key & string>]: SnakageMain<
47
+ T[Key]
48
+ >;
49
+ };
50
+
51
+ /* -----------------------------------------------------------
52
+ SPECIAL CASES
53
+ ----------------------------------------------------------- */
54
+ type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
55
+ never,
56
+ ]
57
+ ? false
58
+ : T extends readonly any[]
59
+ ? number extends T["length"]
60
+ ? false
61
+ : true
62
+ : false;
63
+ type SnakageTuple<T extends readonly any[]> = T extends []
64
+ ? []
65
+ : T extends [infer F]
66
+ ? [SnakageMain<F>]
67
+ : T extends [infer F, ...infer Rest extends readonly any[]]
68
+ ? [SnakageMain<F>, ...SnakageTuple<Rest>]
69
+ : T extends [(infer F)?]
70
+ ? [SnakageMain<F>?]
71
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
72
+ ? [SnakageMain<F>?, ...SnakageTuple<Rest>]
73
+ : [];
74
+
75
+ /* -----------------------------------------------------------
76
+ STRING CONVERTER
77
+ ----------------------------------------------------------- */
78
+ type SnakageString<Key extends string> = Key extends `${infer _}`
79
+ ? SnakageStringRepeatedly<Key, "">
80
+ : Key;
81
+ type SnakageStringRepeatedly<
82
+ S extends string,
83
+ Previous extends string,
84
+ > = S extends `${infer First}${infer Second}${infer Rest}`
85
+ ? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
86
+ First,
87
+ Second
88
+ >}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
89
+ : S extends `${infer First}`
90
+ ? `${Underscore<Previous, First>}${Lowercase<First>}`
91
+ : "";
92
+ type Underscore<First extends string, Second extends string> = First extends
93
+ | UpperAlphabetic
94
+ | ""
95
+ | "_"
96
+ ? ""
97
+ : Second extends UpperAlphabetic
98
+ ? "_"
99
+ : "";
100
+ type UpperAlphabetic =
101
+ | "A"
102
+ | "B"
103
+ | "C"
104
+ | "D"
105
+ | "E"
106
+ | "F"
107
+ | "G"
108
+ | "H"
109
+ | "I"
110
+ | "J"
111
+ | "K"
112
+ | "L"
113
+ | "M"
114
+ | "N"
115
+ | "O"
116
+ | "P"
117
+ | "Q"
118
+ | "R"
119
+ | "S"
120
+ | "T"
121
+ | "U"
122
+ | "V"
123
+ | "W"
124
+ | "X"
125
+ | "Y"
126
+ | "Z";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Extracts property keys whose value type extends the target type.
3
+ *
4
+ * `SpecialFields<Instance, Target>` returns a union of property names from
5
+ * `Instance` where the property value extends `Target`.
6
+ *
7
+ * @author Jeongho Nam - https://github.com/samchon
8
+ * @template Instance Source object type
9
+ * @template Target Target value type to match
10
+ */
11
+ export type SpecialFields<Instance extends object, Target> = {
12
+ [P in keyof Instance]: Instance[P] extends Target ? P : never;
13
+ }[keyof Instance & string];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Discriminated union for validation results.
3
+ *
4
+ * `ValidationPipe<T, E>` represents either a successful validation with data of
5
+ * type `T`, or a failed validation with an array of errors of type `E`. Use the
6
+ * `success` discriminant to narrow the type.
7
+ *
8
+ * @author Jeongho Nam - https://github.com/samchon
9
+ * @template T Success data type
10
+ * @template E Error type
11
+ */
12
+ export type ValidationPipe<T, E> =
13
+ | {
14
+ success: true;
15
+ data: T;
16
+ }
17
+ | {
18
+ success: false;
19
+ errors: E[];
20
+ };
@@ -0,0 +1,13 @@
1
+ export * from "./AssertionGuard";
2
+ export * from "./CamelCase";
3
+ export * from "./PascalCase";
4
+ export * from "./Primitive";
5
+ export * from "./Resolved";
6
+ export * from "./SnakeCase";
7
+
8
+ export * from "./Atomic";
9
+ export * from "./ClassProperties";
10
+ export * from "./OmitNever";
11
+ export * from "./ProtobufAtomic";
12
+ export * from "./SpecialFields";
13
+ export * from "./ValidationPipe";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Checks if two types are exactly equal.
3
+ *
4
+ * `Equal<X, Y>` returns `true` if types X and Y are identical, `false`
5
+ * otherwise. Works with any TypeScript types including unions.
6
+ *
7
+ * @author Kyungsu Kang - https://github.com/kakasoo
8
+ * @template X First type to compare
9
+ * @template Y Second type to compare
10
+ */
11
+ export type Equal<X, Y> =
12
+ (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
13
+ ? true
14
+ : false;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks if an array type is a tuple (fixed length) or regular array.
3
+ *
4
+ * Returns `true` for tuple types like `[string, number]` where length is fixed,
5
+ * and `false` for array types like `string[]` where length is variable.
6
+ *
7
+ * @template T Array or tuple type to check
8
+ */
9
+ export type IsTuple<T extends readonly any[] | { length: number }> = [
10
+ T,
11
+ ] extends [never]
12
+ ? false
13
+ : T extends readonly any[]
14
+ ? number extends T["length"]
15
+ ? false
16
+ : true
17
+ : false;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Union of JavaScript built-in class types.
3
+ *
4
+ * `NativeClass` includes Date, collections (Set, Map, WeakSet, WeakMap), typed
5
+ * arrays (Uint8Array, Int32Array, etc.), binary data types (ArrayBuffer,
6
+ * DataView, Blob, File), and RegExp. These types receive special handling in
7
+ * typia's serialization and validation.
8
+ */
9
+ export type NativeClass =
10
+ | Date
11
+ | Set<any>
12
+ | Map<any, any>
13
+ | WeakSet<any>
14
+ | WeakMap<any, any>
15
+ | Uint8Array
16
+ | Uint8ClampedArray
17
+ | Uint16Array
18
+ | Uint32Array
19
+ | BigUint64Array
20
+ | Int8Array
21
+ | Int16Array
22
+ | Int32Array
23
+ | BigInt64Array
24
+ | Float32Array
25
+ | Float64Array
26
+ | ArrayBuffer
27
+ | SharedArrayBuffer
28
+ | DataView
29
+ | Blob
30
+ | File
31
+ | RegExp;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Extracts the primitive value type from boxed primitives.
3
+ *
4
+ * `ValueOf<Instance>` converts boxed primitive types (Boolean, Number, String)
5
+ * to their primitive equivalents (boolean, number, string). Non-boxed types are
6
+ * returned unchanged.
7
+ *
8
+ * @template Instance Type to extract primitive from
9
+ */
10
+ export type ValueOf<Instance> =
11
+ IsValueOf<Instance, Boolean> extends true
12
+ ? boolean
13
+ : IsValueOf<Instance, Number> extends true
14
+ ? number
15
+ : IsValueOf<Instance, String> extends true
16
+ ? string
17
+ : Instance;
18
+
19
+ type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
20
+ ? Object extends IValueOf<infer Primitive>
21
+ ? Instance extends Primitive
22
+ ? false
23
+ : true // not Primitive, but Object
24
+ : false // cannot be
25
+ : false;
26
+
27
+ interface IValueOf<T> {
28
+ valueOf(): T;
29
+ }
@@ -0,0 +1,105 @@
1
+ import { OpenApi } from "../openapi/OpenApi";
2
+
3
+ /**
4
+ * Random value generator interface for typia.
5
+ *
6
+ * `IRandomGenerator` defines methods for generating random values of various
7
+ * types. Used by `typia.random<T>()` for mock data generation.
8
+ *
9
+ * @author Jeongho Nam - https://github.com/samchon
10
+ */
11
+ export interface IRandomGenerator {
12
+ /** Generates a random boolean. */
13
+ boolean(): boolean | undefined;
14
+
15
+ /** Generates a random number within schema constraints. */
16
+ number(schema: OpenApi.IJsonSchema.INumber): number;
17
+
18
+ /** Generates a random integer within schema constraints. */
19
+ integer(schema: OpenApi.IJsonSchema.IInteger): number;
20
+
21
+ /** Generates a random bigint within schema constraints. */
22
+ bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
23
+
24
+ /** Generates a random string within schema constraints. */
25
+ string(schema: OpenApi.IJsonSchema.IString): string;
26
+
27
+ /** Generates a random array with elements from the generator function. */
28
+ array<T>(
29
+ schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
30
+ element: (index: number, count: number) => T;
31
+ },
32
+ ): T[];
33
+
34
+ /** Generates a random string matching the regex pattern. */
35
+ pattern(regex: RegExp): string;
36
+
37
+ // String format generators
38
+ byte(): string;
39
+
40
+ password(): string;
41
+
42
+ regex(): string;
43
+
44
+ uuid(): string;
45
+
46
+ email(): string;
47
+
48
+ hostname(): string;
49
+
50
+ idnEmail(): string;
51
+
52
+ idnHostname(): string;
53
+
54
+ iri(): string;
55
+
56
+ iriReference(): string;
57
+
58
+ ipv4(): string;
59
+
60
+ ipv6(): string;
61
+
62
+ uri(): string;
63
+
64
+ uriReference(): string;
65
+
66
+ uriTemplate(): string;
67
+
68
+ url(): string;
69
+
70
+ datetime(props?: { minimum?: number; maximum?: number }): string;
71
+
72
+ date(props?: { minimum?: number; maximum?: number }): string;
73
+
74
+ time(): string;
75
+
76
+ duration(): string;
77
+
78
+ jsonPointer(): string;
79
+
80
+ relativeJsonPointer(): string;
81
+ }
82
+
83
+ export namespace IRandomGenerator {
84
+ /** Custom generators for specific schema properties. */
85
+ export interface CustomMap {
86
+ string?: (
87
+ schema: OpenApi.IJsonSchema.IString & Record<string, any>,
88
+ ) => string;
89
+ number?: (
90
+ schema: OpenApi.IJsonSchema.INumber & Record<string, any>,
91
+ ) => number;
92
+ integer?: (
93
+ schema: OpenApi.IJsonSchema.IInteger & Record<string, any>,
94
+ ) => number;
95
+ bigint?: (
96
+ schema: OpenApi.IJsonSchema.IInteger & Record<string, any>,
97
+ ) => bigint;
98
+ boolean?: (schema: Record<string, any>) => boolean | undefined;
99
+ array?: <T>(
100
+ schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
101
+ element: (index: number, count: number) => T;
102
+ } & Record<string, any>,
103
+ ) => T[];
104
+ }
105
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Minimal interface for reading URL query parameters.
3
+ *
4
+ * `IReadableURLSearchParams` is a subset of the standard {@link URLSearchParams}
5
+ * interface, containing only the read operations needed for query parameter
6
+ * parsing. This interface was designed specifically for compatibility with the
7
+ * [Hono.js](https://hono.dev/) web framework, which provides its own query
8
+ * parameter implementation.
9
+ *
10
+ * The interface exposes:
11
+ *
12
+ * - {@link URLSearchParams.size | size}: Number of parameters
13
+ * - {@link URLSearchParams.get | get}: Retrieve first value for a key
14
+ * - {@link URLSearchParams.getAll | getAll}: Retrieve all values for a key
15
+ *
16
+ * Use this interface when implementing query parameter handling that needs to
17
+ * work with both standard `URLSearchParams` and framework-specific
18
+ * implementations.
19
+ *
20
+ * @author https://github.com/miyaji255
21
+ */
22
+ export type IReadableURLSearchParams = Pick<
23
+ URLSearchParams,
24
+ "size" | "get" | "getAll"
25
+ >;
@@ -0,0 +1,2 @@
1
+ export * from "./IRandomGenerator";
2
+ export * from "./IReadableURLSearchParams";