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,1979 +1,1876 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
9
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
-
32
- // src/index.ts
33
- var index_exports = {};
34
- __export(index_exports, {
35
- AbortException: () => AbortException,
36
- BadGatewayException: () => BadGatewayException,
37
- BadRequestException: () => BadRequestException,
38
- ConflictException: () => ConflictException,
39
- ContentTooLargeException: () => ContentTooLargeException,
40
- Exception: () => Exception,
41
- ForbiddenException: () => ForbiddenException,
42
- GatewayTimeoutException: () => GatewayTimeoutException,
43
- ImATeapotException: () => ImATeapotException,
44
- InternalServerErrorException: () => InternalServerErrorException,
45
- Keq: () => Keq,
46
- KeqExecutionContext: () => KeqExecutionContext,
47
- KeqMiddlewareExecutor: () => KeqMiddlewareExecutor,
48
- KeqMiddlewareOrchestrator: () => KeqMiddlewareOrchestrator,
49
- KeqRequest: () => KeqRequest,
50
- KeqSharedContext: () => KeqSharedContext,
51
- MethodNotAllowedException: () => MethodNotAllowedException,
52
- NotAcceptableException: () => NotAcceptableException,
53
- NotFoundedException: () => NotFoundedException,
54
- NotImplementedException: () => NotImplementedException,
55
- PreconditionFailedException: () => PreconditionFailedException,
56
- ProxyAuthenticationRequiredException: () => ProxyAuthenticationRequiredException,
57
- RequestException: () => RequestException,
58
- RequestTimeoutException: () => RequestTimeoutException,
59
- ServiceUnavailableException: () => ServiceUnavailableException,
60
- TimeoutException: () => TimeoutException,
61
- TooManyRequestsException: () => TooManyRequestsException,
62
- TypeException: () => TypeException,
63
- UnauthorizedException: () => UnauthorizedException,
64
- UnsupportedMediaTypeException: () => UnsupportedMediaTypeException,
65
- UriTooLongException: () => UriTooLongException,
66
- composeMiddleware: () => composeMiddleware,
67
- composeRoute: () => composeRoute,
68
- createProxyResponse: () => createProxyResponse,
69
- createRequest: () => createRequest,
70
- request: () => request
71
- });
72
- module.exports = __toCommonJS(index_exports);
73
-
74
- // src/exception/exception.ts
75
- var import_ts_custom_error = require("ts-custom-error");
76
- var Exception = class extends import_ts_custom_error.CustomError {
77
- constructor(message) {
78
- super(message);
79
- Object.defineProperty(this, "name", { value: "KeqError" });
80
- }
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let ts_custom_error = require("ts-custom-error");
25
+ let _opendoc_uri_template = require("@opendoc/uri-template");
26
+ let mitt = require("mitt");
27
+ mitt = __toESM(mitt);
28
+ let klona = require("klona");
29
+ let klona_json = require("klona/json");
30
+ let eventsource_parser_stream = require("eventsource-parser/stream");
31
+ let qs = require("qs");
32
+ qs = __toESM(qs);
33
+ let picomatch = require("picomatch");
34
+ picomatch = __toESM(picomatch);
35
+ let fastq = require("fastq");
36
+ fastq = __toESM(fastq);
37
+ //#region src/exception/exception.ts
38
+ var Exception = class extends ts_custom_error.CustomError {
39
+ constructor(message) {
40
+ super(message);
41
+ Object.defineProperty(this, "name", { value: "KeqError" });
42
+ }
81
43
  };
82
-
83
- // src/exception/type.exception.ts
44
+ //#endregion
45
+ //#region src/exception/type.exception.ts
84
46
  var TypeException = class extends Exception {
85
- constructor(msg) {
86
- super(msg || "Invalid Type");
87
- }
47
+ constructor(msg) {
48
+ super(msg || "Invalid Type");
49
+ }
88
50
  };
89
-
90
- // src/exception/abort.exception.ts
91
- var AbortException = class _AbortException extends DOMException {
92
- constructor(msg) {
93
- super(msg, "AbortError");
94
- Object.setPrototypeOf(this, _AbortException.prototype);
95
- }
51
+ //#endregion
52
+ //#region src/exception/abort.exception.ts
53
+ var AbortException = class AbortException extends DOMException {
54
+ constructor(msg) {
55
+ super(msg, "AbortError");
56
+ Object.setPrototypeOf(this, AbortException.prototype);
57
+ }
96
58
  };
97
-
98
- // src/exception/timeout.exception.ts
59
+ //#endregion
60
+ //#region src/exception/timeout.exception.ts
99
61
  var TimeoutException = class extends AbortException {
100
- constructor(msg) {
101
- super(msg);
102
- }
62
+ constructor(msg) {
63
+ super(msg);
64
+ }
103
65
  };
104
-
105
- // src/exception/http-exceptions/request.exception.ts
66
+ //#endregion
67
+ //#region src/exception/mutex.exception.ts
68
+ var MutexException = class extends Exception {
69
+ constructor(message) {
70
+ super(message);
71
+ Object.defineProperty(this, "name", { value: "MutexException" });
72
+ }
73
+ };
74
+ //#endregion
75
+ //#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
76
+ function _typeof(o) {
77
+ "@babel/helpers - typeof";
78
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
79
+ return typeof o;
80
+ } : function(o) {
81
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
82
+ }, _typeof(o);
83
+ }
84
+ //#endregion
85
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
86
+ function toPrimitive(t, r) {
87
+ if ("object" != _typeof(t) || !t) return t;
88
+ var e = t[Symbol.toPrimitive];
89
+ if (void 0 !== e) {
90
+ var i = e.call(t, r || "default");
91
+ if ("object" != _typeof(i)) return i;
92
+ throw new TypeError("@@toPrimitive must return a primitive value.");
93
+ }
94
+ return ("string" === r ? String : Number)(t);
95
+ }
96
+ //#endregion
97
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
98
+ function toPropertyKey(t) {
99
+ var i = toPrimitive(t, "string");
100
+ return "symbol" == _typeof(i) ? i : i + "";
101
+ }
102
+ //#endregion
103
+ //#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
104
+ function _defineProperty(e, r, t) {
105
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
106
+ value: t,
107
+ enumerable: !0,
108
+ configurable: !0,
109
+ writable: !0
110
+ }) : e[r] = t, e;
111
+ }
112
+ //#endregion
113
+ //#region src/exception/http-exceptions/request.exception.ts
106
114
  var RequestException = class extends Exception {
107
- constructor(statusCode, message, options) {
108
- super(message);
109
- __publicField(this, "statusCode");
110
- __publicField(this, "retry");
111
- __publicField(this, "response");
112
- this.statusCode = statusCode;
113
- this.retry = !(options == null ? void 0 : options.fatal);
114
- this.response = options == null ? void 0 : options.response;
115
- Object.defineProperty(this, "name", { value: "RequestException" });
116
- }
115
+ constructor(statusCode, message, options) {
116
+ super(message);
117
+ _defineProperty(this, "statusCode", void 0);
118
+ _defineProperty(this, "retry", void 0);
119
+ _defineProperty(this, "response", void 0);
120
+ this.statusCode = statusCode;
121
+ this.retry = !options?.fatal;
122
+ this.response = options?.response;
123
+ Object.defineProperty(this, "name", { value: "RequestException" });
124
+ }
117
125
  };
118
-
119
- // src/exception/http-exceptions/bad-request.exception.ts
126
+ //#endregion
127
+ //#region src/exception/http-exceptions/bad-request.exception.ts
120
128
  var BadRequestException = class extends RequestException {
121
- constructor(message = "Bad Request", options) {
122
- super(400, message, { fatal: true, ...options });
123
- Object.defineProperty(this, "name", { value: "BadRequestException" });
124
- }
129
+ constructor(message = "Bad Request", options) {
130
+ super(400, message, {
131
+ fatal: true,
132
+ ...options
133
+ });
134
+ Object.defineProperty(this, "name", { value: "BadRequestException" });
135
+ }
125
136
  };
126
-
127
- // src/exception/http-exceptions/unauthorized.exception.ts
137
+ //#endregion
138
+ //#region src/exception/http-exceptions/unauthorized.exception.ts
128
139
  var UnauthorizedException = class extends RequestException {
129
- constructor(message = "Unauthorized", options) {
130
- super(401, message, { fatal: true, ...options });
131
- Object.defineProperty(this, "name", { value: "UnauthorizedException" });
132
- }
140
+ constructor(message = "Unauthorized", options) {
141
+ super(401, message, {
142
+ fatal: true,
143
+ ...options
144
+ });
145
+ Object.defineProperty(this, "name", { value: "UnauthorizedException" });
146
+ }
133
147
  };
134
-
135
- // src/exception/http-exceptions/forbidden.exception.ts
148
+ //#endregion
149
+ //#region src/exception/http-exceptions/forbidden.exception.ts
136
150
  var ForbiddenException = class extends RequestException {
137
- constructor(message = "Forbidden", options) {
138
- super(403, message, { fatal: true, ...options });
139
- Object.defineProperty(this, "name", { value: "ForbiddenException" });
140
- }
151
+ constructor(message = "Forbidden", options) {
152
+ super(403, message, {
153
+ fatal: true,
154
+ ...options
155
+ });
156
+ Object.defineProperty(this, "name", { value: "ForbiddenException" });
157
+ }
141
158
  };
142
-
143
- // src/exception/http-exceptions/not-founded.exception.ts
159
+ //#endregion
160
+ //#region src/exception/http-exceptions/not-founded.exception.ts
144
161
  var NotFoundedException = class extends RequestException {
145
- constructor(message = "Not Founded", options) {
146
- super(404, message, { fatal: true, ...options });
147
- Object.defineProperty(this, "name", { value: "NotFoundedException" });
148
- }
162
+ constructor(message = "Not Founded", options) {
163
+ super(404, message, {
164
+ fatal: true,
165
+ ...options
166
+ });
167
+ Object.defineProperty(this, "name", { value: "NotFoundedException" });
168
+ }
149
169
  };
150
-
151
- // src/exception/http-exceptions/method-not-allowed.exception.ts
170
+ //#endregion
171
+ //#region src/exception/http-exceptions/method-not-allowed.exception.ts
152
172
  var MethodNotAllowedException = class extends RequestException {
153
- constructor(message = "Method Not Allowed", options) {
154
- super(405, message, { fatal: true, ...options });
155
- Object.defineProperty(this, "name", {
156
- value: "MethodNotAllowedException"
157
- });
158
- }
173
+ constructor(message = "Method Not Allowed", options) {
174
+ super(405, message, {
175
+ fatal: true,
176
+ ...options
177
+ });
178
+ Object.defineProperty(this, "name", { value: "MethodNotAllowedException" });
179
+ }
159
180
  };
160
-
161
- // src/exception/http-exceptions/not-acceptable.exception.ts
181
+ //#endregion
182
+ //#region src/exception/http-exceptions/not-acceptable.exception.ts
162
183
  var NotAcceptableException = class extends RequestException {
163
- constructor(message = "Not Acceptable", options) {
164
- super(406, message, { fatal: true, ...options });
165
- Object.defineProperty(this, "name", { value: "NotAcceptableException" });
166
- }
184
+ constructor(message = "Not Acceptable", options) {
185
+ super(406, message, {
186
+ fatal: true,
187
+ ...options
188
+ });
189
+ Object.defineProperty(this, "name", { value: "NotAcceptableException" });
190
+ }
167
191
  };
168
-
169
- // src/exception/http-exceptions/proxy-authentication-required.exception.ts
192
+ //#endregion
193
+ //#region src/exception/http-exceptions/proxy-authentication-required.exception.ts
170
194
  var ProxyAuthenticationRequiredException = class extends RequestException {
171
- constructor(message = "Proxy Authentication Required", options) {
172
- super(407, message, { fatal: true, ...options });
173
- Object.defineProperty(this, "name", {
174
- value: "ProxyAuthenticationRequiredException"
175
- });
176
- }
195
+ constructor(message = "Proxy Authentication Required", options) {
196
+ super(407, message, {
197
+ fatal: true,
198
+ ...options
199
+ });
200
+ Object.defineProperty(this, "name", { value: "ProxyAuthenticationRequiredException" });
201
+ }
177
202
  };
178
-
179
- // src/exception/http-exceptions/request-timeout.exception.ts
203
+ //#endregion
204
+ //#region src/exception/http-exceptions/request-timeout.exception.ts
180
205
  var RequestTimeoutException = class extends RequestException {
181
- constructor(message = "Request Timeout", options) {
182
- super(408, message, { fatal: false, ...options });
183
- Object.defineProperty(this, "name", {
184
- value: "RequestTimeoutException"
185
- });
186
- }
206
+ constructor(message = "Request Timeout", options) {
207
+ super(408, message, {
208
+ fatal: false,
209
+ ...options
210
+ });
211
+ Object.defineProperty(this, "name", { value: "RequestTimeoutException" });
212
+ }
187
213
  };
188
-
189
- // src/exception/http-exceptions/conflict.exception.ts
214
+ //#endregion
215
+ //#region src/exception/http-exceptions/conflict.exception.ts
190
216
  var ConflictException = class extends RequestException {
191
- constructor(message = "Conflict", options) {
192
- super(409, message, { fatal: true, ...options });
193
- Object.defineProperty(this, "name", { value: "ConflictException" });
194
- }
217
+ constructor(message = "Conflict", options) {
218
+ super(409, message, {
219
+ fatal: true,
220
+ ...options
221
+ });
222
+ Object.defineProperty(this, "name", { value: "ConflictException" });
223
+ }
195
224
  };
196
-
197
- // src/exception/http-exceptions/precondition-failed.exception.ts
225
+ //#endregion
226
+ //#region src/exception/http-exceptions/precondition-failed.exception.ts
198
227
  var PreconditionFailedException = class extends RequestException {
199
- constructor(message = "Precondition Failed", options) {
200
- super(412, message, { fatal: true, ...options });
201
- Object.defineProperty(this, "name", {
202
- value: "PreconditionFailedException"
203
- });
204
- }
228
+ constructor(message = "Precondition Failed", options) {
229
+ super(412, message, {
230
+ fatal: true,
231
+ ...options
232
+ });
233
+ Object.defineProperty(this, "name", { value: "PreconditionFailedException" });
234
+ }
205
235
  };
206
-
207
- // src/exception/http-exceptions/content-too-large.exception.ts
236
+ //#endregion
237
+ //#region src/exception/http-exceptions/content-too-large.exception.ts
208
238
  var ContentTooLargeException = class extends RequestException {
209
- constructor(message = "Content Too Large", options) {
210
- super(413, message, { fatal: true, ...options });
211
- Object.defineProperty(this, "name", {
212
- value: "ContentTooLargeException"
213
- });
214
- }
239
+ constructor(message = "Content Too Large", options) {
240
+ super(413, message, {
241
+ fatal: true,
242
+ ...options
243
+ });
244
+ Object.defineProperty(this, "name", { value: "ContentTooLargeException" });
245
+ }
215
246
  };
216
-
217
- // src/exception/http-exceptions/uri-too-long.exception.ts
247
+ //#endregion
248
+ //#region src/exception/http-exceptions/uri-too-long.exception.ts
218
249
  var UriTooLongException = class extends RequestException {
219
- constructor(message = "URI Too Long", options) {
220
- super(414, message, { fatal: true, ...options });
221
- Object.defineProperty(this, "name", { value: "UriTooLongException" });
222
- }
250
+ constructor(message = "URI Too Long", options) {
251
+ super(414, message, {
252
+ fatal: true,
253
+ ...options
254
+ });
255
+ Object.defineProperty(this, "name", { value: "UriTooLongException" });
256
+ }
223
257
  };
224
-
225
- // src/exception/http-exceptions/unsupported-media-type.exception.ts
258
+ //#endregion
259
+ //#region src/exception/http-exceptions/unsupported-media-type.exception.ts
226
260
  var UnsupportedMediaTypeException = class extends RequestException {
227
- constructor(message = "Unsupported Media Type", options) {
228
- super(415, message, { fatal: true, ...options });
229
- Object.defineProperty(this, "name", { value: "UnsupportedMediaTypeException" });
230
- }
261
+ constructor(message = "Unsupported Media Type", options) {
262
+ super(415, message, {
263
+ fatal: true,
264
+ ...options
265
+ });
266
+ Object.defineProperty(this, "name", { value: "UnsupportedMediaTypeException" });
267
+ }
231
268
  };
232
-
233
- // src/exception/http-exceptions/im-a-teapot.exception.ts
269
+ //#endregion
270
+ //#region src/exception/http-exceptions/im-a-teapot.exception.ts
234
271
  var ImATeapotException = class extends RequestException {
235
- constructor(message = "I'm a teapot", options) {
236
- super(418, message, { fatal: true, ...options });
237
- Object.defineProperty(this, "name", { value: "ImATeapotException" });
238
- }
272
+ constructor(message = "I'm a teapot", options) {
273
+ super(418, message, {
274
+ fatal: true,
275
+ ...options
276
+ });
277
+ Object.defineProperty(this, "name", { value: "ImATeapotException" });
278
+ }
239
279
  };
240
-
241
- // src/exception/http-exceptions/too-many-requests.exception.ts
280
+ //#endregion
281
+ //#region src/exception/http-exceptions/too-many-requests.exception.ts
242
282
  var TooManyRequestsException = class extends RequestException {
243
- constructor(message = "Too Many Requests", options) {
244
- super(429, message, { fatal: false, ...options });
245
- Object.defineProperty(this, "name", { value: "TooManyRequestsException" });
246
- }
283
+ constructor(message = "Too Many Requests", options) {
284
+ super(429, message, {
285
+ fatal: false,
286
+ ...options
287
+ });
288
+ Object.defineProperty(this, "name", { value: "TooManyRequestsException" });
289
+ }
247
290
  };
248
-
249
- // src/exception/http-exceptions/internal-server-error.exception.ts
291
+ //#endregion
292
+ //#region src/exception/http-exceptions/internal-server-error.exception.ts
250
293
  var InternalServerErrorException = class extends RequestException {
251
- constructor(message = "Internal Server Error", options) {
252
- super(500, message, { fatal: false, ...options });
253
- Object.defineProperty(this, "name", {
254
- value: "InternalServerErrorException"
255
- });
256
- }
294
+ constructor(message = "Internal Server Error", options) {
295
+ super(500, message, {
296
+ fatal: false,
297
+ ...options
298
+ });
299
+ Object.defineProperty(this, "name", { value: "InternalServerErrorException" });
300
+ }
257
301
  };
258
-
259
- // src/exception/http-exceptions/not-implemented.exception.ts
302
+ //#endregion
303
+ //#region src/exception/http-exceptions/not-implemented.exception.ts
260
304
  var NotImplementedException = class extends RequestException {
261
- constructor(message = "Not Implemented", options) {
262
- super(501, message, { fatal: true, ...options });
263
- Object.defineProperty(this, "name", { value: "NotImplementedException" });
264
- }
305
+ constructor(message = "Not Implemented", options) {
306
+ super(501, message, {
307
+ fatal: true,
308
+ ...options
309
+ });
310
+ Object.defineProperty(this, "name", { value: "NotImplementedException" });
311
+ }
265
312
  };
