keq 2.8.13 → 2.9.0

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 (842) hide show
  1. package/.claude/settings.local.json +26 -0
  2. package/CHANGELOG.md +14 -0
  3. package/dist/esm/src/create-request.js +2 -0
  4. package/dist/esm/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
  5. package/dist/esm/src/middlewares/mutex-flow-control-middleware.js +22 -0
  6. package/dist/esm/src/types/keq-flow-control.d.ts +1 -1
  7. package/dist/esm/src/types/keq-global.d.ts +1 -0
  8. package/dist/esm/src/util/create-response-proxy.js +2 -2
  9. package/dist/esm/src/util/fork.js +3 -3
  10. package/dist/umd/src/create-request.js +3 -1
  11. package/dist/umd/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
  12. package/dist/umd/src/middlewares/mutex-flow-control-middleware.js +36 -0
  13. package/dist/umd/src/types/keq-flow-control.d.ts +1 -1
  14. package/dist/umd/src/types/keq-global.d.ts +1 -0
  15. package/dist/umd/src/util/create-response-proxy.js +2 -2
  16. package/dist/umd/src/util/fork.js +3 -3
  17. package/package.json +1 -1
  18. package/packages/cache/.turbo/turbo-build.log +26 -16
  19. package/packages/cache/dist/index.d.mts +354 -0
  20. package/packages/cache/dist/index.d.mts.map +1 -0
  21. package/packages/cache/dist/index.d.ts +352 -5
  22. package/packages/cache/dist/index.d.ts.map +1 -1
  23. package/packages/cache/dist/index.js +1211 -1256
  24. package/packages/cache/dist/index.js.map +1 -1
  25. package/packages/cache/dist/index.mjs +1183 -1231
  26. package/packages/cache/dist/index.mjs.map +1 -1
  27. package/packages/cli/.turbo/turbo-build.log +88 -24
  28. package/packages/cli/dist/cli.cjs +1333 -2891
  29. package/packages/cli/dist/cli.cjs.map +1 -1
  30. package/packages/cli/dist/cli.d.cts +1 -0
  31. package/packages/cli/dist/cli.d.mts +1 -0
  32. package/packages/cli/dist/cli.mjs +1359 -0
  33. package/packages/cli/dist/cli.mjs.map +1 -0
  34. package/packages/cli/dist/compiler-0Kli6UCr.cjs +738 -0
  35. package/packages/cli/dist/compiler-0Kli6UCr.cjs.map +1 -0
  36. package/packages/cli/dist/compiler-C3AE8j54.mjs +715 -0
  37. package/packages/cli/dist/compiler-C3AE8j54.mjs.map +1 -0
  38. package/packages/cli/dist/index.cjs +18 -2853
  39. package/packages/cli/dist/index.cjs.map +1 -1
  40. package/packages/cli/dist/index.d.cts +17 -0
  41. package/packages/cli/dist/index.d.cts.map +1 -0
  42. package/packages/cli/dist/index.d.mts +17 -0
  43. package/packages/cli/dist/index.d.mts.map +1 -0
  44. package/packages/cli/dist/index.mjs +10 -0
  45. package/packages/cli/dist/index.mjs.map +1 -0
  46. package/packages/cli/dist/init-BNhD2oCI.mjs +168 -0
  47. package/packages/cli/dist/init-BNhD2oCI.mjs.map +1 -0
  48. package/packages/cli/dist/init-DqxLcRSQ.cjs +170 -0
  49. package/packages/cli/dist/init-DqxLcRSQ.cjs.map +1 -0
  50. package/packages/cli/dist/logger-D7PyVZo3.cjs +46 -0
  51. package/packages/cli/dist/logger-D7PyVZo3.cjs.map +1 -0
  52. package/packages/cli/dist/logger-QLBHySQ3.mjs +12 -0
  53. package/packages/cli/dist/logger-QLBHySQ3.mjs.map +1 -0
  54. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs +16 -0
  55. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs.map +1 -0
  56. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs +11 -0
  57. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs.map +1 -0
  58. package/packages/cli/dist/mock-command-Bp1LxSls.mjs +350 -0
  59. package/packages/cli/dist/mock-command-Bp1LxSls.mjs.map +1 -0
  60. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs +353 -0
  61. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs.map +1 -0
  62. package/packages/cli/dist/plugins-CgMhaNZq.cjs +3558 -0
  63. package/packages/cli/dist/plugins-CgMhaNZq.cjs.map +1 -0
  64. package/packages/cli/dist/plugins-DCvJ8iHR.mjs +3280 -0
  65. package/packages/cli/dist/plugins-DCvJ8iHR.mjs.map +1 -0
  66. package/packages/cli/dist/plugins.cjs +36 -2425
  67. package/packages/cli/dist/plugins.d.cts +2 -0
  68. package/packages/cli/dist/plugins.d.mts +2 -0
  69. package/packages/cli/dist/plugins.mjs +2 -0
  70. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts +780 -0
  71. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts.map +1 -0
  72. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts +780 -0
  73. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts.map +1 -0
  74. package/packages/cli/dist/translators.cjs +14 -0
  75. package/packages/cli/dist/translators.cjs.map +1 -0
  76. package/packages/cli/dist/translators.d.cts +14 -0
  77. package/packages/cli/dist/translators.d.cts.map +1 -0
  78. package/packages/cli/dist/translators.d.mts +14 -0
  79. package/packages/cli/dist/translators.d.mts.map +1 -0
  80. package/packages/cli/dist/translators.mjs +12 -0
  81. package/packages/cli/dist/translators.mjs.map +1 -0
  82. package/packages/cli/node_modules/.bin/eslint +2 -2
  83. package/packages/cli/node_modules/.bin/jiti +2 -2
  84. package/packages/cli/node_modules/.bin/js-yaml +2 -2
  85. package/packages/cli/node_modules/.bin/jsf +21 -0
  86. package/packages/cli/node_modules/.bin/jsonpath +2 -2
  87. package/packages/cli/node_modules/.bin/jsonpath-plus +2 -2
  88. package/packages/cli/node_modules/.bin/semver +2 -2
  89. package/packages/cli/node_modules/.bin/tsc +4 -4
  90. package/packages/cli/node_modules/.bin/tsserver +4 -4
  91. package/packages/exception/.turbo/turbo-build.log +26 -31
  92. package/packages/exception/dist/index.d.mts +21 -0
  93. package/packages/exception/dist/index.d.mts.map +1 -0
  94. package/packages/exception/dist/index.d.ts +21 -0
  95. package/packages/exception/dist/index.d.ts.map +1 -0
  96. package/packages/exception/dist/index.js +97 -105
  97. package/packages/exception/dist/index.js.map +1 -1
  98. package/packages/exception/dist/index.mjs +92 -104
  99. package/packages/exception/dist/index.mjs.map +1 -1
  100. package/packages/headers/.turbo/turbo-build.log +26 -16
  101. package/packages/headers/dist/index.d.mts +46 -0
  102. package/packages/headers/dist/index.d.mts.map +1 -0
  103. package/packages/headers/dist/index.d.ts +46 -0
  104. package/packages/headers/dist/index.d.ts.map +1 -0
  105. package/packages/headers/dist/index.js +68 -64
  106. package/packages/headers/dist/index.js.map +1 -1
  107. package/packages/headers/dist/index.mjs +62 -43
  108. package/packages/headers/dist/index.mjs.map +1 -1
  109. package/packages/keq/.turbo/turbo-build.log +26 -16
  110. package/packages/keq/dist/index.d.mts +962 -0
  111. package/packages/keq/dist/index.d.mts.map +1 -0
  112. package/packages/keq/dist/index.d.ts +961 -7
  113. package/packages/keq/dist/index.d.ts.map +1 -1
  114. package/packages/keq/dist/index.js +1727 -1830
  115. package/packages/keq/dist/index.js.map +1 -1
  116. package/packages/keq/dist/index.mjs +1671 -1805
  117. package/packages/keq/dist/index.mjs.map +1 -1
  118. package/packages/nestjs/.turbo/turbo-build.log +26 -16
  119. package/packages/nestjs/dist/index.d.mts +52 -0
  120. package/packages/nestjs/dist/index.d.mts.map +1 -0
  121. package/packages/nestjs/dist/index.d.ts +51 -2
  122. package/packages/nestjs/dist/index.d.ts.map +1 -1
  123. package/packages/nestjs/dist/index.js +156 -60
  124. package/packages/nestjs/dist/index.js.map +1 -1
  125. package/packages/nestjs/dist/index.mjs +133 -42
  126. package/packages/nestjs/dist/index.mjs.map +1 -1
  127. package/packages/test/.turbo/turbo-build.log +1 -1
  128. package/packages/url/.turbo/turbo-build.log +26 -16
  129. package/packages/url/dist/index.d.mts +9 -0
  130. package/packages/url/dist/index.d.mts.map +1 -0
  131. package/packages/url/dist/index.d.ts +9 -0
  132. package/packages/url/dist/index.d.ts.map +1 -0
  133. package/packages/url/dist/index.js +36 -60
  134. package/packages/url/dist/index.js.map +1 -1
  135. package/packages/url/dist/index.mjs +33 -39
  136. package/packages/url/dist/index.mjs.map +1 -1
  137. package/packages/cache/dist/cache-entry/cache-entry.d.ts +0 -17
  138. package/packages/cache/dist/cache-entry/cache-entry.d.ts.map +0 -1
  139. package/packages/cache/dist/cache-entry/index.d.ts +0 -4
  140. package/packages/cache/dist/cache-entry/index.d.ts.map +0 -1
  141. package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts +0 -8
  142. package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts.map +0 -1
  143. package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts +0 -7
  144. package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts.map +0 -1
  145. package/packages/cache/dist/cache.d.ts +0 -38
  146. package/packages/cache/dist/cache.d.ts.map +0 -1
  147. package/packages/cache/dist/constants/eviction.enum.d.ts +0 -7
  148. package/packages/cache/dist/constants/eviction.enum.d.ts.map +0 -1
  149. package/packages/cache/dist/constants/index.d.ts +0 -5
  150. package/packages/cache/dist/constants/index.d.ts.map +0 -1
  151. package/packages/cache/dist/constants/max-expired-at.d.ts +0 -2
  152. package/packages/cache/dist/constants/max-expired-at.d.ts.map +0 -1
  153. package/packages/cache/dist/constants/size.enum.d.ts +0 -7
  154. package/packages/cache/dist/constants/size.enum.d.ts.map +0 -1
  155. package/packages/cache/dist/constants/strategy.enum.d.ts +0 -7
  156. package/packages/cache/dist/constants/strategy.enum.d.ts.map +0 -1
  157. package/packages/cache/dist/exceptions/cache-exception.d.ts +0 -5
  158. package/packages/cache/dist/exceptions/cache-exception.d.ts.map +0 -1
  159. package/packages/cache/dist/exceptions/index.d.ts +0 -2
  160. package/packages/cache/dist/exceptions/index.d.ts.map +0 -1
  161. package/packages/cache/dist/request-cache-handler/index.d.ts +0 -2
  162. package/packages/cache/dist/request-cache-handler/index.d.ts.map +0 -1
  163. package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts +0 -23
  164. package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts.map +0 -1
  165. package/packages/cache/dist/storage/index.d.ts +0 -6
  166. package/packages/cache/dist/storage/index.d.ts.map +0 -1
  167. package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts +0 -22
  168. package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts.map +0 -1
  169. package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts +0 -2
  170. package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts.map +0 -1
  171. package/packages/cache/dist/storage/indexed-db-storage/index.d.ts +0 -3
  172. package/packages/cache/dist/storage/indexed-db-storage/index.d.ts.map +0 -1
  173. package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts +0 -12
  174. package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts.map +0 -1
  175. package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts +0 -11
  176. package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts.map +0 -1
  177. package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts +0 -11
  178. package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts.map +0 -1
  179. package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts +0 -11
  180. package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts.map +0 -1
  181. package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts +0 -11
  182. package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts.map +0 -1
  183. package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts +0 -7
  184. package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts.map +0 -1
  185. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts +0 -12
  186. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts.map +0 -1
  187. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts +0 -8
  188. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts.map +0 -1
  189. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts +0 -14
  190. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts.map +0 -1
  191. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts +0 -29
  192. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts.map +0 -1
  193. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts +0 -14
  194. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts.map +0 -1
  195. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts +0 -13
  196. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts.map +0 -1
  197. package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts +0 -16
  198. package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts.map +0 -1
  199. package/packages/cache/dist/storage/internal-storage/types/events.d.ts +0 -16
  200. package/packages/cache/dist/storage/internal-storage/types/events.d.ts.map +0 -1
  201. package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts +0 -20
  202. package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts.map +0 -1
  203. package/packages/cache/dist/storage/keq-cache-storage.d.ts +0 -20
  204. package/packages/cache/dist/storage/keq-cache-storage.d.ts.map +0 -1
  205. package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts +0 -31
  206. package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts.map +0 -1
  207. package/packages/cache/dist/storage/memory-storage/index.d.ts +0 -3
  208. package/packages/cache/dist/storage/memory-storage/index.d.ts.map +0 -1
  209. package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts +0 -11
  210. package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts.map +0 -1
  211. package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts +0 -11
  212. package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts.map +0 -1
  213. package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts +0 -13
  214. package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts.map +0 -1
  215. package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts +0 -11
  216. package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts.map +0 -1
  217. package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts +0 -11
  218. package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts.map +0 -1
  219. package/packages/cache/dist/storage/memory-storage/types/index.d.ts +0 -3
  220. package/packages/cache/dist/storage/memory-storage/types/index.d.ts.map +0 -1
  221. package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts +0 -9
  222. package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts.map +0 -1
  223. package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts +0 -13
  224. package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts.map +0 -1
  225. package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts +0 -6
  226. package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts.map +0 -1
  227. package/packages/cache/dist/storage/memory-storage/utils/index.d.ts +0 -3
  228. package/packages/cache/dist/storage/memory-storage/utils/index.d.ts.map +0 -1
  229. package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts +0 -6
  230. package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts.map +0 -1
  231. package/packages/cache/dist/storage/multi-tier-storage/index.d.ts +0 -3
  232. package/packages/cache/dist/storage/multi-tier-storage/index.d.ts.map +0 -1
  233. package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts +0 -36
  234. package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts.map +0 -1
  235. package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts +0 -2
  236. package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts.map +0 -1
  237. package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts +0 -5
  238. package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts.map +0 -1
  239. package/packages/cache/dist/storage/tier-storage/index.d.ts +0 -3
  240. package/packages/cache/dist/storage/tier-storage/index.d.ts.map +0 -1
  241. package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts +0 -15
  242. package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts.map +0 -1
  243. package/packages/cache/dist/storage/tier-storage/types/index.d.ts +0 -2
  244. package/packages/cache/dist/storage/tier-storage/types/index.d.ts.map +0 -1
  245. package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts +0 -21
  246. package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts.map +0 -1
  247. package/packages/cache/dist/strategies/cache-first.d.ts +0 -3
  248. package/packages/cache/dist/strategies/cache-first.d.ts.map +0 -1
  249. package/packages/cache/dist/strategies/index.d.ts +0 -5
  250. package/packages/cache/dist/strategies/index.d.ts.map +0 -1
  251. package/packages/cache/dist/strategies/network-first.d.ts +0 -3
  252. package/packages/cache/dist/strategies/network-first.d.ts.map +0 -1
  253. package/packages/cache/dist/strategies/network-only.d.ts +0 -3
  254. package/packages/cache/dist/strategies/network-only.d.ts.map +0 -1
  255. package/packages/cache/dist/strategies/stale-while-revalidate.d.ts +0 -3
  256. package/packages/cache/dist/strategies/stale-while-revalidate.d.ts.map +0 -1
  257. package/packages/cache/dist/types/index.d.ts +0 -6
  258. package/packages/cache/dist/types/index.d.ts.map +0 -1
  259. package/packages/cache/dist/types/keq-cache-key.d.ts +0 -4
  260. package/packages/cache/dist/types/keq-cache-key.d.ts.map +0 -1
  261. package/packages/cache/dist/types/keq-cache-pattern.d.ts +0 -3
  262. package/packages/cache/dist/types/keq-cache-pattern.d.ts.map +0 -1
  263. package/packages/cache/dist/types/keq-cache-rule.d.ts +0 -6
  264. package/packages/cache/dist/types/keq-cache-rule.d.ts.map +0 -1
  265. package/packages/cache/dist/types/keq-cache-strategy.d.ts +0 -6
  266. package/packages/cache/dist/types/keq-cache-strategy.d.ts.map +0 -1
  267. package/packages/cache/dist/types/request-cache-options.d.ts +0 -34
  268. package/packages/cache/dist/types/request-cache-options.d.ts.map +0 -1
  269. package/packages/cache/dist/utils/get-response-bytes.d.ts +0 -2
  270. package/packages/cache/dist/utils/get-response-bytes.d.ts.map +0 -1
  271. package/packages/cache/dist/utils/index.d.ts +0 -4
  272. package/packages/cache/dist/utils/index.d.ts.map +0 -1
  273. package/packages/cache/dist/utils/logger.d.ts +0 -5
  274. package/packages/cache/dist/utils/logger.d.ts.map +0 -1
  275. package/packages/cache/dist/utils/random.d.ts +0 -2
  276. package/packages/cache/dist/utils/random.d.ts.map +0 -1
  277. package/packages/cli/dist/cli.d.ts +0 -3
  278. package/packages/cli/dist/cli.d.ts.map +0 -1
  279. package/packages/cli/dist/cli.js +0 -2899
  280. package/packages/cli/dist/cli.js.map +0 -1
  281. package/packages/cli/dist/compiler/compiler.d.ts +0 -17
  282. package/packages/cli/dist/compiler/compiler.d.ts.map +0 -1
  283. package/packages/cli/dist/compiler/index.d.ts +0 -4
  284. package/packages/cli/dist/compiler/index.d.ts.map +0 -1
  285. package/packages/cli/dist/compiler/intercepter/index.d.ts +0 -3
  286. package/packages/cli/dist/compiler/intercepter/index.d.ts.map +0 -1
  287. package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts +0 -3
  288. package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts.map +0 -1
  289. package/packages/cli/dist/compiler/intercepter/print-information.d.ts +0 -5
  290. package/packages/cli/dist/compiler/intercepter/print-information.d.ts.map +0 -1
  291. package/packages/cli/dist/compiler/tasks/compile/index.d.ts +0 -6
  292. package/packages/cli/dist/compiler/tasks/compile/index.d.ts.map +0 -1
  293. package/packages/cli/dist/compiler/tasks/download/index.d.ts +0 -10
  294. package/packages/cli/dist/compiler/tasks/download/index.d.ts.map +0 -1
  295. package/packages/cli/dist/compiler/tasks/index.d.ts +0 -6
  296. package/packages/cli/dist/compiler/tasks/index.d.ts.map +0 -1
  297. package/packages/cli/dist/compiler/tasks/persist/index.d.ts +0 -5
  298. package/packages/cli/dist/compiler/tasks/persist/index.d.ts.map +0 -1
  299. package/packages/cli/dist/compiler/tasks/setup/index.d.ts +0 -15
  300. package/packages/cli/dist/compiler/tasks/setup/index.d.ts.map +0 -1
  301. package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts +0 -6
  302. package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts.map +0 -1
  303. package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts +0 -5
  304. package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts.map +0 -1
  305. package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts +0 -4
  306. package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts.map +0 -1
  307. package/packages/cli/dist/compiler/tasks/setup/utils/validate-modules.d.ts +0 -2
  308. package/packages/cli/dist/compiler/tasks/setup/utils/validate-modules.d.ts.map +0 -1
  309. package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts +0 -6
  310. package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts.map +0 -1
  311. package/packages/cli/dist/compiler/tasks/types/index.d.ts +0 -3
  312. package/packages/cli/dist/compiler/tasks/types/index.d.ts.map +0 -1
  313. package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts +0 -4
  314. package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts.map +0 -1
  315. package/packages/cli/dist/compiler/types/compiler-context.d.ts +0 -11
  316. package/packages/cli/dist/compiler/types/compiler-context.d.ts.map +0 -1
  317. package/packages/cli/dist/compiler/types/compiler-hooks.d.ts +0 -18
  318. package/packages/cli/dist/compiler/types/compiler-hooks.d.ts.map +0 -1
  319. package/packages/cli/dist/compiler/types/index.d.ts +0 -3
  320. package/packages/cli/dist/compiler/types/index.d.ts.map +0 -1
  321. package/packages/cli/dist/constants/file-naming-style.d.ts +0 -14
  322. package/packages/cli/dist/constants/file-naming-style.d.ts.map +0 -1
  323. package/packages/cli/dist/constants/index.d.ts +0 -4
  324. package/packages/cli/dist/constants/index.d.ts.map +0 -1
  325. package/packages/cli/dist/constants/qs-array-format.d.ts +0 -9
  326. package/packages/cli/dist/constants/qs-array-format.d.ts.map +0 -1
  327. package/packages/cli/dist/constants/supported-methods.d.ts +0 -2
  328. package/packages/cli/dist/constants/supported-methods.d.ts.map +0 -1
  329. package/packages/cli/dist/define-keq-config.d.ts +0 -3
  330. package/packages/cli/dist/define-keq-config.d.ts.map +0 -1
  331. package/packages/cli/dist/exception.d.ts +0 -6
  332. package/packages/cli/dist/exception.d.ts.map +0 -1
  333. package/packages/cli/dist/generators/index.d.ts +0 -2
  334. package/packages/cli/dist/generators/index.d.ts.map +0 -1
  335. package/packages/cli/dist/index.d.ts +0 -6
  336. package/packages/cli/dist/index.d.ts.map +0 -1
  337. package/packages/cli/dist/index.js +0 -2808
  338. package/packages/cli/dist/index.js.map +0 -1
  339. package/packages/cli/dist/models/anchor.d.ts +0 -20
  340. package/packages/cli/dist/models/anchor.d.ts.map +0 -1
  341. package/packages/cli/dist/models/api-document_v3_1.d.ts +0 -16
  342. package/packages/cli/dist/models/api-document_v3_1.d.ts.map +0 -1
  343. package/packages/cli/dist/models/artifact.d.ts +0 -17
  344. package/packages/cli/dist/models/artifact.d.ts.map +0 -1
  345. package/packages/cli/dist/models/asset.d.ts +0 -5
  346. package/packages/cli/dist/models/asset.d.ts.map +0 -1
  347. package/packages/cli/dist/models/index.d.ts +0 -8
  348. package/packages/cli/dist/models/index.d.ts.map +0 -1
  349. package/packages/cli/dist/models/module-definition.d.ts +0 -7
  350. package/packages/cli/dist/models/module-definition.d.ts.map +0 -1
  351. package/packages/cli/dist/models/operation-definition.d.ts +0 -23
  352. package/packages/cli/dist/models/operation-definition.d.ts.map +0 -1
  353. package/packages/cli/dist/models/schema-definition.d.ts +0 -20
  354. package/packages/cli/dist/models/schema-definition.d.ts.map +0 -1
  355. package/packages/cli/dist/models/utils/to-comment.d.ts +0 -2
  356. package/packages/cli/dist/models/utils/to-comment.d.ts.map +0 -1
  357. package/packages/cli/dist/plugins/body-fallback/index.d.ts +0 -6
  358. package/packages/cli/dist/plugins/body-fallback/index.d.ts.map +0 -1
  359. package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts +0 -5
  360. package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts.map +0 -1
  361. package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts +0 -2
  362. package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts.map +0 -1
  363. package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts +0 -8
  364. package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +0 -1
  365. package/packages/cli/dist/plugins/download-http-file/index.d.ts +0 -2
  366. package/packages/cli/dist/plugins/download-http-file/index.d.ts.map +0 -1
  367. package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts +0 -6
  368. package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +0 -1
  369. package/packages/cli/dist/plugins/download-local-file/index.d.ts +0 -2
  370. package/packages/cli/dist/plugins/download-local-file/index.d.ts.map +0 -1
  371. package/packages/cli/dist/plugins/eslint/index.d.ts +0 -15
  372. package/packages/cli/dist/plugins/eslint/index.d.ts.map +0 -1
  373. package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts +0 -2
  374. package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts.map +0 -1
  375. package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts +0 -12
  376. package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts.map +0 -1
  377. package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts +0 -15
  378. package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts.map +0 -1
  379. package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts +0 -3
  380. package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts.map +0 -1
  381. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts +0 -2
  382. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts.map +0 -1
  383. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts +0 -15
  384. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts.map +0 -1
  385. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts +0 -2
  386. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts.map +0 -1
  387. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts +0 -15
  388. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts.map +0 -1
  389. package/packages/cli/dist/plugins/generate-declaration/index.d.ts +0 -3
  390. package/packages/cli/dist/plugins/generate-declaration/index.d.ts.map +0 -1
  391. package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts +0 -2
  392. package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts.map +0 -1
  393. package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts +0 -11
  394. package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts.map +0 -1
  395. package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts +0 -11
  396. package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts.map +0 -1
  397. package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts +0 -3
  398. package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts.map +0 -1
  399. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts +0 -2
  400. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts.map +0 -1
  401. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts +0 -15
  402. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts.map +0 -1
  403. package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts +0 -2
  404. package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts.map +0 -1
  405. package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts +0 -11
  406. package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts.map +0 -1
  407. package/packages/cli/dist/plugins/generate-micro-function/index.d.ts +0 -3
  408. package/packages/cli/dist/plugins/generate-micro-function/index.d.ts.map +0 -1
  409. package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts +0 -2
  410. package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts.map +0 -1
  411. package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts +0 -10
  412. package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts.map +0 -1
  413. package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts +0 -10
  414. package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts.map +0 -1
  415. package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts +0 -2
  416. package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts.map +0 -1
  417. package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts +0 -14
  418. package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts.map +0 -1
  419. package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts +0 -3
  420. package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts.map +0 -1
  421. package/packages/cli/dist/plugins/index.d.ts +0 -15
  422. package/packages/cli/dist/plugins/index.d.ts.map +0 -1
  423. package/packages/cli/dist/plugins/initialize/index.d.ts +0 -2
  424. package/packages/cli/dist/plugins/initialize/index.d.ts.map +0 -1
  425. package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts +0 -15
  426. package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts.map +0 -1
  427. package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts +0 -2
  428. package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts.map +0 -1
  429. package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts +0 -20
  430. package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts.map +0 -1
  431. package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts +0 -2
  432. package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts.map +0 -1
  433. package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts +0 -18
  434. package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts.map +0 -1
  435. package/packages/cli/dist/plugins/prettier/index.d.ts +0 -2
  436. package/packages/cli/dist/plugins/prettier/index.d.ts.map +0 -1
  437. package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts +0 -6
  438. package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts.map +0 -1
  439. package/packages/cli/dist/plugins/shaking/index.d.ts +0 -2
  440. package/packages/cli/dist/plugins/shaking/index.d.ts.map +0 -1
  441. package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts +0 -8
  442. package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts.map +0 -1
  443. package/packages/cli/dist/plugins/terminal-select/index.d.ts +0 -2
  444. package/packages/cli/dist/plugins/terminal-select/index.d.ts.map +0 -1
  445. package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts +0 -18
  446. package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts.map +0 -1
  447. package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts +0 -2
  448. package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts.map +0 -1
  449. package/packages/cli/dist/plugins/terminal-select/types/index.d.ts +0 -2
  450. package/packages/cli/dist/plugins/terminal-select/types/index.d.ts.map +0 -1
  451. package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts +0 -2
  452. package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts.map +0 -1
  453. package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts +0 -5
  454. package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts.map +0 -1
  455. package/packages/cli/dist/plugins.cjs.map +0 -1
  456. package/packages/cli/dist/plugins.js +0 -2365
  457. package/packages/cli/dist/plugins.js.map +0 -1
  458. package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts +0 -8
  459. package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts.map +0 -1
  460. package/packages/cli/dist/transformers/api-document/index.d.ts +0 -2
  461. package/packages/cli/dist/transformers/api-document/index.d.ts.map +0 -1
  462. package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts +0 -14
  463. package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts.map +0 -1
  464. package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts +0 -12
  465. package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts.map +0 -1
  466. package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts +0 -10
  467. package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts.map +0 -1
  468. package/packages/cli/dist/transformers/entrypoint/index.d.ts +0 -2
  469. package/packages/cli/dist/transformers/entrypoint/index.d.ts.map +0 -1
  470. package/packages/cli/dist/transformers/index.d.ts +0 -6
  471. package/packages/cli/dist/transformers/index.d.ts.map +0 -1
  472. package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts +0 -8
  473. package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts.map +0 -1
  474. package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts +0 -26
  475. package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts.map +0 -1
  476. package/packages/cli/dist/transformers/json-schema/index.d.ts +0 -4
  477. package/packages/cli/dist/transformers/json-schema/index.d.ts.map +0 -1
  478. package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts +0 -7
  479. package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts.map +0 -1
  480. package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts +0 -5
  481. package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts.map +0 -1
  482. package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts +0 -5
  483. package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts.map +0 -1
  484. package/packages/cli/dist/transformers/json-schema/types/index.d.ts +0 -3
  485. package/packages/cli/dist/transformers/json-schema/types/index.d.ts.map +0 -1
  486. package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts +0 -7
  487. package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts.map +0 -1
  488. package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts +0 -8
  489. package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts.map +0 -1
  490. package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts +0 -20
  491. package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts.map +0 -1
  492. package/packages/cli/dist/transformers/operation-definition/index.d.ts +0 -3
  493. package/packages/cli/dist/transformers/operation-definition/index.d.ts.map +0 -1
  494. package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts +0 -19
  495. package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts.map +0 -1
  496. package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts +0 -15
  497. package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts.map +0 -1
  498. package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts +0 -11
  499. package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts.map +0 -1
  500. package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts +0 -22
  501. package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts.map +0 -1
  502. package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts +0 -2
  503. package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts.map +0 -1
  504. package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts +0 -4
  505. package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts.map +0 -1
  506. package/packages/cli/dist/transformers/schema-definition/index.d.ts +0 -2
  507. package/packages/cli/dist/transformers/schema-definition/index.d.ts.map +0 -1
  508. package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts +0 -10
  509. package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts.map +0 -1
  510. package/packages/cli/dist/transformers/types/renderer.d.ts +0 -4
  511. package/packages/cli/dist/transformers/types/renderer.d.ts.map +0 -1
  512. package/packages/cli/dist/types/build-cli-options.d.ts +0 -19
  513. package/packages/cli/dist/types/build-cli-options.d.ts.map +0 -1
  514. package/packages/cli/dist/types/generator.d.ts +0 -7
  515. package/packages/cli/dist/types/generator.d.ts.map +0 -1
  516. package/packages/cli/dist/types/index.d.ts +0 -6
  517. package/packages/cli/dist/types/index.d.ts.map +0 -1
  518. package/packages/cli/dist/types/plugin.d.ts +0 -5
  519. package/packages/cli/dist/types/plugin.d.ts.map +0 -1
  520. package/packages/cli/dist/types/runtime-config.d.ts +0 -32
  521. package/packages/cli/dist/types/runtime-config.d.ts.map +0 -1
  522. package/packages/cli/dist/types/to-code-options.d.ts +0 -4
  523. package/packages/cli/dist/types/to-code-options.d.ts.map +0 -1
  524. package/packages/cli/dist/utils/debugger.d.ts +0 -7
  525. package/packages/cli/dist/utils/debugger.d.ts.map +0 -1
  526. package/packages/cli/dist/utils/ignore-matcher.d.ts +0 -18
  527. package/packages/cli/dist/utils/ignore-matcher.d.ts.map +0 -1
  528. package/packages/cli/dist/utils/indent.d.ts +0 -2
  529. package/packages/cli/dist/utils/indent.d.ts.map +0 -1
  530. package/packages/cli/dist/utils/is-keywords.d.ts +0 -2
  531. package/packages/cli/dist/utils/is-keywords.d.ts.map +0 -1
  532. package/packages/cli/dist/utils/is-reserved-word.d.ts +0 -2
  533. package/packages/cli/dist/utils/is-reserved-word.d.ts.map +0 -1
  534. package/packages/cli/dist/utils/json-schema-utils/index.d.ts +0 -11
  535. package/packages/cli/dist/utils/json-schema-utils/index.d.ts.map +0 -1
  536. package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts +0 -3
  537. package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts.map +0 -1
  538. package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts +0 -4
  539. package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts.map +0 -1
  540. package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts +0 -3
  541. package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts.map +0 -1
  542. package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts +0 -3
  543. package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts.map +0 -1
  544. package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts +0 -5
  545. package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts.map +0 -1
  546. package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts +0 -7
  547. package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts.map +0 -1
  548. package/packages/cli/dist/utils/logger.d.ts +0 -6
  549. package/packages/cli/dist/utils/logger.d.ts.map +0 -1
  550. package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts +0 -3
  551. package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts.map +0 -1
  552. package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts +0 -4
  553. package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts.map +0 -1
  554. package/packages/cli/dist/utils/openapi-utils/dereference.d.ts +0 -3
  555. package/packages/cli/dist/utils/openapi-utils/dereference.d.ts.map +0 -1
  556. package/packages/cli/dist/utils/openapi-utils/index.d.ts +0 -19
  557. package/packages/cli/dist/utils/openapi-utils/index.d.ts.map +0 -1
  558. package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts +0 -3
  559. package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts.map +0 -1
  560. package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts +0 -4
  561. package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts.map +0 -1
  562. package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts +0 -4
  563. package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts.map +0 -1
  564. package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts +0 -3
  565. package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts.map +0 -1
  566. package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts +0 -3
  567. package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts.map +0 -1
  568. package/packages/exception/dist/plugins/index.d.mts +0 -12
  569. package/packages/exception/dist/plugins/index.d.ts +0 -12
  570. package/packages/exception/dist/plugins/index.js +0 -95
  571. package/packages/exception/dist/plugins/index.mjs +0 -68
  572. package/packages/exception/node_modules/.bin/keq +0 -21
  573. package/packages/keq/dist/context/execution-context.d.ts +0 -26
  574. package/packages/keq/dist/context/execution-context.d.ts.map +0 -1
  575. package/packages/keq/dist/context/index.d.ts +0 -5
  576. package/packages/keq/dist/context/index.d.ts.map +0 -1
  577. package/packages/keq/dist/context/middleware-context.d.ts +0 -11
  578. package/packages/keq/dist/context/middleware-context.d.ts.map +0 -1
  579. package/packages/keq/dist/context/orchestrator-context.d.ts +0 -18
  580. package/packages/keq/dist/context/orchestrator-context.d.ts.map +0 -1
  581. package/packages/keq/dist/context/shared-context.d.ts +0 -43
  582. package/packages/keq/dist/context/shared-context.d.ts.map +0 -1
  583. package/packages/keq/dist/context/types/index.d.ts +0 -6
  584. package/packages/keq/dist/context/types/index.d.ts.map +0 -1
  585. package/packages/keq/dist/context/types/keq-context-data.d.ts +0 -7
  586. package/packages/keq/dist/context/types/keq-context-data.d.ts.map +0 -1
  587. package/packages/keq/dist/context/types/keq-context-emitter.d.ts +0 -35
  588. package/packages/keq/dist/context/types/keq-context-emitter.d.ts.map +0 -1
  589. package/packages/keq/dist/context/types/keq-context-options/index.d.ts +0 -6
  590. package/packages/keq/dist/context/types/keq-context-options/index.d.ts.map +0 -1
  591. package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts +0 -5
  592. package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts.map +0 -1
  593. package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts +0 -33
  594. package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts.map +0 -1
  595. package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts +0 -5
  596. package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts.map +0 -1
  597. package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts +0 -2
  598. package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts.map +0 -1
  599. package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts +0 -9
  600. package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts.map +0 -1
  601. package/packages/keq/dist/context/types/keq-context.d.ts +0 -17
  602. package/packages/keq/dist/context/types/keq-context.d.ts.map +0 -1
  603. package/packages/keq/dist/context/types/keq-global.d.ts +0 -7
  604. package/packages/keq/dist/context/types/keq-global.d.ts.map +0 -1
  605. package/packages/keq/dist/context/utils/assign-shared-context.d.ts +0 -3
  606. package/packages/keq/dist/context/utils/assign-shared-context.d.ts.map +0 -1
  607. package/packages/keq/dist/context/utils/clone-shared-context.d.ts +0 -3
  608. package/packages/keq/dist/context/utils/clone-shared-context.d.ts.map +0 -1
  609. package/packages/keq/dist/context/utils/create-proxy-response.d.ts +0 -2
  610. package/packages/keq/dist/context/utils/create-proxy-response.d.ts.map +0 -1
  611. package/packages/keq/dist/context/utils/fork.d.ts +0 -6
  612. package/packages/keq/dist/context/utils/fork.d.ts.map +0 -1
  613. package/packages/keq/dist/context/utils/index.d.ts +0 -5
  614. package/packages/keq/dist/context/utils/index.d.ts.map +0 -1
  615. package/packages/keq/dist/context/utils/watch-object.d.ts +0 -5
  616. package/packages/keq/dist/context/utils/watch-object.d.ts.map +0 -1
  617. package/packages/keq/dist/exception/abort.exception.d.ts +0 -4
  618. package/packages/keq/dist/exception/abort.exception.d.ts.map +0 -1
  619. package/packages/keq/dist/exception/exception.d.ts +0 -5
  620. package/packages/keq/dist/exception/exception.d.ts.map +0 -1
  621. package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts +0 -5
  622. package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts.map +0 -1
  623. package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts +0 -5
  624. package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts.map +0 -1
  625. package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts +0 -5
  626. package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts.map +0 -1
  627. package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts +0 -5
  628. package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts.map +0 -1
  629. package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts +0 -5
  630. package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts.map +0 -1
  631. package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts +0 -5
  632. package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts.map +0 -1
  633. package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts +0 -5
  634. package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts.map +0 -1
  635. package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts +0 -5
  636. package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts.map +0 -1
  637. package/packages/keq/dist/exception/http-exceptions/index.d.ts +0 -22
  638. package/packages/keq/dist/exception/http-exceptions/index.d.ts.map +0 -1
  639. package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts +0 -5
  640. package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts.map +0 -1
  641. package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts +0 -5
  642. package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts.map +0 -1
  643. package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts +0 -5
  644. package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts.map +0 -1
  645. package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts +0 -5
  646. package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts.map +0 -1
  647. package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts +0 -5
  648. package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts.map +0 -1
  649. package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts +0 -5
  650. package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts.map +0 -1
  651. package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts +0 -5
  652. package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts.map +0 -1
  653. package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts +0 -5
  654. package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts.map +0 -1
  655. package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts +0 -12
  656. package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts.map +0 -1
  657. package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts +0 -5
  658. package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts.map +0 -1
  659. package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts +0 -5
  660. package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts.map +0 -1
  661. package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts +0 -5
  662. package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts.map +0 -1
  663. package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts +0 -5
  664. package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts.map +0 -1
  665. package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts +0 -5
  666. package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts.map +0 -1
  667. package/packages/keq/dist/exception/index.d.ts +0 -6
  668. package/packages/keq/dist/exception/index.d.ts.map +0 -1
  669. package/packages/keq/dist/exception/timeout.exception.d.ts +0 -5
  670. package/packages/keq/dist/exception/timeout.exception.d.ts.map +0 -1
  671. package/packages/keq/dist/exception/type.exception.d.ts +0 -5
  672. package/packages/keq/dist/exception/type.exception.d.ts.map +0 -1
  673. package/packages/keq/dist/middleware/index.d.ts +0 -3
  674. package/packages/keq/dist/middleware/index.d.ts.map +0 -1
  675. package/packages/keq/dist/middleware/types/index.d.ts +0 -3
  676. package/packages/keq/dist/middleware/types/index.d.ts.map +0 -1
  677. package/packages/keq/dist/middleware/types/keq-middleware.d.ts +0 -8
  678. package/packages/keq/dist/middleware/types/keq-middleware.d.ts.map +0 -1
  679. package/packages/keq/dist/middleware/types/keq-next.d.ts +0 -2
  680. package/packages/keq/dist/middleware/types/keq-next.d.ts.map +0 -1
  681. package/packages/keq/dist/middleware/utils/compose-middleware.d.ts +0 -7
  682. package/packages/keq/dist/middleware/utils/compose-middleware.d.ts.map +0 -1
  683. package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts +0 -3
  684. package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts.map +0 -1
  685. package/packages/keq/dist/middleware/utils/index.d.ts +0 -3
  686. package/packages/keq/dist/middleware/utils/index.d.ts.map +0 -1
  687. package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts +0 -6
  688. package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts.map +0 -1
  689. package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts +0 -3
  690. package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts.map +0 -1
  691. package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts +0 -4
  692. package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts.map +0 -1
  693. package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts +0 -3
  694. package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts.map +0 -1
  695. package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts +0 -9
  696. package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts.map +0 -1
  697. package/packages/keq/dist/middlewares/index.d.ts +0 -4
  698. package/packages/keq/dist/middlewares/index.d.ts.map +0 -1
  699. package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts +0 -6
  700. package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts.map +0 -1
  701. package/packages/keq/dist/orchestrator/executor.d.ts +0 -13
  702. package/packages/keq/dist/orchestrator/executor.d.ts.map +0 -1
  703. package/packages/keq/dist/orchestrator/index.d.ts +0 -3
  704. package/packages/keq/dist/orchestrator/index.d.ts.map +0 -1
  705. package/packages/keq/dist/orchestrator/orchestrator.d.ts +0 -20
  706. package/packages/keq/dist/orchestrator/orchestrator.d.ts.map +0 -1
  707. package/packages/keq/dist/request/core.d.ts +0 -54
  708. package/packages/keq/dist/request/core.d.ts.map +0 -1
  709. package/packages/keq/dist/request/create-request.d.ts +0 -7
  710. package/packages/keq/dist/request/create-request.d.ts.map +0 -1
  711. package/packages/keq/dist/request/index.d.ts +0 -6
  712. package/packages/keq/dist/request/index.d.ts.map +0 -1
  713. package/packages/keq/dist/request/keq.d.ts +0 -120
  714. package/packages/keq/dist/request/keq.d.ts.map +0 -1
  715. package/packages/keq/dist/request/request.d.ts +0 -79
  716. package/packages/keq/dist/request/request.d.ts.map +0 -1
  717. package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts +0 -42
  718. package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts.map +0 -1
  719. package/packages/keq/dist/request/types/api-schema/api-schema.d.ts +0 -8
  720. package/packages/keq/dist/request/types/api-schema/api-schema.d.ts.map +0 -1
  721. package/packages/keq/dist/request/types/api-schema/default-operation.d.ts +0 -18
  722. package/packages/keq/dist/request/types/api-schema/default-operation.d.ts.map +0 -1
  723. package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts +0 -31
  724. package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts.map +0 -1
  725. package/packages/keq/dist/request/types/api-schema/index.d.ts +0 -6
  726. package/packages/keq/dist/request/types/api-schema/index.d.ts.map +0 -1
  727. package/packages/keq/dist/request/types/api-schema/operation.d.ts +0 -17
  728. package/packages/keq/dist/request/types/api-schema/operation.d.ts.map +0 -1
  729. package/packages/keq/dist/request/types/content-type.d.ts +0 -3
  730. package/packages/keq/dist/request/types/content-type.d.ts.map +0 -1
  731. package/packages/keq/dist/request/types/index.d.ts +0 -8
  732. package/packages/keq/dist/request/types/index.d.ts.map +0 -1
  733. package/packages/keq/dist/request/types/keq-attachable-file.d.ts +0 -2
  734. package/packages/keq/dist/request/types/keq-attachable-file.d.ts.map +0 -1
  735. package/packages/keq/dist/request/types/keq-param-value.d.ts +0 -3
  736. package/packages/keq/dist/request/types/keq-param-value.d.ts.map +0 -1
  737. package/packages/keq/dist/request/types/keq-query-options.d.ts +0 -7
  738. package/packages/keq/dist/request/types/keq-query-options.d.ts.map +0 -1
  739. package/packages/keq/dist/request/types/keq-query-value.d.ts +0 -8
  740. package/packages/keq/dist/request/types/keq-query-value.d.ts.map +0 -1
  741. package/packages/keq/dist/request/types/server-sent-event.d.ts +0 -3
  742. package/packages/keq/dist/request/types/server-sent-event.d.ts.map +0 -1
  743. package/packages/keq/dist/request/utils/fix-content-type.d.ts +0 -4
  744. package/packages/keq/dist/request/utils/fix-content-type.d.ts.map +0 -1
  745. package/packages/keq/dist/request/utils/get-location-id.d.ts +0 -2
  746. package/packages/keq/dist/request/utils/get-location-id.d.ts.map +0 -1
  747. package/packages/keq/dist/request/utils/index.d.ts +0 -7
  748. package/packages/keq/dist/request/utils/index.d.ts.map +0 -1
  749. package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts +0 -2
  750. package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts.map +0 -1
  751. package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts +0 -3
  752. package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts.map +0 -1
  753. package/packages/keq/dist/request/utils/query-stringify.d.ts +0 -3
  754. package/packages/keq/dist/request/utils/query-stringify.d.ts.map +0 -1
  755. package/packages/keq/dist/request/utils/resolve-with.d.ts +0 -3
  756. package/packages/keq/dist/request/utils/resolve-with.d.ts.map +0 -1
  757. package/packages/keq/dist/request-init/index.d.ts +0 -4
  758. package/packages/keq/dist/request-init/index.d.ts.map +0 -1
  759. package/packages/keq/dist/request-init/request-init.d.ts +0 -42
  760. package/packages/keq/dist/request-init/request-init.d.ts.map +0 -1
  761. package/packages/keq/dist/request-init/types/index.d.ts +0 -3
  762. package/packages/keq/dist/request-init/types/index.d.ts.map +0 -1
  763. package/packages/keq/dist/request-init/types/keq-body-init.d.ts +0 -2
  764. package/packages/keq/dist/request-init/types/keq-body-init.d.ts.map +0 -1
  765. package/packages/keq/dist/request-init/types/keq-request-method.d.ts +0 -2
  766. package/packages/keq/dist/request-init/types/keq-request-method.d.ts.map +0 -1
  767. package/packages/keq/dist/request-init/utils/assign-request-init.d.ts +0 -3
  768. package/packages/keq/dist/request-init/utils/assign-request-init.d.ts.map +0 -1
  769. package/packages/keq/dist/request-init/utils/clone-body.d.ts +0 -2
  770. package/packages/keq/dist/request-init/utils/clone-body.d.ts.map +0 -1
  771. package/packages/keq/dist/request-init/utils/clone-headers.d.ts +0 -2
  772. package/packages/keq/dist/request-init/utils/clone-headers.d.ts.map +0 -1
  773. package/packages/keq/dist/request-init/utils/clone-request-init.d.ts +0 -3
  774. package/packages/keq/dist/request-init/utils/clone-request-init.d.ts.map +0 -1
  775. package/packages/keq/dist/request-init/utils/compile-url.d.ts +0 -3
  776. package/packages/keq/dist/request-init/utils/compile-url.d.ts.map +0 -1
  777. package/packages/keq/dist/request-init/utils/index.d.ts +0 -7
  778. package/packages/keq/dist/request-init/utils/index.d.ts.map +0 -1
  779. package/packages/keq/dist/request-init/utils/to-form-data.d.ts +0 -2
  780. package/packages/keq/dist/request-init/utils/to-form-data.d.ts.map +0 -1
  781. package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts +0 -2
  782. package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts.map +0 -1
  783. package/packages/keq/dist/router/index.d.ts +0 -4
  784. package/packages/keq/dist/router/index.d.ts.map +0 -1
  785. package/packages/keq/dist/router/keq-host-route.d.ts +0 -3
  786. package/packages/keq/dist/router/keq-host-route.d.ts.map +0 -1
  787. package/packages/keq/dist/router/keq-location-route.d.ts +0 -3
  788. package/packages/keq/dist/router/keq-location-route.d.ts.map +0 -1
  789. package/packages/keq/dist/router/keq-method-route.d.ts +0 -3
  790. package/packages/keq/dist/router/keq-method-route.d.ts.map +0 -1
  791. package/packages/keq/dist/router/keq-module-route.d.ts +0 -3
  792. package/packages/keq/dist/router/keq-module-route.d.ts.map +0 -1
  793. package/packages/keq/dist/router/keq-pathname-route.d.ts +0 -3
  794. package/packages/keq/dist/router/keq-pathname-route.d.ts.map +0 -1
  795. package/packages/keq/dist/router/keq-router.d.ts +0 -32
  796. package/packages/keq/dist/router/keq-router.d.ts.map +0 -1
  797. package/packages/keq/dist/router/types/index.d.ts +0 -2
  798. package/packages/keq/dist/router/types/index.d.ts.map +0 -1
  799. package/packages/keq/dist/router/types/keq-route.d.ts +0 -7
  800. package/packages/keq/dist/router/types/keq-route.d.ts.map +0 -1
  801. package/packages/keq/dist/router/utils/compose-route.d.ts +0 -3
  802. package/packages/keq/dist/router/utils/compose-route.d.ts.map +0 -1
  803. package/packages/keq/dist/router/utils/index.d.ts +0 -2
  804. package/packages/keq/dist/router/utils/index.d.ts.map +0 -1
  805. package/packages/keq/dist/types/enabled-if-string-index.d.ts +0 -24
  806. package/packages/keq/dist/types/enabled-if-string-index.d.ts.map +0 -1
  807. package/packages/keq/dist/types/exclude-unknown-properties.d.ts +0 -19
  808. package/packages/keq/dist/types/exclude-unknown-properties.d.ts.map +0 -1
  809. package/packages/keq/dist/types/index-keys.d.ts +0 -18
  810. package/packages/keq/dist/types/index-keys.d.ts.map +0 -1
  811. package/packages/keq/dist/types/index.d.ts +0 -7
  812. package/packages/keq/dist/types/index.d.ts.map +0 -1
  813. package/packages/keq/dist/types/literal-keys.d.ts +0 -18
  814. package/packages/keq/dist/types/literal-keys.d.ts.map +0 -1
  815. package/packages/keq/dist/types/loose-nested-like.d.ts +0 -11
  816. package/packages/keq/dist/types/loose-nested-like.d.ts.map +0 -1
  817. package/packages/keq/dist/types/string-index-value-of.d.ts +0 -18
  818. package/packages/keq/dist/types/string-index-value-of.d.ts.map +0 -1
  819. package/packages/keq/dist/utils/base64.d.ts +0 -3
  820. package/packages/keq/dist/utils/base64.d.ts.map +0 -1
  821. package/packages/keq/dist/utils/index.d.ts +0 -4
  822. package/packages/keq/dist/utils/index.d.ts.map +0 -1
  823. package/packages/keq/dist/utils/shallow-clone.d.ts +0 -5
  824. package/packages/keq/dist/utils/shallow-clone.d.ts.map +0 -1
  825. package/packages/keq/dist/utils/sleep.d.ts +0 -2
  826. package/packages/keq/dist/utils/sleep.d.ts.map +0 -1
  827. package/packages/keq/dist/validator/index.d.ts +0 -2
  828. package/packages/keq/dist/validator/index.d.ts.map +0 -1
  829. package/packages/keq/dist/validator/validator.d.ts +0 -65
  830. package/packages/keq/dist/validator/validator.d.ts.map +0 -1
  831. package/packages/keq/node_modules/.bin/tsc +0 -21
  832. package/packages/keq/node_modules/.bin/tsserver +0 -21
  833. package/packages/nestjs/dist/keq.module-definition.d.ts +0 -3
  834. package/packages/nestjs/dist/keq.module-definition.d.ts.map +0 -1
  835. package/packages/nestjs/dist/keq.module.d.ts +0 -7
  836. package/packages/nestjs/dist/keq.module.d.ts.map +0 -1
  837. package/packages/nestjs/dist/types/index.d.ts +0 -2
  838. package/packages/nestjs/dist/types/index.d.ts.map +0 -1
  839. package/packages/nestjs/dist/types/keq-module-options.d.ts +0 -5
  840. package/packages/nestjs/dist/types/keq-module-options.d.ts.map +0 -1
  841. package/packages/nestjs/node_modules/.bin/tsc +0 -21
  842. package/packages/nestjs/node_modules/.bin/tsserver +0 -21
