@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,652 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LlmSchemaConverter = void 0;
4
+ const NamingConvention_1 = require("../utils/NamingConvention");
5
+ const JsonDescriptor_1 = require("../utils/internal/JsonDescriptor");
6
+ const LlmTypeChecker_1 = require("../validators/LlmTypeChecker");
7
+ const OpenApiTypeChecker_1 = require("../validators/OpenApiTypeChecker");
8
+ const OpenApiValidator_1 = require("../validators/OpenApiValidator");
9
+ const LlmDescriptionInverter_1 = require("./internal/LlmDescriptionInverter");
10
+ const LlmParametersComposer_1 = require("./internal/LlmParametersComposer");
11
+ const OpenApiConstraintShifter_1 = require("./internal/OpenApiConstraintShifter");
12
+ /**
13
+ * OpenAPI to LLM schema converter.
14
+ *
15
+ * `LlmSchemaConverter` converts OpenAPI JSON schemas to LLM-compatible
16
+ * {@link ILlmSchema} format. LLMs don't fully support JSON Schema, so this
17
+ * simplifies schemas by removing unsupported features (tuples, `const`, mixed
18
+ * unions).
19
+ *
20
+ * Main functions:
21
+ *
22
+ * - {@link parameters}: Convert object schema to {@link ILlmSchema.IParameters}
23
+ * - {@link schema}: Convert any schema to {@link ILlmSchema}
24
+ * - {@link separate}: Split parameters into LLM-fillable vs human-required
25
+ * - {@link invert}: Extract constraints from description back to schema
26
+ *
27
+ * Configuration options ({@link ILlmSchema.IConfig}):
28
+ *
29
+ * - `reference`: Allow `$ref` references (reduces tokens but may confuse LLM)
30
+ * - `strict`: OpenAI structured output mode (all properties required)
31
+ *
32
+ * @author Jeongho Nam - https://github.com/samchon
33
+ */
34
+ var LlmSchemaConverter;
35
+ (function (LlmSchemaConverter) {
36
+ /**
37
+ * Get configuration with defaults applied.
38
+ *
39
+ * @param config Partial configuration
40
+ * @returns Full configuration with defaults
41
+ */
42
+ LlmSchemaConverter.getConfig = (config) => {
43
+ var _a, _b;
44
+ return ({
45
+ reference: (_a = config === null || config === void 0 ? void 0 : config.reference) !== null && _a !== void 0 ? _a : true,
46
+ strict: (_b = config === null || config === void 0 ? void 0 : config.strict) !== null && _b !== void 0 ? _b : false,
47
+ });
48
+ };
49
+ /* -----------------------------------------------------------
50
+ CONVERTERS
51
+ ----------------------------------------------------------- */
52
+ /**
53
+ * Convert OpenAPI object schema to LLM parameters schema.
54
+ *
55
+ * @param props.config Conversion configuration
56
+ * @param props.components OpenAPI components for reference resolution
57
+ * @param props.schema Object or reference schema to convert
58
+ * @param props.accessor Error path accessor
59
+ * @param props.refAccessor Reference path accessor
60
+ * @returns Converted parameters or error
61
+ */
62
+ LlmSchemaConverter.parameters = (props) => {
63
+ const config = LlmSchemaConverter.getConfig(props.config);
64
+ const entity = LlmParametersComposer_1.LlmParametersFinder.parameters(Object.assign(Object.assign({}, props), { method: "LlmSchemaConverter.parameters" }));
65
+ if (entity.success === false)
66
+ return entity;
67
+ const $defs = {};
68
+ const result = transform(Object.assign(Object.assign({}, props), { config,
69
+ $defs, schema: entity.value }));
70
+ if (result.success === false)
71
+ return result;
72
+ return {
73
+ success: true,
74
+ value: Object.assign(Object.assign({}, result.value), { additionalProperties: false, $defs, description: OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(props.schema)
75
+ ? JsonDescriptor_1.JsonDescriptor.cascade({
76
+ prefix: "#/components/schemas/",
77
+ components: props.components,
78
+ schema: Object.assign(Object.assign({}, props.schema), { description: result.value.description }),
79
+ escape: true,
80
+ })
81
+ : result.value.description }),
82
+ };
83
+ };
84
+ /**
85
+ * Convert OpenAPI schema to LLM schema.
86
+ *
87
+ * @param props.config Conversion configuration
88
+ * @param props.components OpenAPI components for reference resolution
89
+ * @param props.$defs Definition store (mutated with referenced types)
90
+ * @param props.schema Schema to convert
91
+ * @param props.accessor Error path accessor
92
+ * @param props.refAccessor Reference path accessor
93
+ * @returns Converted schema or error
94
+ */
95
+ LlmSchemaConverter.schema = (props) => transform({
96
+ config: LlmSchemaConverter.getConfig(props.config),
97
+ components: props.components,
98
+ $defs: props.$defs,
99
+ schema: props.schema,
100
+ accessor: props.accessor,
101
+ refAccessor: props.refAccessor,
102
+ });
103
+ const transform = (props) => {
104
+ var _a, _b;
105
+ // PREPARE ASSETS
106
+ const union = [];
107
+ const attribute = Object.assign({ title: props.schema.title, description: props.schema.description, deprecated: props.schema.deprecated, readOnly: props.schema.readOnly, writeOnly: props.schema.writeOnly, example: props.schema.example, examples: props.schema.examples }, Object.fromEntries(Object.entries(props.schema).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
108
+ // VALIDADTE SCHEMA
109
+ const reasons = [];
110
+ OpenApiTypeChecker_1.OpenApiTypeChecker.visit({
111
+ closure: (next, accessor) => {
112
+ var _a, _b;
113
+ if (props.config.strict === true) {
114
+ // STRICT MODE VALIDATION
115
+ reasons.push(...validateStrict(next, accessor));
116
+ }
117
+ if (OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(next))
118
+ reasons.push({
119
+ accessor,
120
+ schema: next,
121
+ message: `LLM does not allow tuple type.`,
122
+ });
123
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(next)) {
124
+ // UNABLE TO FIND MATCHED REFERENCE
125
+ const key = (_a = next.$ref.split("#/components/schemas/")[1]) !== null && _a !== void 0 ? _a : next.$ref.split("/").at(-1);
126
+ if (((_b = props.components.schemas) === null || _b === void 0 ? void 0 : _b[key]) === undefined)
127
+ reasons.push({
128
+ schema: next,
129
+ accessor: accessor,
130
+ message: `unable to find reference type ${JSON.stringify(key)}.`,
131
+ });
132
+ }
133
+ },
134
+ components: props.components,
135
+ schema: props.schema,
136
+ accessor: props.accessor,
137
+ refAccessor: props.refAccessor,
138
+ });
139
+ if (reasons.length > 0)
140
+ return {
141
+ success: false,
142
+ error: {
143
+ method: "LlmSchemaConverter.schema",
144
+ message: "Failed to compose LLM schema",
145
+ reasons,
146
+ },
147
+ };
148
+ const visitConstant = (input) => {
149
+ const insert = (value) => {
150
+ var _a;
151
+ const matched = union.find((u) => (u === null || u === void 0 ? void 0 : u.type) === typeof value);
152
+ if (matched !== undefined) {
153
+ (_a = matched.enum) !== null && _a !== void 0 ? _a : (matched.enum = []);
154
+ matched.enum.push(value);
155
+ }
156
+ else
157
+ union.push({
158
+ type: typeof value,
159
+ enum: [value],
160
+ });
161
+ };
162
+ if (OpenApiTypeChecker_1.OpenApiTypeChecker.isConstant(input))
163
+ insert(input.const);
164
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(input))
165
+ input.oneOf.forEach(visitConstant);
166
+ };
167
+ const visit = (input, accessor) => {
168
+ var _a, _b, _c, _d, _e;
169
+ if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(input)) {
170
+ // UNION TYPE
171
+ input.oneOf.forEach((s, i) => visit(s, `${accessor}.oneOf[${i}]`));
172
+ }
173
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(input)) {
174
+ // REFERENCE TYPE
175
+ const key = (_a = input.$ref.split("#/components/schemas/")[1]) !== null && _a !== void 0 ? _a : input.$ref.split("/").at(-1);
176
+ const target = (_b = props.components.schemas) === null || _b === void 0 ? void 0 : _b[key];
177
+ if (target === undefined)
178
+ return;
179
+ else if (
180
+ // KEEP THE REFERENCE TYPE
181
+ props.config.reference === true ||
182
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isRecursiveReference({
183
+ components: props.components,
184
+ schema: input,
185
+ })) {
186
+ const out = () => {
187
+ union.push(Object.assign(Object.assign({}, input), { $ref: `#/$defs/${key}` }));
188
+ };
189
+ if (props.$defs[key] !== undefined)
190
+ return out();
191
+ props.$defs[key] = {};
192
+ const converted = transform({
193
+ config: props.config,
194
+ components: props.components,
195
+ $defs: props.$defs,
196
+ schema: target,
197
+ refAccessor: props.refAccessor,
198
+ accessor: `${(_c = props.refAccessor) !== null && _c !== void 0 ? _c : "$def"}[${JSON.stringify(key)}]`,
199
+ });
200
+ if (converted.success === false)
201
+ return; // UNREACHABLE
202
+ props.$defs[key] = converted.value;
203
+ return out();
204
+ }
205
+ else {
206
+ // DISCARD THE REFERENCE TYPE
207
+ const length = union.length;
208
+ visit(target, accessor);
209
+ visitConstant(target);
210
+ if (length === union.length - 1)
211
+ union[union.length - 1] = Object.assign(Object.assign({}, union[union.length - 1]), { description: JsonDescriptor_1.JsonDescriptor.cascade({
212
+ prefix: "#/components/schemas/",
213
+ components: props.components,
214
+ schema: input,
215
+ escape: true,
216
+ }) });
217
+ else
218
+ attribute.description = JsonDescriptor_1.JsonDescriptor.cascade({
219
+ prefix: "#/components/schemas/",
220
+ components: props.components,
221
+ schema: input,
222
+ escape: true,
223
+ });
224
+ }
225
+ }
226
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(input)) {
227
+ // OBJECT TYPE
228
+ const properties = Object.fromEntries(Object.entries((_d = input.properties) !== null && _d !== void 0 ? _d : {})
229
+ .map(([key, value]) => {
230
+ var _a;
231
+ const converted = transform({
232
+ config: props.config,
233
+ components: props.components,
234
+ $defs: props.$defs,
235
+ schema: value,
236
+ refAccessor: props.refAccessor,
237
+ accessor: `${(_a = props.accessor) !== null && _a !== void 0 ? _a : "$input.schema"}.properties[${JSON.stringify(key)}]`,
238
+ });
239
+ if (converted.success === false) {
240
+ reasons.push(...converted.error.reasons);
241
+ return [key, null];
242
+ }
243
+ return [key, converted.value];
244
+ })
245
+ .filter(([, value]) => value !== null));
246
+ if (Object.values(properties).some((v) => v === null))
247
+ return;
248
+ const additionalProperties = (() => {
249
+ if (typeof input.additionalProperties === "object" &&
250
+ input.additionalProperties !== null) {
251
+ const converted = transform({
252
+ config: props.config,
253
+ components: props.components,
254
+ $defs: props.$defs,
255
+ schema: input.additionalProperties,
256
+ refAccessor: props.refAccessor,
257
+ accessor: `${accessor}.additionalProperties`,
258
+ });
259
+ if (converted.success === false) {
260
+ reasons.push(...converted.error.reasons);
261
+ return null;
262
+ }
263
+ return converted.value;
264
+ }
265
+ return props.config.strict === true
266
+ ? false
267
+ : input.additionalProperties;
268
+ })();
269
+ if (additionalProperties === null)
270
+ return;
271
+ union.push(Object.assign(Object.assign({}, input), { properties,
272
+ additionalProperties, required: (_e = input.required) !== null && _e !== void 0 ? _e : [], description: props.config.strict === true
273
+ ? JsonDescriptor_1.JsonDescriptor.take(input)
274
+ : input.description }));
275
+ }
276
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(input)) {
277
+ // ARRAY TYPE
278
+ const items = transform({
279
+ config: props.config,
280
+ components: props.components,
281
+ $defs: props.$defs,
282
+ schema: input.items,
283
+ refAccessor: props.refAccessor,
284
+ accessor: `${accessor}.items`,
285
+ });
286
+ if (items.success === false) {
287
+ reasons.push(...items.error.reasons);
288
+ return;
289
+ }
290
+ union.push(props.config.strict === true
291
+ ? OpenApiConstraintShifter_1.OpenApiConstraintShifter.shiftArray(Object.assign(Object.assign({}, input), { items: items.value }))
292
+ : Object.assign(Object.assign({}, input), { items: items.value }));
293
+ }
294
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isString(input))
295
+ union.push(props.config.strict === true
296
+ ? OpenApiConstraintShifter_1.OpenApiConstraintShifter.shiftString(Object.assign({}, input))
297
+ : input);
298
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(input) ||
299
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isInteger(input))
300
+ union.push(props.config.strict === true
301
+ ? OpenApiConstraintShifter_1.OpenApiConstraintShifter.shiftNumeric(Object.assign({}, input))
302
+ : input);
303
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(input))
304
+ return; // UNREACHABLE
305
+ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isConstant(input) === false)
306
+ union.push(Object.assign({}, input));
307
+ };
308
+ visitConstant(props.schema);
309
+ visit(props.schema, (_a = props.accessor) !== null && _a !== void 0 ? _a : "$input.schema");
310
+ if (reasons.length > 0)
311
+ return {
312
+ success: false,
313
+ error: {
314
+ method: "LlmSchemaConverter.schema",
315
+ message: "Failed to compose LLM schema",
316
+ reasons,
317
+ },
318
+ };
319
+ else if (union.length === 0)
320
+ return {
321
+ // unknown type
322
+ success: true,
323
+ value: Object.assign(Object.assign({}, attribute), { type: undefined }),
324
+ };
325
+ else if (union.length === 1)
326
+ return {
327
+ // single type
328
+ success: true,
329
+ value: Object.assign(Object.assign(Object.assign({}, attribute), union[0]), { description: props.config.strict === true &&
330
+ LlmTypeChecker_1.LlmTypeChecker.isReference(union[0])
331
+ ? undefined
332
+ : ((_b = union[0].description) !== null && _b !== void 0 ? _b : attribute.description) }),
333
+ };
334
+ return {
335
+ success: true,
336
+ value: Object.assign(Object.assign({}, attribute), { anyOf: union.map((u) => (Object.assign(Object.assign({}, u), { description: props.config.strict === true && LlmTypeChecker_1.LlmTypeChecker.isReference(u)
337
+ ? undefined
338
+ : u.description }))), "x-discriminator": OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(props.schema) &&
339
+ props.schema.discriminator !== undefined &&
340
+ props.schema.oneOf.length === union.length &&
341
+ union.every((e) => LlmTypeChecker_1.LlmTypeChecker.isReference(e) || LlmTypeChecker_1.LlmTypeChecker.isNull(e))
342
+ ? {
343
+ propertyName: props.schema.discriminator.propertyName,
344
+ mapping: props.schema.discriminator.mapping !== undefined
345
+ ? Object.fromEntries(Object.entries(props.schema.discriminator.mapping).map(([key, value]) => [
346
+ key,
347
+ `#/$defs/${value.split("/").at(-1)}`,
348
+ ]))
349
+ : undefined,
350
+ }
351
+ : undefined }),
352
+ };
353
+ };
354
+ /* -----------------------------------------------------------
355
+ INVERTERS
356
+ ----------------------------------------------------------- */
357
+ /**
358
+ * Convert LLM schema back to OpenAPI schema.
359
+ *
360
+ * Restores constraint information from description tags and converts `$defs`
361
+ * references to `#/components/schemas`.
362
+ *
363
+ * @param props.components Target components (mutated with definitions)
364
+ * @param props.schema LLM schema to invert
365
+ * @param props.$defs LLM schema definitions
366
+ * @returns OpenAPI JSON schema
367
+ */
368
+ LlmSchemaConverter.invert = (props) => {
369
+ const union = [];
370
+ const attribute = Object.assign({ title: props.schema.title, description: props.schema.description, deprecated: props.schema.deprecated, readOnly: props.schema.readOnly, writeOnly: props.schema.writeOnly, example: props.schema.example, examples: props.schema.examples }, Object.fromEntries(Object.entries(props.schema).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
371
+ const next = (schema) => LlmSchemaConverter.invert({
372
+ components: props.components,
373
+ $defs: props.$defs,
374
+ schema,
375
+ });
376
+ const visit = (schema) => {
377
+ var _a, _b, _c, _d, _e, _f, _g;
378
+ var _h;
379
+ if (LlmTypeChecker_1.LlmTypeChecker.isArray(schema))
380
+ union.push(Object.assign(Object.assign(Object.assign({}, schema), LlmDescriptionInverter_1.LlmDescriptionInverter.array(schema.description)), { items: next(schema.items) }));
381
+ else if (LlmTypeChecker_1.LlmTypeChecker.isObject(schema))
382
+ union.push(Object.assign(Object.assign({}, schema), { properties: Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => [
383
+ key,
384
+ next(value),
385
+ ])), additionalProperties: typeof schema.additionalProperties === "object" &&
386
+ schema.additionalProperties !== null
387
+ ? next(schema.additionalProperties)
388
+ : schema.additionalProperties }));
389
+ else if (LlmTypeChecker_1.LlmTypeChecker.isAnyOf(schema))
390
+ schema.anyOf.forEach(visit);
391
+ else if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
392
+ const key = (_a = schema.$ref.split("#/$defs/")[1]) !== null && _a !== void 0 ? _a : schema.$ref.split("/").at(-1);
393
+ if (((_b = props.components.schemas) === null || _b === void 0 ? void 0 : _b[key]) === undefined) {
394
+ (_c = (_h = props.components).schemas) !== null && _c !== void 0 ? _c : (_h.schemas = {});
395
+ props.components.schemas[key] = {};
396
+ props.components.schemas[key] = next((_d = props.$defs[key]) !== null && _d !== void 0 ? _d : {});
397
+ }
398
+ union.push(Object.assign(Object.assign({}, schema), { $ref: `#/components/schemas/${key}` }));
399
+ }
400
+ else if (LlmTypeChecker_1.LlmTypeChecker.isBoolean(schema))
401
+ if (!!((_e = schema.enum) === null || _e === void 0 ? void 0 : _e.length))
402
+ schema.enum.forEach((v) => union.push({
403
+ const: v,
404
+ }));
405
+ else
406
+ union.push(schema);
407
+ else if (LlmTypeChecker_1.LlmTypeChecker.isInteger(schema) ||
408
+ LlmTypeChecker_1.LlmTypeChecker.isNumber(schema))
409
+ if (!!((_f = schema.enum) === null || _f === void 0 ? void 0 : _f.length))
410
+ schema.enum.forEach((v) => union.push({
411
+ const: v,
412
+ }));
413
+ else
414
+ union.push(Object.assign(Object.assign(Object.assign({}, schema), LlmDescriptionInverter_1.LlmDescriptionInverter.numeric(schema.description)), { enum: undefined }));
415
+ else if (LlmTypeChecker_1.LlmTypeChecker.isString(schema))
416
+ if (!!((_g = schema.enum) === null || _g === void 0 ? void 0 : _g.length))
417
+ schema.enum.forEach((v) => union.push({
418
+ const: v,
419
+ }));
420
+ else
421
+ union.push(Object.assign(Object.assign(Object.assign({}, schema), LlmDescriptionInverter_1.LlmDescriptionInverter.string(schema.description)), { enum: undefined }));
422
+ else
423
+ union.push(Object.assign({}, schema));
424
+ };
425
+ visit(props.schema);
426
+ return Object.assign(Object.assign({}, attribute), (union.length === 0
427
+ ? { type: undefined }
428
+ : union.length === 1
429
+ ? Object.assign({}, union[0]) : {
430
+ oneOf: union.map((u) => (Object.assign(Object.assign({}, u), { nullable: undefined }))),
431
+ discriminator: LlmTypeChecker_1.LlmTypeChecker.isAnyOf(props.schema) &&
432
+ props.schema["x-discriminator"] !== undefined
433
+ ? {
434
+ propertyName: props.schema["x-discriminator"].propertyName,
435
+ mapping: props.schema["x-discriminator"].mapping !== undefined
436
+ ? Object.fromEntries(Object.entries(props.schema["x-discriminator"].mapping).map(([key, value]) => [
437
+ key,
438
+ `#/components/schemas/${value.split("/").at(-1)}`,
439
+ ]))
440
+ : undefined,
441
+ }
442
+ : undefined,
443
+ }));
444
+ };
445
+ /* -----------------------------------------------------------
446
+ SEPARATORS
447
+ ----------------------------------------------------------- */
448
+ /**
449
+ * Separate parameters into LLM and human parts.
450
+ *
451
+ * Splits parameters based on predicate (human-side if true). Creates separate
452
+ * schemas for LLM-fillable and human-required fields.
453
+ *
454
+ * @param props.parameters Parameters schema to separate
455
+ * @param props.predicate Returns true for human-side properties
456
+ * @param props.convention Key naming convention for separated types
457
+ * @param props.equals Whether to use strict equality validation
458
+ * @returns Separated LLM and human parameter schemas
459
+ */
460
+ LlmSchemaConverter.separate = (props) => {
461
+ var _a, _b;
462
+ const convention = (_a = props.convention) !== null && _a !== void 0 ? _a : ((key, type) => `${key}.${NamingConvention_1.NamingConvention.capitalize(type)}`);
463
+ const [llm, human] = separateObject({
464
+ predicate: props.predicate,
465
+ convention,
466
+ $defs: props.parameters.$defs,
467
+ schema: props.parameters,
468
+ });
469
+ if (llm === null || human === null)
470
+ return {
471
+ llm: (_b = llm) !== null && _b !== void 0 ? _b : {
472
+ type: "object",
473
+ properties: {},
474
+ required: [],
475
+ additionalProperties: false,
476
+ $defs: {},
477
+ },
478
+ human: human,
479
+ };
480
+ const output = {
481
+ llm: Object.assign(Object.assign({}, llm), { $defs: Object.fromEntries(Object.entries(props.parameters.$defs).filter(([key]) => key.endsWith(".Llm"))), additionalProperties: false }),
482
+ human: Object.assign(Object.assign({}, human), { $defs: Object.fromEntries(Object.entries(props.parameters.$defs).filter(([key]) => key.endsWith(".Human"))), additionalProperties: false }),
483
+ };
484
+ for (const key of Object.keys(props.parameters.$defs))
485
+ if (key.endsWith(".Llm") === false && key.endsWith(".Human") === false)
486
+ delete props.parameters.$defs[key];
487
+ if (Object.keys(output.llm.properties).length !== 0) {
488
+ const components = {};
489
+ output.validate = OpenApiValidator_1.OpenApiValidator.create({
490
+ components,
491
+ schema: LlmSchemaConverter.invert({
492
+ components,
493
+ schema: output.llm,
494
+ $defs: output.llm.$defs,
495
+ }),
496
+ required: true,
497
+ equals: props.equals,
498
+ });
499
+ }
500
+ return output;
501
+ };
502
+ const separateStation = (props) => {
503
+ if (props.predicate(props.schema) === true)
504
+ return [null, props.schema];
505
+ else if (LlmTypeChecker_1.LlmTypeChecker.isUnknown(props.schema) ||
506
+ LlmTypeChecker_1.LlmTypeChecker.isAnyOf(props.schema))
507
+ return [props.schema, null];
508
+ else if (LlmTypeChecker_1.LlmTypeChecker.isObject(props.schema))
509
+ return separateObject({
510
+ predicate: props.predicate,
511
+ convention: props.convention,
512
+ $defs: props.$defs,
513
+ schema: props.schema,
514
+ });
515
+ else if (LlmTypeChecker_1.LlmTypeChecker.isArray(props.schema))
516
+ return separateArray({
517
+ predicate: props.predicate,
518
+ convention: props.convention,
519
+ $defs: props.$defs,
520
+ schema: props.schema,
521
+ });
522
+ else if (LlmTypeChecker_1.LlmTypeChecker.isReference(props.schema))
523
+ return separateReference({
524
+ predicate: props.predicate,
525
+ convention: props.convention,
526
+ $defs: props.$defs,
527
+ schema: props.schema,
528
+ });
529
+ return [props.schema, null];
530
+ };
531
+ const separateArray = (props) => {
532
+ const [x, y] = separateStation({
533
+ predicate: props.predicate,
534
+ convention: props.convention,
535
+ $defs: props.$defs,
536
+ schema: props.schema.items,
537
+ });
538
+ return [
539
+ x !== null
540
+ ? Object.assign(Object.assign({}, props.schema), { items: x }) : null,
541
+ y !== null
542
+ ? Object.assign(Object.assign({}, props.schema), { items: y }) : null,
543
+ ];
544
+ };
545
+ const separateObject = (props) => {
546
+ var _a, _b;
547
+ // EMPTY OBJECT
548
+ if (Object.keys((_a = props.schema.properties) !== null && _a !== void 0 ? _a : {}).length === 0 &&
549
+ !!props.schema.additionalProperties === false)
550
+ return [props.schema, null];
551
+ const llm = Object.assign(Object.assign({}, props.schema), { properties: {}, additionalProperties: props.schema.additionalProperties });
552
+ const human = Object.assign(Object.assign({}, props.schema), { properties: {} });
553
+ for (const [key, value] of Object.entries((_b = props.schema.properties) !== null && _b !== void 0 ? _b : {})) {
554
+ const [x, y] = separateStation({
555
+ predicate: props.predicate,
556
+ convention: props.convention,
557
+ $defs: props.$defs,
558
+ schema: value,
559
+ });
560
+ if (x !== null)
561
+ llm.properties[key] = x;
562
+ if (y !== null)
563
+ human.properties[key] = y;
564
+ }
565
+ if (typeof props.schema.additionalProperties === "object" &&
566
+ props.schema.additionalProperties !== null) {
567
+ const [dx, dy] = separateStation({
568
+ predicate: props.predicate,
569
+ convention: props.convention,
570
+ $defs: props.$defs,
571
+ schema: props.schema.additionalProperties,
572
+ });
573
+ llm.additionalProperties = dx !== null && dx !== void 0 ? dx : false;
574
+ human.additionalProperties = dy !== null && dy !== void 0 ? dy : false;
575
+ }
576
+ return [
577
+ !!Object.keys(llm.properties).length || !!llm.additionalProperties
578
+ ? shrinkRequired(llm)
579
+ : null,
580
+ !!Object.keys(human.properties).length || human.additionalProperties
581
+ ? shrinkRequired(human)
582
+ : null,
583
+ ];
584
+ };
585
+ const separateReference = (props) => {
586
+ var _a, _b, _c, _d, _e, _f;
587
+ const key = (_a = props.schema.$ref.split("#/$defs/")[1]) !== null && _a !== void 0 ? _a : props.schema.$ref.split("/").at(-1);
588
+ const humanKey = props.convention(key, "human");
589
+ const llmKey = props.convention(key, "llm");
590
+ // FIND EXISTING
591
+ if (((_b = props.$defs) === null || _b === void 0 ? void 0 : _b[humanKey]) || ((_c = props.$defs) === null || _c === void 0 ? void 0 : _c[llmKey]))
592
+ return [
593
+ ((_d = props.$defs) === null || _d === void 0 ? void 0 : _d[llmKey])
594
+ ? Object.assign(Object.assign({}, props.schema), { $ref: `#/$defs/${llmKey}` }) : null,
595
+ ((_e = props.$defs) === null || _e === void 0 ? void 0 : _e[humanKey])
596
+ ? Object.assign(Object.assign({}, props.schema), { $ref: `#/$defs/${humanKey}` }) : null,
597
+ ];
598
+ // PRE-ASSIGNMENT
599
+ props.$defs[llmKey] = {};
600
+ props.$defs[humanKey] = {};
601
+ // DO COMPOSE
602
+ const schema = (_f = props.$defs) === null || _f === void 0 ? void 0 : _f[key];
603
+ const [llm, human] = separateStation({
604
+ predicate: props.predicate,
605
+ convention: props.convention,
606
+ $defs: props.$defs,
607
+ schema,
608
+ });
609
+ if (llm !== null)
610
+ Object.assign(props.$defs[llmKey], llm);
611
+ if (human !== null)
612
+ Object.assign(props.$defs[humanKey], human);
613
+ // ONLY ONE
614
+ if (llm === null || human === null) {
615
+ delete props.$defs[llmKey];
616
+ delete props.$defs[humanKey];
617
+ return llm === null ? [null, props.schema] : [props.schema, null];
618
+ }
619
+ // BOTH OF THEM
620
+ return [
621
+ llm !== null
622
+ ? Object.assign(Object.assign({}, props.schema), { $ref: `#/$defs/${llmKey}` }) : null,
623
+ human !== null
624
+ ? Object.assign(Object.assign({}, props.schema), { $ref: `#/$defs/${humanKey}` }) : null,
625
+ ];
626
+ };
627
+ const shrinkRequired = (s) => {
628
+ s.required = s.required.filter((key) => { var _a; return ((_a = s.properties) === null || _a === void 0 ? void 0 : _a[key]) !== undefined; });
629
+ return s;
630
+ };
631
+ })(LlmSchemaConverter || (exports.LlmSchemaConverter = LlmSchemaConverter = {}));
632
+ const validateStrict = (schema, accessor) => {
633
+ var _a, _b;
634
+ const reasons = [];
635
+ if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(schema)) {
636
+ if (!!schema.additionalProperties)
637
+ reasons.push({
638
+ schema: schema,
639
+ accessor: `${accessor}.additionalProperties`,
640
+ message: "LLM does not allow additionalProperties in strict mode, the dynamic key typed object.",
641
+ });
642
+ for (const key of Object.keys((_a = schema.properties) !== null && _a !== void 0 ? _a : {}))
643
+ if (((_b = schema.required) === null || _b === void 0 ? void 0 : _b.includes(key)) === false)
644
+ reasons.push({
645
+ schema: schema,
646
+ accessor: `${accessor}.properties.${key}`,
647
+ message: "LLM does not allow optional properties in strict mode.",
648
+ });
649
+ }
650
+ return reasons;
651
+ };
652
+ //# sourceMappingURL=LlmSchemaConverter.js.map