266
-
267
- // src/exception/http-exceptions/bad-gateway.exception.ts
313
+ //#endregion
314
+ //#region src/exception/http-exceptions/bad-gateway.exception.ts
268
315
  var BadGatewayException = class extends RequestException {
269
- constructor(message = "Bad Gateway", options) {
270
- super(502, message, { fatal: false, ...options });
271
- Object.defineProperty(this, "name", { value: "BadGatewayException" });
272
- }
316
+ constructor(message = "Bad Gateway", options) {
317
+ super(502, message, {
318
+ fatal: false,
319
+ ...options
320
+ });
321
+ Object.defineProperty(this, "name", { value: "BadGatewayException" });
322
+ }
273
323
  };
274
-
275
- // src/exception/http-exceptions/service-unavailable.exception.ts
324
+ //#endregion
325
+ //#region src/exception/http-exceptions/service-unavailable.exception.ts
276
326
  var ServiceUnavailableException = class extends RequestException {
277
- constructor(message = "Service Unavailable", options) {
278
- super(503, message, { fatal: false, ...options });
279
- Object.defineProperty(this, "name", {
280
- value: "ServiceUnavailableException"
281
- });
282
- }
327
+ constructor(message = "Service Unavailable", options) {
328
+ super(503, message, {
329
+ fatal: false,
330
+ ...options
331
+ });
332
+ Object.defineProperty(this, "name", { value: "ServiceUnavailableException" });
333
+ }
283
334
  };
284
-
285
- // src/exception/http-exceptions/gateway-timeout.exception.ts
335
+ //#endregion
336
+ //#region src/exception/http-exceptions/gateway-timeout.exception.ts
286
337
  var GatewayTimeoutException = class extends RequestException {
287
- constructor(message = "Gateway Timeout", options) {
288
- super(504, message, { fatal: false, ...options });
289
- Object.defineProperty(this, "name", { value: "GatewayTimeoutException" });
290
- }
338
+ constructor(message = "Gateway Timeout", options) {
339
+ super(504, message, {
340
+ fatal: false,
341
+ ...options
342
+ });
343
+ Object.defineProperty(this, "name", { value: "GatewayTimeoutException" });
344
+ }
291
345
  };
292
-
293
- // src/utils/base64.ts
294
- var base64Encode = globalThis.btoa || ((str) => Buffer.from(str).toString("base64"));
295
- var base64Decode = globalThis.atob || ((str) => Buffer.from(str, "base64").toString("utf8"));
296
-
297
- // src/validator/validator.ts
298
- var Validator = class _Validator {
299
- /**
300
- * 检查是否为浏览器环境
301
- */
302
- static isBrowser() {
303
- return typeof window !== "undefined";
304
- }
305
- /**
306
- * 检查是否为字符串
307
- */
308
- static isString(value) {
309
- return typeof value === "string";
310
- }
311
- /**
312
- * 检查是否为对象
313
- */
314
- static isObject(value) {
315
- return typeof value === "object" && value !== null;
316
- }
317
- /**
318
- * 检查是否为函数
319
- */
320
- static isFunction(value) {
321
- return typeof value === "function";
322
- }
323
- /**
324
- * 检查是否为 ArrayBuffer
325
- */
326
- static isArrayBuffer(body) {
327
- return body instanceof ArrayBuffer;
328
- }
329
- /**
330
- * 检查是否为 ReadableStream
331
- */
332
- static isReadableStream(body) {
333
- return body instanceof ReadableStream;
334
- }
335
- /**
336
- * 检查是否为 Blob 或 File 类对象
337
- */
338
- static isBlob(value) {
339
- if (value instanceof Blob) return true;
340
- const names = ["Blob", "File"];
341
- return _Validator.isObject(value) && _Validator.isString(value["type"]) && _Validator.isFunction(value["arrayBuffer"]) && _Validator.isFunction(value["stream"]) && _Validator.isFunction(value.constructor) && names.includes(value.constructor.name) && "size" in value;
342
- }
343
- /**
344
- * 检查是否为 File
345
- */
346
- static isFile(object) {
347
- if (_Validator.isBrowser()) return object instanceof Blob;
348
- return _Validator.isBlob(object);
349
- }
350
- /**
351
- * 检查是否为 Buffer
352
- */
353
- static isBuffer(obj) {
354
- return _Validator.isBrowser() ? false : Buffer.isBuffer(obj);
355
- }
356
- /**
357
- * 检查是否为 FormData
358
- */
359
- static isFormData(object) {
360
- if (object instanceof FormData) return true;
361
- return _Validator.isObject(object) && _Validator.isFunction(object["append"]) && _Validator.isFunction(object["delete"]) && _Validator.isFunction(object["get"]) && _Validator.isFunction(object["getAll"]) && _Validator.isFunction(object["has"]) && _Validator.isFunction(object["set"]) && _Validator.isFunction(object["entries"]) && _Validator.isFunction(object["keys"]) && _Validator.isFunction(object["values"]);
362
- }
363
- /**
364
- * 检查是否为 Headers
365
- */
366
- static isHeaders(obj) {
367
- if (obj instanceof Headers) return true;
368
- if (_Validator.isObject(obj) && _Validator.isFunction(obj["forEach"]) && _Validator.isFunction(obj["get"]) && _Validator.isFunction(obj["has"]) && _Validator.isFunction(obj["set"]) && _Validator.isFunction(obj["append"]) && _Validator.isFunction(obj["delete"]) && _Validator.isFunction(obj["entries"]) && _Validator.isFunction(obj["keys"]) && _Validator.isFunction(obj["values"])) {
369
- return true;
370
- }
371
- return false;
372
- }
373
- /**
374
- * 检查是否为 URLSearchParams
375
- */
376
- static isUrlSearchParams(obj) {
377
- if (obj instanceof URLSearchParams) return true;
378
- return _Validator.isObject(obj) && _Validator.isFunction(obj["append"]) && _Validator.isFunction(obj["delete"]) && _Validator.isFunction(obj["entries"]) && _Validator.isFunction(obj["forEach"]) && _Validator.isFunction(obj["get"]) && _Validator.isFunction(obj["getAll"]) && _Validator.isFunction(obj["has"]) && _Validator.isFunction(obj["keys"]) && _Validator.isFunction(obj["set"]) && _Validator.isFunction(obj["values"]) && _Validator.isFunction(obj["sort"]) && _Validator.isFunction(obj["toString"]);
379
- }
380
- /**
381
- * 检查是否为合法的 Header 值
382
- * 允许范围: HTAB(\t), 0x20-0x7E, 0x80-0xFF
383
- * 禁止换行等控制字符
384
- */
385
- static isHeaderValue(str) {
386
- const regex = /^[\t\x20-\x7E\x80-\xFF]*$/;
387
- return regex.test(String(str));
388
- }
389
- /**
390
- * 检查是否为 BodyInit 类型
391
- * BodyInit 包括: Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | ReadableStream | string
392
- */
393
- static isBodyInit(value) {
394
- if (value === null || value === void 0) return false;
395
- return _Validator.isString(value) || _Validator.isBlob(value) || _Validator.isArrayBuffer(value) || _Validator.isFormData(value) || _Validator.isUrlSearchParams(value) || _Validator.isReadableStream(value) || _Validator.isBuffer(value) || ArrayBuffer.isView(value);
396
- }
346
+ //#endregion
347
+ //#region src/utils/base64.ts
348
+ const base64Encode = globalThis.btoa || ((str) => Buffer.from(str).toString("base64"));
349
+ globalThis.atob;
350
+ //#endregion
351
+ //#region src/validator/validator.ts
352
+ /**
353
+ * Validator 类用于类型检查
354
+ */
355
+ var Validator = class Validator {
356
+ /**
357
+ * 检查是否为浏览器环境
358
+ */
359
+ static isBrowser() {
360
+ return typeof window !== "undefined";
361
+ }
362
+ /**
363
+ * 检查是否为字符串
364
+ */
365
+ static isString(value) {
366
+ return typeof value === "string";
367
+ }
368
+ /**
369
+ * 检查是否为对象
370
+ */
371
+ static isObject(value) {
372
+ return typeof value === "object" && value !== null;
373
+ }
374
+ /**
375
+ * 检查是否为函数
376
+ */
377
+ static isFunction(value) {
378
+ return typeof value === "function";
379
+ }
380
+ /**
381
+ * 检查是否为 ArrayBuffer
382
+ */
383
+ static isArrayBuffer(body) {
384
+ return body instanceof ArrayBuffer;
385
+ }
386
+ /**
387
+ * 检查是否为 ReadableStream
388
+ */
389
+ static isReadableStream(body) {
390
+ return body instanceof ReadableStream;
391
+ }
392
+ /**
393
+ * 检查是否为 Blob 或 File 类对象
394
+ */
395
+ static isBlob(value) {
396
+ if (value instanceof Blob) return true;
397
+ return Validator.isObject(value) && Validator.isString(value["type"]) && Validator.isFunction(value["arrayBuffer"]) && Validator.isFunction(value["stream"]) && Validator.isFunction(value.constructor) && ["Blob", "File"].includes(value.constructor.name) && "size" in value;
398
+ }
399
+ /**
400
+ * 检查是否为 File
401
+ */
402
+ static isFile(object) {
403
+ if (Validator.isBrowser()) return object instanceof Blob;
404
+ return Validator.isBlob(object);
405
+ }
406
+ /**
407
+ * 检查是否为 Buffer
408
+ */
409
+ static isBuffer(obj) {
410
+ return Validator.isBrowser() ? false : Buffer.isBuffer(obj);
411
+ }
412
+ /**
413
+ * 检查是否为 FormData
414
+ */
415
+ static isFormData(object) {
416
+ if (object instanceof FormData) return true;
417
+ return Validator.isObject(object) && Validator.isFunction(object["append"]) && Validator.isFunction(object["delete"]) && Validator.isFunction(object["get"]) && Validator.isFunction(object["getAll"]) && Validator.isFunction(object["has"]) && Validator.isFunction(object["set"]) && Validator.isFunction(object["entries"]) && Validator.isFunction(object["keys"]) && Validator.isFunction(object["values"]);
418
+ }
419
+ /**
420
+ * 检查是否为 Headers
421
+ */
422
+ static isHeaders(obj) {
423
+ if (obj instanceof Headers) return true;
424
+ if (Validator.isObject(obj) && Validator.isFunction(obj["forEach"]) && Validator.isFunction(obj["get"]) && Validator.isFunction(obj["has"]) && Validator.isFunction(obj["set"]) && Validator.isFunction(obj["append"]) && Validator.isFunction(obj["delete"]) && Validator.isFunction(obj["entries"]) && Validator.isFunction(obj["keys"]) && Validator.isFunction(obj["values"])) return true;
425
+ return false;
426
+ }
427
+ /**
428
+ * 检查是否为 URLSearchParams
429
+ */
430
+ static isUrlSearchParams(obj) {
431
+ if (obj instanceof URLSearchParams) return true;
432
+ return Validator.isObject(obj) && Validator.isFunction(obj["append"]) && Validator.isFunction(obj["delete"]) && Validator.isFunction(obj["entries"]) && Validator.isFunction(obj["forEach"]) && Validator.isFunction(obj["get"]) && Validator.isFunction(obj["getAll"]) && Validator.isFunction(obj["has"]) && Validator.isFunction(obj["keys"]) && Validator.isFunction(obj["set"]) && Validator.isFunction(obj["values"]) && Validator.isFunction(obj["sort"]) && Validator.isFunction(obj["toString"]);
433
+ }
434
+ /**
435
+ * 检查是否为合法的 Header 值
436
+ * 允许范围: HTAB(\t), 0x20-0x7E, 0x80-0xFF
437
+ * 禁止换行等控制字符
438
+ */
439
+ static isHeaderValue(str) {
440
+ return /^[\t\x20-\x7E\x80-\xFF]*$/.test(String(str));
441
+ }
442
+ /**
443
+ * 检查是否为 BodyInit 类型
444
+ * BodyInit 包括: Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | ReadableStream | string
445
+ */
446
+ static isBodyInit(value) {
447
+ if (value === null || value === void 0) return false;
448
+ return Validator.isString(value) || Validator.isBlob(value) || Validator.isArrayBuffer(value) || Validator.isFormData(value) || Validator.isUrlSearchParams(value) || Validator.isReadableStream(value) || Validator.isBuffer(value) || ArrayBuffer.isView(value);
449
+ }
397
450
  };
398
-
399
- // src/utils/shallow-clone.ts
451
+ //#endregion
452
+ //#region src/utils/shallow-clone.ts
453
+ /**
454
+ * @description 浅拷贝
455
+ */
400
456
  function shallowClone(obj) {
401
- if (Array.isArray(obj)) {
402
- return [...obj];
403
- }
404
- if (Validator.isObject(obj)) {
405
- return { ...obj };
406
- }
407
- return obj;
457
+ if (Array.isArray(obj)) return [...obj];
458
+ if (Validator.isObject(obj)) return { ...obj };
459
+ return obj;
408
460
  }
409
-
410
- // src/utils/sleep.ts
461
+ //#endregion
462
+ //#region src/utils/sleep.ts
411
463
  function sleep(ms) {
412
- return new Promise((resolve) => setTimeout(resolve, ms));
464
+ return new Promise((resolve) => setTimeout(resolve, ms));
413
465
  }
414
-
415
- // src/request-init/utils/clone-body.ts
466
+ //#endregion
467
+ //#region src/request-init/utils/clone-body.ts
416
468
  function cloneBody(obj) {
417
- if (Validator.isFormData(obj)) {
418
- const formData = new FormData();
419
- for (const [key, value] of obj.entries()) {
420
- formData.append(key, value);
421
- }
422
- return formData;
423
- }
424
- if (Validator.isUrlSearchParams(obj)) {
425
- const urlSearchParams = new URLSearchParams();
426
- for (const [key, value] of obj.entries()) {
427
- urlSearchParams.append(key, value);
428
- }
429
- return urlSearchParams;
430
- }
431
- if (Validator.isFile(obj)) {
432
- return obj;
433
- }
434
- if (Validator.isBlob(obj)) {
435
- return obj;
436
- }
437
- if (Validator.isBuffer(obj)) {
438
- return obj;
439
- }
440
- if (obj === null) {
441
- return null;
442
- }
443
- if (Array.isArray(obj)) {
444
- return obj.map(cloneBody);
445
- }
446
- if (Validator.isObject(obj)) {
447
- const cloned = {};
448
- for (const key in obj) {
449
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
450
- cloned[key] = cloneBody(obj[key]);
451
- }
452
- }
453
- return cloned;
454
- }
455
- return obj;
469
+ if (Validator.isFormData(obj)) {
470
+ const formData = new FormData();
471
+ for (const [key, value] of obj.entries()) formData.append(key, value);
472
+ return formData;
473
+ }
474
+ if (Validator.isUrlSearchParams(obj)) {
475
+ const urlSearchParams = new URLSearchParams();
476
+ for (const [key, value] of obj.entries()) urlSearchParams.append(key, value);
477
+ return urlSearchParams;
478
+ }
479
+ if (Validator.isFile(obj)) return obj;
480
+ if (Validator.isBlob(obj)) return obj;
481
+ if (Validator.isBuffer(obj)) return obj;
482
+ if (obj === null) return null;
483
+ if (Array.isArray(obj)) return obj.map(cloneBody);
484
+ if (Validator.isObject(obj)) {
485
+ const cloned = {};
486
+ for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) cloned[key] = cloneBody(obj[key]);
487
+ return cloned;
488
+ }
489
+ return obj;
456
490
  }
457
-
458
- // src/request-init/utils/clone-headers.ts
491
+ //#endregion
492
+ //#region src/request-init/utils/clone-headers.ts
459
493
  function cloneHeaders(headers) {
460
- const cloned = new Headers();
461
- for (const [key, value] of headers.entries()) {
462
- cloned.append(key, value);
463
- }
464
- return cloned;
494
+ const cloned = new Headers();
495
+ for (const [key, value] of headers.entries()) cloned.append(key, value);
496
+ return cloned;
465
497
  }
466
-
467
- // src/request-init/utils/compile-url.ts
468
- var import_uri_template = require("@opendoc/uri-template");
498
+ //#endregion
499
+ //#region src/request-init/utils/compile-url.ts
469
500
  function compileUrl(obj, pathParameters) {
470
- const url = new URL(typeof obj === "string" ? obj : obj.href);
471
- url.pathname = new import_uri_template.UriTemplateParser(
472
- decodeURIComponent(url.pathname),
473
- pathParameters
474
- ).expand();
475
- return url;
501
+ const url = new URL(typeof obj === "string" ? obj : obj.href);
502
+ url.pathname = new _opendoc_uri_template.UriTemplateParser(decodeURIComponent(url.pathname), pathParameters).expand();
503
+ return url;
476
504
  }
477
-
478
- // src/request-init/utils/to-form-data.ts
505
+ //#endregion
506
+ //#region src/request-init/utils/to-form-data.ts
479
507
  function toFormData(body) {
480
- const form = new FormData();
481
- for (const [key, value] of Object.entries(body)) {
482
- if (Array.isArray(value)) {
483
- for (const v of value) {
484
- form.append(key, v);
485
- }
486
- } else {
487
- form.append(key, value);
488
- }
489
- }
490
- return form;
508
+ const form = new FormData();
509
+ for (const [key, value] of Object.entries(body)) if (Array.isArray(value)) for (const v of value) form.append(key, v);
510
+ else form.append(key, value);
511
+ return form;
491
512
  }
492
-
493
- // src/request-init/utils/to-url-search-params.ts
513
+ //#endregion
514
+ //#region src/request-init/utils/to-url-search-params.ts
494
515
  function toUrlSearchParams(body) {
495
- const params = new URLSearchParams();
496
- Object.entries(body).map(([key, value]) => {
497
- if (Array.isArray(value)) {
498
- for (const v of value) {
499
- params.append(key, v);
500
- }
501
- } else {
502
- params.append(key, value);
503
- }
504
- });
505
- return params;
516
+ const params = new URLSearchParams();
517
+ Object.entries(body).map(([key, value]) => {
518
+ if (Array.isArray(value)) for (const v of value) params.append(key, v);
519
+ else params.append(key, value);
520
+ });
521
+ return params;
506
522
  }
507
-
508
- // src/request-init/utils/clone-request-init.ts
523
+ //#endregion
524
+ //#region src/request-init/utils/clone-request-init.ts
509
525
  function cloneRequestInit(init) {
510
- return new KeqRequestInit({
511
- url: init.url,
512
- pathParameters: init.pathParameters,
513
- method: init.method,
514
- headers: init.headers,
515
- body: init.body,
516
- cache: init.cache,
517
- credentials: init.credentials,
518
- integrity: init.integrity,
519
- keepalive: init.keepalive,
520
- mode: init.mode,
521
- redirect: init.redirect,
522
- referrer: init.referrer,
523
- referrerPolicy: init.referrerPolicy
524
- });
526
+ return new KeqRequestInit({
527
+ url: init.url,
528
+ pathParameters: init.pathParameters,
529
+ method: init.method,
530
+ headers: init.headers,
531
+ body: init.body,
532
+ cache: init.cache,
533
+ credentials: init.credentials,
534
+ integrity: init.integrity,
535
+ keepalive: init.keepalive,
536
+ mode: init.mode,
537
+ redirect: init.redirect,
538
+ referrer: init.referrer,
539
+ referrerPolicy: init.referrerPolicy
540
+ });
525
541
  }
