@typia/utils 13.0.0-dev.20260427-3 → 13.0.0-dev.20260501

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 -6
  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 +449 -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 -1
  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,384 +1,379 @@
1
- import { __exports as HttpMigrateRouteComposer } from '../../_virtual/HttpMigrateRouteComposer.mjs';
2
- import { __require as requireNamingConvention } from '../../utils/NamingConvention2.mjs';
3
- import { __require as requireEndpointUtil } from '../../utils/internal/EndpointUtil2.mjs';
4
- import { __require as requireOpenApiTypeChecker } from '../../validators/OpenApiTypeChecker2.mjs';
1
+ import { __exports as HttpMigrateRouteComposer$1 } from '../../_virtual/HttpMigrateRouteComposer.mjs';
2
+ import '../../utils/NamingConvention2.mjs';
3
+ import '../../utils/internal/EndpointUtil2.mjs';
4
+ import '../../validators/OpenApiTypeChecker2.mjs';
5
+ import { __exports as EndpointUtil } from '../../_virtual/EndpointUtil.mjs';
6
+ import { __exports as OpenApiTypeChecker } from '../../_virtual/OpenApiTypeChecker.mjs';
7
+ import { __exports as NamingConvention } from '../../_virtual/NamingConvention.mjs';
5
8
 
