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