526
-
527
- // src/request-init/request-init.ts
528
- var AbortControllerProperty = /* @__PURE__ */ Symbol("context.request.abortController");
529
- var _a;
530
- _a = AbortControllerProperty;
542
+ //#endregion
543
+ //#region src/request-init/request-init.ts
544
+ const AbortControllerProperty = "__KeqProtectedProperty(context.request.abortController)__";
531
545
  var KeqRequestInit = class {
532
- constructor(options) {
533
- __publicField(this, "url");
534
- __publicField(this, "pathParameters");
535
- __publicField(this, "method");
536
- __publicField(this, "headers");
537
- __publicField(this, "body");
538
- __publicField(this, "cache");
539
- __publicField(this, "credentials");
540
- __publicField(this, "integrity");
541
- __publicField(this, "keepalive");
542
- __publicField(this, "mode");
543
- __publicField(this, "redirect");
544
- __publicField(this, "referrer");
545
- __publicField(this, "referrerPolicy");
546
- __publicField(this, _a, new AbortController());
547
- this.url = new URL(options.url.href);
548
- this.pathParameters = shallowClone(options.pathParameters);
549
- this.method = options.method;
550
- this.headers = cloneHeaders(options.headers);
551
- this.body = cloneBody(options.body);
552
- this.cache = options.cache;
553
- this.credentials = options.credentials;
554
- this.integrity = options.integrity;
555
- this.keepalive = options.keepalive;
556
- this.mode = options.mode;
557
- this.redirect = options.redirect;
558
- this.referrer = options.referrer;
559
- this.referrerPolicy = options.referrerPolicy;
560
- }
561
- // the url merged pathParameters
562
- get __url__() {
563
- return compileUrl(this.url, this.pathParameters);
564
- }
565
- get signal() {
566
- return this[AbortControllerProperty].signal;
567
- }
568
- abort(reason) {
569
- if (!this[AbortControllerProperty].signal.aborted) {
570
- this[AbortControllerProperty].abort(reason);
571
- }
572
- }
573
- getContentType() {
574
- const contentType = this.headers.get("Content-Type");
575
- if (contentType) return contentType;
576
- if (!this.body) return void 0;
577
- if (Validator.isFormData(this.body)) return "multipart/form-data";
578
- if (Validator.isUrlSearchParams(this.body)) return "application/x-www-form-urlencoded";
579
- if (Validator.isArrayBuffer(this.body)) return "application/octet-stream";
580
- if (typeof this.body === "object") return "application/json";
581
- return void 0;
582
- }
583
- toFetchBody(contentType) {
584
- const body = this.body;
585
- if (body === void 0) return;
586
- if (body === null) return null;
587
- if (Validator.isBodyInit(body)) return body;
588
- if (!contentType || contentType === "application/json") {
589
- return JSON.stringify(body);
590
- }
591
- if (contentType === "application/x-www-form-urlencoded") {
592
- if (Array.isArray(body)) {
593
- throw new Exception("request.body is an array, that cannot be serialized as application/x-www-form-urlencoded format");
594
- }
595
- return toUrlSearchParams(body);
596
- }
597
- if (contentType === "multipart/form-data") {
598
- if (Array.isArray(body)) {
599
- throw new Exception("FormData cannot send array");
600
- }
601
- return toFormData(body);
602
- }
603
- throw new Exception("Cannot auto serialize request.body with Content-Type: ".concat(contentType));
604
- }
605
- toFetchArguments() {
606
- const contentType = this.getContentType();
607
- const headers = cloneHeaders(this.headers);
608
- if (contentType) headers.set("Content-Type", contentType);
609
- const body = this.toFetchBody(contentType);
610
- if (contentType === "multipart/form-data") {
611
- headers.delete("Content-Type");
612
- }
613
- const requestInit = {
614
- method: this.method.toUpperCase(),
615
- headers,
616
- body,
617
- cache: this.cache,
618
- credentials: this.credentials,
619
- integrity: this.integrity,
620
- keepalive: this.keepalive,
621
- mode: this.mode,
622
- redirect: this.redirect,
623
- referrer: this.referrer,
624
- referrerPolicy: this.referrerPolicy,
625
- signal: this.signal
626
- };
627
- return [this.__url__.href, requestInit];
628
- }
546
+ constructor(options) {
547
+ _defineProperty(this, "url", void 0);
548
+ _defineProperty(this, "pathParameters", void 0);
549
+ _defineProperty(this, "method", void 0);
550
+ _defineProperty(this, "headers", void 0);
551
+ _defineProperty(this, "body", void 0);
552
+ _defineProperty(this, "cache", void 0);
553
+ _defineProperty(this, "credentials", void 0);
554
+ _defineProperty(this, "integrity", void 0);
555
+ _defineProperty(this, "keepalive", void 0);
556
+ _defineProperty(this, "mode", void 0);
557
+ _defineProperty(this, "redirect", void 0);
558
+ _defineProperty(this, "referrer", void 0);
559
+ _defineProperty(this, "referrerPolicy", void 0);
560
+ _defineProperty(this, AbortControllerProperty, new AbortController());
561
+ this.url = new URL(options.url.href);
562
+ this.pathParameters = shallowClone(options.pathParameters);
563
+ this.method = options.method;
564
+ this.headers = cloneHeaders(options.headers);
565
+ this.body = cloneBody(options.body);
566
+ this.cache = options.cache;
567
+ this.credentials = options.credentials;
568
+ this.integrity = options.integrity;
569
+ this.keepalive = options.keepalive;
570
+ this.mode = options.mode;
571
+ this.redirect = options.redirect;
572
+ this.referrer = options.referrer;
573
+ this.referrerPolicy = options.referrerPolicy;
574
+ }
575
+ get __url__() {
576
+ return compileUrl(this.url, this.pathParameters);
577
+ }
578
+ get signal() {
579
+ return this[AbortControllerProperty].signal;
580
+ }
581
+ abort(reason) {
582
+ if (!this["__KeqProtectedProperty(context.request.abortController)__"].signal.aborted) this[AbortControllerProperty].abort(reason);
583
+ }
584
+ getContentType() {
585
+ const contentType = this.headers.get("Content-Type");
586
+ if (contentType) return contentType;
587
+ if (!this.body) return void 0;
588
+ if (Validator.isFormData(this.body)) return "multipart/form-data";
589
+ if (Validator.isUrlSearchParams(this.body)) return "application/x-www-form-urlencoded";
590
+ if (Validator.isArrayBuffer(this.body)) return "application/octet-stream";
591
+ if (typeof this.body === "object") return "application/json";
592
+ }
593
+ toFetchBody(contentType) {
594
+ const body = this.body;
595
+ if (body === void 0) return;
596
+ if (body === null) return null;
597
+ if (Validator.isBodyInit(body)) return body;
598
+ if (!contentType || contentType === "application/json") return JSON.stringify(body);
599
+ if (contentType === "application/x-www-form-urlencoded") {
600
+ if (Array.isArray(body)) throw new Exception("request.body is an array, that cannot be serialized as application/x-www-form-urlencoded format");
601
+ return toUrlSearchParams(body);
602
+ }
603
+ if (contentType === "multipart/form-data") {
604
+ if (Array.isArray(body)) throw new Exception("FormData cannot send array");
605
+ return toFormData(body);
606
+ }
607
+ throw new Exception(`Cannot auto serialize request.body with Content-Type: ${contentType}`);
608
+ }
609
+ toFetchArguments() {
610
+ const contentType = this.getContentType();
611
+ const headers = cloneHeaders(this.headers);
612
+ if (contentType) headers.set("Content-Type", contentType);
613
+ const body = this.toFetchBody(contentType);
614
+ if (contentType === "multipart/form-data") headers.delete("Content-Type");
615
+ const requestInit = {
616
+ method: this.method.toUpperCase(),
617
+ headers,
618
+ body,
619
+ cache: this.cache,
620
+ credentials: this.credentials,
621
+ integrity: this.integrity,
622
+ keepalive: this.keepalive,
623
+ mode: this.mode,
624
+ redirect: this.redirect,
625
+ referrer: this.referrer,
626
+ referrerPolicy: this.referrerPolicy,
627
+ signal: this.signal
628
+ };
629
+ return [this.__url__.href, requestInit];
630
+ }
629
631
  };
630
-
631
- // src/context/orchestrator-context.ts
632
- var OrchestratorProperty = /* @__PURE__ */ Symbol("protected context.orchestration.orchestrator");
633
- var ExecutorProperty = /* @__PURE__ */ Symbol("protected context.orchestration.executor");
634
- var _a2, _b;
635
- _b = OrchestratorProperty, _a2 = ExecutorProperty;
632
+ //#endregion
633
+ //#region src/context/orchestrator-context.ts
634
+ const OrchestratorProperty = "__KeyProtectedProperty(context.orchestration.orchestrator)__";
635
+ const ExecutorProperty$1 = "__KeyProtectedProperty(context.orchestration.executor)__";
636
636
  var KeqOrchestratorContext = class {
637
- constructor(orchestrator, executor) {
638
- __publicField(this, _b);
639
- __publicField(this, _a2);
640
- this[OrchestratorProperty] = orchestrator;
641
- this[ExecutorProperty] = executor;
642
- }
643
- get middlewares() {
644
- return this[OrchestratorProperty].executors.map((exe) => exe.context);
645
- }
646
- // NOTE: For Future
647
- // get executing(): KeqMiddlewareContext {
648
- // const current = this[OrchestratorProperty].current
649
- // const executors = this[OrchestratorProperty].executors
650
- // const executor = executors[current]
651
- // return executor.context
652
- // }
653
- /**
654
- * The middleware context of the current middleware
655
- */
656
- get middleware() {
657
- return this[ExecutorProperty].context;
658
- }
659
- fork() {
660
- return this[OrchestratorProperty].fork();
661
- }
662
- merge(source) {
663
- this[OrchestratorProperty].merge(source);
664
- }
637
+ constructor(orchestrator, executor) {
638
+ _defineProperty(this, OrchestratorProperty, void 0);
639
+ _defineProperty(this, ExecutorProperty$1, void 0);
640
+ this[OrchestratorProperty] = orchestrator;
641
+ this[ExecutorProperty$1] = executor;
642
+ }
643
+ get middlewares() {
644
+ return this[OrchestratorProperty].executors.map((exe) => exe.context);
645
+ }
646
+ /**
647
+ * The middleware context of the current middleware
648
+ */
649
+ get middleware() {
650
+ return this[ExecutorProperty$1].context;
651
+ }
652
+ fork() {
653
+ return this[OrchestratorProperty].fork();
654
+ }
655
+ merge(source) {
656
+ this[OrchestratorProperty].merge(source);
657
+ }
665
658
  };
666
-
667
- // src/context/execution-context.ts
668
- var ContextOrchestratorProperty = /* @__PURE__ */ Symbol("protected context.orchestrator");
669
- var ContextOrchestrationProperty = /* @__PURE__ */ Symbol("protected context.orchestration");
670
- var _a3, _b2;
671
- _b2 = ContextOrchestratorProperty, _a3 = ContextOrchestrationProperty;
659
+ //#endregion
660
+ //#region src/context/execution-context.ts
661
+ const ContextOrchestratorProperty = "__KeyProtectedProperty(context.orchestrator)__";
662
+ const ContextOrchestrationProperty = "__KeyProtectedProperty(context.orchestration)__";
672
663
  var KeqExecutionContext = class {
673
- constructor(orchestrator, executor) {
674
- __publicField(this, _b2);
675
- __publicField(this, _a3);
676
- this[ContextOrchestratorProperty] = orchestrator;
677
- this[ContextOrchestrationProperty] = new KeqOrchestratorContext(orchestrator, executor);
678
- }
679
- get orchestration() {
680
- return this[ContextOrchestrationProperty];
681
- }
682
- /**
683
- * The unique identifier of the request's location in the code
684
- */
685
- get locationId() {
686
- return this[ContextOrchestratorProperty].context.locationId;
687
- }
688
- get request() {
689
- return this[ContextOrchestratorProperty].context.request;
690
- }
691
- get global() {
692
- return this[ContextOrchestratorProperty].context.global;
693
- }
694
- get emitter() {
695
- return this[ContextOrchestratorProperty].context.emitter;
696
- }
697
- get options() {
698
- return this[ContextOrchestratorProperty].context.options;
699
- }
700
- // The result get by user if resolveWith is set to 'intelligent' or not set
701
- set output(value) {
702
- if (this.options.resolveWith && this.options.resolveWith !== "intelligent") {
703
- console.warn("The request is configured to resolve with ".concat(this.options.resolveWith, ", so setting context.output maybe no effect."));
704
- }
705
- this[ContextOrchestratorProperty].context.output = value;
706
- }
707
- // The original response
708
- get res() {
709
- return this[ContextOrchestratorProperty].context.res;
710
- }
711
- // The original response
712
- set res(value) {
713
- this[ContextOrchestratorProperty].context.res = value;
714
- }
715
- // The request response
716
- get response() {
717
- return this[ContextOrchestratorProperty].context.response;
718
- }
719
- // The properties extends by middleware
720
- get data() {
721
- return this[ContextOrchestratorProperty].context.data;
722
- }
664
+ constructor(orchestrator, executor) {
665
+ _defineProperty(this, ContextOrchestratorProperty, void 0);
666
+ _defineProperty(this, ContextOrchestrationProperty, void 0);
667
+ this[ContextOrchestratorProperty] = orchestrator;
668
+ this[ContextOrchestrationProperty] = new KeqOrchestratorContext(orchestrator, executor);
669
+ }
670
+ get orchestration() {
671
+ return this[ContextOrchestrationProperty];
672
+ }
673
+ /**
674
+ * The unique identifier of the request's location in the code
675
+ */
676
+ get locationId() {
677
+ return this[ContextOrchestratorProperty].context.locationId;
678
+ }
679
+ get request() {
680
+ return this[ContextOrchestratorProperty].context.request;
681
+ }
682
+ get global() {
683
+ return this[ContextOrchestratorProperty].context.global;
684
+ }
685
+ get emitter() {
686
+ return this[ContextOrchestratorProperty].context.emitter;
687
+ }
688
+ get options() {
689
+ return this[ContextOrchestratorProperty].context.options;
690
+ }
691
+ set output(value) {
692
+ if (this.options.resolveWith && this.options.resolveWith !== "intelligent") console.warn(`The request is configured to resolve with ${this.options.resolveWith}, so setting context.output maybe no effect.`);
693
+ this[ContextOrchestratorProperty].context.output = value;
694
+ }
695
+ get res() {
696
+ return this[ContextOrchestratorProperty].context.res;
697
+ }
698
+ set res(value) {
699
+ this[ContextOrchestratorProperty].context.res = value;
700
+ }
701
+ get response() {
702
+ return this[ContextOrchestratorProperty].context.response;
703
+ }
704
+ get data() {
705
+ return this[ContextOrchestratorProperty].context.data;
706
+ }
723
707
  };
724
-
725
- // src/context/shared-context.ts
726
- var import_mitt = __toESM(require("mitt"));
727
-
728
- // src/context/utils/watch-object.ts
708
+ //#endregion
709
+ //#region src/context/utils/watch-object.ts
729
710
  function watchObject(obj, listeners) {
730
- return new Proxy(obj, {
731
- get(target, prop) {
732
- if (prop in listeners) {
733
- return new Proxy(target[prop], {
734
- apply(target2, thisArg, argArray) {
735
- const listener = listeners[prop];
736
- listener(target2, thisArg, argArray);
737
- return target2.apply(thisArg, argArray);
738
- }
739
- });
740
- }
741
- return target[prop];
742
- }
743
- });
711
+ return new Proxy(obj, { get(target, prop) {
712
+ if (prop in listeners) return new Proxy(target[prop], { apply(target, thisArg, argArray) {
713
+ const listener = listeners[prop];
714
+ listener(target, thisArg, argArray);
715
+ return target.apply(thisArg, argArray);
716
+ } });
717
+ return target[prop];
718
+ } });
744
719
  }
745
-
746
- // src/context/utils/clone-shared-context.ts
747
- var import_klona = require("klona");
720
+ //#endregion
721
+ //#region src/context/utils/clone-shared-context.ts
748
722
  function cloneSharedContext(context) {
749
- const cloned = new KeqSharedContext({
750
- locationId: context[ContextLocationIdProperty],
751
- request: cloneRequestInit(context[ContextRequestProperty]),
752
- global: context[ContextGlobalProperty],
753
- options: (0, import_klona.klona)(context[ContextOptionsProperty]),
754
- data: (0, import_klona.klona)(context[ContextDataProperty])
755
- });
756
- context[ContextEmitterProperty].all.forEach((handlers, type) => {
757
- for (const handler of handlers) {
758
- cloned.emitter.on(type, handler);
759
- }
760
- });
761
- return cloned;
723
+ const cloned = new KeqSharedContext({
724
+ locationId: context[ContextLocationIdProperty],
725
+ request: cloneRequestInit(context[ContextRequestProperty]),
726
+ global: context[ContextGlobalProperty],
727
+ options: (0, klona.klona)(context[ContextOptionsProperty]),
728
+ data: (0, klona.klona)(context[ContextDataProperty])
729
+ });
730
+ context[ContextEmitterProperty].all.forEach((handlers, type) => {
731
+ for (const handler of handlers) cloned.emitter.on(type, handler);
732
+ });
733
+ return cloned;
762
734
  }
