@typia/utils 13.0.0-dev.20260427-2 → 13.0.0-dev.20260430

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 (345) hide show
  1. package/lib/converters/LlmSchemaConverter.js +6 -15
  2. package/lib/converters/LlmSchemaConverter.js.map +1 -1
  3. package/lib/converters/LlmSchemaConverter.mjs +2 -7
  4. package/lib/converters/LlmSchemaConverter.mjs.map +1 -1
  5. package/lib/converters/LlmSchemaConverter2.mjs +440 -451
  6. package/lib/converters/LlmSchemaConverter2.mjs.map +1 -1
  7. package/lib/converters/OpenApiConverter.mjs +2 -7
  8. package/lib/converters/OpenApiConverter.mjs.map +1 -1
  9. package/lib/converters/OpenApiConverter2.mjs +163 -164
  10. package/lib/converters/OpenApiConverter2.mjs.map +1 -1
  11. package/lib/converters/index.mjs +1 -7
  12. package/lib/converters/index.mjs.map +1 -1
  13. package/lib/converters/index2.mjs +31 -32
  14. package/lib/converters/index2.mjs.map +1 -1
  15. package/lib/converters/internal/LlmDescriptionInverter.mjs +2 -7
  16. package/lib/converters/internal/LlmDescriptionInverter.mjs.map +1 -1
  17. package/lib/converters/internal/LlmDescriptionInverter2.mjs +143 -150
  18. package/lib/converters/internal/LlmDescriptionInverter2.mjs.map +1 -1
  19. package/lib/converters/internal/LlmParametersComposer.mjs +2 -7
  20. package/lib/converters/internal/LlmParametersComposer.mjs.map +1 -1
  21. package/lib/converters/internal/LlmParametersComposer2.mjs +37 -44
  22. package/lib/converters/internal/LlmParametersComposer2.mjs.map +1 -1
  23. package/lib/converters/internal/OpenApiConstraintShifter.mjs +2 -7
  24. package/lib/converters/internal/OpenApiConstraintShifter.mjs.map +1 -1
  25. package/lib/converters/internal/OpenApiConstraintShifter2.mjs +105 -112
  26. package/lib/converters/internal/OpenApiConstraintShifter2.mjs.map +1 -1
  27. package/lib/converters/internal/OpenApiExclusiveEmender.mjs +2 -7
  28. package/lib/converters/internal/OpenApiExclusiveEmender.mjs.map +1 -1
  29. package/lib/converters/internal/OpenApiExclusiveEmender2.mjs +32 -40
  30. package/lib/converters/internal/OpenApiExclusiveEmender2.mjs.map +1 -1
  31. package/lib/converters/internal/OpenApiV3Downgrader.mjs +2 -7
  32. package/lib/converters/internal/OpenApiV3Downgrader.mjs.map +1 -1
  33. package/lib/converters/internal/OpenApiV3Downgrader2.mjs +237 -244
  34. package/lib/converters/internal/OpenApiV3Downgrader2.mjs.map +1 -1
  35. package/lib/converters/internal/OpenApiV3Upgrader.mjs +2 -7
  36. package/lib/converters/internal/OpenApiV3Upgrader.mjs.map +1 -1
  37. package/lib/converters/internal/OpenApiV3Upgrader2.mjs +300 -305
  38. package/lib/converters/internal/OpenApiV3Upgrader2.mjs.map +1 -1
  39. package/lib/converters/internal/OpenApiV3_1Downgrader.mjs +2 -7
  40. package/lib/converters/internal/OpenApiV3_1Downgrader.mjs.map +1 -1
  41. package/lib/converters/internal/OpenApiV3_1Downgrader2.mjs +193 -200
  42. package/lib/converters/internal/OpenApiV3_1Downgrader2.mjs.map +1 -1
  43. package/lib/converters/internal/OpenApiV3_1Upgrader.mjs +2 -7
  44. package/lib/converters/internal/OpenApiV3_1Upgrader.mjs.map +1 -1
  45. package/lib/converters/internal/OpenApiV3_1Upgrader2.mjs +424 -429
  46. package/lib/converters/internal/OpenApiV3_1Upgrader2.mjs.map +1 -1
  47. package/lib/converters/internal/OpenApiV3_2Upgrader.mjs +2 -7
  48. package/lib/converters/internal/OpenApiV3_2Upgrader.mjs.map +1 -1
  49. package/lib/converters/internal/OpenApiV3_2Upgrader2.mjs +202 -208
  50. package/lib/converters/internal/OpenApiV3_2Upgrader2.mjs.map +1 -1
  51. package/lib/converters/internal/SwaggerV2Downgrader.mjs +2 -7
  52. package/lib/converters/internal/SwaggerV2Downgrader.mjs.map +1 -1
  53. package/lib/converters/internal/SwaggerV2Downgrader2.mjs +287 -294
  54. package/lib/converters/internal/SwaggerV2Downgrader2.mjs.map +1 -1
  55. package/lib/converters/internal/SwaggerV2Upgrader.mjs +2 -7
  56. package/lib/converters/internal/SwaggerV2Upgrader.mjs.map +1 -1
  57. package/lib/converters/internal/SwaggerV2Upgrader2.mjs +370 -375
  58. package/lib/converters/internal/SwaggerV2Upgrader2.mjs.map +1 -1
  59. package/lib/http/HttpError.mjs +2 -7
  60. package/lib/http/HttpError.mjs.map +1 -1
  61. package/lib/http/HttpError2.mjs +69 -77
  62. package/lib/http/HttpError2.mjs.map +1 -1
  63. package/lib/http/HttpLlm.mjs +2 -7
  64. package/lib/http/HttpLlm.mjs.map +1 -1
  65. package/lib/http/HttpLlm2.mjs +107 -112
  66. package/lib/http/HttpLlm2.mjs.map +1 -1
  67. package/lib/http/HttpMigration.mjs +2 -7
  68. package/lib/http/HttpMigration.mjs.map +1 -1
  69. package/lib/http/HttpMigration2.mjs +58 -63
  70. package/lib/http/HttpMigration2.mjs.map +1 -1
  71. package/lib/http/index.mjs +1 -7
  72. package/lib/http/index.mjs.map +1 -1
  73. package/lib/http/index2.mjs +30 -31
  74. package/lib/http/index2.mjs.map +1 -1
  75. package/lib/http/internal/HttpLlmApplicationComposer.mjs +2 -7
  76. package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
  77. package/lib/http/internal/HttpLlmApplicationComposer2.mjs +301 -306
  78. package/lib/http/internal/HttpLlmApplicationComposer2.mjs.map +1 -1
  79. package/lib/http/internal/HttpLlmFunctionFetcher.mjs +2 -7
  80. package/lib/http/internal/HttpLlmFunctionFetcher.mjs.map +1 -1
  81. package/lib/http/internal/HttpLlmFunctionFetcher2.mjs +26 -33
  82. package/lib/http/internal/HttpLlmFunctionFetcher2.mjs.map +1 -1
  83. package/lib/http/internal/HttpMigrateApplicationComposer.mjs +2 -7
  84. package/lib/http/internal/HttpMigrateApplicationComposer.mjs.map +1 -1
  85. package/lib/http/internal/HttpMigrateApplicationComposer2.mjs +51 -56
  86. package/lib/http/internal/HttpMigrateApplicationComposer2.mjs.map +1 -1
  87. package/lib/http/internal/HttpMigrateRouteAccessor.mjs +2 -7
  88. package/lib/http/internal/HttpMigrateRouteAccessor.mjs.map +1 -1
  89. package/lib/http/internal/HttpMigrateRouteAccessor2.mjs +113 -118
  90. package/lib/http/internal/HttpMigrateRouteAccessor2.mjs.map +1 -1
  91. package/lib/http/internal/HttpMigrateRouteComposer.mjs +2 -7
  92. package/lib/http/internal/HttpMigrateRouteComposer.mjs.map +1 -1
  93. package/lib/http/internal/HttpMigrateRouteComposer2.mjs +376 -381
  94. package/lib/http/internal/HttpMigrateRouteComposer2.mjs.map +1 -1
  95. package/lib/http/internal/HttpMigrateRouteFetcher.mjs +2 -7
  96. package/lib/http/internal/HttpMigrateRouteFetcher.mjs.map +1 -1
  97. package/lib/http/internal/HttpMigrateRouteFetcher2.mjs +182 -189
  98. package/lib/http/internal/HttpMigrateRouteFetcher2.mjs.map +1 -1
  99. package/lib/index.mjs +1 -7
  100. package/lib/index.mjs.map +1 -1
  101. package/lib/index2.mjs +33 -33
  102. package/lib/index2.mjs.map +1 -1
  103. package/lib/utils/ArrayUtil.mjs +2 -7
  104. package/lib/utils/ArrayUtil.mjs.map +1 -1
  105. package/lib/utils/ArrayUtil2.mjs +29 -37
  106. package/lib/utils/ArrayUtil2.mjs.map +1 -1
  107. package/lib/utils/LlmJson.mjs +2 -7
  108. package/lib/utils/LlmJson.mjs.map +1 -1
  109. package/lib/utils/LlmJson2.mjs +166 -169
  110. package/lib/utils/LlmJson2.mjs.map +1 -1
  111. package/lib/utils/MapUtil.mjs +2 -7
  112. package/lib/utils/MapUtil.mjs.map +1 -1
  113. package/lib/utils/MapUtil2.mjs +16 -24
  114. package/lib/utils/MapUtil2.mjs.map +1 -1
  115. package/lib/utils/NamingConvention.mjs +2 -7
  116. package/lib/utils/NamingConvention.mjs.map +1 -1
  117. package/lib/utils/NamingConvention2.mjs +199 -207
  118. package/lib/utils/NamingConvention2.mjs.map +1 -1
  119. package/lib/utils/Singleton.d.ts +1 -6
  120. package/lib/utils/Singleton.js +1 -0
  121. package/lib/utils/Singleton.js.map +1 -1
  122. package/lib/utils/Singleton.mjs +2 -7
  123. package/lib/utils/Singleton.mjs.map +1 -1
  124. package/lib/utils/Singleton2.mjs +17 -24
  125. package/lib/utils/Singleton2.mjs.map +1 -1
  126. package/lib/utils/StringUtil.mjs +2 -7
  127. package/lib/utils/StringUtil.mjs.map +1 -1
  128. package/lib/utils/StringUtil2.mjs +14 -22
  129. package/lib/utils/StringUtil2.mjs.map +1 -1
  130. package/lib/utils/dedent.mjs +2 -7
  131. package/lib/utils/dedent.mjs.map +1 -1
  132. package/lib/utils/dedent2.mjs +50 -58
  133. package/lib/utils/dedent2.mjs.map +1 -1
  134. package/lib/utils/index.mjs +1 -7
  135. package/lib/utils/index.mjs.map +1 -1
  136. package/lib/utils/index2.mjs +42 -39
  137. package/lib/utils/index2.mjs.map +1 -1
  138. package/lib/utils/internal/EndpointUtil.mjs +2 -7
  139. package/lib/utils/internal/EndpointUtil.mjs.map +1 -1
  140. package/lib/utils/internal/EndpointUtil2.mjs +39 -46
  141. package/lib/utils/internal/EndpointUtil2.mjs.map +1 -1
  142. package/lib/utils/internal/JsonDescriptor.mjs +2 -7
  143. package/lib/utils/internal/JsonDescriptor.mjs.map +1 -1
  144. package/lib/utils/internal/JsonDescriptor2.mjs +55 -61
  145. package/lib/utils/internal/JsonDescriptor2.mjs.map +1 -1
  146. package/lib/utils/internal/OpenApiTypeCheckerBase.js +23 -14
  147. package/lib/utils/internal/OpenApiTypeCheckerBase.js.map +1 -1
  148. package/lib/utils/internal/OpenApiTypeCheckerBase.mjs +2 -7
  149. package/lib/utils/internal/OpenApiTypeCheckerBase.mjs.map +1 -1
  150. package/lib/utils/internal/OpenApiTypeCheckerBase2.mjs +539 -536
  151. package/lib/utils/internal/OpenApiTypeCheckerBase2.mjs.map +1 -1
  152. package/lib/utils/internal/coerceLlmArguments.js +27 -1
  153. package/lib/utils/internal/coerceLlmArguments.js.map +1 -1
  154. package/lib/utils/internal/coerceLlmArguments.mjs +2 -7
  155. package/lib/utils/internal/coerceLlmArguments.mjs.map +1 -1
  156. package/lib/utils/internal/coerceLlmArguments2.mjs +278 -258
  157. package/lib/utils/internal/coerceLlmArguments2.mjs.map +1 -1
  158. package/lib/utils/internal/parseLenientJson.mjs +2 -7
  159. package/lib/utils/internal/parseLenientJson.mjs.map +1 -1
  160. package/lib/utils/internal/parseLenientJson2.mjs +803 -811
  161. package/lib/utils/internal/parseLenientJson2.mjs.map +1 -1
  162. package/lib/utils/internal/stringifyValidationFailure.mjs +2 -7
  163. package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
  164. package/lib/utils/internal/stringifyValidationFailure2.mjs +310 -316
  165. package/lib/utils/internal/stringifyValidationFailure2.mjs.map +1 -1
  166. package/lib/validators/LlmTypeChecker.mjs +2 -7
  167. package/lib/validators/LlmTypeChecker.mjs.map +1 -1
  168. package/lib/validators/LlmTypeChecker2.mjs +314 -320
  169. package/lib/validators/LlmTypeChecker2.mjs.map +1 -1
  170. package/lib/validators/OpenApiTypeChecker.mjs +2 -7
  171. package/lib/validators/OpenApiTypeChecker.mjs.map +1 -1
  172. package/lib/validators/OpenApiTypeChecker2.mjs +209 -216
  173. package/lib/validators/OpenApiTypeChecker2.mjs.map +1 -1
  174. package/lib/validators/OpenApiV3TypeChecker.mjs +2 -7
  175. package/lib/validators/OpenApiV3TypeChecker.mjs.map +1 -1
  176. package/lib/validators/OpenApiV3TypeChecker2.mjs +30 -38
  177. package/lib/validators/OpenApiV3TypeChecker2.mjs.map +1 -1
  178. package/lib/validators/OpenApiV3_1TypeChecker.mjs +2 -7
  179. package/lib/validators/OpenApiV3_1TypeChecker.mjs.map +1 -1
  180. package/lib/validators/OpenApiV3_1TypeChecker2.mjs +34 -42
  181. package/lib/validators/OpenApiV3_1TypeChecker2.mjs.map +1 -1
  182. package/lib/validators/OpenApiValidator.mjs +2 -7
  183. package/lib/validators/OpenApiValidator.mjs.map +1 -1
  184. package/lib/validators/OpenApiValidator2.mjs +73 -80
  185. package/lib/validators/OpenApiValidator2.mjs.map +1 -1
  186. package/lib/validators/SwaggerV2TypeChecker.mjs +2 -7
  187. package/lib/validators/SwaggerV2TypeChecker.mjs.map +1 -1
  188. package/lib/validators/SwaggerV2TypeChecker2.mjs +31 -39
  189. package/lib/validators/SwaggerV2TypeChecker2.mjs.map +1 -1
  190. package/lib/validators/functional/_isBigintString.mjs +2 -7
  191. package/lib/validators/functional/_isBigintString.mjs.map +1 -1
  192. package/lib/validators/functional/_isBigintString2.mjs +14 -22
  193. package/lib/validators/functional/_isBigintString2.mjs.map +1 -1
  194. package/lib/validators/functional/_isFormatByte.mjs +2 -7
  195. package/lib/validators/functional/_isFormatByte.mjs.map +1 -1
  196. package/lib/validators/functional/_isFormatByte2.mjs +10 -18
  197. package/lib/validators/functional/_isFormatByte2.mjs.map +1 -1
  198. package/lib/validators/functional/_isFormatDate.mjs +2 -7
  199. package/lib/validators/functional/_isFormatDate.mjs.map +1 -1
  200. package/lib/validators/functional/_isFormatDate2.mjs +7 -15
  201. package/lib/validators/functional/_isFormatDate2.mjs.map +1 -1
  202. package/lib/validators/functional/_isFormatDateTime.mjs +2 -7
  203. package/lib/validators/functional/_isFormatDateTime.mjs.map +1 -1
  204. package/lib/validators/functional/_isFormatDateTime2.mjs +7 -15
  205. package/lib/validators/functional/_isFormatDateTime2.mjs.map +1 -1
  206. package/lib/validators/functional/_isFormatDuration.mjs +2 -7
  207. package/lib/validators/functional/_isFormatDuration.mjs.map +1 -1
  208. package/lib/validators/functional/_isFormatDuration2.mjs +7 -15
  209. package/lib/validators/functional/_isFormatDuration2.mjs.map +1 -1
  210. package/lib/validators/functional/_isFormatEmail.mjs +2 -7
  211. package/lib/validators/functional/_isFormatEmail.mjs.map +1 -1
  212. package/lib/validators/functional/_isFormatEmail2.mjs +7 -15
  213. package/lib/validators/functional/_isFormatEmail2.mjs.map +1 -1
  214. package/lib/validators/functional/_isFormatHostname.mjs +2 -7
  215. package/lib/validators/functional/_isFormatHostname.mjs.map +1 -1
  216. package/lib/validators/functional/_isFormatHostname2.mjs +7 -15
  217. package/lib/validators/functional/_isFormatHostname2.mjs.map +1 -1
  218. package/lib/validators/functional/_isFormatIdnEmail.mjs +2 -7
  219. package/lib/validators/functional/_isFormatIdnEmail.mjs.map +1 -1
  220. package/lib/validators/functional/_isFormatIdnEmail2.mjs +7 -15
  221. package/lib/validators/functional/_isFormatIdnEmail2.mjs.map +1 -1
  222. package/lib/validators/functional/_isFormatIdnHostname.mjs +2 -7
  223. package/lib/validators/functional/_isFormatIdnHostname.mjs.map +1 -1
  224. package/lib/validators/functional/_isFormatIdnHostname2.mjs +7 -15
  225. package/lib/validators/functional/_isFormatIdnHostname2.mjs.map +1 -1
  226. package/lib/validators/functional/_isFormatIpv4.mjs +2 -7
  227. package/lib/validators/functional/_isFormatIpv4.mjs.map +1 -1
  228. package/lib/validators/functional/_isFormatIpv42.mjs +7 -15
  229. package/lib/validators/functional/_isFormatIpv42.mjs.map +1 -1
  230. package/lib/validators/functional/_isFormatIpv6.mjs +2 -7
  231. package/lib/validators/functional/_isFormatIpv6.mjs.map +1 -1
  232. package/lib/validators/functional/_isFormatIpv62.mjs +7 -15
  233. package/lib/validators/functional/_isFormatIpv62.mjs.map +1 -1
  234. package/lib/validators/functional/_isFormatIri.mjs +2 -7
  235. package/lib/validators/functional/_isFormatIri.mjs.map +1 -1
  236. package/lib/validators/functional/_isFormatIri2.mjs +7 -15
  237. package/lib/validators/functional/_isFormatIri2.mjs.map +1 -1
  238. package/lib/validators/functional/_isFormatIriReference.mjs +2 -7
  239. package/lib/validators/functional/_isFormatIriReference.mjs.map +1 -1
  240. package/lib/validators/functional/_isFormatIriReference2.mjs +7 -15
  241. package/lib/validators/functional/_isFormatIriReference2.mjs.map +1 -1
  242. package/lib/validators/functional/_isFormatJsonPointer.mjs +2 -7
  243. package/lib/validators/functional/_isFormatJsonPointer.mjs.map +1 -1
  244. package/lib/validators/functional/_isFormatJsonPointer2.mjs +7 -15
  245. package/lib/validators/functional/_isFormatJsonPointer2.mjs.map +1 -1
  246. package/lib/validators/functional/_isFormatPassword.mjs +2 -7
  247. package/lib/validators/functional/_isFormatPassword.mjs.map +1 -1
  248. package/lib/validators/functional/_isFormatPassword2.mjs +6 -14
  249. package/lib/validators/functional/_isFormatPassword2.mjs.map +1 -1
  250. package/lib/validators/functional/_isFormatRegex.mjs +2 -7
  251. package/lib/validators/functional/_isFormatRegex.mjs.map +1 -1
  252. package/lib/validators/functional/_isFormatRegex2.mjs +14 -22
  253. package/lib/validators/functional/_isFormatRegex2.mjs.map +1 -1
  254. package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs +2 -7
  255. package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs.map +1 -1
  256. package/lib/validators/functional/_isFormatRelativeJsonPointer2.mjs +7 -15
  257. package/lib/validators/functional/_isFormatRelativeJsonPointer2.mjs.map +1 -1
  258. package/lib/validators/functional/_isFormatTime.mjs +2 -7
  259. package/lib/validators/functional/_isFormatTime.mjs.map +1 -1
  260. package/lib/validators/functional/_isFormatTime2.mjs +7 -15
  261. package/lib/validators/functional/_isFormatTime2.mjs.map +1 -1
  262. package/lib/validators/functional/_isFormatUri.mjs +2 -7
  263. package/lib/validators/functional/_isFormatUri.mjs.map +1 -1
  264. package/lib/validators/functional/_isFormatUri2.mjs +8 -16
  265. package/lib/validators/functional/_isFormatUri2.mjs.map +1 -1
  266. package/lib/validators/functional/_isFormatUriReference.mjs +2 -7
  267. package/lib/validators/functional/_isFormatUriReference.mjs.map +1 -1
  268. package/lib/validators/functional/_isFormatUriReference2.mjs +7 -15
  269. package/lib/validators/functional/_isFormatUriReference2.mjs.map +1 -1
  270. package/lib/validators/functional/_isFormatUriTemplate.mjs +2 -7
  271. package/lib/validators/functional/_isFormatUriTemplate.mjs.map +1 -1
  272. package/lib/validators/functional/_isFormatUriTemplate2.mjs +7 -15
  273. package/lib/validators/functional/_isFormatUriTemplate2.mjs.map +1 -1
  274. package/lib/validators/functional/_isFormatUrl.mjs +2 -7
  275. package/lib/validators/functional/_isFormatUrl.mjs.map +1 -1
  276. package/lib/validators/functional/_isFormatUrl2.mjs +7 -15
  277. package/lib/validators/functional/_isFormatUrl2.mjs.map +1 -1
  278. package/lib/validators/functional/_isFormatUuid.mjs +2 -7
  279. package/lib/validators/functional/_isFormatUuid.mjs.map +1 -1
  280. package/lib/validators/functional/_isFormatUuid2.mjs +7 -15
  281. package/lib/validators/functional/_isFormatUuid2.mjs.map +1 -1
  282. package/lib/validators/functional/_isUniqueItems.mjs +2 -7
  283. package/lib/validators/functional/_isUniqueItems.mjs.map +1 -1
  284. package/lib/validators/functional/_isUniqueItems2.mjs +140 -148
  285. package/lib/validators/functional/_isUniqueItems2.mjs.map +1 -1
  286. package/lib/validators/index.mjs +1 -7
  287. package/lib/validators/index.mjs.map +1 -1
  288. package/lib/validators/index2.mjs +42 -40
  289. package/lib/validators/index2.mjs.map +1 -1
  290. package/lib/validators/internal/IOpenApiValidatorContext.mjs +2 -7
  291. package/lib/validators/internal/IOpenApiValidatorContext.mjs.map +1 -1
  292. package/lib/validators/internal/IOpenApiValidatorContext2.mjs +2 -10
  293. package/lib/validators/internal/IOpenApiValidatorContext2.mjs.map +1 -1
  294. package/lib/validators/internal/OpenApiArrayValidator.mjs +2 -7
  295. package/lib/validators/internal/OpenApiArrayValidator.mjs.map +1 -1
  296. package/lib/validators/internal/OpenApiArrayValidator2.mjs +36 -42
  297. package/lib/validators/internal/OpenApiArrayValidator2.mjs.map +1 -1
  298. package/lib/validators/internal/OpenApiBooleanValidator.mjs +2 -7
  299. package/lib/validators/internal/OpenApiBooleanValidator.mjs.map +1 -1
  300. package/lib/validators/internal/OpenApiBooleanValidator2.mjs +10 -18
  301. package/lib/validators/internal/OpenApiBooleanValidator2.mjs.map +1 -1
  302. package/lib/validators/internal/OpenApiConstantValidator.mjs +2 -7
  303. package/lib/validators/internal/OpenApiConstantValidator.mjs.map +1 -1
  304. package/lib/validators/internal/OpenApiConstantValidator2.mjs +10 -18
  305. package/lib/validators/internal/OpenApiConstantValidator2.mjs.map +1 -1
  306. package/lib/validators/internal/OpenApiIntegerValidator.mjs +2 -7
  307. package/lib/validators/internal/OpenApiIntegerValidator.mjs.map +1 -1
  308. package/lib/validators/internal/OpenApiIntegerValidator2.mjs +33 -41
  309. package/lib/validators/internal/OpenApiIntegerValidator2.mjs.map +1 -1
  310. package/lib/validators/internal/OpenApiNumberValidator.mjs +2 -7
  311. package/lib/validators/internal/OpenApiNumberValidator.mjs.map +1 -1
  312. package/lib/validators/internal/OpenApiNumberValidator2.mjs +33 -41
  313. package/lib/validators/internal/OpenApiNumberValidator2.mjs.map +1 -1
  314. package/lib/validators/internal/OpenApiObjectValidator.js +2 -3
  315. package/lib/validators/internal/OpenApiObjectValidator.js.map +1 -1
  316. package/lib/validators/internal/OpenApiObjectValidator.mjs +2 -7
  317. package/lib/validators/internal/OpenApiObjectValidator.mjs.map +1 -1
  318. package/lib/validators/internal/OpenApiObjectValidator2.mjs +55 -62
  319. package/lib/validators/internal/OpenApiObjectValidator2.mjs.map +1 -1
  320. package/lib/validators/internal/OpenApiOneOfValidator.mjs +2 -7
  321. package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -1
  322. package/lib/validators/internal/OpenApiOneOfValidator2.mjs +188 -193
  323. package/lib/validators/internal/OpenApiOneOfValidator2.mjs.map +1 -1
  324. package/lib/validators/internal/OpenApiSchemaNamingRule.mjs +2 -7
  325. package/lib/validators/internal/OpenApiSchemaNamingRule.mjs.map +1 -1
  326. package/lib/validators/internal/OpenApiSchemaNamingRule2.mjs +124 -131
  327. package/lib/validators/internal/OpenApiSchemaNamingRule2.mjs.map +1 -1
  328. package/lib/validators/internal/OpenApiStationValidator.mjs +2 -7
  329. package/lib/validators/internal/OpenApiStationValidator.mjs.map +1 -1
  330. package/lib/validators/internal/OpenApiStationValidator2.mjs +86 -83
  331. package/lib/validators/internal/OpenApiStationValidator2.mjs.map +1 -1
  332. package/lib/validators/internal/OpenApiStringValidator.mjs +2 -7
  333. package/lib/validators/internal/OpenApiStringValidator.mjs.map +1 -1
  334. package/lib/validators/internal/OpenApiStringValidator2.mjs +115 -102
  335. package/lib/validators/internal/OpenApiStringValidator2.mjs.map +1 -1
  336. package/lib/validators/internal/OpenApiTupleValidator.mjs +2 -7
  337. package/lib/validators/internal/OpenApiTupleValidator.mjs.map +1 -1
  338. package/lib/validators/internal/OpenApiTupleValidator2.mjs +33 -40
  339. package/lib/validators/internal/OpenApiTupleValidator2.mjs.map +1 -1
  340. package/package.json +4 -4
  341. package/src/converters/LlmSchemaConverter.ts +1 -8
  342. package/src/utils/Singleton.ts +1 -0
  343. package/src/utils/internal/OpenApiTypeCheckerBase.ts +12 -3
  344. package/src/utils/internal/coerceLlmArguments.ts +27 -1
  345. package/src/validators/internal/OpenApiObjectValidator.ts +1 -2