6
- var hasRequiredHttpMigrateRouteComposer;
9
+ Object.defineProperty(HttpMigrateRouteComposer$1, "__esModule", { value: true });
10
+ var HttpMigrateRouteComposer_2 = HttpMigrateRouteComposer$1.HttpMigrateRouteComposer = void 0;
11
+ const NamingConvention_1 = NamingConvention;
12
+ const EndpointUtil_1 = EndpointUtil;
13
+ const OpenApiTypeChecker_1 = OpenApiTypeChecker;
14
+ var HttpMigrateRouteComposer;
15
+ (function (HttpMigrateRouteComposer) {
16
+ HttpMigrateRouteComposer.compose = (props) => {
17
+ var _a, _b, _c, _d, _e;
18
+ //----
19
+ // REQUEST AND RESPONSE BODY
20
+ //----
21
+ const body = emplaceBodySchema("request")((schema) => emplaceReference({
22
+ document: props.document,
23
+ name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
24
+ "." +
25
+ EndpointUtil_1.EndpointUtil.pascal(`${props.method}/Body`),
26
+ schema,
27
+ }))(props.operation.requestBody);
28
+ const success = (() => {
29
+ var _a, _b, _c, _d, _e;
30
+ var _f, _g;
31
+ const body = emplaceBodySchema("response")((schema) => emplaceReference({
32
+ document: props.document,
33
+ name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
34
+ "." +
35
+ EndpointUtil_1.EndpointUtil.pascal(`${props.method}/Response`),
36
+ schema,
37
+ }))((_g = (_f = (_a = props.operation.responses) === null || _a === void 0 ? void 0 : _a["201"]) !== null && _f !== void 0 ? _f : (_b = props.operation.responses) === null || _b === void 0 ? void 0 : _b["200"]) !== null && _g !== void 0 ? _g : (_c = props.operation.responses) === null || _c === void 0 ? void 0 : _c.default);
38
+ return body
39
+ ? Object.assign(Object.assign({}, body), { status: ((_d = props.operation.responses) === null || _d === void 0 ? void 0 : _d["201"])
40
+ ? "201"
41
+ : ((_e = props.operation.responses) === null || _e === void 0 ? void 0 : _e["200"])
42
+ ? "200"
43
+ : "default" }) : body;
44
+ })();
45
+ const failures = [];
46
+ if (body === false)
47
+ failures.push(`supports only "application/json", "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain" content type in the request body.`);
48
+ if (success === false)
49
+ failures.push(`supports only "application/json", "application/x-www-form-urlencoded" and "text/plain" content type in the response body.`);
50
+ //----
51
+ // HEADERS AND QUERY
52
+ //---
53
+ const [headers, query] = ["header", "query"].map((type) => {
54
+ var _a, _b, _c, _d;
55
+ // FIND TARGET PARAMETERS
56
+ const parameters = ((_a = props.operation.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === type);
57
+ if (parameters.length === 0)
58
+ return null;
59
+ // CHECK PARAMETER TYPES -> TO BE OBJECT
60
+ const objects = parameters
61
+ .map((p) => { var _a; var _b; return OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(p.schema)
62
+ ? p.schema
63
+ : OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(p.schema) &&
64
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isObject((_b = (_a = props.document.components.schemas) === null || _a === void 0 ? void 0 : _a[p.schema.$ref.replace(`#/components/schemas/`, ``)]) !== null && _b !== void 0 ? _b : {})
65
+ ? p.schema
66
+ : null; })
67
+ .filter((s) => !!s);
68
+ const primitives = parameters.filter((p) => OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(p.schema) ||
69
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isInteger(p.schema) ||
70
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(p.schema) ||
71
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isString(p.schema) ||
72
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(p.schema) ||
73
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(p.schema));
74
+ const out = (elem) => (Object.assign(Object.assign({}, elem), { name: type, key: type, title: () => elem.title, description: () => elem.description, example: () => elem.example, examples: () => elem.examples }));
75
+ if (objects.length === 1 && primitives.length === 0)
76
+ return out(parameters[0]);
77
+ else if (objects.length > 1) {
78
+ failures.push(`${type} typed parameters must be only one object type`);
79
+ return false;
80
+ }
81
+ // GATHER TO OBJECT TYPE
82
+ const dto = objects[0]
83
+ ? OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(objects[0])
84
+ ? objects[0]
85
+ : ((_b = props.document.components.schemas) !== null && _b !== void 0 ? _b : {})[objects[0].$ref.replace(`#/components/schemas/`, ``)]
86
+ : null;
87
+ const entire = [
88
+ ...objects.map((o) => { var _a; return OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(o)
89
+ ? o
90
+ : (_a = props.document.components.schemas) === null || _a === void 0 ? void 0 : _a[o.$ref.replace(`#/components/schemas/`, ``)]; }),
91
+ {
92
+ type: "object",
93
+ properties: Object.fromEntries([
94
+ ...primitives.map((p) => { var _a; return [
95
+ p.name,
96
+ Object.assign(Object.assign({}, p.schema), { description: (_a = p.schema.description) !== null && _a !== void 0 ? _a : p.description }),
97
+ ]; }),
98
+ ...(dto ? Object.entries((_c = dto.properties) !== null && _c !== void 0 ? _c : {}) : []),
99
+ ]),
100
+ required: [
101
+ ...new Set([
102
+ ...primitives.filter((p) => p.required).map((p) => p.name),
103
+ ...((_d = dto === null || dto === void 0 ? void 0 : dto.required) !== null && _d !== void 0 ? _d : []),
104
+ ]),
105
+ ],
106
+ },
107
+ ];
108
+ return parameters.length === 0
109
+ ? null
110
+ : out({
111
+ schema: emplaceReference({
112
+ document: props.document,
113
+ name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
114
+ "." +
115
+ EndpointUtil_1.EndpointUtil.pascal(`${props.method}/${type}`),
116
+ schema: {
117
+ type: "object",
118
+ properties: Object.fromEntries([
119
+ ...new Map(entire
120
+ .map((o) => { var _a; return Object.entries((_a = o.properties) !== null && _a !== void 0 ? _a : {}).map(([name, schema]) => { var _a; return [
121
+ name,
122
+ Object.assign(Object.assign({}, schema), { description: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.description }),
123
+ ]; }); })
124
+ .flat()),
125
+ ]),
126
+ required: [
127
+ ...new Set(entire.map((o) => { var _a; return (_a = o.required) !== null && _a !== void 0 ? _a : []; }).flat()),
128
+ ],
129
+ },
130
+ }),
131
+ });
132
+ });
133
+ //----
134
+ // PATH PARAMETERS
135
+ //----
136
+ const parameterNames = EndpointUtil_1.EndpointUtil.splitWithNormalization(props.emendedPath)
137
+ .filter((str) => str[0] === ":")
138
+ .map((str) => str.substring(1));
139
+ const pathParameters = ((_a = props.operation.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === "path");
140
+ if (parameterNames.length !== pathParameters.length)
141
+ if (pathParameters.length < parameterNames.length &&
142
+ pathParameters.every((p) => p.name !== undefined && parameterNames.includes(p.name))) {
143
+ for (const name of parameterNames)
144
+ if (pathParameters.find((p) => p.name === name) === undefined)
145
+ pathParameters.push({
146
+ name,
147
+ in: "path",
148
+ schema: { type: "string" },
149
+ });
150
+ pathParameters.sort((a, b) => parameterNames.indexOf(a.name) - parameterNames.indexOf(b.name));
151
+ props.operation.parameters = [
152
+ ...pathParameters,
153
+ ...((_b = props.operation.parameters) !== null && _b !== void 0 ? _b : []).filter((p) => p.in !== "path"),
154
+ ];
155
+ }
156
+ else
157
+ failures.push("number of path parameters are not matched with its full path.");
158
+ if (failures.length)
159
+ return failures;
160
+ const parameters = ((_c = props.operation.parameters) !== null && _c !== void 0 ? _c : [])
161
+ .filter((p) => p.in === "path")
162
+ .map((p, i) => ({
163
+ // FILL KEY NAME IF NOT EXISTS
164
+ name: parameterNames[i],
165
+ key: (() => {
166
+ let key = EndpointUtil_1.EndpointUtil.normalize(parameterNames[i]);
167
+ if (NamingConvention_1.NamingConvention.variable(key))
168
+ return key;
169
+ while (true) {
170
+ key = "_" + key;
171
+ if (!parameterNames.some((s) => s === key))
172
+ return key;
173
+ }
174
+ })(),
175
+ schema: p.schema,
176
+ parameter: () => p,
177
+ }));
178
+ return {
179
+ method: props.method,
180
+ path: props.path,
181
+ emendedPath: props.emendedPath,
182
+ accessor: ["@lazy"],
183
+ parameters: ((_d = props.operation.parameters) !== null && _d !== void 0 ? _d : [])
184
+ .filter((p) => p.in === "path")
185
+ .map((p, i) => ({
186
+ // FILL KEY NAME IF NOT EXISTS
187
+ name: parameterNames[i],
188
+ key: (() => {
189
+ let key = EndpointUtil_1.EndpointUtil.normalize(parameterNames[i]);
190
+ if (NamingConvention_1.NamingConvention.variable(key))
191
+ return key;
192
+ while (true) {
193
+ key = "_" + key;
194
+ if (!parameterNames.some((s) => s === key))
195
+ return key;
196
+ }
197
+ })(),
198
+ schema: p.schema,
199
+ parameter: () => p,
200
+ })),
201
+ headers: headers || null,
202
+ query: query || null,
203
+ body: body || null,
204
+ success: success || null,
205
+ exceptions: Object.fromEntries(Object.entries((_e = props.operation.responses) !== null && _e !== void 0 ? _e : {})
206
+ .filter(([key]) => key !== "200" && key !== "201" && key !== "default")
207
+ .map(([status, response]) => { var _a, _b; var _c; return [
208
+ status,
209
+ {
210
+ schema: ((_c = (_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) === null || _b === void 0 ? void 0 : _b.schema) !== null && _c !== void 0 ? _c : {}),
211
+ response: () => response,
212
+ media: () => { var _a; var _b; return ((_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) !== null && _b !== void 0 ? _b : {}); },
213
+ },
214
+ ]; })),
215
+ comment: () => writeRouteComment({
216
+ operation: props.operation,
217
+ parameters,
218
+ body: body || null,
219
+ }),
220
+ operation: () => props.operation,
221
+ };
222
+ };
223
+ const writeRouteComment = (props) => {
224
+ var _a, _b, _c;
225
+ var _d, _e, _f;
226
+ // write basic description combining with summary
227
+ let description = (_d = props.operation.description) !== null && _d !== void 0 ? _d : "";
228
+ if (!!((_a = props.operation.summary) === null || _a === void 0 ? void 0 : _a.length)) {
229
+ const summary = props.operation.summary.endsWith(".")
230
+ ? props.operation.summary
231
+ : props.operation.summary + ".";
232
+ if (!!description.length &&
233
+ !description.startsWith(props.operation.summary))
234
+ description = `${summary}\n\n${description}`;
235
+ }
236
+ description = description
237
+ .split("\n")
238
+ .map((s) => s.trim())
239
+ .join("\n");
240
+ //----
241
+ // compose jsdoc comment tags
242
+ //----
243
+ const commentTags = [];
244
+ const add = (text) => {
245
+ if (commentTags.every((line) => line !== text))
246
+ commentTags.push(text);
247
+ };
248
+ // parameters
249
+ add("@param connection");
250
+ for (const p of (_e = props.parameters) !== null && _e !== void 0 ? _e : []) {
251
+ const param = p.parameter();
252
+ if (param.description) {
253
+ const text = param.description;
254
+ add(`@param ${p.name} ${writeIndented(text, p.name.length + 8)}`);
255
+ }
256
+ }
257
+ if ((_c = (_b = props.body) === null || _b === void 0 ? void 0 : _b.description()) === null || _c === void 0 ? void 0 : _c.length)
258
+ add(`@param body ${writeIndented(props.body.description(), 12)}`);
259
+ // security
260
+ for (const security of (_f = props.operation.security) !== null && _f !== void 0 ? _f : [])
261
+ for (const [name, scopes] of Object.entries(security))
262
+ add(`@security ${[name, ...scopes].join("")}`);
263
+ // categorizing tags
264
+ if (props.operation.tags)
265
+ props.operation.tags.forEach((name) => add(`@tag ${name}`));
266
+ // deprecated
267
+ if (props.operation.deprecated)
268
+ add("@deprecated");
269
+ // plugin properties
270
+ for (const [key, value] of Object.entries(props.operation)) {
271
+ if (key.startsWith("x-") === false)
272
+ continue;
273
+ else if (value !== null &&
274
+ typeof value !== "boolean" &&
275
+ typeof value !== "number" &&
276
+ typeof value !== "string")
277
+ continue;
278
+ add(`@${key} ${value}`);
279
+ }
280
+ // finalize description
281
+ description = description.length
282
+ ? commentTags.length
283
+ ? `${description}\n\n${commentTags.join("\n")}`
284
+ : description
285
+ : commentTags.join("\n");
286
+ description = description.split("*/").join("*\\/");
287
+ return description;
288
+ };
289
+ const writeIndented = (text, spaces) => text
290
+ .split("\n")
291
+ .map((s) => s.trim())
292
+ .map((s, i) => (i === 0 ? s : `${" ".repeat(spaces)}${s}`))
293
+ .join("\n");
294
+ const emplaceBodySchema = (from) => (emplacer) => (meta) => {
295
+ if (!(meta === null || meta === void 0 ? void 0 : meta.content))
296
+ return null;
297
+ const entries = Object.entries(meta.content).filter(([_, v]) => !!v);
298
+ const json = entries.find((e) => meta["x-nestia-encrypted"] === true
299
+ ? e[0].includes("text/plain") || e[0].includes("application/json")
300
+ : e[0].includes("application/json") || e[0].includes("*/*"));
301
+ if (json) {
302
+ const { schema } = json[1];
303
+ return schema
304
+ ? {
305
+ type: "application/json",
306
+ name: "body",
307
+ key: "body",
308
+ schema: isNotObjectLiteral(schema) ? schema : emplacer(schema),
309
+ description: () => meta.description,
310
+ media: () => json[1],
311
+ "x-nestia-encrypted": meta["x-nestia-encrypted"],
312
+ }
313
+ : null;
314
+ }
315
+ const query = entries.find((e) => e[0].includes("application/x-www-form-urlencoded"));
316
+ if (query) {
317
+ const { schema } = query[1];
318
+ return schema
319
+ ? {
320
+ type: "application/x-www-form-urlencoded",
321
+ name: "body",
322
+ key: "body",
323
+ schema: isNotObjectLiteral(schema) ? schema : emplacer(schema),
324
+ description: () => meta.description,
325
+ media: () => query[1],
326
+ }
327
+ : null;
328
+ }
329
+ const text = entries.find((e) => e[0].includes("text/plain"));
330
+ if (text)
331
+ return {
332
+ type: "text/plain",
333
+ name: "body",
334
+ key: "body",
335
+ schema: { type: "string" },
336
+ description: () => meta.description,
337
+ media: () => text[1],
338
+ };
339
+ if (from === "request") {
340
+ const multipart = entries.find((e) => e[0].includes("multipart/form-data"));
341
+ if (multipart) {
342
+ const { schema } = multipart[1];
343
+ return {
344
+ type: "multipart/form-data",
345
+ name: "body",
346
+ key: "body",
347
+ schema: schema
348
+ ? isNotObjectLiteral(schema)
349
+ ? schema
350
+ : emplacer(schema)
351
+ : {},
352
+ description: () => meta.description,
353
+ media: () => multipart[1],
354
+ };
355
+ }
356
+ }
357
+ return false;
358
+ };
359
+ const emplaceReference = (props) => {
360
+ var _a;
361
+ var _b;
362
+ (_a = (_b = props.document.components).schemas) !== null && _a !== void 0 ? _a : (_b.schemas = {});
363
+ props.document.components.schemas[props.name] = props.schema;
364
+ return {
365
+ $ref: `#/components/schemas/${props.name}`,
366
+ };
367
+ };
368
+ const isNotObjectLiteral = (schema) => OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema) ||
369
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema) ||
370
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(schema) ||
371
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isString(schema) ||
372
+ OpenApiTypeChecker_1.OpenApiTypeChecker.isUnknown(schema) ||
373
+ (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema) &&
374
+ schema.oneOf.every(isNotObjectLiteral)) ||
375
+ (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(schema) && isNotObjectLiteral(schema.items));
376
+ })(HttpMigrateRouteComposer || (HttpMigrateRouteComposer_2 = HttpMigrateRouteComposer$1.HttpMigrateRouteComposer = HttpMigrateRouteComposer = {}));
7
377
 