763
-
764
- // src/context/utils/fork.ts
765
- var import_json = require("klona/json");
766
- var UnWrapPropertyKey = /* @__PURE__ */ Symbol("UnWrapPropertyKey");
767
- var ARRAY_MUTATORS = /* @__PURE__ */ new Set([
768
- "push",
769
- "pop",
770
- "shift",
771
- "unshift",
772
- "splice",
773
- "sort",
774
- "reverse",
775
- "fill",
776
- "copyWithin"
735
+ //#endregion
736
+ //#region src/context/utils/fork.ts
737
+ const ForkedObjectBrandPropertyKey = "__KeqProtectedProperty(forked.object.brand)__";
738
+ const ARRAY_MUTATORS = new Set([
739
+ "push",
740
+ "pop",
741
+ "shift",
742
+ "unshift",
743
+ "splice",
744
+ "sort",
745
+ "reverse",
746
+ "fill",
747
+ "copyWithin"
777
748
  ]);
778
749
  function objectPath(obj, path) {
779
- return path.reduce((o, k) => o[k], obj);
750
+ return path.reduce((o, k) => o[k], obj);
780
751
  }
752
+ /**
753
+ * Fork an json object, using copy-on-write strategy to avoid unnecessary deep cloning.
754
+ */
781
755
  function fork(original) {
782
- if (original === null || typeof original !== "object") {
783
- return original;
784
- }
785
- let current = original;
786
- const ensureCopy = () => {
787
- if (current === original) {
788
- current = (0, import_json.klona)(original);
789
- }
790
- return current;
791
- };
792
- const createProxy = (path = []) => {
793
- const getTarget = () => objectPath(current, path);
794
- return new Proxy(getTarget(), {
795
- get(target, prop) {
796
- const realTarget = getTarget();
797
- if (prop === UnWrapPropertyKey) return realTarget;
798
- const value = realTarget[prop];
799
- if (current !== original) {
800
- return value;
801
- }
802
- if (Array.isArray(realTarget) && ARRAY_MUTATORS.has(prop)) {
803
- return new Proxy(value, {
804
- apply(fn, thisArg, args) {
805
- ensureCopy();
806
- const t = objectPath(current, path);
807
- return Reflect.apply(t[prop], t, args);
808
- }
809
- });
810
- }
811
- if (typeof value === "object" && value !== null) {
812
- return createProxy([...path, prop]);
813
- }
814
- return value;
815
- },
816
- set(target, prop, value) {
817
- ensureCopy();
818
- objectPath(current, path)[prop] = value;
819
- return true;
820
- },
821
- deleteProperty(target, prop) {
822
- ensureCopy();
823
- delete objectPath(current, path)[prop];
824
- return true;
825
- },
826
- ownKeys(target) {
827
- const realTarget = getTarget();
828
- return Reflect.ownKeys(realTarget);
829
- },
830
- getOwnPropertyDescriptor(target, prop) {
831
- const realTarget = getTarget();
832
- return Reflect.getOwnPropertyDescriptor(realTarget, prop);
833
- }
834
- });
835
- };
836
- return createProxy();
756
+ if (original === null || typeof original !== "object") return original;
757
+ let current = original;
758
+ const ensureCopy = () => {
759
+ if (current === original) current = (0, klona_json.klona)(original);
760
+ return current;
761
+ };
762
+ const createProxy = (path = []) => {
763
+ const getTarget = () => objectPath(current, path);
764
+ return new Proxy(getTarget(), {
765
+ get(target, prop) {
766
+ const realTarget = getTarget();
767
+ if (prop === ForkedObjectBrandPropertyKey) return realTarget;
768
+ const value = realTarget[prop];
769
+ if (current !== original) return value;
770
+ if (Array.isArray(realTarget) && ARRAY_MUTATORS.has(prop)) return new Proxy(value, { apply(fn, thisArg, args) {
771
+ ensureCopy();
772
+ const t = objectPath(current, path);
773
+ return Reflect.apply(t[prop], t, args);
774
+ } });
775
+ if (typeof value === "object" && value !== null) return createProxy([...path, prop]);
776
+ return value;
777
+ },
778
+ set(target, prop, value) {
779
+ ensureCopy();
780
+ objectPath(current, path)[prop] = value;
781
+ return true;
782
+ },
783
+ deleteProperty(target, prop) {
784
+ ensureCopy();
785
+ delete objectPath(current, path)[prop];
786
+ return true;
787
+ },
788
+ ownKeys(target) {
789
+ const realTarget = getTarget();
790
+ return Reflect.ownKeys(realTarget);
791
+ },
792
+ getOwnPropertyDescriptor(target, prop) {
793
+ const realTarget = getTarget();
794
+ return Reflect.getOwnPropertyDescriptor(realTarget, prop);
795
+ }
796
+ });
797
+ };
798
+ return createProxy();
837
799
  }
838
800
  function unwrap(proxy) {
839
- return proxy && proxy[UnWrapPropertyKey] ? proxy[UnWrapPropertyKey] : proxy;
801
+ return proxy && proxy[ForkedObjectBrandPropertyKey] ? proxy[ForkedObjectBrandPropertyKey] : proxy;
840
802
  }
841
-
842
- // src/context/utils/create-proxy-response.ts
843
- var JsonCachePropertyKey = /* @__PURE__ */ Symbol("KeqResponseProxyJsonCachePropertyKey");
844
- var TextCachePropertyKey = /* @__PURE__ */ Symbol("KeqResponseProxyTextCachePropertyKey");
803
+ //#endregion
804
+ //#region src/context/utils/create-proxy-response.ts
805
+ const JsonCachePropertyKey = "__KeqProtectedProperty(response.proxy.cache.json)__";
806
+ const TextCachePropertyKey = "__KeqProtectedProperty(response.proxy.cache.text)__";
845
807
  function createProxyResponse(response) {
846
- return new Proxy(response, {
847
- get(res, prop) {
848
- if (typeof prop === "string") {
849
- if (prop === "json") {
850
- return new Proxy(res[prop], {
851
- apply() {
852
- if (res[JsonCachePropertyKey]) {
853
- return fork(res[JsonCachePropertyKey]);
854
- }
855
- return res.clone().json().then((body) => {
856
- res[JsonCachePropertyKey] = body;
857
- return fork(body);
858
- });
859
- }
860
- });
861
- } else if (prop === "text") {
862
- return new Proxy(res[prop], {
863
- apply() {
864
- if (res[TextCachePropertyKey]) {
865
- return fork(res[TextCachePropertyKey]);
866
- }
867
- return res.clone().text().then((body) => {
868
- res[TextCachePropertyKey] = body;
869
- return body;
870
- });
871
- }
872
- });
873
- } else if (["arrayBuffer", "blob", "buffer", "formData"].includes(prop)) {
874
- return new Proxy(res[prop], {
875
- apply(target, thisArg, argArray) {
876
- return res.clone()[prop](...argArray);
877
- }
878
- });
879
- } else if (prop === "body") {
880
- const mirror = res.clone();
881
- return mirror.body;
882
- }
883
- }
884
- if (typeof res[prop] === "function") {
885
- return res[prop].bind(res);
886
- }
887
- return res[prop];
888
- }
889
- });
808
+ return new Proxy(response, { get(res, prop) {
809
+ if (typeof prop === "string") {
810
+ if (prop === "json") return new Proxy(res[prop], { apply() {
811
+ if (res[JsonCachePropertyKey]) return fork(res[JsonCachePropertyKey]);
812
+ return res.clone().json().then((body) => {
813
+ res[JsonCachePropertyKey] = body;
814
+ return fork(body);
815
+ });
816
+ } });
817
+ else if (prop === "text") return new Proxy(res[prop], { apply() {
818
+ if (res[TextCachePropertyKey]) return fork(res[TextCachePropertyKey]);
819
+ return res.clone().text().then((body) => {
820
+ res[TextCachePropertyKey] = body;
821
+ return body;
822
+ });
823
+ } });
824
+ else if ([
825
+ "arrayBuffer",
826
+ "blob",
827
+ "buffer",
828
+ "formData"
829
+ ].includes(prop))
830
+ /**
831
+ * clone when invoking body, json, text, arrayBuffer, blob, buffer, formData
832
+ * to avoid time-consuming cloning
833
+ */
834
+ return new Proxy(res[prop], { apply(target, thisArg, argArray) {
835
+ return res.clone()[prop](...argArray);
836
+ } });
837
+ else if (prop === "body") return res.clone().body;
838
+ }
839
+ if (typeof res[prop] === "function") return res[prop].bind(res);
840
+ return res[prop];
841
+ } });
890
842
  }
891
-
892
- // src/context/shared-context.ts
893
- var ContextLocationIdProperty = /* @__PURE__ */ Symbol("protected context.locationId");
894
- var ContextRequestProperty = /* @__PURE__ */ Symbol("protected context.request");
895
- var ContextGlobalProperty = /* @__PURE__ */ Symbol("protected context.global");
896
- var ContextEmitterProperty = /* @__PURE__ */ Symbol("protected context.emitter");
897
- var ContextOptionsProperty = /* @__PURE__ */ Symbol("protected context.options");
898
- var ContextDataProperty = /* @__PURE__ */ Symbol("protected context.data");
899
- var ContextOutputProperty = /* @__PURE__ */ Symbol("protected context.output");
900
- var _a4, _b3, _c, _d, _e, _f, _g;
901
- _g = ContextLocationIdProperty, _f = ContextRequestProperty, _e = ContextGlobalProperty, _d = ContextEmitterProperty, _c = ContextOptionsProperty, _b3 = ContextOutputProperty, _a4 = ContextDataProperty;
843
+ //#endregion
844
+ //#region src/context/shared-context.ts
845
+ const ContextLocationIdProperty = "__KeqProtectedProperty(context.locationId)__";
846
+ const ContextRequestProperty = "__KeqProtectedProperty(context.request)__";
847
+ const ContextGlobalProperty = "__KeqProtectedProperty(context.global)__";
848
+ const ContextEmitterProperty = "__KeqProtectedProperty(context.emitter)__";
849
+ const ContextOptionsProperty = "__KeqProtectedProperty(context.options)__";
850
+ const ContextDataProperty = "__KeqProtectedProperty(context.data)__";
851
+ const ContextOutputProperty = "__KeqProtectedProperty(context.output)__";
902
852
  var KeqSharedContext = class {
903
- constructor(options) {
904
- __publicField(this, _g);
905
- __publicField(this, _f);
906
- __publicField(this, _e);
907
- __publicField(this, _d);
908
- __publicField(this, _c);
909
- __publicField(this, _b3);
910
- // The properties extends by middleware
911
- __publicField(this, _a4, {});
912
- /**
913
- * original response
914
- */
915
- __publicField(this, "res");
916
- this[ContextLocationIdProperty] = options.locationId;
917
- this[ContextRequestProperty] = watchObject(new KeqRequestInit(options.request), {
918
- abort: (target, thisArg, argArray) => {
919
- this[ContextEmitterProperty].emit("abort", { context: this, reason: argArray[0] });
920
- }
921
- });
922
- this[ContextEmitterProperty] = options.emitter || (0, import_mitt.default)();
923
- this[ContextGlobalProperty] = options.global;
924
- this[ContextOptionsProperty] = options.options ? shallowClone(options.options) : {};
925
- this[ContextDataProperty] = options.data || {};
926
- }
927
- /**
928
- * The unique identifier of the request's location in the code
929
- */
930
- get locationId() {
931
- return this[ContextLocationIdProperty];
932
- }
933
- get request() {
934
- return this[ContextRequestProperty];
935
- }
936
- get global() {
937
- return this[ContextGlobalProperty];
938
- }
939
- get emitter() {
940
- return this[ContextEmitterProperty];
941
- }
942
- get options() {
943
- return this[ContextOptionsProperty];
944
- }
945
- set output(value) {
946
- this[ContextOutputProperty] = value;
947
- }
948
- get response() {
949
- if (!this.res) return void 0;
950
- return createProxyResponse(this.res);
951
- }
952
- get data() {
953
- return this[ContextDataProperty];
954
- }
853
+ constructor(options) {
854
+ _defineProperty(this, ContextLocationIdProperty, void 0);
855
+ _defineProperty(this, ContextRequestProperty, void 0);
856
+ _defineProperty(this, ContextGlobalProperty, void 0);
857
+ _defineProperty(this, ContextEmitterProperty, void 0);
858
+ _defineProperty(this, ContextOptionsProperty, void 0);
859
+ _defineProperty(this, ContextOutputProperty, void 0);
860
+ _defineProperty(this, ContextDataProperty, {});
861
+ _defineProperty(
862
+ this,
863
+ /**
864
+ * original response
865
+ */
866
+ "res",
867
+ void 0
868
+ );
869
+ this[ContextLocationIdProperty] = options.locationId;
870
+ this[ContextRequestProperty] = watchObject(new KeqRequestInit(options.request), { abort: (target, thisArg, argArray) => {
871
+ this[ContextEmitterProperty].emit("abort", {
872
+ context: this,
873
+ reason: argArray[0]
874
+ });
875
+ } });
876
+ this[ContextEmitterProperty] = options.emitter || (0, mitt.default)();
877
+ this[ContextGlobalProperty] = options.global;
878
+ this[ContextOptionsProperty] = options.options ? shallowClone(options.options) : {};
879
+ this[ContextDataProperty] = options.data || {};
880
+ }
881
+ /**
882
+ * The unique identifier of the request's location in the code
883
+ */
884
+ get locationId() {
885
+ return this[ContextLocationIdProperty];
886
+ }
887
+ get request() {
888
+ return this[ContextRequestProperty];
889
+ }
890
+ get global() {
891
+ return this[ContextGlobalProperty];
892
+ }
893
+ get emitter() {
894
+ return this[ContextEmitterProperty];
895
+ }
896
+ get options() {
897
+ return this[ContextOptionsProperty];
898
+ }
899
+ set output(value) {
900
+ this[ContextOutputProperty] = value;
901
+ }
902
+ get response() {
903
+ if (!this.res) return void 0;
904
+ return createProxyResponse(this.res);
905
+ }
906
+ get data() {
907
+ return this[ContextDataProperty];
908
+ }
955
909
  };
956
-
957
- // src/middleware/utils/get-middleware-name.ts
910
+ //#endregion
911
+ //#region src/middleware/utils/get-middleware-name.ts
958
912
  function getMiddlewareName(middleware) {
959
- return middleware.__keqMiddlewareName__ || middleware.name || "anonymous";
913
+ return middleware.__keqMiddlewareName__ || middleware.name || "anonymous";
960
914
  }
961
-
962
- // src/middleware/utils/compose-middleware.ts
915
+ //#endregion
916
+ //#region src/middleware/utils/compose-middleware.ts
963
917
  function composeMiddleware(middlewares, options) {
964
- if (!middlewares.length) {
965
- throw new TypeException("At least one middleware");
966
- }
967
- const middleware = [...middlewares].reverse().reduce(function(prev, curr) {
968
- return async (ctx, next) => {
969
- await curr(ctx, async () => prev(ctx, next));
970
- };
971
- });
972
- if (options == null ? void 0 : options.name) {
973
- middleware.__keqMiddlewareName__ = options.name;
974
- } else {
975
- middleware.__keqMiddlewareName__ = "composeMiddleware(".concat(middlewares.map((i) => getMiddlewareName(i)).join(", "), ")");
976
- }
977
- return middleware;
918
+ if (!middlewares.length) throw new TypeException("At least one middleware");
919
+ const middleware = [...middlewares].reverse().reduce(function(prev, curr) {
920
+ return async (ctx, next) => {
921
+ await curr(ctx, async () => prev(ctx, next));
922
+ };
923
+ });
924
+ if (options?.name) middleware.__keqMiddlewareName__ = options.name;
925
+ else middleware.__keqMiddlewareName__ = `composeMiddleware(${middlewares.map((i) => getMiddlewareName(i)).join(", ")})`;
926
+ return middleware;
978
927
  }
979
-
980
- // src/context/middleware-context.ts
981
- var ExecutorProperty2 = /* @__PURE__ */ Symbol("protected context.orchestration.middlewares");
982
- var _a5;
983
- _a5 = ExecutorProperty2;
928
+ //#endregion
929
+ //#region src/context/middleware-context.ts
930
+ const ExecutorProperty = "__KeyProtectedProperty(context.orchestration.middlewares)__";
984
931
  var KeqMiddlewareContext = class {
985
- constructor(executor) {
986
- __publicField(this, _a5);
987
- this[ExecutorProperty2] = executor;
988
- }
989
- get name() {
990
- return this[ExecutorProperty2].name;
991
- }
992
- get status() {
993
- return this[ExecutorProperty2].status;
994
- }
995
- get finished() {
996
- return this.status === "fulfilled" || this.status === "rejected";
997
- }
932
+ constructor(executor) {
933
+ _defineProperty(this, ExecutorProperty, void 0);
934
+ this[ExecutorProperty] = executor;
935
+ }
936
+ get name() {
937
+ return this[ExecutorProperty].name;
938
+ }
939
+ get status() {
940
+ return this[ExecutorProperty].status;
941
+ }
942
+ get finished() {
943
+ return this.status === "fulfilled" || this.status === "rejected";
944
+ }
998
945
  };
999
-
1000
- // src/orchestrator/executor.ts
946
+ //#endregion
947
+ //#region src/orchestrator/executor.ts
1001
948
  var KeqMiddlewareExecutor = class {
1002
- constructor(middleware) {
1003
- this.middleware = middleware;
1004
- __publicField(this, "name");
1005
- __publicField(this, "status", "idle");
1006
- __publicField(this, "context");
1007
- this.name = getMiddlewareName(middleware);
1008
- this.context = new KeqMiddlewareContext(this);
1009
- }
1010
- async execute(context, next) {
1011
- if (this.status !== "idle") {
1012
- throw new Exception('Middleware "'.concat(this.name, '" has already been executed.'));
1013
- }
1014
- try {
1015
- this.status = "pending";
1016
- context.emitter.emit("middleware:before", { context });
1017
- await this.middleware(context, next);
1018
- context.emitter.emit("middleware:after", { context });
1019
- if (this.status === "pending") {
1020
- this.status = "fulfilled";
1021
- }
1022
- } catch (error) {
1023
- if (this.status === "pending") {
1024
- this.status = "rejected";
1025
- }
1026
- throw error;
1027
- }
1028
- }
949
+ constructor(middleware) {
950
+ this.middleware = middleware;
951
+ _defineProperty(this, "name", void 0);
952
+ _defineProperty(this, "status", "idle");
953
+ _defineProperty(this, "context", void 0);
954
+ this.name = getMiddlewareName(middleware);
955
+ this.context = new KeqMiddlewareContext(this);
956
+ }
957
+ async execute(context, next) {
958
+ if (this.status !== "idle") throw new Exception(`Middleware "${this.name}" has already been executed.`);
959
+ try {
960
+ this.status = "pending";
961
+ context.emitter.emit("middleware:before", { context });
962
+ await this.middleware(context, next);
963
+ context.emitter.emit("middleware:after", { context });
964
+ if (this.status === "pending") this.status = "fulfilled";
965
+ } catch (error) {
966
+ if (this.status === "pending") this.status = "rejected";
967
+ throw error;
968
+ }
969
+ }
1029
970
  };
1030
-
1031
- // src/request-init/utils/assign-request-init.ts
971
+ //#endregion
972
+ //#region src/request-init/utils/assign-request-init.ts
1032
973
  function assignRequestInit(target, source) {
1033
- target.url = source.url;
1034
- target.pathParameters = source.pathParameters;
1035
- target.method = source.method;
1036
- target.headers = source.headers;
1037
- target.body = source.body;
1038
- target.cache = source.cache;
1039
- target.credentials = source.credentials;
1040
- target.integrity = source.integrity;
1041
- target.keepalive = source.keepalive;
1042
- target.mode = source.mode;
1043
- target.redirect = source.redirect;
1044
- target.referrer = source.referrer;
1045
- target.referrerPolicy = source.referrerPolicy;
1046
- target[AbortControllerProperty] = source[AbortControllerProperty];
974
+ target.url = source.url;
975
+ target.pathParameters = source.pathParameters;
976
+ target.method = source.method;
977
+ target.headers = source.headers;
978
+ target.body = source.body;
979
+ target.cache = source.cache;
980
+ target.credentials = source.credentials;
981
+ target.integrity = source.integrity;
982
+ target.keepalive = source.keepalive;
983
+ target.mode = source.mode;
984
+ target.redirect = source.redirect;
985
+ target.referrer = source.referrer;
986
+ target.referrerPolicy = source.referrerPolicy;
987
+ target[AbortControllerProperty] = source[AbortControllerProperty];
1047
988
  }
1048
-
1049
- // src/context/utils/assign-shared-context.ts
989
+ //#endregion
990
+ //#region src/context/utils/assign-shared-context.ts
1050
991
  function assignSharedContext(target, source) {
1051
- assignRequestInit(target.request, source.request);
1052
- Object.assign(target.global, source.global);
1053
- Object.assign(target.options, source.options);
1054
- Object.assign(target.data, source.data);
1055
- target[ContextEmitterProperty] = source[ContextEmitterProperty];
1056
- target[ContextOutputProperty] = source[ContextOutputProperty];
1057
- target.res = source.res;
992
+ assignRequestInit(target.request, source.request);
993
+ Object.assign(target.global, source.global);
994
+ Object.assign(target.options, source.options);
995
+ Object.assign(target.data, source.data);
996
+ target[ContextEmitterProperty] = source[ContextEmitterProperty];
997
+ target[ContextOutputProperty] = source[ContextOutputProperty];
998
+ target.res = source.res;
1058
999
  }
1059
-
1060
- // src/orchestrator/orchestrator.ts
1061
- var KeqMiddlewareOrchestrator = class _KeqMiddlewareOrchestrator {
1062
- constructor(context, middlewares = []) {
1063
- __publicField(this, "main");
1064
- __publicField(this, "status", "idle");
1065
- __publicField(this, "context");
1066
- __publicField(this, "executors", []);
1067
- __publicField(this, "current", -1);
1068
- this.context = context;
1069
- this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw));
1070
- }
1071
- cancelNotFinished() {
1072
- const current = this.current;
1073
- for (let i = current + 1; i < this.executors.length; i++) {
1074
- const executor = this.executors[i];
1075
- if (executor.status === "pending") {
1076
- executor.status = "canceled";
1077
- }
1078
- }
1079
- }
1080
- async run() {
1081
- if (this.executors.length === 0) return;
1082
- const executors = [...this.executors];
1083
- const next = async (nextIndex) => {
1084
- if (nextIndex >= executors.length) return;
1085
- const nextExecutor = executors[nextIndex];
1086
- if (nextExecutor.status !== "idle") {
1087
- const msg = "Cannot call next() because the next Middleware(".concat(nextExecutor.name, ") status is ").concat(nextExecutor.status, ". If you want to re-execute it, please fork a new orchestrator.");
1088
- throw new Exception(msg);
1089
- }
1090
- if (this.current + 1 !== nextIndex) {
1091
- const parentExecutor = executors[nextIndex - 1];
1092
- const msg = parentExecutor ? "Cannot call next() outside Middleware(".concat(parentExecutor.name, ") runtime. You can fork a new orchestration and execute the forked one anywhere.") : "Cannot jump to non-sequential middleware. Please call next() in order.";
1093
- throw new Exception(msg);
1094
- }
1095
- const last = this.current;
1096
- this.current = nextIndex;
1097
- const context = new KeqExecutionContext(this, nextExecutor);
1098
- try {
1099
- await nextExecutor.execute(context, () => next.call(this, nextIndex + 1));
1100
- } finally {
1101
- if (this.current === last + 1) {
1102
- this.current = last;
1103
- } else if (this.current > last) {
1104
- this.cancelNotFinished();
1105
- this.current = last;
1106
- }
1107
- }
1108
- };
1109
- await next.call(this, 0);
1110
- }
1111
- async execute() {
1112
- if (this.status !== "idle") {
1113
- throw new Exception("Orchestrator has already been executed.");
1114
- }
1115
- this.status = "pending";
1116
- try {
1117
- await this.run();
1118
- this.status = "fulfilled";
1119
- } catch (error) {
1120
- this.status = "rejected";
1121
- throw error;
1122
- }
1123
- }
1124
- fork() {
1125
- const context = cloneSharedContext(this.context);
1126
- const next = this.current + 1;
1127
- const middlewares = this.executors.slice(next).map((executor) => executor.middleware);
1128
- const forkedOrchestrator = new _KeqMiddlewareOrchestrator(context, middlewares);
1129
- forkedOrchestrator.main = {
1130
- orchestrator: this.main ? this.main.orchestrator : this,
1131
- index: this.main ? this.main.index + next : next
1132
- };
1133
- return forkedOrchestrator;
1134
- }
1135
- merge(source) {
1136
- if (!source.main) throw new TypeException("Source orchestrator is not a forked orchestrator.");
1137
- const target = this.main ? this.main.orchestrator : this;
1138
- if (source.main.orchestrator !== target) throw new TypeException("Cannot rebase to unrelated orchestrator");
1139
- if (source.main.index !== this.current + 1) throw new TypeException("Cannot merge from non-current(expected: ".concat(this.current + 1, ", actual: ").concat(source.main.index, ") forked orchestrator"));
1140
- assignSharedContext(this.context, source.context);
1141
- for (const [i, executor] of this.executors.slice(source.main.index).entries()) {
1142
- executor.status = source.executors[i].status;
1143
- }
1144
- }
1000
+ //#endregion
1001
+ //#region src/orchestrator/orchestrator.ts
1002
+ var KeqMiddlewareOrchestrator = class KeqMiddlewareOrchestrator {
1003
+ constructor(context, middlewares = [], inherit) {
1004
+ _defineProperty(this, "main", void 0);
1005
+ _defineProperty(this, "status", "idle");
1006
+ _defineProperty(this, "context", void 0);
1007
+ _defineProperty(this, "executors", []);
1008
+ _defineProperty(this, "current", -1);
1009
+ this.context = context;
1010
+ this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw));
1011
+ if (inherit?.main) this.main = inherit.main;
1012
+ }
1013
+ cancelNotFinished() {
1014
+ const current = this.current;
1015
+ for (let i = current + 1; i < this.executors.length; i++) {
1016
+ const executor = this.executors[i];
1017
+ if (executor.status === "pending") executor.status = "canceled";
1018
+ }
1019
+ }
1020
+ async run() {
1021
+ if (this.executors.length === 0) return;
1022
+ const executors = [...this.executors];
1023
+ const next = async (nextIndex) => {
1024
+ if (nextIndex >= executors.length) return;
1025
+ const nextExecutor = executors[nextIndex];
1026
+ if (nextExecutor.status !== "idle") throw new Exception(`Cannot call next() because the next Middleware(${nextExecutor.name}) status is ${nextExecutor.status}. If you want to re-execute it, please fork a new orchestrator.`);
1027
+ if (this.current + 1 !== nextIndex) {
1028
+ const parentExecutor = executors[nextIndex - 1];
1029
+ throw new Exception(parentExecutor ? `Cannot call next() outside Middleware(${parentExecutor.name}) runtime. You can fork a new orchestration and execute the forked one anywhere.` : "Cannot jump to non-sequential middleware. Please call next() in order.");
1030
+ }
1031
+ const last = this.current;
1032
+ this.current = nextIndex;
1033
+ const context = new KeqExecutionContext(this, nextExecutor);
1034
+ try {
1035
+ await nextExecutor.execute(context, () => next.call(this, nextIndex + 1));
1036
+ } finally {
1037
+ if (this.current === last + 1) this.current = last;
1038
+ else if (this.current > last) {
1039
+ this.cancelNotFinished();
1040
+ this.current = last;
1041
+ }
1042
+ }
1043
+ };
1044
+ await next.call(this, 0);
1045
+ }
1046
+ async execute() {
1047
+ if (this.status !== "idle") throw new Exception("Orchestrator has already been executed.");
1048
+ this.status = "pending";
1049
+ try {
1050
+ await this.run();
1051
+ this.status = "fulfilled";
1052
+ } catch (error) {
1053
+ this.status = "rejected";
1054
+ throw error;
1055
+ }
1056
+ }
1057
+ fork() {
1058
+ const context = cloneSharedContext(this.context);
1059
+ const next = this.current + 1;
1060
+ return new KeqMiddlewareOrchestrator(context, this.executors.slice(next).map((executor) => executor.middleware), { main: {
1061
+ orchestrator: this.main ? this.main.orchestrator : this,
1062
+ index: this.main ? this.main.index + next : next
1063
+ } });
1064
+ }
1065
+ merge(source) {
1066
+ if (!source.main) throw new TypeException("Source orchestrator is not a forked orchestrator.");
1067
+ const target = this.main ? this.main.orchestrator : this;
1068
+ if (source.main.orchestrator !== target) throw new TypeException("Cannot rebase to unrelated orchestrator");
1069
+ if (source.main.index !== this.current + 1) throw new TypeException(`Cannot merge from non-current(expected: ${this.current + 1}, actual: ${source.main.index}) forked orchestrator`);
1070
+ assignSharedContext(this.context, source.context);
1071
+ for (const [i, executor] of this.executors.slice(source.main.index).entries()) executor.status = source.executors[i].status;
1072
+ }
1145
1073
  };