@@ -1,262 +1,282 @@
1
- import { __exports as coerceLlmArguments } from '../../_virtual/coerceLlmArguments.mjs';
2
- import { __require as requireLlmTypeChecker } from '../../validators/LlmTypeChecker2.mjs';
3
- import { __require as requireParseLenientJson } from './parseLenientJson2.mjs';
1
+ import { __exports as coerceLlmArguments$1 } from '../../_virtual/coerceLlmArguments.mjs';
2
+ import '../../validators/LlmTypeChecker2.mjs';
3
+ import './parseLenientJson2.mjs';
4
+ import { __exports as LlmTypeChecker } from '../../_virtual/LlmTypeChecker.mjs';
5
+ import { __exports as parseLenientJson } from '../../_virtual/parseLenientJson.mjs';
4
6
 
5
- var hasRequiredCoerceLlmArguments;
6
-
7
- function requireCoerceLlmArguments () {
8
- if (hasRequiredCoerceLlmArguments) return coerceLlmArguments;
9
- hasRequiredCoerceLlmArguments = 1;
10
- Object.defineProperty(coerceLlmArguments, "__esModule", { value: true });
11
- coerceLlmArguments.coerceLlmArguments = coerceLlmArguments$1;
12
- const LlmTypeChecker_1 = requireLlmTypeChecker();
13
- const parseLenientJson_1 = requireParseLenientJson();
14
- /**
15
- * Coerce LLM arguments by parsing double-stringified JSON values.
16
- *
17
- * When LLM produces stringified JSON for non-string schema types, this function
18
- * attempts to parse them using the lenient JSON parser.
19
- *
20
- * Only applies coercion when value is string but schema expects non-string.
21
- * Type validation is handled separately by `ILlmFunction.validate`.
22
- *
23
- * @param value Parsed JSON value (potentially with stringified nested values)
24
- * @param parameters LLM parameters schema
25
- * @returns Coerced value with double-stringified JSON parsed
26
- * @internal
27
- */
28
- function coerceLlmArguments$1(value, parameters) {
29
- return coerceValue(value, parameters, parameters.$defs);
30
- }
31
- function coerceValue(value, schema, $defs) {
32
- // Resolve reference
33
- if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
34
- const key = schema.$ref.replace("#/$defs/", "");
35
- const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
36
- if (resolved !== undefined) {
37
- return coerceValue(value, resolved, $defs);
38
- }
39
- return value;
40
- }
41
- // Handle anyOf
42
- if (LlmTypeChecker_1.LlmTypeChecker.isAnyOf(schema)) {
43
- // Value is string
44
- if (typeof value === "string") {
45
- // If string is in union, don't parse - it's valid as-is
46
- const hasString = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isString(resolveSchema(s, $defs)));
47
- if (hasString) {
48
- return value;
49
- }
50
- // String value but no string in union - try to parse
51
- const parsed = (0, parseLenientJson_1.parseLenientJson)(value);
52
- if (parsed.success) {
53
- // Find uniquely matching schema via type + x-discriminator
54
- const matched = findMatchingAnyOfSchema(parsed.data, schema, $defs);
55
- if (matched !== undefined) {
56
- return coerceValue(parsed.data, matched, $defs);
57
- }
58
- return parsed.data;
59
- }
60
- // JSON parse failed - try "n" -> false or null
61
- if (value.length === 1 && value.toLowerCase() === "n") {
62
- const hasBoolean = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isBoolean(resolveSchema(s, $defs)));
63
- const hasNull = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isNull(resolveSchema(s, $defs)));
64
- if (hasBoolean && !hasNull)
65
- return false;
66
- else if (hasNull && !hasBoolean)
67
- return null;
68
- return value;
69
- }
70
- }
71
- // Value is object - find matching schema via discriminated union
72
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
73
- const matched = findMatchingObjectInAnyOf(value, schema, $defs);
74
- if (matched !== undefined) {
75
- return coerceValue(value, matched, $defs);
76
- }
77
- return value;
78
- }
79
- // Value is array - find matching array schema (only if unambiguous)
80
- if (Array.isArray(value)) {
81
- const arraySchemas = schema.anyOf.filter((s) => LlmTypeChecker_1.LlmTypeChecker.isArray(resolveSchema(s, $defs)));
82
- if (arraySchemas.length === 1) {
83
- return coerceValue(value, arraySchemas[0], $defs);
84
- }
85
- // Multiple or no array schemas - skip coercion
86
- return value;
87
- }
88
- // Non-string primitive or no matching schema - return as-is
89
- return value;
90
- }
91
- // String schema - no coercion needed (value stays as-is)
92
- if (LlmTypeChecker_1.LlmTypeChecker.isString(schema)) {
93
- return value;
94
- }
95
- // Unknown schema - no coercion needed
96
- if (LlmTypeChecker_1.LlmTypeChecker.isUnknown(schema)) {
97
- return value;
98
- }
99
- // Value is string but schema is non-string - try to parse
100
- if (typeof value === "string") {
101
- const parsed = (0, parseLenientJson_1.parseLenientJson)(value);
102
- if (parsed.success) {
103
- // Continue coercion on the parsed value (for nested stringified values)
104
- return coerceValue(parsed.data, schema, $defs);
105
- }
106
- // JSON parse failed - try "n" -> false for boolean schema
107
- if (value.length === 1 && value.toLowerCase() === "n") {
108
- if (LlmTypeChecker_1.LlmTypeChecker.isNull(schema))
109
- return null;
110
- if (LlmTypeChecker_1.LlmTypeChecker.isBoolean(schema))
111
- return false;
112
- }
113
- // Parse failed, return original - validate will catch type error
114
- return value;
115
- }
116
- // Value is array and schema is array - recurse into items
117
- if (Array.isArray(value) && LlmTypeChecker_1.LlmTypeChecker.isArray(schema)) {
118
- return value.map((item) => coerceValue(item, schema.items, $defs));
119
- }
120
- // Value is object and schema is object - recurse into properties
121
- if (typeof value === "object" &&
122
- value !== null &&
123
- !Array.isArray(value) &&
124
- LlmTypeChecker_1.LlmTypeChecker.isObject(schema)) {
125
- return coerceObject(value, schema, $defs);
126
- }
127
- // Everything else (null, boolean, number, integer) - return as-is
128
- return value;
129
- }
130
- function coerceObject(value, schema, $defs) {
131
- const result = {};
132
- // Coerce known properties
133
- for (const [key, propSchema] of Object.entries(schema.properties)) {
134
- if (key in value) {
135
- result[key] = coerceValue(value[key], propSchema, $defs);
136
- }
137
- }
138
- // Preserve additional properties - let validation handle rejection
139
- const additionalSchema = typeof schema.additionalProperties === "object"
140
- ? schema.additionalProperties
141
- : undefined;
142
- for (const key of Object.keys(value)) {
143
- if (!(key in schema.properties)) {
144
- result[key] = additionalSchema
145
- ? coerceValue(value[key], additionalSchema, $defs)
146
- : value[key];
147
- }
148
- }
149
- return result;
150
- }
151
- function resolveSchema(schema, $defs) {
152
- if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
153
- const key = schema.$ref.replace("#/$defs/", "");
154
- const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
155
- if (resolved !== undefined) {
156
- return resolveSchema(resolved, $defs);
157
- }
158
- }
159
- return schema;
160
- }
161
- /**
162
- * Check if value roughly matches the expected schema type. Used for anyOf
163
- * matching after parsing.
164
- */
165
- function matchesSchemaType(value, schema, $defs) {
166
- if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
167
- const key = schema.$ref.replace("#/$defs/", "");
168
- const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
169
- if (resolved)
170
- return matchesSchemaType(value, resolved, $defs);
171
- return false;
172
- }
173
- if (LlmTypeChecker_1.LlmTypeChecker.isNull(schema))
174
- return value === null;
175
- if (LlmTypeChecker_1.LlmTypeChecker.isBoolean(schema))
176
- return typeof value === "boolean";
177
- if (LlmTypeChecker_1.LlmTypeChecker.isInteger(schema))
178
- return typeof value === "number" && Number.isInteger(value);
179
- if (LlmTypeChecker_1.LlmTypeChecker.isNumber(schema))
180
- return typeof value === "number";
181
- if (LlmTypeChecker_1.LlmTypeChecker.isString(schema))
182
- return typeof value === "string";
183
- if (LlmTypeChecker_1.LlmTypeChecker.isArray(schema))
184
- return Array.isArray(value);
185
- if (LlmTypeChecker_1.LlmTypeChecker.isObject(schema))
186
- return typeof value === "object" && value !== null && !Array.isArray(value);
187
- if (LlmTypeChecker_1.LlmTypeChecker.isUnknown(schema))
188
- return true;
189
- if (LlmTypeChecker_1.LlmTypeChecker.isAnyOf(schema))
190
- return schema.anyOf.some((s) => matchesSchemaType(value, s, $defs));
191
- return false;
192
- }
193
- /**
194
- * Find the uniquely matching schema for a value among anyOf alternatives. Uses
195
- * `x-discriminator` for object disambiguation. Returns undefined if no unique
196
- * match can be determined.
197
- */
198
- function findMatchingAnyOfSchema(value, schema, $defs) {
199
- const matching = schema.anyOf.filter((s) => matchesSchemaType(value, s, $defs));
200
- if (matching.length === 1)
201
- return matching[0];
202
- if (matching.length === 0)
203
- return undefined;
204
- // Multiple type matches - try x-discriminator for objects
205
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
206
- return findMatchingObjectInAnyOf(value, schema, $defs);
207
- }
208
- return undefined;
209
- }
210
- /**
211
- * Find the matching object schema among anyOf using `x-discriminator`. If only
212
- * one object schema exists, returns it directly. If multiple exist but no
213
- * x-discriminator, gives up.
214
- */
215
- function findMatchingObjectInAnyOf(value, schema, $defs) {
216
- var _a, _b;
217
- const objectSchemas = schema.anyOf.filter((s) => LlmTypeChecker_1.LlmTypeChecker.isObject(resolveSchema(s, $defs)));
218
- if (objectSchemas.length === 0)
219
- return undefined;
220
- if (objectSchemas.length === 1)
221
- return objectSchemas[0];
222
- // Multiple object schemas - require x-discriminator
223
- const discriminator = schema["x-discriminator"];
224
- if (discriminator === undefined)
225
- return undefined;
226
- const key = discriminator.propertyName;
227
- const discriminatorValue = value[key];
228
- // Use mapping for direct $ref lookup
229
- if (discriminator.mapping !== undefined &&
230
- typeof discriminatorValue === "string") {
231
- const ref = discriminator.mapping[discriminatorValue];
232
- if (ref !== undefined) {
233
- for (const s of schema.anyOf) {
234
- if (LlmTypeChecker_1.LlmTypeChecker.isReference(s) && s.$ref === ref) {
235
- return s;
236
- }
237
- }
238
- }
239
- return undefined;
240
- }
241
- // No mapping - match by enum values on the discriminator property
242
- for (const s of objectSchemas) {
243
- const resolved = resolveSchema(s, $defs);
244
- if (!LlmTypeChecker_1.LlmTypeChecker.isObject(resolved))
245
- continue;
246
- const propSchema = (_a = resolved.properties) === null || _a === void 0 ? void 0 : _a[key];
247
- if (propSchema === undefined)
248
- continue;
249
- const resolvedProp = resolveSchema(propSchema, $defs);
250
- if (LlmTypeChecker_1.LlmTypeChecker.isString(resolvedProp) &&
251
- ((_b = resolvedProp.enum) === null || _b === void 0 ? void 0 : _b.includes(discriminatorValue))) {
252
- return s;
253
- }
254
- }
255
- return undefined;
256
- }
257
-
258
- return coerceLlmArguments;
7
+ Object.defineProperty(coerceLlmArguments$1, "__esModule", { value: true });
8
+ var coerceLlmArguments_2 = coerceLlmArguments$1.coerceLlmArguments = coerceLlmArguments;
9
+ const LlmTypeChecker_1 = LlmTypeChecker;
10
+ const parseLenientJson_1 = parseLenientJson;
11
+ /**
12
+ * Coerce LLM arguments by parsing double-stringified JSON values.
13
+ *
14
+ * When LLM produces stringified JSON for non-string schema types, this function
15
+ * attempts to parse them using the lenient JSON parser.
16
+ *
17
+ * Only applies coercion when value is string but schema expects non-string.
18
+ * Type validation is handled separately by `ILlmFunction.validate`.
19
+ *
20
+ * @param value Parsed JSON value (potentially with stringified nested values)
21
+ * @param parameters LLM parameters schema
22
+ * @returns Coerced value with double-stringified JSON parsed
23
+ * @internal
24
+ */
25
+ function coerceLlmArguments(value, parameters) {
26
+ return coerceValue(value, parameters, parameters.$defs);
27
+ }
28
+ function coerceValue(value, schema, $defs) {
29
+ // Resolve reference
30
+ if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
31
+ const key = schema.$ref.replace("#/$defs/", "");
32
+ const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
33
+ if (resolved !== undefined) {
34
+ return coerceValue(value, resolved, $defs);
35
+ }
36
+ return value;
37
+ }
38
+ // Handle anyOf
39
+ if (LlmTypeChecker_1.LlmTypeChecker.isAnyOf(schema)) {
40
+ // Value is string
41
+ if (typeof value === "string") {
42
+ // If string is in union, don't parse - it's valid as-is
43
+ const hasString = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isString(resolveSchema(s, $defs)));
44
+ if (hasString) {
45
+ return value;
46
+ }
47
+ // String value but no string in union - try to parse
48
+ const parsed = (0, parseLenientJson_1.parseLenientJson)(value);
49
+ if (parsed.success) {
50
+ // Find uniquely matching schema via type + x-discriminator
51
+ const matched = findMatchingAnyOfSchema(parsed.data, schema, $defs);
52
+ if (matched !== undefined) {
53
+ return coerceValue(parsed.data, matched, $defs);
54
+ }
55
+ return parsed.data;
56
+ }
57
+ // JSON parse failed - try "n" -> false or null
58
+ if (value.length === 1 && value.toLowerCase() === "n") {
59
+ const hasBoolean = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isBoolean(resolveSchema(s, $defs)));
60
+ const hasNull = schema.anyOf.some((s) => LlmTypeChecker_1.LlmTypeChecker.isNull(resolveSchema(s, $defs)));
61
+ if (hasBoolean && !hasNull)
62
+ return false;
63
+ else if (hasNull && !hasBoolean)
64
+ return null;
65
+ return value;
66
+ }
67
+ }
68
+ // Value is object - find matching schema via discriminated union
69
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
70
+ const matched = findMatchingObjectInAnyOf(value, schema, $defs);
71
+ if (matched !== undefined) {
72
+ return coerceValue(value, matched, $defs);
73
+ }
74
+ return value;
75
+ }
76
+ // Value is array - find matching array schema (only if unambiguous)
77
+ if (Array.isArray(value)) {
78
+ const arraySchemas = schema.anyOf.filter((s) => LlmTypeChecker_1.LlmTypeChecker.isArray(resolveSchema(s, $defs)));
79
+ if (arraySchemas.length === 1) {
80
+ return coerceValue(value, arraySchemas[0], $defs);
81
+ }
82
+ // Multiple or no array schemas - skip coercion
83
+ return value;
84
+ }
85
+ // Non-string primitive or no matching schema - return as-is
86
+ return value;
87
+ }
88
+ // String schema - no coercion needed (value stays as-is)
89
+ if (LlmTypeChecker_1.LlmTypeChecker.isString(schema)) {
90
+ return value;
91
+ }
92
+ // Unknown schema - no coercion needed
93
+ if (LlmTypeChecker_1.LlmTypeChecker.isUnknown(schema)) {
94
+ return value;
95
+ }
96
+ // Value is string but schema is non-string - try to parse
97
+ if (typeof value === "string") {
98
+ const parsed = (0, parseLenientJson_1.parseLenientJson)(value);
99
+ if (parsed.success) {
100
+ // Continue coercion on the parsed value (for nested stringified values)
101
+ return coerceValue(parsed.data, schema, $defs);
102
+ }
103
+ // JSON parse failed - try "n" -> false for boolean schema
104
+ if (value.length === 1 && value.toLowerCase() === "n") {
105
+ if (LlmTypeChecker_1.LlmTypeChecker.isNull(schema))
106
+ return null;
107
+ if (LlmTypeChecker_1.LlmTypeChecker.isBoolean(schema))
108
+ return false;
109
+ }
110
+ // Parse failed, return original - validate will catch type error
111
+ return value;
112
+ }
113
+ // Value is array and schema is array - recurse into items
114
+ if (Array.isArray(value) && LlmTypeChecker_1.LlmTypeChecker.isArray(schema)) {
115
+ return value.map((item) => coerceValue(item, schema.items, $defs));
116
+ }
117
+ // Value is object and schema is object - recurse into properties
118
+ if (typeof value === "object" &&
119
+ value !== null &&
120
+ !Array.isArray(value) &&
121
+ LlmTypeChecker_1.LlmTypeChecker.isObject(schema)) {
122
+ return coerceObject(value, schema, $defs);
123
+ }
124
+ // Everything else (null, boolean, number, integer) - return as-is
125
+ return value;
126
+ }
127
+ function coerceObject(value, schema, $defs) {
128
+ const result = {};
129
+ // Coerce known properties
130
+ for (const [key, propSchema] of Object.entries(schema.properties)) {
131
+ if (key in value) {
132
+ result[key] = coerceValue(value[key], propSchema, $defs);
133
+ }
134
+ }
135
+ // Preserve additional properties - let validation handle rejection
136
+ const additionalSchema = typeof schema.additionalProperties === "object"
137
+ ? schema.additionalProperties
138
+ : undefined;
139
+ for (const key of Object.keys(value)) {
140
+ if (!(key in schema.properties)) {
141
+ result[key] = additionalSchema
142
+ ? coerceValue(value[key], additionalSchema, $defs)
143
+ : coerceLoose(value[key]);
144
+ }
145
+ }
146
+ return result;
147
+ }
148
+ function coerceLoose(value) {
149
+ if (typeof value === "string") {
150
+ const parsed = (0, parseLenientJson_1.parseLenientJson)(value);
151
+ if (parsed.success)
152
+ return coerceLoose(parsed.data);
153
+ if (value === "true")
154
+ return true;
155
+ if (value === "false")
156
+ return false;
157
+ if (/^-?\d+(?:\.\d+)?$/.test(value))
158
+ return Number(value);
159
+ return value;
160
+ }
161
+ if (Array.isArray(value))
162
+ return value.map(coerceLoose);
163
+ if (value !== null && typeof value === "object")
164
+ return Object.fromEntries(Object.entries(value).map(([key, val]) => [
165
+ key,
166
+ coerceLoose(val),
167
+ ]));
168
+ return value;
169
+ }
170
+ function resolveSchema(schema, $defs) {
171
+ if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
172
+ const key = schema.$ref.replace("#/$defs/", "");
173
+ const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
174
+ if (resolved !== undefined) {
175
+ return resolveSchema(resolved, $defs);
176
+ }
177
+ }
178
+ return schema;
179
+ }
180
+ /**
181
+ * Check if value roughly matches the expected schema type. Used for anyOf
182
+ * matching after parsing.
183
+ */
184
+ function matchesSchemaType(value, schema, $defs) {
185
+ if (LlmTypeChecker_1.LlmTypeChecker.isReference(schema)) {
186
+ const key = schema.$ref.replace("#/$defs/", "");
187
+ const resolved = $defs === null || $defs === void 0 ? void 0 : $defs[key];
188
+ if (resolved)
189
+ return matchesSchemaType(value, resolved, $defs);
190
+ return false;
191
+ }
192
+ if (LlmTypeChecker_1.LlmTypeChecker.isNull(schema))
193
+ return value === null;
194
+ if (LlmTypeChecker_1.LlmTypeChecker.isBoolean(schema))
195
+ return typeof value === "boolean";
196
+ if (LlmTypeChecker_1.LlmTypeChecker.isInteger(schema))
197
+ return typeof value === "number" && Number.isInteger(value);
198
+ if (LlmTypeChecker_1.LlmTypeChecker.isNumber(schema))
199
+ return typeof value === "number";
200
+ if (LlmTypeChecker_1.LlmTypeChecker.isString(schema))
201
+ return typeof value === "string";
202
+ if (LlmTypeChecker_1.LlmTypeChecker.isArray(schema))
203
+ return Array.isArray(value);
204
+ if (LlmTypeChecker_1.LlmTypeChecker.isObject(schema))
205
+ return typeof value === "object" && value !== null && !Array.isArray(value);
206
+ if (LlmTypeChecker_1.LlmTypeChecker.isUnknown(schema))
207
+ return true;
208
+ if (LlmTypeChecker_1.LlmTypeChecker.isAnyOf(schema))
209
+ return schema.anyOf.some((s) => matchesSchemaType(value, s, $defs));
210
+ return false;
211
+ }
212
+ /**
213
+ * Find the uniquely matching schema for a value among anyOf alternatives. Uses
214
+ * `x-discriminator` for object disambiguation. Returns undefined if no unique
215
+ * match can be determined.
216
+ */
217
+ function findMatchingAnyOfSchema(value, schema, $defs) {
218
+ const matching = schema.anyOf.filter((s) => matchesSchemaType(value, s, $defs));
219
+ if (matching.length === 1)
220
+ return matching[0];
221
+ if (matching.length === 0)
222
+ return undefined;
223
+ // Multiple type matches - try x-discriminator for objects
224
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
225
+ return findMatchingObjectInAnyOf(value, schema, $defs);
226
+ }
227
+ return undefined;
228
+ }
229
+ /**
230
+ * Find the matching object schema among anyOf using `x-discriminator`. If only
231
+ * one object schema exists, returns it directly. If multiple exist but no
232
+ * x-discriminator, gives up.
233
+ */
234
+ function findMatchingObjectInAnyOf(value, schema, $defs) {
235
+ var _a, _b;
236
+ const objectSchemas = schema.anyOf.filter((s) => LlmTypeChecker_1.LlmTypeChecker.isObject(resolveSchema(s, $defs)));
237
+ if (objectSchemas.length === 0)
238
+ return undefined;
239
+ if (objectSchemas.length === 1)
240
+ return objectSchemas[0];
241
+ // Multiple object schemas - require x-discriminator
242
+ const discriminator = schema["x-discriminator"];
243
+ if (discriminator === undefined)
244
+ return undefined;
245
+ const key = discriminator.propertyName;
246
+ const discriminatorValue = value[key];
247
+ // Use mapping for direct $ref lookup
248
+ if (discriminator.mapping !== undefined &&
249
+ typeof discriminatorValue === "string") {
250
+ const ref = discriminator.mapping[discriminatorValue];
251
+ if (ref !== undefined) {
252
+ for (const s of schema.anyOf) {
253
+ if (LlmTypeChecker_1.LlmTypeChecker.isReference(s) && s.$ref === ref) {
254
+ return s;
255
+ }
256
+ }
257
+ }
258
+ return undefined;
259
+ }
260
+ // No mapping - match by enum values on the discriminator property
261
+ for (const s of objectSchemas) {
262
+ const resolved = resolveSchema(s, $defs);
263
+ if (!LlmTypeChecker_1.LlmTypeChecker.isObject(resolved))
264
+ continue;
265
+ const propSchema = (_a = resolved.properties) === null || _a === void 0 ? void 0 : _a[key];
266
+ if (propSchema === undefined)
267
+ continue;
268
+ const resolvedProp = resolveSchema(propSchema, $defs);
269
+ if ("const" in resolvedProp &&
270
+ resolvedProp.const === discriminatorValue) {
271
+ return s;
272
+ }
273
+ if (LlmTypeChecker_1.LlmTypeChecker.isString(resolvedProp) &&
274
+ ((_b = resolvedProp.enum) === null || _b === void 0 ? void 0 : _b.includes(discriminatorValue))) {
275
+ return s;
276
+ }
277
+ }
278
+ return undefined;
259
279
  }
260
280
 
261
- export { requireCoerceLlmArguments as __require };
281
+ export { coerceLlmArguments_2 as coerceLlmArguments, coerceLlmArguments$1 as default };
262
282
  //# sourceMappingURL=coerceLlmArguments2.mjs.map