@@ -1,2922 +1,1364 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
-
26
- // src/cli.ts
27
- var import_semver = __toESM(require("semver"), 1);
28
- var import_commander = require("commander");
29
-
30
- // src/constants/supported-methods.ts
31
- var SupportedMethods = [
32
- "get",
33
- "post",
34
- "put",
35
- "delete",
36
- "patch",
37
- "head",
38
- "options"
39
- ];
40
-
41
- // src/utils/logger.ts
42
- var import_chalk = __toESM(require("chalk"), 1);
43
- var logger = {
44
- log: (str) => console.log(import_chalk.default.green(str)),
45
- warn: (str) => console.warn(import_chalk.default.yellow(str)),
46
- error: (str) => console.error(import_chalk.default.red(str))
47
- };
48
-
49
- // src/compiler/compiler.ts
50
- var import_listr22 = require("listr2");
51
- var import_tapable4 = require("tapable");
52
-
53
- // src/compiler/tasks/setup/index.ts
54
- var import_fs_extra2 = __toESM(require("fs-extra"), 1);
55
- var import_path = __toESM(require("path"), 1);
56
- var import_value = require("@sinclair/typebox/value");
57
- var import_cosmiconfig = require("cosmiconfig");
58
-
59
- // src/utils/ignore-matcher.ts
60
- var R = __toESM(require("ramda"), 1);
61
- var import_fs_extra = __toESM(require("fs-extra"), 1);
62
- var IgnoreMatcher = class _IgnoreMatcher {
63
- rules;
64
- constructor(rules) {
65
- this.rules = rules;
66
- }
67
- static async read(filepath) {
68
- let content = await import_fs_extra.default.readFile(filepath, "utf-8");
69
- content = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/#.*$/gm, "").replace(/\n+/g, "\n").trim();
70
- let rules = content.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => {
71
- const matched = line.match(/^(!)?\s*([^\s/]+)\s+([^\s/]+)\s+([^\s]+)$/);
72
- if (!matched) throw new Error(`Invalid ignore rule: "${line}"`);
73
- const [, flag, moduleName, operationMethod, operationPathname] = matched;
74
- return {
75
- persist: true,
76
- ignore: !flag,
77
- moduleName,
78
- operationMethod: operationMethod.toLowerCase(),
79
- operationPathname
80
- };
81
- });
82
- rules = R.sortBy(
83
- R.prop("ignore"),
84
- rules
85
- );
86
- rules = R.uniqWith(
87
- (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,
88
- rules
89
- );
90
- return new _IgnoreMatcher(rules);
91
- }
92
- async write(filepath) {
93
- const ruleGroups = R.compose(
94
- R.groupBy((rule) => rule.moduleName),
95
- R.reverse,
96
- R.uniqWith(
97
- (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname
98
- ),
99
- R.filter((rule) => rule.persist)
100
- )(this.rules);
101
- const content = Object.entries(ruleGroups).sort((a, b) => {
102
- const aModuleName = a[0];
103
- const bModuleName = b[0];
104
- if (aModuleName === "*") return -1;
105
- if (bModuleName === "*") return 1;
106
- return aModuleName.localeCompare(bModuleName);
107
- }).map(([, rules]) => (rules || []).sort((a, b) => {
108
- if (a.ignore !== b.ignore) return a.ignore ? -1 : 1;
109
- if (a.operationMethod === "*") return -1;
110
- if (b.operationMethod === "*") return 1;
111
- if (a.operationPathname === "*") return -1;
112
- if (b.operationPathname === "*") return 1;
113
- if (a.operationMethod !== b.operationMethod) return a.operationMethod.localeCompare(b.operationMethod);
114
- if (a.operationPathname !== b.operationPathname) return a.operationPathname.localeCompare(b.operationPathname);
115
- return 0;
116
- }).map((rule) => `${rule.ignore ? "" : "! "}${rule.moduleName} ${rule.operationMethod.toUpperCase()} ${rule.operationPathname}`).join("\n")).join("\n\n");
117
- await import_fs_extra.default.writeFile(filepath, content, "utf-8");
118
- }
119
- append(rule) {
120
- this.rules.unshift(rule);
121
- }
122
- // if operation is ignored, return true
123
- isOperationIgnored(operationDefinition) {
124
- const moduleName = operationDefinition.module.name;
125
- const operationMethod = operationDefinition.method.toLowerCase();
126
- const operationPathname = operationDefinition.pathname;
127
- for (const rule of this.rules) {
128
- if (rule.moduleName !== "*" && rule.moduleName !== moduleName) continue;
129
- if (rule.operationMethod !== "*" && rule.operationMethod !== operationMethod) continue;
130
- if (rule.operationPathname !== "*" && rule.operationPathname !== operationPathname) continue;
131
- return rule.ignore;
132
- }
133
- return false;
134
- }
135
- isModuleIgnored(moduleDefinition) {
136
- const moduleName = moduleDefinition.name;
137
- for (const rule of this.rules) {
138
- if (!rule.ignore) {
139
- if (rule.moduleName === "*" || rule.moduleName === moduleName) return false;
140
- continue;
141
- }
142
- if (rule.operationMethod !== "*") continue;
143
- if (rule.operationPathname !== "*") continue;
144
- if (rule.moduleName === "*" || rule.moduleName === moduleName) return true;
145
- }
146
- return false;
147
- }
148
- };
149
-
150
- // src/types/runtime-config.ts
151
- var import_typebox = require("@sinclair/typebox");
152
-
153
- // src/constants/file-naming-style.ts
154
- var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
155
- FileNamingStyle2["camelCase"] = "camelCase";
156
- FileNamingStyle2["capitalCase"] = "capitalCase";
157
- FileNamingStyle2["constantCase"] = "constantCase";
158
- FileNamingStyle2["dotCase"] = "dotCase";
159
- FileNamingStyle2["headerCase"] = "headerCase";
160
- FileNamingStyle2["noCase"] = "noCase";
161
- FileNamingStyle2["paramCase"] = "paramCase";
162
- FileNamingStyle2["pascalCase"] = "pascalCase";
163
- FileNamingStyle2["pathCase"] = "pathCase";
164
- FileNamingStyle2["sentenceCase"] = "sentenceCase";
165
- FileNamingStyle2["snakeCase"] = "snakeCase";
166
- return FileNamingStyle2;
167
- })(FileNamingStyle || {});
168
-
169
- // src/types/runtime-config.ts
170
- var RuntimeConfig = import_typebox.Type.Object({
171
- mode: import_typebox.Type.Optional(
172
- import_typebox.Type.Union([
173
- import_typebox.Type.Literal("micro-function"),
174
- import_typebox.Type.Literal("nestjs-module"),
175
- import_typebox.Type.Literal("none")
176
- ], { default: "micro-function" })
177
- ),
178
- /**
179
- * Whether to generate ES Module code
180
- *
181
- * If not specified, the module system will be inferred from the nearest package.json "type" field
182
- * or defaults to "cjs" if no package.json is found.
183
- */
184
- esm: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
185
- /**
186
- * Output directory for generated files
187
- */
188
- outdir: import_typebox.Type.String({ default: `${process.cwd()}/api` }),
189
- /**
190
- * File naming style for generated files
191
- */
192
- fileNamingStyle: import_typebox.Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
193
- modules: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.String()),
194
- debug: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
195
- /**
196
- * Whether to tolerate wrong openapi/swagger structure
197
- */
198
- tolerant: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: false })),
199
- plugins: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.Any(), { default: [] }))
200
- });
201
-
202
- // src/compiler/tasks/setup/utils/validate-modules.ts
203
- var R2 = __toESM(require("ramda"), 1);
204
- var import_validator = __toESM(require("validator"), 1);
205
- function validateModules(modules) {
206
- const keys2 = Object.keys(modules);
207
- for (const key of keys2) {
208
- if (!/^[A-Za-z_][A-Za-z0-9_$]*$/.test(key)) {
209
- throw new Error(`Module name "${key}" is not valid. It must start with a letter or underscore, and can only contain letters, numbers, and underscores.`);
210
- }
211
- }
212
- const keysGroupByLowerCase = R2.groupBy(R2.toLower, keys2);
213
- for (const groupKey in keysGroupByLowerCase) {
214
- const keys3 = keysGroupByLowerCase[groupKey] || [];
215
- if (keys3.length > 1) {
216
- throw new Error(`Module names ${keys3.map((name) => `"${name}"`).join(", ")} are case-insensitively duplicated.`);
217
- }
218
- }
219
- for (const key in modules) {
220
- const address = modules[key];
221
- if (import_validator.default.isURL(address, { require_host: true, require_protocol: true, protocols: ["http", "https"] })) {
222
- continue;
223
- }
224
- if (/^(\/|\.\/|\.\.\/)/.test(address)) {
225
- continue;
226
- }
227
- throw new Error(`Module address "${address}" of module "${key}" is not valid. It must be a URL or a local path.`);
228
- }
229
- }
230
-
231
- // src/compiler/tasks/setup/utils/find-nearest-package-json.ts
232
- var import_node_fs = __toESM(require("fs"), 1);
233
- var import_node_path = __toESM(require("path"), 1);
234
- function findNearestPackageJson(startDir = process.cwd()) {
235
- let dir = startDir;
236
- while (true) {
237
- const pkgPath = import_node_path.default.join(dir, "package.json");
238
- if (import_node_fs.default.existsSync(pkgPath)) {
239
- const json = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf8"));
240
- return { json, path: pkgPath };
241
- }
242
- const parent = import_node_path.default.dirname(dir);
243
- if (parent === dir) break;
244
- dir = parent;
245
- }
246
- return null;
247
- }
248
-
249
- // src/compiler/tasks/setup/utils/get-project-module-system.ts
250
- function getProjectModuleSystem(pkgInfo) {
251
- if (!pkgInfo?.json) return "cjs";
252
- const { json } = pkgInfo;
253
- if (json.type === "module") return "esm";
254
- return "cjs";
255
- }
256
-
257
- // src/compiler/tasks/setup/index.ts
258
- var explore = (0, import_cosmiconfig.cosmiconfig)("keq");
259
- function main(compiler, options) {
260
- return {
261
- task: async (context, task) => {
262
- const result = options?.config ? await explore.load(options.config) : await explore.search();
263
- if (!result || "isEmpty" in result && result.isEmpty) {
264
- throw new Error("Cannot find config file.");
265
- }
266
- if (!import_value.Value.Check(RuntimeConfig, result.config)) {
267
- const errors = [...import_value.Value.Errors(RuntimeConfig, result.config)];
268
- const message = errors.map(({ path: path13, message: message2 }) => `${path13}: ${message2}`).join("\n");
269
- throw new Error(`Invalid Config: ${message}`);
270
- }
271
- const rc = import_value.Value.Default(RuntimeConfig, result.config);
272
- validateModules(rc.modules);
273
- if (options?.debug) {
274
- await import_fs_extra2.default.ensureDir(".keq");
275
- rc.debug = true;
276
- }
277
- rc.tolerant = Boolean(rc.tolerant);
278
- const packageJsonInfo = findNearestPackageJson();
279
- if (packageJsonInfo) {
280
- const moduleSystem = getProjectModuleSystem(packageJsonInfo);
281
- rc.esm = moduleSystem === "esm";
282
- }
283
- context.rc = rc;
284
- let matcher = new IgnoreMatcher([]);
285
- if (result.filepath) {
286
- const ignoreFilepath = import_path.default.resolve(import_path.default.dirname(result.filepath), ".keqignore");
287
- if (await import_fs_extra2.default.exists(ignoreFilepath)) {
288
- matcher = await IgnoreMatcher.read(ignoreFilepath);
289
- }
290
- }
291
- const ignoreRules = options.ignore === false ? [] : options.ignore?.rules || [];
292
- for (const rule of ignoreRules) {
293
- matcher.append({
294
- persist: !!rule.persist,
295
- ignore: rule.ignore,
296
- moduleName: rule.moduleName,
297
- operationMethod: rule.operationMethod,
298
- operationPathname: rule.operationPathname
299
- });
300
- }
301
- context.matcher = matcher;
302
- await compiler.hooks.setup.promise(task);
303
- }
304
- };
2
+ const require_logger = require("./logger-D7PyVZo3.cjs");
3
+ const require_compiler = require("./compiler-0Kli6UCr.cjs");
4
+ const require_plugins = require("./plugins-CgMhaNZq.cjs");
5
+ let fs_extra = require("fs-extra");
6
+ fs_extra = require_logger.__toESM(fs_extra, 1);
7
+ let path = require("path");
8
+ path = require_logger.__toESM(path, 1);
9
+ let cosmiconfig = require("cosmiconfig");
10
+ let ramda = require("ramda");
11
+ ramda = require_logger.__toESM(ramda, 1);
12
+ let picomatch = require("picomatch");
13
+ picomatch = require_logger.__toESM(picomatch, 1);
14
+ let js_yaml = require("js-yaml");
15
+ js_yaml = require_logger.__toESM(js_yaml, 1);
16
+ let semver = require("semver");
17
+ semver = require_logger.__toESM(semver, 1);
18
+ let commander = require("commander");
19
+ let os = require("os");
20
+ os = require_logger.__toESM(os, 1);
21
+ let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
22
+ let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
23
+ let zod = require("zod");
24
+ //#region src/utils/xprod-merge.ts
25
+ /**
26
+ * 对多个对象数组执行笛卡尔积合并
27
+ * @example
28
+ * xprodMerge([{ a: 1 }, { a: 2 }], [{b: 1}], [{ c: 1 }])
29
+ * // => [{ a: 1, b: 1, c: 1}, { a: 2, b:1, c: 1 }]
30
+ */
31
+ function xprodMerge(...lists) {
32
+ if (lists.length === 0) return [];
33
+ if (lists.length === 1) return lists[0];
34
+ return lists.reduce((acc, curr) => ramda.chain((item1) => ramda.map((item2) => ramda.mergeAll([item1, item2]), curr), acc));
305
35
  }
306
- function createSetupTask(compiler, options) {
307
- return {
308
- title: "Setup",
309
- enabled: options?.enabled,
310
- skip: options?.skip,
311
- task: (context, task) => task.newListr(
312
- [
313
- main(compiler, options),
314
- {
315
- task: (context2, task2) => compiler.hooks.afterSetup.promise(task2)
316
- }
317
- ],
318
- {
319
- concurrent: false
320
- }
321
- )
322
- };
36
+ //#endregion
37
+ //#region src/commands/utils/xprod-filter-rules.ts
38
+ function xprodFilterRules(options) {
39
+ return xprodMerge((options.module || ["*"]).map((moduleName) => ({
40
+ deny: false,
41
+ persist: options.persist,
42
+ moduleName
43
+ })), options.method ? [{ operationMethod: options.method.toLowerCase() }] : [{ operationMethod: "*" }], options.pathname ? [{ operationPathname: options.pathname }] : [{ operationPathname: "/**" }]);
323
44
  }
324
-
325
- // src/compiler/tasks/download/index.ts
326
- var import_listr2 = require("listr2");
327
- var import_openapi_parser2 = require("@scalar/openapi-parser");
328
-
329
- // src/models/artifact.ts
330
- var path3 = __toESM(require("path"), 1);
331
-
332
- // src/models/anchor.ts
333
- var AnchorBlock = class {
334
- constructor(artifact) {
335
- this.artifact = artifact;
336
- }
337
- /**
338
- * Append content to the end of the anchor block.
339
- */
340
- append(anchorName, content) {
341
- const lines = this.artifact.content.split("\n");
342
- const anchor = `@anchor:${anchorName}:end`;
343
- const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
344
- if (anchorIndex === -1) {
345
- throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
346
- }
347
- lines.splice(anchorIndex, 0, content);
348
- this.artifact.content = lines.join("\n");
349
- }
350
- prepend(anchorName, content) {
351
- const lines = this.artifact.content.split("\n");
352
- const anchor = `@anchor:${anchorName}:start`;
353
- const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
354
- if (anchorIndex === -1) {
355
- throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
356
- }
357
- lines.splice(anchorIndex + 1, 0, content);
358
- this.artifact.content = lines.join("\n");
359
- }
360
- replace(anchorName, content) {
361
- const lines = this.artifact.content.split("\n");
362
- const startIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:start */`));
363
- const endIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:end */`));
364
- if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
365
- throw new Error(`"@anchor:${anchorName}:start" or "@anchor:${anchorName}:end" not found in artifact "${this.artifact.filepath}".`);
366
- }
367
- lines.splice(startIndex + 1, endIndex - startIndex - 1, content);
368
- this.artifact.content = lines.join("\n");
369
- }
370
- };
371
- var Anchor = class {
372
- constructor(artifact) {
373
- this.artifact = artifact;
374
- this.block = new AnchorBlock(artifact);
375
- }
376
- block;
377
- append(anchorName, content) {
378
- const lines = this.artifact.content.split("\n");
379
- const anchor = `@anchor:${anchorName}`;
380
- const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
381
- if (anchorIndex === -1) {
382
- throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
383
- }
384
- lines.splice(anchorIndex + 1, 0, content);
385
- this.artifact.content = lines.join("\n");
386
- }
387
- prepend(anchorName, content) {
388
- const lines = this.artifact.content.split("\n");
389
- const anchor = `@anchor:${anchorName}`;
390
- const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
391
- if (anchorIndex === -1) {
392
- throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
393
- }
394
- lines.splice(anchorIndex, 0, content);
395
- this.artifact.content = lines.join("\n");
396
- }
397
- };
398
-
399
- // src/models/artifact.ts
400
- var HeaderComment = [
401
- "// Code generated by keq-cli. DO NOT EDIT.",
402
- "// Code generated by keq-cli. DO NOT EDIT.",
403
- "// Code generated by keq-cli. DO NOT EDIT.",
404
- "",
405
- ""
406
- ].join("\n");
407
- var Artifact = class {
408
- id;
409
- filepath;
410
- content;
411
- extensionName;
412
- anchor = new Anchor(this);
413
- constructor(options) {
414
- this.id = options.id;
415
- this.filepath = options.filepath;
416
- this.extensionName = options.extensionName || path3.extname(options.filepath);
417
- this.content = options.content;
418
- }
419
- get dirname() {
420
- return path3.dirname(this.filepath);
421
- }
422
- renderer() {
423
- return `${HeaderComment}${this.content}`;
424
- }
425
- };
426
-
427
- // src/models/api-document_v3_1.ts
428
- var R5 = __toESM(require("ramda"), 1);
429
-
430
- // src/models/module-definition.ts
431
- var ModuleDefinition = class _ModuleDefinition {
432
- name;
433
- address;
434
- constructor(name, address) {
435
- this.name = name;
436
- this.address = address;
437
- }
438
- static unknown() {
439
- return new _ModuleDefinition("", "");
440
- }
441
- };
442
-
443
- // src/models/operation-definition.ts
444
- var R4 = __toESM(require("ramda"), 1);
445
-
446
- // src/utils/is-keywords.ts
447
- var keywords = [
448
- "break",
449
- "case",
450
- "catch",
451
- "continue",
452
- "default",
453
- "delete",
454
- "do",
455
- "else",
456
- "finally",
457
- "for",
458
- "function",
459
- "if",
460
- "in",
461
- "instanceof",
462
- "new",
463
- "return",
464
- "switch",
465
- "this",
466
- "throw",
467
- "try",
468
- "typeof",
469
- "var",
470
- "void",
471
- "while",
472
- "with"
473
- ];
474
- function isKeywords(str) {
475
- return keywords.includes(str);
45
+ //#endregion
46
+ //#region src/commands/build.ts
47
+ function registerBuildCommand(program) {
48
+ program.command("build").description("Build and generate API client code from OpenAPI/Swagger specifications").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to generate").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--fresh", "Clean the output directory before building").option("-i --interactive", "Interactive select the scope of generation").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathname>", "Only generate files of the specified operation pathname").action(async (options) => {
49
+ const filterRules = [];
50
+ if (options.module || options.method || options.pathname) filterRules.push({
51
+ deny: true,
52
+ persist: false,
53
+ moduleName: "*",
54
+ operationMethod: "*",
55
+ operationPathname: "/**"
56
+ }, ...xprodFilterRules({
57
+ module: options.module,
58
+ method: options.method,
59
+ pathname: options.pathname,
60
+ persist: false
61
+ }));
62
+ else if (options.interactive) filterRules.push({
63
+ deny: true,
64
+ persist: false,
65
+ moduleName: "*",
66
+ operationMethod: "*",
67
+ operationPathname: "/**"
68
+ });
69
+ await new require_compiler.Compiler({
70
+ build: true,
71
+ persist: true,
72
+ fresh: !!options.fresh,
73
+ config: options.config,
74
+ debug: !!options.debug,
75
+ tolerant: !!options.tolerant,
76
+ interactive: !!options.interactive && { mode: "allow" },
77
+ filter: filterRules.length > 0 ? { rules: filterRules } : void 0
78
+ }).run();
79
+ });
476
80
  }