1146
-
1147
- // src/request/utils/fix-content-type.ts
1074
+ //#endregion
1075
+ //#region src/request/utils/fix-content-type.ts
1148
1076
  function fixContentType(contentType) {
1149
- if (["json", "xml"].includes(contentType)) {
1150
- return "application/".concat(contentType);
1151
- } else if (["html", "css"].includes(contentType)) {
1152
- return "text/".concat(contentType);
1153
- } else if (["form-data"].includes(contentType)) {
1154
- return "multipart/".concat(contentType);
1155
- } else if (["jpeg", "bmp", "apng", "gif", "x-icon", "png", "webp", "tiff"].includes(contentType)) {
1156
- return "image/".concat(contentType);
1157
- } else if (contentType === "form") {
1158
- return "application/x-www-form-urlencoded";
1159
- } else if (contentType === "svg") {
1160
- return "image/svg+xml";
1161
- }
1162
- return contentType;
1077
+ if (["json", "xml"].includes(contentType)) return `application/${contentType}`;
1078
+ else if (["html", "css"].includes(contentType)) return `text/${contentType}`;
1079
+ else if (["form-data"].includes(contentType)) return `multipart/${contentType}`;
1080
+ else if ([
1081
+ "jpeg",
1082
+ "bmp",
1083
+ "apng",
1084
+ "gif",
1085
+ "x-icon",
1086
+ "png",
1087
+ "webp",
1088
+ "tiff"
1089
+ ].includes(contentType)) return `image/${contentType}`;
1090
+ else if (contentType === "form") return "application/x-www-form-urlencoded";
1091
+ else if (contentType === "svg") return "image/svg+xml";
1092
+ return contentType;
1163
1093
  }
1164
-
1165
- // src/request/utils/get-location-id.ts
1094
+ //#endregion
1095
+ //#region src/request/utils/get-location-id.ts
1166
1096
  function getLocationId(depth = 0) {
1167
- const err = new Error();
1168
- if (!err.stack) return "";
1169
- const stackLine = err.stack.split("\n")[depth + 2];
1170
- return stackLine.trim();
1097
+ const err = /* @__PURE__ */ new Error();
1098
+ if (!err.stack) return "";
1099
+ return err.stack.split("\n")[depth + 2].trim();
1171
1100
  }
1172
-
1173
- // src/request/utils/resolve-with.ts
1174
- var import_stream = require("eventsource-parser/stream");
1101
+ //#endregion
1102
+ //#region src/request/utils/resolve-with.ts
1175
1103
  async function resolveWith(response, mode) {
1176
- if (mode === "response") return response.clone();
1177
- if (mode === "text") return await response.text();
1178
- if (mode === "json") return unwrap(await response.json());
1179
- if (mode === "form-data") return await response.formData();
1180
- if (mode === "blob") return await response.blob();
1181
- if (mode === "array-buffer") return await response.arrayBuffer();
1182
- if (mode === "sse") {
1183
- if (!response.body) return response.body;
1184
- return response.clone().body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_stream.EventSourceParserStream());
1185
- }
1186
- return void 0;
1104
+ if (mode === "response") return response.clone();
1105
+ if (mode === "text") return await response.text();
1106
+ if (mode === "json") return unwrap(await response.json());
1107
+ if (mode === "form-data") return await response.formData();
1108
+ if (mode === "blob") return await response.blob();
1109
+ if (mode === "array-buffer") return await response.arrayBuffer();
1110
+ if (mode === "sse") {
1111
+ if (!response.body) return response.body;
1112
+ return response.clone().body.pipeThrough(new TextDecoderStream()).pipeThrough(new eventsource_parser_stream.EventSourceParserStream());
1113
+ }
1187
1114
  }
1188
-
1189
- // src/request/utils/intelligent-parse-response.ts
1115
+ //#endregion
1116
+ //#region src/request/utils/intelligent-parse-response.ts
1190
1117
  async function intelligentParseResponse(response) {
1191
- if (!response) return void 0;
1192
- if (response.status === 204) {
1193
- return void 0;
1194
- }
1195
- const contentType = response.headers.get("content-type") || "";
1196
- try {
1197
- if (contentType.match(/^application\/(.+\+)?json/)) {
1198
- return resolveWith(response, "json");
1199
- } else if (contentType.includes("multipart/form-data")) {
1200
- return resolveWith(response, "form-data");
1201
- } else if (contentType.includes("plain/text")) {
1202
- return resolveWith(response, "text");
1203
- } else if (contentType.includes("text/event-stream")) {
1204
- return resolveWith(response, "sse");
1205
- }
1206
- } catch (err) {
1207
- console.warn("Failed to intelligent parse response body: ".concat(response.url), err);
1208
- throw err;
1209
- }
1210
- return void 0;
1118
+ if (!response) return void 0;
1119
+ if (response.status === 204) return;
1120
+ const contentType = response.headers.get("content-type") || "";
1121
+ try {
1122
+ if (contentType.match(/^application\/(.+\+)?json/)) return resolveWith(response, "json");
1123
+ else if (contentType.includes("multipart/form-data")) return resolveWith(response, "form-data");
1124
+ else if (contentType.includes("plain/text")) return resolveWith(response, "text");
1125
+ else if (contentType.includes("text/event-stream")) return resolveWith(response, "sse");
1126
+ } catch (err) {
1127
+ console.warn(`Failed to intelligent parse response body: ${response.url}`, err);
1128
+ throw err;
1129
+ }
1211
1130
  }
1212
-
1213
- // src/request/utils/merge-keq-request-body.ts
1131
+ //#endregion
1132
+ //#region src/request/utils/merge-keq-request-body.ts
1214
1133
  function mergeKeqRequestBody(left, right) {
1215
- if (right === void 0) return left;
1216
- if (typeof right === "number") {
1217
- throw new TypeError("Cannot set request body to a number.");
1218
- }
1219
- if (left === null || right === null || Validator.isBuffer(right) || Validator.isArrayBuffer(right) || Validator.isBlob(right) || Validator.isReadableStream(right) || Validator.isBuffer(left) || Validator.isArrayBuffer(left) || Validator.isBlob(left) || Validator.isReadableStream(left) || Array.isArray(left) || Array.isArray(right) || typeof left !== "object" && left !== void 0 || typeof right !== "object") {
1220
- return Array.isArray(right) ? [...right] : right;
1221
- }
1222
- const result = left || {};
1223
- if (Validator.isUrlSearchParams(right)) {
1224
- const keys = right.keys();
1225
- for (const key of keys) {
1226
- const values = right.getAll(key);
1227
- if (values.length === 1) {
1228
- result[key] = values[0];
1229
- } else if (values.length > 1) {
1230
- result[key] = values;
1231
- }
1232
- }
1233
- } else if (Validator.isFormData(right)) {
1234
- const keys = right.keys();
1235
- for (const key of keys) {
1236
- const values = right.getAll(key);
1237
- if (values.length === 1) {
1238
- result[key] = values[0];
1239
- } else if (values.length > 1) {
1240
- result[key] = values;
1241
- }
1242
- }
1243
- } else if (typeof right === "object") {
1244
- for (const key in right) {
1245
- result[key] = right[key];
1246
- }
1247
- } else {
1248
- throw new Exception("Not support request body type: ".concat(typeof right));
1249
- }
1250
- return result;
1134
+ if (right === void 0) return left;
1135
+ if (typeof right === "number") throw new TypeError("Cannot set request body to a number.");
1136
+ if (left === null || right === null || Validator.isBuffer(right) || Validator.isArrayBuffer(right) || Validator.isBlob(right) || Validator.isReadableStream(right) || Validator.isBuffer(left) || Validator.isArrayBuffer(left) || Validator.isBlob(left) || Validator.isReadableStream(left) || Array.isArray(left) || Array.isArray(right) || typeof left !== "object" && left !== void 0 || typeof right !== "object") return Array.isArray(right) ? [...right] : right;
1137
+ const result = left || {};
1138
+ if (Validator.isUrlSearchParams(right)) {
1139
+ const keys = right.keys();
1140
+ for (const key of keys) {
1141
+ const values = right.getAll(key);
1142
+ if (values.length === 1) result[key] = values[0];
1143
+ else if (values.length > 1) result[key] = values;
1144
+ }
1145
+ } else if (Validator.isFormData(right)) {
1146
+ const keys = right.keys();
1147
+ for (const key of keys) {
1148
+ const values = right.getAll(key);
1149
+ if (values.length === 1) result[key] = values[0];
1150
+ else if (values.length > 1) result[key] = values;
1151
+ }
1152
+ } else if (typeof right === "object") for (const key in right) result[key] = right[key];
1153
+ else throw new Exception(`Not support request body type: ${typeof right}`);
1154
+ return result;
1251
1155
  }
1252
-
1253
- // src/request/utils/query-stringify.ts
1254
- var import_qs = __toESM(require("qs"));
1156
+ //#endregion
1157
+ //#region src/request/utils/query-stringify.ts
1255
1158
  function normalize(value, options) {
1256
- if (Array.isArray(value)) {
1257
- return value.map((v) => normalize(v, options));
1258
- }
1259
- if (typeof value === "bigint") {
1260
- return value.toString();
1261
- }
1262
- if (typeof value === "object" && value !== null) {
1263
- const obj = { ...value };
1264
- for (const key of Object.keys(obj)) {
1265
- obj[key] = normalize(obj[key], options);
1266
- }
1267
- return obj;
1268
- }
1269
- return value;
1159
+ if (Array.isArray(value)) return value.map((v) => normalize(v, options));
1160
+ if (typeof value === "bigint") return value.toString();
1161
+ if (typeof value === "object" && value !== null) {
1162
+ const obj = { ...value };
1163
+ for (const key of Object.keys(obj)) obj[key] = normalize(obj[key], options);
1164
+ return obj;
1165
+ }
1166
+ return value;
1270
1167
  }
1271
1168
  function queryStringify(query, options) {
1272
- const value = normalize(query, options);
1273
- const opts = {};
1274
- if ((options == null ? void 0 : options.allowDots) !== void 0) {
1275
- opts.allowDots = options.allowDots;
1276
- }
1277
- if ((options == null ? void 0 : options.indices) !== void 0) {
1278
- opts.indices = options.indices;
1279
- }
1280
- if ((options == null ? void 0 : options.arrayFormat) === "pipe") {
1281
- opts.filter = (_, val) => {
1282
- if (Array.isArray(val)) return val.join("|");
1283
- return val;
1284
- };
1285
- } else if ((options == null ? void 0 : options.arrayFormat) === "space") {
1286
- opts.filter = (_, val) => {
1287
- if (Array.isArray(val)) return val.join(" ");
1288
- return val;
1289
- };
1290
- } else if (options == null ? void 0 : options.arrayFormat) {
1291
- opts.arrayFormat = options.arrayFormat;
1292
- }
1293
- return import_qs.default.stringify(value, opts);
1169
+ const value = normalize(query, options);
1170
+ const opts = {};
1171
+ if (options?.allowDots !== void 0) opts.allowDots = options.allowDots;
1172
+ if (options?.indices !== void 0) opts.indices = options.indices;
1173
+ if (options?.arrayFormat === "pipe") opts.filter = (_, val) => {
1174
+ if (Array.isArray(val)) return val.join("|");
1175
+ return val;
1176
+ };
1177
+ else if (options?.arrayFormat === "space") opts.filter = (_, val) => {
1178
+ if (Array.isArray(val)) return val.join(" ");
1179
+ return val;
1180
+ };
1181
+ else if (options?.arrayFormat) opts.arrayFormat = options.arrayFormat;
1182
+ return qs.default.stringify(value, opts);
1294
1183
  }
