@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,326 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyValidationFailure = stringifyValidationFailure;
4
+ const NamingConvention_1 = require("./NamingConvention");
5
+ const dedent_1 = require("./dedent");
6
+ /**
7
+ * Format validation failure for LLM auto-correction feedback.
8
+ *
9
+ * When LLM generates invalid function call arguments, this produces annotated
10
+ * JSON with inline `// ❌` error comments at each invalid property. The output
11
+ * is wrapped in a markdown code block so that LLM can understand and correct
12
+ * its mistakes in the next turn.
13
+ *
14
+ * Below is an example of the output format:
15
+ *
16
+ * ```json
17
+ * {
18
+ * "name": "John",
19
+ * "age": "twenty", // ❌ [{"path":"$input.age","expected":"number & Type<\"uint32\">"}]
20
+ * "email": "not-an-email", // ❌ [{"path":"$input.email","expected":"string & Format<\"email\">"}]
21
+ * "hobbies": "reading" // ❌ [{"path":"$input.hobbies","expected":"Array<string>"}]
22
+ * }
23
+ * ```
24
+ *
25
+ * @author Jeongho Nam - https://github.com/samchon
26
+ * @param failure Validation failure from {@link ILlmFunction.validate}
27
+ * @returns Markdown code block with error-annotated JSON
28
+ */
29
+ function stringifyValidationFailure(failure) {
30
+ const usedErrors = new Set();
31
+ const jsonOutput = stringify({
32
+ value: failure.data,
33
+ errors: failure.errors,
34
+ path: "$input",
35
+ tab: 0,
36
+ inArray: false,
37
+ inToJson: false,
38
+ usedErrors,
39
+ });
40
+ // Find errors that couldn't be embedded
41
+ const unmappableErrors = failure.errors.filter((e) => !usedErrors.has(e));
42
+ // If there are unmappable errors, append them as a separate block
43
+ if (unmappableErrors.length > 0)
44
+ return (0, dedent_1.dedent) `
45
+ \`\`\`json
46
+ ${jsonOutput}
47
+ \`\`\`
48
+
49
+ **Unmappable validation errors:**
50
+ \`\`\`json
51
+ ${JSON.stringify(unmappableErrors, null, 2)}
52
+ \`\`\`
53
+ `;
54
+ return (0, dedent_1.dedent) `
55
+ \`\`\`json
56
+ ${jsonOutput}
57
+ \`\`\`
58
+ `;
59
+ }
60
+ function stringify(props) {
61
+ var _a;
62
+ const { value, errors, path, tab, inArray, inToJson, usedErrors } = props;
63
+ const indent = " ".repeat(tab);
64
+ const errorComment = getErrorComment(path, errors, usedErrors);
65
+ // Handle undefined in arrays
66
+ if (inArray && value === undefined) {
67
+ return `${indent}undefined${errorComment}`;
68
+ }
69
+ // Array
70
+ if (Array.isArray(value)) {
71
+ // Check for missing array element errors (path[])
72
+ const missingElementErrors = getMissingArrayElementErrors(path, errors, usedErrors);
73
+ const hasMissingElements = missingElementErrors.length > 0;
74
+ if (value.length === 0) {
75
+ // Empty array but has missing element errors - show placeholders
76
+ if (hasMissingElements) {
77
+ const innerIndent = " ".repeat(tab + 1);
78
+ const lines = [];
79
+ lines.push(`${indent}[${errorComment}`);
80
+ missingElementErrors.forEach((e, idx) => {
81
+ const errComment = ` // ❌ ${JSON.stringify([{ path: e.path, expected: e.expected, description: e.description }])}`;
82
+ const comma = idx < missingElementErrors.length - 1 ? "," : "";
83
+ lines.push(`${innerIndent}undefined${comma}${errComment}`);
84
+ });
85
+ lines.push(`${indent}]`);
86
+ return lines.join("\n");
87
+ }
88
+ return `${indent}[]${errorComment}`;
89
+ }
90
+ const lines = [];
91
+ lines.push(`${indent}[${errorComment}`);
92
+ value.forEach((item, index) => {
93
+ const itemPath = `${path}[${index}]`;
94
+ const isLastElement = index === value.length - 1;
95
+ // If there are missing element errors, this is not truly the last line
96
+ const needsComma = !isLastElement || hasMissingElements;
97
+ let itemStr = stringify({
98
+ value: item,
99
+ errors,
100
+ path: itemPath,
101
+ tab: tab + 1,
102
+ inArray: true,
103
+ inToJson: false,
104
+ usedErrors,
105
+ });
106
+ // Add comma before the error comment if not the last element
107
+ if (needsComma) {
108
+ const itemLines = itemStr.split("\n");
109
+ const lastLine = itemLines[itemLines.length - 1];
110
+ const commentIndex = lastLine.indexOf(" //");
111
+ if (commentIndex !== -1) {
112
+ itemLines[itemLines.length - 1] = `${lastLine.slice(0, commentIndex)},${lastLine.slice(commentIndex)}`;
113
+ }
114
+ else {
115
+ itemLines[itemLines.length - 1] += ",";
116
+ }
117
+ itemStr = itemLines.join("\n");
118
+ }
119
+ lines.push(itemStr);
120
+ });
121
+ // Add missing element placeholders at the end for each [] error
122
+ if (hasMissingElements) {
123
+ const innerIndent = " ".repeat(tab + 1);
124
+ missingElementErrors.forEach((e, idx) => {
125
+ const errComment = ` // ❌ ${JSON.stringify([{ path: e.path, expected: e.expected, description: e.description }])}`;
126
+ const comma = idx < missingElementErrors.length - 1 ? "," : "";
127
+ lines.push(`${innerIndent}undefined${comma}${errComment}`);
128
+ });
129
+ }
130
+ lines.push(`${indent}]`);
131
+ return lines.join("\n");
132
+ }
133
+ // Object
134
+ if (typeof value === "object" && value !== null) {
135
+ // Check for toJSON method
136
+ // biome-ignore lint: intended
137
+ if (!inToJson && typeof value.toJSON === "function") {
138
+ // biome-ignore lint: intended
139
+ const jsonValue = value.toJSON();
140
+ return stringify({
141
+ value: jsonValue,
142
+ errors,
143
+ path,
144
+ tab,
145
+ inArray,
146
+ inToJson: true,
147
+ usedErrors,
148
+ });
149
+ }
150
+ // Get all entries from the object (including undefined values that have errors)
151
+ const allEntries = Object.entries(value);
152
+ // Split into defined and undefined entries
153
+ const definedEntries = allEntries.filter(([_, val]) => val !== undefined);
154
+ const undefinedEntryKeys = new Set(allEntries.filter(([_, val]) => val === undefined).map(([key]) => key));
155
+ // Find missing properties that have validation errors (not in object at all)
156
+ const missingKeys = getMissingProperties(path, value, errors);
157
+ // Combine: defined entries + undefined entries with errors + missing properties
158
+ const undefinedKeysWithErrors = Array.from(undefinedEntryKeys).filter((key) => {
159
+ const propPath = NamingConvention_1.NamingConvention.variable(key)
160
+ ? `${path}.${key}`
161
+ : `${path}[${JSON.stringify(key)}]`;
162
+ return errors.some((e) => e.path.startsWith(propPath));
163
+ });
164
+ const allKeys = [
165
+ ...definedEntries.map(([key]) => key),
166
+ ...undefinedKeysWithErrors,
167
+ ...missingKeys,
168
+ ];
169
+ if (allKeys.length === 0) {
170
+ return `${indent}{}${errorComment}`;
171
+ }
172
+ const lines = [];
173
+ lines.push(`${indent}{${errorComment}`);
174
+ allKeys.forEach((key, index, array) => {
175
+ const propPath = NamingConvention_1.NamingConvention.variable(key)
176
+ ? `${path}.${key}`
177
+ : `${path}[${JSON.stringify(key)}]`;
178
+ const propIndent = " ".repeat(tab + 1);
179
+ // Get the value (undefined for missing properties or undefined entries)
180
+ const val = missingKeys.includes(key) || undefinedKeysWithErrors.includes(key)
181
+ ? undefined
182
+ : // biome-ignore lint: intended
183
+ value[key];
184
+ // Primitive property value (including undefined for missing properties)
185
+ if (val === undefined ||
186
+ val === null ||
187
+ typeof val === "boolean" ||
188
+ typeof val === "number" ||
189
+ typeof val === "string") {
190
+ const propErrorComment = getErrorComment(propPath, errors, usedErrors);
191
+ const keyStr = JSON.stringify(key);
192
+ const valueStr = val === undefined
193
+ ? `${propIndent}${keyStr}: undefined`
194
+ : `${propIndent}${keyStr}: ${JSON.stringify(val)}`;
195
+ const withComma = index < array.length - 1 ? `${valueStr},` : valueStr;
196
+ const line = withComma + propErrorComment;
197
+ lines.push(line);
198
+ }
199
+ // Complex property value (object or array)
200
+ else {
201
+ const keyLine = `${propIndent}${JSON.stringify(key)}: `;
202
+ let valStr = stringify({
203
+ value: val,
204
+ errors,
205
+ path: propPath,
206
+ tab: tab + 1,
207
+ inArray: false,
208
+ inToJson: false,
209
+ usedErrors,
210
+ });
211
+ const valStrWithoutIndent = valStr.trimStart();
212
+ // Add comma before the error comment if not the last property
213
+ if (index < array.length - 1) {
214
+ const valLines = valStrWithoutIndent.split("\n");
215
+ const lastLine = valLines[valLines.length - 1];
216
+ const commentIndex = lastLine.indexOf(" //");
217
+ if (commentIndex !== -1) {
218
+ valLines[valLines.length - 1] = `${lastLine.slice(0, commentIndex)},${lastLine.slice(commentIndex)}`;
219
+ }
220
+ else {
221
+ valLines[valLines.length - 1] += ",";
222
+ }
223
+ valStr = valLines.join("\n");
224
+ }
225
+ else {
226
+ valStr = valStrWithoutIndent;
227
+ }
228
+ const combined = keyLine + valStr;
229
+ lines.push(combined);
230
+ }
231
+ });
232
+ lines.push(`${indent}}`);
233
+ return lines.join("\n");
234
+ }
235
+ // Primitive types (null, boolean, number, string, undefined, etc.)
236
+ const valStr = value === undefined
237
+ ? "undefined"
238
+ : ((_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : String(value));
239
+ return `${indent}${valStr}${errorComment}`;
240
+ }
241
+ /** Get error comment for a given path */
242
+ function getErrorComment(path, errors, usedErrors) {
243
+ const pathErrors = errors.filter((e) => e.path === path);
244
+ if (pathErrors.length === 0) {
245
+ return "";
246
+ }
247
+ // Mark these errors as used
248
+ pathErrors.forEach((e) => usedErrors.add(e));
249
+ return ` // ❌ ${JSON.stringify(pathErrors.map((e) => ({
250
+ path: e.path,
251
+ expected: e.expected,
252
+ description: e.description,
253
+ })))}`;
254
+ }
255
+ /**
256
+ * Check if there are missing array element errors (path ending with []) Returns
257
+ * an array of error objects, one per missing element
258
+ */
259
+ function getMissingArrayElementErrors(path, errors, usedErrors) {
260
+ const wildcardPath = `${path}[]`;
261
+ const missingErrors = errors.filter((e) => e.path === wildcardPath);
262
+ // Mark these errors as used
263
+ missingErrors.forEach((e) => usedErrors.add(e));
264
+ return missingErrors;
265
+ }
266
+ /**
267
+ * Find missing properties that have validation errors but don't exist in the
268
+ * data Returns array of property keys that should be displayed as undefined
269
+ */
270
+ function getMissingProperties(path, value, errors) {
271
+ const missingKeys = new Set();
272
+ for (const e of errors) {
273
+ // Check if error.path is a direct child of current path
274
+ const childKey = extractDirectChildKey(path, e.path);
275
+ if (childKey !== null) {
276
+ // Check if this property actually exists in the value
277
+ if (!(childKey in value)) {
278
+ missingKeys.add(childKey);
279
+ }
280
+ }
281
+ }
282
+ return Array.from(missingKeys);
283
+ }
284
+ /**
285
+ * Extract direct child property key if errorPath is a direct child of
286
+ * parentPath Returns null if not a direct child
287
+ *
288
+ * Examples:
289
+ *
290
+ * - ExtractDirectChildKey("$input", "$input.email") => "email"
291
+ * - ExtractDirectChildKey("$input", "$input.user.email") => null (grandchild)
292
+ * - ExtractDirectChildKey("$input.user", "$input.user.email") => "email"
293
+ * - ExtractDirectChildKey("$input", "$input[0]") => null (array index, not object
294
+ * property)
295
+ * - ExtractDirectChildKey("$input", "$input["foo-bar"]") => "foo-bar"
296
+ * - ExtractDirectChildKey("$input", "$input["foo"]["bar"]") => null (grandchild)
297
+ */
298
+ function extractDirectChildKey(parentPath, errorPath) {
299
+ if (!errorPath.startsWith(parentPath)) {
300
+ return null;
301
+ }
302
+ const suffix = errorPath.slice(parentPath.length);
303
+ // Match ".propertyName" pattern (direct child property with dot notation)
304
+ // Should not contain additional dots or brackets after the property name
305
+ const dotMatch = suffix.match(/^\.([^.[\]]+)$/);
306
+ if (dotMatch !== null) {
307
+ return dotMatch[1];
308
+ }
309
+ // Match '["key"]' pattern (direct child property with bracket notation)
310
+ // The key is a JSON-encoded string
311
+ const bracketMatch = suffix.match(/^\[("[^"\\]*(?:\\.[^"\\]*)*")\]$/);
312
+ if (bracketMatch !== null) {
313
+ try {
314
+ const parsed = JSON.parse(bracketMatch[1]);
315
+ // Ensure it's a string key, not a number (array index)
316
+ if (typeof parsed === "string") {
317
+ return parsed;
318
+ }
319
+ }
320
+ catch (_a) {
321
+ // Invalid JSON, ignore
322
+ }
323
+ }
324
+ return null;
325
+ }
326
+ //# sourceMappingURL=stringifyValidationFailure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringifyValidationFailure.js","sourceRoot":"","sources":["../../src/utils/stringifyValidationFailure.ts"],"names":[],"mappings":";;AA4BA,gEAoCC;AA9DD,yDAAsD;AACtD,qCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,0BAA0B,CACxC,OAA6B;IAE7B,MAAM,UAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC;QAC3B,KAAK,EAAE,OAAO,CAAC,IAAI;QACnB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;QACf,UAAU;KACX,CAAC,CAAC;IAEH,wCAAwC;IACxC,MAAM,gBAAgB,GAAyB,OAAO,CAAC,MAAM,CAAC,MAAM,CAClE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAA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tE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,CAAC;YAC5C,uDAAuD;YACvD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAAC,WAAM,CAAC;YACP,uBAAuB;QACzB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,325 @@
1
+ import { NamingConvention } from './NamingConvention.mjs';
2
+ import { dedent } from './dedent.mjs';
3
+
4
+ /**
5
+ * Format validation failure for LLM auto-correction feedback.
6
+ *
7
+ * When LLM generates invalid function call arguments, this produces annotated
8
+ * JSON with inline `// ❌` error comments at each invalid property. The output
9
+ * is wrapped in a markdown code block so that LLM can understand and correct
10
+ * its mistakes in the next turn.
11
+ *
12
+ * Below is an example of the output format:
13
+ *
14
+ * ```json
15
+ * {
16
+ * "name": "John",
17
+ * "age": "twenty", // ❌ [{"path":"$input.age","expected":"number & Type<\"uint32\">"}]
18
+ * "email": "not-an-email", // ❌ [{"path":"$input.email","expected":"string & Format<\"email\">"}]
19
+ * "hobbies": "reading" // ❌ [{"path":"$input.hobbies","expected":"Array<string>"}]
20
+ * }
21
+ * ```
22
+ *
23
+ * @author Jeongho Nam - https://github.com/samchon
24
+ * @param failure Validation failure from {@link ILlmFunction.validate}
25
+ * @returns Markdown code block with error-annotated JSON
26
+ */
27
+ function stringifyValidationFailure(failure) {
28
+ const usedErrors = new Set();
29
+ const jsonOutput = stringify({
30
+ value: failure.data,
31
+ errors: failure.errors,
32
+ path: "$input",
33
+ tab: 0,
34
+ inArray: false,
35
+ inToJson: false,
36
+ usedErrors,
37
+ });
38
+ // Find errors that couldn't be embedded
39
+ const unmappableErrors = failure.errors.filter((e) => !usedErrors.has(e));
40
+ // If there are unmappable errors, append them as a separate block
41
+ if (unmappableErrors.length > 0)
42
+ return dedent `
43
+ \`\`\`json
44
+ ${jsonOutput}
45
+ \`\`\`
46
+
47
+ **Unmappable validation errors:**
48
+ \`\`\`json
49
+ ${JSON.stringify(unmappableErrors, null, 2)}
50
+ \`\`\`
51
+ `;
52
+ return dedent `
53
+ \`\`\`json
54
+ ${jsonOutput}
55
+ \`\`\`
56
+ `;
57
+ }
58
+ function stringify(props) {
59
+ const { value, errors, path, tab, inArray, inToJson, usedErrors } = props;
60
+ const indent = " ".repeat(tab);
61
+ const errorComment = getErrorComment(path, errors, usedErrors);
62
+ // Handle undefined in arrays
63
+ if (inArray && value === undefined) {
64
+ return `${indent}undefined${errorComment}`;
65
+ }
66
+ // Array
67
+ if (Array.isArray(value)) {
68
+ // Check for missing array element errors (path[])
69
+ const missingElementErrors = getMissingArrayElementErrors(path, errors, usedErrors);
70
+ const hasMissingElements = missingElementErrors.length > 0;
71
+ if (value.length === 0) {
72
+ // Empty array but has missing element errors - show placeholders
73
+ if (hasMissingElements) {
74
+ const innerIndent = " ".repeat(tab + 1);
75
+ const lines = [];
76
+ lines.push(`${indent}[${errorComment}`);
77
+ missingElementErrors.forEach((e, idx) => {
78
+ const errComment = ` // ❌ ${JSON.stringify([{ path: e.path, expected: e.expected, description: e.description }])}`;
79
+ const comma = idx < missingElementErrors.length - 1 ? "," : "";
80
+ lines.push(`${innerIndent}undefined${comma}${errComment}`);
81
+ });
82
+ lines.push(`${indent}]`);
83
+ return lines.join("\n");
84
+ }
85
+ return `${indent}[]${errorComment}`;
86
+ }
87
+ const lines = [];
88
+ lines.push(`${indent}[${errorComment}`);
89
+ value.forEach((item, index) => {
90
+ const itemPath = `${path}[${index}]`;
91
+ const isLastElement = index === value.length - 1;
92
+ // If there are missing element errors, this is not truly the last line
93
+ const needsComma = !isLastElement || hasMissingElements;
94
+ let itemStr = stringify({
95
+ value: item,
96
+ errors,
97
+ path: itemPath,
98
+ tab: tab + 1,
99
+ inArray: true,
100
+ inToJson: false,
101
+ usedErrors,
102
+ });
103
+ // Add comma before the error comment if not the last element
104
+ if (needsComma) {
105
+ const itemLines = itemStr.split("\n");
106
+ const lastLine = itemLines[itemLines.length - 1];
107
+ const commentIndex = lastLine.indexOf(" //");
108
+ if (commentIndex !== -1) {
109
+ itemLines[itemLines.length - 1] = `${lastLine.slice(0, commentIndex)},${lastLine.slice(commentIndex)}`;
110
+ }
111
+ else {
112
+ itemLines[itemLines.length - 1] += ",";
113
+ }
114
+ itemStr = itemLines.join("\n");
115
+ }
116
+ lines.push(itemStr);
117
+ });
118
+ // Add missing element placeholders at the end for each [] error
119
+ if (hasMissingElements) {
120
+ const innerIndent = " ".repeat(tab + 1);
121
+ missingElementErrors.forEach((e, idx) => {
122
+ const errComment = ` // ❌ ${JSON.stringify([{ path: e.path, expected: e.expected, description: e.description }])}`;
123
+ const comma = idx < missingElementErrors.length - 1 ? "," : "";
124
+ lines.push(`${innerIndent}undefined${comma}${errComment}`);
125
+ });
126
+ }
127
+ lines.push(`${indent}]`);
128
+ return lines.join("\n");
129
+ }
130
+ // Object
131
+ if (typeof value === "object" && value !== null) {
132
+ // Check for toJSON method
133
+ // biome-ignore lint: intended
134
+ if (!inToJson && typeof value.toJSON === "function") {
135
+ // biome-ignore lint: intended
136
+ const jsonValue = value.toJSON();
137
+ return stringify({
138
+ value: jsonValue,
139
+ errors,
140
+ path,
141
+ tab,
142
+ inArray,
143
+ inToJson: true,
144
+ usedErrors,
145
+ });
146
+ }
147
+ // Get all entries from the object (including undefined values that have errors)
148
+ const allEntries = Object.entries(value);
149
+ // Split into defined and undefined entries
150
+ const definedEntries = allEntries.filter(([_, val]) => val !== undefined);
151
+ const undefinedEntryKeys = new Set(allEntries.filter(([_, val]) => val === undefined).map(([key]) => key));
152
+ // Find missing properties that have validation errors (not in object at all)
153
+ const missingKeys = getMissingProperties(path, value, errors);
154
+ // Combine: defined entries + undefined entries with errors + missing properties
155
+ const undefinedKeysWithErrors = Array.from(undefinedEntryKeys).filter((key) => {
156
+ const propPath = NamingConvention.variable(key)
157
+ ? `${path}.${key}`
158
+ : `${path}[${JSON.stringify(key)}]`;
159
+ return errors.some((e) => e.path.startsWith(propPath));
160
+ });
161
+ const allKeys = [
162
+ ...definedEntries.map(([key]) => key),
163
+ ...undefinedKeysWithErrors,
164
+ ...missingKeys,
165
+ ];
166
+ if (allKeys.length === 0) {
167
+ return `${indent}{}${errorComment}`;
168
+ }
169
+ const lines = [];
170
+ lines.push(`${indent}{${errorComment}`);
171
+ allKeys.forEach((key, index, array) => {
172
+ const propPath = NamingConvention.variable(key)
173
+ ? `${path}.${key}`
174
+ : `${path}[${JSON.stringify(key)}]`;
175
+ const propIndent = " ".repeat(tab + 1);
176
+ // Get the value (undefined for missing properties or undefined entries)
177
+ const val = missingKeys.includes(key) || undefinedKeysWithErrors.includes(key)
178
+ ? undefined
179
+ : // biome-ignore lint: intended
180
+ value[key];
181
+ // Primitive property value (including undefined for missing properties)
182
+ if (val === undefined ||
183
+ val === null ||
184
+ typeof val === "boolean" ||
185
+ typeof val === "number" ||
186
+ typeof val === "string") {
187
+ const propErrorComment = getErrorComment(propPath, errors, usedErrors);
188
+ const keyStr = JSON.stringify(key);
189
+ const valueStr = val === undefined
190
+ ? `${propIndent}${keyStr}: undefined`
191
+ : `${propIndent}${keyStr}: ${JSON.stringify(val)}`;
192
+ const withComma = index < array.length - 1 ? `${valueStr},` : valueStr;
193
+ const line = withComma + propErrorComment;
194
+ lines.push(line);
195
+ }
196
+ // Complex property value (object or array)
197
+ else {
198
+ const keyLine = `${propIndent}${JSON.stringify(key)}: `;
199
+ let valStr = stringify({
200
+ value: val,
201
+ errors,
202
+ path: propPath,
203
+ tab: tab + 1,
204
+ inArray: false,
205
+ inToJson: false,
206
+ usedErrors,
207
+ });
208
+ const valStrWithoutIndent = valStr.trimStart();
209
+ // Add comma before the error comment if not the last property
210
+ if (index < array.length - 1) {
211
+ const valLines = valStrWithoutIndent.split("\n");
212
+ const lastLine = valLines[valLines.length - 1];
213
+ const commentIndex = lastLine.indexOf(" //");
214
+ if (commentIndex !== -1) {
215
+ valLines[valLines.length - 1] = `${lastLine.slice(0, commentIndex)},${lastLine.slice(commentIndex)}`;
216
+ }
217
+ else {
218
+ valLines[valLines.length - 1] += ",";
219
+ }
220
+ valStr = valLines.join("\n");
221
+ }
222
+ else {
223
+ valStr = valStrWithoutIndent;
224
+ }
225
+ const combined = keyLine + valStr;
226
+ lines.push(combined);
227
+ }
228
+ });
229
+ lines.push(`${indent}}`);
230
+ return lines.join("\n");
231
+ }
232
+ // Primitive types (null, boolean, number, string, undefined, etc.)
233
+ const valStr = value === undefined
234
+ ? "undefined"
235
+ : (JSON.stringify(value) ?? String(value));
236
+ return `${indent}${valStr}${errorComment}`;
237
+ }
238
+ /** Get error comment for a given path */
239
+ function getErrorComment(path, errors, usedErrors) {
240
+ const pathErrors = errors.filter((e) => e.path === path);
241
+ if (pathErrors.length === 0) {
242
+ return "";
243
+ }
244
+ // Mark these errors as used
245
+ pathErrors.forEach((e) => usedErrors.add(e));
246
+ return ` // ❌ ${JSON.stringify(pathErrors.map((e) => ({
247
+ path: e.path,
248
+ expected: e.expected,
249
+ description: e.description,
250
+ })))}`;
251
+ }
252
+ /**
253
+ * Check if there are missing array element errors (path ending with []) Returns
254
+ * an array of error objects, one per missing element
255
+ */
256
+ function getMissingArrayElementErrors(path, errors, usedErrors) {
257
+ const wildcardPath = `${path}[]`;
258
+ const missingErrors = errors.filter((e) => e.path === wildcardPath);
259
+ // Mark these errors as used
260
+ missingErrors.forEach((e) => usedErrors.add(e));
261
+ return missingErrors;
262
+ }
263
+ /**
264
+ * Find missing properties that have validation errors but don't exist in the
265
+ * data Returns array of property keys that should be displayed as undefined
266
+ */
267
+ function getMissingProperties(path, value, errors) {
268
+ const missingKeys = new Set();
269
+ for (const e of errors) {
270
+ // Check if error.path is a direct child of current path
271
+ const childKey = extractDirectChildKey(path, e.path);
272
+ if (childKey !== null) {
273
+ // Check if this property actually exists in the value
274
+ if (!(childKey in value)) {
275
+ missingKeys.add(childKey);
276
+ }
277
+ }
278
+ }
279
+ return Array.from(missingKeys);
280
+ }
281
+ /**
282
+ * Extract direct child property key if errorPath is a direct child of
283
+ * parentPath Returns null if not a direct child
284
+ *
285
+ * Examples:
286
+ *
287
+ * - ExtractDirectChildKey("$input", "$input.email") => "email"
288
+ * - ExtractDirectChildKey("$input", "$input.user.email") => null (grandchild)
289
+ * - ExtractDirectChildKey("$input.user", "$input.user.email") => "email"
290
+ * - ExtractDirectChildKey("$input", "$input[0]") => null (array index, not object
291
+ * property)
292
+ * - ExtractDirectChildKey("$input", "$input["foo-bar"]") => "foo-bar"
293
+ * - ExtractDirectChildKey("$input", "$input["foo"]["bar"]") => null (grandchild)
294
+ */
295
+ function extractDirectChildKey(parentPath, errorPath) {
296
+ if (!errorPath.startsWith(parentPath)) {
297
+ return null;
298
+ }
299
+ const suffix = errorPath.slice(parentPath.length);
300
+ // Match ".propertyName" pattern (direct child property with dot notation)
301
+ // Should not contain additional dots or brackets after the property name
302
+ const dotMatch = suffix.match(/^\.([^.[\]]+)$/);
303
+ if (dotMatch !== null) {
304
+ return dotMatch[1];
305
+ }
306
+ // Match '["key"]' pattern (direct child property with bracket notation)
307
+ // The key is a JSON-encoded string
308
+ const bracketMatch = suffix.match(/^\[("[^"\\]*(?:\\.[^"\\]*)*")\]$/);
309
+ if (bracketMatch !== null) {
310
+ try {
311
+ const parsed = JSON.parse(bracketMatch[1]);
312
+ // Ensure it's a string key, not a number (array index)
313
+ if (typeof parsed === "string") {
314
+ return parsed;
315
+ }
316
+ }
317
+ catch {
318
+ // Invalid JSON, ignore
319
+ }
320
+ }
321
+ return null;
322
+ }
323
+
324
+ export { stringifyValidationFailure };
325
+ //# sourceMappingURL=stringifyValidationFailure.mjs.map