477
-
478
- // src/utils/is-reserved-word.ts
479
- var reservedWords = [
480
- "abstract",
481
- "boolean",
482
- "byte",
483
- "char",
484
- "class",
485
- "const",
486
- "debugger",
487
- "double",
488
- "enum",
489
- "export",
490
- "extends",
491
- "final",
492
- "float",
493
- "goto",
494
- "implements",
495
- "import",
496
- "int",
497
- "interface",
498
- "long",
499
- "native",
500
- "package",
501
- "private",
502
- "protected",
503
- "public",
504
- "short",
505
- "static",
506
- "super",
507
- "synchronized",
508
- "throws",
509
- "transient",
510
- "volatile"
511
- ];
512
- function isReservedWord(str) {
513
- return reservedWords.includes(str);
81
+ //#endregion
82
+ //#region src/commands/filter.ts
83
+ function registerFilterCommand(program) {
84
+ program.command("filter").description("Manage filter rules for API generation using .keqfilter file").addArgument(new commander.Argument("<mode>", "The filter mode").choices([
85
+ "all",
86
+ "deny",
87
+ "allow"
88
+ ]).argRequired()).option("-c --config <config>", "The keq-cli config file").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--module <modules...>").option("--build", "Build after updating .keqfilter file").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").option("-i --interactive", "Interactive select the scope of generation").action(async (mode, options) => {
89
+ let compiler;
90
+ if (mode === "all") {
91
+ if (options.build) throw new Error("'--build' cannot be used with 'all' mode");
92
+ if (options.interactive) throw new Error("'--interactive' cannot be used with 'all' mode");
93
+ if (options.module) throw new Error("'--module' cannot be used with 'all' mode");
94
+ if (options.method) throw new Error("'--method' cannot be used with 'all' mode");
95
+ if (options.pathname) throw new Error("'--pathname' cannot be used with 'all' mode");
96
+ compiler = new require_compiler.Compiler({
97
+ build: false,
98
+ persist: true,
99
+ config: options.config,
100
+ debug: !!options.debug,
101
+ tolerant: !!options.tolerant,
102
+ interactive: false,
103
+ filter: { rules: [{
104
+ persist: true,
105
+ deny: true,
106
+ moduleName: "*",
107
+ operationMethod: "*",
108
+ operationPathname: "/**"
109
+ }] }
110
+ });
111
+ } else if (options.interactive) {
112
+ if (options.interactive) {
113
+ if (options.method) throw new Error("'--method' cannot be used with '--interactive'");
114
+ if (options.pathname) throw new Error("'--pathname' cannot be used with '--interactive'");
115
+ }
116
+ compiler = new require_compiler.Compiler({
117
+ build: !!options.build,
118
+ persist: true,
119
+ config: options.config,
120
+ debug: !!options.debug,
121
+ tolerant: !!options.tolerant,
122
+ interactive: {
123
+ mode,
124
+ persist: true
125
+ },
126
+ filter: { rules: [{
127
+ persist: false,
128
+ deny: true,
129
+ moduleName: "*",
130
+ operationMethod: "*",
131
+ operationPathname: "/**"
132
+ }] }
133
+ });
134
+ } else {
135
+ if (!options.method && !options.pathname) throw new Error("at least one of '-i --interactive', '--method' or '--pathname' must be specified");
136
+ const moduleNames = options.module || ["*"];
137
+ compiler = new require_compiler.Compiler({
138
+ build: !!options.build,
139
+ persist: true,
140
+ config: options.config,
141
+ debug: !!options.debug,
142
+ tolerant: !!options.tolerant,
143
+ filter: { rules: moduleNames.map((moduleNames) => ({
144
+ persist: true,
145
+ deny: mode === "deny",
146
+ moduleName: moduleNames,
147
+ operationMethod: options.method,
148
+ operationPathname: options.pathname
149
+ })) },
150
+ interactive: false
151
+ });
152
+ }
153
+ await compiler.run();
154
+ });
514
155
  }