1295
-
1296
- // src/request/core.ts
1297
- var Core = class {
1298
- constructor(url, options) {
1299
- /**
1300
- * The unique identifier of the request's location in the code
1301
- */
1302
- __publicField(this, "__locationId__");
1303
- __publicField(this, "requestPromise");
1304
- __publicField(this, "requestInit");
1305
- __publicField(this, "__listeners__", {});
1306
- __publicField(this, "__global__");
1307
- __publicField(this, "__prepend_middlewares__", []);
1308
- __publicField(this, "__append_middlewares__", []);
1309
- __publicField(this, "__qs__");
1310
- __publicField(this, "__options__", {
1311
- resolveWithFullResponse: false,
1312
- resolveWith: "intelligent"
1313
- });
1314
- this.__global__ = options.global || {};
1315
- this.__locationId__ = options.locationId;
1316
- this.__qs__ = options.qs;
1317
- this.requestInit = new KeqRequestInit({
1318
- method: "get",
1319
- headers: new Headers(),
1320
- pathParameters: {},
1321
- body: void 0,
1322
- ...options,
1323
- url: new URL(url.href)
1324
- });
1325
- }
1326
- get __middlewares__() {
1327
- return [...this.__prepend_middlewares__, ...this.__append_middlewares__];
1328
- }
1329
- prependMiddlewares(...middlewares) {
1330
- this.__prepend_middlewares__.push(...middlewares);
1331
- return this;
1332
- }
1333
- /**
1334
- * Appends middlewares to the end of the middleware chain.
1335
- * Using this method indiscriminately is discouraged;
1336
- * prefer using `.use` to maintain predictable execution order.
1337
- */
1338
- appendMiddlewares(...middlewares) {
1339
- this.__append_middlewares__.unshift(...middlewares);
1340
- return this;
1341
- }
1342
- use(...middlewares) {
1343
- return this.prependMiddlewares(...middlewares);
1344
- }
1345
- on(event, listener) {
1346
- this.__listeners__[event] = this.__listeners__[event] || [];
1347
- this.__listeners__[event].push(listener);
1348
- return this;
1349
- }
1350
- option(key, value = true) {
1351
- this.__options__[key] = value;
1352
- return this;
1353
- }
1354
- options(opts) {
1355
- for (const [key, value] of Object.entries(opts)) {
1356
- this.__options__[key] = value;
1357
- }
1358
- return this;
1359
- }
1360
- buildSharedContext() {
1361
- const coreContext = new KeqSharedContext({
1362
- locationId: this.__locationId__,
1363
- request: this.requestInit,
1364
- global: this.__global__,
1365
- options: this.__options__
1366
- });
1367
- for (const eventName in this.__listeners__) {
1368
- const listeners = this.__listeners__[eventName];
1369
- for (const listener of listeners) {
1370
- coreContext.emitter.on(eventName, listener);
1371
- }
1372
- }
1373
- return coreContext;
1374
- }
1375
- async run() {
1376
- var _a6, _b4, _c2, _d2;
1377
- let attempt;
1378
- while (true) {
1379
- const attemptWithDefault = attempt || 0;
1380
- const sharedContext = this.buildSharedContext();
1381
- const orchestrator = new KeqMiddlewareOrchestrator(sharedContext, this.__middlewares__);
1382
- if (attempt !== void 0) sharedContext.data.retry = { attempt };
1383
- if (attempt && attempt >= 1) sharedContext.emitter.emit("retry", { context: sharedContext });
1384
- let error = null;
1385
- try {
1386
- await orchestrator.execute();
1387
- } catch (err) {
1388
- error = err;
1389
- }
1390
- const retryOn = typeof ((_a6 = sharedContext.options.retry) == null ? void 0 : _a6.on) === "function" ? sharedContext.options.retry.on : (attempt2, error2) => {
1391
- if (error2 instanceof RequestException && error2.retry === false) return false;
1392
- return !!error2;
1393
- };
1394
- let retryTimes = ((_b4 = sharedContext.options.retry) == null ? void 0 : _b4.times) || 0;
1395
- if (retryTimes) {
1396
- if (retryTimes < 0) retryTimes = 0;
1397
- else if (!Number.isInteger(retryTimes)) retryTimes = Math.floor(retryTimes);
1398
- }
1399
- if (attemptWithDefault >= retryTimes || await retryOn(attemptWithDefault, error, sharedContext) === false) {
1400
- if (error) {
1401
- sharedContext.emitter.emit("error", { context: sharedContext });
1402
- throw error;
1403
- }
1404
- return sharedContext;
1405
- }
1406
- const retryDelay = typeof ((_c2 = sharedContext.options.retry) == null ? void 0 : _c2.delay) === "function" ? await sharedContext.options.retry.delay(attemptWithDefault, error, sharedContext) : ((_d2 = sharedContext.options.retry) == null ? void 0 : _d2.delay) || 0;
1407
- if (retryDelay) await sleep(retryDelay);
1408
- attempt = attemptWithDefault + 1;
1409
- }
1410
- }
1411
- async end() {
1412
- var _a6;
1413
- const coreContext = await this.run();
1414
- const resolveWithMode = coreContext.options.resolveWith;
1415
- if (resolveWithMode === "response") {
1416
- return (_a6 = coreContext.response) == null ? void 0 : _a6.clone();
1417
- }
1418
- const response = coreContext.response;
1419
- if (!resolveWithMode || resolveWithMode === "intelligent") {
1420
- const output = coreContext.output;
1421
- if (output !== void 0) {
1422
- return output;
1423
- }
1424
- return await intelligentParseResponse(response);
1425
- }
1426
- if (!response) {
1427
- throw new Exception([
1428
- "Unable to process the response with '".concat(resolveWithMode, "'. Possible causes:"),
1429
- "1. The request was never initiated or sent",
1430
- "2. The request failed before a response was received."
1431
- ].join("\n"));
1432
- }
1433
- return await resolveWith(response, resolveWithMode);
1434
- }
1435
- /**
1436
- * Attaches callbacks for the resolution and/or rejection of the Promise.
1437
- * @param onfulfilled The callback to execute when the Promise is resolved.
1438
- * @param onrejected The callback to execute when the Promise is rejected.
1439
- * @returns A Promise for the completion of which ever callback is executed.
1440
- */
1441
- then(onfulfilled, onrejected) {
1442
- if (!this.requestPromise) this.requestPromise = this.end();
1443
- return this.requestPromise.then(onfulfilled, onrejected);
1444
- }
1445
- catch(onrejected) {
1446
- return this.end().catch(onrejected);
1447
- }
1448
- finally(onfinally) {
1449
- return this.end().finally(onfinally);
1450
- }
1184
+ //#endregion
1185
+ //#region src/request/core.ts
1186
+ let _Symbol$species;
1187
+ _Symbol$species = Symbol.species;
1188
+ /**
1189
+ * Core class that provides the foundational structure for managing middlewares, events, and request execution.
1190
+ */
1191
+ var Core = class extends Promise {
1192
+ /**
1193
+ * Ensures `.then()`, `.catch()`, `.finally()` return plain Promise instances instead of Core/Keq instances.
1194
+ */
1195
+ static get [_Symbol$species]() {
1196
+ return Promise;
1197
+ }
1198
+ get __middlewares__() {
1199
+ return [...this.__prepend_middlewares__, ...this.__append_middlewares__];
1200
+ }
1201
+ constructor(url, options) {
1202
+ let resolve;
1203
+ let reject;
1204
+ super((res, rej) => {
1205
+ resolve = res;
1206
+ reject = rej;
1207
+ });
1208
+ _defineProperty(
1209
+ this,
1210
+ /**
1211
+ * The unique identifier of the request's location in the code
1212
+ */
1213
+ "__locationId__",
1214
+ void 0
1215
+ );
1216
+ _defineProperty(this, "__resolve__", void 0);
1217
+ _defineProperty(this, "__reject__", void 0);
1218
+ _defineProperty(this, "__triggered__", false);
1219
+ _defineProperty(this, "__requestPromise__", void 0);
1220
+ _defineProperty(this, "requestInit", void 0);
1221
+ _defineProperty(this, "__listeners__", {});
1222
+ _defineProperty(this, "__global__", void 0);
1223
+ _defineProperty(this, "__prepend_middlewares__", []);
1224
+ _defineProperty(this, "__append_middlewares__", []);
1225
+ _defineProperty(this, "__qs__", void 0);
1226
+ _defineProperty(this, "__options__", {
1227
+ resolveWithFullResponse: false,
1228
+ resolveWith: "intelligent"
1229
+ });
1230
+ this.__resolve__ = resolve;
1231
+ this.__reject__ = reject;
1232
+ this.__global__ = options.global || {};
1233
+ this.__locationId__ = options.locationId;
1234
+ this.__qs__ = options.qs;
1235
+ this.requestInit = new KeqRequestInit({
1236
+ method: "get",
1237
+ headers: new Headers(),
1238
+ pathParameters: {},
1239
+ body: void 0,
1240
+ ...options,
1241
+ url: new URL(url.href)
1242
+ });
1243
+ if (options.middlewares) this.__append_middlewares__.push(...options.middlewares);
1244
+ }
1245
+ use(...middlewares) {
1246
+ this.__prepend_middlewares__.push(...middlewares);
1247
+ return this;
1248
+ }
1249
+ on(event, listener) {
1250
+ this.__listeners__[event] = this.__listeners__[event] || [];
1251
+ this.__listeners__[event].push(listener);
1252
+ return this;
1253
+ }
1254
+ option(key, value = true) {
1255
+ this.__options__[key] = value;
1256
+ return this;
1257
+ }
1258
+ options(opts) {
1259
+ for (const [key, value] of Object.entries(opts)) this.__options__[key] = value;
1260
+ return this;
1261
+ }
1262
+ derive() {
1263
+ const derived = new this.constructor(this.requestInit.url, {
1264
+ method: this.requestInit.method,
1265
+ headers: this.requestInit.headers,
1266
+ body: this.requestInit.body,
1267
+ pathParameters: this.requestInit.pathParameters,
1268
+ cache: this.requestInit.cache,
1269
+ credentials: this.requestInit.credentials,
1270
+ integrity: this.requestInit.integrity,
1271
+ keepalive: this.requestInit.keepalive,
1272
+ mode: this.requestInit.mode,
1273
+ redirect: this.requestInit.redirect,
1274
+ referrer: this.requestInit.referrer,
1275
+ referrerPolicy: this.requestInit.referrerPolicy,
1276
+ locationId: this.__locationId__,
1277
+ global: this.__global__,
1278
+ qs: this.__qs__ ? { ...this.__qs__ } : void 0,
1279
+ middlewares: [...this.__append_middlewares__]
1280
+ });
1281
+ derived.__prepend_middlewares__ = [...this.__prepend_middlewares__];
1282
+ derived.__listeners__ = {};
1283
+ for (const key in this.__listeners__) derived.__listeners__[key] = [...this.__listeners__[key]];
1284
+ derived.__options__ = (0, klona_json.klona)(this.__options__);
1285
+ return derived;
1286
+ }
1287
+ buildSharedContext() {
1288
+ const coreContext = new KeqSharedContext({
1289
+ locationId: this.__locationId__,
1290
+ request: this.requestInit,
1291
+ global: this.__global__,
1292
+ options: this.__options__
1293
+ });
1294
+ for (const eventName in this.__listeners__) {
1295
+ const listeners = this.__listeners__[eventName];
1296
+ for (const listener of listeners) coreContext.emitter.on(eventName, listener);
1297
+ }
1298
+ return coreContext;
1299
+ }
1300
+ async run() {
1301
+ let attempt;
1302
+ while (true) {
1303
+ const attemptWithDefault = attempt || 0;
1304
+ const sharedContext = this.buildSharedContext();
1305
+ const orchestrator = new KeqMiddlewareOrchestrator(sharedContext, this.__middlewares__);
1306
+ if (attempt !== void 0) sharedContext.data.retry = { attempt };
1307
+ if (attempt && attempt >= 1) sharedContext.emitter.emit("retry", { context: sharedContext });
1308
+ let error = null;
1309
+ try {
1310
+ await orchestrator.execute();
1311
+ } catch (err) {
1312
+ error = err;
1313
+ }
1314
+ const retryOn = typeof sharedContext.options.retry?.on === "function" ? sharedContext.options.retry.on : (attempt, error) => {
1315
+ if (error instanceof RequestException && error.retry === false) return false;
1316
+ return !!error;
1317
+ };
1318
+ let retryTimes = sharedContext.options.retry?.times || 0;
1319
+ if (retryTimes) {
1320
+ if (retryTimes < 0) retryTimes = 0;
1321
+ else if (!Number.isInteger(retryTimes)) retryTimes = Math.floor(retryTimes);
1322
+ }
1323
+ if (attemptWithDefault >= retryTimes || await retryOn(attemptWithDefault, error, sharedContext) === false) {
1324
+ if (error) {
1325
+ sharedContext.emitter.emit("error", { context: sharedContext });
1326
+ throw error;
1327
+ }
1328
+ return sharedContext;
1329
+ }
1330
+ const retryDelay = typeof sharedContext.options.retry?.delay === "function" ? await sharedContext.options.retry.delay(attemptWithDefault, error, sharedContext) : sharedContext.options.retry?.delay || 0;
1331
+ if (retryDelay) await sleep(retryDelay);
1332
+ attempt = attemptWithDefault + 1;
1333
+ }
1334
+ }
1335
+ __execute__() {
1336
+ if (!this.__requestPromise__) this.__requestPromise__ = (async () => {
1337
+ const coreContext = await this.run();
1338
+ const resolveWithMode = coreContext.options.resolveWith;
1339
+ if (resolveWithMode === "response") return coreContext.response?.clone();
1340
+ const response = coreContext.response;
1341
+ if (!resolveWithMode || resolveWithMode === "intelligent") {
1342
+ const output = coreContext.output;
1343
+ if (output !== void 0) return output;
1344
+ return await intelligentParseResponse(response);
1345
+ }
1346
+ if (!response) throw new Exception([
1347
+ `Unable to process the response with '${resolveWithMode}'. Possible causes:`,
1348
+ "1. The request was never initiated or sent",
1349
+ "2. The request failed before a response was received."
1350
+ ].join("\n"));
1351
+ return await resolveWith(response, resolveWithMode);
1352
+ })();
1353
+ return this.__requestPromise__;
1354
+ }
1355
+ fire() {
1356
+ if (!this.__triggered__) {
1357
+ this.__triggered__ = true;
1358
+ this.__execute__().then(this.__resolve__, this.__reject__);
1359
+ }
1360
+ }
1361
+ then(onfulfilled, onrejected) {
1362
+ if (!this.__triggered__) {
1363
+ this.__triggered__ = true;
1364
+ this.__execute__().then(this.__resolve__, this.__reject__);
1365
+ }
1366
+ return super.then(onfulfilled, onrejected);
1367
+ }
1451
1368
  };
1452
-
1453
- // src/request/keq.ts
1369
+ //#endregion
1370
+ //#region src/request/keq.ts
1371
+ /**
1372
+ * extends Core to provide a fluent API for building HTTP requests
1373
+ */
1454
1374
  var Keq = class extends Core {
1455
- set(headersOrName, value) {
1456
- if (Validator.isHeaders(headersOrName)) {
1457
- headersOrName.forEach((value2, key) => {
1458
- this.requestInit.headers.set(key, value2);
1459
- });
1460
- } else if (typeof headersOrName === "string" && value) {
1461
- if (!Validator.isHeaderValue(value)) {
1462
- throw new Exception("[Invalid header] Key: ".concat(headersOrName, " Value: ").concat(value));
1463
- }
1464
- this.requestInit.headers.set(headersOrName, String(value));
1465
- } else if (typeof headersOrName === "object") {
1466
- for (const [key, value2] of Object.entries(headersOrName)) {
1467
- if (!Validator.isHeaderValue(value2)) {
1468
- throw new Exception("[Invalid header] Key: ".concat(key, " Value: ").concat(String(value2)));
1469
- }
1470
- this.requestInit.headers.set(key, String(value2));
1471
- }
1472
- }
1473
- return this;
1474
- }
1475
- headers(headersOrName, value) {
1476
- return this.set(headersOrName, value);
1477
- }
1478
- query(arg1, arg2, arg3) {
1479
- if (Validator.isObject(arg1)) {
1480
- const str = queryStringify(arg1, arg2 || this.__qs__);
1481
- for (const [k, v] of new URLSearchParams(str).entries()) {
1482
- for (const item of Array.isArray(v) ? v : [v]) {
1483
- this.requestInit.url.searchParams.append(k, item);
1484
- }
1485
- }
1486
- this.requestInit.url.search = this.requestInit.url.searchParams.toString().replace(/\+/g, "%20");
1487
- return this;
1488
- }
1489
- if (typeof arg1 === "string") {
1490
- this.query({ [arg1]: arg2 }, arg3);
1491
- return this;
1492
- }
1493
- throw new TypeException("Invalid Arguments for .query()");
1494
- }
1495
- params(arg1, arg2) {
1496
- if (typeof arg1 === "string" && arg2 !== void 0) {
1497
- this.requestInit.pathParameters[arg1] = arg2;
1498
- } else if (typeof arg1 === "object" && arg1 !== null) {
1499
- for (const k of Object.keys(arg1)) {
1500
- if (arg1[k]) this.requestInit.pathParameters[k] = arg1[k];
1501
- }
1502
- } else {
1503
- throw new TypeError("Invalid Arguments for .params()");
1504
- }
1505
- return this;
1506
- }
1507
- /**
1508
- * Set request body
1509
- */
1510
- body(value) {
1511
- this.requestInit.body = value;
1512
- return this;
1513
- }
1514
- type(contentType) {
1515
- const type = fixContentType(contentType);
1516
- this.set("content-type", type);
1517
- return this;
1518
- }
1519
- /**
1520
- * Http Basic Authentication
1521
- */
1522
- auth(username, password) {
1523
- this.set("Authorization", "Basic ".concat(base64Encode("".concat(username, ":").concat(password))));
1524
- return this;
1525
- }
1526
- setTypeIfEmpty(contentType) {
1527
- if (!this.requestInit.headers.has("Content-Type")) void this.type(contentType);
1528
- }
1529
- send(value) {
1530
- this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, value);
1531
- if (Validator.isUrlSearchParams(value)) {
1532
- this.setTypeIfEmpty("form");
1533
- } else if (Validator.isFormData(value)) {
1534
- this.setTypeIfEmpty("form-data");
1535
- } else if (Validator.isBlob(value) || Validator.isReadableStream(value) || Validator.isArrayBuffer(value)) {
1536
- } else if (typeof value === "object") {
1537
- this.setTypeIfEmpty("json");
1538
- }
1539
- return this;
1540
- }
1541
- field(arg1, arg2) {
1542
- if (typeof arg1 === "object") {
1543
- this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, arg1);
1544
- } else if (arg2) {
1545
- this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [arg1]: arg2 });
1546
- } else {
1547
- throw new TypeException("Invalid arguments for .field()");
1548
- }
1549
- this.setTypeIfEmpty("form-data");
1550
- return this;
1551
- }
1552
- attach(key, value, arg3 = "file") {
1553
- const formData = new FormData();
1554
- const appendFile = (file) => {
1555
- if (Validator.isBlob(file)) {
1556
- formData.append(key, file, arg3);
1557
- } else if (Validator.isFile(file)) {
1558
- formData.append(key, file);
1559
- } else if (Validator.isBuffer(file)) {
1560
- formData.append(key, new Blob([file]), arg3);
1561
- } else {
1562
- throw new TypeException("Invalid file type for .attach()");
1563
- }
1564
- };
1565
- if (Array.isArray(value)) {
1566
- if (value.length === 0) {
1567
- throw new TypeException("Empty array provided to .attach() is not valid");
1568
- }
1569
- for (const item of value) {
1570
- appendFile(item);
1571
- }
1572
- } else {
1573
- appendFile(value);
1574
- }
1575
- const files = formData.getAll(key);
1576
- this.requestInit.body = mergeKeqRequestBody(
1577
- this.requestInit.body,
1578
- {
1579
- [key]: files.length === 1 ? files[0] : files
1580
- }
1581
- );
1582
- this.setTypeIfEmpty("form-data");
1583
- return this;
1584
- }
1585
- /**
1586
- *
1587
- * @param retryTimes Max number of retries per call
1588
- * @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)
1589
- * @param retryCallback Will be called after request failed
1590
- */
1591
- retry(retryTimes, retryDelay = 0, retryOn = (attempt, error) => !!error) {
1592
- this.option("retry", {
1593
- times: retryTimes,
1594
- delay: retryDelay,
1595
- on: retryOn
1596
- });
1597
- return this;
1598
- }
1599
- redirect(mod) {
1600
- this.requestInit.redirect = mod;
1601
- return this;
1602
- }
1603
- credentials(mod) {
1604
- this.requestInit.credentials = mod;
1605
- return this;
1606
- }
1607
- mode(mod) {
1608
- this.requestInit.mode = mod;
1609
- return this;
1610
- }
1611
- flowControl(mode, arg2, arg3) {
1612
- const concurrencyLimit = typeof arg2 === "number" ? arg2 : void 0;
1613
- const sig = typeof arg2 === "function" || typeof arg2 === "string" ? arg2 : arg3 && (typeof arg3 === "function" || typeof arg3 === "string") ? arg3 : this.__locationId__;
1614
- if (!sig) {
1615
- throw new Exception("please set signal to .flowControl()");
1616
- }
1617
- const flowControl = {
1618
- mode,
1619
- concurrencyLimit,
1620
- signal: sig
1621
- };
1622
- this.option("flowControl", flowControl);
1623
- return this;
1624
- }
1625
- timeout(milliseconds) {
1626
- this.option("timeout", { millisecond: milliseconds });
1627
- return this;
1628
- }
1629
- resolveWith(m2) {
1630
- this.option("resolveWith", m2);
1631
- return this;
1632
- }
1375
+ set(headersOrName, value) {
1376
+ if (Validator.isHeaders(headersOrName)) headersOrName.forEach((value, key) => {
1377
+ this.requestInit.headers.set(key, value);
1378
+ });
1379
+ else if (typeof headersOrName === "string" && value) {
1380
+ if (!Validator.isHeaderValue(value)) throw new Exception(`[Invalid header] Key: ${headersOrName} Value: ${value}`);
1381
+ this.requestInit.headers.set(headersOrName, String(value));
1382
+ } else if (typeof headersOrName === "object") for (const [key, value] of Object.entries(headersOrName)) {
1383
+ if (!Validator.isHeaderValue(value)) throw new Exception(`[Invalid header] Key: ${key} Value: ${String(value)}`);
1384
+ this.requestInit.headers.set(key, String(value));
1385
+ }
1386
+ return this;
1387
+ }
1388
+ headers(headersOrName, value) {
1389
+ return this.set(headersOrName, value);
1390
+ }
1391
+ query(arg1, arg2, arg3) {
1392
+ if (Validator.isObject(arg1)) {
1393
+ const str = queryStringify(arg1, arg2 || this.__qs__);
1394
+ for (const [k, v] of new URLSearchParams(str).entries()) for (const item of Array.isArray(v) ? v : [v]) this.requestInit.url.searchParams.append(k, item);
1395
+ this.requestInit.url.search = this.requestInit.url.searchParams.toString().replace(/\+/g, "%20");
1396
+ return this;
1397
+ }
1398
+ if (typeof arg1 === "string") {
1399
+ this.query({ [arg1]: arg2 }, arg3);
1400
+ return this;
1401
+ }
1402
+ throw new TypeException("Invalid Arguments for .query()");
1403
+ }
1404
+ params(arg1, arg2) {
1405
+ if (typeof arg1 === "string" && arg2 !== void 0) this.requestInit.pathParameters[arg1] = arg2;
1406
+ else if (typeof arg1 === "object" && arg1 !== null) {
1407
+ for (const k of Object.keys(arg1)) if (arg1[k]) this.requestInit.pathParameters[k] = arg1[k];
1408
+ } else throw new TypeError("Invalid Arguments for .params()");
1409
+ return this;
1410
+ }
1411
+ /**
1412
+ * Set request body
1413
+ */
1414
+ body(value) {
1415
+ this.requestInit.body = value;
1416
+ return this;
1417
+ }
1418
+ type(contentType) {
1419
+ const type = fixContentType(contentType);
1420
+ this.set("content-type", type);
1421
+ return this;
1422
+ }
1423
+ /**
1424
+ * Http Basic Authentication
1425
+ */
1426
+ auth(username, password) {
1427
+ this.set("Authorization", `Basic ${base64Encode(`${username}:${password}`)}`);
1428
+ return this;
1429
+ }
1430
+ setTypeIfEmpty(contentType) {
1431
+ if (!this.requestInit.headers.has("Content-Type")) this.type(contentType);
1432
+ }
1433
+ send(value) {
1434
+ this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, value);
1435
+ if (Validator.isUrlSearchParams(value)) this.setTypeIfEmpty("form");
1436
+ else if (Validator.isFormData(value)) this.setTypeIfEmpty("form-data");
1437
+ else if (Validator.isBlob(value) || Validator.isReadableStream(value) || Validator.isArrayBuffer(value)) {} else if (typeof value === "object") this.setTypeIfEmpty("json");
1438
+ return this;
1439
+ }
1440
+ field(arg1, arg2) {
1441
+ if (typeof arg1 === "object") this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, arg1);
1442
+ else if (arg2) this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [arg1]: arg2 });
1443
+ else throw new TypeException("Invalid arguments for .field()");
1444
+ this.setTypeIfEmpty("form-data");
1445
+ return this;
1446
+ }
1447
+ attach(key, value, arg3 = "file") {
1448
+ const formData = new FormData();
1449
+ const appendFile = (file) => {
1450
+ if (Validator.isBlob(file)) formData.append(key, file, arg3);
1451
+ else if (Validator.isFile(file)) formData.append(key, file);
1452
+ else if (Validator.isBuffer(file)) formData.append(key, new Blob([file]), arg3);
1453
+ else throw new TypeException("Invalid file type for .attach()");
1454
+ };
1455
+ if (Array.isArray(value)) {
1456
+ if (value.length === 0) throw new TypeException("Empty array provided to .attach() is not valid");
1457
+ for (const item of value) appendFile(item);
1458
+ } else appendFile(value);
1459
+ const files = formData.getAll(key);
1460
+ this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [key]: files.length === 1 ? files[0] : files });
1461
+ this.setTypeIfEmpty("form-data");
1462
+ return this;
1463
+ }
1464
+ /**
1465
+ *
1466
+ * @param retryTimes Max number of retries per call
1467
+ * @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)
1468
+ * @param retryCallback Will be called after request failed
1469
+ */
1470
+ retry(retryTimes, retryDelay = 0, retryOn = (attempt, error) => !!error) {
1471
+ this.option("retry", {
1472
+ times: retryTimes,
1473
+ delay: retryDelay,
1474
+ on: retryOn
1475
+ });
1476
+ return this;
1477
+ }
1478
+ redirect(mod) {
1479
+ this.requestInit.redirect = mod;
1480
+ return this;
1481
+ }
1482
+ credentials(mod) {
1483
+ this.requestInit.credentials = mod;
1484
+ return this;
1485
+ }
1486
+ mode(mod) {
1487
+ this.requestInit.mode = mod;
1488
+ return this;
1489
+ }
1490
+ flowControl(mode, arg2, arg3) {
1491
+ const concurrencyLimit = typeof arg2 === "number" ? arg2 : void 0;
1492
+ const sig = typeof arg2 === "function" || typeof arg2 === "string" ? arg2 : arg3 && (typeof arg3 === "function" || typeof arg3 === "string") ? arg3 : this.__locationId__;
1493
+ if (!sig) throw new Exception("please set signal to .flowControl()");
1494
+ const flowControl = {
1495
+ mode,
1496
+ concurrencyLimit,
1497
+ signal: sig
1498
+ };
1499
+ this.option("flowControl", flowControl);
1500
+ return this;
1501
+ }
1502
+ timeout(milliseconds) {
1503
+ this.option("timeout", { millisecond: milliseconds });
1504
+ return this;
1505
+ }
1506
+ resolveWith(m) {
1507
+ this.option("resolveWith", m);
1508
+ return this;
1509
+ }
1633
1510
  };
