@typia/utils 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 (471) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/lib/converters/LlmSchemaConverter.d.ts +102 -0
  4. package/lib/converters/LlmSchemaConverter.js +652 -0
  5. package/lib/converters/LlmSchemaConverter.js.map +1 -0
  6. package/lib/converters/LlmSchemaConverter.mjs +771 -0
  7. package/lib/converters/LlmSchemaConverter.mjs.map +1 -0
  8. package/lib/converters/OpenApiConverter.d.ts +135 -0
  9. package/lib/converters/OpenApiConverter.js +130 -0
  10. package/lib/converters/OpenApiConverter.js.map +1 -0
  11. package/lib/converters/OpenApiConverter.mjs +128 -0
  12. package/lib/converters/OpenApiConverter.mjs.map +1 -0
  13. package/lib/converters/index.d.ts +2 -0
  14. package/lib/converters/index.js +21 -0
  15. package/lib/converters/index.js.map +1 -0
  16. package/lib/converters/index.mjs +4 -0
  17. package/lib/converters/index.mjs.map +1 -0
  18. package/lib/converters/internal/LlmDescriptionInverter.d.ts +6 -0
  19. package/lib/converters/internal/LlmDescriptionInverter.js +141 -0
  20. package/lib/converters/internal/LlmDescriptionInverter.js.map +1 -0
  21. package/lib/converters/internal/LlmDescriptionInverter.mjs +141 -0
  22. package/lib/converters/internal/LlmDescriptionInverter.mjs.map +1 -0
  23. package/lib/converters/internal/LlmParametersComposer.d.ts +1 -0
  24. package/lib/converters/internal/LlmParametersComposer.js +39 -0
  25. package/lib/converters/internal/LlmParametersComposer.js.map +1 -0
  26. package/lib/converters/internal/LlmParametersComposer.mjs +42 -0
  27. package/lib/converters/internal/LlmParametersComposer.mjs.map +1 -0
  28. package/lib/converters/internal/OpenApiConstraintShifter.d.ts +6 -0
  29. package/lib/converters/internal/OpenApiConstraintShifter.js +103 -0
  30. package/lib/converters/internal/OpenApiConstraintShifter.js.map +1 -0
  31. package/lib/converters/internal/OpenApiConstraintShifter.mjs +102 -0
  32. package/lib/converters/internal/OpenApiConstraintShifter.mjs.map +1 -0
  33. package/lib/converters/internal/OpenApiExclusiveEmender.d.ts +4 -0
  34. package/lib/converters/internal/OpenApiExclusiveEmender.js +32 -0
  35. package/lib/converters/internal/OpenApiExclusiveEmender.js.map +1 -0
  36. package/lib/converters/internal/OpenApiExclusiveEmender.mjs +35 -0
  37. package/lib/converters/internal/OpenApiExclusiveEmender.mjs.map +1 -0
  38. package/lib/converters/internal/OpenApiV3Downgrader.d.ts +10 -0
  39. package/lib/converters/internal/OpenApiV3Downgrader.js +214 -0
  40. package/lib/converters/internal/OpenApiV3Downgrader.js.map +1 -0
  41. package/lib/converters/internal/OpenApiV3Downgrader.mjs +279 -0
  42. package/lib/converters/internal/OpenApiV3Downgrader.mjs.map +1 -0
  43. package/lib/converters/internal/OpenApiV3Upgrader.d.ts +6 -0
  44. package/lib/converters/internal/OpenApiV3Upgrader.js +285 -0
  45. package/lib/converters/internal/OpenApiV3Upgrader.js.map +1 -0
  46. package/lib/converters/internal/OpenApiV3Upgrader.mjs +349 -0
  47. package/lib/converters/internal/OpenApiV3Upgrader.mjs.map +1 -0
  48. package/lib/converters/internal/OpenApiV3_1Upgrader.d.ts +6 -0
  49. package/lib/converters/internal/OpenApiV3_1Upgrader.js +405 -0
  50. package/lib/converters/internal/OpenApiV3_1Upgrader.js.map +1 -0
  51. package/lib/converters/internal/OpenApiV3_1Upgrader.mjs +545 -0
  52. package/lib/converters/internal/OpenApiV3_1Upgrader.mjs.map +1 -0
  53. package/lib/converters/internal/SwaggerV2Downgrader.d.ts +10 -0
  54. package/lib/converters/internal/SwaggerV2Downgrader.js +294 -0
  55. package/lib/converters/internal/SwaggerV2Downgrader.js.map +1 -0
  56. package/lib/converters/internal/SwaggerV2Downgrader.mjs +332 -0
  57. package/lib/converters/internal/SwaggerV2Downgrader.mjs.map +1 -0
  58. package/lib/converters/internal/SwaggerV2Upgrader.d.ts +6 -0
  59. package/lib/converters/internal/SwaggerV2Upgrader.js +357 -0
  60. package/lib/converters/internal/SwaggerV2Upgrader.js.map +1 -0
  61. package/lib/converters/internal/SwaggerV2Upgrader.mjs +403 -0
  62. package/lib/converters/internal/SwaggerV2Upgrader.mjs.map +1 -0
  63. package/lib/http/HttpError.d.ts +61 -0
  64. package/lib/http/HttpError.js +70 -0
  65. package/lib/http/HttpError.js.map +1 -0
  66. package/lib/http/HttpError.mjs +76 -0
  67. package/lib/http/HttpError.mjs.map +1 -0
  68. package/lib/http/HttpLlm.d.ts +130 -0
  69. package/lib/http/HttpLlm.js +124 -0
  70. package/lib/http/HttpLlm.js.map +1 -0
  71. package/lib/http/HttpLlm.mjs +123 -0
  72. package/lib/http/HttpLlm.mjs.map +1 -0
  73. package/lib/http/HttpMigration.d.ts +58 -0
  74. package/lib/http/HttpMigration.js +52 -0
  75. package/lib/http/HttpMigration.js.map +1 -0
  76. package/lib/http/HttpMigration.mjs +52 -0
  77. package/lib/http/HttpMigration.mjs.map +1 -0
  78. package/lib/http/index.d.ts +3 -0
  79. package/lib/http/index.js +20 -0
  80. package/lib/http/index.js.map +1 -0
  81. package/lib/http/index.mjs +4 -0
  82. package/lib/http/index.mjs.map +1 -0
  83. package/lib/http/internal/HttpLlmApplicationComposer.d.ts +8 -0
  84. package/lib/http/internal/HttpLlmApplicationComposer.js +254 -0
  85. package/lib/http/internal/HttpLlmApplicationComposer.js.map +1 -0
  86. package/lib/http/internal/HttpLlmApplicationComposer.mjs +256 -0
  87. package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -0
  88. package/lib/http/internal/HttpLlmFunctionFetcher.d.ts +6 -0
  89. package/lib/http/internal/HttpLlmFunctionFetcher.js +24 -0
  90. package/lib/http/internal/HttpLlmFunctionFetcher.js.map +1 -0
  91. package/lib/http/internal/HttpLlmFunctionFetcher.mjs +24 -0
  92. package/lib/http/internal/HttpLlmFunctionFetcher.mjs.map +1 -0
  93. package/lib/http/internal/HttpMigrateApplicationComposer.d.ts +4 -0
  94. package/lib/http/internal/HttpMigrateApplicationComposer.js +45 -0
  95. package/lib/http/internal/HttpMigrateApplicationComposer.js.map +1 -0
  96. package/lib/http/internal/HttpMigrateApplicationComposer.mjs +47 -0
  97. package/lib/http/internal/HttpMigrateApplicationComposer.mjs.map +1 -0
  98. package/lib/http/internal/HttpMigrateRouteAccessor.d.ts +4 -0
  99. package/lib/http/internal/HttpMigrateRouteAccessor.js +107 -0
  100. package/lib/http/internal/HttpMigrateRouteAccessor.js.map +1 -0
  101. package/lib/http/internal/HttpMigrateRouteAccessor.mjs +106 -0
  102. package/lib/http/internal/HttpMigrateRouteAccessor.mjs.map +1 -0
  103. package/lib/http/internal/HttpMigrateRouteComposer.d.ts +11 -0
  104. package/lib/http/internal/HttpMigrateRouteComposer.js +398 -0
  105. package/lib/http/internal/HttpMigrateRouteComposer.js.map +1 -0
  106. package/lib/http/internal/HttpMigrateRouteComposer.mjs +392 -0
  107. package/lib/http/internal/HttpMigrateRouteComposer.mjs.map +1 -0
  108. package/lib/http/internal/HttpMigrateRouteFetcher.d.ts +6 -0
  109. package/lib/http/internal/HttpMigrateRouteFetcher.js +179 -0
  110. package/lib/http/internal/HttpMigrateRouteFetcher.js.map +1 -0
  111. package/lib/http/internal/HttpMigrateRouteFetcher.mjs +174 -0
  112. package/lib/http/internal/HttpMigrateRouteFetcher.mjs.map +1 -0
  113. package/lib/http/internal/LlmDataMerger.d.ts +48 -0
  114. package/lib/http/internal/LlmDataMerger.js +60 -0
  115. package/lib/http/internal/LlmDataMerger.js.map +1 -0
  116. package/lib/http/internal/LlmDataMerger.mjs +59 -0
  117. package/lib/http/internal/LlmDataMerger.mjs.map +1 -0
  118. package/lib/index.d.ts +4 -0
  119. package/lib/index.js +21 -0
  120. package/lib/index.js.map +1 -0
  121. package/lib/index.mjs +20 -0
  122. package/lib/index.mjs.map +1 -0
  123. package/lib/utils/ArrayUtil.d.ts +1 -0
  124. package/lib/utils/ArrayUtil.js +29 -0
  125. package/lib/utils/ArrayUtil.js.map +1 -0
  126. package/lib/utils/ArrayUtil.mjs +28 -0
  127. package/lib/utils/ArrayUtil.mjs.map +1 -0
  128. package/lib/utils/MapUtil.d.ts +1 -0
  129. package/lib/utils/MapUtil.js +16 -0
  130. package/lib/utils/MapUtil.js.map +1 -0
  131. package/lib/utils/MapUtil.mjs +15 -0
  132. package/lib/utils/MapUtil.mjs.map +1 -0
  133. package/lib/utils/NamingConvention.d.ts +68 -0
  134. package/lib/utils/NamingConvention.js +199 -0
  135. package/lib/utils/NamingConvention.js.map +1 -0
  136. package/lib/utils/NamingConvention.mjs +198 -0
  137. package/lib/utils/NamingConvention.mjs.map +1 -0
  138. package/lib/utils/Singleton.d.ts +1 -0
  139. package/lib/utils/Singleton.js +18 -0
  140. package/lib/utils/Singleton.js.map +1 -0
  141. package/lib/utils/Singleton.mjs +18 -0
  142. package/lib/utils/Singleton.mjs.map +1 -0
  143. package/lib/utils/StringUtil.d.ts +1 -0
  144. package/lib/utils/StringUtil.js +17 -0
  145. package/lib/utils/StringUtil.js.map +1 -0
  146. package/lib/utils/StringUtil.mjs +13 -0
  147. package/lib/utils/StringUtil.mjs.map +1 -0
  148. package/lib/utils/dedent.d.ts +12 -0
  149. package/lib/utils/dedent.js +51 -0
  150. package/lib/utils/dedent.js.map +1 -0
  151. package/lib/utils/dedent.mjs +50 -0
  152. package/lib/utils/dedent.mjs.map +1 -0
  153. package/lib/utils/index.d.ts +7 -0
  154. package/lib/utils/index.js +24 -0
  155. package/lib/utils/index.js.map +1 -0
  156. package/lib/utils/index.mjs +8 -0
  157. package/lib/utils/index.mjs.map +1 -0
  158. package/lib/utils/internal/EndpointUtil.d.ts +8 -0
  159. package/lib/utils/internal/EndpointUtil.js +37 -0
  160. package/lib/utils/internal/EndpointUtil.js.map +1 -0
  161. package/lib/utils/internal/EndpointUtil.mjs +37 -0
  162. package/lib/utils/internal/EndpointUtil.mjs.map +1 -0
  163. package/lib/utils/internal/JsonDescriptor.d.ts +10 -0
  164. package/lib/utils/internal/JsonDescriptor.js +58 -0
  165. package/lib/utils/internal/JsonDescriptor.js.map +1 -0
  166. package/lib/utils/internal/JsonDescriptor.mjs +48 -0
  167. package/lib/utils/internal/JsonDescriptor.mjs.map +1 -0
  168. package/lib/utils/internal/OpenApiTypeCheckerBase.d.ts +1 -0
  169. package/lib/utils/internal/OpenApiTypeCheckerBase.js +520 -0
  170. package/lib/utils/internal/OpenApiTypeCheckerBase.js.map +1 -0
  171. package/lib/utils/internal/OpenApiTypeCheckerBase.mjs +584 -0
  172. package/lib/utils/internal/OpenApiTypeCheckerBase.mjs.map +1 -0
  173. package/lib/utils/stringifyValidationFailure.d.ts +25 -0
  174. package/lib/utils/stringifyValidationFailure.js +326 -0
  175. package/lib/utils/stringifyValidationFailure.js.map +1 -0
  176. package/lib/utils/stringifyValidationFailure.mjs +325 -0
  177. package/lib/utils/stringifyValidationFailure.mjs.map +1 -0
  178. package/lib/validators/LlmTypeChecker.d.ts +117 -0
  179. package/lib/validators/LlmTypeChecker.js +309 -0
  180. package/lib/validators/LlmTypeChecker.js.map +1 -0
  181. package/lib/validators/LlmTypeChecker.mjs +300 -0
  182. package/lib/validators/LlmTypeChecker.mjs.map +1 -0
  183. package/lib/validators/OpenApiTypeChecker.d.ts +211 -0
  184. package/lib/validators/OpenApiTypeChecker.js +207 -0
  185. package/lib/validators/OpenApiTypeChecker.js.map +1 -0
  186. package/lib/validators/OpenApiTypeChecker.mjs +218 -0
  187. package/lib/validators/OpenApiTypeChecker.mjs.map +1 -0
  188. package/lib/validators/OpenApiV3TypeChecker.d.ts +26 -0
  189. package/lib/validators/OpenApiV3TypeChecker.js +30 -0
  190. package/lib/validators/OpenApiV3TypeChecker.js.map +1 -0
  191. package/lib/validators/OpenApiV3TypeChecker.mjs +29 -0
  192. package/lib/validators/OpenApiV3TypeChecker.mjs.map +1 -0
  193. package/lib/validators/OpenApiV3_1TypeChecker.d.ts +29 -0
  194. package/lib/validators/OpenApiV3_1TypeChecker.js +34 -0
  195. package/lib/validators/OpenApiV3_1TypeChecker.js.map +1 -0
  196. package/lib/validators/OpenApiV3_1TypeChecker.mjs +33 -0
  197. package/lib/validators/OpenApiV3_1TypeChecker.mjs.map +1 -0
  198. package/lib/validators/OpenApiValidator.d.ts +36 -0
  199. package/lib/validators/OpenApiValidator.js +71 -0
  200. package/lib/validators/OpenApiValidator.js.map +1 -0
  201. package/lib/validators/OpenApiValidator.mjs +75 -0
  202. package/lib/validators/OpenApiValidator.mjs.map +1 -0
  203. package/lib/validators/SwaggerV2TypeChecker.d.ts +27 -0
  204. package/lib/validators/SwaggerV2TypeChecker.js +31 -0
  205. package/lib/validators/SwaggerV2TypeChecker.js.map +1 -0
  206. package/lib/validators/SwaggerV2TypeChecker.mjs +30 -0
  207. package/lib/validators/SwaggerV2TypeChecker.mjs.map +1 -0
  208. package/lib/validators/functional/_isBigintString.d.ts +1 -0
  209. package/lib/validators/functional/_isBigintString.js +14 -0
  210. package/lib/validators/functional/_isBigintString.js.map +1 -0
  211. package/lib/validators/functional/_isBigintString.mjs +12 -0
  212. package/lib/validators/functional/_isBigintString.mjs.map +1 -0
  213. package/lib/validators/functional/_isFormatByte.d.ts +1 -0
  214. package/lib/validators/functional/_isFormatByte.js +10 -0
  215. package/lib/validators/functional/_isFormatByte.js.map +1 -0
  216. package/lib/validators/functional/_isFormatByte.mjs +8 -0
  217. package/lib/validators/functional/_isFormatByte.mjs.map +1 -0
  218. package/lib/validators/functional/_isFormatDate.d.ts +1 -0
  219. package/lib/validators/functional/_isFormatDate.js +7 -0
  220. package/lib/validators/functional/_isFormatDate.js.map +1 -0
  221. package/lib/validators/functional/_isFormatDate.mjs +5 -0
  222. package/lib/validators/functional/_isFormatDate.mjs.map +1 -0
  223. package/lib/validators/functional/_isFormatDateTime.d.ts +1 -0
  224. package/lib/validators/functional/_isFormatDateTime.js +7 -0
  225. package/lib/validators/functional/_isFormatDateTime.js.map +1 -0
  226. package/lib/validators/functional/_isFormatDateTime.mjs +5 -0
  227. package/lib/validators/functional/_isFormatDateTime.mjs.map +1 -0
  228. package/lib/validators/functional/_isFormatDuration.d.ts +1 -0
  229. package/lib/validators/functional/_isFormatDuration.js +7 -0
  230. package/lib/validators/functional/_isFormatDuration.js.map +1 -0
  231. package/lib/validators/functional/_isFormatDuration.mjs +5 -0
  232. package/lib/validators/functional/_isFormatDuration.mjs.map +1 -0
  233. package/lib/validators/functional/_isFormatEmail.d.ts +1 -0
  234. package/lib/validators/functional/_isFormatEmail.js +7 -0
  235. package/lib/validators/functional/_isFormatEmail.js.map +1 -0
  236. package/lib/validators/functional/_isFormatEmail.mjs +5 -0
  237. package/lib/validators/functional/_isFormatEmail.mjs.map +1 -0
  238. package/lib/validators/functional/_isFormatHostname.d.ts +1 -0
  239. package/lib/validators/functional/_isFormatHostname.js +7 -0
  240. package/lib/validators/functional/_isFormatHostname.js.map +1 -0
  241. package/lib/validators/functional/_isFormatHostname.mjs +5 -0
  242. package/lib/validators/functional/_isFormatHostname.mjs.map +1 -0
  243. package/lib/validators/functional/_isFormatIdnEmail.d.ts +1 -0
  244. package/lib/validators/functional/_isFormatIdnEmail.js +7 -0
  245. package/lib/validators/functional/_isFormatIdnEmail.js.map +1 -0
  246. package/lib/validators/functional/_isFormatIdnEmail.mjs +5 -0
  247. package/lib/validators/functional/_isFormatIdnEmail.mjs.map +1 -0
  248. package/lib/validators/functional/_isFormatIdnHostname.d.ts +1 -0
  249. package/lib/validators/functional/_isFormatIdnHostname.js +7 -0
  250. package/lib/validators/functional/_isFormatIdnHostname.js.map +1 -0
  251. package/lib/validators/functional/_isFormatIdnHostname.mjs +5 -0
  252. package/lib/validators/functional/_isFormatIdnHostname.mjs.map +1 -0
  253. package/lib/validators/functional/_isFormatIpv4.d.ts +1 -0
  254. package/lib/validators/functional/_isFormatIpv4.js +7 -0
  255. package/lib/validators/functional/_isFormatIpv4.js.map +1 -0
  256. package/lib/validators/functional/_isFormatIpv4.mjs +5 -0
  257. package/lib/validators/functional/_isFormatIpv4.mjs.map +1 -0
  258. package/lib/validators/functional/_isFormatIpv6.d.ts +1 -0
  259. package/lib/validators/functional/_isFormatIpv6.js +7 -0
  260. package/lib/validators/functional/_isFormatIpv6.js.map +1 -0
  261. package/lib/validators/functional/_isFormatIpv6.mjs +5 -0
  262. package/lib/validators/functional/_isFormatIpv6.mjs.map +1 -0
  263. package/lib/validators/functional/_isFormatIri.d.ts +1 -0
  264. package/lib/validators/functional/_isFormatIri.js +7 -0
  265. package/lib/validators/functional/_isFormatIri.js.map +1 -0
  266. package/lib/validators/functional/_isFormatIri.mjs +5 -0
  267. package/lib/validators/functional/_isFormatIri.mjs.map +1 -0
  268. package/lib/validators/functional/_isFormatIriReference.d.ts +1 -0
  269. package/lib/validators/functional/_isFormatIriReference.js +7 -0
  270. package/lib/validators/functional/_isFormatIriReference.js.map +1 -0
  271. package/lib/validators/functional/_isFormatIriReference.mjs +5 -0
  272. package/lib/validators/functional/_isFormatIriReference.mjs.map +1 -0
  273. package/lib/validators/functional/_isFormatJsonPointer.d.ts +1 -0
  274. package/lib/validators/functional/_isFormatJsonPointer.js +7 -0
  275. package/lib/validators/functional/_isFormatJsonPointer.js.map +1 -0
  276. package/lib/validators/functional/_isFormatJsonPointer.mjs +5 -0
  277. package/lib/validators/functional/_isFormatJsonPointer.mjs.map +1 -0
  278. package/lib/validators/functional/_isFormatPassword.d.ts +1 -0
  279. package/lib/validators/functional/_isFormatPassword.js +6 -0
  280. package/lib/validators/functional/_isFormatPassword.js.map +1 -0
  281. package/lib/validators/functional/_isFormatPassword.mjs +4 -0
  282. package/lib/validators/functional/_isFormatPassword.mjs.map +1 -0
  283. package/lib/validators/functional/_isFormatRegex.d.ts +1 -0
  284. package/lib/validators/functional/_isFormatRegex.js +14 -0
  285. package/lib/validators/functional/_isFormatRegex.js.map +1 -0
  286. package/lib/validators/functional/_isFormatRegex.mjs +12 -0
  287. package/lib/validators/functional/_isFormatRegex.mjs.map +1 -0
  288. package/lib/validators/functional/_isFormatRelativeJsonPointer.d.ts +1 -0
  289. package/lib/validators/functional/_isFormatRelativeJsonPointer.js +7 -0
  290. package/lib/validators/functional/_isFormatRelativeJsonPointer.js.map +1 -0
  291. package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs +5 -0
  292. package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs.map +1 -0
  293. package/lib/validators/functional/_isFormatTime.d.ts +1 -0
  294. package/lib/validators/functional/_isFormatTime.js +7 -0
  295. package/lib/validators/functional/_isFormatTime.js.map +1 -0
  296. package/lib/validators/functional/_isFormatTime.mjs +5 -0
  297. package/lib/validators/functional/_isFormatTime.mjs.map +1 -0
  298. package/lib/validators/functional/_isFormatUri.d.ts +1 -0
  299. package/lib/validators/functional/_isFormatUri.js +8 -0
  300. package/lib/validators/functional/_isFormatUri.js.map +1 -0
  301. package/lib/validators/functional/_isFormatUri.mjs +6 -0
  302. package/lib/validators/functional/_isFormatUri.mjs.map +1 -0
  303. package/lib/validators/functional/_isFormatUriReference.d.ts +1 -0
  304. package/lib/validators/functional/_isFormatUriReference.js +7 -0
  305. package/lib/validators/functional/_isFormatUriReference.js.map +1 -0
  306. package/lib/validators/functional/_isFormatUriReference.mjs +5 -0
  307. package/lib/validators/functional/_isFormatUriReference.mjs.map +1 -0
  308. package/lib/validators/functional/_isFormatUriTemplate.d.ts +1 -0
  309. package/lib/validators/functional/_isFormatUriTemplate.js +7 -0
  310. package/lib/validators/functional/_isFormatUriTemplate.js.map +1 -0
  311. package/lib/validators/functional/_isFormatUriTemplate.mjs +5 -0
  312. package/lib/validators/functional/_isFormatUriTemplate.mjs.map +1 -0
  313. package/lib/validators/functional/_isFormatUrl.d.ts +1 -0
  314. package/lib/validators/functional/_isFormatUrl.js +7 -0
  315. package/lib/validators/functional/_isFormatUrl.js.map +1 -0
  316. package/lib/validators/functional/_isFormatUrl.mjs +5 -0
  317. package/lib/validators/functional/_isFormatUrl.mjs.map +1 -0
  318. package/lib/validators/functional/_isFormatUuid.d.ts +1 -0
  319. package/lib/validators/functional/_isFormatUuid.js +7 -0
  320. package/lib/validators/functional/_isFormatUuid.js.map +1 -0
  321. package/lib/validators/functional/_isFormatUuid.mjs +5 -0
  322. package/lib/validators/functional/_isFormatUuid.mjs.map +1 -0
  323. package/lib/validators/functional/_isUniqueItems.d.ts +1 -0
  324. package/lib/validators/functional/_isUniqueItems.js +140 -0
  325. package/lib/validators/functional/_isUniqueItems.js.map +1 -0
  326. package/lib/validators/functional/_isUniqueItems.mjs +138 -0
  327. package/lib/validators/functional/_isUniqueItems.mjs.map +1 -0
  328. package/lib/validators/index.d.ts +2 -0
  329. package/lib/validators/index.js +27 -0
  330. package/lib/validators/index.js.map +1 -0
  331. package/lib/validators/index.mjs +7 -0
  332. package/lib/validators/index.mjs.map +1 -0
  333. package/lib/validators/internal/IOpenApiValidatorContext.d.ts +14 -0
  334. package/lib/validators/internal/IOpenApiValidatorContext.js +3 -0
  335. package/lib/validators/internal/IOpenApiValidatorContext.js.map +1 -0
  336. package/lib/validators/internal/IOpenApiValidatorContext.mjs +2 -0
  337. package/lib/validators/internal/IOpenApiValidatorContext.mjs.map +1 -0
  338. package/lib/validators/internal/OpenApiArrayValidator.d.ts +5 -0
  339. package/lib/validators/internal/OpenApiArrayValidator.js +32 -0
  340. package/lib/validators/internal/OpenApiArrayValidator.js.map +1 -0
  341. package/lib/validators/internal/OpenApiArrayValidator.mjs +47 -0
  342. package/lib/validators/internal/OpenApiArrayValidator.mjs.map +1 -0
  343. package/lib/validators/internal/OpenApiBooleanValidator.d.ts +5 -0
  344. package/lib/validators/internal/OpenApiBooleanValidator.js +10 -0
  345. package/lib/validators/internal/OpenApiBooleanValidator.js.map +1 -0
  346. package/lib/validators/internal/OpenApiBooleanValidator.mjs +9 -0
  347. package/lib/validators/internal/OpenApiBooleanValidator.mjs.map +1 -0
  348. package/lib/validators/internal/OpenApiConstantValidator.d.ts +5 -0
  349. package/lib/validators/internal/OpenApiConstantValidator.js +10 -0
  350. package/lib/validators/internal/OpenApiConstantValidator.js.map +1 -0
  351. package/lib/validators/internal/OpenApiConstantValidator.mjs +9 -0
  352. package/lib/validators/internal/OpenApiConstantValidator.mjs.map +1 -0
  353. package/lib/validators/internal/OpenApiIntegerValidator.d.ts +5 -0
  354. package/lib/validators/internal/OpenApiIntegerValidator.js +33 -0
  355. package/lib/validators/internal/OpenApiIntegerValidator.js.map +1 -0
  356. package/lib/validators/internal/OpenApiIntegerValidator.mjs +47 -0
  357. package/lib/validators/internal/OpenApiIntegerValidator.mjs.map +1 -0
  358. package/lib/validators/internal/OpenApiNumberValidator.d.ts +5 -0
  359. package/lib/validators/internal/OpenApiNumberValidator.js +33 -0
  360. package/lib/validators/internal/OpenApiNumberValidator.js.map +1 -0
  361. package/lib/validators/internal/OpenApiNumberValidator.mjs +47 -0
  362. package/lib/validators/internal/OpenApiNumberValidator.mjs.map +1 -0
  363. package/lib/validators/internal/OpenApiObjectValidator.d.ts +5 -0
  364. package/lib/validators/internal/OpenApiObjectValidator.js +58 -0
  365. package/lib/validators/internal/OpenApiObjectValidator.js.map +1 -0
  366. package/lib/validators/internal/OpenApiObjectValidator.mjs +68 -0
  367. package/lib/validators/internal/OpenApiObjectValidator.mjs.map +1 -0
  368. package/lib/validators/internal/OpenApiOneOfValidator.d.ts +5 -0
  369. package/lib/validators/internal/OpenApiOneOfValidator.js +182 -0
  370. package/lib/validators/internal/OpenApiOneOfValidator.js.map +1 -0
  371. package/lib/validators/internal/OpenApiOneOfValidator.mjs +206 -0
  372. package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -0
  373. package/lib/validators/internal/OpenApiSchemaNamingRule.d.ts +4 -0
  374. package/lib/validators/internal/OpenApiSchemaNamingRule.js +122 -0
  375. package/lib/validators/internal/OpenApiSchemaNamingRule.js.map +1 -0
  376. package/lib/validators/internal/OpenApiSchemaNamingRule.mjs +121 -0
  377. package/lib/validators/internal/OpenApiSchemaNamingRule.mjs.map +1 -0
  378. package/lib/validators/internal/OpenApiStationValidator.d.ts +5 -0
  379. package/lib/validators/internal/OpenApiStationValidator.js +63 -0
  380. package/lib/validators/internal/OpenApiStationValidator.js.map +1 -0
  381. package/lib/validators/internal/OpenApiStationValidator.mjs +107 -0
  382. package/lib/validators/internal/OpenApiStationValidator.mjs.map +1 -0
  383. package/lib/validators/internal/OpenApiStringValidator.d.ts +5 -0
  384. package/lib/validators/internal/OpenApiStringValidator.js +73 -0
  385. package/lib/validators/internal/OpenApiStringValidator.js.map +1 -0
  386. package/lib/validators/internal/OpenApiStringValidator.mjs +85 -0
  387. package/lib/validators/internal/OpenApiStringValidator.mjs.map +1 -0
  388. package/lib/validators/internal/OpenApiTupleValidator.d.ts +5 -0
  389. package/lib/validators/internal/OpenApiTupleValidator.js +31 -0
  390. package/lib/validators/internal/OpenApiTupleValidator.js.map +1 -0
  391. package/lib/validators/internal/OpenApiTupleValidator.mjs +46 -0
  392. package/lib/validators/internal/OpenApiTupleValidator.mjs.map +1 -0
  393. package/package.json +91 -0
  394. package/src/converters/LlmSchemaConverter.ts +924 -0
  395. package/src/converters/OpenApiConverter.ts +285 -0
  396. package/src/converters/index.ts +5 -0
  397. package/src/converters/internal/LlmDescriptionInverter.ts +178 -0
  398. package/src/converters/internal/LlmParametersComposer.ts +52 -0
  399. package/src/converters/internal/OpenApiConstraintShifter.ts +154 -0
  400. package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -0
  401. package/src/converters/internal/OpenApiV3Downgrader.ts +355 -0
  402. package/src/converters/internal/OpenApiV3Upgrader.ts +470 -0
  403. package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -0
  404. package/src/converters/internal/SwaggerV2Downgrader.ts +424 -0
  405. package/src/converters/internal/SwaggerV2Upgrader.ts +523 -0
  406. package/src/http/HttpError.ts +107 -0
  407. package/src/http/HttpLlm.ts +210 -0
  408. package/src/http/HttpMigration.ts +92 -0
  409. package/src/http/index.ts +3 -0
  410. package/src/http/internal/HttpLlmApplicationComposer.ts +308 -0
  411. package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -0
  412. package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -0
  413. package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -0
  414. package/src/http/internal/HttpMigrateRouteComposer.ts +513 -0
  415. package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -0
  416. package/src/http/internal/LlmDataMerger.ts +73 -0
  417. package/src/index.ts +4 -0
  418. package/src/utils/ArrayUtil.ts +42 -0
  419. package/src/utils/MapUtil.ts +15 -0
  420. package/src/utils/NamingConvention.ts +205 -0
  421. package/src/utils/Singleton.ts +17 -0
  422. package/src/utils/StringUtil.ts +14 -0
  423. package/src/utils/dedent.ts +57 -0
  424. package/src/utils/index.ts +8 -0
  425. package/src/utils/internal/EndpointUtil.ts +44 -0
  426. package/src/utils/internal/JsonDescriptor.ts +70 -0
  427. package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -0
  428. package/src/utils/stringifyValidationFailure.ts +415 -0
  429. package/src/validators/LlmTypeChecker.ts +402 -0
  430. package/src/validators/OpenApiTypeChecker.ts +297 -0
  431. package/src/validators/OpenApiV3TypeChecker.ts +70 -0
  432. package/src/validators/OpenApiV3_1TypeChecker.ts +86 -0
  433. package/src/validators/OpenApiValidator.ts +94 -0
  434. package/src/validators/SwaggerV2TypeChecker.ts +71 -0
  435. package/src/validators/functional/_isBigintString.ts +8 -0
  436. package/src/validators/functional/_isFormatByte.ts +7 -0
  437. package/src/validators/functional/_isFormatDate.ts +3 -0
  438. package/src/validators/functional/_isFormatDateTime.ts +4 -0
  439. package/src/validators/functional/_isFormatDuration.ts +4 -0
  440. package/src/validators/functional/_isFormatEmail.ts +4 -0
  441. package/src/validators/functional/_isFormatHostname.ts +4 -0
  442. package/src/validators/functional/_isFormatIdnEmail.ts +4 -0
  443. package/src/validators/functional/_isFormatIdnHostname.ts +4 -0
  444. package/src/validators/functional/_isFormatIpv4.ts +4 -0
  445. package/src/validators/functional/_isFormatIpv6.ts +4 -0
  446. package/src/validators/functional/_isFormatIri.ts +3 -0
  447. package/src/validators/functional/_isFormatIriReference.ts +4 -0
  448. package/src/validators/functional/_isFormatJsonPointer.ts +3 -0
  449. package/src/validators/functional/_isFormatPassword.ts +1 -0
  450. package/src/validators/functional/_isFormatRegex.ts +8 -0
  451. package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -0
  452. package/src/validators/functional/_isFormatTime.ts +4 -0
  453. package/src/validators/functional/_isFormatUri.ts +6 -0
  454. package/src/validators/functional/_isFormatUriReference.ts +5 -0
  455. package/src/validators/functional/_isFormatUriTemplate.ts +4 -0
  456. package/src/validators/functional/_isFormatUrl.ts +4 -0
  457. package/src/validators/functional/_isFormatUuid.ts +3 -0
  458. package/src/validators/functional/_isUniqueItems.ts +159 -0
  459. package/src/validators/index.ts +14 -0
  460. package/src/validators/internal/IOpenApiValidatorContext.ts +17 -0
  461. package/src/validators/internal/OpenApiArrayValidator.ts +49 -0
  462. package/src/validators/internal/OpenApiBooleanValidator.ts +11 -0
  463. package/src/validators/internal/OpenApiConstantValidator.ts +11 -0
  464. package/src/validators/internal/OpenApiIntegerValidator.ts +49 -0
  465. package/src/validators/internal/OpenApiNumberValidator.ts +48 -0
  466. package/src/validators/internal/OpenApiObjectValidator.ts +83 -0
  467. package/src/validators/internal/OpenApiOneOfValidator.ts +309 -0
  468. package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -0
  469. package/src/validators/internal/OpenApiStationValidator.ts +115 -0
  470. package/src/validators/internal/OpenApiStringValidator.ts +88 -0
  471. package/src/validators/internal/OpenApiTupleValidator.ts +55 -0