515
-
516
- // src/models/operation-definition.ts
517
- var import_jsonpath_plus2 = require("jsonpath-plus");
518
-
519
- // src/models/schema-definition.ts
520
- var R3 = __toESM(require("ramda"), 1);
521
- var import_jsonpath_plus = require("jsonpath-plus");
522
- var SchemaDefinition = class _SchemaDefinition {
523
- name;
524
- schema;
525
- module;
526
- document;
527
- get id() {
528
- return `${this.module.address}#/components/schemas/${this.name}`;
529
- }
530
- constructor(args) {
531
- this.module = args.module;
532
- this.name = args.name;
533
- this.schema = args.schema;
534
- this.document = args.document;
535
- }
536
- getDependencies() {
537
- const refs = R3.uniq((0, import_jsonpath_plus.JSONPath)({
538
- path: "$..*['$ref']",
539
- json: this.schema
540
- }));
541
- return refs.filter((ref) => typeof ref === "string" && !!ref.trim()).map((ref) => {
542
- const definition = this.document.dereference(ref);
543
- if (definition) return definition;
544
- return _SchemaDefinition.unknown();
545
- });
546
- }
547
- static unknown() {
548
- return new _SchemaDefinition({
549
- name: "",
550
- schema: {},
551
- module: ModuleDefinition.unknown(),
552
- document: ApiDocumentV3_1.unknown()
553
- });
554
- }
555
- static isUnknown(definition) {
556
- return definition.name === "";
557
- }
558
- };
559
-
560
- // src/models/operation-definition.ts
561
- var OperationDefinition = class {
562
- module;
563
- operationId;
564
- method;
565
- pathname;
566
- operation;
567
- document;
568
- get id() {
569
- return `${this.module.address}#/paths/${this.pathname}/${this.method}`;
570
- }
571
- constructor(args) {
572
- this.module = args.module;
573
- this.method = args.method.toLowerCase();
574
- this.pathname = args.pathname;
575
- this.document = args.document;
576
- this.operationId = this.formatOperationId(args.method, args.pathname, args.operation);
577
- this.operation = {
578
- ...args.operation,
579
- operationId: this.operationId
580
- };
581
- }
582
- formatOperationId(method, pathname, operation) {
583
- const operationId = operation.operationId;
584
- if (operationId && operationId !== "index" && !isKeywords(operationId) && !isReservedWord(operationId)) {
585
- return operationId;
586
- }
587
- return `${method}_${pathname}`.replace(/\//g, "_").replace(/-/g, "_").replace(/:/g, "$$").replace(/{(.+)}/, "$$$1");
588
- }
589
- getDependencies() {
590
- const refs = R4.uniq([
591
- ...(0, import_jsonpath_plus2.JSONPath)({
592
- path: "$.requestBody.content..schema..$ref",
593
- json: this.operation
594
- }),
595
- ...(0, import_jsonpath_plus2.JSONPath)({
596
- path: "$.responses..content..schema..$ref",
597
- json: this.operation
598
- }),
599
- ...(0, import_jsonpath_plus2.JSONPath)({
600
- path: "$.parameters..schema..$ref",
601
- json: this.operation
602
- })
603
- ]);
604
- const dependencies = refs.filter((ref) => typeof ref === "string" && ref).map((ref) => {
605
- const schemaDefinition = this.document.dereference(ref);
606
- if (schemaDefinition) return schemaDefinition;
607
- return SchemaDefinition.unknown();
608
- });
609
- return dependencies;
610
- }
611
- };
612
-
613
- // src/models/api-document_v3_1.ts
614
- var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
615
- module;
616
- specification;
617
- constructor(specification, module2) {
618
- this.module = module2;
619
- this.specification = specification;
620
- }
621
- get schemas() {
622
- const module2 = this.module;
623
- return Object.entries(this.specification.components?.schemas || {}).map(([name, schema]) => new SchemaDefinition({
624
- name,
625
- schema,
626
- module: module2,
627
- document: this
628
- }));
629
- }
630
- get operations() {
631
- const module2 = this.module;
632
- return Object.entries(this.specification.paths || {}).flatMap(([pathname, pathItem]) => Object.entries(pathItem || {}).filter(([method]) => SupportedMethods.includes(method.toLowerCase())).map(([method, operation]) => new OperationDefinition({
633
- method,
634
- pathname,
635
- operation,
636
- module: module2,
637
- document: this
638
- })));
639
- }
640
- isEmpty() {
641
- return R5.isEmpty(this.specification.paths);
642
- }
643
- dereference($ref) {
644
- if ($ref.startsWith("#/")) {
645
- return this.schemas.find((schema) => schema.id.endsWith($ref));
646
- }
647
- logger.warn(`The $ref(${$ref}) is not defined in ${this.module.name} openapi/swagger.`);
648
- }
649
- isRefDefined($ref) {
650
- if ($ref.startsWith("#/")) {
651
- const path13 = $ref.replace("#/", "").split("/");
652
- return R5.path(path13, this.specification) !== void 0;
653
- }
654
- return false;
655
- }
656
- static unknown() {
657
- return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
658
- }
659
- };
660
-
661
- // src/models/asset.ts
662
- var Asset = class {
663
- path;
664
- constructor(path13) {
665
- this.path = path13;
666
- }
667
- };
668
-
669
- // src/exception.ts
670
- var import_ts_custom_error = require("ts-custom-error");
671
- var import_word_wrap = __toESM(require("word-wrap"), 1);
672
- var Exception = class extends import_ts_custom_error.CustomError {
673
- constructor(module2, message) {
674
- const moduleName = typeof module2 === "string" ? module2 : module2.name;
675
- const msg = (0, import_word_wrap.default)(message, { width: 60, indent: " " });
676
- super(`${moduleName} module failed to compile:
677
- ${msg}`);
678
- Object.defineProperty(this, "name", { value: "KeqCLI_Exception" });
679
- }
680
- };
681
-
682
- // src/utils/openapi-utils/dereference.ts
683
- function dereference($ref, swagger) {
684
- let value;
685
- for (const key of $ref.split("/")) {
686
- if (key === "#") {
687
- value = swagger;
688
- } else {
689
- value = value[key];
690
- }
691
- if (!value) break;
692
- }
693
- return value;
156
+ //#endregion
157
+ //#region src/utils/scan-generated-files.ts
158
+ /**
159
+ * Recursively find all files in a directory
160
+ */
161
+ async function findAllFiles(dir, extensions) {
162
+ const results = [];
163
+ async function scan(currentDir) {
164
+ let entries;
165
+ try {
166
+ entries = await fs_extra.default.readdir(currentDir);
167
+ } catch (err) {
168
+ return;
169
+ }
170
+ for (const entry of entries) {
171
+ if (entry === "node_modules" || entry === ".git") continue;
172
+ const fullPath = path.join(currentDir, entry);
173
+ let stat;
174
+ try {
175
+ stat = await fs_extra.default.stat(fullPath);
176
+ } catch (err) {
177
+ continue;
178
+ }
179
+ if (stat.isDirectory()) await scan(fullPath);
180
+ else if (stat.isFile()) if (!extensions) results.push(fullPath);
181
+ else {
182
+ const ext = path.extname(fullPath);
183
+ if (extensions.includes(ext)) results.push(fullPath);
184
+ }
185
+ }
186
+ }
187
+ await scan(dir);
188
+ return results;
694
189
  }
695
-
696
- // src/utils/openapi-utils/dereference-operation.ts
697
- var R8 = __toESM(require("ramda"), 1);
698
- var import_jsonpointer2 = __toESM(require("jsonpointer"), 1);
699
- var import_jsonpath_plus4 = require("jsonpath-plus");
700
-
701
- // src/utils/openapi-utils/remove-undefined-ref.ts
702
- var R7 = __toESM(require("ramda"), 1);
703
- var import_jsonpointer = __toESM(require("jsonpointer"), 1);
704
- var import_jsonpath_plus3 = require("jsonpath-plus");
705
-
706
- // src/utils/openapi-utils/is-ref-defined.ts
707
- var R6 = __toESM(require("ramda"), 1);
708
- function isRefDefined($ref, swagger) {
709
- if ($ref.startsWith("#/")) {
710
- const path13 = $ref.replace("#/", "").split("/");
711
- return R6.path(path13, swagger) !== void 0;
712
- }
713
- return false;
190
+ /**
191
+ * Scan all files in the output directory
192
+ * @param outdir The output directory to scan
193
+ * @returns List of all files with their paths
194
+ */
195
+ async function scanAllFiles(outdir) {
196
+ const absoluteOutdir = path.resolve(outdir);
197
+ if (!await fs_extra.default.exists(absoluteOutdir)) return [];
198
+ return (await findAllFiles(absoluteOutdir)).map((file) => ({
199
+ absolutePath: file,
200
+ relativePath: path.relative(absoluteOutdir, file)
201
+ }));
714
202
  }
715
-
716
- // src/utils/openapi-utils/remove-undefined-ref.ts
717
- function removeUndefinedRef(swagger) {
718
- const shadow = R7.clone(swagger);
719
- const matches = (0, import_jsonpath_plus3.JSONPath)({
720
- path: "$..*['$ref']^",
721
- json: swagger,
722
- resultType: "all"
723
- });
724
- for (const match of matches) {
725
- if (match.value.$ref && !isRefDefined(match.value.$ref, swagger)) {
726
- import_jsonpointer.default.set(shadow, match.pointer, R7.omit(["$ref"], match.value));
727
- }
728
- }
729
- return shadow;
203
+ /**
204
+ * Find invalid files that are not in the current artifacts list
205
+ * This includes both non-generated files and outdated generated files
206
+ * @param outdir The output directory
207
+ * @param validFilePaths List of valid file paths (relative to outdir)
208
+ * @returns List of invalid files
209
+ */
210
+ async function findInvalidFiles(outdir, validFilePaths) {
211
+ const allFiles = await scanAllFiles(outdir);
212
+ const validPathsSet = new Set(validFilePaths.map((p) => path.normalize(p)));
213
+ return allFiles.filter((file) => {
214
+ const normalizedPath = path.normalize(file.relativePath);
215
+ return !validPathsSet.has(normalizedPath);
216
+ });
730
217
  }
731
-
732
- // src/utils/openapi-utils/dereference-operation.ts
733
- function dereferencePathObject(swagger) {
734
- const matches = (0, import_jsonpath_plus4.JSONPath)({
735
- path: "$.paths.*.$ref^",
736
- json: swagger,
737
- resultType: "all"
738
- });
739
- for (const match of matches) {
740
- const value = dereference(match.value.$ref, swagger);
741
- import_jsonpointer2.default.set(swagger, match.pointer, value);
742
- }
218
+ //#endregion
219
+ //#region src/commands/list.ts
220
+ function registerListCommand(program) {
221
+ program.command("list").description("List generated files based on current configuration").option("-c --config <config>", "The keq-cli config file").option("--invalid", "List only invalid generated files (files not in current build)").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").action(async (options) => {
222
+ const compiler = new require_compiler.Compiler({
223
+ build: true,
224
+ persist: false,
225
+ silent: true,
226
+ config: options.config,
227
+ debug: !!options.debug,
228
+ tolerant: !!options.tolerant
229
+ });
230
+ await compiler.run();
231
+ const context = compiler.context;
232
+ if (!context.rc) throw new Error("Failed to load configuration");
233
+ if (options.invalid) {
234
+ const validFilePaths = (context.artifacts || []).map((artifact) => artifact.filepath);
235
+ const invalidFiles = await findInvalidFiles(context.rc.outdir, validFilePaths);
236
+ for (const file of invalidFiles) {
237
+ const fullPath = `./${path.join(context.rc.outdir, file.relativePath)}`;
238
+ console.log(fullPath);
239
+ }
240
+ } else {
241
+ const artifacts = context.artifacts || [];
242
+ for (const artifact of artifacts) {
243
+ const fullPath = `./${path.join(context.rc.outdir, artifact.filepath)}`;
244
+ console.log(fullPath);
245
+ }
246
+ }
247
+ });
743
248
  }
744
- function dereferenceRequestBody(swagger) {
745
- const matches = (0, import_jsonpath_plus4.JSONPath)({
746
- path: "$.paths.*.*.requestBody.$ref^",
747
- json: swagger,
748
- resultType: "all"
749
- });
750
- for (const match of matches) {
751
- const value = dereference(match.value.$ref, swagger);
752
- import_jsonpointer2.default.set(swagger, match.pointer, value);
753
- }
249
+ //#endregion
250
+ //#region src/commands/apis.ts
251
+ function registerApisCommand(program) {
252
+ program.command("apis").description("List API operations and components from OpenAPI/Swagger specifications").option("-c --config <config>", "The keq-cli config file").option("--tolerant", "Tolerate wrong swagger/openapi structure").addOption(new commander.Option("--includes <includes...>", "Include specific parts").choices(["operations", "components"])).option("--module <modules...>", "Filter module(s) to list").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").addOption(new commander.Option("--format <format>", "Output format").choices(["compact", "json"])).option("--json", "Output in JSON format (shortcut for --format json)").option("--all", "Ignore .keqfilter rules and show all modules/operations").option("--debug", "Print debug information").action(async (options) => {
253
+ if (options.all && (options.module || options.method || options.pathname)) throw new Error("'--all' cannot be used with '--module', '--method', or '--pathname'");
254
+ const filterRules = [];
255
+ if (options.module || options.method || options.pathname) filterRules.push({
256
+ deny: true,
257
+ persist: false,
258
+ moduleName: "*",
259
+ operationMethod: "*",
260
+ operationPathname: "/**"
261
+ }, ...xprodFilterRules({
262
+ module: options.module,
263
+ method: options.method,
264
+ pathname: options.pathname,
265
+ persist: false
266
+ }));
267
+ const compiler = new require_compiler.Compiler({
268
+ build: true,
269
+ persist: false,
270
+ silent: true,
271
+ config: options.config,
272
+ debug: !!options.debug,
273
+ tolerant: !!options.tolerant,
274
+ filter: options.all ? false : filterRules.length > 0 ? { rules: filterRules } : void 0
275
+ });
276
+ await compiler.run();
277
+ const documents = compiler.context.documents || [];
278
+ const includesList = options.includes || ["operations", "components"];
279
+ const includeOperations = includesList.includes("operations");
280
+ const includeComponents = includesList.includes("components");
281
+ const result = documents.map((document) => {
282
+ const item = { module: document.module.name };
283
+ if (includeOperations) item.operations = document.operations.map((operation) => ({
284
+ method: operation.method.toUpperCase(),
285
+ path: operation.pathname,
286
+ operationId: operation.operationId,
287
+ summary: operation.operation.summary || "",
288
+ description: operation.operation.description || ""
289
+ }));
290
+ if (includeComponents) item.components = { schemas: document.schemas.map((schema) => {
291
+ const schemaObj = schema.schema;
292
+ return {
293
+ name: schema.name,
294
+ description: schemaObj.description || ""
295
+ };
296
+ }) };
297
+ return item;
298
+ });
299
+ const format = options.format || (options.json ? "json" : void 0);
300
+ if (format === "json") console.log(JSON.stringify(result, null, 2));
301
+ else if (format === "compact") {
302
+ for (const item of result) {
303
+ console.log(`\nModule: ${item.module}`);
304
+ console.log("─".repeat(70));
305
+ if (includeOperations) {
306
+ console.log("\n APIs:");
307
+ if (!item.operations || item.operations.length === 0) console.log(" (No APIs)");
308
+ else for (const operation of item.operations) {
309
+ const method = operation.method.padEnd(7);
310
+ const desc = operation.summary || operation.description;
311
+ const descText = desc ? ` ${desc}` : "";
312
+ console.log(` ${method} ${operation.path}${descText}`);
313
+ }
314
+ }
315
+ if (includeComponents) {
316
+ console.log("\n Schemas:");
317
+ if (!item.components || item.components.schemas.length === 0) console.log(" (No Schemas)");
318
+ else for (const schema of item.components.schemas) {
319
+ const desc = schema.description ? ` ${schema.description}` : "";
320
+ console.log(` ${schema.name}${desc}`);
321
+ }
322
+ }
323
+ }
324
+ const totalApis = result.reduce((sum, item) => sum + (item.operations?.length || 0), 0);
325
+ const totalSchemas = result.reduce((sum, item) => sum + (item.components?.schemas.length || 0), 0);
326
+ console.log("\n" + "─".repeat(70));
327
+ const parts = [`${result.length} modules`];
328
+ if (includeOperations) parts.push(`${totalApis} APIs`);
329
+ if (includeComponents) parts.push(`${totalSchemas} Schemas`);
330
+ console.log(`Total: ${parts.join(", ")}`);
331
+ } else {
332
+ for (const item of result) {
333
+ console.log(`\nModule: ${item.module}`);
334
+ console.log("─".repeat(70));
335
+ if (includeOperations) {
336
+ console.log("\n APIs:");
337
+ if (!item.operations || item.operations.length === 0) console.log(" (No APIs)");
338
+ else for (const operation of item.operations) {
339
+ const method = operation.method.padEnd(7);
340
+ console.log(` ${method} ${operation.path}`);
341
+ const desc = operation.summary || operation.description;
342
+ if (desc) console.log(` ${desc}`);
343
+ }
344
+ }
345
+ if (includeComponents) {
346
+ console.log("\n Schemas:");
347
+ if (!item.components || item.components.schemas.length === 0) console.log(" (No Schemas)");
348
+ else for (const schema of item.components.schemas) {
349
+ console.log(` ${schema.name}`);
350
+ if (schema.description) console.log(` ${schema.description}`);
351
+ }
352
+ }
353
+ }
354
+ const totalApis = result.reduce((sum, item) => sum + (item.operations?.length || 0), 0);
355
+ const totalSchemas = result.reduce((sum, item) => sum + (item.components?.schemas.length || 0), 0);
356
+ console.log("\n" + "─".repeat(70));
357
+ const parts = [`${result.length} modules`];
358
+ if (includeOperations) parts.push(`${totalApis} APIs`);
359
+ if (includeComponents) parts.push(`${totalSchemas} Schemas`);
360
+ console.log(`Total: ${parts.join(", ")}`);
361
+ }
362
+ });
754
363
  }
755
- function dereferenceResponses(swagger) {
756
- const matches = [
757
- ...(0, import_jsonpath_plus4.JSONPath)({
758
- path: "$.paths.*.*.responses.*.$ref^",
759
- json: swagger,
760
- resultType: "all"
761
- }),
762
- ...(0, import_jsonpath_plus4.JSONPath)({
763
- path: "$.paths.*.*.responses.*.headers.*.$ref^",
764
- json: swagger,
765
- resultType: "all"
766
- })
767
- ];
768
- for (const match of matches) {
769
- const value = dereference(match.value.$ref, swagger);
770
- import_jsonpointer2.default.set(swagger, match.pointer, value);
771
- }
364
+ //#endregion
365
+ //#region src/commands/mock.ts
366
+ function registerMockCommand(program) {
367
+ program.command("mock").description("Start a mock server based on OpenAPI specifications").option("-c --config <config>", "The keq-cli config file").option("-p --port <port>", "Port to listen on", "3939").option("--host <host>", "Host to bind to", "localhost").option("--module <modules...>", "Filter module(s) to mock").option("--cors", "Enable CORS headers", true).option("--delay <delay>", "Response delay in ms (or min-max range like \"100-500\")").option("--max-depth <depth>", "Max schema depth for mock data generation", "10").option("--ref-depth <depth>", "Max $ref recursion depth for circular schemas", "5").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").action(async (options) => {
368
+ const { mockCommand } = await Promise.resolve().then(() => require("./mock-command-WZcfy5Iq.cjs"));
369
+ await mockCommand(options);
370
+ });
772
371
  }