1634
-
1635
- // src/router/utils/compose-route.ts
1511
+ //#endregion
1512
+ //#region src/router/utils/compose-route.ts
1636
1513
  function composeRoute(routes) {
1637
- if (!routes.length) {
1638
- throw new Exception("At least one route");
1639
- }
1640
- return async (ctx) => {
1641
- const results = await Promise.all(routes.map((route) => route(ctx)));
1642
- return results.every((result) => result === true);
1643
- };
1514
+ if (!routes.length) throw new Exception("At least one route");
1515
+ return async (ctx) => {
1516
+ return (await Promise.all(routes.map((route) => route(ctx)))).every((result) => result === true);
1517
+ };
1644
1518
  }
1645
-
1646
- // src/router/keq-host-route.ts
1519
+ //#endregion
1520
+ //#region src/router/keq-host-route.ts
1647
1521
  function keqHostRoute(host) {
1648
- return (ctx) => ctx.request.url.host === host;
1522
+ return (ctx) => ctx.request.url.host === host;
1649
1523
  }
1650
-
1651
- // src/router/keq-location-route.ts
1524
+ //#endregion
1525
+ //#region src/router/keq-location-route.ts
1652
1526
  function keqLocationRoute() {
1653
- return (ctx) => Validator.isBrowser() && ctx.request.url.host === window.location.host;
1527
+ return (ctx) => Validator.isBrowser() && ctx.request.url.host === window.location.host;
1654
1528
  }
1655
-
1656
- // src/router/keq-method-route.ts
1529
+ //#endregion
1530
+ //#region src/router/keq-method-route.ts
1657
1531
  function keqMethodRoute(method) {
1658
- return (ctx) => ctx.request.method.toLowerCase() === method.toLowerCase();
1532
+ return (ctx) => ctx.request.method.toLowerCase() === method.toLowerCase();
1659
1533
  }
1660
-
1661
- // src/router/keq-module-route.ts
1662
- function keqModuleRoute(moduleName) {
1663
- if (!moduleName) {
1664
- throw new Exception("Module name should not be empty");
1665
- }
1666
- return (ctx) => {
1667
- var _a6;
1668
- return ((_a6 = ctx.options.module) == null ? void 0 : _a6.name) === moduleName;
1669
- };
1670
- }
1671
-
1672
- // src/router/keq-pathname-route.ts
1673
- var m = __toESM(require("minimatch"));
1534
+ //#endregion
1535
+ //#region src/router/keq-pathname-route.ts
1674
1536
  function keqPathnameRoute(pathname) {
1675
- return (ctx) => {
1676
- return m.minimatch(ctx.request.url.pathname, pathname);
1677
- };
1537
+ const isMatch = (0, picomatch.default)(pathname);
1538
+ return (ctx) => {
1539
+ return isMatch(ctx.request.url.pathname);
1540
+ };
1678
1541
  }
1679
-
1680
- // src/router/keq-router.ts
1681
- var KeqRouter = class _KeqRouter {
1682
- constructor(middlewares = []) {
1683
- this.middlewares = middlewares;
1684
- }
1685
- static buildMiddleware(route, middlewares) {
1686
- if (middlewares.length === 0) {
1687
- throw new TypeException("At least one middleware is required to build a route middleware");
1688
- }
1689
- const composedMiddleware = middlewares.length > 1 ? composeMiddleware(middlewares) : middlewares[0];
1690
- const middleware = async function router(ctx, next) {
1691
- if (route(ctx)) await composedMiddleware(ctx, next);
1692
- else await next();
1693
- };
1694
- return middleware;
1695
- }
1696
- route(route, middleware, ...additionalMiddlewares) {
1697
- const mid = _KeqRouter.route(route, middleware, ...additionalMiddlewares);
1698
- this.middlewares.push(mid);
1699
- return this;
1700
- }
1701
- host(host, middleware, ...additionalMiddlewares) {
1702
- const mid = _KeqRouter.host(host, middleware, ...additionalMiddlewares);
1703
- this.middlewares.push(mid);
1704
- return this;
1705
- }
1706
- method(method, middleware, ...additionalMiddlewares) {
1707
- const mid = _KeqRouter.method(method, middleware, ...additionalMiddlewares);
1708
- this.middlewares.push(mid);
1709
- return this;
1710
- }
1711
- pathname(pathname, middleware, ...additionalMiddlewares) {
1712
- const mid = _KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares);
1713
- this.middlewares.push(mid);
1714
- return this;
1715
- }
1716
- location(middleware, ...additionalMiddlewares) {
1717
- const mid = _KeqRouter.location(middleware, ...additionalMiddlewares);
1718
- this.middlewares.push(mid);
1719
- return this;
1720
- }
1721
- module(moduleName, middleware, ...additionalMiddlewares) {
1722
- const mid = _KeqRouter.module(moduleName, middleware, ...additionalMiddlewares);
1723
- this.middlewares.push(mid);
1724
- return this;
1725
- }
1726
- static route(route, middleware, ...additionalMiddlewares) {
1727
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1728
- const mid = _KeqRouter.buildMiddleware(route, list);
1729
- mid.__keqMiddlewareName__ = "route(".concat(route.__keqRouteName__ || route.name, ", ").concat(list.map(getMiddlewareName).join(", "), ")");
1730
- return mid;
1731
- }
1732
- static host(host, middleware, ...additionalMiddlewares) {
1733
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1734
- const mid = _KeqRouter.buildMiddleware(keqHostRoute(host), list);
1735
- mid.__keqMiddlewareName__ = "host(".concat(JSON.stringify(host), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
1736
- return mid;
1737
- }
1738
- static method(method, middleware, ...additionalMiddlewares) {
1739
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1740
- const mid = _KeqRouter.buildMiddleware(keqMethodRoute(method), list);
1741
- mid.__keqMiddlewareName__ = "method(".concat(JSON.stringify(method), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
1742
- return mid;
1743
- }
1744
- static pathname(pathname, middleware, ...additionalMiddlewares) {
1745
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1746
- const mid = _KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list);
1747
- mid.__keqMiddlewareName__ = "pathname(".concat(JSON.stringify(pathname), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
1748
- return mid;
1749
- }
1750
- static location(middleware, ...additionalMiddlewares) {
1751
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1752
- const mid = _KeqRouter.buildMiddleware(keqLocationRoute(), list);
1753
- mid.__keqMiddlewareName__ = "location(".concat(list.map(getMiddlewareName).join(", "), ")");
1754
- return mid;
1755
- }
1756
- static module(moduleName, middleware, ...additionalMiddlewares) {
1757
- const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1758
- const mid = _KeqRouter.buildMiddleware(keqModuleRoute(moduleName), list);
1759
- mid.__keqMiddlewareName__ = "module(".concat(JSON.stringify(moduleName), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
1760
- return mid;
1761
- }
1542
+ //#endregion
1543
+ //#region src/router/keq-router.ts
1544
+ var KeqRouter = class KeqRouter {
1545
+ constructor(middlewares = []) {
1546
+ this.middlewares = middlewares;
1547
+ }
1548
+ static buildMiddleware(route, middlewares) {
1549
+ if (middlewares.length === 0) throw new TypeException("At least one middleware is required to build a route middleware");
1550
+ const composedMiddleware = middlewares.length > 1 ? composeMiddleware(middlewares) : middlewares[0];
1551
+ return async function router(ctx, next) {
1552
+ if (route(ctx)) await composedMiddleware(ctx, next);
1553
+ else await next();
1554
+ };
1555
+ }
1556
+ route(route, middleware, ...additionalMiddlewares) {
1557
+ const mid = KeqRouter.route(route, middleware, ...additionalMiddlewares);
1558
+ this.middlewares.push(mid);
1559
+ return this;
1560
+ }
1561
+ host(host, middleware, ...additionalMiddlewares) {
1562
+ const mid = KeqRouter.host(host, middleware, ...additionalMiddlewares);
1563
+ this.middlewares.push(mid);
1564
+ return this;
1565
+ }
1566
+ method(method, middleware, ...additionalMiddlewares) {
1567
+ const mid = KeqRouter.method(method, middleware, ...additionalMiddlewares);
1568
+ this.middlewares.push(mid);
1569
+ return this;
1570
+ }
1571
+ pathname(pathname, middleware, ...additionalMiddlewares) {
1572
+ const mid = KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares);
1573
+ this.middlewares.push(mid);
1574
+ return this;
1575
+ }
1576
+ location(middleware, ...additionalMiddlewares) {
1577
+ const mid = KeqRouter.location(middleware, ...additionalMiddlewares);
1578
+ this.middlewares.push(mid);
1579
+ return this;
1580
+ }
1581
+ static route(route, middleware, ...additionalMiddlewares) {
1582
+ const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1583
+ const mid = KeqRouter.buildMiddleware(route, list);
1584
+ mid.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${list.map(getMiddlewareName).join(", ")})`;
1585
+ return mid;
1586
+ }
1587
+ static host(host, middleware, ...additionalMiddlewares) {
1588
+ const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1589
+ const mid = KeqRouter.buildMiddleware(keqHostRoute(host), list);
1590
+ mid.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${list.map(getMiddlewareName).join(", ")})`;
1591
+ return mid;
1592
+ }
1593
+ static method(method, middleware, ...additionalMiddlewares) {
1594
+ const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1595
+ const mid = KeqRouter.buildMiddleware(keqMethodRoute(method), list);
1596
+ mid.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${list.map(getMiddlewareName).join(", ")})`;
1597
+ return mid;
1598
+ }
1599
+ static pathname(pathname, middleware, ...additionalMiddlewares) {
1600
+ const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1601
+ const mid = KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list);
1602
+ mid.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${list.map(getMiddlewareName).join(", ")})`;
1603
+ return mid;
1604
+ }
1605
+ static location(middleware, ...additionalMiddlewares) {
1606
+ const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
1607
+ const mid = KeqRouter.buildMiddleware(keqLocationRoute(), list);
1608
+ mid.__keqMiddlewareName__ = `location(${list.map(getMiddlewareName).join(", ")})`;
1609
+ return mid;
1610
+ }
1762
1611
  };
1763
-
1764
- // src/middlewares/timeout-middleware/index.ts
1612
+ //#endregion
1613
+ //#region src/middlewares/timeout-middleware/index.ts
1765
1614
  function keqTimeoutMiddleware() {
1766
- return async function timeoutMiddleware(ctx, next) {
1767
- if (!ctx.options.timeout || ctx.options.timeout.millisecond <= 0) {
1768
- await next();
1769
- return;
1770
- }
1771
- const millisecond = ctx.options.timeout.millisecond;
1772
- ctx.emitter.on("fetch:after", ({ context }) => {
1773
- setTimeout(
1774
- () => {
1775
- const err = new TimeoutException("keq request timeout(".concat(millisecond, "ms)"));
1776
- context.request.abort(err);
1777
- context.emitter.emit("timeout", { context });
1778
- },
1779
- millisecond
1780
- );
1781
- });
1782
- await next();
1783
- };
1615
+ return async function timeoutMiddleware(ctx, next) {
1616
+ if (!ctx.options.timeout || ctx.options.timeout.millisecond <= 0) {
1617
+ await next();
1618
+ return;
1619
+ }
1620
+ const millisecond = ctx.options.timeout.millisecond;
1621
+ let timer;
1622
+ ctx.emitter.on("fetch:before", ({ context }) => {
1623
+ timer = setTimeout(() => {
1624
+ const err = new TimeoutException(`keq request timeout(${millisecond}ms)`);
1625
+ context.request.abort(err);
1626
+ context.emitter.emit("timeout", { context });
1627
+ }, millisecond);
1628
+ });
1629
+ ctx.emitter.on("fetch:after", () => {
1630
+ if (timer !== void 0) {
1631
+ clearTimeout(timer);
1632
+ timer = void 0;
1633
+ }
1634
+ });
1635
+ await next();
1636
+ };
1784
1637
  }