8
- function requireHttpMigrateRouteComposer () {
9
- if (hasRequiredHttpMigrateRouteComposer) return HttpMigrateRouteComposer;
10
- hasRequiredHttpMigrateRouteComposer = 1;
11
- Object.defineProperty(HttpMigrateRouteComposer, "__esModule", { value: true });
12
- HttpMigrateRouteComposer.HttpMigrateRouteComposer = void 0;
13
- const NamingConvention_1 = requireNamingConvention();
14
- const EndpointUtil_1 = requireEndpointUtil();
15
- const OpenApiTypeChecker_1 = requireOpenApiTypeChecker();
16
- var HttpMigrateRouteComposer$1;
17
- (function (HttpMigrateRouteComposer) {
18
- HttpMigrateRouteComposer.compose = (props) => {
19
- var _a, _b, _c, _d, _e;
20
- //----
21
- // REQUEST AND RESPONSE BODY
22
- //----
23
- const body = emplaceBodySchema("request")((schema) => emplaceReference({
24
- document: props.document,
25
- name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
26
- "." +
27
- EndpointUtil_1.EndpointUtil.pascal(`${props.method}/Body`),
28
- schema,
29
- }))(props.operation.requestBody);
30
- const success = (() => {
31
- var _a, _b, _c, _d, _e;
32
- var _f, _g;
33
- const body = emplaceBodySchema("response")((schema) => emplaceReference({
34
- document: props.document,
35
- name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
36
- "." +
37
- EndpointUtil_1.EndpointUtil.pascal(`${props.method}/Response`),
38
- schema,
39
- }))((_g = (_f = (_a = props.operation.responses) === null || _a === void 0 ? void 0 : _a["201"]) !== null && _f !== void 0 ? _f : (_b = props.operation.responses) === null || _b === void 0 ? void 0 : _b["200"]) !== null && _g !== void 0 ? _g : (_c = props.operation.responses) === null || _c === void 0 ? void 0 : _c.default);
40
- return body
41
- ? Object.assign(Object.assign({}, body), { status: ((_d = props.operation.responses) === null || _d === void 0 ? void 0 : _d["201"])
42
- ? "201"
43
- : ((_e = props.operation.responses) === null || _e === void 0 ? void 0 : _e["200"])
44
- ? "200"
45
- : "default" }) : body;
46
- })();
47
- const failures = [];
48
- if (body === false)
49
- failures.push(`supports only "application/json", "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain" content type in the request body.`);
50
- if (success === false)
51
- failures.push(`supports only "application/json", "application/x-www-form-urlencoded" and "text/plain" content type in the response body.`);
52
- //----
53
- // HEADERS AND QUERY
54
- //---
55
- const [headers, query] = ["header", "query"].map((type) => {
56
- var _a, _b, _c, _d;
57
- // FIND TARGET PARAMETERS
58
- const parameters = ((_a = props.operation.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === type);
59
- if (parameters.length === 0)
60
- return null;
61
- // CHECK PARAMETER TYPES -> TO BE OBJECT
62
- const objects = parameters
63
- .map((p) => { var _a; var _b; return OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(p.schema)
64
- ? p.schema
65
- : OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(p.schema) &&
66
- OpenApiTypeChecker_1.OpenApiTypeChecker.isObject((_b = (_a = props.document.components.schemas) === null || _a === void 0 ? void 0 : _a[p.schema.$ref.replace(`#/components/schemas/`, ``)]) !== null && _b !== void 0 ? _b : {})
67
- ? p.schema
68
- : null; })
69
- .filter((s) => !!s);
70
- const primitives = parameters.filter((p) => OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(p.schema) ||
71
- OpenApiTypeChecker_1.OpenApiTypeChecker.isInteger(p.schema) ||
72
- OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(p.schema) ||
73
- OpenApiTypeChecker_1.OpenApiTypeChecker.isString(p.schema) ||
74
- OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(p.schema) ||
75
- OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(p.schema));
76
- const out = (elem) => (Object.assign(Object.assign({}, elem), { name: type, key: type, title: () => elem.title, description: () => elem.description, example: () => elem.example, examples: () => elem.examples }));
77
- if (objects.length === 1 && primitives.length === 0)
78
- return out(parameters[0]);
79
- else if (objects.length > 1) {
80
- failures.push(`${type} typed parameters must be only one object type`);
81
- return false;
82
- }
83
- // GATHER TO OBJECT TYPE
84
- const dto = objects[0]
85
- ? OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(objects[0])
86
- ? objects[0]
87
- : ((_b = props.document.components.schemas) !== null && _b !== void 0 ? _b : {})[objects[0].$ref.replace(`#/components/schemas/`, ``)]
88
- : null;
89
- const entire = [
90
- ...objects.map((o) => { var _a; return OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(o)
91
- ? o
92
- : (_a = props.document.components.schemas) === null || _a === void 0 ? void 0 : _a[o.$ref.replace(`#/components/schemas/`, ``)]; }),
93
- {
94
- type: "object",
95
- properties: Object.fromEntries([
96
- ...primitives.map((p) => { var _a; return [
97
- p.name,
98
- Object.assign(Object.assign({}, p.schema), { description: (_a = p.schema.description) !== null && _a !== void 0 ? _a : p.description }),
99
- ]; }),
100
- ...(dto ? Object.entries((_c = dto.properties) !== null && _c !== void 0 ? _c : {}) : []),
101
- ]),
102
- required: [
103
- ...new Set([
104
- ...primitives.filter((p) => p.required).map((p) => p.name),
105
- ...((_d = dto === null || dto === void 0 ? void 0 : dto.required) !== null && _d !== void 0 ? _d : []),
106
- ]),
107
- ],
108
- },
109
- ];
110
- return parameters.length === 0
111
- ? null
112
- : out({
113
- schema: emplaceReference({
114
- document: props.document,
115
- name: EndpointUtil_1.EndpointUtil.pascal(`I/Api/${props.path}`) +
116
- "." +
117
- EndpointUtil_1.EndpointUtil.pascal(`${props.method}/${type}`),
118
- schema: {
119
- type: "object",
120
- properties: Object.fromEntries([
121
- ...new Map(entire
122
- .map((o) => { var _a; return Object.entries((_a = o.properties) !== null && _a !== void 0 ? _a : {}).map(([name, schema]) => { var _a; return [
123
- name,
124
- Object.assign(Object.assign({}, schema), { description: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.description }),
125
- ]; }); })
126
- .flat()),
127
- ]),
128
- required: [
129
- ...new Set(entire.map((o) => { var _a; return (_a = o.required) !== null && _a !== void 0 ? _a : []; }).flat()),
130
- ],
131
- },
132
- }),
133
- });
134
- });
135
- //----
136
- // PATH PARAMETERS
137
- //----
138
- const parameterNames = EndpointUtil_1.EndpointUtil.splitWithNormalization(props.emendedPath)
139
- .filter((str) => str[0] === ":")
140
- .map((str) => str.substring(1));
141
- const pathParameters = ((_a = props.operation.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === "path");
142
- if (parameterNames.length !== pathParameters.length)
143
- if (pathParameters.length < parameterNames.length &&
144
- pathParameters.every((p) => p.name !== undefined && parameterNames.includes(p.name))) {
145
- for (const name of parameterNames)
146
- if (pathParameters.find((p) => p.name === name) === undefined)
147
- pathParameters.push({
148
- name,
149
- in: "path",
150
- schema: { type: "string" },
151
- });
152
- pathParameters.sort((a, b) => parameterNames.indexOf(a.name) - parameterNames.indexOf(b.name));
153
- props.operation.parameters = [
154
- ...pathParameters,
155
- ...((_b = props.operation.parameters) !== null && _b !== void 0 ? _b : []).filter((p) => p.in !== "path"),
156
- ];
157
- }
158
- else
159
- failures.push("number of path parameters are not matched with its full path.");
160
- if (failures.length)
161
- return failures;
162
- const parameters = ((_c = props.operation.parameters) !== null && _c !== void 0 ? _c : [])
163
- .filter((p) => p.in === "path")
164
- .map((p, i) => ({
165
- // FILL KEY NAME IF NOT EXISTS
166
- name: parameterNames[i],
167
- key: (() => {
168
- let key = EndpointUtil_1.EndpointUtil.normalize(parameterNames[i]);
169
- if (NamingConvention_1.NamingConvention.variable(key))
170
- return key;
171
- while (true) {
172
- key = "_" + key;
173
- if (!parameterNames.some((s) => s === key))
174
- return key;
175
- }
176
- })(),
177
- schema: p.schema,
178
- parameter: () => p,
179
- }));
180
- return {
181
- method: props.method,
182
- path: props.path,
183
- emendedPath: props.emendedPath,
184
- accessor: ["@lazy"],
185
- parameters: ((_d = props.operation.parameters) !== null && _d !== void 0 ? _d : [])
186
- .filter((p) => p.in === "path")
187
- .map((p, i) => ({
188
- // FILL KEY NAME IF NOT EXISTS
189
- name: parameterNames[i],
190
- key: (() => {
191
- let key = EndpointUtil_1.EndpointUtil.normalize(parameterNames[i]);
192
- if (NamingConvention_1.NamingConvention.variable(key))
193
- return key;
194
- while (true) {
195
- key = "_" + key;
196
- if (!parameterNames.some((s) => s === key))
197
- return key;
198
- }
199
- })(),
200
- schema: p.schema,
201
- parameter: () => p,
202
- })),
203
- headers: headers || null,
204
- query: query || null,
205
- body: body || null,
206
- success: success || null,
207
- exceptions: Object.fromEntries(Object.entries((_e = props.operation.responses) !== null && _e !== void 0 ? _e : {})
208
- .filter(([key]) => key !== "200" && key !== "201" && key !== "default")
209
- .map(([status, response]) => { var _a, _b; var _c; return [
210
- status,
211
- {
212
- schema: ((_c = (_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) === null || _b === void 0 ? void 0 : _b.schema) !== null && _c !== void 0 ? _c : {}),
213
- response: () => response,
214
- media: () => { var _a; var _b; return ((_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) !== null && _b !== void 0 ? _b : {}); },
215
- },
216
- ]; })),
217
- comment: () => writeRouteComment({
218
- operation: props.operation,
219
- parameters,
220
- body: body || null,
221
- }),
222
- operation: () => props.operation,
223
- };
224
- };
225
- const writeRouteComment = (props) => {
226
- var _a, _b, _c;
227
- var _d, _e, _f;
228
- // write basic description combining with summary
229
- let description = (_d = props.operation.description) !== null && _d !== void 0 ? _d : "";
230
- if (!!((_a = props.operation.summary) === null || _a === void 0 ? void 0 : _a.length)) {
231
- const summary = props.operation.summary.endsWith(".")
232
- ? props.operation.summary
233
- : props.operation.summary + ".";
234
- if (!!description.length &&
235
- !description.startsWith(props.operation.summary))
236
- description = `${summary}\n\n${description}`;
237
- }
238
- description = description
239
- .split("\n")
240
- .map((s) => s.trim())
241
- .join("\n");
242
- //----
243
- // compose jsdoc comment tags
244
- //----
245
- const commentTags = [];
246
- const add = (text) => {
247
- if (commentTags.every((line) => line !== text))
248
- commentTags.push(text);
249
- };
250
- // parameters
251
- add("@param connection");
252
- for (const p of (_e = props.parameters) !== null && _e !== void 0 ? _e : []) {
253
- const param = p.parameter();
254
- if (param.description) {
255
- const text = param.description;
256
- add(`@param ${p.name} ${writeIndented(text, p.name.length + 8)}`);
257
- }
258
- }
259
- if ((_c = (_b = props.body) === null || _b === void 0 ? void 0 : _b.description()) === null || _c === void 0 ? void 0 : _c.length)
260
- add(`@param body ${writeIndented(props.body.description(), 12)}`);
261
- // security
262
- for (const security of (_f = props.operation.security) !== null && _f !== void 0 ? _f : [])
263
- for (const [name, scopes] of Object.entries(security))
264
- add(`@security ${[name, ...scopes].join("")}`);
265
- // categorizing tags
266
- if (props.operation.tags)
267
- props.operation.tags.forEach((name) => add(`@tag ${name}`));
268
- // deprecated
269
- if (props.operation.deprecated)
270
- add("@deprecated");
271
- // plugin properties
272
- for (const [key, value] of Object.entries(props.operation)) {
273
- if (key.startsWith("x-") === false)
274
- continue;
275
- else if (value !== null &&
276
- typeof value !== "boolean" &&
277
- typeof value !== "number" &&
278
- typeof value !== "string")
279
- continue;
280
- add(`@${key} ${value}`);
281
- }
282
- // finalize description
283
- description = description.length
284
- ? commentTags.length
285
- ? `${description}\n\n${commentTags.join("\n")}`
286
- : description
287
- : commentTags.join("\n");
288
- description = description.split("*/").join("*\\/");
289
- return description;
290
- };
291
- const writeIndented = (text, spaces) => text
292
- .split("\n")
293
- .map((s) => s.trim())
294
- .map((s, i) => (i === 0 ? s : `${" ".repeat(spaces)}${s}`))
295
- .join("\n");
296
- const emplaceBodySchema = (from) => (emplacer) => (meta) => {
297
- if (!(meta === null || meta === void 0 ? void 0 : meta.content))
298
- return null;
299
- const entries = Object.entries(meta.content).filter(([_, v]) => !!v);
300
- const json = entries.find((e) => meta["x-nestia-encrypted"] === true
301
- ? e[0].includes("text/plain") || e[0].includes("application/json")
302
- : e[0].includes("application/json") || e[0].includes("*/*"));
303
- if (json) {
304
- const { schema } = json[1];
305
- return schema
306
- ? {
307
- type: "application/json",
308
- name: "body",
309
- key: "body",
310
- schema: isNotObjectLiteral(schema) ? schema : emplacer(schema),
311
- description: () => meta.description,
312
- media: () => json[1],
313
- "x-nestia-encrypted": meta["x-nestia-encrypted"],
314
- }
315
- : null;
316
- }
317
- const query = entries.find((e) => e[0].includes("application/x-www-form-urlencoded"));
318
- if (query) {
319
- const { schema } = query[1];
320
- return schema
321
- ? {
322
- type: "application/x-www-form-urlencoded",
323
- name: "body",
324
- key: "body",
325
- schema: isNotObjectLiteral(schema) ? schema : emplacer(schema),
326
- description: () => meta.description,
327
- media: () => query[1],
328
- }
329
- : null;
330
- }
331
- const text = entries.find((e) => e[0].includes("text/plain"));
332
- if (text)
333
- return {
334
- type: "text/plain",
335
- name: "body",
336
- key: "body",
337
- schema: { type: "string" },
338
- description: () => meta.description,
339
- media: () => text[1],
340
- };
341
- if (from === "request") {
342
- const multipart = entries.find((e) => e[0].includes("multipart/form-data"));
343
- if (multipart) {
344
- const { schema } = multipart[1];
345
- return {
346
- type: "multipart/form-data",
347
- name: "body",
348
- key: "body",
349
- schema: schema
350
- ? isNotObjectLiteral(schema)
351
- ? schema
352
- : emplacer(schema)
353
- : {},
354
- description: () => meta.description,
355
- media: () => multipart[1],
356
- };
357
- }
358
- }
359
- return false;
360
- };
361
- const emplaceReference = (props) => {
362
- var _a;
363
- var _b;
364
- (_a = (_b = props.document.components).schemas) !== null && _a !== void 0 ? _a : (_b.schemas = {});
365
- props.document.components.schemas[props.name] = props.schema;
366
- return {
367
- $ref: `#/components/schemas/${props.name}`,
368
- };
369
- };
370
- const isNotObjectLiteral = (schema) => OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema) ||
371
- OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema) ||
372
- OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(schema) ||
373
- OpenApiTypeChecker_1.OpenApiTypeChecker.isString(schema) ||
374
- OpenApiTypeChecker_1.OpenApiTypeChecker.isUnknown(schema) ||
375
- (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema) &&
376
- schema.oneOf.every(isNotObjectLiteral)) ||
377
- (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(schema) && isNotObjectLiteral(schema.items));
378
- })(HttpMigrateRouteComposer$1 || (HttpMigrateRouteComposer.HttpMigrateRouteComposer = HttpMigrateRouteComposer$1 = {}));
379
-
380
- return HttpMigrateRouteComposer;
381
- }
382
-
383
- export { requireHttpMigrateRouteComposer as __require };
378
+ export { HttpMigrateRouteComposer_2 as HttpMigrateRouteComposer, HttpMigrateRouteComposer$1 as default };
384
379
  //# sourceMappingURL=HttpMigrateRouteComposer2.mjs.map