773
- function dereferenceParameters(swagger) {
774
- const matches = (0, import_jsonpath_plus4.JSONPath)({
775
- path: "$.paths.*.*.parameters.*.$ref^",
776
- json: swagger,
777
- resultType: "all"
778
- });
779
- for (const match of matches) {
780
- const value = dereference(match.value.$ref, swagger);
781
- import_jsonpointer2.default.set(swagger, match.pointer, value);
782
- }
372
+ //#endregion
373
+ //#region src/commands/init.ts
374
+ function registerInitCommand(program) {
375
+ program.command("init").description("Initialize keq configuration file").option("-f --force", "Force overwrite existing config file").action(async (options) => {
376
+ const { initConfig } = await Promise.resolve().then(() => require("./init-DqxLcRSQ.cjs"));
377
+ await initConfig(options);
378
+ });
783
379
  }
784
- function dereferenceOperation(swagger) {
785
- const shadow = R8.clone(swagger);
786
- dereferencePathObject(shadow);
787
- dereferenceRequestBody(shadow);
788
- dereferenceResponses(shadow);
789
- dereferenceParameters(shadow);
790
- return removeUndefinedRef(shadow);
380
+ //#endregion
381
+ //#region src/search/embedder.ts
382
+ const MODEL_NAME = "intfloat/multilingual-e5-small";
383
+ const CACHE_DIR = path.default.join(os.default.homedir(), ".cache", "keq", "models");
384
+ let transformers = null;
385
+ let loadError = null;
386
+ let extractor = null;
387
+ var EmbedderUnavailableError = class extends Error {
388
+ constructor(cause) {
389
+ super("@huggingface/transformers is not installed. Semantic search is unavailable.\nRun `pnpm add @huggingface/transformers` to enable this feature.");
390
+ this.name = "EmbedderUnavailableError";
391
+ if (cause) this.cause = cause;
392
+ }
393
+ };
394
+ async function loadTransformers() {
395
+ if (transformers) return transformers;
396
+ if (loadError) throw new EmbedderUnavailableError(loadError);
397
+ try {
398
+ transformers = await import("@huggingface/transformers");
399
+ return transformers;
400
+ } catch (e) {
401
+ loadError = e instanceof Error ? e : new Error(String(e));
402
+ throw new EmbedderUnavailableError(loadError);
403
+ }
791
404
  }
792
-
793
- // src/utils/json-schema-utils/is-array.ts
794
- function isArray(schema) {
795
- return schema.type === "array";
405
+ async function getEmbedder() {
406
+ if (extractor) return extractor;
407
+ const { pipeline, env } = await loadTransformers();
408
+ env.cacheDir = CACHE_DIR;
409
+ env.allowLocalModels = true;
410
+ extractor = await pipeline("feature-extraction", MODEL_NAME, { dtype: "fp32" });
411
+ return extractor;
796
412
  }
797
-
798
- // src/utils/json-schema-utils/is-mixed.ts
799
- function isMixed(schema) {
800
- return Array.isArray(schema.type);
413
+ async function embed(texts) {
414
+ return (await (await getEmbedder())(texts.map((t) => `query: ${t}`), {
415
+ pooling: "mean",
416
+ normalize: true
417
+ })).tolist().map((vec) => new Float32Array(vec));
801
418
  }
802
-
803
- // src/utils/json-schema-utils/is-non-array.ts
804
- function isNonArray(schema) {
805
- return typeof schema.type === "string" && schema.type !== "array";
419
+ async function embedDocuments(texts) {
420
+ return (await (await getEmbedder())(texts.map((t) => `passage: ${t}`), {
421
+ pooling: "mean",
422
+ normalize: true
423
+ })).tolist().map((vec) => new Float32Array(vec));
806
424
  }
807
-
808
- // src/utils/json-schema-utils/is-ref.ts
809
- function isRef(schema) {
810
- return "$ref" in schema;
425
+ function cosineSimilarity(a, b) {
426
+ let dot = 0;
427
+ for (let i = 0; i < a.length; i++) dot += a[i] * b[i];
428
+ return dot;
811
429
  }
812
-
813
- // src/utils/json-schema-utils/index.ts
814
- var JsonSchemaUtils = class {
815
- static isRef = isRef;
816
- static isArray = isArray;
817
- static isNonArray = isNonArray;
818
- static isMixed = isMixed;
430
+ //#endregion
431
+ //#region src/search/search-engine.ts
432
+ var SearchEngine = class {
433
+ operations = [];
434
+ async buildIndex(documents) {
435
+ this.operations = [];
436
+ for (const document of documents) for (const op of document.operations) {
437
+ const tags = op.operation.tags || [];
438
+ const summary = op.operation.summary || "";
439
+ const description = op.operation.description || "";
440
+ const text = [
441
+ op.method.toUpperCase(),
442
+ op.pathname,
443
+ op.operationId,
444
+ summary,
445
+ description,
446
+ ...tags
447
+ ].filter(Boolean).join(" ");
448
+ this.operations.push({
449
+ id: `${document.module.name}:${op.method}:${op.pathname}`,
450
+ module: document.module.name,
451
+ method: op.method.toUpperCase(),
452
+ pathname: op.pathname,
453
+ operationId: op.operationId,
454
+ summary,
455
+ description,
456
+ tags,
457
+ text,
458
+ operation: op.operation
459
+ });
460
+ }
461
+ const embeddings = await embedDocuments(this.operations.map((op) => op.text));
462
+ for (let i = 0; i < this.operations.length; i++) this.operations[i].embedding = embeddings[i];
463
+ }
464
+ async search(query, options) {
465
+ const limit = options?.limit ?? 10;
466
+ const modules = options?.module;
467
+ let candidates = this.operations;
468
+ if (modules && modules.length > 0) candidates = candidates.filter((op) => modules.includes(op.module));
469
+ if (candidates.length === 0) return [];
470
+ const [queryEmbedding] = await embed([query]);
471
+ return candidates.filter((op) => op.embedding).map((op) => ({
472
+ op,
473
+ score: cosineSimilarity(queryEmbedding, op.embedding)
474
+ })).sort((a, b) => b.score - a.score).slice(0, limit).map(({ op, score }) => ({
475
+ score: Math.round(score * 1e3) / 1e3,
476
+ module: op.module,
477
+ method: op.method,
478
+ pathname: op.pathname,
479
+ operationId: op.operationId,
480
+ summary: op.summary,
481
+ description: op.description,
482
+ tags: op.tags
483
+ }));
484
+ }
485
+ getDetail(module, method, pathname) {
486
+ const op = this.operations.find((o) => o.module === module && o.method === method.toUpperCase() && o.pathname === pathname);
487
+ if (!op) return void 0;
488
+ const operation = op.operation;
489
+ return {
490
+ score: 1,
491
+ module: op.module,
492
+ method: op.method,
493
+ pathname: op.pathname,
494
+ operationId: op.operationId,
495
+ summary: op.summary,
496
+ description: op.description,
497
+ tags: op.tags,
498
+ parameters: operation.parameters || [],
499
+ requestBody: operation.requestBody || null,
500
+ responses: operation.responses || null
501
+ };
502
+ }
503
+ listModules() {
504
+ return [...new Set(this.operations.map((op) => op.module))];
505
+ }
819
506
  };
820
-
821
- // src/utils/openapi-utils/dereference-deep.ts
822
- function dereferenceDeep($ref, swagger) {
823
- const stack = [$ref];
824
- let value;
825
- while (true) {
826
- const last2 = stack[stack.length - 1];
827
- value = dereference(last2, swagger);
828
- if (JsonSchemaUtils.isRef(value)) {
829
- if (!stack.includes(value.$ref)) {
830
- stack.push(value.$ref);
831
- continue;
832
- } else {
833
- throw new Error(`Circular reference detected: ${stack.join(" -> ")} -> ${value.$ref}`);
834
- }
835
- }
836
- break;
837
- }
838
- return value;
839
- }
840
-
841
- // src/utils/openapi-utils/to-3_1.ts
842
- var import_openapi_parser = require("@scalar/openapi-parser");
843
- function To3_1(openapi) {
844
- const { specification } = (0, import_openapi_parser.upgrade)(openapi);
845
- return specification;
507
+ //#endregion
508
+ //#region src/commands/search.ts
509
+ function registerSearchCommand(program) {
510
+ program.command("search").description("Semantic search for API operations using natural language").argument("<query>", "Natural language search query").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to search").option("--limit <limit>", "Maximum number of results", "10").option("--detail", "Include full request/response schema in results").addOption(new commander.Option("--format <format>", "Output format").choices(["json", "compact"]).default("json")).option("--all", "Ignore .keqfilter rules").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--debug", "Print debug information").action(async (query, options) => {
511
+ const filterRules = [];
512
+ if (options.module && !options.all) filterRules.push({
513
+ deny: true,
514
+ persist: false,
515
+ moduleName: "*",
516
+ operationMethod: "*",
517
+ operationPathname: "/**"
518
+ }, ...xprodFilterRules({
519
+ module: options.module,
520
+ persist: false
521
+ }));
522
+ const compiler = new require_compiler.Compiler({
523
+ build: true,
524
+ persist: false,
525
+ silent: true,
526
+ config: options.config,
527
+ debug: !!options.debug,
528
+ tolerant: !!options.tolerant,
529
+ filter: options.all ? false : filterRules.length > 0 ? { rules: filterRules } : void 0
530
+ });
531
+ await compiler.run();
532
+ const documents = compiler.context.documents || [];
533
+ const engine = new SearchEngine();
534
+ try {
535
+ await engine.buildIndex(documents);
536
+ } catch (e) {
537
+ if (e instanceof EmbedderUnavailableError) {
538
+ console.error(e.message);
539
+ process.exit(1);
540
+ }
541
+ throw e;
542
+ }
543
+ const limit = parseInt(options.limit, 10);
544
+ const results = await engine.search(query, {
545
+ limit,
546
+ module: options.module
547
+ });
548
+ if (options.detail) printResults(results.map((r) => {
549
+ return engine.getDetail(r.module, r.method, r.pathname) || r;
550
+ }), options.format);
551
+ else printResults(results, options.format);
552
+ });
846
553
  }
847
-
848
- // src/utils/openapi-utils/map-operation.ts
849
- var R9 = __toESM(require("ramda"), 1);
850
- function mapOperation(specification, mapper) {
851
- const shadow = R9.clone(specification);
852
- for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {
853
- for (const m in pathItem) {
854
- const method = m.toLowerCase();
855
- if (!SupportedMethods.includes(method)) continue;
856
- if (typeof pathItem[m] !== "object" || Array.isArray(pathItem[m]) || pathItem[m] === null) continue;
857
- const operation = pathItem[m];
858
- pathItem[m] = mapper(method, pathname, operation);
859
- }
860
- }
861
- return shadow;
554
+ function printResults(results, format) {
555
+ if (format === "json") console.log(JSON.stringify({
556
+ results,
557
+ total: results.length
558
+ }, null, 2));
559
+ else {
560
+ for (const r of results) {
561
+ const method = String(r.method).padEnd(7);
562
+ const score = String(r.score);
563
+ console.log(` [${score}] ${method} ${String(r.pathname)}`);
564
+ if (typeof r.summary === "string") console.log(` ${r.summary}`);
565
+ console.log(` ${String(r.module)} | ${String(r.operationId)}`);
566
+ console.log();
567
+ }
568
+ console.log(`Total: ${results.length} results`);
569
+ }
862
570
  }
863
-
864
- // src/utils/openapi-utils/map-parameter.ts
865
- function mapParameter(specification, mapper) {
866
- return mapOperation(specification, (method, pathname, operation) => {
867
- if (!operation.parameters) return operation;
868
- operation.parameters = operation.parameters.map((parameter) => mapper(method, pathname, operation, parameter));
869
- return operation;
870
- });
871
- }
872
-
873
- // src/utils/openapi-utils/index.ts
874
- var OpenapiUtils = class {
875
- static isRefDefined = isRefDefined;
876
- static dereference = dereference;
877
- static dereferenceDeep = dereferenceDeep;
878
- static removeUndefinedRef = removeUndefinedRef;
879
- static dereferenceOperation = dereferenceOperation;
880
- static mapOperation = mapOperation;
881
- static mapParameter = mapParameter;
882
- // static updateOperationId = updateOperationId
883
- static to3_1 = To3_1;
571
+ //#endregion
572
+ //#region src/mcp/compiler-provider.ts
573
+ /**
574
+ * Manages the Compiler lifecycle with automatic lazy reload.
575
+ * Tracks .keqrc and .keqfilter for changes; getters transparently
576
+ * re-compile when config files are modified, with built-in concurrency protection.
577
+ */
578
+ var CompilerProvider = class CompilerProvider {
579
+ tracker = new require_plugins.FileTracker();
580
+ _engine = new SearchEngine();
581
+ _engineAvailable = false;
582
+ _documents = [];
583
+ _context = {};
584
+ _matcher = new require_compiler.Matcher([]);
585
+ _keqfilterPath = "";
586
+ _configPath = "";
587
+ _loaded = false;
588
+ _loadPromise = null;
589
+ options;
590
+ constructor(options) {
591
+ this.options = options;
592
+ }
593
+ get configPath() {
594
+ return this._configPath;
595
+ }
596
+ static async init(options) {
597
+ const provider = new CompilerProvider(options);
598
+ const explore = (0, cosmiconfig.cosmiconfig)("keq");
599
+ const result = options.config ? await explore.load(options.config) : await explore.search();
600
+ if (!result) throw new Error("Cannot find config file.");
601
+ const configFilepath = result.filepath;
602
+ const keqfilterPath = path.default.resolve(path.default.dirname(configFilepath), ".keqfilter");
603
+ provider._keqfilterPath = keqfilterPath;
604
+ provider._configPath = configFilepath;
605
+ await provider.tracker.track(configFilepath);
606
+ await provider.tracker.track(keqfilterPath);
607
+ return provider;
608
+ }
609
+ async getDocuments() {
610
+ await this.ensureLoaded();
611
+ return this._documents;
612
+ }
613
+ async getEngine() {
614
+ await this.ensureLoaded();
615
+ if (!this._engineAvailable) throw new EmbedderUnavailableError();
616
+ return this._engine;
617
+ }
618
+ async getContext() {
619
+ await this.ensureLoaded();
620
+ return this._context;
621
+ }
622
+ async getMatcher() {
623
+ await this.ensureLoaded();
624
+ return this._matcher;
625
+ }
626
+ async invalidate() {
627
+ await this.tracker.forceReload(() => this.reload());
628
+ }
629
+ async ensureLoaded() {
630
+ if (this._loaded) {
631
+ await this.tracker.ensureFresh(() => this.reload());
632
+ return;
633
+ }
634
+ if (this._loadPromise) {
635
+ await this._loadPromise;
636
+ return;
637
+ }
638
+ this._loadPromise = this.reload().finally(() => {
639
+ this._loadPromise = null;
640
+ });
641
+ await this._loadPromise;
642
+ }
643
+ async reload() {
644
+ const { config, debug, tolerant } = this.options;
645
+ const compiler = new require_compiler.Compiler({
646
+ build: true,
647
+ persist: false,
648
+ silent: true,
649
+ config,
650
+ debug,
651
+ tolerant,
652
+ filter: false
653
+ });
654
+ await compiler.run();
655
+ this._context = compiler.context;
656
+ this._documents = compiler.context.documents || [];
657
+ try {
658
+ await this._engine.buildIndex(this._documents);
659
+ this._engineAvailable = true;
660
+ } catch (e) {
661
+ if (e instanceof EmbedderUnavailableError) this._engineAvailable = false;
662
+ else throw e;
663
+ }
664
+ if (await fs_extra.default.exists(this._keqfilterPath)) this._matcher = await require_compiler.Matcher.read(this._keqfilterPath);
665
+ else this._matcher = new require_compiler.Matcher([]);
666
+ await this.tracker.snapshot();
667
+ this._loaded = true;
668
+ }
884
669
  };
885
-
886
- // src/compiler/tasks/download/index.ts
887
- function main2(compiler, options) {
888
- return {
889
- task: (context, task) => {
890
- if (!context.rc || !context.matcher) {
891
- throw new Error("Please run setup task first.");
892
- }
893
- const rc = context.rc;
894
- const matcher = context.matcher;
895
- context.documents = [];
896
- return task.newListr(
897
- Object.entries(rc.modules).map(([moduleName, address]) => new ModuleDefinition(moduleName, address)).map((moduleDefinition) => ({
898
- title: moduleDefinition.name,
899
- task: async (ctx, task2) => {
900
- if (options?.skipIgnoredModules && matcher.isModuleIgnored(moduleDefinition)) {
901
- task2.skip(`(${moduleDefinition.name}) is ignored`);
902
- return;
903
- }
904
- task2.output = `Downloaded from ${moduleDefinition.address}`;
905
- const content = await compiler.hooks.download.promise(moduleDefinition.address, moduleDefinition, task2);
906
- if (!content) {
907
- throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`);
908
- }
909
- const spec = JSON.parse(content);
910
- const { valid, errors } = await (0, import_openapi_parser2.validate)(spec);
911
- if (!valid) {
912
- const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
913
- ${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
914
- task2.output = message;
915
- }
916
- OpenapiUtils.dereferenceOperation(spec);
917
- const document = new ApiDocumentV3_1(
918
- spec,
919
- moduleDefinition
920
- );
921
- ctx.documents?.push(document);
922
- }
923
- })),
924
- {
925
- concurrent: true,
926
- exitOnError: false,
927
- collectErrors: "minimal",
928
- rendererOptions: {
929
- collapseSubtasks: false,
930
- // collapseSkips: false,
931
- suffixSkips: true,
932
- timer: import_listr2.PRESET_TIMER
933
- }
934
- }
935
- );
936
- }
937
- };
938
- }
939
- function createDownloadTask(compiler, options) {
940
- return {
941
- title: "Download",
942
- enabled: options?.enabled,
943
- skip: options?.skip,
944
- task: (_, task) => task.newListr(
945
- [
946
- main2(compiler, options),
947
- {
948
- task: (context, task2) => compiler.hooks.afterDownload.promise(task2)
949
- }
950
- ],
951
- {
952
- concurrent: false
953
- }
954
- )
955
- };
956
- }
957
-
958
- // src/compiler/tasks/persist/index.ts
959
- var path6 = __toESM(require("path"), 1);
960
- var import_fs_extra3 = __toESM(require("fs-extra"), 1);
961
- function createPersistArtifactTask() {
962
- return {
963
- title: "Write files",
964
- task: async (context, task) => {
965
- if (!context.rc) throw new Error("Please run setup task first.");
966
- if (!context.artifacts || context.artifacts.length === 0) {
967
- task.skip("No compiled artifacts to persist.");
968
- return;
969
- }
970
- const rc = context.rc;
971
- const artifacts = context.artifacts;
972
- const total = artifacts.length;
973
- let completed = 0;
974
- const files = await Promise.all(artifacts.map(async (artifact) => {
975
- const realpath = `./${path6.join(rc.outdir, artifact.filepath)}`;
976
- await import_fs_extra3.default.ensureFile(realpath);
977
- await import_fs_extra3.default.writeFile(realpath, artifact.renderer());
978
- completed += 1;
979
- task.output = `Persisted ${completed}/${total} files`;
980
- return new Asset(path6.resolve(realpath));
981
- }));
982
- context.assets = files;
983
- }
984
- };
985
- }
986
- function createPersistIgnoreTask() {
987
- return {
988
- title: "Update .keqignore",
989
- task: async (context, task) => {
990
- if (!context.matcher) throw new Error("Please run setup task first.");
991
- const matcher = context.matcher;
992
- await matcher.write(".keqignore");
993
- }
994
- };
995
- }
996
- function main3() {
997
- return {
998
- task: (context, task) => task.newListr(
999
- [
1000
- createPersistArtifactTask(),
1001
- createPersistIgnoreTask()
1002
- ],
1003
- {
1004
- concurrent: true,
1005
- rendererOptions: {
1006
- collapseSubtasks: true
1007
- }
1008
- }
1009
- )
1010
- };
1011
- }
1012
- function createPersistTask(compiler, options) {
1013
- return {
1014
- title: "Persist",
1015
- enabled: options?.enabled,
1016
- skip: options?.skip,
1017
- task: (context, task) => task.newListr(
1018
- [
1019
- main3(),
1020
- {
1021
- task: (context2, task2) => compiler.hooks.afterPersist.promise(task2)
1022
- }
1023
- ],
1024
- {
1025
- concurrent: false
1026
- }
1027
- )
1028
- };
1029
- }
1030
-
1031
- // src/compiler/tasks/compile/index.ts
1032
- function main4(compiler) {
1033
- return {
1034
- task: async (context, task) => {
1035
- if (!context.rc) throw new Error("Please run setup task first.");
1036
- if (!context.documents) throw new Error("Please run shaking task first.");
1037
- context.artifacts = [];
1038
- await compiler.hooks.compile.promise(task);
1039
- }
1040
- };
670
+ //#endregion
671
+ //#region src/mcp/find-config-in-dir.ts
672
+ const CONFIG_FILENAMES = [
673
+ ".keqrc",
674
+ ".keqrc.ts",
675
+ ".keqrc.js",
676
+ ".keqrc.mjs",
677
+ ".keqrc.cjs",
678
+ ".keqrc.json",
679
+ ".keqrc.yml",
680
+ ".keqrc.yaml",
681
+ "keq.config.ts",
682
+ "keq.config.js",
683
+ "keq.config.mjs",
684
+ "keq.config.cjs",
685
+ "keq.config.json",
686
+ "keq.config.yml",
687
+ "keq.config.yaml"
688
+ ];
689
+ async function findConfigInDir(dir) {
690
+ for (const filename of CONFIG_FILENAMES) {
691
+ const filePath = path.default.resolve(dir, filename);
692
+ if (await fs_extra.default.pathExists(filePath)) return filePath;
693
+ }
694
+ return null;
1041
695
  }
1042
- function createCompileTask(compiler, options) {
1043
- return {
1044
- title: "Compile",
1045
- enabled: options?.enabled,
1046
- skip: options?.skip,
1047
- task: (context, task) => task.newListr(
1048
- [
1049
- {
1050
- task: (context2, task2) => compiler.hooks.beforeCompile.promise(task2)
1051
- },
1052
- main4(compiler),
1053
- {
1054
- task: (context2, task2) => compiler.hooks.afterCompile.promise(task2)
1055
- }
1056
- ],
1057
- {
1058
- concurrent: false
1059
- }
1060
- )
1061
- };
696
+ //#endregion
697
+ //#region src/mcp/compiler-provider-registry.ts
698
+ /**
699
+ * Manages multiple CompilerProvider instances for monorepo/multi-project support.
700
+ * Lazily initializes providers on first access and dynamically registers new projects
701
+ * when an unknown project directory is requested.
702
+ */
703
+ var CompilerProviderRegistry = class {
704
+ entries = /* @__PURE__ */ new Map();
705
+ providers = /* @__PURE__ */ new Map();
706
+ options;
707
+ constructor(options) {
708
+ this.options = options;
709
+ }
710
+ register(entry) {
711
+ this.entries.set(entry.projectDir, entry);
712
+ }
713
+ has(projectDir) {
714
+ return this.entries.has(projectDir);
715
+ }
716
+ list() {
717
+ return [...this.entries.values()];
718
+ }
719
+ async resolve(projectDir) {
720
+ const entry = await this.resolveEntry(projectDir);
721
+ const cached = this.providers.get(entry.projectDir);
722
+ if (cached) return cached;
723
+ const provider = await CompilerProvider.init({
724
+ config: entry.configPath,
725
+ debug: this.options.debug,
726
+ tolerant: this.options.tolerant
727
+ });
728
+ this.providers.set(entry.projectDir, provider);
729
+ return provider;
730
+ }
731
+ getConfigPath(projectDir) {
732
+ return this.resolveEntrySync(projectDir).configPath;
733
+ }
734
+ async resolveEntry(projectDir) {
735
+ if (!projectDir) return this.resolveDefault();
736
+ if (!path.default.isAbsolute(projectDir)) throw new Error(`The 'project' parameter must be an absolute path. Received: ${projectDir}`);
737
+ const existing = this.entries.get(projectDir);
738
+ if (existing) return existing;
739
+ const configPath = await findConfigInDir(projectDir);
740
+ if (!configPath) throw new Error(`No keqrc config file found in ${projectDir}`);
741
+ const entry = {
742
+ configPath,
743
+ projectDir
744
+ };
745
+ this.register(entry);
746
+ return entry;
747
+ }
748
+ resolveEntrySync(projectDir) {
749
+ if (!projectDir) return this.resolveDefault();
750
+ if (!path.default.isAbsolute(projectDir)) throw new Error(`The 'project' parameter must be an absolute path. Received: ${projectDir}`);
751
+ const existing = this.entries.get(projectDir);
752
+ if (!existing) throw new Error(`No keqrc config file found in ${projectDir}`);
753
+ return existing;
754
+ }
755
+ resolveDefault() {
756
+ if (this.entries.size === 0) throw new Error("No keq project found. Please specify 'project' parameter with the absolute path to your project directory containing a keqrc config file.");
757
+ if (this.entries.size === 1) return this.entries.values().next().value;
758
+ const projects = [...this.entries.values()].map((e) => `- ${e.projectDir} (${path.default.basename(e.configPath)})`).join("\n");
759
+ throw new Error(`This is a monorepo with multiple keq projects. Please specify 'project' parameter with one of the following project directories:\n${projects}`);
760
+ }
761
+ };
762
+ //#endregion
763
+ //#region src/mcp/discover-projects.ts
764
+ async function discoverProjects(config) {
765
+ if (config) {
766
+ const configPath = path.default.resolve(config);
767
+ return [{
768
+ configPath,
769
+ projectDir: path.default.dirname(configPath)
770
+ }];
771
+ }
772
+ const monorepoEntries = await discoverFromMonorepo(process.cwd());
773
+ if (monorepoEntries.length > 0) return monorepoEntries;
774
+ const result = await (0, cosmiconfig.cosmiconfig)("keq").search();
775
+ if (result) return [{
776
+ configPath: result.filepath,
777
+ projectDir: path.default.dirname(result.filepath)
778
+ }];
779
+ return [];
1062
780
  }
1063
-
1064
- // src/compiler/intercepter/print-information.ts
1065
- function proxyTaskWrapper(pluginName, task) {
1066
- return new Proxy(task, {
1067
- set(target, prop2, value) {
1068
- if (prop2 !== "output") {
1069
- return Reflect.set(target, prop2, value);
1070
- }
1071
- target.output = `[Plugin: ${pluginName}] ${value}`;
1072
- return true;
1073
- }
1074
- });
781
+ async function discoverFromMonorepo(root) {
782
+ const workspaceGlobs = await getWorkspaceGlobs(root);
783
+ if (workspaceGlobs.length === 0) return [];
784
+ const dirs = [root, ...await expandWorkspaceGlobs(root, workspaceGlobs)];
785
+ const entries = [];
786
+ for (const dir of dirs) {
787
+ const configPath = await findConfigInDir(dir);
788
+ if (configPath) entries.push({
789
+ configPath,
790
+ projectDir: dir
791
+ });
792
+ }
793
+ return entries;
1075
794
  }
1076
- function printInformation(taskIndex) {
1077
- return {
1078
- register: (tap) => {
1079
- const fn = tap.fn;
1080
- if (tap.type === "promise") {
1081
- tap.fn = (...args) => {
1082
- const task = args[taskIndex];
1083
- const proxyTask = proxyTaskWrapper(tap.name, task);
1084
- args[taskIndex] = proxyTask;
1085
- proxyTask.output = "Processing...";
1086
- return fn(...args);
1087
- };
1088
- }
1089
- if (tap.type === "sync") {
1090
- tap.fn = (...args) => {
1091
- const task = args[taskIndex];
1092
- const proxyTask = proxyTaskWrapper(tap.name, task);
1093
- args[taskIndex] = proxyTask;
1094
- proxyTask.output = "Processing...";
1095
- return fn(...args);
1096
- };
1097
- }
1098
- if (tap.type === "async") {
1099
- tap.fn = (...args) => {
1100
- const task = args[taskIndex];
1101
- const proxyTask = proxyTaskWrapper(tap.name, task);
1102
- args[taskIndex] = proxyTask;
1103
- proxyTask.output = "Processing...";
1104
- return fn(...args);
1105
- };
1106
- }
1107
- return tap;
1108
- }
1109
- };
795
+ async function getWorkspaceGlobs(root) {
796
+ const pnpmWorkspacePath = path.default.join(root, "pnpm-workspace.yaml");
797
+ if (await fs_extra.default.pathExists(pnpmWorkspacePath)) {
798
+ const content = await fs_extra.default.readFile(pnpmWorkspacePath, "utf-8");
799
+ const parsed = js_yaml.load(content);
800
+ if (parsed?.packages) return parsed.packages;
801
+ }
802
+ const packageJsonPath = path.default.join(root, "package.json");
803
+ if (await fs_extra.default.pathExists(packageJsonPath)) {
804
+ const pkg = await fs_extra.default.readJson(packageJsonPath);
805
+ if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
806
+ if (Array.isArray(pkg.workspaces?.packages)) return pkg.workspaces.packages;
807
+ }
808
+ return [];
1110
809
  }
1111
-
1112
- // src/compiler/intercepter/perfect-error-message.ts
1113
- var R10 = __toESM(require("ramda"), 1);
1114
- function perfectErrorMessage() {
1115
- return {
1116
- register: (tap) => {
1117
- const fn = tap.fn;
1118
- function prefix(err) {
1119
- if (err instanceof Error) {
1120
- err.message = `[Plugin: ${tap.name}] ${err.message}`;
1121
- }
1122
- }
1123
- if (tap.type === "promise") {
1124
- tap.fn = async (...args) => {
1125
- try {
1126
- return await fn(...args);
1127
- } catch (err) {
1128
- prefix(err);
1129
- throw err;
1130
- }
1131
- };
1132
- }
1133
- if (tap.type === "sync") {
1134
- tap.fn = (...args) => {
1135
- try {
1136
- return fn(...args);
1137
- } catch (err) {
1138
- prefix(err);
1139
- throw err;
1140
- }
1141
- };
1142
- }
1143
- if (tap.type === "async") {
1144
- tap.fn = (...args) => {
1145
- const callback = R10.last(args);
1146
- return fn(...R10.init(args), (err, result) => {
1147
- prefix(err);
1148
- return callback(err, result);
1149
- });
1150
- };
1151
- }
1152
- return tap;
1153
- }
1154
- };
810
+ async function expandWorkspaceGlobs(root, globs) {
811
+ const dirs = [];
812
+ for (const glob of globs) {
813
+ const parts = glob.split("/");
814
+ const baseParts = [];
815
+ let globPart = "";
816
+ for (let i = 0; i < parts.length; i++) {
817
+ if (parts[i].includes("*") || parts[i].includes("{") || parts[i].includes("?")) {
818
+ globPart = parts.slice(i).join("/");
819
+ break;
820
+ }
821
+ baseParts.push(parts[i]);
822
+ }
823
+ const baseDir = path.default.join(root, ...baseParts);
824
+ if (!await fs_extra.default.pathExists(baseDir)) continue;
825
+ if (!globPart) {
826
+ const fullPath = path.default.resolve(root, glob);
827
+ if (await fs_extra.default.pathExists(fullPath)) dirs.push(fullPath);
828
+ continue;
829
+ }
830
+ const matcher = (0, picomatch.default)(globPart);
831
+ const candidates = await fs_extra.default.readdir(baseDir, { withFileTypes: true });
832
+ for (const entry of candidates) {
833
+ if (!entry.isDirectory()) continue;
834
+ if (matcher(entry.name)) dirs.push(path.default.join(baseDir, entry.name));
835
+ }
836
+ }
837
+ return dirs;
1155
838
  }
1156
-
1157
- // src/plugins/eslint/index.ts
1158
- var import_eslint = require("eslint");
1159
-
1160
- // src/plugins/prettier/prettier.plugin.ts
1161
- var import_child_process = require("child_process");
1162
- var import_util = require("util");
1163
- var execAsync = (0, import_util.promisify)(import_child_process.exec);
1164
-
1165
- // src/plugins/body-fallback/index.ts
1166
- var R22 = __toESM(require("ramda"), 1);
1167
-
1168
- // src/plugins/generate-micro-function/generate-micro-function.plugin.ts
1169
- var import_tapable2 = require("tapable");
1170
-
1171
- // src/plugins/generate-micro-function/constants/metadata-storage.ts
1172
- var MetadataStorage = /* @__PURE__ */ new WeakMap();
1173
-
1174
- // src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
1175
- var R21 = __toESM(require("ramda"), 1);
1176
- var path10 = __toESM(require("path"), 1);
1177
- var changeCase6 = __toESM(require("change-case"), 1);
1178
-
1179
- // src/plugins/generate-declaration/generate-declaration.plugin.ts
1180
- var import_tapable = require("tapable");
1181
-
1182
- // src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
1183
- var path9 = __toESM(require("path"), 1);
1184
- var changeCase5 = __toESM(require("change-case"), 1);
1185
-
1186
- // src/transformers/json-schema/comment.renderer.ts
1187
- var CommentRenderer = class {
1188
- constructor(schema) {
1189
- this.schema = schema;
1190
- }
1191
- render() {
1192
- const schema = this.schema;
1193
- const lines = ["/**"];
1194
- if (schema.description) {
1195
- const description = schema.description.replace("*/", "*\\/");
1196
- lines.push(...description.split("\n").map((line) => ` * ${line}`));
1197
- }
1198
- if (schema.deprecated) {
1199
- lines.push(" * @deprecated");
1200
- }
1201
- if (schema.readOnly) {
1202
- lines.push(" * @readonly");
1203
- }
1204
- if (schema.format) {
1205
- lines.push(` * @format ${schema.format}`);
1206
- }
1207
- lines.push(" */");
1208
- if (lines.length === 2) return "";
1209
- return lines.join("\n");
1210
- }
1211
- };
1212
-
1213
- // src/transformers/json-schema/declaration.renderer.ts
1214
- var R12 = __toESM(require("ramda"), 1);
1215
-
1216
- // src/utils/indent.ts
1217
- function indent(space, text) {
1218
- if (text === "") return "";
1219
- const indentation = " ".repeat(space);
1220
- return text.split("\n").map((line) => line ? `${indentation}${line}` : line).join("\n");
839
+ //#endregion
840
+ //#region src/commands/mcp.ts
841
+ function getFilterAnnotation(matcher, op) {
842
+ if (op && matcher.isOperationDenied(op)) return "This API is excluded from the code generation list by .keqfilter rules";
843
+ return "This API is included in the code generation list";
1221
844
  }
1222
-
1223
- // src/transformers/json-schema/reference.transformer.ts
1224
- var R11 = __toESM(require("ramda"), 1);
1225
- var ReferenceTransformer = class {
1226
- static toDeclaration(schema, alias2 = R11.identity) {
1227
- if (!schema.$ref || !schema.$ref.startsWith("#")) return `unknown /* ${schema.$ref.replace("*/", "*\\/")} */`;
1228
- const parts = schema.$ref.split("/");
1229
- return alias2(parts[parts.length - 1]) || "unknown";
1230
- }
1231
- };
1232
-
1233
- // src/transformers/json-schema/declaration.renderer.ts
1234
- var DeclarationRenderer = class {
1235
- constructor(schema, options = {}) {
1236
- this.schema = schema;
1237
- this.options = options;
1238
- }
1239
- render() {
1240
- return this.renderSchema(this.schema);
1241
- }
1242
- renderSchema(schema) {
1243
- if (typeof schema === "boolean") return "unknown";
1244
- if (JsonSchemaUtils.isRef(schema)) return this.renderReference(schema);
1245
- if (JsonSchemaUtils.isMixed(schema)) return this.renderMixed(schema);
1246
- if (JsonSchemaUtils.isArray(schema)) return this.renderArray(schema);
1247
- if (schema.type === "object") return this.renderObject(schema);
1248
- if (schema.enum) return this.renderEnum(schema);
1249
- if (schema.oneOf) return this.renderOneOf(schema);
1250
- if (schema.anyOf) return this.renderAnyOf(schema);
1251
- if (schema.allOf) return this.renderAllOf(schema);
1252
- if (schema.type === "string") return this.renderString(schema);
1253
- if (schema.type === "number") return this.renderNumber(schema);
1254
- if (schema.type === "boolean") return this.renderBoolean(schema);
1255
- if (schema.type === "null") return this.renderNull(schema);
1256
- if (schema.type === "integer") return this.renderInteger(schema);
1257
- return "unknown";
1258
- }
1259
- renderMixed(schema) {
1260
- if (Array.isArray(schema.type)) {
1261
- schema.type.map((type) => ({ ...schema, type })).map((schema2) => this.renderSchema(schema2)).join(" | ");
1262
- }
1263
- return "unknown";
1264
- }
1265
- renderReference(schema) {
1266
- if (!this.options.referenceTransformer) {
1267
- return ReferenceTransformer.toDeclaration(schema);
1268
- }
1269
- return this.options.referenceTransformer(schema);
1270
- }
1271
- renderArray(schema) {
1272
- if (schema.items && Array.isArray(schema.items)) {
1273
- const items = schema.items.map((s) => this.renderSchema(s)).join(", ");
1274
- return `[${items}]`;
1275
- }
1276
- if (schema.items && typeof schema.items === "object") {
1277
- return `${this.renderSchema(schema.items)}[]`;
1278
- }
1279
- return "any[]";
1280
- }
1281
- renderObject(schema) {
1282
- if ((!schema.properties || R12.isEmpty(schema.properties)) && (!schema.additionalProperties || R12.isEmpty(schema.additionalProperties))) {
1283
- return "object";
1284
- }
1285
- const $properties = Object.entries(schema.properties || {}).map(([propertyName, propertySchema]) => {
1286
- let $comment = new CommentRenderer(propertySchema).render();
1287
- if ($comment) $comment += "\n";
1288
- const $key = `"${propertyName}"${schema.required?.includes(propertyName) ? "" : "?"}`;
1289
- const $value = this.renderSchema(propertySchema);
1290
- return indent(2, `${$comment}${$key}: ${$value}`);
1291
- });
1292
- if (schema.additionalProperties) {
1293
- const $value = schema.additionalProperties === true ? "any" : this.renderSchema(schema.additionalProperties);
1294
- $properties.push(indent(2, `[key: string]: ${$value}`));
1295
- }
1296
- return [
1297
- "{",
1298
- ...$properties,
1299
- "}"
1300
- ].join("\n");
1301
- }
1302
- renderOneOf(schema) {
1303
- if (!schema.oneOf) return "unknown";
1304
- return schema.oneOf.map((s) => this.renderSchema(s)).join(" | ");
1305
- }
1306
- renderAnyOf(schema) {
1307
- if (!schema.anyOf) return "unknown";
1308
- return schema.anyOf.map((s) => this.renderSchema(s)).join(" | ");
1309
- }
1310
- renderAllOf(schema) {
1311
- if (!schema.allOf) return "unknown";
1312
- return schema.allOf.map((s) => this.renderSchema(s)).join(" & ");
1313
- }
1314
- renderEnum(schema) {
1315
- if (!schema.enum) return "unknown";
1316
- return schema.enum.map((v) => JSON.stringify(v)).join(" | ");
1317
- }
1318
- renderString(schema) {
1319
- if (schema.contentMediaType === "application/octet-stream") return "Blob | Buffer";
1320
- if (schema.format === "binary") return "Blob | Buffer";
1321
- return "string";
1322
- }
1323
- renderNumber(schema) {
1324
- return "number";
1325
- }
1326
- renderBoolean(schema) {
1327
- return "boolean";
1328
- }
1329
- renderNull(schema) {
1330
- return "null";
1331
- }
1332
- renderInteger(schema) {
1333
- return "number";
1334
- }
1335
- };
1336
-
1337
- // src/transformers/json-schema/json-schema.transformer.ts
1338
- var JsonSchemaTransformer = class {
1339
- static toComment(schema) {
1340
- return new CommentRenderer(schema).render();
1341
- }
1342
- static toDeclaration(schema, options) {
1343
- return new DeclarationRenderer(schema, options).render();
1344
- }
1345
- };
1346
-
1347
- // src/transformers/schema-definition/schema-definition.transformer.ts
1348
- var R13 = __toESM(require("ramda"), 1);
1349
- var SchemaDefinitionTransformer = class {
1350
- static toDeclaration(schemaDefinition, options) {
1351
- const dependencies = schemaDefinition.getDependencies();
1352
- let $dependencies = dependencies.filter((dep) => !SchemaDefinition.isUnknown(dep)).map((dep) => {
1353
- const filepath = options.getDependentSchemaDefinitionFilepath(dep);
1354
- return `import type { ${dep.name} } from "${filepath}"`;
1355
- }).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, options.esm ? ' from "$1.js"' : ' from "$1"')).join("\n");
1356
- if ($dependencies) $dependencies += "\n";
1357
- let $comment = JsonSchemaTransformer.toComment(schemaDefinition.schema);
1358
- if ($comment) $comment += "\n";
1359
- if (typeof schemaDefinition.schema === "boolean") {
1360
- return [
1361
- "/* @anchor:file:start */",
1362
- "",
1363
- $dependencies,
1364
- $comment || void 0,
1365
- `type ${schemaDefinition.name} = unknown`,
1366
- "",
1367
- "/* @anchor:file:end */"
1368
- ].filter(R13.isNotNil).join("\n");
1369
- }
1370
- if (JsonSchemaUtils.isNonArray(schemaDefinition.schema) && schemaDefinition.schema.type === "object") {
1371
- const $schema = JsonSchemaTransformer.toDeclaration(schemaDefinition.schema);
1372
- const $declaration = $schema.startsWith("{") ? `export interface ${schemaDefinition.name} ${$schema}` : `export type ${schemaDefinition.name} = ${$schema}`;
1373
- return [
1374
- "/* @anchor:file:start */",
1375
- "",
1376
- $dependencies,
1377
- $comment || void 0,
1378
- $declaration,
1379
- "",
1380
- "/* @anchor:file:end */"
1381
- ].filter(R13.isNotNil).join("\n");
1382
- }
1383
- return [
1384
- "/* @anchor:file:start */",
1385
- "",
1386
- $dependencies,
1387
- $comment || void 0,
1388
- `export type ${schemaDefinition.name} = ${JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)}`,
1389
- "",
1390
- "/* @anchor:file:end */"
1391
- ].filter(R13.isNotNil).join("\n");
1392
- }
1393
- };
1394
-
1395
- // src/transformers/operation-definition/comment.renderer.ts
1396
- var R14 = __toESM(require("ramda"), 1);
1397
- var CommentRenderer2 = class {
1398
- constructor(operationDefinition) {
1399
- this.operationDefinition = operationDefinition;
1400
- }
1401
- render() {
1402
- const operation = this.operationDefinition.operation;
1403
- if (!operation.summary && !operation.description) return "";
1404
- const lines = ["/**"];
1405
- if (operation.summary && typeof operation.summary === "string") {
1406
- lines.push(` * ${R14.trim(operation.summary)}`);
1407
- lines.push(" *");
1408
- }
1409
- if (operation.description && typeof operation.description === "string") {
1410
- lines.push(` * @description ${R14.trim(operation.description)}`);
1411
- }
1412
- lines.push(" */");
1413
- return lines.join("\n");
1414
- }
1415
- };
1416
-
1417
- // src/transformers/operation-definition/declaration.renderer.ts
1418
- var R15 = __toESM(require("ramda"), 1);
1419
-
1420
- // src/transformers/operation-definition/utils/type-name-factory.ts
1421
- var changeCase = __toESM(require("change-case"), 1);
1422
- function typeNameFactory(operationDefinition) {
1423
- const pascalCaseOperationId = changeCase.pascalCase(operationDefinition.operationId);
1424
- return (name) => `${pascalCaseOperationId}${name}`;
845
+ function registerMcpCommand(program) {
846
+ program.command("mcp").description("Start keq MCP server").option("-c --config <config>", "The keq-cli config file").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--debug", "Print debug information").action(async (options) => {
847
+ const config = options.config;
848
+ const tolerant = !!options.tolerant;
849
+ const debug = !!options.debug;
850
+ const entries = await discoverProjects(config);
851
+ const registry = new CompilerProviderRegistry({
852
+ debug,
853
+ tolerant
854
+ });
855
+ for (const entry of entries) registry.register(entry);
856
+ const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
857
+ name: "keq",
858
+ version: "1.0.0",
859
+ description: "查询和搜索项目中对接的所有后端服务 API 接口。当用户想了解后端有哪些接口、查找某个功能的 API、查看接口的请求参数和响应格式时使用。支持自然语言语义搜索(中英文)。也可为接口生成 TypeScript 客户端代码。数据来源:项目配置的 Swagger/OpenAPI 规范文档。"
860
+ });
861
+ const projectParam = zod.z.string().optional().describe("项目目录绝对路径,用于 monorepo 中指定操作哪个子项目。非 monorepo 项目无需提供。");
862
+ server.registerTool("search_apis", {
863
+ description: "通过语义匹配搜索项目中的后端 API 接口。仅当用户描述了具体功能或业务场景(如\"用户登录\"、\"搜索商品\")来查找相关接口时使用。如果用户想查看所有接口或按模块/路径浏览接口列表,应使用 list_apis 而非此工具。支持中英文自然语言,返回按相关度排序的接口列表。",
864
+ inputSchema: {
865
+ project: projectParam,
866
+ query: zod.z.string().describe("自然语言搜索词,如\"用户登录\"、\"搜索商品\"、\"订单列表\"等"),
867
+ module: zod.z.array(zod.z.string()).optional().describe("按模块名筛选,限定在特定后端服务中搜索"),
868
+ limit: zod.z.number().optional().default(10).describe("返回结果数量上限")
869
+ },
870
+ annotations: {
871
+ readOnlyHint: true,
872
+ destructiveHint: false
873
+ }
874
+ }, async ({ project, query, module, limit }) => {
875
+ try {
876
+ const provider = await registry.resolve(project);
877
+ const engine = await provider.getEngine();
878
+ const matcher = await provider.getMatcher();
879
+ const documents = await provider.getDocuments();
880
+ const annotated = (await engine.search(query, {
881
+ limit,
882
+ module
883
+ })).map((result) => {
884
+ const { score, ...rest } = result;
885
+ const op = documents.find((d) => d.module.name === result.module)?.operations.find((o) => o.method.toLowerCase() === result.method.toLowerCase() && o.pathname === result.pathname);
886
+ return {
887
+ ...rest,
888
+ "x-keq-score": score,
889
+ "x-keq-filter": getFilterAnnotation(matcher, op)
890
+ };
891
+ });
892
+ return { content: [{
893
+ type: "text",
894
+ text: JSON.stringify(annotated, null, 2)
895
+ }] };
896
+ } catch (error) {
897
+ return {
898
+ content: [{
899
+ type: "text",
900
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
901
+ }],
902
+ isError: true
903
+ };
904
+ }
905
+ });
906
+ server.registerTool("get_api_detail", {
907
+ description: "获取某个 API 接口的完整详情,包含请求参数、请求体、响应体的结构定义。当用户想知道某个接口怎么调用、需要传什么参数、返回什么数据时使用。需要先通过 search_apis 或 list_apis 获取接口的 module、method、pathname。",
908
+ inputSchema: {
909
+ project: projectParam,
910
+ module: zod.z.string().describe("Module name"),
911
+ method: zod.z.string().describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),
912
+ pathname: zod.z.string().describe("API pathname (e.g. /api/v1/users)")
913
+ },
914
+ annotations: {
915
+ readOnlyHint: true,
916
+ destructiveHint: false
917
+ }
918
+ }, async ({ project, module, method, pathname }) => {
919
+ try {
920
+ const provider = await registry.resolve(project);
921
+ const engine = await provider.getEngine();
922
+ const matcher = await provider.getMatcher();
923
+ const documents = await provider.getDocuments();
924
+ const detail = engine.getDetail(module, method, pathname);
925
+ if (!detail) return {
926
+ content: [{
927
+ type: "text",
928
+ text: "API not found"
929
+ }],
930
+ isError: true
931
+ };
932
+ const op = documents.find((d) => d.module.name === module)?.operations.find((o) => o.method.toLowerCase() === method.toLowerCase() && o.pathname === pathname);
933
+ return { content: [{
934
+ type: "text",
935
+ text: JSON.stringify({
936
+ ...detail,
937
+ "x-keq-filter": getFilterAnnotation(matcher, op)
938
+ }, null, 2)
939
+ }] };
940
+ } catch (error) {
941
+ return {
942
+ content: [{
943
+ type: "text",
944
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
945
+ }],
946
+ isError: true
947
+ };
948
+ }
949
+ });
950
+ server.registerTool("list_modules", {
951
+ description: "列出项目对接的所有后端服务模块。当用户想知道项目接入了哪些后端系统、有哪些服务可用时使用。每个模块对应一个后端服务的 API 文档。",
952
+ inputSchema: { project: projectParam },
953
+ annotations: {
954
+ readOnlyHint: true,
955
+ destructiveHint: false
956
+ }
957
+ }, async ({ project }) => {
958
+ try {
959
+ const modules = (await (await registry.resolve(project)).getEngine()).listModules();
960
+ return { content: [{
961
+ type: "text",
962
+ text: JSON.stringify(modules, null, 2)
963
+ }] };
964
+ } catch (error) {
965
+ return {
966
+ content: [{
967
+ type: "text",
968
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
969
+ }],
970
+ isError: true
971
+ };
972
+ }
973
+ });
974
+ server.registerTool("list_apis", {
975
+ description: "列出项目中所有可用的后端 API 接口。当用户想查看所有接口、浏览某个服务的全部接口、查询某个系统有哪些接口、或按条件筛选接口(如只看 GET 请求或某个路径下的接口)时使用。如果用户描述了具体功能来查找接口(如\"搜索商品的接口\"),应使用 search_apis。",
976
+ inputSchema: {
977
+ project: projectParam,
978
+ module: zod.z.array(zod.z.string()).optional().describe("Filter by module names"),
979
+ method: zod.z.string().optional().describe("Filter by HTTP method (GET, POST, PUT, DELETE, etc.)"),
980
+ pathname: zod.z.string().optional().describe("Filter by pathname pattern (glob supported)"),
981
+ includes: zod.z.array(zod.z.enum(["operations", "components"])).optional().default(["operations"]).describe("What to include in results")
982
+ },
983
+ annotations: {
984
+ readOnlyHint: true,
985
+ destructiveHint: false
986
+ }
987
+ }, async ({ project, module, method, pathname, includes }) => {
988
+ try {
989
+ const provider = await registry.resolve(project);
990
+ const documents = await provider.getDocuments();
991
+ const matcher = await provider.getMatcher();
992
+ const result = documents.filter((doc) => !module || module.includes(doc.module.name)).map((document) => {
993
+ const item = { module: document.module.name };
994
+ if (includes.includes("operations")) {
995
+ let ops = document.operations;
996
+ if (method) ops = ops.filter((op) => op.method.toLowerCase() === method.toLowerCase());
997
+ if (pathname) {
998
+ const match = (0, picomatch.default)(pathname);
999
+ ops = ops.filter((op) => match(op.pathname));
1000
+ }
1001
+ item.operations = ops.map((op) => ({
1002
+ method: op.method.toUpperCase(),
1003
+ path: op.pathname,
1004
+ operationId: op.operationId,
1005
+ summary: op.operation.summary || "",
1006
+ description: op.operation.description || "",
1007
+ "x-keq-filter": getFilterAnnotation(matcher, op)
1008
+ }));
1009
+ }
1010
+ if (includes.includes("components")) item.components = { schemas: document.schemas.map((schema) => {
1011
+ const schemaObj = schema.schema;
1012
+ return {
1013
+ name: schema.name,
1014
+ description: schemaObj.description || ""
1015
+ };
1016
+ }) };
1017
+ return item;
1018
+ });
1019
+ return { content: [{
1020
+ type: "text",
1021
+ text: JSON.stringify(result, null, 2)
1022
+ }] };
1023
+ } catch (error) {
1024
+ return {
1025
+ content: [{
1026
+ type: "text",
1027
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1028
+ }],
1029
+ isError: true
1030
+ };
1031
+ }
1032
+ });
1033
+ server.registerTool("build_apis", {
1034
+ description: "为后端 API 接口生成类型安全的 TypeScript 请求函数代码。当用户想生成某个接口的调用代码、需要类型安全的 HTTP 客户端时使用。可按模块、方法、路径范围筛选要生成的接口。生成的文件写入项目配置的输出目录。",
1035
+ inputSchema: {
1036
+ project: projectParam,
1037
+ module: zod.z.array(zod.z.string()).optional().describe("Module(s) to generate code for"),
1038
+ method: zod.z.string().optional().describe("HTTP method filter (e.g. GET, POST)"),
1039
+ pathname: zod.z.string().optional().describe("Pathname filter (glob pattern supported, e.g. /api/v1/users/**)"),
1040
+ fresh: zod.z.boolean().optional().default(false).describe("Clean output directory before building")
1041
+ },
1042
+ annotations: {
1043
+ readOnlyHint: false,
1044
+ destructiveHint: false
1045
+ }
1046
+ }, async ({ project, module, method, pathname, fresh }) => {
1047
+ try {
1048
+ const provider = await registry.resolve(project);
1049
+ const configPath = registry.getConfigPath(project);
1050
+ const filterRules = [];
1051
+ if (module || method || pathname) filterRules.push({
1052
+ deny: true,
1053
+ persist: false,
1054
+ moduleName: "*",
1055
+ operationMethod: "*",
1056
+ operationPathname: "/**"
1057
+ }, ...xprodFilterRules({
1058
+ module,
1059
+ method,
1060
+ pathname,
1061
+ persist: false
1062
+ }));
1063
+ const buildCompiler = new require_compiler.Compiler({
1064
+ build: true,
1065
+ persist: true,
1066
+ silent: true,
1067
+ fresh,
1068
+ config: configPath,
1069
+ debug,
1070
+ tolerant,
1071
+ filter: filterRules.length > 0 ? { rules: filterRules } : void 0
1072
+ });
1073
+ await buildCompiler.run();
1074
+ const artifacts = buildCompiler.context.artifacts || [];
1075
+ const rc = buildCompiler.context.rc;
1076
+ const files = artifacts.map((a) => rc ? `./${path.join(rc.outdir, a.filepath)}` : a.filepath);
1077
+ await provider.invalidate();
1078
+ return { content: [{
1079
+ type: "text",
1080
+ text: JSON.stringify({
1081
+ generated: files.length,
1082
+ files
1083
+ }, null, 2)
1084
+ }] };
1085
+ } catch (error) {
1086
+ return {
1087
+ content: [{
1088
+ type: "text",
1089
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1090
+ }],
1091
+ isError: true
1092
+ };
1093
+ }
1094
+ });
1095
+ server.registerTool("list_generated_files", {
1096
+ description: "列出已生成的 API 客户端代码文件。当用户想查看哪些接口已经生成了代码、或想找出过期/无效的生成文件时使用。",
1097
+ inputSchema: {
1098
+ project: projectParam,
1099
+ invalid: zod.z.boolean().optional().default(false).describe("If true, only list invalid/stale files not matching current build")
1100
+ },
1101
+ annotations: {
1102
+ readOnlyHint: true,
1103
+ destructiveHint: false
1104
+ }
1105
+ }, async ({ project, invalid }) => {
1106
+ try {
1107
+ const context = await (await registry.resolve(project)).getContext();
1108
+ const rc = context.rc;
1109
+ if (!rc) return {
1110
+ content: [{
1111
+ type: "text",
1112
+ text: "Error: Failed to load configuration"
1113
+ }],
1114
+ isError: true
1115
+ };
1116
+ if (invalid) {
1117
+ const validFilePaths = (context.artifacts || []).map((a) => a.filepath);
1118
+ const files = (await findInvalidFiles(rc.outdir, validFilePaths)).map((f) => `./${path.join(rc.outdir, f.relativePath)}`);
1119
+ return { content: [{
1120
+ type: "text",
1121
+ text: JSON.stringify({
1122
+ count: files.length,
1123
+ files
1124
+ }, null, 2)
1125
+ }] };
1126
+ }
1127
+ const files = (context.artifacts || []).map((a) => `./${path.join(rc.outdir, a.filepath)}`);
1128
+ return { content: [{
1129
+ type: "text",
1130
+ text: JSON.stringify({
1131
+ count: files.length,
1132
+ files
1133
+ }, null, 2)
1134
+ }] };
1135
+ } catch (error) {
1136
+ return {
1137
+ content: [{
1138
+ type: "text",
1139
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1140
+ }],
1141
+ isError: true
1142
+ };
1143
+ }
1144
+ });
1145
+ server.registerTool("get_filter_rules", {
1146
+ description: "查看当前的接口过滤规则。过滤规则决定哪些 API 接口会被纳入代码生成范围。当用户想了解哪些接口被排除或包含在生成列表中时使用。",
1147
+ inputSchema: { project: projectParam },
1148
+ annotations: {
1149
+ readOnlyHint: true,
1150
+ destructiveHint: false
1151
+ }
1152
+ }, async ({ project }) => {
1153
+ try {
1154
+ await registry.resolve(project);
1155
+ const configPath = registry.getConfigPath(project);
1156
+ const filterPath = path.resolve(path.dirname(configPath), ".keqfilter");
1157
+ if (!await fs_extra.default.exists(filterPath)) return { content: [{
1158
+ type: "text",
1159
+ text: JSON.stringify({
1160
+ exists: false,
1161
+ content: ""
1162
+ }, null, 2)
1163
+ }] };
1164
+ const content = await fs_extra.default.readFile(filterPath, "utf-8");
1165
+ return { content: [{
1166
+ type: "text",
1167
+ text: JSON.stringify({
1168
+ exists: true,
1169
+ content
1170
+ }, null, 2)
1171
+ }] };
1172
+ } catch (error) {
1173
+ return {
1174
+ content: [{
1175
+ type: "text",
1176
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1177
+ }],
1178
+ isError: true
1179
+ };
1180
+ }
1181
+ });
1182
+ server.registerTool("add_filter_rule", {
1183
+ description: "添加接口过滤规则,控制哪些 API 需要生成代码。当用户想排除某些不需要的接口、或只保留特定接口时使用。deny 模式排除接口,allow 模式包含接口。",
1184
+ inputSchema: {
1185
+ project: projectParam,
1186
+ mode: zod.z.enum(["deny", "allow"]).describe("Rule mode: deny excludes APIs, allow includes them"),
1187
+ module: zod.z.string().optional().default("*").describe("Module name pattern (glob supported)"),
1188
+ method: zod.z.string().optional().default("*").describe("HTTP method pattern (e.g. GET, POST, or * for all)"),
1189
+ pathname: zod.z.string().describe("Pathname pattern (glob supported, e.g. /api/v1/users/**)"),
1190
+ build: zod.z.boolean().optional().default(false).describe("Whether to rebuild after adding the rule")
1191
+ },
1192
+ annotations: {
1193
+ readOnlyHint: false,
1194
+ destructiveHint: false
1195
+ }
1196
+ }, async ({ project, mode, module, method, pathname, build }) => {
1197
+ try {
1198
+ const provider = await registry.resolve(project);
1199
+ await new require_compiler.Compiler({
1200
+ build,
1201
+ persist: true,
1202
+ silent: true,
1203
+ config: registry.getConfigPath(project),
1204
+ debug,
1205
+ tolerant,
1206
+ filter: { rules: [{
1207
+ persist: true,
1208
+ deny: mode === "deny",
1209
+ moduleName: module,
1210
+ operationMethod: method.toLowerCase(),
1211
+ operationPathname: pathname
1212
+ }] }
1213
+ }).run();
1214
+ if (build) await provider.invalidate();
1215
+ return { content: [{
1216
+ type: "text",
1217
+ text: JSON.stringify({
1218
+ success: true,
1219
+ rule: {
1220
+ mode,
1221
+ module,
1222
+ method,
1223
+ pathname
1224
+ }
1225
+ }, null, 2)
1226
+ }] };
1227
+ } catch (error) {
1228
+ return {
1229
+ content: [{
1230
+ type: "text",
1231
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1232
+ }],
1233
+ isError: true
1234
+ };
1235
+ }
1236
+ });
1237
+ server.registerTool("remove_filter_rule", {
1238
+ description: "移除已有的接口过滤规则。当用户想恢复之前被排除的接口、或调整过滤策略时使用。",
1239
+ inputSchema: {
1240
+ project: projectParam,
1241
+ mode: zod.z.enum(["deny", "allow"]).describe("Which section the rule is in"),
1242
+ module: zod.z.string().describe("Exact module name pattern to match"),
1243
+ method: zod.z.string().describe("Exact method pattern to match"),
1244
+ pathname: zod.z.string().describe("Exact pathname pattern to match"),
1245
+ build: zod.z.boolean().optional().default(false).describe("Whether to rebuild after removing the rule")
1246
+ },
1247
+ annotations: {
1248
+ readOnlyHint: false,
1249
+ destructiveHint: false
1250
+ }
1251
+ }, async ({ project, mode, module, method, pathname, build }) => {
1252
+ try {
1253
+ const provider = await registry.resolve(project);
1254
+ const configPath = registry.getConfigPath(project);
1255
+ const filterPath = path.resolve(path.dirname(configPath), ".keqfilter");
1256
+ if (!await fs_extra.default.exists(filterPath)) return {
1257
+ content: [{
1258
+ type: "text",
1259
+ text: "Error: .keqfilter file not found"
1260
+ }],
1261
+ isError: true
1262
+ };
1263
+ const content = await fs_extra.default.readFile(filterPath, "utf-8");
1264
+ const isDeny = mode === "deny";
1265
+ const targetMethod = method.toLowerCase();
1266
+ const lines = content.split("\n");
1267
+ const resultLines = [];
1268
+ let currentSection = null;
1269
+ let skipNext = false;
1270
+ for (const line of lines) {
1271
+ const trimmed = line.replace(/#.*$/, "").trim();
1272
+ if (trimmed === "[deny]") {
1273
+ currentSection = "deny";
1274
+ resultLines.push(line);
1275
+ continue;
1276
+ }
1277
+ if (trimmed === "[allow]") {
1278
+ currentSection = "allow";
1279
+ resultLines.push(line);
1280
+ continue;
1281
+ }
1282
+ if (!trimmed) {
1283
+ if (!skipNext) resultLines.push(line);
1284
+ skipNext = false;
1285
+ continue;
1286
+ }
1287
+ const matched = trimmed.match(/^([^\s]+)\s+([^:\s]+):(.*)$/);
1288
+ if (matched && currentSection === (isDeny ? "deny" : "allow")) {
1289
+ const [, ruleMethod, ruleModule, rulePathname] = matched;
1290
+ if (ruleMethod.toLowerCase() === targetMethod && ruleModule === module && rulePathname === pathname) {
1291
+ skipNext = false;
1292
+ continue;
1293
+ }
1294
+ }
1295
+ resultLines.push(line);
1296
+ skipNext = false;
1297
+ }
1298
+ await fs_extra.default.writeFile(filterPath, resultLines.join("\n"), "utf-8");
1299
+ if (build) {
1300
+ await new require_compiler.Compiler({
1301
+ build: true,
1302
+ persist: true,
1303
+ silent: true,
1304
+ config: configPath,
1305
+ debug,
1306
+ tolerant
1307
+ }).run();
1308
+ await provider.invalidate();
1309
+ }
1310
+ return { content: [{
1311
+ type: "text",
1312
+ text: JSON.stringify({
1313
+ success: true,
1314
+ removed: {
1315
+ mode,
1316
+ module,
1317
+ method,
1318
+ pathname
1319
+ }
1320
+ }, null, 2)
1321
+ }] };
1322
+ } catch (error) {
1323
+ return {
1324
+ content: [{
1325
+ type: "text",
1326
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`
1327
+ }],
1328
+ isError: true
1329
+ };
1330
+ }
1331
+ });
1332
+ const transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
1333
+ await server.connect(transport);
1334
+ if (registry.list().length === 1) (await registry.resolve()).getEngine().catch(() => {});
1335
+ });
1425
1336
  }
1426
-
1427
- // src/transformers/operation-definition/declaration.renderer.ts
1428
- var alias = (name) => `${name}Schema`;
1429
- var DeclarationRenderer2 = class {
1430
- constructor(operationDefinition, options) {
1431
- this.operationDefinition = operationDefinition;
1432
- this.options = options;
1433
- this.typeName = typeNameFactory(operationDefinition);
1434
- }
1435
- typeName;
1436
- renderResponseBodies(operation, options) {
1437
- if (!operation.responses || R15.isEmpty(operation.responses)) {
1438
- return `export interface ${this.typeName("ResponseBodies")} {}`;
1439
- }
1440
- const $responses = Object.entries(operation.responses).map(([statusCode, response]) => {
1441
- if (!JsonSchemaUtils.isRef(response)) {
1442
- const $value = Object.entries(response.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
1443
- if (mediaType.includes("text/event-stream")) return "ReadableStream<ServerSentEvent>";
1444
- if (mediaType.includes("multipart/form-data")) return "FormData";
1445
- if (!schema) return "unknown";
1446
- return JsonSchemaTransformer.toDeclaration(schema, options);
1447
- }).join(" | ");
1448
- return indent(2, `${statusCode}: ${$value || "void"}`);
1449
- }
1450
- }).join("\n");
1451
- return [
1452
- `export interface ${this.typeName("ResponseBodies")} {`,
1453
- $responses,
1454
- "}"
1455
- ].join("\n");
1456
- }
1457
- renderRequestBodies(operation, options) {
1458
- let $requestBodies = `export interface ${this.typeName("RequestBodies")} {}`;
1459
- if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {
1460
- const $mediaTypes = Object.entries(operation.requestBody.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
1461
- if (!schema) return `${JSON.stringify(mediaType)}: unknown`;
1462
- return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schema, options)}`;
1463
- }).map((pair) => indent(2, pair));
1464
- $requestBodies = [
1465
- `export interface ${this.typeName("RequestBodies")} {`,
1466
- ...$mediaTypes,
1467
- "}"
1468
- ].join("\n");
1469
- }
1470
- return $requestBodies;
1471
- }
1472
- renderParameterBodies(operationDefinition, options) {
1473
- const { operation } = operationDefinition;
1474
- let parameterBodies = "";
1475
- if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {
1476
- const $mediaTypes = Object.entries(operation.requestBody.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schemaOrRef]) => {
1477
- if (!schemaOrRef) return `${JSON.stringify(mediaType)}: unknown`;
1478
- const schema = JsonSchemaUtils.isRef(schemaOrRef) ? OpenapiUtils.dereferenceDeep(schemaOrRef.$ref, operationDefinition.document.specification) : schemaOrRef;
1479
- if (schema.type === "object" || schema.properties) {
1480
- return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schemaOrRef, options)} & { [key: string]: any }`;
1481
- }
1482
- return `${JSON.stringify(mediaType)}: { [key: string]: any }`;
1483
- }).map((pair) => indent(2, pair));
1484
- parameterBodies = [
1485
- `interface ${this.typeName("ParameterBodies")} {`,
1486
- ...$mediaTypes,
1487
- "}",
1488
- ""
1489
- ].join("\n");
1490
- }
1491
- return parameterBodies;
1492
- }
1493
- renderRequestParameters(operation, options) {
1494
- const mediaTypes = operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody) ? Object.keys(operation.requestBody.content || {}) : [];
1495
- const base = `${this.typeName("RequestQuery")} & ${this.typeName("RouteParameters")} & ${this.typeName("RequestHeaders")}`;
1496
- if (mediaTypes.length === 1) {
1497
- return `export type ${this.typeName("RequestParameters")} = ${base} & ${this.typeName("RequestBodies")}[${JSON.stringify(mediaTypes[0])}]`;
1498
- }
1499
- if (mediaTypes.length > 1) {
1500
- const unions = mediaTypes.map((mediaType) => `(${base} & ${this.typeName("RequestBodies")}[${JSON.stringify(mediaType)}] & { "content-type": ${JSON.stringify(mediaType)} })`).join("\n| ");
1501
- return `export type ${this.typeName("RequestParameters")} = ${unions}`;
1502
- }
1503
- return `export type ${this.typeName("RequestParameters")} = ${base}`;
1504
- }
1505
- rendererParameters(name, parameters, options) {
1506
- if (parameters.length === 0) {
1507
- return `export type ${name} = {}`;
1508
- }
1509
- const $parameters = parameters.map((parameter) => {
1510
- const parameterName = `"${parameter.name}"`;
1511
- const $key = parameter.required ? parameterName : `${parameterName}?`;
1512
- const $value = JsonSchemaTransformer.toDeclaration(parameter.schema || { type: "any" }, options);
1513
- return indent(2, `${$key}: ${$value}`);
1514
- }).join("\n");
1515
- return [
1516
- `export type ${name} = {`,
1517
- $parameters,
1518
- "}"
1519
- ].filter(Boolean).join("\n");
1520
- }
1521
- renderDependencies() {
1522
- const schemaDefinitions = this.operationDefinition.getDependencies().filter((schemaDefinition) => !SchemaDefinition.isUnknown(schemaDefinition));
1523
- const $schemaDefinitions = schemaDefinitions.map((schemaDefinition) => {
1524
- const filepath = this.options.getDependentSchemaDefinitionFilepath(schemaDefinition);
1525
- const schemaName = schemaDefinition.name;
1526
- return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
1527
- }).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
1528
- return [
1529
- 'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
1530
- ...$schemaDefinitions
1531
- ].join("\n");
1532
- }
1533
- render() {
1534
- const { operation } = this.operationDefinition;
1535
- if (!operation.responses) return "";
1536
- const jsonSchemaDeclarationRendererOptions = {
1537
- referenceTransformer: (schema) => {
1538
- return ReferenceTransformer.toDeclaration(schema, alias);
1539
- }
1540
- };
1541
- const $dependencies = this.renderDependencies();
1542
- const $responseBodies = this.renderResponseBodies(operation, jsonSchemaDeclarationRendererOptions);
1543
- const $requestBodies = this.renderRequestBodies(operation, jsonSchemaDeclarationRendererOptions);
1544
- const $parameterBodies = this.renderParameterBodies(this.operationDefinition, jsonSchemaDeclarationRendererOptions);
1545
- const $requestParameters = this.renderRequestParameters(operation, jsonSchemaDeclarationRendererOptions);
1546
- const $requestQuery = this.rendererParameters(
1547
- `${this.typeName("RequestQuery")}`,
1548
- operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "query") || [],
1549
- jsonSchemaDeclarationRendererOptions
1550
- );
1551
- const $routeParameters = this.rendererParameters(
1552
- `${this.typeName("RouteParameters")}`,
1553
- operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "path") || [],
1554
- jsonSchemaDeclarationRendererOptions
1555
- );
1556
- const $requestHeaders = this.rendererParameters(
1557
- `${this.typeName("RequestHeaders")}`,
1558
- operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "header") || [],
1559
- jsonSchemaDeclarationRendererOptions
1560
- );
1561
- return [
1562
- "/* @anchor:file:start */",
1563
- "",
1564
- $dependencies,
1565
- "",
1566
- $responseBodies,
1567
- "",
1568
- $requestBodies,
1569
- "",
1570
- $requestQuery,
1571
- "",
1572
- $routeParameters,
1573
- "",
1574
- $requestHeaders,
1575
- "",
1576
- $parameterBodies || void 0,
1577
- $requestParameters,
1578
- "",
1579
- `export interface ${this.typeName("Operation")}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${$parameterBodies ? `keyof ${this.typeName("ParameterBodies")}` : "string"} > extends KeqOperation {`,
1580
- ` requestParams: ${this.typeName("RouteParameters")} & { [key: string]: KeqPathParameterInit }`,
1581
- ` requestQuery: ${this.typeName("RequestQuery")} & { [key: string]: KeqQueryInit }`,
1582
- ` requestHeaders: ${this.typeName("RequestHeaders")} & { [key: string]: string | number }`,
1583
- ` requestBody: ${$parameterBodies ? `${this.typeName("ParameterBodies")}[CONTENT_TYPE] | ` : "object | "}BodyInit`,
1584
- ` responseBody: ${this.typeName("ResponseBodies")}[STATUS]`,
1585
- "}",
1586
- "",
1587
- "/* @anchor:file:end */"
1588
- ].filter(R15.isNotNil).join("\n");
1589
- }
1590
- };
1591
-
1592
- // src/transformers/operation-definition/micro-function.renderer.ts
1593
- var R17 = __toESM(require("ramda"), 1);
1594
-
1595
- // src/transformers/operation-definition/typescript-snippet.ts
1596
- var R16 = __toESM(require("ramda"), 1);
1597
-
1598
- // src/constants/qs-array-format.ts
1599
- var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
1600
- QsArrayFormat2["brackets"] = "brackets";
1601
- QsArrayFormat2["indices"] = "indices";
1602
- QsArrayFormat2["repeat"] = "repeat";
1603
- QsArrayFormat2["comma"] = "comma";
1604
- QsArrayFormat2["space"] = "space";
1605
- QsArrayFormat2["pipe"] = "pipe";
1606
- return QsArrayFormat2;
1607
- })(QsArrayFormat || {});
1608
-
1609
- // src/transformers/operation-definition/typescript-snippet.ts
1610
- var OperationDefinitionSnippet = class {
1611
- constructor(operationDefinition, options) {
1612
- this.operationDefinition = operationDefinition;
1613
- this.options = options;
1614
- this.typeName = typeNameFactory(operationDefinition);
1615
- }
1616
- typeName;
1617
- getQsParameters(parameter) {
1618
- let arrayFormat;
1619
- let allowDots;
1620
- let indices;
1621
- const style = parameter.style || "form";
1622
- const explode = parameter.explode ?? true;
1623
- if ("x-qs-array-format" in parameter) {
1624
- arrayFormat = parameter["x-qs-array-format"];
1625
- } else {
1626
- if (style === "deepObject") {
1627
- arrayFormat = "brackets" /* brackets */;
1628
- } else if (explode) {
1629
- arrayFormat = "repeat" /* repeat */;
1630
- } else {
1631
- if (style === "form") {
1632
- arrayFormat = "comma" /* comma */;
1633
- } else if (style === "spaceDelimited") {
1634
- arrayFormat = "space" /* space */;
1635
- } else if (style === "pipeDelimited") {
1636
- arrayFormat = "pipe" /* pipe */;
1637
- }
1638
- }
1639
- }
1640
- if ("x-qs-allow-dots" in parameter) {
1641
- allowDots = Boolean(parameter["x-qs-allow-dots"]);
1642
- }
1643
- if ("x-qs-indices" in parameter) {
1644
- indices = Boolean(parameter["x-qs-indices"]);
1645
- }
1646
- if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
1647
- return {
1648
- ...arrayFormat ? { arrayFormat } : {},
1649
- ...allowDots !== void 0 ? { allowDots } : {},
1650
- ...indices !== void 0 ? { indices } : {}
1651
- };
1652
- }
1653
- return void 0;
1654
- }
1655
- // render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
1656
- renderRequestHeaders() {
1657
- const { operation } = this.operationDefinition;
1658
- const $headers = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "header").map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.header(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`).join("\n");
1659
- return $headers;
1660
- }
1661
- // render: "if (args && 'id' in args) req.query('id', args['id'], options)"
1662
- renderRequestQuery() {
1663
- const { operation } = this.operationDefinition;
1664
- const $query = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "query").map((p) => {
1665
- const option = this.getQsParameters(p);
1666
- const $option = !option || R16.isEmpty(option) ? "" : `, ${JSON.stringify(option)}`;
1667
- return `if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`;
1668
- }).join("\n");
1669
- return $query;
1670
- }
1671
- // render: "if (args && 'id' in args) req.params('id', args['id'])"
1672
- renderRequestPathParameters() {
1673
- const { operation } = this.operationDefinition;
1674
- const $pathParameters = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "path").map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.params(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`).join("\n");
1675
- return $pathParameters;
1676
- }
1677
- getRequestMediaTypes() {
1678
- const { operation } = this.operationDefinition;
1679
- const requestBodyContent = operation.requestBody?.content || {};
1680
- return Object.keys(requestBodyContent);
1681
- }
1682
- // render "req.type("application/json")"
1683
- renderMediaType() {
1684
- const mediaTypes = this.getRequestMediaTypes();
1685
- if (mediaTypes.length === 1 && !mediaTypes[0].endsWith("/*")) {
1686
- return `req.type("${mediaTypes[0]}")
1687
- `;
1688
- } else if (mediaTypes.some((mediaType) => mediaType === "*/*")) {
1689
- } else if (mediaTypes.some((mediaType) => mediaType.endsWith("/*"))) {
1690
- return 'if(args?.["content-type"]) req.type(args["content-type"])\n';
1691
- } else if (mediaTypes.length > 1) {
1692
- return 'if(args?.["content-type"]) req.type(args["content-type"])\n';
1693
- }
1694
- return "";
1695
- }
1696
- // render body
1697
- requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType) {
1698
- try {
1699
- const $propertyName = JSON.stringify(propertyName);
1700
- const schema = JsonSchemaUtils.isRef(propertySchema) ? OpenapiUtils.dereferenceDeep(propertySchema.$ref, this.operationDefinition.document.specification) : propertySchema;
1701
- if (schema.type === "string" && schema.format === "binary" || schema.contentMediaType === "application/octet-stream") {
1702
- return `if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`;
1703
- } else if (schema.type === "string" || schema.type === "array" && schema.items && schema.items.type === "string") {
1704
- return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`;
1705
- } else if (schema.type === "number" || schema.type === "integer") {
1706
- return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]))`;
1707
- }
1708
- return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]) /* type is non-string in schema; triggers type coercion here */)`;
1709
- } catch (err) {
1710
- return this.renderErrorComment(err, mediaType);
1711
- }
1712
- }
1713
- requestBodyPropertyRenderer(propertyName, propertySchema, mediaType) {
1714
- if (mediaType === "application/json") {
1715
- const $propertyName = JSON.stringify(propertyName);
1716
- return `if (args && ${$propertyName} in args) req.send({ ${$propertyName}: args[${$propertyName}] })`;
1717
- } else if (mediaType === "multipart/form-data") {
1718
- return this.requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType);
1719
- } else {
1720
- throw new Error(`Unsupported media type: ${mediaType}`);
1721
- }
1722
- }
1723
- renderRequestBody() {
1724
- const { operation } = this.operationDefinition;
1725
- const requestBodyContent = operation.requestBody?.content || {};
1726
- const $requestBody = Object.entries(requestBodyContent).map(([mediaType, mediaTypeObject]) => {
1727
- if (!mediaTypeObject.schema) return;
1728
- try {
1729
- const schema = JsonSchemaUtils.isRef(mediaTypeObject.schema) ? OpenapiUtils.dereferenceDeep(mediaTypeObject.schema.$ref, this.operationDefinition.document.specification) : mediaTypeObject.schema;
1730
- if (schema.type !== "object") return;
1731
- const properties = schema.properties || {};
1732
- return Object.entries(properties).map(([propertyName, propertySchema]) => this.requestBodyPropertyRenderer(propertyName, propertySchema, mediaType)).join("\n");
1733
- } catch (err) {
1734
- return this.renderErrorComment(err, mediaType);
1735
- }
1736
- }).filter(R16.isNotNil).join("\n");
1737
- return $requestBody;
1738
- }
1739
- renderErrorComment(err, mediaType) {
1740
- const $err = String(err).split("\n").map(((line) => ` * ${line}`)).join("\n");
1741
- return [
1742
- "/**",
1743
- ` * Unable to dereference schema for media type ${mediaType}`,
1744
- $err,
1745
- " */"
1746
- ].join("\n");
1747
- }
1748
- };
1749
-
1750
- // src/transformers/operation-definition/micro-function.renderer.ts
1751
- var OperationDefinitionMicroFunctionRenderer = class {
1752
- constructor(operationDefinition, options) {
1753
- this.operationDefinition = operationDefinition;
1754
- this.options = options;
1755
- this.typeName = typeNameFactory(operationDefinition);
1756
- this.helper = new OperationDefinitionSnippet(operationDefinition, options);
1757
- }
1758
- helper;
1759
- typeName;
1760
- render() {
1761
- const { operation, operationId, method, pathname } = this.operationDefinition;
1762
- if (!operation.responses) return "";
1763
- const $dependencies = this.renderDependencies();
1764
- const $comment = new CommentRenderer2(this.operationDefinition).render();
1765
- const moduleName = this.operationDefinition.module.name;
1766
- const $method = method.toLowerCase();
1767
- const $queryParameters = this.helper.renderRequestQuery();
1768
- const $headerParameters = this.helper.renderRequestHeaders();
1769
- const $pathParameters = this.helper.renderRequestPathParameters();
1770
- const $mediaType = this.helper.renderMediaType();
1771
- const $requestBody = this.helper.renderRequestBody();
1772
- const $operationDeclaration = this.renderOperationDeclaration();
1773
- return [
1774
- "/* @anchor:file:start */",
1775
- "",
1776
- $dependencies,
1777
- "",
1778
- `const moduleName = "${moduleName}"`,
1779
- `const method = "${method}"`,
1780
- `const pathname = "${pathname}"`,
1781
- "",
1782
- $comment || void 0,
1783
- `export ${$operationDeclaration} {`,
1784
- ` const req = request.${$method}<${this.typeName("ResponseBodies")}[STATUS]>("${pathname}")`,
1785
- " .option('module', { name: moduleName, pathname, method })",
1786
- "",
1787
- $mediaType ? indent(2, $mediaType) : void 0,
1788
- " /* @anchor:query:start */",
1789
- $queryParameters ? indent(2, $queryParameters) : void 0,
1790
- " /* @anchor:query:end */",
1791
- "",
1792
- " /* @anchor:headers:start */",
1793
- $headerParameters ? indent(2, $headerParameters) : void 0,
1794
- " /* @anchor:headers:end */",
1795
- "",
1796
- " /* @anchor:path-parameters:start */",
1797
- $pathParameters ? indent(2, $pathParameters) : void 0,
1798
- " /* @anchor:path-parameters:end */",
1799
- "",
1800
- " /* @anchor:body:start */",
1801
- $requestBody ? indent(2, $requestBody) : void 0,
1802
- " /* @anchor:body:end */",
1803
- "",
1804
- " /* @anchor:operation-return */",
1805
- ` return req as ReturnType<typeof ${operationId}<STATUS${$operationDeclaration.includes("CONTENT_TYPE") ? ", CONTENT_TYPE" : ""}>>`,
1806
- "}",
1807
- "",
1808
- `${operationId}.pathname = pathname`,
1809
- `${operationId}.method = method`,
1810
- "/* @anchor:file:end */"
1811
- ].filter(R17.isNotNil).join("\n");
1812
- }
1813
- renderDependencies() {
1814
- const declarationFilepath = this.options.getOperationDefinitionDeclarationFilepath(this.operationDefinition);
1815
- const requestFilepath = this.options.getRequestFilepath();
1816
- return [
1817
- 'import { Keq } from "keq"',
1818
- `import { request } from "${requestFilepath}"`,
1819
- `import type { ${this.typeName("Operation")}, ${this.typeName("ResponseBodies")}, ${this.typeName("RequestParameters")} } from "${declarationFilepath}"`,
1820
- `export type { ${this.typeName("RequestQuery")}, ${this.typeName("RequestHeaders")}, ${this.typeName("RequestBodies")} } from "${declarationFilepath}"`
1821
- ].map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"')).join("\n");
1822
- }
1823
- renderOperationDeclaration() {
1824
- const { operationId } = this.operationDefinition;
1825
- const mediaTypes = this.helper.getRequestMediaTypes();
1826
- if (mediaTypes.length === 0) {
1827
- return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends never = never>(args?: ${this.typeName("RequestParameters")}): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1828
- } else if (mediaTypes.length === 1) {
1829
- return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${this.typeName("RequestParameters")}): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1830
- } else if (mediaTypes.length > 1) {
1831
- return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${this.typeName("RequestParameters")}["content-type"]>(args?: Extract<${this.typeName("RequestParameters")}, { "content-type": CONTENT_TYPE }>): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1832
- }
1833
- throw new Exception(this.operationDefinition.module, "[operationDeclarationRenderer] Unreachable");
1834
- }
1835
- };
1836
-
1837
- // src/transformers/operation-definition/nestjs-method.renderer.ts
1838
- var R18 = __toESM(require("ramda"), 1);
1839
- var OperationDefinitionNestjsMethodRenderer = class {
1840
- constructor(operationDefinition, options) {
1841
- this.operationDefinition = operationDefinition;
1842
- this.options = options;
1843
- this.typeName = typeNameFactory(operationDefinition);
1844
- this.helper = new OperationDefinitionSnippet(operationDefinition, options);
1845
- }
1846
- helper;
1847
- typeName;
1848
- render() {
1849
- const pathname = this.operationDefinition.pathname;
1850
- const $comment = new CommentRenderer2(this.operationDefinition).render();
1851
- const $method = this.operationDefinition.method.toLowerCase();
1852
- const $mediaType = this.helper.renderMediaType();
1853
- const $operationDeclaration = this.renderOperationDeclaration(this.operationDefinition);
1854
- const $queryParameters = this.helper.renderRequestQuery();
1855
- const $headerParameters = this.helper.renderRequestHeaders();
1856
- const $pathParameters = this.helper.renderRequestPathParameters();
1857
- const $requestBody = this.helper.renderRequestBody();
1858
- return [
1859
- $comment,
1860
- `${$operationDeclaration} {`,
1861
- ` const req = this.request.${$method}<${this.typeName("ResponseBodies")}[STATUS]>(${JSON.stringify(pathname)})`,
1862
- " .option(",
1863
- ' "module",',
1864
- " {",
1865
- ` name: ${JSON.stringify(this.operationDefinition.module.name)},`,
1866
- ` pathname: ${JSON.stringify(pathname)},`,
1867
- ` method: ${JSON.stringify($method)},`,
1868
- " },",
1869
- " )",
1870
- "",
1871
- $mediaType ? indent(2, $mediaType) : void 0,
1872
- "",
1873
- " /* @anchor:query:start */",
1874
- $queryParameters ? indent(2, $queryParameters) : void 0,
1875
- " /* @anchor:query:end */",
1876
- "",
1877
- " /* @anchor:headers:start */",
1878
- $headerParameters ? indent(2, $headerParameters) : void 0,
1879
- " /* @anchor:headers:end */",
1880
- "",
1881
- " /* @anchor:path-parameters:start */",
1882
- $pathParameters ? indent(2, $pathParameters) : void 0,
1883
- " /* @anchor:path-parameters:end */",
1884
- "",
1885
- " /* @anchor:body:start */",
1886
- $requestBody ? indent(2, $requestBody) : void 0,
1887
- " /* @anchor:body:end */",
1888
- "",
1889
- " return req",
1890
- "}"
1891
- ].filter(R18.isNotNil).join("\n");
1892
- }
1893
- renderOperationDeclaration(operationDefinition) {
1894
- const { operationId } = operationDefinition;
1895
- const typeName = typeNameFactory(operationDefinition);
1896
- const mediaTypes = this.helper.getRequestMediaTypes();
1897
- if (mediaTypes.length === 0) {
1898
- return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends never = never>(args?: ${typeName("RequestParameters")}): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1899
- } else if (mediaTypes.length === 1) {
1900
- return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${typeName("RequestParameters")}): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1901
- } else if (mediaTypes.length > 1) {
1902
- return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${typeName("RequestParameters")}["content-type"]>(args?: Extract<${typeName("RequestParameters")}, { "content-type": CONTENT_TYPE }>): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
1903
- }
1904
- throw new Exception(operationDefinition.module, "[operationDeclarationRenderer] Unreachable");
1905
- }
1906
- };
1907
-
1908
- // src/transformers/operation-definition/operation-definition.transformer.ts
1909
- var OperationDefinitionTransformer = class {
1910
- static toDeclaration(operationDefinition, options) {
1911
- return new DeclarationRenderer2(operationDefinition, options).render();
1912
- }
1913
- static toMicroFunction(operationDefinition, options) {
1914
- return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render();
1915
- }
1916
- static toNestjsMethod(operationDefinition, options) {
1917
- return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render();
1918
- }
1919
- static toComment(operationDefinition) {
1920
- return new CommentRenderer2(operationDefinition).render();
1921
- }
1922
- };
1923
-
1924
- // src/transformers/entrypoint/entrypoint.transformer.ts
1925
- var path7 = __toESM(require("path"), 1);
1926
- var EntrypointTransformer = class {
1927
- static toTypescript(exports2, options) {
1928
- const $exports = exports2.map((exportArtifact) => {
1929
- const relativePath = path7.relative(
1930
- options.dirpath,
1931
- exportArtifact.filepath
1932
- ).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, options.esm ? ".js" : "");
1933
- return relativePath.startsWith(".") ? `export * from '${relativePath}'` : `export * from './${relativePath}'`;
1934
- });
1935
- return [
1936
- "/* @anchor:file:start */",
1937
- "",
1938
- ...$exports,
1939
- "",
1940
- "/* @anchor:file:end */"
1941
- ].join("\n");
1942
- }
1943
- };
1944
-
1945
- // src/transformers/api-document/nestjs-client.renderer.ts
1946
- var R19 = __toESM(require("ramda"), 1);
1947
- var changeCase2 = __toESM(require("change-case"), 1);
1948
- var NestjsClientRenderer = class {
1949
- constructor(document, options) {
1950
- this.document = document;
1951
- this.options = options;
1952
- }
1953
- renderDependencies() {
1954
- const $operations = this.document.operations.map((operationDefinition) => {
1955
- const filepath = this.options.getOperationDefinitionDeclarationFilepath(operationDefinition);
1956
- const typeName = typeNameFactory(operationDefinition);
1957
- return `import type { ${typeName("Operation")}, ${typeName("ResponseBodies")}, ${typeName("RequestParameters")} } from "${filepath}"`;
1958
- }).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
1959
- return [
1960
- 'import { Injectable, Logger } from "@nestjs/common"',
1961
- 'import { Keq, KeqRequest } from "keq"',
1962
- ...$operations
1963
- ].join("\n");
1964
- }
1965
- render() {
1966
- const moduleName = changeCase2.pascalCase(this.document.module.name);
1967
- const $dependencies = this.renderDependencies();
1968
- const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
1969
- esm: this.options.esm
1970
- })).join("\n\n");
1971
- return [
1972
- "/* @anchor:file:start */",
1973
- "",
1974
- $dependencies,
1975
- "",
1976
- "@Injectable()",
1977
- `export class ${moduleName}Client {`,
1978
- ` private readonly logger = new Logger(${moduleName}Client.name)`,
1979
- "",
1980
- " constructor(",
1981
- " // @anchor:client-constructor-parameters:start",
1982
- " private readonly request: KeqRequest,",
1983
- " // @anchor:client-constructor-parameters:end",
1984
- " ) {}",
1985
- "",
1986
- indent(2, $operations),
1987
- "}",
1988
- "",
1989
- "/* @anchor:file:end */"
1990
- ].filter(R19.isNotNil).join("\n");
1991
- }
1992
- };
1993
-
1994
- // src/transformers/api-document/nestjs-module.renderer.ts
1995
- var changeCase3 = __toESM(require("change-case"), 1);
1996
- var NestjsModuleRenderer = class {
1997
- constructor(document, options) {
1998
- this.document = document;
1999
- this.options = options;
2000
- }
2001
- render() {
2002
- const moduleName = changeCase3.pascalCase(this.document.module.name);
2003
- const clientFilepath = this.options.getNestjsClientFilepath(this.document).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, this.options.esm ? ".js" : "");
2004
- return [
2005
- "/* @anchor:file:start */",
2006
- 'import { Module, Inject, ConfigurableModuleBuilder, Global } from "@nestjs/common"',
2007
- 'import { KeqRequest } from "keq"',
2008
- 'import { KeqModuleOptions } from "@keq-request/nestjs"',
2009
- `import { ${moduleName}Client } from "${clientFilepath}"`,
2010
- "",
2011
- "",
2012
- "const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder<KeqModuleOptions>().build()",
2013
- "",
2014
- "@Global()",
2015
- "@Module({",
2016
- " imports: [],",
2017
- " controllers: [],",
2018
- ` providers: [${moduleName}Client],`,
2019
- ` exports: [${moduleName}Client],`,
2020
- "})",
2021
- `export class ${moduleName}Module extends ConfigurableModuleClass {`,
2022
- "",
2023
- " constructor(",
2024
- " @Inject(MODULE_OPTIONS_TOKEN) private readonly options: KeqModuleOptions,",
2025
- " private readonly request: KeqRequest,",
2026
- " ) {",
2027
- " super()",
2028
- " }",
2029
- "",
2030
- " onModuleInit() {",
2031
- " if (this.options.middlewares) {",
2032
- " for (const middleware of this.options.middlewares) {",
2033
- " this.request.use(middleware)",
2034
- " }",
2035
- " }",
2036
- " }",
2037
- "}",
2038
- "",
2039
- "/* @anchor:file:end */"
2040
- ].join("\n");
2041
- }
2042
- };
2043
-
2044
- // src/transformers/api-document/api-document.transformer.ts
2045
- var ApiDocumentTransformer = class {
2046
- static toNestjsModule(document, options) {
2047
- return new NestjsModuleRenderer(document, options).render();
2048
- }
2049
- static toNestjsClient(document, options) {
2050
- return new NestjsClientRenderer(document, options).render();
2051
- }
2052
- };
2053
-
2054
- // src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
2055
- var R20 = __toESM(require("ramda"), 1);
2056
- var path8 = __toESM(require("path"), 1);
2057
- var changeCase4 = __toESM(require("change-case"), 1);
2058
-
2059
- // src/plugins/generate-declaration/constants/metadata-storage.ts
2060
- var MetadataStorage2 = /* @__PURE__ */ new WeakMap();
2061
-
2062
- // src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
2063
- var SCHEMA_GENERATOR = "schemaGenerator";
2064
- var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
2065
- async compile(compiler, task) {
2066
- const context = compiler.context;
2067
- const metadata = MetadataStorage2.get(compiler);
2068
- const rc = context.rc;
2069
- const documents = context.documents;
2070
- const schemaDefinitions = documents.flatMap((document) => document.schemas);
2071
- const artifactMap = new Map(
2072
- await Promise.all(
2073
- schemaDefinitions.map(async (schemaDefinition) => [
2074
- schemaDefinition,
2075
- await metadata.hooks.afterSchemaDeclarationArtifactGenerated.promise(
2076
- this.generateSchemaDefinitionsArtifact(schemaDefinition, rc),
2077
- schemaDefinition,
2078
- task
2079
- )
2080
- ])
2081
- )
2082
- );
2083
- const entrypoints = R20.collectBy(
2084
- (schemaDefinition) => schemaDefinition.module.name,
2085
- schemaDefinitions
2086
- ).map((schemaDefinitions2) => [
2087
- schemaDefinitions2[0].module,
2088
- schemaDefinitions2.map((schemaDefinition) => artifactMap.get(schemaDefinition)).filter((artifact) => Boolean(artifact))
2089
- ]).map(([moduleDefinition, artifacts]) => this.generateEntrypointArtifact(
2090
- moduleDefinition,
2091
- artifacts,
2092
- rc
2093
- ));
2094
- return [...artifactMap.values(), ...entrypoints];
2095
- }
2096
- generateSchemaDefinitionsArtifact(schemaDefinition, rc) {
2097
- const filepath = _SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(schemaDefinition, rc.fileNamingStyle);
2098
- const dirpath = path8.dirname(filepath);
2099
- const artifact = new Artifact({
2100
- id: _SchemaDeclarationGenerator.getSchemaDefinitionArtifactId(schemaDefinition),
2101
- filepath,
2102
- content: SchemaDefinitionTransformer.toDeclaration(
2103
- schemaDefinition,
2104
- {
2105
- esm: rc.esm,
2106
- getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
2107
- const relativePath = path8.relative(
2108
- dirpath,
2109
- _SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
2110
- );
2111
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2112
- }
2113
- }
2114
- ),
2115
- extensionName: ".schema.ts"
2116
- });
2117
- return artifact;
2118
- }
2119
- generateEntrypointArtifact(moduleDefinition, exports2, rc) {
2120
- const filepath = _SchemaDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
2121
- const dirpath = path8.dirname(filepath);
2122
- const artifact = new Artifact({
2123
- id: _SchemaDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
2124
- filepath,
2125
- content: EntrypointTransformer.toTypescript(exports2, { dirpath })
2126
- });
2127
- return artifact;
2128
- }
2129
- static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
2130
- return [
2131
- ".",
2132
- changeCase4[fileNamingStyle](moduleDefinition.name),
2133
- "types",
2134
- "components",
2135
- "schemas",
2136
- "index.ts"
2137
- ].join("/");
2138
- }
2139
- static getEntrypointArtifactId(moduleDefinition) {
2140
- return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
2141
- }
2142
- static getSchemaDefinitionArtifactFilepath(schemaDefinition, fileNamingStyle) {
2143
- const filename = `${changeCase4[fileNamingStyle](schemaDefinition.name)}.schema.ts`;
2144
- return [
2145
- ".",
2146
- changeCase4[fileNamingStyle](schemaDefinition.module.name),
2147
- "types",
2148
- "components",
2149
- "schemas",
2150
- filename
2151
- ].join("/");
2152
- }
2153
- static getSchemaDefinitionArtifactId(schemaDefinition) {
2154
- return `${schemaDefinition.id}?generator=${SCHEMA_GENERATOR}`;
2155
- }
2156
- };
2157
-
2158
- // src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
2159
- var OPERATION_GENERATOR = "operationDeclarationGenerator";
2160
- var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
2161
- async compile(compiler, task) {
2162
- const context = compiler.context;
2163
- const metadata = MetadataStorage2.get(compiler);
2164
- const rc = context.rc;
2165
- const documents = context.documents;
2166
- const operationDefinitions = documents.flatMap((document) => document.operations);
2167
- const artifactMap = new Map(
2168
- await Promise.all(
2169
- operationDefinitions.map(async (operationDefinition) => [
2170
- operationDefinition,
2171
- await metadata.hooks.afterOperationDeclarationArtifactGenerated.promise(
2172
- this.generateOperationDefinitionArtifact(operationDefinition, rc),
2173
- operationDefinition,
2174
- task
2175
- )
2176
- ])
2177
- )
2178
- );
2179
- return Array.from(artifactMap.values());
2180
- }
2181
- generateOperationDefinitionArtifact(operationDefinition, rc) {
2182
- const filepath = _OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
2183
- const dirpath = path9.dirname(filepath);
2184
- const artifact = new Artifact({
2185
- id: _OperationDeclarationGenerator.getOperationDefinitionArtifactId(operationDefinition),
2186
- filepath,
2187
- content: OperationDefinitionTransformer.toDeclaration(
2188
- operationDefinition,
2189
- {
2190
- esm: rc.esm,
2191
- getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
2192
- const relativePath = path9.relative(
2193
- dirpath,
2194
- SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
2195
- );
2196
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2197
- }
2198
- }
2199
- ),
2200
- extensionName: ".type.ts"
2201
- });
2202
- return artifact;
2203
- }
2204
- generateEntrypointArtifact(moduleDefinition, exports2, rc) {
2205
- const filepath = _OperationDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
2206
- const dirpath = path9.dirname(filepath);
2207
- const artifact = new Artifact({
2208
- id: _OperationDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
2209
- filepath,
2210
- content: EntrypointTransformer.toTypescript(exports2, { dirpath })
2211
- });
2212
- return artifact;
2213
- }
2214
- static getOperationDefinitionArtifactFilepath(operationDefinition, fileNamingStyle) {
2215
- const filename = `${changeCase5[fileNamingStyle](operationDefinition.operationId)}.type.ts`;
2216
- const filepath = [
2217
- ".",
2218
- changeCase5[fileNamingStyle](operationDefinition.module.name),
2219
- "types",
2220
- "operations",
2221
- filename
2222
- ].join("/");
2223
- return filepath;
2224
- }
2225
- static getOperationDefinitionArtifactId(operationDefinition) {
2226
- return `${operationDefinition.id}?generator=${OPERATION_GENERATOR}`;
2227
- }
2228
- static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
2229
- return [
2230
- ".",
2231
- changeCase5[fileNamingStyle](moduleDefinition.name),
2232
- "types",
2233
- "operations",
2234
- "index.ts"
2235
- ].join("/");
2236
- }
2237
- static getEntrypointArtifactId(moduleDefinition) {
2238
- return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
2239
- }
2240
- };
2241
-
2242
- // src/plugins/generate-declaration/generate-declaration.plugin.ts
2243
- var DECLARATION_GENERATOR = "declarationGenerator";
2244
- var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
2245
- name = DECLARATION_GENERATOR;
2246
- operationGenerator = new OperationDeclarationGenerator();
2247
- schemaGenerator = new SchemaDeclarationGenerator();
2248
- constructor() {
2249
- }
2250
- apply(compiler) {
2251
- _GenerateDeclarationPlugin.register(compiler);
2252
- compiler.hooks.compile.tapPromise(_GenerateDeclarationPlugin.name, async (task) => {
2253
- compiler.context.artifacts?.push(
2254
- ...await this.schemaGenerator.compile(compiler, task),
2255
- ...await this.operationGenerator.compile(compiler, task)
2256
- );
2257
- });
2258
- }
2259
- static register(compiler) {
2260
- if (!MetadataStorage2.has(compiler)) {
2261
- MetadataStorage2.set(compiler, {
2262
- hooks: {
2263
- afterEntrypointArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "task"]),
2264
- afterSchemaDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "schemaDefinition", "task"]),
2265
- afterOperationDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
2266
- }
2267
- });
2268
- }
2269
- return MetadataStorage2.get(compiler);
2270
- }
2271
- static of(compiler) {
2272
- return this.register(compiler);
2273
- }
2274
- };
2275
-
2276
- // src/plugins/generate-micro-function/generators/request/request.generator.ts
2277
- var MICRO_FUNCTION_REQUEST_GENERATOR = "microFunctionRequestGenerator";
2278
- var RequestGenerator = class _RequestGenerator {
2279
- generateRequestArtifact() {
2280
- const content = [
2281
- "/* @anchor:file:start */",
2282
- "",
2283
- 'import { KeqRequest } from "keq"',
2284
- "",
2285
- "/* @anchor:request-declaration */",
2286
- "export const request = new KeqRequest()",
2287
- "",
2288
- "/* @anchor:file:end */"
2289
- ].join("\n");
2290
- return new Artifact({
2291
- id: _RequestGenerator.getRequestArtifactId(),
2292
- filepath: _RequestGenerator.getRequestArtifactFilepath(),
2293
- content
2294
- });
2295
- }
2296
- // eslint-disable-next-line @typescript-eslint/require-await
2297
- async compile(compiler, task) {
2298
- return [
2299
- this.generateRequestArtifact()
2300
- ];
2301
- }
2302
- static getRequestArtifactFilepath() {
2303
- return "./request.ts";
2304
- }
2305
- static getRequestArtifactId() {
2306
- return `request?generator=${MICRO_FUNCTION_REQUEST_GENERATOR}`;
2307
- }
2308
- };
2309
-
2310
- // src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
2311
- var MICRO_FUNCTION_GENERATOR = "microFunctionGenerator";
2312
- var MicroFunctionGenerator = class _MicroFunctionGenerator {
2313
- async compile(compiler, task) {
2314
- const metadata = MetadataStorage.get(compiler);
2315
- const context = compiler.context;
2316
- const rc = context.rc;
2317
- const documents = context.documents;
2318
- const operationDefinitions = documents.flatMap((document) => document.operations);
2319
- const artifactMap = new Map(
2320
- await Promise.all(
2321
- operationDefinitions.map(async (operationDefinition) => [
2322
- operationDefinition,
2323
- await metadata.hooks.afterMicroFunctionArtifactGenerated.promise(
2324
- this.generateOperationDefinitionArtifact(operationDefinition, rc),
2325
- operationDefinition,
2326
- task
2327
- )
2328
- ])
2329
- )
2330
- );
2331
- const entrypoints = await Promise.all(
2332
- R21.collectBy(
2333
- (operationDefinition) => operationDefinition.module.name,
2334
- operationDefinitions
2335
- ).map((operationDefinitions2) => [
2336
- operationDefinitions2[0].module,
2337
- operationDefinitions2.map((operationDefinition) => artifactMap.get(operationDefinition)).filter((artifact) => Boolean(artifact))
2338
- ]).map(async ([moduleDefinition, artifacts]) => await metadata.hooks.afterEntrypointArtifactGenerated.promise(
2339
- this.generateEntrypointArtifact(
2340
- moduleDefinition,
2341
- artifacts,
2342
- rc
2343
- ),
2344
- task
2345
- ))
2346
- );
2347
- return [...entrypoints, ...artifactMap.values()];
2348
- }
2349
- generateOperationDefinitionArtifact(operationDefinition, rc) {
2350
- const filepath = _MicroFunctionGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
2351
- const dirpath = path10.dirname(filepath);
2352
- const artifact = new Artifact({
2353
- id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
2354
- filepath,
2355
- content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
2356
- esm: rc.esm,
2357
- getOperationDefinitionDeclarationFilepath(operationDefinition2) {
2358
- const relativePath = path10.relative(
2359
- dirpath,
2360
- OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition2, rc.fileNamingStyle)
2361
- );
2362
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2363
- },
2364
- getRequestFilepath() {
2365
- const relativePath = path10.relative(
2366
- dirpath,
2367
- RequestGenerator.getRequestArtifactFilepath()
2368
- );
2369
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2370
- }
2371
- }),
2372
- extensionName: ".type.ts"
2373
- });
2374
- return artifact;
2375
- }
2376
- generateEntrypointArtifact(moduleDefinition, exports2, rc) {
2377
- const filepath = _MicroFunctionGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
2378
- const dirpath = filepath.substring(0, filepath.lastIndexOf("/"));
2379
- const artifact = new Artifact({
2380
- id: _MicroFunctionGenerator.getEntrypointArtifactId(moduleDefinition),
2381
- filepath,
2382
- content: EntrypointTransformer.toTypescript(exports2, { dirpath })
2383
- });
2384
- return artifact;
2385
- }
2386
- static getOperationDefinitionArtifactFilepath(operationDefinition, fileNamingStyle) {
2387
- const filename = `${changeCase6[fileNamingStyle](operationDefinition.operationId)}.fn.ts`;
2388
- const filepath = [
2389
- ".",
2390
- changeCase6[fileNamingStyle](operationDefinition.module.name),
2391
- "operations",
2392
- filename
2393
- ].join("/");
2394
- return filepath;
2395
- }
2396
- static getOperationDefinitionArtifactId(operationDefinition) {
2397
- return `${operationDefinition.id}?generator=${MICRO_FUNCTION_GENERATOR}`;
2398
- }
2399
- static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
2400
- return [
2401
- ".",
2402
- changeCase6[fileNamingStyle](moduleDefinition.name),
2403
- "operations",
2404
- "index.ts"
2405
- ].join("/");
2406
- }
2407
- static getEntrypointArtifactId(moduleDefinition) {
2408
- return `${moduleDefinition.address}/paths/entrypoint?generator=${MICRO_FUNCTION_GENERATOR}`;
2409
- }
2410
- };
2411
-
2412
- // src/plugins/generate-micro-function/generate-micro-function.plugin.ts
2413
- var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
2414
- microFunctionGenerator = new MicroFunctionGenerator();
2415
- requestGenerator = new RequestGenerator();
2416
- apply(compiler) {
2417
- _GenerateMicroFunctionPlugin.register(compiler);
2418
- compiler.hooks.compile.tapPromise(_GenerateMicroFunctionPlugin.name, async (task) => {
2419
- const artifacts = [
2420
- ...await this.requestGenerator.compile(compiler, task),
2421
- ...await this.microFunctionGenerator.compile(compiler, task)
2422
- ];
2423
- compiler.context.artifacts.push(...artifacts);
2424
- });
2425
- }
2426
- static register(compiler) {
2427
- if (!MetadataStorage.has(compiler)) {
2428
- MetadataStorage.set(compiler, {
2429
- hooks: {
2430
- afterEntrypointArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "task"]),
2431
- afterMicroFunctionArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
2432
- }
2433
- });
2434
- }
2435
- return MetadataStorage.get(compiler);
2436
- }
2437
- static of(compiler) {
2438
- return this.register(compiler);
2439
- }
2440
- };
2441
-
2442
- // src/plugins/generate-nestjs-module/generate-nestjs-module.ts
2443
- var import_tapable3 = require("tapable");
2444
-
2445
- // src/plugins/generate-nestjs-module/constants/metadata-storage.ts
2446
- var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
2447
-
2448
- // src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts
2449
- var path11 = __toESM(require("path"), 1);
2450
- var changeCase7 = __toESM(require("change-case"), 1);
2451
- var NESTJS_MODULE_GENERATOR = "nestjs-module-generator";
2452
- var NestjsModuleGenerator = class _NestjsModuleGenerator {
2453
- generateNestjsModuleArtifact(document, rc) {
2454
- const filepath = _NestjsModuleGenerator.getNestjsModuleArtifactFilepath(document, rc.fileNamingStyle);
2455
- const dirname6 = path11.dirname(filepath);
2456
- const artifact = new Artifact({
2457
- id: _NestjsModuleGenerator.getNestjsModuleArtifactId(document),
2458
- filepath,
2459
- content: ApiDocumentTransformer.toNestjsModule(document, {
2460
- esm: rc.esm,
2461
- getNestjsClientFilepath(document2) {
2462
- const relativePath = path11.relative(
2463
- dirname6,
2464
- _NestjsModuleGenerator.getNestjsClientArtifactFilepath(document2, rc.fileNamingStyle)
2465
- );
2466
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2467
- }
2468
- })
2469
- });
2470
- return artifact;
2471
- }
2472
- generateNestjsClientArtifact(document, rc) {
2473
- const filepath = _NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle);
2474
- const dirpath = path11.dirname(filepath);
2475
- const artifact = new Artifact({
2476
- id: _NestjsModuleGenerator.getNestjsClientArtifactId(document),
2477
- filepath,
2478
- content: ApiDocumentTransformer.toNestjsClient(document, {
2479
- esm: rc.esm,
2480
- getOperationDefinitionDeclarationFilepath(operationDefinition) {
2481
- const relativePath = path11.relative(
2482
- dirpath,
2483
- OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)
2484
- );
2485
- return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
2486
- }
2487
- })
2488
- });
2489
- return artifact;
2490
- }
2491
- async compile(compiler, task) {
2492
- const metadata = MetadataStorage3.get(compiler);
2493
- const rc = compiler.context.rc;
2494
- const documents = compiler.context.documents;
2495
- const nestjsModuleArtifacts = await Promise.all(
2496
- documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(
2497
- this.generateNestjsModuleArtifact(document, rc),
2498
- document,
2499
- task
2500
- ))
2501
- );
2502
- const nestjsClientArtifacts = await Promise.all(
2503
- documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(
2504
- this.generateNestjsClientArtifact(document, rc),
2505
- document,
2506
- task
2507
- ))
2508
- );
2509
- return [...nestjsModuleArtifacts, ...nestjsClientArtifacts];
2510
- }
2511
- static getNestjsModuleArtifactFilepath(document, fileNamingStyle) {
2512
- const filename = `${changeCase7[fileNamingStyle](document.module.name)}.module.ts`;
2513
- const filepath = [
2514
- ".",
2515
- changeCase7[fileNamingStyle](document.module.name),
2516
- filename
2517
- ];
2518
- return filepath.join("/");
2519
- }
2520
- static getNestjsModuleArtifactId(document) {
2521
- return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}`;
2522
- }
2523
- static getNestjsClientArtifactFilepath(document, fileNamingStyle) {
2524
- const filename = `${changeCase7[fileNamingStyle](document.module.name)}.client.ts`;
2525
- const filepath = [
2526
- ".",
2527
- changeCase7[fileNamingStyle](document.module.name),
2528
- filename
2529
- ];
2530
- return filepath.join("/");
2531
- }
2532
- static getNestjsClientArtifactId(document) {
2533
- return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}-client`;
2534
- }
2535
- };
2536
-
2537
- // src/plugins/generate-nestjs-module/generate-nestjs-module.ts
2538
- var GenerateNestjsModulePlugin = class _GenerateNestjsModulePlugin {
2539
- nestjsModuleGenerator = new NestjsModuleGenerator();
2540
- apply(compiler) {
2541
- _GenerateNestjsModulePlugin.register(compiler);
2542
- compiler.hooks.compile.tapPromise(_GenerateNestjsModulePlugin.name, async (task) => {
2543
- const artifacts = await this.nestjsModuleGenerator.compile(compiler, task);
2544
- compiler.context.artifacts.push(...artifacts);
2545
- });
2546
- }
2547
- static register(compiler) {
2548
- if (!MetadataStorage3.has(compiler)) {
2549
- MetadataStorage3.set(compiler, {
2550
- hooks: {
2551
- afterNestjsModuleArtifactGenerated: new import_tapable3.AsyncSeriesWaterfallHook(["artifact", "document", "task"])
2552
- }
2553
- });
2554
- }
2555
- return MetadataStorage3.get(compiler);
2556
- }
2557
- static of(compiler) {
2558
- return MetadataStorage3.get(compiler);
2559
- }
2560
- };
2561
-
2562
- // src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts
2563
- var import_swagger_fix = require("swagger-fix");
2564
-
2565
- // src/plugins/download-http-file/download-http-file.plugin.ts
2566
- var validUrl = __toESM(require("valid-url"), 1);
2567
- var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
2568
- apply(compiler) {
2569
- compiler.hooks.download.tapPromise(_DownloadHttpFilePlugin.name, async (address, task) => {
2570
- if (!validUrl.isUri(address)) return void 0;
2571
- const content = await this.download(address);
2572
- const spec = this.deserialize(content);
2573
- return JSON.stringify(spec);
2574
- });
2575
- }
2576
- async download(address) {
2577
- try {
2578
- const res = await fetch(address);
2579
- if (res.status >= 400) throw new Error(`failed with status code ${res.status}`);
2580
- return await res.text();
2581
- } catch (e) {
2582
- if (e instanceof Error) {
2583
- e.message = `Unable get the openapi/swagger file from ${address}: ${e.message}`;
2584
- }
2585
- throw e;
2586
- }
2587
- }
2588
- deserialize(content) {
2589
- const json = JSON.parse(content);
2590
- const spec = OpenapiUtils.to3_1(json);
2591
- return spec;
2592
- }
2593
- };
2594
-
2595
- // src/plugins/download-local-file/download-local-file.plugin.ts
2596
- var path12 = __toESM(require("path"), 1);
2597
- var fs5 = __toESM(require("fs/promises"), 1);
2598
- var yaml = __toESM(require("js-yaml"), 1);
2599
- var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
2600
- apply(compiler) {
2601
- compiler.hooks.download.tapPromise(_DownloadLocalFilePlugin.name, async (address, task) => {
2602
- if (!address.startsWith("./") && !address.startsWith("/") && !address.startsWith("../")) return void 0;
2603
- const fileExt = path12.extname(address);
2604
- const content = await fs5.readFile(address, "utf8");
2605
- if ([".yml", ".yaml"].includes(fileExt)) {
2606
- const value = yaml.load(content);
2607
- return JSON.stringify(OpenapiUtils.to3_1(value));
2608
- } else if (fileExt === ".json") {
2609
- return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(content)));
2610
- }
2611
- });
2612
- }
2613
- };
2614
-
2615
- // src/plugins/shaking/shaking.plugin.ts
2616
- var import_openapi_shaking = require("@opendoc/openapi-shaking");
2617
- var ShakingPlugin = class _ShakingPlugin {
2618
- apply(compiler) {
2619
- compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
2620
- const matcher = compiler.context.matcher;
2621
- const documents = compiler.context.documents;
2622
- compiler.context.documents = documents.map((document) => this.shaking(compiler, document)).filter((document) => !document.isEmpty()).filter((document) => !matcher.isModuleIgnored(document.module));
2623
- });
2624
- }
2625
- shaking(compiler, document) {
2626
- const rc = compiler.context.rc;
2627
- const matcher = compiler.context.matcher;
2628
- const isAccepted = (pathname, method, operation) => {
2629
- if (!SupportedMethods.includes(method)) return false;
2630
- return !matcher.isOperationIgnored(new OperationDefinition({
2631
- method,
2632
- pathname,
2633
- operation,
2634
- module: document.module,
2635
- document
2636
- }));
2637
- };
2638
- const sharkedSwagger = (0, import_openapi_shaking.openapiShakingSync)(
2639
- document.specification,
2640
- isAccepted,
2641
- { tolerant: rc.tolerant }
2642
- );
2643
- return new ApiDocumentV3_1(
2644
- sharkedSwagger,
2645
- new ModuleDefinition(
2646
- document.module.name,
2647
- `file://${document.module.name}.v3_1.sharked.json`
2648
- )
2649
- );
2650
- }
2651
- };
2652
-
2653
- // src/plugins/terminal-select/utils/select-operation-definitions.ts
2654
- var import_inquirer_select_pro = require("inquirer-select-pro");
2655
- var import_prompt_adapter_inquirer = require("@listr2/prompt-adapter-inquirer");
2656
- async function selectOperationDefinitions(task, operationDefinitions) {
2657
- const selectedOperationDefinitions = await task.prompt(import_prompt_adapter_inquirer.ListrInquirerPromptAdapter).run(
2658
- import_inquirer_select_pro.select,
2659
- {
2660
- message: "Select Pathname",
2661
- defaultValue: [],
2662
- options: (input) => {
2663
- const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }));
2664
- if (!input) return items;
2665
- const keys2 = input.trim().toLowerCase().split(/\s+/);
2666
- return items.filter((i) => {
2667
- const name = i.name.toLowerCase();
2668
- return keys2.every((q) => name.includes(q));
2669
- });
2670
- }
2671
- }
2672
- );
2673
- return selectedOperationDefinitions;
1337
+ //#endregion
1338
+ //#region src/cli.ts
1339
+ if (semver.default.lt(process.version, "20.0.0")) throw new Error("Node.js version must be greater than 20");
1340
+ const program = new commander.Command();
1341
+ registerBuildCommand(program);
1342
+ registerFilterCommand(program);
1343
+ registerListCommand(program);
1344
+ registerApisCommand(program);
1345
+ registerMockCommand(program);
1346
+ registerInitCommand(program);
1347
+ registerSearchCommand(program);
1348
+ registerMcpCommand(program);
1349
+ async function main() {
1350
+ program.on("command:*", function(operands) {
1351
+ throw new Error(`Unknown command '${String(operands[0])}'`);
1352
+ });
1353
+ try {
1354
+ await program.parseAsync(process.argv);
1355
+ } catch (err) {
1356
+ if (process.argv.includes("--debug")) console.error(err);
1357
+ else require_logger.logger.error(err instanceof Error ? err.message : String(err));
1358
+ process.exit(1);
1359
+ }
2674
1360
  }