@@ -0,0 +1,402 @@
1
+ import { ILlmSchema } from "@typia/interface";
2
+
3
+ import { MapUtil } from "../utils/MapUtil";
4
+ import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
5
+
6
+ /**
7
+ * Type checker for LLM function calling schema.
8
+ *
9
+ * `LlmTypeChecker` is a type checker of {@link ILlmSchema}, the type schema for
10
+ * LLM (Large Language Model) function calling.
11
+ *
12
+ * This checker provides type guard functions for validating schema types, and
13
+ * operators for traversing and comparing schemas.
14
+ *
15
+ * @author Jeongho Nam - https://github.com/samchon
16
+ */
17
+ export namespace LlmTypeChecker {
18
+ /* -----------------------------------------------------------
19
+ TYPE CHECKERS
20
+ ----------------------------------------------------------- */
21
+ /**
22
+ * Test whether the schema is a null type.
23
+ *
24
+ * @param schema Target schema
25
+ * @returns Whether null type or not
26
+ */
27
+ export const isNull = (schema: ILlmSchema): schema is ILlmSchema.INull =>
28
+ (schema as ILlmSchema.INull).type === "null";
29
+
30
+ /**
31
+ * Test whether the schema is an unknown type.
32
+ *
33
+ * @param schema Target schema
34
+ * @returns Whether unknown type or not
35
+ */
36
+ export const isUnknown = (
37
+ schema: ILlmSchema,
38
+ ): schema is ILlmSchema.IUnknown =>
39
+ (schema as ILlmSchema.IUnknown).type === undefined &&
40
+ !isAnyOf(schema) &&
41
+ !isReference(schema);
42
+
43
+ /**
44
+ * Test whether the schema is a boolean type.
45
+ *
46
+ * @param schema Target schema
47
+ * @returns Whether boolean type or not
48
+ */
49
+ export const isBoolean = (
50
+ schema: ILlmSchema,
51
+ ): schema is ILlmSchema.IBoolean =>
52
+ (schema as ILlmSchema.IBoolean).type === "boolean";
53
+
54
+ /**
55
+ * Test whether the schema is an integer type.
56
+ *
57
+ * @param schema Target schema
58
+ * @returns Whether integer type or not
59
+ */
60
+ export const isInteger = (
61
+ schema: ILlmSchema,
62
+ ): schema is ILlmSchema.IInteger =>
63
+ (schema as ILlmSchema.IInteger).type === "integer";
64
+
65
+ /**
66
+ * Test whether the schema is a number type.
67
+ *
68
+ * @param schema Target schema
69
+ * @returns Whether number type or not
70
+ */
71
+ export const isNumber = (schema: ILlmSchema): schema is ILlmSchema.INumber =>
72
+ (schema as ILlmSchema.INumber).type === "number";
73
+
74
+ /**
75
+ * Test whether the schema is a string type.
76
+ *
77
+ * @param schema Target schema
78
+ * @returns Whether string type or not
79
+ */
80
+ export const isString = (schema: ILlmSchema): schema is ILlmSchema.IString =>
81
+ (schema as ILlmSchema.IString).type === "string";
82
+
83
+ /**
84
+ * Test whether the schema is an array type.
85
+ *
86
+ * @param schema Target schema
87
+ * @returns Whether array type or not
88
+ */
89
+ export const isArray = (schema: ILlmSchema): schema is ILlmSchema.IArray =>
90
+ (schema as ILlmSchema.IArray).type === "array" &&
91
+ (schema as ILlmSchema.IArray).items !== undefined;
92
+
93
+ /**
94
+ * Test whether the schema is an object type.
95
+ *
96
+ * @param schema Target schema
97
+ * @returns Whether object type or not
98
+ */
99
+ export const isObject = (schema: ILlmSchema): schema is ILlmSchema.IObject =>
100
+ (schema as ILlmSchema.IObject).type === "object";
101
+
102
+ /**
103
+ * Test whether the schema is a reference type.
104
+ *
105
+ * @param schema Target schema
106
+ * @returns Whether reference type or not
107
+ */
108
+ export const isReference = (
109
+ schema: ILlmSchema,
110
+ ): schema is ILlmSchema.IReference => (schema as any).$ref !== undefined;
111
+
112
+ /**
113
+ * Test whether the schema is a union type.
114
+ *
115
+ * @param schema Target schema
116
+ * @returns Whether union type or not
117
+ */
118
+ export const isAnyOf = (schema: ILlmSchema): schema is ILlmSchema.IAnyOf =>
119
+ (schema as ILlmSchema.IAnyOf).anyOf !== undefined;
120
+
121
+ /* -----------------------------------------------------------
122
+ OPERATORS
123
+ ----------------------------------------------------------- */
124
+ /**
125
+ * Visit every nested schemas.
126
+ *
127
+ * Visit every nested schemas of the target, and apply the `props.closure`
128
+ * function.
129
+ *
130
+ * Here is the list of occurring nested visitings:
131
+ *
132
+ * - {@link ILlmSchema.IAnyOf.anyOf}
133
+ * - {@link ILlmSchema.IReference}
134
+ * - {@link ILlmSchema.IObject.properties}
135
+ * - {@link ILlmSchema.IArray.items}
136
+ *
137
+ * @param props Properties for visiting
138
+ */
139
+ export const visit = (props: {
140
+ closure: (schema: ILlmSchema, accessor: string) => void;
141
+ $defs?: Record<string, ILlmSchema> | undefined;
142
+ schema: ILlmSchema;
143
+ accessor?: string;
144
+ refAccessor?: string;
145
+ }): void => {
146
+ const already: Set<string> = new Set();
147
+ const refAccessor: string = props.refAccessor ?? "$input.$defs";
148
+ const next = (schema: ILlmSchema, accessor: string): void => {
149
+ props.closure(schema, accessor);
150
+ if (LlmTypeChecker.isReference(schema)) {
151
+ const key: string = schema.$ref.split("#/$defs/").pop()!;
152
+ if (already.has(key) === true) return;
153
+ already.add(key);
154
+ const found: ILlmSchema | undefined = props.$defs?.[key];
155
+ if (found !== undefined) next(found, `${refAccessor}[${key}]`);
156
+ } else if (LlmTypeChecker.isAnyOf(schema))
157
+ schema.anyOf.forEach((s, i) => next(s, `${accessor}.anyOf[${i}]`));
158
+ else if (LlmTypeChecker.isObject(schema)) {
159
+ for (const [key, value] of Object.entries(schema.properties))
160
+ next(value, `${accessor}.properties[${JSON.stringify(key)}]`);
161
+ if (
162
+ typeof schema.additionalProperties === "object" &&
163
+ schema.additionalProperties !== null
164
+ )
165
+ next(schema.additionalProperties, `${accessor}.additionalProperties`);
166
+ } else if (LlmTypeChecker.isArray(schema))
167
+ next(schema.items, `${accessor}.items`);
168
+ };
169
+ next(props.schema, props.accessor ?? "$input.schemas");
170
+ };
171
+
172
+ /**
173
+ * Test whether the `x` schema covers the `y` schema.
174
+ *
175
+ * @param props Properties for testing
176
+ * @returns Whether the `x` schema covers the `y` schema
177
+ */
178
+ export const covers = (props: {
179
+ $defs?: Record<string, ILlmSchema> | undefined;
180
+ x: ILlmSchema;
181
+ y: ILlmSchema;
182
+ }): boolean =>
183
+ coverStation({
184
+ $defs: props.$defs,
185
+ x: props.x,
186
+ y: props.y,
187
+ visited: new Map(),
188
+ });
189
+
190
+ const coverStation = (p: {
191
+ $defs?: Record<string, ILlmSchema> | undefined;
192
+ visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
193
+ x: ILlmSchema;
194
+ y: ILlmSchema;
195
+ }): boolean => {
196
+ const cache: boolean | undefined = p.visited.get(p.x)?.get(p.y);
197
+ if (cache !== undefined) return cache;
198
+
199
+ // FOR RECURSIVE CASE
200
+ const nested: Map<ILlmSchema, boolean> = MapUtil.take(
201
+ p.visited,
202
+ p.x,
203
+ () => new Map(),
204
+ );
205
+ nested.set(p.y, true);
206
+
207
+ // COMPUTE IT
208
+ const result: boolean = coverSchema(p);
209
+ nested.set(p.y, result);
210
+ return result;
211
+ };
212
+
213
+ const coverSchema = (p: {
214
+ $defs?: Record<string, ILlmSchema> | undefined;
215
+ visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
216
+ x: ILlmSchema;
217
+ y: ILlmSchema;
218
+ }): boolean => {
219
+ // CHECK EQUALITY
220
+ if (p.x === p.y) return true;
221
+ else if (isReference(p.x) && isReference(p.y) && p.x.$ref === p.y.$ref)
222
+ return true;
223
+
224
+ // COMPARE WITH FLATTENING
225
+ const alpha: ILlmSchema[] = flatSchema(p.$defs, p.x);
226
+ const beta: ILlmSchema[] = flatSchema(p.$defs, p.y);
227
+ if (alpha.some((x) => isUnknown(x))) return true;
228
+ else if (beta.some((x) => isUnknown(x))) return false;
229
+ return beta.every((b) =>
230
+ alpha.some((a) =>
231
+ coverEscapedSchema({
232
+ $defs: p.$defs,
233
+ visited: p.visited,
234
+ x: a,
235
+ y: b,
236
+ }),
237
+ ),
238
+ );
239
+ };
240
+
241
+ const coverEscapedSchema = (p: {
242
+ $defs?: Record<string, ILlmSchema> | undefined;
243
+ visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
244
+ x: ILlmSchema;
245
+ y: ILlmSchema;
246
+ }): boolean => {
247
+ // CHECK EQUALITY
248
+ if (p.x === p.y) return true;
249
+ else if (isUnknown(p.x)) return true;
250
+ else if (isUnknown(p.y)) return false;
251
+ else if (isNull(p.x)) return isNull(p.y);
252
+ // ATOMIC CASE
253
+ else if (isBoolean(p.x)) return isBoolean(p.y) && coverBoolean(p.x, p.y);
254
+ else if (isInteger(p.x)) return isInteger(p.y) && coverInteger(p.x, p.y);
255
+ else if (isNumber(p.x)) return isNumber(p.y) && coverNumber(p.x, p.y);
256
+ else if (isString(p.x)) return isString(p.y) && coverString(p.x, p.y);
257
+ // INSTANCE CASE
258
+ else if (isArray(p.x))
259
+ return (
260
+ isArray(p.y) &&
261
+ coverArray({
262
+ $defs: p.$defs,
263
+ visited: p.visited,
264
+ x: p.x,
265
+ y: p.y,
266
+ })
267
+ );
268
+ else if (isObject(p.x))
269
+ return (
270
+ isObject(p.y) &&
271
+ coverObject({
272
+ $defs: p.$defs,
273
+ visited: p.visited,
274
+ x: p.x,
275
+ y: p.y,
276
+ })
277
+ );
278
+ else if (isReference(p.x)) return isReference(p.y) && p.x.$ref === p.y.$ref;
279
+ return false;
280
+ };
281
+
282
+ const coverArray = (p: {
283
+ $defs?: Record<string, ILlmSchema> | undefined;
284
+ visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
285
+ x: ILlmSchema.IArray;
286
+ y: ILlmSchema.IArray;
287
+ }): boolean => {
288
+ if (
289
+ !(
290
+ p.x.minItems === undefined ||
291
+ (p.y.minItems !== undefined && p.x.minItems <= p.y.minItems)
292
+ )
293
+ )
294
+ return false;
295
+ else if (
296
+ !(
297
+ p.x.maxItems === undefined ||
298
+ (p.y.maxItems !== undefined && p.x.maxItems >= p.y.maxItems)
299
+ )
300
+ )
301
+ return false;
302
+ return coverStation({
303
+ $defs: p.$defs,
304
+ visited: p.visited,
305
+ x: p.x.items,
306
+ y: p.y.items,
307
+ });
308
+ };
309
+
310
+ const coverObject = (p: {
311
+ $defs?: Record<string, ILlmSchema> | undefined;
312
+ visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
313
+ x: ILlmSchema.IObject;
314
+ y: ILlmSchema.IObject;
315
+ }): boolean => {
316
+ if (!p.x.additionalProperties && !!p.y.additionalProperties) return false;
317
+ else if (
318
+ !!p.x.additionalProperties &&
319
+ !!p.y.additionalProperties &&
320
+ ((typeof p.x.additionalProperties === "object" &&
321
+ p.y.additionalProperties === true) ||
322
+ (typeof p.x.additionalProperties === "object" &&
323
+ typeof p.y.additionalProperties === "object" &&
324
+ !coverStation({
325
+ $defs: p.$defs,
326
+ visited: p.visited,
327
+ x: p.x.additionalProperties,
328
+ y: p.y.additionalProperties,
329
+ })))
330
+ )
331
+ return false;
332
+ return Object.entries(p.y.properties ?? {}).every(([key, b]) => {
333
+ const a: ILlmSchema | undefined = p.x.properties?.[key];
334
+ if (a === undefined) return false;
335
+ else if (
336
+ (p.x.required?.includes(key) ?? false) === true &&
337
+ (p.y.required?.includes(key) ?? false) === false
338
+ )
339
+ return false;
340
+ return coverStation({
341
+ $defs: p.$defs,
342
+ visited: p.visited,
343
+ x: a,
344
+ y: b,
345
+ });
346
+ });
347
+ };
348
+
349
+ const coverBoolean = (
350
+ x: ILlmSchema.IBoolean,
351
+ y: ILlmSchema.IBoolean,
352
+ ): boolean => {
353
+ if (!!x.enum?.length)
354
+ return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
355
+ return true;
356
+ };
357
+
358
+ const coverInteger = (
359
+ x: ILlmSchema.IInteger,
360
+ y: ILlmSchema.IInteger,
361
+ ): boolean => {
362
+ if (!!x.enum?.length)
363
+ return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
364
+ return OpenApiTypeCheckerBase.coverInteger(x, y);
365
+ };
366
+
367
+ const coverNumber = (
368
+ x: ILlmSchema.INumber,
369
+ y: ILlmSchema.IInteger | ILlmSchema.INumber,
370
+ ): boolean => {
371
+ if (!!x.enum?.length)
372
+ return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
373
+ return OpenApiTypeCheckerBase.coverNumber(x, y);
374
+ };
375
+
376
+ const coverString = (
377
+ x: ILlmSchema.IString,
378
+ y: ILlmSchema.IString,
379
+ ): boolean => {
380
+ if (!!x.enum?.length)
381
+ return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
382
+ return OpenApiTypeCheckerBase.coverString(x, y);
383
+ };
384
+
385
+ const flatSchema = (
386
+ $defs: Record<string, ILlmSchema> | undefined,
387
+ schema: ILlmSchema,
388
+ ): ILlmSchema[] => {
389
+ schema = escapeReference($defs, schema);
390
+ if (isAnyOf(schema))
391
+ return schema.anyOf.map((v) => flatSchema($defs, v)).flat();
392
+ return [schema];
393
+ };
394
+
395
+ const escapeReference = (
396
+ $defs: Record<string, ILlmSchema> | undefined,
397
+ schema: ILlmSchema,
398
+ ): Exclude<ILlmSchema, ILlmSchema.IReference> =>
399
+ isReference(schema)
400
+ ? escapeReference($defs, $defs![schema.$ref.replace("#/$defs/", "")]!)
401
+ : schema;
402
+ }
@@ -0,0 +1,297 @@
1
+ import { IJsonSchemaTransformError, IResult, OpenApi } from "@typia/interface";
2
+
3
+ import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
4
+
5
+ /**
6
+ * Type checker for emended OpenAPI v3.1 JSON schemas.
7
+ *
8
+ * `OpenApiTypeChecker` provides type guard functions for
9
+ * {@link OpenApi.IJsonSchema} (typia's normalized OpenAPI format). Use these to
10
+ * narrow schema types before accessing type-specific properties.
11
+ *
12
+ * Type checkers:
13
+ *
14
+ * - Primitives: {@link isNull}, {@link isBoolean}, {@link isInteger},
15
+ * {@link isNumber}, {@link isString}
16
+ * - Constants: {@link isConstant}
17
+ * - Collections: {@link isArray}, {@link isTuple}, {@link isObject}
18
+ * - Composition: {@link isOneOf}, {@link isReference}
19
+ * - Special: {@link isUnknown}
20
+ *
21
+ * Also provides schema operations:
22
+ *
23
+ * - {@link visit}: Traverse and transform schemas recursively
24
+ * - {@link covers}: Check if one schema subsumes another
25
+ * - {@link escape}: Unwrap reference schemas
26
+ *
27
+ * For other OpenAPI versions, use {@link OpenApiV3TypeChecker},
28
+ * {@link OpenApiV3_1TypeChecker}, or {@link SwaggerV2TypeChecker}.
29
+ *
30
+ * @author Jeongho Nam - https://github.com/samchon
31
+ */
32
+ export namespace OpenApiTypeChecker {
33
+ /* -----------------------------------------------------------
34
+ TYPE CHECKERS
35
+ ----------------------------------------------------------- */
36
+ /**
37
+ * Test whether the schema is a nul type.
38
+ *
39
+ * @param schema Target schema
40
+ * @returns Whether null type or not
41
+ */
42
+ export const isNull = (
43
+ schema: OpenApi.IJsonSchema,
44
+ ): schema is OpenApi.IJsonSchema.INull =>
45
+ OpenApiTypeCheckerBase.isNull(schema);
46
+
47
+ /**
48
+ * Test whether the schema is an unknown type.
49
+ *
50
+ * @param schema Target schema
51
+ * @returns Whether unknown type or not
52
+ */
53
+ export const isUnknown = (
54
+ schema: OpenApi.IJsonSchema,
55
+ ): schema is OpenApi.IJsonSchema.IUnknown =>
56
+ OpenApiTypeCheckerBase.isUnknown(schema);
57
+
58
+ /**
59
+ * Test whether the schema is a constant type.
60
+ *
61
+ * @param schema Target schema
62
+ * @returns Whether constant type or not
63
+ */
64
+ export const isConstant = (
65
+ schema: OpenApi.IJsonSchema,
66
+ ): schema is OpenApi.IJsonSchema.IConstant =>
67
+ OpenApiTypeCheckerBase.isConstant(schema);
68
+
69
+ /**
70
+ * Test whether the schema is a boolean type.
71
+ *
72
+ * @param schema Target schema
73
+ * @returns Whether boolean type or not
74
+ */
75
+ export const isBoolean = (
76
+ schema: OpenApi.IJsonSchema,
77
+ ): schema is OpenApi.IJsonSchema.IBoolean =>
78
+ OpenApiTypeCheckerBase.isBoolean(schema);
79
+
80
+ /**
81
+ * Test whether the schema is an integer type.
82
+ *
83
+ * @param schema Target schema
84
+ * @returns Whether integer type or not
85
+ */
86
+ export const isInteger = (
87
+ schema: OpenApi.IJsonSchema,
88
+ ): schema is OpenApi.IJsonSchema.IInteger =>
89
+ OpenApiTypeCheckerBase.isInteger(schema);
90
+
91
+ /**
92
+ * Test whether the schema is a number type.
93
+ *
94
+ * @param schema Target schema
95
+ * @returns Whether number type or not
96
+ */
97
+ export const isNumber = (
98
+ schema: OpenApi.IJsonSchema,
99
+ ): schema is OpenApi.IJsonSchema.INumber =>
100
+ OpenApiTypeCheckerBase.isNumber(schema);
101
+
102
+ /**
103
+ * Test whether the schema is a string type.
104
+ *
105
+ * @param schema Target schema
106
+ * @returns Whether string type or not
107
+ */
108
+ export const isString = (
109
+ schema: OpenApi.IJsonSchema,
110
+ ): schema is OpenApi.IJsonSchema.IString =>
111
+ OpenApiTypeCheckerBase.isString(schema);
112
+
113
+ /**
114
+ * Test whether the schema is an array type.
115
+ *
116
+ * @param schema Target schema
117
+ * @returns Whether array type or not
118
+ */
119
+ export const isArray = (
120
+ schema: OpenApi.IJsonSchema,
121
+ ): schema is OpenApi.IJsonSchema.IArray =>
122
+ OpenApiTypeCheckerBase.isArray(schema);
123
+
124
+ /**
125
+ * Test whether the schema is a tuple type.
126
+ *
127
+ * @param schema Target schema
128
+ * @returns Whether tuple type or not
129
+ */
130
+ export const isTuple = (
131
+ schema: OpenApi.IJsonSchema,
132
+ ): schema is OpenApi.IJsonSchema.ITuple =>
133
+ OpenApiTypeCheckerBase.isTuple(schema);
134
+
135
+ /**
136
+ * Test whether the schema is an object type.
137
+ *
138
+ * @param schema Target schema
139
+ * @returns Whether object type or not
140
+ */
141
+ export const isObject = (
142
+ schema: OpenApi.IJsonSchema,
143
+ ): schema is OpenApi.IJsonSchema.IObject =>
144
+ OpenApiTypeCheckerBase.isObject(schema);
145
+
146
+ /**
147
+ * Test whether the schema is a reference type.
148
+ *
149
+ * @param schema Target schema
150
+ * @returns Whether reference type or not
151
+ */
152
+ export const isReference = (
153
+ schema: OpenApi.IJsonSchema,
154
+ ): schema is OpenApi.IJsonSchema.IReference =>
155
+ OpenApiTypeCheckerBase.isReference(schema);
156
+
157
+ /**
158
+ * Test whether the schema is an union type.
159
+ *
160
+ * @param schema Target schema
161
+ * @returns Whether union type or not
162
+ */
163
+ export const isOneOf = (
164
+ schema: OpenApi.IJsonSchema,
165
+ ): schema is OpenApi.IJsonSchema.IOneOf =>
166
+ OpenApiTypeCheckerBase.isOneOf(schema);
167
+
168
+ /**
169
+ * Test whether the schema is recursive reference type.
170
+ *
171
+ * Test whether the target schema is a reference type, and test one thing more
172
+ * that the reference is self-recursive or not.
173
+ *
174
+ * @param props Properties for recursive reference test
175
+ * @returns Whether the schema is recursive reference type or not
176
+ */
177
+ export const isRecursiveReference = (props: {
178
+ components: OpenApi.IComponents;
179
+ schema: OpenApi.IJsonSchema;
180
+ }): boolean =>
181
+ OpenApiTypeCheckerBase.isRecursiveReference({
182
+ prefix: "#/components/schemas/",
183
+ components: props.components,
184
+ schema: props.schema,
185
+ });
186
+
187
+ /* -----------------------------------------------------------
188
+ OPERATORS
189
+ ----------------------------------------------------------- */
190
+ /**
191
+ * Escape from the {@link OpenApi.IJsonSchema.IReference} type.
192
+ *
193
+ * Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the
194
+ * every references to the actual schemas. If the escape is successful, the
195
+ * returned schema never contains any {@link OpenApi.IJsonSchema.IReference}
196
+ * type in its structure.
197
+ *
198
+ * If the schema has a recursive reference, the recursive reference would be
199
+ * repeated as much as the `props.recursive` depth. If you've configured the
200
+ * `props.recursive` as `false` or `0`, it would be failed and return an
201
+ * {@link IJsonSchemaTransformError}. Also, if there's a
202
+ * {@link OpenApi.IJsonSchema.IReference} type which cannot find the matched
203
+ * type in the {@link OpenApi.IComponents.schemas}, it would also be failed and
204
+ * return an {@link IJsonSchemaTransformError} either.
205
+ *
206
+ * @param props Properties for escaping
207
+ * @returns Escaped schema, or error with reason
208
+ */
209
+ export const escape = (props: {
210
+ components: OpenApi.IComponents;
211
+ schema: OpenApi.IJsonSchema;
212
+ recursive: false | number;
213
+ accessor?: string;
214
+ refAccessor?: string;
215
+ }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
216
+ OpenApiTypeCheckerBase.escape({
217
+ ...props,
218
+ prefix: "#/components/schemas/",
219
+ method: "OpenApiTypeChecker.method",
220
+ });
221
+
222
+ /**
223
+ * Unreference the schema.
224
+ *
225
+ * Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference}
226
+ * type to the actual schema. Different with {@link escape} is, the
227
+ * `unreference` function does not resolve every references in the schema, but
228
+ * resolve only one time.
229
+ *
230
+ * If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find
231
+ * the matched type in the {@link OpenApi.IComponents.schemas}, and you've
232
+ * called this `unreference()` function with the reference, it would also be
233
+ * failed and return an {@link IJsonSchemaTransformError} value.
234
+ *
235
+ * @param props Properties of unreference
236
+ * @returns Unreferenced schema
237
+ */
238
+ export const unreference = (props: {
239
+ components: OpenApi.IComponents;
240
+ schema: OpenApi.IJsonSchema;
241
+ accessor?: string;
242
+ refAccessor?: string;
243
+ }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
244
+ OpenApiTypeCheckerBase.unreference({
245
+ ...props,
246
+ prefix: "#/components/schemas/",
247
+ method: "OpenApiTypeChecker.unreference",
248
+ });
249
+
250
+ /**
251
+ * Visit every nested schemas.
252
+ *
253
+ * Visit every nested schemas of the target, and apply the `props.closure`
254
+ * function.
255
+ *
256
+ * Here is the list of occurring nested visitings:
257
+ *
258
+ * - {@link OpenApi.IJsonSchema.IOneOf.oneOf}
259
+ * - {@link OpenApi.IJsonSchema.IReference}
260
+ * - {@link OpenApi.IJsonSchema.IObject.properties}
261
+ * - {@link OpenApi.IJsonSchema.IObject.additionalProperties}
262
+ * - {@link OpenApi.IJsonSchema.IArray.items}
263
+ * - {@link OpenApi.IJsonSchema.ITuple.prefixItems}
264
+ * - {@link OpenApi.IJsonSchema.ITuple.additionalItems}
265
+ *
266
+ * @param props Properties for visiting
267
+ */
268
+ export const visit = (props: {
269
+ closure: (schema: OpenApi.IJsonSchema, accessor: string) => void;
270
+ components: OpenApi.IComponents;
271
+ schema: OpenApi.IJsonSchema;
272
+ accessor?: string;
273
+ refAccessor?: string;
274
+ }): void =>
275
+ OpenApiTypeCheckerBase.visit({
276
+ ...props,
277
+ prefix: "#/components/schemas/",
278
+ });
279
+
280
+ /**
281
+ * Test whether the `x` schema covers the `y` schema.
282
+ *
283
+ * @param props Properties for testing
284
+ * @returns Whether the `x` schema covers the `y` schema
285
+ */
286
+ export const covers = (props: {
287
+ components: OpenApi.IComponents;
288
+ x: OpenApi.IJsonSchema;
289
+ y: OpenApi.IJsonSchema;
290
+ }): boolean =>
291
+ OpenApiTypeCheckerBase.covers({
292
+ prefix: "#/components/schemas/",
293
+ components: props.components,
294
+ x: props.x,
295
+ y: props.y,
296
+ });
297
+ }