1785
-
1786
- // src/middlewares/flow-control-middleware/serial-flow-control-middleware.ts
1787
- var fastq = __toESM(require("fastq"));
1638
+ //#endregion
1639
+ //#region src/middlewares/flow-control-middleware/serial-flow-control-middleware.ts
1788
1640
  function keqSerialFlowControlMiddleware() {
1789
- return async function serialFlowControlMiddleware(ctx, next) {
1790
- if (!ctx.options.flowControl || !["serial", "concurrent"].includes(ctx.options.flowControl.mode)) {
1791
- await next();
1792
- return;
1793
- }
1794
- const { signal } = ctx.options.flowControl;
1795
- const concurrent = ctx.options.flowControl.mode === "serial" ? 1 : !ctx.options.flowControl.concurrencyLimit ? 1 : ctx.options.flowControl.concurrencyLimit < 1 ? 1 : parseInt(ctx.options.flowControl.concurrencyLimit, 10);
1796
- const key = typeof signal === "string" ? signal : signal(ctx);
1797
- if (!ctx.global.serialFlowControl) ctx.global.serialFlowControl = {};
1798
- if (!ctx.global.serialFlowControl[key]) {
1799
- ctx.global.serialFlowControl[key] = fastq.promise(async (next2) => {
1800
- await next2();
1801
- }, concurrent);
1802
- }
1803
- const queue = ctx.global.serialFlowControl[key];
1804
- await queue.push(next);
1805
- };
1641
+ return async function serialFlowControlMiddleware(ctx, next) {
1642
+ if (!ctx.options.flowControl || !["serial", "concurrent"].includes(ctx.options.flowControl.mode)) {
1643
+ await next();
1644
+ return;
1645
+ }
1646
+ const { signal } = ctx.options.flowControl;
1647
+ const concurrent = ctx.options.flowControl.mode === "serial" ? 1 : !ctx.options.flowControl.concurrencyLimit || ctx.options.flowControl.concurrencyLimit < 1 ? 1 : Math.floor(ctx.options.flowControl.concurrencyLimit);
1648
+ const key = typeof signal === "string" ? signal : signal(ctx);
1649
+ if (!ctx.global.core) ctx.global.core = {};
1650
+ if (!ctx.global.core.serialFlowControl) ctx.global.core.serialFlowControl = {};
1651
+ if (!ctx.global.core.serialFlowControl[key]) ctx.global.core.serialFlowControl[key] = fastq.promise(async ({ next }) => {
1652
+ await next();
1653
+ }, concurrent);
1654
+ await ctx.global.core.serialFlowControl[key].push({ next });
1655
+ };
1806
1656
  }
1807
-
1808
- // src/middlewares/flow-control-middleware/abort-flow-control-middleware.ts
1657
+ //#endregion
1658
+ //#region src/middlewares/flow-control-middleware/abort-flow-control-middleware.ts
1809
1659
  function keqAbortFlowControlMiddleware() {
1810
- return async function abortFlowControlMiddleware(ctx, next) {
1811
- if (!ctx.options.flowControl || ctx.options.flowControl.mode !== "abort") {
1812
- await next();
1813
- return;
1814
- }
1815
- const { signal } = ctx.options.flowControl;
1816
- const key = typeof signal === "string" ? signal : signal(ctx);
1817
- if (!ctx.global.abortFlowControl) ctx.global.abortFlowControl = {};
1818
- const abort = ctx.global.abortFlowControl[key];
1819
- if (abort) {
1820
- const reason = new AbortException('Previous request was aborted by AbortFlowControl with key "'.concat(key, '"'));
1821
- abort(reason);
1822
- }
1823
- const fn = ctx.request.abort.bind(ctx.request);
1824
- ctx.global.abortFlowControl[key] = fn;
1825
- try {
1826
- await next();
1827
- } finally {
1828
- if (ctx.global.abortFlowControl[key] === fn) {
1829
- ctx.global.abortFlowControl[key] = void 0;
1830
- }
1831
- }
1832
- };
1660
+ return async function abortFlowControlMiddleware(ctx, next) {
1661
+ if (!ctx.options.flowControl || ctx.options.flowControl.mode !== "abort") {
1662
+ await next();
1663
+ return;
1664
+ }
1665
+ const { signal } = ctx.options.flowControl;
1666
+ const key = typeof signal === "string" ? signal : signal(ctx);
1667
+ if (!ctx.global.core) ctx.global.core = {};
1668
+ if (!ctx.global.core.abortFlowControl) ctx.global.core.abortFlowControl = {};
1669
+ const abort = ctx.global.core.abortFlowControl[key];
1670
+ if (abort) abort(new AbortException(`Previous request was aborted by AbortFlowControl with key "${key}"`));
1671
+ const fn = ctx.request.abort.bind(ctx.request);
1672
+ ctx.global.core.abortFlowControl[key] = fn;
1673
+ try {
1674
+ await next();
1675
+ } finally {
1676
+ if (ctx.global.core.abortFlowControl[key] === fn) ctx.global.core.abortFlowControl[key] = void 0;
1677
+ }
1678
+ };
1833
1679
  }
1834
-
1835
- // src/middlewares/flow-control-middleware/index.ts
1680
+ //#endregion
1681
+ //#region src/middlewares/flow-control-middleware/mutex-flow-control-middleware.ts
1682
+ function keqMutexFlowControlMiddleware() {
1683
+ return async function mutexFlowControlMiddleware(ctx, next) {
1684
+ if (!ctx.options.flowControl || ctx.options.flowControl.mode !== "mutex") {
1685
+ await next();
1686
+ return;
1687
+ }
1688
+ const { signal } = ctx.options.flowControl;
1689
+ const key = typeof signal === "string" ? signal : signal(ctx);
1690
+ if (!ctx.global.core) ctx.global.core = {};
1691
+ if (!ctx.global.core.mutexFlowControl) ctx.global.core.mutexFlowControl = /* @__PURE__ */ new Set();
1692
+ if (ctx.global.core.mutexFlowControl.has(key)) throw new MutexException(`Request rejected by MutexFlowControl: a request with key "${key}" is already in-flight`);
1693
+ ctx.global.core.mutexFlowControl.add(key);
1694
+ try {
1695
+ await next();
1696
+ } finally {
1697
+ ctx.global.core.mutexFlowControl.delete(key);
1698
+ }
1699
+ };
1700
+ }
1701
+ //#endregion
1702
+ //#region src/middlewares/flow-control-middleware/index.ts
1836
1703
  function keqFlowControlMiddleware() {
1837
- return composeMiddleware(
1838
- [keqSerialFlowControlMiddleware(), keqAbortFlowControlMiddleware()],
1839
- { name: "flowControlMiddleware" }
1840
- );
1704
+ return composeMiddleware([
1705
+ keqMutexFlowControlMiddleware(),
1706
+ keqSerialFlowControlMiddleware(),
1707
+ keqAbortFlowControlMiddleware()
1708
+ ], { name: "flowControlMiddleware" });
1841
1709
  }
1842
-
1843
- // src/middlewares/fetch-middleware/index.ts
1710
+ //#endregion
1711
+ //#region src/middlewares/fetch-middleware/index.ts
1712
+ /**
1713
+ * Send Request
1714
+ */
1844
1715
  function keqFetchMiddleware() {
1845
- return async function fetchMiddleware(context) {
1846
- const fetch = context.options.fetchAPI || globalThis.fetch;
1847
- context.emitter.emit("fetch:before", { context });
1848
- const response = await fetch(...context.request.toFetchArguments());
1849
- context.emitter.emit("fetch:after", { context });
1850
- context.res = response;
1851
- };
1716
+ return async function fetchMiddleware(context) {
1717
+ const fetch = context.options.fetchAPI || globalThis.fetch;
1718
+ context.emitter.emit("fetch:before", { context });
1719
+ const response = await fetch(...context.request.toFetchArguments());
1720
+ context.emitter.emit("fetch:after", { context });
1721
+ context.res = response;
1722
+ };
1852
1723
  }
1853
-
1854
- // src/request/request.ts
1855
- var KeqRequest = class {
1856
- constructor(options) {
1857
- __publicField(this, "baseOrigin");
1858
- __publicField(this, "qs");
1859
- /**
1860
- * share data between requests, used to implement flowControl
1861
- * @description 跨请求共享数据,用于实现 flowControl的功能
1862
- */
1863
- __publicField(this, "global", {});
1864
- __publicField(this, "preMiddlewares", []);
1865
- __publicField(this, "postMiddlewares", []);
1866
- if (options == null ? void 0 : options.baseOrigin) {
1867
- this.baseOrigin = options.baseOrigin;
1868
- } else {
1869
- this.baseOrigin = Validator.isBrowser() ? location.origin : "http://127.0.0.1";
1870
- }
1871
- this.qs = options == null ? void 0 : options.qs;
1872
- this.postMiddlewares = (options == null ? void 0 : options.postMiddlewares) || [
1873
- keqFlowControlMiddleware(),
1874
- keqTimeoutMiddleware(),
1875
- keqFetchMiddleware()
1876
- ];
1877
- this.preMiddlewares = (options == null ? void 0 : options.preMiddlewares) || [];
1878
- }
1879
- __formatUrl__(url) {
1880
- if (typeof url === "string") {
1881
- return new URL(url, this.baseOrigin);
1882
- }
1883
- return new URL(url.href);
1884
- }
1885
- __fetch__(url, init, locationId) {
1886
- const keq = new Keq(this.__formatUrl__(url), { ...init, locationId, global: this.global, qs: this.qs });
1887
- keq.appendMiddlewares(...this.postMiddlewares);
1888
- keq.prependMiddlewares(...this.preMiddlewares);
1889
- return keq;
1890
- }
1891
- fetch(url, init) {
1892
- return this.__fetch__(
1893
- url,
1894
- init,
1895
- getLocationId(1)
1896
- );
1897
- }
1898
- get(url) {
1899
- return this.__fetch__(
1900
- url,
1901
- { method: "get" },
1902
- getLocationId(1)
1903
- );
1904
- }
1905
- put(url) {
1906
- const locationId = getLocationId(1);
1907
- const keq = new Keq(
1908
- this.__formatUrl__(url),
1909
- {
1910
- method: "put",
1911
- locationId,
1912
- global: this.global
1913
- }
1914
- );
1915
- keq.appendMiddlewares(...this.postMiddlewares);
1916
- keq.prependMiddlewares(...this.preMiddlewares);
1917
- return keq;
1918
- }
1919
- delete(url) {
1920
- return this.__fetch__(
1921
- url,
1922
- { method: "delete" },
1923
- getLocationId(1)
1924
- );
1925
- }
1926
- del(url) {
1927
- return this.delete(url);
1928
- }
1929
- post(url) {
1930
- return this.__fetch__(
1931
- url,
1932
- { method: "post" },
1933
- getLocationId(1)
1934
- );
1935
- }
1936
- head(url) {
1937
- return this.__fetch__(
1938
- url,
1939
- { method: "head" },
1940
- getLocationId(1)
1941
- );
1942
- }
1943
- patch(url) {
1944
- return this.__fetch__(
1945
- url,
1946
- { method: "patch" },
1947
- getLocationId(1)
1948
- );
1949
- }
1950
- options(url) {
1951
- return this.__fetch__(
1952
- url,
1953
- { method: "options" },
1954
- getLocationId(1)
1955
- );
1956
- }
1957
- use(firstMiddleware, ...middleware) {
1958
- this.preMiddlewares.push(firstMiddleware, ...middleware);
1959
- return this;
1960
- }
1961
- useRouter() {
1962
- return new KeqRouter(this.preMiddlewares);
1963
- }
1964
- on(event, listener) {
1965
- const middleware = async (context, next) => {
1966
- context.emitter.on(event, listener);
1967
- await next();
1968
- };
1969
- this.use(middleware);
1970
- return this;
1971
- }
1724
+ //#endregion
1725
+ //#region src/request/request.ts
1726
+ /**
1727
+ * Keq instance factory class,
1728
+ * and shares global data and middlewares across requests
1729
+ */
1730
+ var KeqRequest = class KeqRequest {
1731
+ constructor(options) {
1732
+ _defineProperty(this, "baseOrigin", void 0);
1733
+ _defineProperty(this, "qs", void 0);
1734
+ _defineProperty(this, "global", {});
1735
+ _defineProperty(this, "middlewares", []);
1736
+ _defineProperty(this, "__terminalMiddlewares__", []);
1737
+ _defineProperty(this, "__parent__", void 0);
1738
+ if (options?.baseOrigin) this.baseOrigin = options.baseOrigin;
1739
+ else this.baseOrigin = Validator.isBrowser() ? location.origin : "http://127.0.0.1";
1740
+ this.qs = options?.qs;
1741
+ this.__terminalMiddlewares__ = options?.terminalMiddlewares || [
1742
+ keqFlowControlMiddleware(),
1743
+ keqTimeoutMiddleware(),
1744
+ keqFetchMiddleware()
1745
+ ];
1746
+ this.middlewares = options?.middlewares || [];
1747
+ }
1748
+ __formatUrl__(url) {
1749
+ if (typeof url === "string") return new URL(url, this.baseOrigin);
1750
+ return new URL(url.href);
1751
+ }
1752
+ resolveMiddlewares() {
1753
+ if (!this.__parent__) return this.middlewares;
1754
+ return [...this.__parent__.resolveMiddlewares(), ...this.middlewares];
1755
+ }
1756
+ __fetch__(url, init, locationId) {
1757
+ return new Keq(this.__formatUrl__(url), {
1758
+ ...init,
1759
+ locationId,
1760
+ global: this.global,
1761
+ qs: this.qs,
1762
+ middlewares: [...this.resolveMiddlewares(), ...this.__terminalMiddlewares__]
1763
+ });
1764
+ }
1765
+ fetch(url, init) {
1766
+ return this.__fetch__(url, init, getLocationId(1));
1767
+ }
1768
+ get(url) {
1769
+ return this.__fetch__(url, { method: "get" }, getLocationId(1));
1770
+ }
1771
+ put(url) {
1772
+ return this.__fetch__(url, { method: "put" }, getLocationId(1));
1773
+ }
1774
+ delete(url) {
1775
+ return this.__fetch__(url, { method: "delete" }, getLocationId(1));
1776
+ }
1777
+ del(url) {
1778
+ return this.delete(url);
1779
+ }
1780
+ post(url) {
1781
+ return this.__fetch__(url, { method: "post" }, getLocationId(1));
1782
+ }
1783
+ head(url) {
1784
+ return this.__fetch__(url, { method: "head" }, getLocationId(1));
1785
+ }
1786
+ patch(url) {
1787
+ return this.__fetch__(url, { method: "patch" }, getLocationId(1));
1788
+ }
1789
+ options(url) {
1790
+ return this.__fetch__(url, { method: "options" }, getLocationId(1));
1791
+ }
1792
+ use(firstMiddleware, ...middleware) {
1793
+ this.middlewares.push(firstMiddleware, ...middleware);
1794
+ return this;
1795
+ }
1796
+ useRouter() {
1797
+ return new KeqRouter(this.middlewares);
1798
+ }
1799
+ fork(options) {
1800
+ const child = new KeqRequest({
1801
+ baseOrigin: options?.baseOrigin ?? this.baseOrigin,
1802
+ qs: options?.qs ?? (this.qs ? { ...this.qs } : void 0)
1803
+ });
1804
+ child.__parent__ = this;
1805
+ return child;
1806
+ }
1807
+ inherit(parent) {
1808
+ this.__parent__ = parent;
1809
+ return this;
1810
+ }
1811
+ adopt(child) {
1812
+ child.__parent__ = this;
1813
+ return this;
1814
+ }
1815
+ /** @deprecated Use `middlewares` instead */
1816
+ get preMiddlewares() {
1817
+ return this.middlewares;
1818
+ }
1819
+ on(event, listener) {
1820
+ const middleware = async (context, next) => {
1821
+ context.emitter.on(event, listener);
1822
+ await next();
1823
+ };
1824
+ middleware.__keqMiddlewareName__ = `listen(${event}, ${listener.name || "anonymous"})`;
1825
+ this.use(middleware);
1826
+ return this;
1827
+ }
1972
1828
  };
1973
- var request = new KeqRequest();
1974
-
1975
- // src/request/create-request.ts
1829
+ const request = new KeqRequest();
1830
+ //#endregion
1831
+ //#region src/request/create-request.ts
1832
+ /**
1833
+ * @deprecated use new KeqRequest<SCHEMA>(options) instead
1834
+ */
1976
1835
  function createRequest(options) {
1977
- return new KeqRequest(options);
1836
+ return new KeqRequest(options);
1978
1837
  }
1838
+ //#endregion
1839
+ exports.AbortException = AbortException;
1840
+ exports.BadGatewayException = BadGatewayException;
1841
+ exports.BadRequestException = BadRequestException;
1842
+ exports.ConflictException = ConflictException;
1843
+ exports.ContentTooLargeException = ContentTooLargeException;
1844
+ exports.Exception = Exception;
1845
+ exports.ForbiddenException = ForbiddenException;
1846
+ exports.GatewayTimeoutException = GatewayTimeoutException;
1847
+ exports.ImATeapotException = ImATeapotException;
1848
+ exports.InternalServerErrorException = InternalServerErrorException;
1849
+ exports.Keq = Keq;
1850
+ exports.KeqExecutionContext = KeqExecutionContext;
1851
+ exports.KeqMiddlewareExecutor = KeqMiddlewareExecutor;
1852
+ exports.KeqMiddlewareOrchestrator = KeqMiddlewareOrchestrator;
1853
+ exports.KeqRequest = KeqRequest;
1854
+ exports.KeqSharedContext = KeqSharedContext;
1855
+ exports.MethodNotAllowedException = MethodNotAllowedException;
1856
+ exports.NotAcceptableException = NotAcceptableException;
1857
+ exports.NotFoundedException = NotFoundedException;
1858
+ exports.NotImplementedException = NotImplementedException;
1859
+ exports.PreconditionFailedException = PreconditionFailedException;
1860
+ exports.ProxyAuthenticationRequiredException = ProxyAuthenticationRequiredException;
1861
+ exports.RequestException = RequestException;
1862
+ exports.RequestTimeoutException = RequestTimeoutException;
1863
+ exports.ServiceUnavailableException = ServiceUnavailableException;
1864
+ exports.TimeoutException = TimeoutException;
1865
+ exports.TooManyRequestsException = TooManyRequestsException;
1866
+ exports.TypeException = TypeException;
1867
+ exports.UnauthorizedException = UnauthorizedException;
1868
+ exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException;
1869
+ exports.UriTooLongException = UriTooLongException;
1870
+ exports.composeMiddleware = composeMiddleware;
1871
+ exports.composeRoute = composeRoute;
1872
+ exports.createProxyResponse = createProxyResponse;
1873
+ exports.createRequest = createRequest;
1874
+ exports.request = request;
1875
+
1979
1876
  //# sourceMappingURL=index.js.map