1361
+ main();
1362
+ //#endregion
2675
1363
 
2676
- // src/plugins/terminal-select/terminal-select.plugin.ts
2677
- var TerminalSelectPlugin = class _TerminalSelectPlugin {
2678
- constructor(options) {
2679
- this.options = options;
2680
- }
2681
- apply(compiler) {
2682
- compiler.hooks.afterDownload.tapPromise(_TerminalSelectPlugin.name, async (task) => {
2683
- const context = compiler.context;
2684
- const matcher = context.matcher;
2685
- const documents = context.documents;
2686
- const operationDefinitions = documents.flatMap((document) => document.operations);
2687
- const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions);
2688
- if (this.options.clear) {
2689
- matcher.append({
2690
- persist: false,
2691
- ignore: true,
2692
- moduleName: "*",
2693
- operationMethod: "*",
2694
- operationPathname: "*"
2695
- });
2696
- }
2697
- for (const op of selectedOperationDefinitions) {
2698
- matcher.append({
2699
- persist: !!this.options.persist,
2700
- ignore: this.options.mode === "add",
2701
- moduleName: op.module.name,
2702
- operationMethod: op.method,
2703
- operationPathname: op.pathname
2704
- });
2705
- }
2706
- });
2707
- }
2708
- };
2709
-
2710
- // src/plugins/initialize/initialize.plugin.ts
2711
- var R23 = __toESM(require("ramda"), 1);
2712
- var InitializePlugin = class _InitializePlugin {
2713
- constructor(options) {
2714
- this.options = options;
2715
- }
2716
- apply(compiler) {
2717
- compiler.hooks.setup.tap(_InitializePlugin.name, (task) => {
2718
- new DownloadHttpFilePlugin().apply(compiler);
2719
- new DownloadLocalFilePlugin().apply(compiler);
2720
- new GenerateDeclarationPlugin().apply(compiler);
2721
- if (this.options.build) {
2722
- new ShakingPlugin().apply(compiler);
2723
- }
2724
- if (this.options.interactive) {
2725
- new TerminalSelectPlugin(
2726
- typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
2727
- ).apply(compiler);
2728
- }
2729
- const rc = compiler.context.rc;
2730
- if (rc.mode === "micro-function") {
2731
- new GenerateMicroFunctionPlugin().apply(compiler);
2732
- } else if (rc.mode === "nestjs-module") {
2733
- new GenerateNestjsModulePlugin().apply(compiler);
2734
- }
2735
- if (rc.plugins && rc.plugins.length) {
2736
- for (const plugin of rc.plugins) {
2737
- plugin.apply(compiler);
2738
- }
2739
- }
2740
- });
2741
- if (this.options.includes && this.options.includes.length) {
2742
- const modulesIncludes = this.options.includes;
2743
- compiler.hooks.afterSetup.tap(_InitializePlugin.name, (task) => {
2744
- const rc = compiler.context.rc;
2745
- const matcher = compiler.context.matcher;
2746
- const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules));
2747
- if (notExistModules.length) {
2748
- throw new Error(`Cannot find module(s) ${notExistModules.join(", ")} in config file.`);
2749
- }
2750
- const ignoredModules = R23.difference(R23.keys(rc.modules), modulesIncludes);
2751
- for (const moduleName of ignoredModules) {
2752
- matcher.append({
2753
- persist: false,
2754
- ignore: true,
2755
- moduleName,
2756
- operationMethod: "*",
2757
- operationPathname: "*"
2758
- });
2759
- }
2760
- });
2761
- }
2762
- }
2763
- };
2764
-
2765
- // src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
2766
- var QsArrayFormatUnion = Object.values(QsArrayFormat);
2767
-
2768
- // src/compiler/compiler.ts
2769
- var Compiler = class {
2770
- constructor(options) {
2771
- this.options = options;
2772
- for (const hook of Object.values(this.hooks)) {
2773
- hook.intercept(perfectErrorMessage());
2774
- }
2775
- this.hooks.afterSetup.intercept(printInformation(0));
2776
- this.hooks.afterPersist.intercept(printInformation(0));
2777
- new InitializePlugin({
2778
- build: options.build,
2779
- interactive: options.interactive,
2780
- includes: options.includes
2781
- }).apply(this);
2782
- }
2783
- context = {};
2784
- hooks = {
2785
- setup: new import_tapable4.AsyncParallelHook(["task"]),
2786
- afterSetup: new import_tapable4.AsyncSeriesHook(["task"]),
2787
- beforeDownload: new import_tapable4.AsyncSeriesHook(["task"]),
2788
- download: new import_tapable4.AsyncSeriesBailHook(["address", "moduleDefinition", "task"]),
2789
- afterDownload: new import_tapable4.AsyncSeriesHook(["task"]),
2790
- beforeCompile: new import_tapable4.AsyncSeriesHook(["task"]),
2791
- compile: new import_tapable4.AsyncParallelHook(["task"]),
2792
- afterCompile: new import_tapable4.AsyncSeriesHook(["task"]),
2793
- beforePersist: new import_tapable4.AsyncSeriesHook(["task"]),
2794
- persist: new import_tapable4.AsyncParallelHook(["task"]),
2795
- afterPersist: new import_tapable4.AsyncSeriesHook(["task"]),
2796
- done: new import_tapable4.SyncHook()
2797
- };
2798
- async run() {
2799
- const options = this.options;
2800
- const tasks = new import_listr22.Listr(
2801
- [
2802
- createSetupTask(this, options),
2803
- createDownloadTask(this, { skipIgnoredModules: !options.interactive }),
2804
- createCompileTask(this, { enabled: !!options.build }),
2805
- createPersistTask(this)
2806
- ],
2807
- {
2808
- concurrent: false,
2809
- renderer: "default",
2810
- rendererOptions: {
2811
- suffixSkips: true,
2812
- collapseSubtasks: false,
2813
- collapseErrors: false
2814
- }
2815
- }
2816
- );
2817
- await tasks.run(this.context);
2818
- await this.hooks.done.promise();
2819
- }
2820
- };
2821
-
2822
- // src/cli.ts
2823
- if (import_semver.default.lt(process.version, "20.0.0")) {
2824
- throw new Error("Node.js version must be greater than 20");
2825
- }
2826
- var program = new import_commander.Command();
2827
- program.command("build").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to generate").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("-i --interactive", "Interactive select the scope of generation").action(async (options) => {
2828
- const compiler = new Compiler({
2829
- build: true,
2830
- config: options.config,
2831
- includes: options.module,
2832
- debug: !!options.debug,
2833
- tolerant: !!options.tolerant,
2834
- interactive: !!options.interactive && {
2835
- mode: "except",
2836
- clear: true
2837
- }
2838
- });
2839
- await compiler.run();
2840
- });
2841
- program.command("ignore").addArgument(
2842
- new import_commander.Argument("<mode>", "The ignore mode").choices(["all", "add", "except"]).argRequired()
2843
- ).option("-c --config <config>", "The keq-cli config file").option("--debug", "Print debug information").option("--module <modules...>").option("--build", "Build after updating .keqignore file").addOption(
2844
- new import_commander.Option("--method <method>", "Only generate files of the specified operation method").choices([
2845
- ...SupportedMethods,
2846
- ...SupportedMethods.map((method) => method.toUpperCase())
2847
- ])
2848
- ).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").option("-i --interactive", "Interactive select the scope of generation").action(async (mode, options) => {
2849
- let compiler;
2850
- if (mode === "all") {
2851
- if (options.build) throw new Error("'--build' cannot be used with 'all' mode");
2852
- compiler = new Compiler({
2853
- build: false,
2854
- config: options.config,
2855
- includes: options.module,
2856
- debug: !!options.debug,
2857
- interactive: false,
2858
- ignore: {
2859
- rules: [{
2860
- persist: true,
2861
- ignore: true,
2862
- moduleName: "*",
2863
- operationMethod: "*",
2864
- operationPathname: "*"
2865
- }]
2866
- }
2867
- });
2868
- } else if (options.interactive) {
2869
- if (options.interactive) {
2870
- if (options.method) throw new Error("'--method' cannot be used with '--interactive'");
2871
- if (options.pathname) throw new Error("'--pathname' cannot be used with '--interactive'");
2872
- }
2873
- compiler = new Compiler({
2874
- build: !!options.build,
2875
- config: options.config,
2876
- includes: options.module,
2877
- debug: !!options.debug,
2878
- interactive: {
2879
- mode,
2880
- persist: true
2881
- }
2882
- });
2883
- } else {
2884
- if (!options.method && !options.pathname) {
2885
- throw new Error("at least one of '-i --interactive', '--method' or '--pathname' must be specified");
2886
- }
2887
- const moduleNames = options.module || ["*"];
2888
- compiler = new Compiler({
2889
- build: !!options.build,
2890
- config: options.config,
2891
- debug: !!options.debug,
2892
- includes: options.module,
2893
- ignore: {
2894
- rules: moduleNames.map((moduleNames2) => ({
2895
- persist: true,
2896
- ignore: mode === "add",
2897
- moduleName: moduleNames2,
2898
- operationMethod: options.method,
2899
- operationPathname: options.pathname
2900
- }))
2901
- },
2902
- interactive: false
2903
- });
2904
- }
2905
- await compiler.run();
2906
- });
2907
- async function main5() {
2908
- program.on("command:*", function(operands) {
2909
- throw new Error(`Unknown command '${String(operands[0])}'`);
2910
- });
2911
- try {
2912
- await program.parseAsync(process.argv);
2913
- } catch (err) {
2914
- if (process.argv.includes("--debug")) {
2915
- console.error(err);
2916
- } else {
2917
- logger.error(err instanceof Error ? err.message : String(err));
2918
- }
2919
- }
2920
- }
2921
- void main5();
2922
1364
  //# sourceMappingURL=cli.cjs.map