keq 2.8.13 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (842) hide show
  1. package/.claude/settings.local.json +26 -0
  2. package/CHANGELOG.md +14 -0
  3. package/dist/esm/src/create-request.js +2 -0
  4. package/dist/esm/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
  5. package/dist/esm/src/middlewares/mutex-flow-control-middleware.js +22 -0
  6. package/dist/esm/src/types/keq-flow-control.d.ts +1 -1
  7. package/dist/esm/src/types/keq-global.d.ts +1 -0
  8. package/dist/esm/src/util/create-response-proxy.js +2 -2
  9. package/dist/esm/src/util/fork.js +3 -3
  10. package/dist/umd/src/create-request.js +3 -1
  11. package/dist/umd/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
  12. package/dist/umd/src/middlewares/mutex-flow-control-middleware.js +36 -0
  13. package/dist/umd/src/types/keq-flow-control.d.ts +1 -1
  14. package/dist/umd/src/types/keq-global.d.ts +1 -0
  15. package/dist/umd/src/util/create-response-proxy.js +2 -2
  16. package/dist/umd/src/util/fork.js +3 -3
  17. package/package.json +1 -1
  18. package/packages/cache/.turbo/turbo-build.log +26 -16
  19. package/packages/cache/dist/index.d.mts +354 -0
  20. package/packages/cache/dist/index.d.mts.map +1 -0
  21. package/packages/cache/dist/index.d.ts +352 -5
  22. package/packages/cache/dist/index.d.ts.map +1 -1
  23. package/packages/cache/dist/index.js +1211 -1256
  24. package/packages/cache/dist/index.js.map +1 -1
  25. package/packages/cache/dist/index.mjs +1183 -1231
  26. package/packages/cache/dist/index.mjs.map +1 -1
  27. package/packages/cli/.turbo/turbo-build.log +88 -24
  28. package/packages/cli/dist/cli.cjs +1333 -2891
  29. package/packages/cli/dist/cli.cjs.map +1 -1
  30. package/packages/cli/dist/cli.d.cts +1 -0
  31. package/packages/cli/dist/cli.d.mts +1 -0
  32. package/packages/cli/dist/cli.mjs +1359 -0
  33. package/packages/cli/dist/cli.mjs.map +1 -0
  34. package/packages/cli/dist/compiler-0Kli6UCr.cjs +738 -0
  35. package/packages/cli/dist/compiler-0Kli6UCr.cjs.map +1 -0
  36. package/packages/cli/dist/compiler-C3AE8j54.mjs +715 -0
  37. package/packages/cli/dist/compiler-C3AE8j54.mjs.map +1 -0
  38. package/packages/cli/dist/index.cjs +18 -2853
  39. package/packages/cli/dist/index.cjs.map +1 -1
  40. package/packages/cli/dist/index.d.cts +17 -0
  41. package/packages/cli/dist/index.d.cts.map +1 -0
  42. package/packages/cli/dist/index.d.mts +17 -0
  43. package/packages/cli/dist/index.d.mts.map +1 -0
  44. package/packages/cli/dist/index.mjs +10 -0
  45. package/packages/cli/dist/index.mjs.map +1 -0
  46. package/packages/cli/dist/init-BNhD2oCI.mjs +168 -0
  47. package/packages/cli/dist/init-BNhD2oCI.mjs.map +1 -0
  48. package/packages/cli/dist/init-DqxLcRSQ.cjs +170 -0
  49. package/packages/cli/dist/init-DqxLcRSQ.cjs.map +1 -0
  50. package/packages/cli/dist/logger-D7PyVZo3.cjs +46 -0
  51. package/packages/cli/dist/logger-D7PyVZo3.cjs.map +1 -0
  52. package/packages/cli/dist/logger-QLBHySQ3.mjs +12 -0
  53. package/packages/cli/dist/logger-QLBHySQ3.mjs.map +1 -0
  54. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs +16 -0
  55. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs.map +1 -0
  56. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs +11 -0
  57. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs.map +1 -0
  58. package/packages/cli/dist/mock-command-Bp1LxSls.mjs +350 -0
  59. package/packages/cli/dist/mock-command-Bp1LxSls.mjs.map +1 -0
  60. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs +353 -0
  61. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs.map +1 -0
  62. package/packages/cli/dist/plugins-CgMhaNZq.cjs +3558 -0
  63. package/packages/cli/dist/plugins-CgMhaNZq.cjs.map +1 -0
  64. package/packages/cli/dist/plugins-DCvJ8iHR.mjs +3280 -0
  65. package/packages/cli/dist/plugins-DCvJ8iHR.mjs.map +1 -0
  66. package/packages/cli/dist/plugins.cjs +36 -2425
  67. package/packages/cli/dist/plugins.d.cts +2 -0
  68. package/packages/cli/dist/plugins.d.mts +2 -0
  69. package/packages/cli/dist/plugins.mjs +2 -0
  70. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts +780 -0
  71. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts.map +1 -0
  72. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts +780 -0
  73. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts.map +1 -0
  74. package/packages/cli/dist/translators.cjs +14 -0
  75. package/packages/cli/dist/translators.cjs.map +1 -0
  76. package/packages/cli/dist/translators.d.cts +14 -0
  77. package/packages/cli/dist/translators.d.cts.map +1 -0
  78. package/packages/cli/dist/translators.d.mts +14 -0
  79. package/packages/cli/dist/translators.d.mts.map +1 -0
  80. package/packages/cli/dist/translators.mjs +12 -0
  81. package/packages/cli/dist/translators.mjs.map +1 -0
  82. package/packages/cli/node_modules/.bin/eslint +2 -2
  83. package/packages/cli/node_modules/.bin/jiti +2 -2
  84. package/packages/cli/node_modules/.bin/js-yaml +2 -2
  85. package/packages/cli/node_modules/.bin/jsf +21 -0
  86. package/packages/cli/node_modules/.bin/jsonpath +2 -2
  87. package/packages/cli/node_modules/.bin/jsonpath-plus +2 -2
  88. package/packages/cli/node_modules/.bin/semver +2 -2
  89. package/packages/cli/node_modules/.bin/tsc +4 -4
  90. package/packages/cli/node_modules/.bin/tsserver +4 -4
  91. package/packages/exception/.turbo/turbo-build.log +26 -31
  92. package/packages/exception/dist/index.d.mts +21 -0
  93. package/packages/exception/dist/index.d.mts.map +1 -0
  94. package/packages/exception/dist/index.d.ts +21 -0
  95. package/packages/exception/dist/index.d.ts.map +1 -0
  96. package/packages/exception/dist/index.js +97 -105
  97. package/packages/exception/dist/index.js.map +1 -1
  98. package/packages/exception/dist/index.mjs +92 -104
  99. package/packages/exception/dist/index.mjs.map +1 -1
  100. package/packages/headers/.turbo/turbo-build.log +26 -16
  101. package/packages/headers/dist/index.d.mts +46 -0
  102. package/packages/headers/dist/index.d.mts.map +1 -0
  103. package/packages/headers/dist/index.d.ts +46 -0
  104. package/packages/headers/dist/index.d.ts.map +1 -0
  105. package/packages/headers/dist/index.js +68 -64
  106. package/packages/headers/dist/index.js.map +1 -1
  107. package/packages/headers/dist/index.mjs +62 -43
  108. package/packages/headers/dist/index.mjs.map +1 -1
  109. package/packages/keq/.turbo/turbo-build.log +26 -16
  110. package/packages/keq/dist/index.d.mts +962 -0
  111. package/packages/keq/dist/index.d.mts.map +1 -0
  112. package/packages/keq/dist/index.d.ts +961 -7
  113. package/packages/keq/dist/index.d.ts.map +1 -1
  114. package/packages/keq/dist/index.js +1727 -1830
  115. package/packages/keq/dist/index.js.map +1 -1
  116. package/packages/keq/dist/index.mjs +1671 -1805
  117. package/packages/keq/dist/index.mjs.map +1 -1
  118. package/packages/nestjs/.turbo/turbo-build.log +26 -16
  119. package/packages/nestjs/dist/index.d.mts +52 -0
  120. package/packages/nestjs/dist/index.d.mts.map +1 -0
  121. package/packages/nestjs/dist/index.d.ts +51 -2
  122. package/packages/nestjs/dist/index.d.ts.map +1 -1
  123. package/packages/nestjs/dist/index.js +156 -60
  124. package/packages/nestjs/dist/index.js.map +1 -1
  125. package/packages/nestjs/dist/index.mjs +133 -42
  126. package/packages/nestjs/dist/index.mjs.map +1 -1
  127. package/packages/test/.turbo/turbo-build.log +1 -1
  128. package/packages/url/.turbo/turbo-build.log +26 -16
  129. package/packages/url/dist/index.d.mts +9 -0
  130. package/packages/url/dist/index.d.mts.map +1 -0
  131. package/packages/url/dist/index.d.ts +9 -0
  132. package/packages/url/dist/index.d.ts.map +1 -0
  133. package/packages/url/dist/index.js +36 -60
  134. package/packages/url/dist/index.js.map +1 -1
  135. package/packages/url/dist/index.mjs +33 -39
  136. package/packages/url/dist/index.mjs.map +1 -1
  137. package/packages/cache/dist/cache-entry/cache-entry.d.ts +0 -17
  138. package/packages/cache/dist/cache-entry/cache-entry.d.ts.map +0 -1
  139. package/packages/cache/dist/cache-entry/index.d.ts +0 -4
  140. package/packages/cache/dist/cache-entry/index.d.ts.map +0 -1
  141. package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts +0 -8
  142. package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts.map +0 -1
  143. package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts +0 -7
  144. package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts.map +0 -1
  145. package/packages/cache/dist/cache.d.ts +0 -38
  146. package/packages/cache/dist/cache.d.ts.map +0 -1
  147. package/packages/cache/dist/constants/eviction.enum.d.ts +0 -7
  148. package/packages/cache/dist/constants/eviction.enum.d.ts.map +0 -1
  149. package/packages/cache/dist/constants/index.d.ts +0 -5
  150. package/packages/cache/dist/constants/index.d.ts.map +0 -1
  151. package/packages/cache/dist/constants/max-expired-at.d.ts +0 -2
  152. package/packages/cache/dist/constants/max-expired-at.d.ts.map +0 -1
  153. package/packages/cache/dist/constants/size.enum.d.ts +0 -7
  154. package/packages/cache/dist/constants/size.enum.d.ts.map +0 -1
  155. package/packages/cache/dist/constants/strategy.enum.d.ts +0 -7
  156. package/packages/cache/dist/constants/strategy.enum.d.ts.map +0 -1
  157. package/packages/cache/dist/exceptions/cache-exception.d.ts +0 -5
  158. package/packages/cache/dist/exceptions/cache-exception.d.ts.map +0 -1
  159. package/packages/cache/dist/exceptions/index.d.ts +0 -2
  160. package/packages/cache/dist/exceptions/index.d.ts.map +0 -1
  161. package/packages/cache/dist/request-cache-handler/index.d.ts +0 -2
  162. package/packages/cache/dist/request-cache-handler/index.d.ts.map +0 -1
  163. package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts +0 -23
  164. package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts.map +0 -1
  165. package/packages/cache/dist/storage/index.d.ts +0 -6
  166. package/packages/cache/dist/storage/index.d.ts.map +0 -1
  167. package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts +0 -22
  168. package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts.map +0 -1
  169. package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts +0 -2
  170. package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts.map +0 -1
  171. package/packages/cache/dist/storage/indexed-db-storage/index.d.ts +0 -3
  172. package/packages/cache/dist/storage/indexed-db-storage/index.d.ts.map +0 -1
  173. package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts +0 -12
  174. package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts.map +0 -1
  175. package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts +0 -11
  176. package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts.map +0 -1
  177. package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts +0 -11
  178. package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts.map +0 -1
  179. package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts +0 -11
  180. package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts.map +0 -1
  181. package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts +0 -11
  182. package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts.map +0 -1
  183. package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts +0 -7
  184. package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts.map +0 -1
  185. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts +0 -12
  186. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts.map +0 -1
  187. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts +0 -8
  188. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts.map +0 -1
  189. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts +0 -14
  190. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts.map +0 -1
  191. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts +0 -29
  192. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts.map +0 -1
  193. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts +0 -14
  194. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts.map +0 -1
  195. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts +0 -13
  196. package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts.map +0 -1
  197. package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts +0 -16
  198. package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts.map +0 -1
  199. package/packages/cache/dist/storage/internal-storage/types/events.d.ts +0 -16
  200. package/packages/cache/dist/storage/internal-storage/types/events.d.ts.map +0 -1
  201. package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts +0 -20
  202. package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts.map +0 -1
  203. package/packages/cache/dist/storage/keq-cache-storage.d.ts +0 -20
  204. package/packages/cache/dist/storage/keq-cache-storage.d.ts.map +0 -1
  205. package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts +0 -31
  206. package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts.map +0 -1
  207. package/packages/cache/dist/storage/memory-storage/index.d.ts +0 -3
  208. package/packages/cache/dist/storage/memory-storage/index.d.ts.map +0 -1
  209. package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts +0 -11
  210. package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts.map +0 -1
  211. package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts +0 -11
  212. package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts.map +0 -1
  213. package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts +0 -13
  214. package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts.map +0 -1
  215. package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts +0 -11
  216. package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts.map +0 -1
  217. package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts +0 -11
  218. package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts.map +0 -1
  219. package/packages/cache/dist/storage/memory-storage/types/index.d.ts +0 -3
  220. package/packages/cache/dist/storage/memory-storage/types/index.d.ts.map +0 -1
  221. package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts +0 -9
  222. package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts.map +0 -1
  223. package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts +0 -13
  224. package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts.map +0 -1
  225. package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts +0 -6
  226. package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts.map +0 -1
  227. package/packages/cache/dist/storage/memory-storage/utils/index.d.ts +0 -3
  228. package/packages/cache/dist/storage/memory-storage/utils/index.d.ts.map +0 -1
  229. package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts +0 -6
  230. package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts.map +0 -1
  231. package/packages/cache/dist/storage/multi-tier-storage/index.d.ts +0 -3
  232. package/packages/cache/dist/storage/multi-tier-storage/index.d.ts.map +0 -1
  233. package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts +0 -36
  234. package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts.map +0 -1
  235. package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts +0 -2
  236. package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts.map +0 -1
  237. package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts +0 -5
  238. package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts.map +0 -1
  239. package/packages/cache/dist/storage/tier-storage/index.d.ts +0 -3
  240. package/packages/cache/dist/storage/tier-storage/index.d.ts.map +0 -1
  241. package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts +0 -15
  242. package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts.map +0 -1
  243. package/packages/cache/dist/storage/tier-storage/types/index.d.ts +0 -2
  244. package/packages/cache/dist/storage/tier-storage/types/index.d.ts.map +0 -1
  245. package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts +0 -21
  246. package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts.map +0 -1
  247. package/packages/cache/dist/strategies/cache-first.d.ts +0 -3
  248. package/packages/cache/dist/strategies/cache-first.d.ts.map +0 -1
  249. package/packages/cache/dist/strategies/index.d.ts +0 -5
  250. package/packages/cache/dist/strategies/index.d.ts.map +0 -1
  251. package/packages/cache/dist/strategies/network-first.d.ts +0 -3
  252. package/packages/cache/dist/strategies/network-first.d.ts.map +0 -1
  253. package/packages/cache/dist/strategies/network-only.d.ts +0 -3
  254. package/packages/cache/dist/strategies/network-only.d.ts.map +0 -1
  255. package/packages/cache/dist/strategies/stale-while-revalidate.d.ts +0 -3
  256. package/packages/cache/dist/strategies/stale-while-revalidate.d.ts.map +0 -1
  257. package/packages/cache/dist/types/index.d.ts +0 -6
  258. package/packages/cache/dist/types/index.d.ts.map +0 -1
  259. package/packages/cache/dist/types/keq-cache-key.d.ts +0 -4
  260. package/packages/cache/dist/types/keq-cache-key.d.ts.map +0 -1
  261. package/packages/cache/dist/types/keq-cache-pattern.d.ts +0 -3
  262. package/packages/cache/dist/types/keq-cache-pattern.d.ts.map +0 -1
  263. package/packages/cache/dist/types/keq-cache-rule.d.ts +0 -6
  264. package/packages/cache/dist/types/keq-cache-rule.d.ts.map +0 -1
  265. package/packages/cache/dist/types/keq-cache-strategy.d.ts +0 -6
  266. package/packages/cache/dist/types/keq-cache-strategy.d.ts.map +0 -1
  267. package/packages/cache/dist/types/request-cache-options.d.ts +0 -34
  268. package/packages/cache/dist/types/request-cache-options.d.ts.map +0 -1
  269. package/packages/cache/dist/utils/get-response-bytes.d.ts +0 -2
  270. package/packages/cache/dist/utils/get-response-bytes.d.ts.map +0 -1
  271. package/packages/cache/dist/utils/index.d.ts +0 -4
  272. package/packages/cache/dist/utils/index.d.ts.map +0 -1
  273. package/packages/cache/dist/utils/logger.d.ts +0 -5
  274. package/packages/cache/dist/utils/logger.d.ts.map +0 -1
  275. package/packages/cache/dist/utils/random.d.ts +0 -2
  276. package/packages/cache/dist/utils/random.d.ts.map +0 -1
  277. package/packages/cli/dist/cli.d.ts +0 -3
  278. package/packages/cli/dist/cli.d.ts.map +0 -1
  279. package/packages/cli/dist/cli.js +0 -2899
  280. package/packages/cli/dist/cli.js.map +0 -1
  281. package/packages/cli/dist/compiler/compiler.d.ts +0 -17
  282. package/packages/cli/dist/compiler/compiler.d.ts.map +0 -1
  283. package/packages/cli/dist/compiler/index.d.ts +0 -4
  284. package/packages/cli/dist/compiler/index.d.ts.map +0 -1
  285. package/packages/cli/dist/compiler/intercepter/index.d.ts +0 -3
  286. package/packages/cli/dist/compiler/intercepter/index.d.ts.map +0 -1
  287. package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts +0 -3
  288. package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts.map +0 -1
  289. package/packages/cli/dist/compiler/intercepter/print-information.d.ts +0 -5
  290. package/packages/cli/dist/compiler/intercepter/print-information.d.ts.map +0 -1
  291. package/packages/cli/dist/compiler/tasks/compile/index.d.ts +0 -6
  292. package/packages/cli/dist/compiler/tasks/compile/index.d.ts.map +0 -1
  293. package/packages/cli/dist/compiler/tasks/download/index.d.ts +0 -10
  294. package/packages/cli/dist/compiler/tasks/download/index.d.ts.map +0 -1
  295. package/packages/cli/dist/compiler/tasks/index.d.ts +0 -6
  296. package/packages/cli/dist/compiler/tasks/index.d.ts.map +0 -1
  297. package/packages/cli/dist/compiler/tasks/persist/index.d.ts +0 -5
  298. package/packages/cli/dist/compiler/tasks/persist/index.d.ts.map +0 -1
  299. package/packages/cli/dist/compiler/tasks/setup/index.d.ts +0 -15
  300. package/packages/cli/dist/compiler/tasks/setup/index.d.ts.map +0 -1
  301. package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts +0 -6
  302. package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts.map +0 -1
  303. package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts +0 -5
  304. package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts.map +0 -1
  305. package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts +0 -4
  306. package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts.map +0 -1
  307. package/packages/cli/dist/compiler/tasks/setup/utils/validate-modules.d.ts +0 -2
  308. package/packages/cli/dist/compiler/tasks/setup/utils/validate-modules.d.ts.map +0 -1
  309. package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts +0 -6
  310. package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts.map +0 -1
  311. package/packages/cli/dist/compiler/tasks/types/index.d.ts +0 -3
  312. package/packages/cli/dist/compiler/tasks/types/index.d.ts.map +0 -1
  313. package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts +0 -4
  314. package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts.map +0 -1
  315. package/packages/cli/dist/compiler/types/compiler-context.d.ts +0 -11
  316. package/packages/cli/dist/compiler/types/compiler-context.d.ts.map +0 -1
  317. package/packages/cli/dist/compiler/types/compiler-hooks.d.ts +0 -18
  318. package/packages/cli/dist/compiler/types/compiler-hooks.d.ts.map +0 -1
  319. package/packages/cli/dist/compiler/types/index.d.ts +0 -3
  320. package/packages/cli/dist/compiler/types/index.d.ts.map +0 -1
  321. package/packages/cli/dist/constants/file-naming-style.d.ts +0 -14
  322. package/packages/cli/dist/constants/file-naming-style.d.ts.map +0 -1
  323. package/packages/cli/dist/constants/index.d.ts +0 -4
  324. package/packages/cli/dist/constants/index.d.ts.map +0 -1
  325. package/packages/cli/dist/constants/qs-array-format.d.ts +0 -9
  326. package/packages/cli/dist/constants/qs-array-format.d.ts.map +0 -1
  327. package/packages/cli/dist/constants/supported-methods.d.ts +0 -2
  328. package/packages/cli/dist/constants/supported-methods.d.ts.map +0 -1
  329. package/packages/cli/dist/define-keq-config.d.ts +0 -3
  330. package/packages/cli/dist/define-keq-config.d.ts.map +0 -1
  331. package/packages/cli/dist/exception.d.ts +0 -6
  332. package/packages/cli/dist/exception.d.ts.map +0 -1
  333. package/packages/cli/dist/generators/index.d.ts +0 -2
  334. package/packages/cli/dist/generators/index.d.ts.map +0 -1
  335. package/packages/cli/dist/index.d.ts +0 -6
  336. package/packages/cli/dist/index.d.ts.map +0 -1
  337. package/packages/cli/dist/index.js +0 -2808
  338. package/packages/cli/dist/index.js.map +0 -1
  339. package/packages/cli/dist/models/anchor.d.ts +0 -20
  340. package/packages/cli/dist/models/anchor.d.ts.map +0 -1
  341. package/packages/cli/dist/models/api-document_v3_1.d.ts +0 -16
  342. package/packages/cli/dist/models/api-document_v3_1.d.ts.map +0 -1
  343. package/packages/cli/dist/models/artifact.d.ts +0 -17
  344. package/packages/cli/dist/models/artifact.d.ts.map +0 -1
  345. package/packages/cli/dist/models/asset.d.ts +0 -5
  346. package/packages/cli/dist/models/asset.d.ts.map +0 -1
  347. package/packages/cli/dist/models/index.d.ts +0 -8
  348. package/packages/cli/dist/models/index.d.ts.map +0 -1
  349. package/packages/cli/dist/models/module-definition.d.ts +0 -7
  350. package/packages/cli/dist/models/module-definition.d.ts.map +0 -1
  351. package/packages/cli/dist/models/operation-definition.d.ts +0 -23
  352. package/packages/cli/dist/models/operation-definition.d.ts.map +0 -1
  353. package/packages/cli/dist/models/schema-definition.d.ts +0 -20
  354. package/packages/cli/dist/models/schema-definition.d.ts.map +0 -1
  355. package/packages/cli/dist/models/utils/to-comment.d.ts +0 -2
  356. package/packages/cli/dist/models/utils/to-comment.d.ts.map +0 -1
  357. package/packages/cli/dist/plugins/body-fallback/index.d.ts +0 -6
  358. package/packages/cli/dist/plugins/body-fallback/index.d.ts.map +0 -1
  359. package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts +0 -5
  360. package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts.map +0 -1
  361. package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts +0 -2
  362. package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts.map +0 -1
  363. package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts +0 -8
  364. package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +0 -1
  365. package/packages/cli/dist/plugins/download-http-file/index.d.ts +0 -2
  366. package/packages/cli/dist/plugins/download-http-file/index.d.ts.map +0 -1
  367. package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts +0 -6
  368. package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +0 -1
  369. package/packages/cli/dist/plugins/download-local-file/index.d.ts +0 -2
  370. package/packages/cli/dist/plugins/download-local-file/index.d.ts.map +0 -1
  371. package/packages/cli/dist/plugins/eslint/index.d.ts +0 -15
  372. package/packages/cli/dist/plugins/eslint/index.d.ts.map +0 -1
  373. package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts +0 -2
  374. package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts.map +0 -1
  375. package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts +0 -12
  376. package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts.map +0 -1
  377. package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts +0 -15
  378. package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts.map +0 -1
  379. package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts +0 -3
  380. package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts.map +0 -1
  381. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts +0 -2
  382. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts.map +0 -1
  383. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts +0 -15
  384. package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts.map +0 -1
  385. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts +0 -2
  386. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts.map +0 -1
  387. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts +0 -15
  388. package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts.map +0 -1
  389. package/packages/cli/dist/plugins/generate-declaration/index.d.ts +0 -3
  390. package/packages/cli/dist/plugins/generate-declaration/index.d.ts.map +0 -1
  391. package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts +0 -2
  392. package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts.map +0 -1
  393. package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts +0 -11
  394. package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts.map +0 -1
  395. package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts +0 -11
  396. package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts.map +0 -1
  397. package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts +0 -3
  398. package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts.map +0 -1
  399. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts +0 -2
  400. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts.map +0 -1
  401. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts +0 -15
  402. package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts.map +0 -1
  403. package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts +0 -2
  404. package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts.map +0 -1
  405. package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts +0 -11
  406. package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts.map +0 -1
  407. package/packages/cli/dist/plugins/generate-micro-function/index.d.ts +0 -3
  408. package/packages/cli/dist/plugins/generate-micro-function/index.d.ts.map +0 -1
  409. package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts +0 -2
  410. package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts.map +0 -1
  411. package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts +0 -10
  412. package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts.map +0 -1
  413. package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts +0 -10
  414. package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts.map +0 -1
  415. package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts +0 -2
  416. package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts.map +0 -1
  417. package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts +0 -14
  418. package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts.map +0 -1
  419. package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts +0 -3
  420. package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts.map +0 -1
  421. package/packages/cli/dist/plugins/index.d.ts +0 -15
  422. package/packages/cli/dist/plugins/index.d.ts.map +0 -1
  423. package/packages/cli/dist/plugins/initialize/index.d.ts +0 -2
  424. package/packages/cli/dist/plugins/initialize/index.d.ts.map +0 -1
  425. package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts +0 -15
  426. package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts.map +0 -1
  427. package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts +0 -2
  428. package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts.map +0 -1
  429. package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts +0 -20
  430. package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts.map +0 -1
  431. package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts +0 -2
  432. package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts.map +0 -1
  433. package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts +0 -18
  434. package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts.map +0 -1
  435. package/packages/cli/dist/plugins/prettier/index.d.ts +0 -2
  436. package/packages/cli/dist/plugins/prettier/index.d.ts.map +0 -1
  437. package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts +0 -6
  438. package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts.map +0 -1
  439. package/packages/cli/dist/plugins/shaking/index.d.ts +0 -2
  440. package/packages/cli/dist/plugins/shaking/index.d.ts.map +0 -1
  441. package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts +0 -8
  442. package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts.map +0 -1
  443. package/packages/cli/dist/plugins/terminal-select/index.d.ts +0 -2
  444. package/packages/cli/dist/plugins/terminal-select/index.d.ts.map +0 -1
  445. package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts +0 -18
  446. package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts.map +0 -1
  447. package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts +0 -2
  448. package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts.map +0 -1
  449. package/packages/cli/dist/plugins/terminal-select/types/index.d.ts +0 -2
  450. package/packages/cli/dist/plugins/terminal-select/types/index.d.ts.map +0 -1
  451. package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts +0 -2
  452. package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts.map +0 -1
  453. package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts +0 -5
  454. package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts.map +0 -1
  455. package/packages/cli/dist/plugins.cjs.map +0 -1
  456. package/packages/cli/dist/plugins.js +0 -2365
  457. package/packages/cli/dist/plugins.js.map +0 -1
  458. package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts +0 -8
  459. package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts.map +0 -1
  460. package/packages/cli/dist/transformers/api-document/index.d.ts +0 -2
  461. package/packages/cli/dist/transformers/api-document/index.d.ts.map +0 -1
  462. package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts +0 -14
  463. package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts.map +0 -1
  464. package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts +0 -12
  465. package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts.map +0 -1
  466. package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts +0 -10
  467. package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts.map +0 -1
  468. package/packages/cli/dist/transformers/entrypoint/index.d.ts +0 -2
  469. package/packages/cli/dist/transformers/entrypoint/index.d.ts.map +0 -1
  470. package/packages/cli/dist/transformers/index.d.ts +0 -6
  471. package/packages/cli/dist/transformers/index.d.ts.map +0 -1
  472. package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts +0 -8
  473. package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts.map +0 -1
  474. package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts +0 -26
  475. package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts.map +0 -1
  476. package/packages/cli/dist/transformers/json-schema/index.d.ts +0 -4
  477. package/packages/cli/dist/transformers/json-schema/index.d.ts.map +0 -1
  478. package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts +0 -7
  479. package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts.map +0 -1
  480. package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts +0 -5
  481. package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts.map +0 -1
  482. package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts +0 -5
  483. package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts.map +0 -1
  484. package/packages/cli/dist/transformers/json-schema/types/index.d.ts +0 -3
  485. package/packages/cli/dist/transformers/json-schema/types/index.d.ts.map +0 -1
  486. package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts +0 -7
  487. package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts.map +0 -1
  488. package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts +0 -8
  489. package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts.map +0 -1
  490. package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts +0 -20
  491. package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts.map +0 -1
  492. package/packages/cli/dist/transformers/operation-definition/index.d.ts +0 -3
  493. package/packages/cli/dist/transformers/operation-definition/index.d.ts.map +0 -1
  494. package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts +0 -19
  495. package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts.map +0 -1
  496. package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts +0 -15
  497. package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts.map +0 -1
  498. package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts +0 -11
  499. package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts.map +0 -1
  500. package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts +0 -22
  501. package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts.map +0 -1
  502. package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts +0 -2
  503. package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts.map +0 -1
  504. package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts +0 -4
  505. package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts.map +0 -1
  506. package/packages/cli/dist/transformers/schema-definition/index.d.ts +0 -2
  507. package/packages/cli/dist/transformers/schema-definition/index.d.ts.map +0 -1
  508. package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts +0 -10
  509. package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts.map +0 -1
  510. package/packages/cli/dist/transformers/types/renderer.d.ts +0 -4
  511. package/packages/cli/dist/transformers/types/renderer.d.ts.map +0 -1
  512. package/packages/cli/dist/types/build-cli-options.d.ts +0 -19
  513. package/packages/cli/dist/types/build-cli-options.d.ts.map +0 -1
  514. package/packages/cli/dist/types/generator.d.ts +0 -7
  515. package/packages/cli/dist/types/generator.d.ts.map +0 -1
  516. package/packages/cli/dist/types/index.d.ts +0 -6
  517. package/packages/cli/dist/types/index.d.ts.map +0 -1
  518. package/packages/cli/dist/types/plugin.d.ts +0 -5
  519. package/packages/cli/dist/types/plugin.d.ts.map +0 -1
  520. package/packages/cli/dist/types/runtime-config.d.ts +0 -32
  521. package/packages/cli/dist/types/runtime-config.d.ts.map +0 -1
  522. package/packages/cli/dist/types/to-code-options.d.ts +0 -4
  523. package/packages/cli/dist/types/to-code-options.d.ts.map +0 -1
  524. package/packages/cli/dist/utils/debugger.d.ts +0 -7
  525. package/packages/cli/dist/utils/debugger.d.ts.map +0 -1
  526. package/packages/cli/dist/utils/ignore-matcher.d.ts +0 -18
  527. package/packages/cli/dist/utils/ignore-matcher.d.ts.map +0 -1
  528. package/packages/cli/dist/utils/indent.d.ts +0 -2
  529. package/packages/cli/dist/utils/indent.d.ts.map +0 -1
  530. package/packages/cli/dist/utils/is-keywords.d.ts +0 -2
  531. package/packages/cli/dist/utils/is-keywords.d.ts.map +0 -1
  532. package/packages/cli/dist/utils/is-reserved-word.d.ts +0 -2
  533. package/packages/cli/dist/utils/is-reserved-word.d.ts.map +0 -1
  534. package/packages/cli/dist/utils/json-schema-utils/index.d.ts +0 -11
  535. package/packages/cli/dist/utils/json-schema-utils/index.d.ts.map +0 -1
  536. package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts +0 -3
  537. package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts.map +0 -1
  538. package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts +0 -4
  539. package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts.map +0 -1
  540. package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts +0 -3
  541. package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts.map +0 -1
  542. package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts +0 -3
  543. package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts.map +0 -1
  544. package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts +0 -5
  545. package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts.map +0 -1
  546. package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts +0 -7
  547. package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts.map +0 -1
  548. package/packages/cli/dist/utils/logger.d.ts +0 -6
  549. package/packages/cli/dist/utils/logger.d.ts.map +0 -1
  550. package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts +0 -3
  551. package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts.map +0 -1
  552. package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts +0 -4
  553. package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts.map +0 -1
  554. package/packages/cli/dist/utils/openapi-utils/dereference.d.ts +0 -3
  555. package/packages/cli/dist/utils/openapi-utils/dereference.d.ts.map +0 -1
  556. package/packages/cli/dist/utils/openapi-utils/index.d.ts +0 -19
  557. package/packages/cli/dist/utils/openapi-utils/index.d.ts.map +0 -1
  558. package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts +0 -3
  559. package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts.map +0 -1
  560. package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts +0 -4
  561. package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts.map +0 -1
  562. package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts +0 -4
  563. package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts.map +0 -1
  564. package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts +0 -3
  565. package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts.map +0 -1
  566. package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts +0 -3
  567. package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts.map +0 -1
  568. package/packages/exception/dist/plugins/index.d.mts +0 -12
  569. package/packages/exception/dist/plugins/index.d.ts +0 -12
  570. package/packages/exception/dist/plugins/index.js +0 -95
  571. package/packages/exception/dist/plugins/index.mjs +0 -68
  572. package/packages/exception/node_modules/.bin/keq +0 -21
  573. package/packages/keq/dist/context/execution-context.d.ts +0 -26
  574. package/packages/keq/dist/context/execution-context.d.ts.map +0 -1
  575. package/packages/keq/dist/context/index.d.ts +0 -5
  576. package/packages/keq/dist/context/index.d.ts.map +0 -1
  577. package/packages/keq/dist/context/middleware-context.d.ts +0 -11
  578. package/packages/keq/dist/context/middleware-context.d.ts.map +0 -1
  579. package/packages/keq/dist/context/orchestrator-context.d.ts +0 -18
  580. package/packages/keq/dist/context/orchestrator-context.d.ts.map +0 -1
  581. package/packages/keq/dist/context/shared-context.d.ts +0 -43
  582. package/packages/keq/dist/context/shared-context.d.ts.map +0 -1
  583. package/packages/keq/dist/context/types/index.d.ts +0 -6
  584. package/packages/keq/dist/context/types/index.d.ts.map +0 -1
  585. package/packages/keq/dist/context/types/keq-context-data.d.ts +0 -7
  586. package/packages/keq/dist/context/types/keq-context-data.d.ts.map +0 -1
  587. package/packages/keq/dist/context/types/keq-context-emitter.d.ts +0 -35
  588. package/packages/keq/dist/context/types/keq-context-emitter.d.ts.map +0 -1
  589. package/packages/keq/dist/context/types/keq-context-options/index.d.ts +0 -6
  590. package/packages/keq/dist/context/types/keq-context-options/index.d.ts.map +0 -1
  591. package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts +0 -5
  592. package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts.map +0 -1
  593. package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts +0 -33
  594. package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts.map +0 -1
  595. package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts +0 -5
  596. package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts.map +0 -1
  597. package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts +0 -2
  598. package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts.map +0 -1
  599. package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts +0 -9
  600. package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts.map +0 -1
  601. package/packages/keq/dist/context/types/keq-context.d.ts +0 -17
  602. package/packages/keq/dist/context/types/keq-context.d.ts.map +0 -1
  603. package/packages/keq/dist/context/types/keq-global.d.ts +0 -7
  604. package/packages/keq/dist/context/types/keq-global.d.ts.map +0 -1
  605. package/packages/keq/dist/context/utils/assign-shared-context.d.ts +0 -3
  606. package/packages/keq/dist/context/utils/assign-shared-context.d.ts.map +0 -1
  607. package/packages/keq/dist/context/utils/clone-shared-context.d.ts +0 -3
  608. package/packages/keq/dist/context/utils/clone-shared-context.d.ts.map +0 -1
  609. package/packages/keq/dist/context/utils/create-proxy-response.d.ts +0 -2
  610. package/packages/keq/dist/context/utils/create-proxy-response.d.ts.map +0 -1
  611. package/packages/keq/dist/context/utils/fork.d.ts +0 -6
  612. package/packages/keq/dist/context/utils/fork.d.ts.map +0 -1
  613. package/packages/keq/dist/context/utils/index.d.ts +0 -5
  614. package/packages/keq/dist/context/utils/index.d.ts.map +0 -1
  615. package/packages/keq/dist/context/utils/watch-object.d.ts +0 -5
  616. package/packages/keq/dist/context/utils/watch-object.d.ts.map +0 -1
  617. package/packages/keq/dist/exception/abort.exception.d.ts +0 -4
  618. package/packages/keq/dist/exception/abort.exception.d.ts.map +0 -1
  619. package/packages/keq/dist/exception/exception.d.ts +0 -5
  620. package/packages/keq/dist/exception/exception.d.ts.map +0 -1
  621. package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts +0 -5
  622. package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts.map +0 -1
  623. package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts +0 -5
  624. package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts.map +0 -1
  625. package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts +0 -5
  626. package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts.map +0 -1
  627. package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts +0 -5
  628. package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts.map +0 -1
  629. package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts +0 -5
  630. package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts.map +0 -1
  631. package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts +0 -5
  632. package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts.map +0 -1
  633. package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts +0 -5
  634. package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts.map +0 -1
  635. package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts +0 -5
  636. package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts.map +0 -1
  637. package/packages/keq/dist/exception/http-exceptions/index.d.ts +0 -22
  638. package/packages/keq/dist/exception/http-exceptions/index.d.ts.map +0 -1
  639. package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts +0 -5
  640. package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts.map +0 -1
  641. package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts +0 -5
  642. package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts.map +0 -1
  643. package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts +0 -5
  644. package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts.map +0 -1
  645. package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts +0 -5
  646. package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts.map +0 -1
  647. package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts +0 -5
  648. package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts.map +0 -1
  649. package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts +0 -5
  650. package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts.map +0 -1
  651. package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts +0 -5
  652. package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts.map +0 -1
  653. package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts +0 -5
  654. package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts.map +0 -1
  655. package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts +0 -12
  656. package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts.map +0 -1
  657. package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts +0 -5
  658. package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts.map +0 -1
  659. package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts +0 -5
  660. package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts.map +0 -1
  661. package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts +0 -5
  662. package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts.map +0 -1
  663. package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts +0 -5
  664. package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts.map +0 -1
  665. package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts +0 -5
  666. package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts.map +0 -1
  667. package/packages/keq/dist/exception/index.d.ts +0 -6
  668. package/packages/keq/dist/exception/index.d.ts.map +0 -1
  669. package/packages/keq/dist/exception/timeout.exception.d.ts +0 -5
  670. package/packages/keq/dist/exception/timeout.exception.d.ts.map +0 -1
  671. package/packages/keq/dist/exception/type.exception.d.ts +0 -5
  672. package/packages/keq/dist/exception/type.exception.d.ts.map +0 -1
  673. package/packages/keq/dist/middleware/index.d.ts +0 -3
  674. package/packages/keq/dist/middleware/index.d.ts.map +0 -1
  675. package/packages/keq/dist/middleware/types/index.d.ts +0 -3
  676. package/packages/keq/dist/middleware/types/index.d.ts.map +0 -1
  677. package/packages/keq/dist/middleware/types/keq-middleware.d.ts +0 -8
  678. package/packages/keq/dist/middleware/types/keq-middleware.d.ts.map +0 -1
  679. package/packages/keq/dist/middleware/types/keq-next.d.ts +0 -2
  680. package/packages/keq/dist/middleware/types/keq-next.d.ts.map +0 -1
  681. package/packages/keq/dist/middleware/utils/compose-middleware.d.ts +0 -7
  682. package/packages/keq/dist/middleware/utils/compose-middleware.d.ts.map +0 -1
  683. package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts +0 -3
  684. package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts.map +0 -1
  685. package/packages/keq/dist/middleware/utils/index.d.ts +0 -3
  686. package/packages/keq/dist/middleware/utils/index.d.ts.map +0 -1
  687. package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts +0 -6
  688. package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts.map +0 -1
  689. package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts +0 -3
  690. package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts.map +0 -1
  691. package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts +0 -4
  692. package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts.map +0 -1
  693. package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts +0 -3
  694. package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts.map +0 -1
  695. package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts +0 -9
  696. package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts.map +0 -1
  697. package/packages/keq/dist/middlewares/index.d.ts +0 -4
  698. package/packages/keq/dist/middlewares/index.d.ts.map +0 -1
  699. package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts +0 -6
  700. package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts.map +0 -1
  701. package/packages/keq/dist/orchestrator/executor.d.ts +0 -13
  702. package/packages/keq/dist/orchestrator/executor.d.ts.map +0 -1
  703. package/packages/keq/dist/orchestrator/index.d.ts +0 -3
  704. package/packages/keq/dist/orchestrator/index.d.ts.map +0 -1
  705. package/packages/keq/dist/orchestrator/orchestrator.d.ts +0 -20
  706. package/packages/keq/dist/orchestrator/orchestrator.d.ts.map +0 -1
  707. package/packages/keq/dist/request/core.d.ts +0 -54
  708. package/packages/keq/dist/request/core.d.ts.map +0 -1
  709. package/packages/keq/dist/request/create-request.d.ts +0 -7
  710. package/packages/keq/dist/request/create-request.d.ts.map +0 -1
  711. package/packages/keq/dist/request/index.d.ts +0 -6
  712. package/packages/keq/dist/request/index.d.ts.map +0 -1
  713. package/packages/keq/dist/request/keq.d.ts +0 -120
  714. package/packages/keq/dist/request/keq.d.ts.map +0 -1
  715. package/packages/keq/dist/request/request.d.ts +0 -79
  716. package/packages/keq/dist/request/request.d.ts.map +0 -1
  717. package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts +0 -42
  718. package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts.map +0 -1
  719. package/packages/keq/dist/request/types/api-schema/api-schema.d.ts +0 -8
  720. package/packages/keq/dist/request/types/api-schema/api-schema.d.ts.map +0 -1
  721. package/packages/keq/dist/request/types/api-schema/default-operation.d.ts +0 -18
  722. package/packages/keq/dist/request/types/api-schema/default-operation.d.ts.map +0 -1
  723. package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts +0 -31
  724. package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts.map +0 -1
  725. package/packages/keq/dist/request/types/api-schema/index.d.ts +0 -6
  726. package/packages/keq/dist/request/types/api-schema/index.d.ts.map +0 -1
  727. package/packages/keq/dist/request/types/api-schema/operation.d.ts +0 -17
  728. package/packages/keq/dist/request/types/api-schema/operation.d.ts.map +0 -1
  729. package/packages/keq/dist/request/types/content-type.d.ts +0 -3
  730. package/packages/keq/dist/request/types/content-type.d.ts.map +0 -1
  731. package/packages/keq/dist/request/types/index.d.ts +0 -8
  732. package/packages/keq/dist/request/types/index.d.ts.map +0 -1
  733. package/packages/keq/dist/request/types/keq-attachable-file.d.ts +0 -2
  734. package/packages/keq/dist/request/types/keq-attachable-file.d.ts.map +0 -1
  735. package/packages/keq/dist/request/types/keq-param-value.d.ts +0 -3
  736. package/packages/keq/dist/request/types/keq-param-value.d.ts.map +0 -1
  737. package/packages/keq/dist/request/types/keq-query-options.d.ts +0 -7
  738. package/packages/keq/dist/request/types/keq-query-options.d.ts.map +0 -1
  739. package/packages/keq/dist/request/types/keq-query-value.d.ts +0 -8
  740. package/packages/keq/dist/request/types/keq-query-value.d.ts.map +0 -1
  741. package/packages/keq/dist/request/types/server-sent-event.d.ts +0 -3
  742. package/packages/keq/dist/request/types/server-sent-event.d.ts.map +0 -1
  743. package/packages/keq/dist/request/utils/fix-content-type.d.ts +0 -4
  744. package/packages/keq/dist/request/utils/fix-content-type.d.ts.map +0 -1
  745. package/packages/keq/dist/request/utils/get-location-id.d.ts +0 -2
  746. package/packages/keq/dist/request/utils/get-location-id.d.ts.map +0 -1
  747. package/packages/keq/dist/request/utils/index.d.ts +0 -7
  748. package/packages/keq/dist/request/utils/index.d.ts.map +0 -1
  749. package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts +0 -2
  750. package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts.map +0 -1
  751. package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts +0 -3
  752. package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts.map +0 -1
  753. package/packages/keq/dist/request/utils/query-stringify.d.ts +0 -3
  754. package/packages/keq/dist/request/utils/query-stringify.d.ts.map +0 -1
  755. package/packages/keq/dist/request/utils/resolve-with.d.ts +0 -3
  756. package/packages/keq/dist/request/utils/resolve-with.d.ts.map +0 -1
  757. package/packages/keq/dist/request-init/index.d.ts +0 -4
  758. package/packages/keq/dist/request-init/index.d.ts.map +0 -1
  759. package/packages/keq/dist/request-init/request-init.d.ts +0 -42
  760. package/packages/keq/dist/request-init/request-init.d.ts.map +0 -1
  761. package/packages/keq/dist/request-init/types/index.d.ts +0 -3
  762. package/packages/keq/dist/request-init/types/index.d.ts.map +0 -1
  763. package/packages/keq/dist/request-init/types/keq-body-init.d.ts +0 -2
  764. package/packages/keq/dist/request-init/types/keq-body-init.d.ts.map +0 -1
  765. package/packages/keq/dist/request-init/types/keq-request-method.d.ts +0 -2
  766. package/packages/keq/dist/request-init/types/keq-request-method.d.ts.map +0 -1
  767. package/packages/keq/dist/request-init/utils/assign-request-init.d.ts +0 -3
  768. package/packages/keq/dist/request-init/utils/assign-request-init.d.ts.map +0 -1
  769. package/packages/keq/dist/request-init/utils/clone-body.d.ts +0 -2
  770. package/packages/keq/dist/request-init/utils/clone-body.d.ts.map +0 -1
  771. package/packages/keq/dist/request-init/utils/clone-headers.d.ts +0 -2
  772. package/packages/keq/dist/request-init/utils/clone-headers.d.ts.map +0 -1
  773. package/packages/keq/dist/request-init/utils/clone-request-init.d.ts +0 -3
  774. package/packages/keq/dist/request-init/utils/clone-request-init.d.ts.map +0 -1
  775. package/packages/keq/dist/request-init/utils/compile-url.d.ts +0 -3
  776. package/packages/keq/dist/request-init/utils/compile-url.d.ts.map +0 -1
  777. package/packages/keq/dist/request-init/utils/index.d.ts +0 -7
  778. package/packages/keq/dist/request-init/utils/index.d.ts.map +0 -1
  779. package/packages/keq/dist/request-init/utils/to-form-data.d.ts +0 -2
  780. package/packages/keq/dist/request-init/utils/to-form-data.d.ts.map +0 -1
  781. package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts +0 -2
  782. package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts.map +0 -1
  783. package/packages/keq/dist/router/index.d.ts +0 -4
  784. package/packages/keq/dist/router/index.d.ts.map +0 -1
  785. package/packages/keq/dist/router/keq-host-route.d.ts +0 -3
  786. package/packages/keq/dist/router/keq-host-route.d.ts.map +0 -1
  787. package/packages/keq/dist/router/keq-location-route.d.ts +0 -3
  788. package/packages/keq/dist/router/keq-location-route.d.ts.map +0 -1
  789. package/packages/keq/dist/router/keq-method-route.d.ts +0 -3
  790. package/packages/keq/dist/router/keq-method-route.d.ts.map +0 -1
  791. package/packages/keq/dist/router/keq-module-route.d.ts +0 -3
  792. package/packages/keq/dist/router/keq-module-route.d.ts.map +0 -1
  793. package/packages/keq/dist/router/keq-pathname-route.d.ts +0 -3
  794. package/packages/keq/dist/router/keq-pathname-route.d.ts.map +0 -1
  795. package/packages/keq/dist/router/keq-router.d.ts +0 -32
  796. package/packages/keq/dist/router/keq-router.d.ts.map +0 -1
  797. package/packages/keq/dist/router/types/index.d.ts +0 -2
  798. package/packages/keq/dist/router/types/index.d.ts.map +0 -1
  799. package/packages/keq/dist/router/types/keq-route.d.ts +0 -7
  800. package/packages/keq/dist/router/types/keq-route.d.ts.map +0 -1
  801. package/packages/keq/dist/router/utils/compose-route.d.ts +0 -3
  802. package/packages/keq/dist/router/utils/compose-route.d.ts.map +0 -1
  803. package/packages/keq/dist/router/utils/index.d.ts +0 -2
  804. package/packages/keq/dist/router/utils/index.d.ts.map +0 -1
  805. package/packages/keq/dist/types/enabled-if-string-index.d.ts +0 -24
  806. package/packages/keq/dist/types/enabled-if-string-index.d.ts.map +0 -1
  807. package/packages/keq/dist/types/exclude-unknown-properties.d.ts +0 -19
  808. package/packages/keq/dist/types/exclude-unknown-properties.d.ts.map +0 -1
  809. package/packages/keq/dist/types/index-keys.d.ts +0 -18
  810. package/packages/keq/dist/types/index-keys.d.ts.map +0 -1
  811. package/packages/keq/dist/types/index.d.ts +0 -7
  812. package/packages/keq/dist/types/index.d.ts.map +0 -1
  813. package/packages/keq/dist/types/literal-keys.d.ts +0 -18
  814. package/packages/keq/dist/types/literal-keys.d.ts.map +0 -1
  815. package/packages/keq/dist/types/loose-nested-like.d.ts +0 -11
  816. package/packages/keq/dist/types/loose-nested-like.d.ts.map +0 -1
  817. package/packages/keq/dist/types/string-index-value-of.d.ts +0 -18
  818. package/packages/keq/dist/types/string-index-value-of.d.ts.map +0 -1
  819. package/packages/keq/dist/utils/base64.d.ts +0 -3
  820. package/packages/keq/dist/utils/base64.d.ts.map +0 -1
  821. package/packages/keq/dist/utils/index.d.ts +0 -4
  822. package/packages/keq/dist/utils/index.d.ts.map +0 -1
  823. package/packages/keq/dist/utils/shallow-clone.d.ts +0 -5
  824. package/packages/keq/dist/utils/shallow-clone.d.ts.map +0 -1
  825. package/packages/keq/dist/utils/sleep.d.ts +0 -2
  826. package/packages/keq/dist/utils/sleep.d.ts.map +0 -1
  827. package/packages/keq/dist/validator/index.d.ts +0 -2
  828. package/packages/keq/dist/validator/index.d.ts.map +0 -1
  829. package/packages/keq/dist/validator/validator.d.ts +0 -65
  830. package/packages/keq/dist/validator/validator.d.ts.map +0 -1
  831. package/packages/keq/node_modules/.bin/tsc +0 -21
  832. package/packages/keq/node_modules/.bin/tsserver +0 -21
  833. package/packages/nestjs/dist/keq.module-definition.d.ts +0 -3
  834. package/packages/nestjs/dist/keq.module-definition.d.ts.map +0 -1
  835. package/packages/nestjs/dist/keq.module.d.ts +0 -7
  836. package/packages/nestjs/dist/keq.module.d.ts.map +0 -1
  837. package/packages/nestjs/dist/types/index.d.ts +0 -2
  838. package/packages/nestjs/dist/types/index.d.ts.map +0 -1
  839. package/packages/nestjs/dist/types/keq-module-options.d.ts +0 -5
  840. package/packages/nestjs/dist/types/keq-module-options.d.ts.map +0 -1
  841. package/packages/nestjs/node_modules/.bin/tsc +0 -21
  842. package/packages/nestjs/node_modules/.bin/tsserver +0 -21
@@ -1,1316 +1,1271 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
9
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
-
32
- // src/index.ts
33
- var index_exports = {};
34
- __export(index_exports, {
35
- Eviction: () => Eviction,
36
- IndexedDBStorage: () => IndexedDBStorage,
37
- KeqCacheStorage: () => KeqCacheStorage,
38
- MemoryStorage: () => MemoryStorage,
39
- MultiTierStorage: () => MultiTierStorage,
40
- Size: () => Size,
41
- Strategy: () => Strategy,
42
- TierStorage: () => TierStorage,
43
- cache: () => cache
44
- });
45
- module.exports = __toCommonJS(index_exports);
46
-
47
- // src/cache.ts
48
- var R2 = __toESM(require("ramda"));
49
-
50
- // src/request-cache-handler/request-cache-handler.ts
51
- var R = __toESM(require("ramda"));
52
-
53
- // src/exceptions/cache-exception.ts
54
- var import_keq = require("keq");
55
- var CacheException = class extends import_keq.Exception {
56
- constructor(message) {
57
- super("[@keq-request/cache] ".concat(message));
58
- }
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let ramda = require("ramda");
25
+ ramda = __toESM(ramda);
26
+ let fastq = require("fastq");
27
+ fastq = __toESM(fastq);
28
+ let keq = require("keq");
29
+ let dayjs = require("dayjs");
30
+ dayjs = __toESM(dayjs);
31
+ let idb = require("idb");
32
+ //#region src/exceptions/cache-exception.ts
33
+ var CacheException = class extends keq.Exception {
34
+ constructor(message) {
35
+ super(`[@keq-request/cache] ${message}`);
36
+ }
59
37
  };
60
-
61
- // src/cache-entry/cache-entry.ts
62
- var import_keq2 = require("keq");
63
-
64
- // src/utils/get-response-bytes.ts
38
+ //#endregion
39
+ //#region src/utils/get-response-bytes.ts
65
40
  async function getResponseBytes(response) {
66
- const contentLength = response.headers.get("content-length");
67
- if (contentLength) {
68
- return parseInt(contentLength);
69
- }
70
- const arrayBuffer = await response.clone().arrayBuffer();
71
- return arrayBuffer.byteLength;
41
+ const contentLength = response.headers.get("content-length");
42
+ if (contentLength) return parseInt(contentLength);
43
+ return (await response.clone().arrayBuffer()).byteLength;
72
44
  }
73
-
74
- // src/constants/max-expired-at.ts
75
- var MAX_EXPIRED_AT = /* @__PURE__ */ new Date(864e13);
76
-
77
- // src/constants/eviction.enum.ts
78
- var Eviction = /* @__PURE__ */ ((Eviction2) => {
79
- Eviction2["LRU"] = "lru";
80
- Eviction2["LFU"] = "lfu";
81
- Eviction2["RANDOM"] = "random";
82
- Eviction2["TTL"] = "ttl";
83
- return Eviction2;
84
- })(Eviction || {});
85
-
86
- // src/constants/size.enum.ts
87
- var Size = /* @__PURE__ */ ((Size2) => {
88
- Size2[Size2["B"] = 1] = "B";
89
- Size2[Size2["KB"] = 1024] = "KB";
90
- Size2[Size2["MB"] = 1048576] = "MB";
91
- Size2[Size2["GB"] = 1073741824] = "GB";
92
- return Size2;
93
- })(Size || {});
94
-
95
- // src/utils/logger.ts
45
+ //#endregion
46
+ //#region src/constants/max-expired-at.ts
47
+ const MAX_EXPIRED_AT = /* @__PURE__ */ new Date(864e13);
48
+ //#endregion
49
+ //#region src/constants/eviction.enum.ts
50
+ let Eviction = /* @__PURE__ */ function(Eviction) {
51
+ Eviction["LRU"] = "lru";
52
+ Eviction["LFU"] = "lfu";
53
+ Eviction["RANDOM"] = "random";
54
+ Eviction["TTL"] = "ttl";
55
+ return Eviction;
56
+ }({});
57
+ //#endregion
58
+ //#region src/constants/size.enum.ts
59
+ let Size = /* @__PURE__ */ function(Size) {
60
+ Size[Size["B"] = 1] = "B";
61
+ Size[Size["KB"] = 1024] = "KB";
62
+ Size[Size["MB"] = 1048576] = "MB";
63
+ Size[Size["GB"] = 1073741824] = "GB";
64
+ return Size;
65
+ }({});
66
+ //#endregion
67
+ //#region src/utils/logger.ts
96
68
  var Logger = class {
97
- static debug(...args) {
98
- console.debug("[@keq-request/cache] [DEBUG] ", ...args);
99
- }
100
- static error(...args) {
101
- console.error("[@keq-request/cache] [ERROR] ", ...args);
102
- }
69
+ static debug(...args) {
70
+ console.debug("[@keq-request/cache] [DEBUG] ", ...args);
71
+ }
72
+ static error(...args) {
73
+ console.error("[@keq-request/cache] [ERROR] ", ...args);
74
+ }
103
75
  };
104
-
105
- // src/utils/random.ts
76
+ //#endregion
77
+ //#region src/utils/random.ts
106
78
  function random(min, max) {
107
- return Math.floor(Math.random() * (max - min)) + min;
79
+ return Math.floor(Math.random() * (max - min)) + min;
108
80
  }
109
-
110
- // src/strategies/cache-first.ts
111
- var cacheFirst = async function cacheFirst2(handler, context, next) {
112
- const [cacheKey, cacheValue] = await handler.getCache(context);
113
- if (handler.options.debug) {
114
- Logger.debug([
115
- "",
116
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
117
- "Strategy: Cache First",
118
- "Cache Key: ".concat(cacheKey),
119
- "Cache Status: ".concat(cacheValue ? "HIT" : "MISS")
120
- ].join("\n"));
121
- }
122
- if (cacheValue) {
123
- context.emitter.emit("cache:hit", { key: cacheKey, response: cacheValue.response, context });
124
- context.res = cacheValue.response;
125
- return;
126
- }
127
- context.emitter.emit("cache:miss", { key: cacheKey, context });
128
- await next();
129
- const [, entry] = await handler.setCache(context);
130
- if (handler.options.debug) {
131
- Logger.debug([
132
- "",
133
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
134
- "Strategy: Cache First",
135
- "Cache Key: ".concat(cacheKey),
136
- "ACTIONS: ".concat(entry ? "UPDATED" : "EXCLUDED")
137
- ].join("\n"));
138
- }
139
- if (entry) {
140
- context.emitter.emit("cache:update", {
141
- key: entry.key,
142
- oldResponse: void 0,
143
- newResponse: entry.response,
144
- context
145
- });
146
- }
81
+ //#endregion
82
+ //#region src/strategies/cache-first.ts
83
+ const cacheFirst = async function cacheFirst(handler, context, next) {
84
+ const [cacheKey, cacheValue] = await handler.getCache();
85
+ if (handler.options.debug) Logger.debug([
86
+ "",
87
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
88
+ "Strategy: Cache First",
89
+ `Cache Key: ${cacheKey}`,
90
+ `Cache Status: ${cacheValue ? "HIT" : "MISS"}`
91
+ ].join("\n"));
92
+ if (cacheValue) {
93
+ context.emitter.emit("cache:hit", {
94
+ key: cacheKey,
95
+ response: cacheValue.response,
96
+ context
97
+ });
98
+ context.res = cacheValue.response;
99
+ return;
100
+ }
101
+ context.emitter.emit("cache:miss", {
102
+ key: cacheKey,
103
+ context
104
+ });
105
+ await next();
106
+ const [, entry] = await handler.setCache(context);
107
+ if (handler.options.debug) Logger.debug([
108
+ "",
109
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
110
+ "Strategy: Cache First",
111
+ `Cache Key: ${cacheKey}`,
112
+ `ACTIONS: ${entry ? "UPDATED" : "EXCLUDED"}`
113
+ ].join("\n"));
114
+ if (entry) context.emitter.emit("cache:update", {
115
+ key: entry.key,
116
+ oldResponse: void 0,
117
+ newResponse: entry.response,
118
+ context
119
+ });
147
120
  };
148
-
149
- // src/strategies/network-first.ts
150
- var networkFirst = async function networkFirst2(handler, context, next) {
151
- try {
152
- await next();
153
- const [cacheKey, cache2] = await handler.getCache(context);
154
- const [, entry] = await handler.setCache(context);
155
- if (handler.options.debug) {
156
- Logger.debug([
157
- "",
158
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
159
- "Strategy: Network First",
160
- "Cache Key: ".concat(cacheKey),
161
- "ACTIONS: ".concat(entry ? "UPDATED" : "EXCLUDED")
162
- ].join("\n"));
163
- }
164
- if (entry) {
165
- context.emitter.emit("cache:update", {
166
- key: entry.key,
167
- oldResponse: cache2 == null ? void 0 : cache2.response,
168
- newResponse: entry.response,
169
- context
170
- });
171
- }
172
- } catch (err) {
173
- const [cacheKey, cache2] = await handler.getCache(context);
174
- if (handler.options.debug) {
175
- Logger.debug([
176
- "",
177
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
178
- "Strategy: Network First",
179
- "Cache Key: ".concat(cacheKey),
180
- "Cache Status: ".concat(cache2 ? "HIT" : "MISS")
181
- ].join("\n"));
182
- }
183
- if (!cache2) {
184
- context.emitter.emit("cache:miss", { key: cacheKey, context });
185
- throw err;
186
- }
187
- context.emitter.emit("cache:hit", { key: cacheKey, response: cache2.response, context });
188
- context.res = cache2.response;
189
- }
121
+ //#endregion
122
+ //#region src/strategies/network-first.ts
123
+ const networkFirst = async function networkFirst(handler, context, next) {
124
+ try {
125
+ await next();
126
+ const [cacheKey, cache] = await handler.getCache();
127
+ const [, entry] = await handler.setCache(context);
128
+ if (handler.options.debug) Logger.debug([
129
+ "",
130
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
131
+ "Strategy: Network First",
132
+ `Cache Key: ${cacheKey}`,
133
+ `ACTIONS: ${entry ? "UPDATED" : "EXCLUDED"}`
134
+ ].join("\n"));
135
+ if (entry) context.emitter.emit("cache:update", {
136
+ key: entry.key,
137
+ oldResponse: cache?.response,
138
+ newResponse: entry.response,
139
+ context
140
+ });
141
+ } catch (err) {
142
+ const [cacheKey, cache] = await handler.getCache();
143
+ if (handler.options.debug) Logger.debug([
144
+ "",
145
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
146
+ "Strategy: Network First",
147
+ `Cache Key: ${cacheKey}`,
148
+ `Cache Status: ${cache ? "HIT" : "MISS"}`
149
+ ].join("\n"));
150
+ if (!cache) {
151
+ context.emitter.emit("cache:miss", {
152
+ key: cacheKey,
153
+ context
154
+ });
155
+ throw err;
156
+ }
157
+ context.emitter.emit("cache:hit", {
158
+ key: cacheKey,
159
+ response: cache.response,
160
+ context
161
+ });
162
+ context.res = cache.response;
163
+ }
190
164
  };
191
-
192
- // src/strategies/network-only.ts
193
- var networkOnly = async function(handler, context, next) {
194
- await next();
165
+ //#endregion
166
+ //#region src/strategies/network-only.ts
167
+ const networkOnly = async function(handler, context, next) {
168
+ await next();
195
169
  };
196
-
197
- // src/strategies/stale-while-revalidate.ts
198
- var staleWhileRevalidate = async function(handler, context, next) {
199
- const [cacheKey, cache2] = await handler.getCache(context);
200
- if (handler.options.debug) {
201
- Logger.debug([
202
- "",
203
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
204
- "Strategy: Stale While Revalidate",
205
- "Cache Key: ".concat(cacheKey),
206
- "Cache Status: ".concat(cache2 ? "HIT" : "MISS")
207
- ].join("\n"));
208
- }
209
- if (cache2) {
210
- context.emitter.emit("cache:hit", { key: cacheKey, response: cache2.response, context });
211
- } else {
212
- context.emitter.emit("cache:miss", { key: cacheKey, context });
213
- }
214
- if (cache2) {
215
- const orchestrator = context.orchestration.fork();
216
- context.res = cache2.response;
217
- setTimeout(async () => {
218
- try {
219
- await orchestrator.execute();
220
- const context2 = orchestrator.context;
221
- const [cacheKey2, entry] = await handler.setCache(context2);
222
- if (handler.options.debug) {
223
- Logger.debug([
224
- "",
225
- "Request: ".concat(context2.request.method.toUpperCase(), " ").concat(context2.request.__url__.href),
226
- "Strategy: Stale While Revalidate",
227
- "Cache Key: ".concat(cacheKey2),
228
- "ACTIONS: ".concat(entry ? "UPDATED" : "EXCLUDED")
229
- ].join("\n"));
230
- }
231
- if (entry) {
232
- context2.emitter.emit("cache:update", {
233
- key: cacheKey2,
234
- oldResponse: cache2.response,
235
- newResponse: entry.response,
236
- context: context2
237
- });
238
- }
239
- } catch (err) {
240
- }
241
- }, 1);
242
- } else {
243
- await next();
244
- const [cacheKey2, entry] = await handler.setCache(context);
245
- if (handler.options.debug) {
246
- Logger.debug([
247
- "",
248
- "Request: ".concat(context.request.method.toUpperCase(), " ").concat(context.request.__url__.href),
249
- "Strategy: Stale While Revalidate",
250
- "Cache Key: ".concat(cacheKey2),
251
- "ACTIONS: ".concat(entry ? "UPDATED" : "EXCLUDED")
252
- ].join("\n"));
253
- }
254
- if (entry) {
255
- context.emitter.emit("cache:update", {
256
- key: cacheKey2,
257
- oldResponse: void 0,
258
- newResponse: entry.response,
259
- context
260
- });
261
- }
262
- }
170
+ //#endregion
171
+ //#region src/strategies/stale-while-revalidate.ts
172
+ const staleWhileRevalidate = async function(handler, context, next) {
173
+ const [cacheKey, cache] = await handler.getCache();
174
+ if (handler.options.debug) Logger.debug([
175
+ "",
176
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
177
+ "Strategy: Stale While Revalidate",
178
+ `Cache Key: ${cacheKey}`,
179
+ `Cache Status: ${cache ? "HIT" : "MISS"}`
180
+ ].join("\n"));
181
+ if (cache) context.emitter.emit("cache:hit", {
182
+ key: cacheKey,
183
+ response: cache.response,
184
+ context
185
+ });
186
+ else context.emitter.emit("cache:miss", {
187
+ key: cacheKey,
188
+ context
189
+ });
190
+ if (cache) {
191
+ const orchestrator = context.orchestration.fork();
192
+ context.res = cache.response;
193
+ setTimeout(async () => {
194
+ try {
195
+ await orchestrator.execute();
196
+ const context = orchestrator.context;
197
+ const [cacheKey, entry] = await handler.setCache(context);
198
+ if (handler.options.debug) Logger.debug([
199
+ "",
200
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
201
+ "Strategy: Stale While Revalidate",
202
+ `Cache Key: ${cacheKey}`,
203
+ `ACTIONS: ${entry ? "UPDATED" : "EXCLUDED"}`
204
+ ].join("\n"));
205
+ if (entry) context.emitter.emit("cache:update", {
206
+ key: cacheKey,
207
+ oldResponse: cache.response,
208
+ newResponse: entry.response,
209
+ context
210
+ });
211
+ } catch (err) {}
212
+ }, 1);
213
+ } else {
214
+ await next();
215
+ const [cacheKey, entry] = await handler.setCache(context);
216
+ if (handler.options.debug) Logger.debug([
217
+ "",
218
+ `Request: ${context.request.method.toUpperCase()} ${context.request.__url__.href}`,
219
+ "Strategy: Stale While Revalidate",
220
+ `Cache Key: ${cacheKey}`,
221
+ `ACTIONS: ${entry ? "UPDATED" : "EXCLUDED"}`
222
+ ].join("\n"));
223
+ if (entry) context.emitter.emit("cache:update", {
224
+ key: cacheKey,
225
+ oldResponse: void 0,
226
+ newResponse: entry.response,
227
+ context
228
+ });
229
+ }
263
230
  };
264
-
265
- // src/constants/strategy.enum.ts
266
- var Strategy = {
267
- STALE_WHILE_REVALIDATE: staleWhileRevalidate,
268
- NETWORK_FIRST: networkFirst,
269
- NETWORK_ONLY: networkOnly,
270
- CACHE_FIRST: cacheFirst
231
+ //#endregion
232
+ //#region src/constants/strategy.enum.ts
233
+ const Strategy = {
234
+ STALE_WHILE_REVALIDATE: staleWhileRevalidate,
235
+ NETWORK_FIRST: networkFirst,
236
+ NETWORK_ONLY: networkOnly,
237
+ CACHE_FIRST: cacheFirst
271
238
  };
272
-
273
- // src/cache-entry/cache-entry.ts
274
- var CacheEntry = class _CacheEntry {
275
- constructor(options) {
276
- __publicField(this, "key");
277
- __publicField(this, "response");
278
- /**
279
- * @en bytes
280
- * @zh 字节数
281
- */
282
- __publicField(this, "size");
283
- __publicField(this, "expiredAt");
284
- var _a;
285
- this.key = options.key;
286
- this.response = (0, import_keq2.createProxyResponse)(options.response);
287
- this.size = options.size;
288
- this.expiredAt = (_a = options.expiredAt) != null ? _a : MAX_EXPIRED_AT;
289
- }
290
- static async build(options) {
291
- var _a;
292
- const expiredAt = "expiredAt" in options ? options.expiredAt : "ttl" in options && typeof options.ttl === "number" && options.ttl > 0 ? new Date(Date.now() + options.ttl * 1e3) : MAX_EXPIRED_AT;
293
- const response = options.response.clone();
294
- return new _CacheEntry({
295
- key: options.key,
296
- response,
297
- size: (_a = options.size) != null ? _a : await getResponseBytes(response),
298
- expiredAt
299
- });
300
- }
301
- clone() {
302
- return new _CacheEntry({
303
- key: this.key,
304
- response: this.response.clone(),
305
- size: this.size,
306
- expiredAt: this.expiredAt
307
- });
308
- }
309
- assign(another) {
310
- this.key = another.key;
311
- this.response = another.response.clone();
312
- this.size = another.size;
313
- this.expiredAt = another.expiredAt;
314
- return this;
315
- }
239
+ //#endregion
240
+ //#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
241
+ function _typeof(o) {
242
+ "@babel/helpers - typeof";
243
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
244
+ return typeof o;
245
+ } : function(o) {
246
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
247
+ }, _typeof(o);
248
+ }
249
+ //#endregion
250
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
251
+ function toPrimitive(t, r) {
252
+ if ("object" != _typeof(t) || !t) return t;
253
+ var e = t[Symbol.toPrimitive];
254
+ if (void 0 !== e) {
255
+ var i = e.call(t, r || "default");
256
+ if ("object" != _typeof(i)) return i;
257
+ throw new TypeError("@@toPrimitive must return a primitive value.");
258
+ }
259
+ return ("string" === r ? String : Number)(t);
260
+ }
261
+ //#endregion
262
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
263
+ function toPropertyKey(t) {
264
+ var i = toPrimitive(t, "string");
265
+ return "symbol" == _typeof(i) ? i : i + "";
266
+ }
267
+ //#endregion
268
+ //#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
269
+ function _defineProperty(e, r, t) {
270
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
271
+ value: t,
272
+ enumerable: !0,
273
+ configurable: !0,
274
+ writable: !0
275
+ }) : e[r] = t, e;
276
+ }
277
+ //#endregion
278
+ //#region src/cache-entry/cache-entry.ts
279
+ var CacheEntry = class CacheEntry {
280
+ constructor(options) {
281
+ _defineProperty(this, "key", void 0);
282
+ _defineProperty(this, "response", void 0);
283
+ _defineProperty(
284
+ this,
285
+ /**
286
+ * @en bytes
287
+ * @zh 字节数
288
+ */
289
+ "size",
290
+ void 0
291
+ );
292
+ _defineProperty(this, "expiredAt", void 0);
293
+ this.key = options.key;
294
+ this.response = (0, keq.createProxyResponse)(options.response);
295
+ this.size = options.size;
296
+ this.expiredAt = options.expiredAt ?? MAX_EXPIRED_AT;
297
+ }
298
+ static async build(options) {
299
+ const expiredAt = "expiredAt" in options ? options.expiredAt : "ttl" in options && typeof options.ttl === "number" && options.ttl > 0 ? new Date(Date.now() + options.ttl * 1e3) : MAX_EXPIRED_AT;
300
+ const response = options.response.clone();
301
+ return new CacheEntry({
302
+ key: options.key,
303
+ response,
304
+ size: options.size ?? await getResponseBytes(response),
305
+ expiredAt
306
+ });
307
+ }
308
+ clone() {
309
+ return new CacheEntry({
310
+ key: this.key,
311
+ response: this.response.clone(),
312
+ size: this.size,
313
+ expiredAt: this.expiredAt
314
+ });
315
+ }
316
+ assignResponseHeaders(headers) {
317
+ this.response = new Response(this.response.body, {
318
+ status: this.response.status,
319
+ statusText: this.response.statusText,
320
+ headers
321
+ });
322
+ }
316
323
  };
317
-
318
- // src/request-cache-handler/request-cache-handler.ts
324
+ //#endregion
325
+ //#region src/request-cache-handler/request-cache-handler.ts
319
326
  var RequestCacheHandler = class {
320
- constructor(storage, options) {
321
- this.storage = storage;
322
- this.options = options;
323
- }
324
- /**
325
- * Get cache key for request
326
- */
327
- getRequestCacheKey(context) {
328
- const options = this.options;
329
- if (typeof options.key === "string") return options.key;
330
- else if (typeof options.key === "function") return options.key(context);
331
- else if (R.isNil(options.key) && context.locationId) return context.locationId;
332
- else throw new CacheException("Cannot resolve cache key");
333
- }
334
- /**
335
- * Get cache from storage
336
- */
337
- async getCache(context) {
338
- const key = this.getRequestCacheKey(context);
339
- if (this.options.serverTiming) {
340
- const startAt = /* @__PURE__ */ new Date();
341
- const entry = await this.storage.get(key);
342
- if (entry) {
343
- const dur = (/* @__PURE__ */ new Date()).getTime() - startAt.getTime();
344
- entry.response.headers.append("Server-Timing", "keq-cache; dur=".concat(dur, '; desc="HIT"'));
345
- }
346
- return [key, entry];
347
- }
348
- return [key, await this.storage.get(key)];
349
- }
350
- /**
351
- * Store response that in context to storage
352
- */
353
- async setCache(context) {
354
- const options = this.options;
355
- const key = this.getRequestCacheKey(context);
356
- if (!context.response) return [key, void 0];
357
- if (options.exclude && await options.exclude(context.response)) return [key, void 0];
358
- const entry = await CacheEntry.build({
359
- key,
360
- response: context.response,
361
- ttl: options.ttl
362
- });
363
- void this.storage.set(entry);
364
- return [key, entry];
365
- }
327
+ constructor(cacheKey, storage, options) {
328
+ this.cacheKey = cacheKey;
329
+ this.storage = storage;
330
+ this.options = options;
331
+ }
332
+ /**
333
+ * Resolve cache key for request context
334
+ */
335
+ static resolveRequestCacheKey(context, options) {
336
+ if (typeof options.key === "string") return options.key;
337
+ else if (typeof options.key === "function") return options.key(context);
338
+ else if (ramda.isNil(options.key) && context.locationId) return context.locationId;
339
+ else throw new CacheException("Cannot resolve cache key");
340
+ }
341
+ /**
342
+ * Get cache from storage
343
+ */
344
+ async getCache() {
345
+ const key = this.cacheKey;
346
+ if (this.options.serverTiming) {
347
+ const startAt = /* @__PURE__ */ new Date();
348
+ const entry = await this.storage.get(key);
349
+ if (entry) {
350
+ const dur = (/* @__PURE__ */ new Date()).getTime() - startAt.getTime();
351
+ const HeadersWithServerTiming = new Headers(entry.response.headers);
352
+ HeadersWithServerTiming.set("Server-Timing", `keq-cache; dur=${dur}; desc="HIT"`);
353
+ entry.assignResponseHeaders(HeadersWithServerTiming);
354
+ }
355
+ return [key, entry];
356
+ }
357
+ return [key, await this.storage.get(key)];
358
+ }
359
+ /**
360
+ * Store response that in context to storage
361
+ */
362
+ async setCache(context) {
363
+ const options = this.options;
364
+ const key = this.cacheKey;
365
+ if (!context.response) return [key, void 0];
366
+ if (options.exclude && await options.exclude(context.response)) return [key, void 0];
367
+ const entry = await CacheEntry.build({
368
+ key,
369
+ response: context.response,
370
+ ttl: options.ttl
371
+ });
372
+ this.storage.set(entry);
373
+ return [key, entry];
374
+ }
366
375
  };
367
-
368
- // src/cache.ts
376
+ //#endregion
377
+ //#region src/cache.ts
369
378
  function cache(options) {
370
- const storage = options.storage;
371
- const rules = (options == null ? void 0 : options.rules) || [];
372
- return async function cache2(ctx, next) {
373
- if (ctx.options.cache === false) {
374
- await next();
375
- return;
376
- }
377
- let requestCacheOptions = ctx.options.cache;
378
- const rule = rules.find((rule2) => {
379
- if (rule2.pattern === void 0 || rule2.pattern === true) return true;
380
- if (typeof rule2.pattern === "function") return rule2.pattern(ctx);
381
- return rule2.pattern.test(ctx.request.__url__.href);
382
- });
383
- if (rule) requestCacheOptions = R2.mergeRight(rule, requestCacheOptions || {});
384
- if (!requestCacheOptions || R2.isEmpty(requestCacheOptions)) {
385
- await next();
386
- return;
387
- }
388
- if (!requestCacheOptions.key) requestCacheOptions.key = options.keyFactory;
389
- if (!ctx.locationId && !requestCacheOptions.key) {
390
- console.warn("[@keq/cache] Warning: Cannot resolve Cache Key. Cache is skipped.");
391
- await next();
392
- return;
393
- }
394
- if (requestCacheOptions.serverTiming === void 0 && options.serverTiming !== void 0) {
395
- requestCacheOptions.serverTiming = options.serverTiming;
396
- }
397
- const handler = new RequestCacheHandler(storage, requestCacheOptions);
398
- const strategy = requestCacheOptions.strategy;
399
- await strategy(handler, ctx, next);
400
- };
379
+ const storage = options.storage;
380
+ const rules = options?.rules || [];
381
+ return async function cache(ctx, next) {
382
+ if (ctx.options.cache === false) {
383
+ await next();
384
+ return;
385
+ }
386
+ let requestCacheOptions = ctx.options.cache;
387
+ const rule = rules.find((rule) => {
388
+ if (rule.pattern === void 0 || rule.pattern === true) return true;
389
+ if (typeof rule.pattern === "function") return rule.pattern(ctx);
390
+ return rule.pattern.test(ctx.request.__url__.href);
391
+ });
392
+ if (rule) requestCacheOptions = ramda.mergeRight(rule, requestCacheOptions || {});
393
+ if (!requestCacheOptions || ramda.isEmpty(requestCacheOptions)) {
394
+ await next();
395
+ return;
396
+ }
397
+ if (!requestCacheOptions.key) requestCacheOptions.key = options.keyFactory;
398
+ if (!ctx.locationId && !requestCacheOptions.key) {
399
+ console.warn("[@keq/cache] Warning: Cannot resolve Cache Key. Cache is skipped.");
400
+ await next();
401
+ return;
402
+ }
403
+ if (requestCacheOptions.serverTiming === void 0 && options.serverTiming !== void 0) requestCacheOptions.serverTiming = options.serverTiming;
404
+ const cacheKey = RequestCacheHandler.resolveRequestCacheKey(ctx, requestCacheOptions);
405
+ const handler = new RequestCacheHandler(cacheKey, storage, requestCacheOptions);
406
+ const strategy = requestCacheOptions.strategy;
407
+ if (requestCacheOptions.concurrent) await strategy(handler, ctx, next);
408
+ else {
409
+ if (!ctx.global.core) ctx.global.core = {};
410
+ if (!ctx.global.core.cache) ctx.global.core.cache = {};
411
+ if (!ctx.global.core.cache[cacheKey]) ctx.global.core.cache[cacheKey] = fastq.promise(async ({ next }) => {
412
+ await next();
413
+ }, 1);
414
+ await ctx.global.core.cache[cacheKey].push({ next: async () => {
415
+ await strategy(handler, ctx, next);
416
+ } });
417
+ }
418
+ };
401
419
  }
402
-
403
- // src/storage/memory-storage/ttl-memory-storage.ts
404
- var import_dayjs2 = __toESM(require("dayjs"));
405
- var R4 = __toESM(require("ramda"));
406
-
407
- // src/storage/memory-storage/base-memory-storage.ts
408
- var import_dayjs = __toESM(require("dayjs"));
409
- var R3 = __toESM(require("ramda"));
410
-
411
- // src/storage/keq-cache-storage.ts
412
- var KeqCacheStorage = class {
413
- };
414
-
415
- // src/storage/internal-storage/internal-storage.ts
420
+ //#endregion
421
+ //#region src/storage/keq-cache-storage.ts
422
+ var KeqCacheStorage = class {};
423
+ //#endregion
424
+ //#region src/storage/internal-storage/internal-storage.ts
416
425
  var InternalStorage = class extends KeqCacheStorage {
417
- constructor(options) {
418
- var _a;
419
- super();
420
- __publicField(this, "__id__", Math.random().toString(36).slice(2));
421
- __publicField(this, "__size__");
422
- __publicField(this, "__debug__");
423
- __publicField(this, "__onCacheGet__");
424
- __publicField(this, "__onCacheSet__");
425
- __publicField(this, "__onCacheRemove__");
426
- __publicField(this, "__onCacheEvict__");
427
- __publicField(this, "__onCacheExpired__");
428
- if ((options == null ? void 0 : options.size) && (typeof (options == null ? void 0 : options.size) !== "number" || options.size <= 0)) {
429
- throw new CacheException("Invalid size: ".concat(String(options == null ? void 0 : options.size)));
430
- }
431
- this.__size__ = (_a = options == null ? void 0 : options.size) != null ? _a : Infinity;
432
- this.__debug__ = !!(options == null ? void 0 : options.debug);
433
- this.__onCacheGet__ = options == null ? void 0 : options.onCacheGet;
434
- this.__onCacheSet__ = options == null ? void 0 : options.onCacheSet;
435
- this.__onCacheRemove__ = options == null ? void 0 : options.onCacheRemove;
436
- this.__onCacheEvict__ = options == null ? void 0 : options.onCacheEvict;
437
- this.debug((log) => log("Storage Created: ", this));
438
- }
439
- debug(fn) {
440
- if (this.__debug__) {
441
- fn((...args) => {
442
- Logger.debug("[Storage(".concat(this.__id__, ")]"), ...args);
443
- });
444
- }
445
- }
426
+ constructor(options) {
427
+ super();
428
+ _defineProperty(this, "__id__", Math.random().toString(36).slice(2));
429
+ _defineProperty(this, "__size__", void 0);
430
+ _defineProperty(this, "__debug__", void 0);
431
+ _defineProperty(this, "__onCacheGet__", void 0);
432
+ _defineProperty(this, "__onCacheSet__", void 0);
433
+ _defineProperty(this, "__onCacheRemove__", void 0);
434
+ _defineProperty(this, "__onCacheEvict__", void 0);
435
+ _defineProperty(this, "__onCacheExpired__", void 0);
436
+ if (options?.size && (typeof options?.size !== "number" || options.size <= 0)) throw new CacheException(`Invalid size: ${String(options?.size)}`);
437
+ this.__size__ = options?.size ?? Infinity;
438
+ this.__debug__ = !!options?.debug;
439
+ this.__onCacheGet__ = options?.onCacheGet;
440
+ this.__onCacheSet__ = options?.onCacheSet;
441
+ this.__onCacheRemove__ = options?.onCacheRemove;
442
+ this.__onCacheEvict__ = options?.onCacheEvict;
443
+ this.debug((log) => log("Storage Created: ", this));
444
+ }
445
+ debug(fn) {
446
+ if (this.__debug__) fn((...args) => {
447
+ Logger.debug(`[Storage(${this.__id__})]`, ...args);
448
+ });
449
+ }
446
450
  };
447
-
448
- // src/storage/memory-storage/utils/humanize-size.ts
451
+ //#endregion
452
+ //#region src/storage/memory-storage/utils/humanize-size.ts
453
+ /**
454
+ * @en Humanize size in bytes to KB, MB, GB
455
+ * @zh 将字节数转换为 KB、MB、GB 等易读格式
456
+ */
449
457
  function humanizeSize(size) {
450
- if (size < 1024) return "".concat(size, " B");
451
- if (size < 1024 * 1024) return "".concat((size / 1024).toFixed(2), " KB");
452
- if (size < 1024 * 1024 * 1024) return "".concat((size / (1024 * 1024)).toFixed(2), " MB");
453
- return "".concat((size / (1024 * 1024 * 1024)).toFixed(2), " GB");
458
+ if (size < 1024) return `${size} B`;
459
+ if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB`;
460
+ if (size < 1024 * 1024 * 1024) return `${(size / (1024 * 1024)).toFixed(2)} MB`;
461
+ return `${(size / (1024 * 1024 * 1024)).toFixed(2)} GB`;
454
462
  }
455
-
456
- // src/storage/memory-storage/utils/serialize-response-body.ts
463
+ //#endregion
464
+ //#region src/storage/memory-storage/utils/serialize-response-body.ts
465
+ /**
466
+ * @en Serialize the response body based on content-type
467
+ * @zh 根据 content-type 序列化响应体
468
+ */
457
469
  async function serializeResponseBody(response) {
458
- var _a;
459
- const contentType = (_a = response.headers.get("content-type")) != null ? _a : "";
460
- try {
461
- if (contentType.includes("application/json")) {
462
- const json = await response.json();
463
- return JSON.stringify(json);
464
- }
465
- if (contentType.includes("text/") || contentType.includes("application/xml") || contentType.includes("application/javascript")) {
466
- return await response.text();
467
- }
468
- return "[Binary or unsupported content]";
469
- } catch {
470
- return "[Unable to serialize]";
471
- }
470
+ const contentType = response.headers.get("content-type") ?? "";
471
+ try {
472
+ if (contentType.includes("application/json")) {
473
+ const json = await response.json();
474
+ return JSON.stringify(json);
475
+ }
476
+ if (contentType.includes("text/") || contentType.includes("application/xml") || contentType.includes("application/javascript")) return await response.text();
477
+ return "[Binary or unsupported content]";
478
+ } catch {
479
+ return "[Unable to serialize]";
480
+ }
472
481
  }
473
-
474
- // src/storage/memory-storage/base-memory-storage.ts
482
+ //#endregion
483
+ //#region src/storage/memory-storage/base-memory-storage.ts
475
484
  var BaseMemoryStorage = class extends InternalStorage {
476
- constructor() {
477
- super(...arguments);
478
- __publicField(this, "storage", /* @__PURE__ */ new Map());
479
- __publicField(this, "visitTimeRecords", /* @__PURE__ */ new Map());
480
- __publicField(this, "visitCountRecords", /* @__PURE__ */ new Map());
481
- __publicField(this, "lastEvictExpiredTime", (0, import_dayjs.default)());
482
- }
483
- get size() {
484
- const used = R3.sum(R3.pluck("size", [...this.storage.values()]));
485
- const free = this.__size__ > used ? this.__size__ - used : 0;
486
- return {
487
- used,
488
- free
489
- };
490
- }
491
- get(key) {
492
- var _a;
493
- this.evictExpired();
494
- const entry = this.storage.get(key);
495
- this.visitCountRecords.set(key, ((_a = this.visitCountRecords.get(key)) != null ? _a : 0) + 1);
496
- this.visitTimeRecords.set(key, /* @__PURE__ */ new Date());
497
- if (!entry) this.debug((log) => log("Entry(".concat(key, ") Not Found")));
498
- else this.debug((log) => log("Entry(".concat(key, ") Found: "), entry));
499
- return entry == null ? void 0 : entry.clone();
500
- }
501
- set(value) {
502
- var _a;
503
- if (!this.evict(value.size)) {
504
- this.debug((log) => log("Storage Size Not Enough: ", this.size.free, " < ", value.size));
505
- return;
506
- }
507
- this.storage.set(value.key, value);
508
- this.visitTimeRecords.set(value.key, /* @__PURE__ */ new Date());
509
- this.visitCountRecords.set(value.key, (_a = this.visitCountRecords.get(value.key)) != null ? _a : 0);
510
- this.debug((log) => log("Entry Added: ", value));
511
- this.debug((log) => log("Storage Size: ", this.size));
512
- }
513
- __remove__(keys) {
514
- for (const key of keys) {
515
- const entry = this.storage.get(key);
516
- if (!entry) return;
517
- this.storage.delete(key);
518
- this.visitCountRecords.delete(key);
519
- this.visitTimeRecords.delete(key);
520
- this.debug((log) => log("Entry Removed: ", entry));
521
- this.debug((log) => log("Storage Size: ", this.size));
522
- }
523
- }
524
- remove(key) {
525
- this.__remove__([key]);
526
- }
527
- /**
528
- * @zh 清除过期的缓存
529
- */
530
- evictExpired() {
531
- var _a;
532
- const now = (0, import_dayjs.default)();
533
- if (now.diff(this.lastEvictExpiredTime, "second") < 1) return;
534
- const keys = [];
535
- for (const [key, entry] of this.storage.entries()) {
536
- if (entry.expiredAt && now.isAfter(entry.expiredAt)) {
537
- keys.push(key);
538
- }
539
- }
540
- this.__remove__(keys);
541
- (_a = this.__onCacheExpired__) == null ? void 0 : _a.call(this, { keys });
542
- }
543
- /**
544
- * @en Evict the storage to make sure the size is enough
545
- * @zh 清除缓存以确保有足够的空间
546
- *
547
- * @return {boolean} - is evicted successfully
548
- */
549
- evict(expectSize) {
550
- this.evictExpired();
551
- const size = this.size;
552
- return size.free >= expectSize;
553
- }
554
- /**
555
- * @en Print all cached data using console.table for debugging
556
- * @zh 使用 console.table 打印所有缓存数据,用于调试
557
- */
558
- async print() {
559
- if (this.storage.size === 0) {
560
- console.log("MemoryStorage is empty");
561
- return;
562
- }
563
- const entries = await Promise.all(
564
- [...this.storage.entries()].map(async ([key, entry]) => {
565
- var _a, _b, _c;
566
- const body = await serializeResponseBody(entry.response.clone());
567
- return {
568
- key,
569
- size: humanizeSize(entry.size),
570
- "Expired Time": entry.expiredAt.getTime() >= MAX_EXPIRED_AT.getTime() ? "-" : entry.expiredAt.toISOString(),
571
- "Visit Count": (_a = this.visitCountRecords.get(key)) != null ? _a : 0,
572
- "Last Visit Time": (_c = (_b = this.visitTimeRecords.get(key)) == null ? void 0 : _b.toISOString()) != null ? _c : "-",
573
- "Response Status": entry.response.status,
574
- "Response URL": entry.response.url,
575
- "Response Body": body
576
- };
577
- })
578
- );
579
- console.table(entries);
580
- }
485
+ constructor(..._args) {
486
+ super(..._args);
487
+ _defineProperty(this, "storage", /* @__PURE__ */ new Map());
488
+ _defineProperty(this, "visitTimeRecords", /* @__PURE__ */ new Map());
489
+ _defineProperty(this, "visitCountRecords", /* @__PURE__ */ new Map());
490
+ _defineProperty(this, "lastEvictExpiredTime", (0, dayjs.default)());
491
+ }
492
+ get size() {
493
+ const used = ramda.sum(ramda.pluck("size", [...this.storage.values()]));
494
+ return {
495
+ used,
496
+ free: this.__size__ > used ? this.__size__ - used : 0
497
+ };
498
+ }
499
+ get(key) {
500
+ this.evictExpired();
501
+ const entry = this.storage.get(key);
502
+ this.visitCountRecords.set(key, (this.visitCountRecords.get(key) ?? 0) + 1);
503
+ this.visitTimeRecords.set(key, /* @__PURE__ */ new Date());
504
+ if (!entry) this.debug((log) => log(`Entry(${key}) Not Found`));
505
+ else this.debug((log) => log(`Entry(${key}) Found: `, entry));
506
+ return entry?.clone();
507
+ }
508
+ set(value) {
509
+ if (!this.evict(value.size)) {
510
+ this.debug((log) => log("Storage Size Not Enough: ", this.size.free, " < ", value.size));
511
+ return;
512
+ }
513
+ this.storage.set(value.key, value);
514
+ this.visitTimeRecords.set(value.key, /* @__PURE__ */ new Date());
515
+ this.visitCountRecords.set(value.key, this.visitCountRecords.get(value.key) ?? 0);
516
+ this.debug((log) => log("Entry Added: ", value));
517
+ this.debug((log) => log("Storage Size: ", this.size));
518
+ }
519
+ __remove__(keys) {
520
+ for (const key of keys) {
521
+ const entry = this.storage.get(key);
522
+ if (!entry) return;
523
+ this.storage.delete(key);
524
+ this.visitCountRecords.delete(key);
525
+ this.visitTimeRecords.delete(key);
526
+ this.debug((log) => log("Entry Removed: ", entry));
527
+ this.debug((log) => log("Storage Size: ", this.size));
528
+ }
529
+ }
530
+ remove(key) {
531
+ this.__remove__([key]);
532
+ }
533
+ /**
534
+ * @zh 清除过期的缓存
535
+ */
536
+ evictExpired() {
537
+ const now = (0, dayjs.default)();
538
+ if (now.diff(this.lastEvictExpiredTime, "second") < 1) return;
539
+ const keys = [];
540
+ for (const [key, entry] of this.storage.entries()) if (entry.expiredAt && now.isAfter(entry.expiredAt)) keys.push(key);
541
+ this.__remove__(keys);
542
+ this.__onCacheExpired__?.({ keys });
543
+ }
544
+ /**
545
+ * @en Evict the storage to make sure the size is enough
546
+ * @zh 清除缓存以确保有足够的空间
547
+ *
548
+ * @return {boolean} - is evicted successfully
549
+ */
550
+ evict(expectSize) {
551
+ this.evictExpired();
552
+ return this.size.free >= expectSize;
553
+ }
554
+ /**
555
+ * @en Print all cached data using console.table for debugging
556
+ * @zh 使用 console.table 打印所有缓存数据,用于调试
557
+ */
558
+ async print() {
559
+ if (this.storage.size === 0) {
560
+ console.log("MemoryStorage is empty");
561
+ return;
562
+ }
563
+ const entries = await Promise.all([...this.storage.entries()].map(async ([key, entry]) => {
564
+ const body = await serializeResponseBody(entry.response.clone());
565
+ return {
566
+ key,
567
+ size: humanizeSize(entry.size),
568
+ "Expired Time": entry.expiredAt.getTime() >= MAX_EXPIRED_AT.getTime() ? "-" : entry.expiredAt.toISOString(),
569
+ "Visit Count": this.visitCountRecords.get(key) ?? 0,
570
+ "Last Visit Time": this.visitTimeRecords.get(key)?.toISOString() ?? "-",
571
+ "Response Status": entry.response.status,
572
+ "Response URL": entry.response.url,
573
+ "Response Body": body
574
+ };
575
+ }));
576
+ console.table(entries);
577
+ }
581
578
  };
582
-
583
- // src/storage/memory-storage/ttl-memory-storage.ts
579
+ //#endregion
580
+ //#region src/storage/memory-storage/ttl-memory-storage.ts
584
581
  var TTLMemoryStorage = class extends BaseMemoryStorage {
585
- constructor(options) {
586
- super(options);
587
- }
588
- get(key) {
589
- var _a;
590
- const entry = super.get(key);
591
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
592
- return entry;
593
- }
594
- set(value) {
595
- var _a;
596
- super.set(value);
597
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
598
- }
599
- remove(key) {
600
- var _a;
601
- super.remove(key);
602
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
603
- }
604
- evict(expectSize) {
605
- var _a;
606
- if (expectSize > this.__size__) {
607
- this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
608
- return false;
609
- }
610
- this.evictExpired();
611
- let deficitSize = expectSize - this.size.free;
612
- if (deficitSize <= 0) return true;
613
- const entries = [...this.storage.values()].sort((a, b) => {
614
- const aExpiredAt = (0, import_dayjs2.default)(a.expiredAt);
615
- const bExpiredAt = (0, import_dayjs2.default)(b.expiredAt);
616
- return aExpiredAt.isBefore(bExpiredAt) ? 1 : -1;
617
- });
618
- if (R4.sum(R4.pluck("size", entries)) < deficitSize) {
619
- this.debug((log) => log("Storage Size Not Enough: ", this.size.free, " < ", deficitSize));
620
- return false;
621
- }
622
- const keys = [];
623
- while (deficitSize > 0 && entries.length) {
624
- const entry = entries.pop();
625
- deficitSize -= entry.size;
626
- keys.push(entry.key);
627
- }
628
- this.__remove__(keys);
629
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
630
- return true;
631
- }
582
+ constructor(options) {
583
+ super(options);
584
+ }
585
+ get(key) {
586
+ const entry = super.get(key);
587
+ this.__onCacheGet__?.({ key });
588
+ return entry;
589
+ }
590
+ set(value) {
591
+ super.set(value);
592
+ this.__onCacheSet__?.({ key: value.key });
593
+ }
594
+ remove(key) {
595
+ super.remove(key);
596
+ this.__onCacheRemove__?.({ key });
597
+ }
598
+ evict(expectSize) {
599
+ if (expectSize > this.__size__) {
600
+ this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
601
+ return false;
602
+ }
603
+ this.evictExpired();
604
+ let deficitSize = expectSize - this.size.free;
605
+ if (deficitSize <= 0) return true;
606
+ const entries = [...this.storage.values()].sort((a, b) => {
607
+ const aExpiredAt = (0, dayjs.default)(a.expiredAt);
608
+ const bExpiredAt = (0, dayjs.default)(b.expiredAt);
609
+ return aExpiredAt.isBefore(bExpiredAt) ? 1 : -1;
610
+ });
611
+ if (ramda.sum(ramda.pluck("size", entries)) < deficitSize) {
612
+ this.debug((log) => log("Storage Size Not Enough: ", this.size.free, " < ", deficitSize));
613
+ return false;
614
+ }
615
+ const keys = [];
616
+ while (deficitSize > 0 && entries.length) {
617
+ const entry = entries.pop();
618
+ deficitSize -= entry.size;
619
+ keys.push(entry.key);
620
+ }
621
+ this.__remove__(keys);
622
+ this.__onCacheEvict__?.({ keys });
623
+ return true;
624
+ }
632
625
  };
633
-
634
- // src/storage/memory-storage/random-memory-storage.ts
626
+ //#endregion
627
+ //#region src/storage/memory-storage/random-memory-storage.ts
635
628
  var RandomMemoryStorage = class extends BaseMemoryStorage {
636
- constructor(options) {
637
- super(options);
638
- }
639
- get(key) {
640
- var _a;
641
- const entry = super.get(key);
642
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
643
- return entry;
644
- }
645
- set(value) {
646
- var _a;
647
- super.set(value);
648
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
649
- }
650
- remove(key) {
651
- var _a;
652
- super.remove(key);
653
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
654
- }
655
- evict(expectSize) {
656
- var _a;
657
- if (expectSize > this.__size__) {
658
- this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
659
- return false;
660
- }
661
- this.evictExpired();
662
- let deficitSize = expectSize - this.size.free;
663
- if (deficitSize <= 0) return true;
664
- const entries = [...this.storage.values()];
665
- const keys = [];
666
- while (deficitSize > 0 && entries.length) {
667
- const index = random(0, entries.length - 1);
668
- const entry = entries[index];
669
- deficitSize -= entry.size;
670
- entries.splice(index, 1);
671
- keys.push(entry.key);
672
- }
673
- this.__remove__(keys);
674
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
675
- return true;
676
- }
629
+ constructor(options) {
630
+ super(options);
631
+ }
632
+ get(key) {
633
+ const entry = super.get(key);
634
+ this.__onCacheGet__?.({ key });
635
+ return entry;
636
+ }
637
+ set(value) {
638
+ super.set(value);
639
+ this.__onCacheSet__?.({ key: value.key });
640
+ }
641
+ remove(key) {
642
+ super.remove(key);
643
+ this.__onCacheRemove__?.({ key });
644
+ }
645
+ evict(expectSize) {
646
+ if (expectSize > this.__size__) {
647
+ this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
648
+ return false;
649
+ }
650
+ this.evictExpired();
651
+ let deficitSize = expectSize - this.size.free;
652
+ if (deficitSize <= 0) return true;
653
+ const entries = [...this.storage.values()];
654
+ const keys = [];
655
+ while (deficitSize > 0 && entries.length) {
656
+ const index = random(0, entries.length - 1);
657
+ const entry = entries[index];
658
+ deficitSize -= entry.size;
659
+ entries.splice(index, 1);
660
+ keys.push(entry.key);
661
+ }
662
+ this.__remove__(keys);
663
+ this.__onCacheEvict__?.({ keys });
664
+ return true;
665
+ }
677
666
  };
678
-
679
- // src/storage/memory-storage/lru-memory-storage.ts
680
- var import_dayjs3 = __toESM(require("dayjs"));
667
+ //#endregion
668
+ //#region src/storage/memory-storage/lru-memory-storage.ts
681
669
  var LRUMemoryStorage = class extends BaseMemoryStorage {
682
- constructor(options) {
683
- super(options);
684
- }
685
- get(key) {
686
- var _a;
687
- const entry = super.get(key);
688
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
689
- return entry;
690
- }
691
- set(value) {
692
- var _a;
693
- super.set(value);
694
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
695
- }
696
- remove(key) {
697
- var _a;
698
- super.remove(key);
699
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
700
- }
701
- evict(expectSize) {
702
- var _a;
703
- if (expectSize > this.__size__) {
704
- this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
705
- return false;
706
- }
707
- this.evictExpired();
708
- let deficitSize = expectSize - this.size.free;
709
- if (deficitSize <= 0) return true;
710
- const entries = [...this.storage.values()].sort((a, b) => {
711
- const aVisitAt = this.visitTimeRecords.get(a.key);
712
- const bVisitAt = this.visitTimeRecords.get(b.key);
713
- if (aVisitAt === bVisitAt) return 0;
714
- if (!aVisitAt) return 1;
715
- if (!bVisitAt) return -1;
716
- return (0, import_dayjs3.default)(aVisitAt).isBefore((0, import_dayjs3.default)(bVisitAt)) ? 1 : -1;
717
- });
718
- const keys = [];
719
- while (deficitSize > 0 && entries.length) {
720
- const entry = entries.pop();
721
- deficitSize -= entry.size;
722
- keys.push(entry.key);
723
- }
724
- this.__remove__(keys);
725
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
726
- return true;
727
- }
670
+ constructor(options) {
671
+ super(options);
672
+ }
673
+ get(key) {
674
+ const entry = super.get(key);
675
+ this.__onCacheGet__?.({ key });
676
+ return entry;
677
+ }
678
+ set(value) {
679
+ super.set(value);
680
+ this.__onCacheSet__?.({ key: value.key });
681
+ }
682
+ remove(key) {
683
+ super.remove(key);
684
+ this.__onCacheRemove__?.({ key });
685
+ }
686
+ evict(expectSize) {
687
+ if (expectSize > this.__size__) {
688
+ this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
689
+ return false;
690
+ }
691
+ this.evictExpired();
692
+ let deficitSize = expectSize - this.size.free;
693
+ if (deficitSize <= 0) return true;
694
+ const entries = [...this.storage.values()].sort((a, b) => {
695
+ const aVisitAt = this.visitTimeRecords.get(a.key);
696
+ const bVisitAt = this.visitTimeRecords.get(b.key);
697
+ if (aVisitAt === bVisitAt) return 0;
698
+ if (!aVisitAt) return 1;
699
+ if (!bVisitAt) return -1;
700
+ return (0, dayjs.default)(aVisitAt).isBefore((0, dayjs.default)(bVisitAt)) ? 1 : -1;
701
+ });
702
+ const keys = [];
703
+ while (deficitSize > 0 && entries.length) {
704
+ const entry = entries.pop();
705
+ deficitSize -= entry.size;
706
+ keys.push(entry.key);
707
+ }
708
+ this.__remove__(keys);
709
+ this.__onCacheEvict__?.({ keys });
710
+ return true;
711
+ }
728
712
  };
729
-
730
- // src/storage/memory-storage/lfu-memory-storage.ts
713
+ //#endregion
714
+ //#region src/storage/memory-storage/lfu-memory-storage.ts
731
715
  var LFUMemoryStorage = class extends BaseMemoryStorage {
732
- constructor(options) {
733
- super(options);
734
- }
735
- get(key) {
736
- var _a;
737
- const entry = super.get(key);
738
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
739
- return entry;
740
- }
741
- set(value) {
742
- var _a;
743
- super.set(value);
744
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
745
- }
746
- remove(key) {
747
- var _a;
748
- super.remove(key);
749
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
750
- }
751
- evict(expectSize) {
752
- var _a;
753
- if (expectSize > this.__size__) {
754
- this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
755
- return false;
756
- }
757
- this.evictExpired();
758
- let deficitSize = expectSize - this.size.free;
759
- if (deficitSize <= 0) return true;
760
- const entries = [...this.storage.values()].sort((a, b) => {
761
- const aVisitCount = this.visitCountRecords.get(a.key) || 0;
762
- const bVisitCount = this.visitCountRecords.get(b.key) || 0;
763
- return bVisitCount - aVisitCount;
764
- });
765
- const keys = [];
766
- while (deficitSize > 0 && entries.length) {
767
- const entry = entries.pop();
768
- deficitSize -= entry.size;
769
- keys.push(entry.key);
770
- }
771
- this.__remove__(keys);
772
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
773
- return true;
774
- }
716
+ constructor(options) {
717
+ super(options);
718
+ }
719
+ get(key) {
720
+ const entry = super.get(key);
721
+ this.__onCacheGet__?.({ key });
722
+ return entry;
723
+ }
724
+ set(value) {
725
+ super.set(value);
726
+ this.__onCacheSet__?.({ key: value.key });
727
+ }
728
+ remove(key) {
729
+ super.remove(key);
730
+ this.__onCacheRemove__?.({ key });
731
+ }
732
+ evict(expectSize) {
733
+ if (expectSize > this.__size__) {
734
+ this.debug((log) => log("Storage Size Not Enough: ", this.__size__, " < ", expectSize));
735
+ return false;
736
+ }
737
+ this.evictExpired();
738
+ let deficitSize = expectSize - this.size.free;
739
+ if (deficitSize <= 0) return true;
740
+ const entries = [...this.storage.values()].sort((a, b) => {
741
+ const aVisitCount = this.visitCountRecords.get(a.key) || 0;
742
+ return (this.visitCountRecords.get(b.key) || 0) - aVisitCount;
743
+ });
744
+ const keys = [];
745
+ while (deficitSize > 0 && entries.length) {
746
+ const entry = entries.pop();
747
+ deficitSize -= entry.size;
748
+ keys.push(entry.key);
749
+ }
750
+ this.__remove__(keys);
751
+ this.__onCacheEvict__?.({ keys });
752
+ return true;
753
+ }
775
754
  };
776
-
777
- // src/storage/memory-storage/memory-storage.ts
755
+ //#endregion
756
+ //#region src/storage/memory-storage/memory-storage.ts
778
757
  var MemoryStorage = class extends KeqCacheStorage {
779
- constructor(options) {
780
- super();
781
- __publicField(this, "storage");
782
- const eviction = (options == null ? void 0 : options.eviction) || "lru" /* LRU */;
783
- if (eviction === "ttl" /* TTL */) {
784
- this.storage = new TTLMemoryStorage(options);
785
- } else if (eviction === "random" /* RANDOM */) {
786
- this.storage = new RandomMemoryStorage(options);
787
- } else if (eviction === "lru" /* LRU */) {
788
- this.storage = new LRUMemoryStorage(options);
789
- } else if (eviction === "lfu" /* LFU */) {
790
- this.storage = new LFUMemoryStorage(options);
791
- } else {
792
- throw new TypeError("Invalid eviction: ".concat(String(eviction)));
793
- }
794
- }
795
- set(entry) {
796
- return this.storage.set(entry);
797
- }
798
- get(key) {
799
- return this.storage.get(key);
800
- }
801
- remove(key) {
802
- return this.storage.remove(key);
803
- }
804
- async print() {
805
- return this.storage.print();
806
- }
758
+ constructor(options) {
759
+ super();
760
+ _defineProperty(this, "storage", void 0);
761
+ const eviction = options?.eviction || "lru";
762
+ if (eviction === "ttl") this.storage = new TTLMemoryStorage(options);
763
+ else if (eviction === "random") this.storage = new RandomMemoryStorage(options);
764
+ else if (eviction === "lru") this.storage = new LRUMemoryStorage(options);
765
+ else if (eviction === "lfu") this.storage = new LFUMemoryStorage(options);
766
+ else throw new TypeError(`Invalid eviction: ${String(eviction)}`);
767
+ }
768
+ set(entry) {
769
+ return this.storage.set(entry);
770
+ }
771
+ get(key) {
772
+ return this.storage.get(key);
773
+ }
774
+ remove(key) {
775
+ return this.storage.remove(key);
776
+ }
777
+ async print() {
778
+ return this.storage.print();
779
+ }
807
780
  };
808
-
809
- // src/storage/indexed-db-storage/random-indexed-db-storage.ts
810
- var R6 = __toESM(require("ramda"));
811
-
812
- // src/storage/indexed-db-storage/base-indexed-db-storage.ts
813
- var R5 = __toESM(require("ramda"));
814
- var import_dayjs4 = __toESM(require("dayjs"));
815
- var import_idb = require("idb");
816
-
817
- // src/storage/indexed-db-storage/constants/default-table-name.ts
818
- var DEFAULT_TABLE_NAME = "keq_cache_indexed_db_storage";
819
-
820
- // src/storage/indexed-db-storage/base-indexed-db-storage.ts
781
+ //#endregion
782
+ //#region src/storage/indexed-db-storage/constants/default-table-name.ts
783
+ const DEFAULT_TABLE_NAME = "keq_cache_indexed_db_storage";
784
+ //#endregion
785
+ //#region src/storage/indexed-db-storage/base-indexed-db-storage.ts
821
786
  var BaseIndexedDBStorage = class extends InternalStorage {
822
- constructor(options) {
823
- super(options);
824
- __publicField(this, "tableName", DEFAULT_TABLE_NAME);
825
- __publicField(this, "db");
826
- __publicField(this, "lastEvictExpiredTime", (0, import_dayjs4.default)(0));
827
- if ((options == null ? void 0 : options.tableName) === DEFAULT_TABLE_NAME) {
828
- throw new CacheException('IndexedDBStorage name cannot be "'.concat(DEFAULT_TABLE_NAME, '"'));
829
- }
830
- this.tableName = (options == null ? void 0 : options.tableName) || DEFAULT_TABLE_NAME;
831
- }
832
- async openDB() {
833
- if (this.db) return this.db;
834
- const tableName = this.tableName;
835
- const db = await (0, import_idb.openDB)(tableName, 2, {
836
- upgrade(db2) {
837
- if (!db2.objectStoreNames.contains("metadata")) {
838
- const entriesStore = db2.createObjectStore("metadata", { keyPath: "key" });
839
- entriesStore.createIndex("expiredAt", "expiredAt");
840
- }
841
- if (!db2.objectStoreNames.contains("response")) {
842
- const responsesStore = db2.createObjectStore("response", { keyPath: "key" });
843
- responsesStore.createIndex("responseStatus", "responseStatus");
844
- }
845
- if (!db2.objectStoreNames.contains("visits")) {
846
- const visitsStore = db2.createObjectStore("visits", { keyPath: "key" });
847
- visitsStore.createIndex("visitCount", "visitCount");
848
- visitsStore.createIndex("lastVisitedAt", "lastVisitedAt");
849
- }
850
- },
851
- blocked() {
852
- Logger.error("[@keq-request/cache] IndexedDB Table ".concat(tableName, " is blocked"));
853
- },
854
- blocking() {
855
- Logger.error("[@keq-request/cache] IndexedDB Table ".concat(tableName, " is blocking"));
856
- },
857
- terminated() {
858
- Logger.error("[@keq-request/cache] IndexedDB Table ".concat(tableName, " is terminated"));
859
- }
860
- });
861
- this.db = db;
862
- return db;
863
- }
864
- async getSize() {
865
- const db = await this.openDB();
866
- const items = await db.getAll("metadata");
867
- const used = R5.sum(items.map((entry) => entry.size));
868
- const free = this.__size__ - used;
869
- return { used, free };
870
- }
871
- async get(key) {
872
- await this.evictExpired();
873
- try {
874
- const db = await this.openDB();
875
- const dbMetadata = await db.get("metadata", key);
876
- const dbResponse = await db.get("response", key);
877
- const dbVisits = await db.get("visits", key);
878
- if (!dbMetadata || !dbResponse) return;
879
- await db.put("visits", {
880
- key: dbMetadata.key,
881
- visitCount: dbVisits ? dbVisits.visitCount + 1 : 1,
882
- lastVisitedAt: /* @__PURE__ */ new Date()
883
- });
884
- const response = new Response(dbResponse.responseBody, {
885
- status: dbResponse.responseStatus,
886
- headers: new Headers(dbResponse.responseHeaders),
887
- statusText: dbResponse.responseStatusText
888
- });
889
- return await CacheEntry.build({
890
- key: dbMetadata.key,
891
- expiredAt: dbMetadata.expiredAt,
892
- response,
893
- size: dbMetadata.size
894
- });
895
- } catch (error) {
896
- return;
897
- }
898
- }
899
- async set(entry) {
900
- try {
901
- if (!await this.evict(entry.size)) {
902
- const size = await this.getSize();
903
- this.debug((log) => log("Storage Size Not Enough: ".concat(size.free, " < ").concat(entry.size)));
904
- return;
905
- }
906
- const dbMetadata = {
907
- key: entry.key,
908
- size: entry.size,
909
- expiredAt: entry.expiredAt,
910
- visitedAt: /* @__PURE__ */ new Date(),
911
- visitCount: 0
912
- };
913
- const response = entry.response.clone();
914
- const dbResponse = {
915
- key: entry.key,
916
- responseBody: await response.arrayBuffer(),
917
- responseHeaders: [...response.headers.entries()],
918
- responseStatus: response.status,
919
- responseStatusText: response.statusText
920
- };
921
- const db = await this.openDB();
922
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
923
- const metadataStore = tx.objectStore("metadata");
924
- const responseStore = tx.objectStore("response");
925
- const visitsStore = tx.objectStore("visits");
926
- const dbVisits = await visitsStore.get(entry.key) || {
927
- key: entry.key,
928
- visitCount: 0,
929
- lastVisitedAt: /* @__PURE__ */ new Date()
930
- };
931
- await Promise.all([
932
- metadataStore.put(dbMetadata),
933
- responseStore.put(dbResponse),
934
- visitsStore.put(dbVisits)
935
- ]);
936
- await tx.done;
937
- } catch (error) {
938
- return;
939
- }
940
- }
941
- async __remove__(tx, keys) {
942
- await Promise.all(
943
- R5.unnest(
944
- keys.map((key) => [
945
- tx.objectStore("metadata").delete(key),
946
- tx.objectStore("response").delete(key),
947
- tx.objectStore("visits").delete(key)
948
- ])
949
- )
950
- );
951
- }
952
- async remove(key) {
953
- try {
954
- const db = await this.openDB();
955
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
956
- await this.__remove__(tx, [key]);
957
- await tx.done;
958
- } catch (error) {
959
- return;
960
- }
961
- }
962
- /**
963
- * @zh 清除过期的缓存
964
- */
965
- async evictExpired() {
966
- var _a;
967
- const now = (0, import_dayjs4.default)();
968
- if (now.diff(this.lastEvictExpiredTime, "second") < 1) return;
969
- this.lastEvictExpiredTime = now;
970
- try {
971
- const db = await this.openDB();
972
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
973
- const metadataStore = tx.objectStore("metadata");
974
- let cursor = await metadataStore.index("expiredAt").openCursor(IDBKeyRange.upperBound(now.toDate()));
975
- const expiredKeys = [];
976
- while (cursor) {
977
- if ((0, import_dayjs4.default)(cursor.value.expiredAt).isBefore(now)) {
978
- expiredKeys.push(cursor.value.key);
979
- cursor = await cursor.continue();
980
- } else {
981
- break;
982
- }
983
- }
984
- await this.__remove__(tx, expiredKeys);
985
- await tx.done;
986
- (_a = this.__onCacheExpired__) == null ? void 0 : _a.call(this, { keys: expiredKeys });
987
- } catch (error) {
988
- return;
989
- }
990
- }
787
+ constructor(options) {
788
+ super(options);
789
+ _defineProperty(this, "tableName", DEFAULT_TABLE_NAME);
790
+ _defineProperty(this, "db", void 0);
791
+ _defineProperty(this, "lastEvictExpiredTime", (0, dayjs.default)(0));
792
+ if (options?.tableName === "keq_cache_indexed_db_storage") throw new CacheException(`IndexedDBStorage name cannot be "${DEFAULT_TABLE_NAME}"`);
793
+ this.tableName = options?.tableName || "keq_cache_indexed_db_storage";
794
+ }
795
+ async openDB() {
796
+ if (this.db) return this.db;
797
+ const tableName = this.tableName;
798
+ const db = await (0, idb.openDB)(tableName, 2, {
799
+ upgrade(db) {
800
+ if (!db.objectStoreNames.contains("metadata")) db.createObjectStore("metadata", { keyPath: "key" }).createIndex("expiredAt", "expiredAt");
801
+ if (!db.objectStoreNames.contains("response")) db.createObjectStore("response", { keyPath: "key" }).createIndex("responseStatus", "responseStatus");
802
+ if (!db.objectStoreNames.contains("visits")) {
803
+ const visitsStore = db.createObjectStore("visits", { keyPath: "key" });
804
+ visitsStore.createIndex("visitCount", "visitCount");
805
+ visitsStore.createIndex("lastVisitedAt", "lastVisitedAt");
806
+ }
807
+ },
808
+ blocked() {
809
+ Logger.error(`[@keq-request/cache] IndexedDB Table ${tableName} is blocked`);
810
+ },
811
+ blocking() {
812
+ Logger.error(`[@keq-request/cache] IndexedDB Table ${tableName} is blocking`);
813
+ },
814
+ terminated() {
815
+ Logger.error(`[@keq-request/cache] IndexedDB Table ${tableName} is terminated`);
816
+ }
817
+ });
818
+ this.db = db;
819
+ return db;
820
+ }
821
+ async getSize() {
822
+ const items = await (await this.openDB()).getAll("metadata");
823
+ const used = ramda.sum(items.map((entry) => entry.size));
824
+ return {
825
+ used,
826
+ free: this.__size__ - used
827
+ };
828
+ }
829
+ async get(key) {
830
+ await this.evictExpired();
831
+ try {
832
+ const db = await this.openDB();
833
+ const dbMetadata = await db.get("metadata", key);
834
+ const dbResponse = await db.get("response", key);
835
+ const dbVisits = await db.get("visits", key);
836
+ if (!dbMetadata || !dbResponse) return;
837
+ await db.put("visits", {
838
+ key: dbMetadata.key,
839
+ visitCount: dbVisits ? dbVisits.visitCount + 1 : 1,
840
+ lastVisitedAt: /* @__PURE__ */ new Date()
841
+ });
842
+ const response = new Response(dbResponse.responseBody, {
843
+ status: dbResponse.responseStatus,
844
+ headers: new Headers(dbResponse.responseHeaders),
845
+ statusText: dbResponse.responseStatusText
846
+ });
847
+ return await CacheEntry.build({
848
+ key: dbMetadata.key,
849
+ expiredAt: dbMetadata.expiredAt,
850
+ response,
851
+ size: dbMetadata.size
852
+ });
853
+ } catch (error) {
854
+ return;
855
+ }
856
+ }
857
+ async set(entry) {
858
+ try {
859
+ if (!await this.evict(entry.size)) {
860
+ const size = await this.getSize();
861
+ this.debug((log) => log(`Storage Size Not Enough: ${size.free} < ${entry.size}`));
862
+ return;
863
+ }
864
+ const dbMetadata = {
865
+ key: entry.key,
866
+ size: entry.size,
867
+ expiredAt: entry.expiredAt,
868
+ visitedAt: /* @__PURE__ */ new Date(),
869
+ visitCount: 0
870
+ };
871
+ const response = entry.response.clone();
872
+ const dbResponse = {
873
+ key: entry.key,
874
+ responseBody: await response.arrayBuffer(),
875
+ responseHeaders: [...response.headers.entries()],
876
+ responseStatus: response.status,
877
+ responseStatusText: response.statusText
878
+ };
879
+ const tx = (await this.openDB()).transaction([
880
+ "metadata",
881
+ "response",
882
+ "visits"
883
+ ], "readwrite");
884
+ const metadataStore = tx.objectStore("metadata");
885
+ const responseStore = tx.objectStore("response");
886
+ const visitsStore = tx.objectStore("visits");
887
+ const dbVisits = await visitsStore.get(entry.key) || {
888
+ key: entry.key,
889
+ visitCount: 0,
890
+ lastVisitedAt: /* @__PURE__ */ new Date()
891
+ };
892
+ await Promise.all([
893
+ metadataStore.put(dbMetadata),
894
+ responseStore.put(dbResponse),
895
+ visitsStore.put(dbVisits)
896
+ ]);
897
+ await tx.done;
898
+ } catch (error) {
899
+ return;
900
+ }
901
+ }
902
+ async __remove__(tx, keys) {
903
+ await Promise.all(ramda.unnest(keys.map((key) => [
904
+ tx.objectStore("metadata").delete(key),
905
+ tx.objectStore("response").delete(key),
906
+ tx.objectStore("visits").delete(key)
907
+ ])));
908
+ }
909
+ async remove(key) {
910
+ try {
911
+ const tx = (await this.openDB()).transaction([
912
+ "metadata",
913
+ "response",
914
+ "visits"
915
+ ], "readwrite");
916
+ await this.__remove__(tx, [key]);
917
+ await tx.done;
918
+ } catch (error) {
919
+ return;
920
+ }
921
+ }
922
+ /**
923
+ * @zh 清除过期的缓存
924
+ */
925
+ async evictExpired() {
926
+ const now = (0, dayjs.default)();
927
+ if (now.diff(this.lastEvictExpiredTime, "second") < 1) return;
928
+ this.lastEvictExpiredTime = now;
929
+ try {
930
+ const tx = (await this.openDB()).transaction([
931
+ "metadata",
932
+ "response",
933
+ "visits"
934
+ ], "readwrite");
935
+ let cursor = await tx.objectStore("metadata").index("expiredAt").openCursor(IDBKeyRange.upperBound(now.toDate()));
936
+ const expiredKeys = [];
937
+ while (cursor) if ((0, dayjs.default)(cursor.value.expiredAt).isBefore(now)) {
938
+ expiredKeys.push(cursor.value.key);
939
+ cursor = await cursor.continue();
940
+ } else break;
941
+ await this.__remove__(tx, expiredKeys);
942
+ await tx.done;
943
+ this.__onCacheExpired__?.({ keys: expiredKeys });
944
+ } catch (error) {
945
+ return;
946
+ }
947
+ }
991
948
  };
992
-
993
- // src/storage/indexed-db-storage/random-indexed-db-storage.ts
949
+ //#endregion
950
+ //#region src/storage/indexed-db-storage/random-indexed-db-storage.ts
994
951
  var RandomIndexedDBStorage = class extends BaseIndexedDBStorage {
995
- constructor(options) {
996
- super(options);
997
- }
998
- async get(key) {
999
- var _a;
1000
- const entry = await super.get(key);
1001
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
1002
- return entry;
1003
- }
1004
- async set(value) {
1005
- var _a;
1006
- await super.set(value);
1007
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
1008
- }
1009
- async remove(key) {
1010
- var _a;
1011
- await super.remove(key);
1012
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
1013
- }
1014
- async evict(expectSize) {
1015
- var _a;
1016
- await this.evictExpired();
1017
- const size = await this.getSize();
1018
- let deficitSize = expectSize - size.free;
1019
- if (deficitSize <= 0) return true;
1020
- const db = await this.openDB();
1021
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
1022
- const metadataStore = tx.objectStore("metadata");
1023
- const metadatas = await metadataStore.getAll();
1024
- const totalSize = R6.sum(metadatas.map((m) => m.size));
1025
- if (totalSize < deficitSize) {
1026
- this.debug((log) => log("Storage Size Not Enough, deficit size: ".concat(deficitSize - totalSize)));
1027
- tx.abort();
1028
- return false;
1029
- }
1030
- const keys = [];
1031
- while (deficitSize > 0 && metadatas.length) {
1032
- const index = random(0, metadatas.length - 1);
1033
- const metadata = metadatas[index];
1034
- deficitSize -= metadata.size;
1035
- keys.push(metadata.key);
1036
- metadatas.splice(index, 1);
1037
- }
1038
- await this.__remove__(tx, keys);
1039
- await tx.done;
1040
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
1041
- return true;
1042
- }
952
+ constructor(options) {
953
+ super(options);
954
+ }
955
+ async get(key) {
956
+ const entry = await super.get(key);
957
+ this.__onCacheGet__?.({ key });
958
+ return entry;
959
+ }
960
+ async set(value) {
961
+ await super.set(value);
962
+ this.__onCacheSet__?.({ key: value.key });
963
+ }
964
+ async remove(key) {
965
+ await super.remove(key);
966
+ this.__onCacheRemove__?.({ key });
967
+ }
968
+ async evict(expectSize) {
969
+ await this.evictExpired();
970
+ let deficitSize = expectSize - (await this.getSize()).free;
971
+ if (deficitSize <= 0) return true;
972
+ const tx = (await this.openDB()).transaction([
973
+ "metadata",
974
+ "response",
975
+ "visits"
976
+ ], "readwrite");
977
+ const metadatas = await tx.objectStore("metadata").getAll();
978
+ const totalSize = ramda.sum(metadatas.map((m) => m.size));
979
+ if (totalSize < deficitSize) {
980
+ this.debug((log) => log(`Storage Size Not Enough, deficit size: ${deficitSize - totalSize}`));
981
+ tx.abort();
982
+ return false;
983
+ }
984
+ const keys = [];
985
+ while (deficitSize > 0 && metadatas.length) {
986
+ const index = random(0, metadatas.length - 1);
987
+ const metadata = metadatas[index];
988
+ deficitSize -= metadata.size;
989
+ keys.push(metadata.key);
990
+ metadatas.splice(index, 1);
991
+ }
992
+ await this.__remove__(tx, keys);
993
+ await tx.done;
994
+ this.__onCacheEvict__?.({ keys });
995
+ return true;
996
+ }
1043
997
  };
1044
-
1045
- // src/storage/indexed-db-storage/lfu-indexed-db-storage.ts
998
+ //#endregion
999
+ //#region src/storage/indexed-db-storage/lfu-indexed-db-storage.ts
1046
1000
  var LFUIndexedDBStorage = class extends BaseIndexedDBStorage {
1047
- constructor(options) {
1048
- super(options);
1049
- }
1050
- async get(key) {
1051
- var _a;
1052
- const entry = await super.get(key);
1053
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
1054
- return entry;
1055
- }
1056
- async set(value) {
1057
- var _a;
1058
- await super.set(value);
1059
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
1060
- }
1061
- async remove(key) {
1062
- var _a;
1063
- await super.remove(key);
1064
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
1065
- }
1066
- async evict(expectSize) {
1067
- var _a;
1068
- await this.evictExpired();
1069
- const size = await this.getSize();
1070
- let deficitSize = expectSize - size.free;
1071
- if (deficitSize <= 0) return true;
1072
- const db = await this.openDB();
1073
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
1074
- const metadataStore = tx.objectStore("metadata");
1075
- const visitsStore = tx.objectStore("visits");
1076
- let cursor = await visitsStore.index("visitCount").openCursor();
1077
- const keys = [];
1078
- while (deficitSize > 0 && cursor) {
1079
- const metadata = await metadataStore.get(cursor.value.key);
1080
- if (!metadata) {
1081
- await cursor.delete();
1082
- cursor = await cursor.continue();
1083
- continue;
1084
- }
1085
- deficitSize -= metadata.size;
1086
- keys.push(cursor.value.key);
1087
- cursor = await cursor.continue();
1088
- }
1089
- if (deficitSize > 0) {
1090
- this.debug((log) => log("Storage Size Not Enough, deficit size: ".concat(deficitSize)));
1091
- tx.abort();
1092
- return false;
1093
- }
1094
- await this.__remove__(tx, keys);
1095
- await tx.done;
1096
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
1097
- return true;
1098
- }
1001
+ constructor(options) {
1002
+ super(options);
1003
+ }
1004
+ async get(key) {
1005
+ const entry = await super.get(key);
1006
+ this.__onCacheGet__?.({ key });
1007
+ return entry;
1008
+ }
1009
+ async set(value) {
1010
+ await super.set(value);
1011
+ this.__onCacheSet__?.({ key: value.key });
1012
+ }
1013
+ async remove(key) {
1014
+ await super.remove(key);
1015
+ this.__onCacheRemove__?.({ key });
1016
+ }
1017
+ async evict(expectSize) {
1018
+ await this.evictExpired();
1019
+ let deficitSize = expectSize - (await this.getSize()).free;
1020
+ if (deficitSize <= 0) return true;
1021
+ const tx = (await this.openDB()).transaction([
1022
+ "metadata",
1023
+ "response",
1024
+ "visits"
1025
+ ], "readwrite");
1026
+ const metadataStore = tx.objectStore("metadata");
1027
+ let cursor = await tx.objectStore("visits").index("visitCount").openCursor();
1028
+ const keys = [];
1029
+ while (deficitSize > 0 && cursor) {
1030
+ const metadata = await metadataStore.get(cursor.value.key);
1031
+ if (!metadata) {
1032
+ await cursor.delete();
1033
+ cursor = await cursor.continue();
1034
+ continue;
1035
+ }
1036
+ deficitSize -= metadata.size;
1037
+ keys.push(cursor.value.key);
1038
+ cursor = await cursor.continue();
1039
+ }
1040
+ if (deficitSize > 0) {
1041
+ this.debug((log) => log(`Storage Size Not Enough, deficit size: ${deficitSize}`));
1042
+ tx.abort();
1043
+ return false;
1044
+ }
1045
+ await this.__remove__(tx, keys);
1046
+ await tx.done;
1047
+ this.__onCacheEvict__?.({ keys });
1048
+ return true;
1049
+ }
1099
1050
  };
1100
-
1101
- // src/storage/indexed-db-storage/lru-indexed-db-storage.ts
1051
+ //#endregion
1052
+ //#region src/storage/indexed-db-storage/lru-indexed-db-storage.ts
1102
1053
  var LRUIndexedDBStorage = class extends BaseIndexedDBStorage {
1103
- constructor(options) {
1104
- super(options);
1105
- }
1106
- async get(key) {
1107
- var _a;
1108
- const entry = await super.get(key);
1109
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
1110
- return entry;
1111
- }
1112
- async set(value) {
1113
- var _a;
1114
- await super.set(value);
1115
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
1116
- }
1117
- async remove(key) {
1118
- var _a;
1119
- await super.remove(key);
1120
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
1121
- }
1122
- async evict(expectSize) {
1123
- var _a;
1124
- await this.evictExpired();
1125
- const size = await this.getSize();
1126
- let deficitSize = expectSize - size.free;
1127
- if (deficitSize <= 0) return true;
1128
- const db = await this.openDB();
1129
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
1130
- const metadataStore = tx.objectStore("metadata");
1131
- const visitsStore = tx.objectStore("visits");
1132
- const keys = [];
1133
- let cursor = await visitsStore.index("lastVisitedAt").openCursor();
1134
- while (deficitSize > 0 && cursor) {
1135
- const metadata = await metadataStore.get(cursor.value.key);
1136
- if (!metadata) {
1137
- await cursor.delete();
1138
- cursor = await cursor.continue();
1139
- continue;
1140
- }
1141
- deficitSize -= metadata.size;
1142
- keys.push(cursor.value.key);
1143
- cursor = await cursor.continue();
1144
- }
1145
- if (deficitSize > 0) {
1146
- this.debug((log) => log("Storage Size Not Enough, deficit size: ".concat(deficitSize)));
1147
- tx.abort();
1148
- return false;
1149
- }
1150
- await this.__remove__(tx, keys);
1151
- await tx.done;
1152
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
1153
- return true;
1154
- }
1054
+ constructor(options) {
1055
+ super(options);
1056
+ }
1057
+ async get(key) {
1058
+ const entry = await super.get(key);
1059
+ this.__onCacheGet__?.({ key });
1060
+ return entry;
1061
+ }
1062
+ async set(value) {
1063
+ await super.set(value);
1064
+ this.__onCacheSet__?.({ key: value.key });
1065
+ }
1066
+ async remove(key) {
1067
+ await super.remove(key);
1068
+ this.__onCacheRemove__?.({ key });
1069
+ }
1070
+ async evict(expectSize) {
1071
+ await this.evictExpired();
1072
+ let deficitSize = expectSize - (await this.getSize()).free;
1073
+ if (deficitSize <= 0) return true;
1074
+ const tx = (await this.openDB()).transaction([
1075
+ "metadata",
1076
+ "response",
1077
+ "visits"
1078
+ ], "readwrite");
1079
+ const metadataStore = tx.objectStore("metadata");
1080
+ const visitsStore = tx.objectStore("visits");
1081
+ const keys = [];
1082
+ let cursor = await visitsStore.index("lastVisitedAt").openCursor();
1083
+ while (deficitSize > 0 && cursor) {
1084
+ const metadata = await metadataStore.get(cursor.value.key);
1085
+ if (!metadata) {
1086
+ await cursor.delete();
1087
+ cursor = await cursor.continue();
1088
+ continue;
1089
+ }
1090
+ deficitSize -= metadata.size;
1091
+ keys.push(cursor.value.key);
1092
+ cursor = await cursor.continue();
1093
+ }
1094
+ if (deficitSize > 0) {
1095
+ this.debug((log) => log(`Storage Size Not Enough, deficit size: ${deficitSize}`));
1096
+ tx.abort();
1097
+ return false;
1098
+ }
1099
+ await this.__remove__(tx, keys);
1100
+ await tx.done;
1101
+ this.__onCacheEvict__?.({ keys });
1102
+ return true;
1103
+ }
1155
1104
  };
1156
-
1157
- // src/storage/indexed-db-storage/ttl-indexed-db-storage.ts
1105
+ //#endregion
1106
+ //#region src/storage/indexed-db-storage/ttl-indexed-db-storage.ts
1158
1107
  var TTLIndexedDBStorage = class extends BaseIndexedDBStorage {
1159
- constructor(options) {
1160
- super(options);
1161
- }
1162
- async get(key) {
1163
- var _a;
1164
- const entry = await super.get(key);
1165
- (_a = this.__onCacheGet__) == null ? void 0 : _a.call(this, { key });
1166
- return entry;
1167
- }
1168
- async set(value) {
1169
- var _a;
1170
- await super.set(value);
1171
- (_a = this.__onCacheSet__) == null ? void 0 : _a.call(this, { key: value.key });
1172
- }
1173
- async remove(key) {
1174
- var _a;
1175
- await super.remove(key);
1176
- (_a = this.__onCacheRemove__) == null ? void 0 : _a.call(this, { key });
1177
- }
1178
- async evict(expectSize) {
1179
- var _a;
1180
- await this.evictExpired();
1181
- const size = await this.getSize();
1182
- let deficitSize = expectSize - size.free;
1183
- if (deficitSize <= 0) return true;
1184
- const db = await this.openDB();
1185
- const tx = db.transaction(["metadata", "response", "visits"], "readwrite");
1186
- const metadataStore = tx.objectStore("metadata");
1187
- const keys = [];
1188
- let cursor = await metadataStore.index("expiredAt").openCursor();
1189
- while (deficitSize > 0 && cursor) {
1190
- const metadata = await metadataStore.get(cursor.value.key);
1191
- if (!metadata) {
1192
- await cursor.delete();
1193
- cursor = await cursor.continue();
1194
- continue;
1195
- }
1196
- deficitSize -= metadata.size;
1197
- keys.push(cursor.value.key);
1198
- cursor = await cursor.continue();
1199
- }
1200
- if (deficitSize > 0) {
1201
- this.debug((log) => log("Storage Size Not Enough, deficit size: ".concat(deficitSize)));
1202
- tx.abort();
1203
- return false;
1204
- }
1205
- await this.__remove__(tx, keys);
1206
- await tx.done;
1207
- (_a = this.__onCacheEvict__) == null ? void 0 : _a.call(this, { keys });
1208
- return true;
1209
- }
1108
+ constructor(options) {
1109
+ super(options);
1110
+ }
1111
+ async get(key) {
1112
+ const entry = await super.get(key);
1113
+ this.__onCacheGet__?.({ key });
1114
+ return entry;
1115
+ }
1116
+ async set(value) {
1117
+ await super.set(value);
1118
+ this.__onCacheSet__?.({ key: value.key });
1119
+ }
1120
+ async remove(key) {
1121
+ await super.remove(key);
1122
+ this.__onCacheRemove__?.({ key });
1123
+ }
1124
+ async evict(expectSize) {
1125
+ await this.evictExpired();
1126
+ let deficitSize = expectSize - (await this.getSize()).free;
1127
+ if (deficitSize <= 0) return true;
1128
+ const tx = (await this.openDB()).transaction([
1129
+ "metadata",
1130
+ "response",
1131
+ "visits"
1132
+ ], "readwrite");
1133
+ const metadataStore = tx.objectStore("metadata");
1134
+ const keys = [];
1135
+ let cursor = await metadataStore.index("expiredAt").openCursor();
1136
+ while (deficitSize > 0 && cursor) {
1137
+ const metadata = await metadataStore.get(cursor.value.key);
1138
+ if (!metadata) {
1139
+ await cursor.delete();
1140
+ cursor = await cursor.continue();
1141
+ continue;
1142
+ }
1143
+ deficitSize -= metadata.size;
1144
+ keys.push(cursor.value.key);
1145
+ cursor = await cursor.continue();
1146
+ }
1147
+ if (deficitSize > 0) {
1148
+ this.debug((log) => log(`Storage Size Not Enough, deficit size: ${deficitSize}`));
1149
+ tx.abort();
1150
+ return false;
1151
+ }
1152
+ await this.__remove__(tx, keys);
1153
+ await tx.done;
1154
+ this.__onCacheEvict__?.({ keys });
1155
+ return true;
1156
+ }
1210
1157
  };
1211
-
1212
- // src/storage/indexed-db-storage/indexed-db-storage.ts
1158
+ //#endregion
1159
+ //#region src/storage/indexed-db-storage/indexed-db-storage.ts
1213
1160
  var IndexedDBStorage = class extends KeqCacheStorage {
1214
- constructor(options) {
1215
- super();
1216
- __publicField(this, "storage");
1217
- const eviction = (options == null ? void 0 : options.eviction) || "lru" /* LRU */;
1218
- if (eviction === "random" /* RANDOM */) {
1219
- this.storage = new RandomIndexedDBStorage(options);
1220
- } else if (eviction === "lfu" /* LFU */) {
1221
- this.storage = new LFUIndexedDBStorage(options);
1222
- } else if (eviction === "lru" /* LRU */) {
1223
- this.storage = new LRUIndexedDBStorage(options);
1224
- } else if (eviction === "ttl" /* TTL */) {
1225
- this.storage = new TTLIndexedDBStorage(options);
1226
- } else {
1227
- throw new CacheException("Not Supported Eviction: ".concat(String(options == null ? void 0 : options.eviction)));
1228
- }
1229
- }
1230
- set(entry) {
1231
- return this.storage.set(entry);
1232
- }
1233
- get(key) {
1234
- return this.storage.get(key);
1235
- }
1236
- remove(key) {
1237
- return this.storage.remove(key);
1238
- }
1161
+ constructor(options) {
1162
+ super();
1163
+ _defineProperty(this, "storage", void 0);
1164
+ const eviction = options?.eviction || "lru";
1165
+ if (eviction === "random") this.storage = new RandomIndexedDBStorage(options);
1166
+ else if (eviction === "lfu") this.storage = new LFUIndexedDBStorage(options);
1167
+ else if (eviction === "lru") this.storage = new LRUIndexedDBStorage(options);
1168
+ else if (eviction === "ttl") this.storage = new TTLIndexedDBStorage(options);
1169
+ else throw new CacheException(`Not Supported Eviction: ${String(options?.eviction)}`);
1170
+ }
1171
+ set(entry) {
1172
+ return this.storage.set(entry);
1173
+ }
1174
+ get(key) {
1175
+ return this.storage.get(key);
1176
+ }
1177
+ remove(key) {
1178
+ return this.storage.remove(key);
1179
+ }
1239
1180
  };
1240
-
1241
- // src/storage/multi-tier-storage/multi-tier-storage.ts
1181
+ //#endregion
1182
+ //#region src/storage/multi-tier-storage/multi-tier-storage.ts
1183
+ /**
1184
+ * @en Multi-tier cache storage that manages multiple KeqCacheStorage instances in tiers
1185
+ * @zh 多层缓存存储,管理多个分层的 KeqCacheStorage 实例
1186
+ */
1242
1187
  var MultiTierStorage = class extends KeqCacheStorage {
1243
- /**
1244
- * @param storages Array of storage instances ordered by performance (fastest first)
1245
- * @zh 按性价比排序的存储实例数组,排在前面的成本低,排在后面的成本高
1246
- */
1247
- constructor(options) {
1248
- super();
1249
- __publicField(this, "storages");
1250
- if (!options.tiers || options.tiers.length === 0) {
1251
- throw new Error("At least one storage instance is required");
1252
- }
1253
- this.storages = [...options.tiers];
1254
- }
1255
- /**
1256
- * @en Get cache entry, searching from lowest to highest tier
1257
- * @zh 获取缓存条目,从最底层到高层依次搜索
1258
- */
1259
- async get(key) {
1260
- for (let i = 0; i < this.storages.length; i++) {
1261
- const storage = this.storages[i];
1262
- const entry = await storage.get(key);
1263
- if (entry) {
1264
- if (i > 0) {
1265
- await this.syncToLowerTiers(entry, i);
1266
- }
1267
- return entry;
1268
- }
1269
- }
1270
- return void 0;
1271
- }
1272
- /**
1273
- * @en Set cache entry to all tiers concurrently
1274
- * @zh 并发写入所有层的缓存
1275
- */
1276
- async set(entry) {
1277
- const promises = this.storages.map(async (storage) => storage.set(entry));
1278
- await Promise.all(promises);
1279
- }
1280
- /**
1281
- * @en Remove cache entry from all tiers
1282
- * @zh 从所有层删除缓存条目
1283
- */
1284
- async remove(key) {
1285
- const promises = this.storages.map(async (storage) => storage.remove(key));
1286
- await Promise.all(promises);
1287
- }
1288
- /**
1289
- * @en Sync cache entry to all lower tiers (tiers with index < currentTierIndex)
1290
- * @zh 将缓存条目同步到所有低层存储(索引小于当前层的存储)
1291
- */
1292
- async syncToLowerTiers(entry, currentTierIndex) {
1293
- const lowerTierStorages = this.storages.slice(0, currentTierIndex);
1294
- if (lowerTierStorages.length === 0) {
1295
- return;
1296
- }
1297
- const promises = lowerTierStorages.map(async (storage) => storage.set(entry.clone()));
1298
- try {
1299
- await Promise.all(promises);
1300
- } catch (error) {
1301
- console.warn("Failed to sync cache entry to lower tiers:", error);
1302
- }
1303
- }
1188
+ /**
1189
+ * @param storages Array of storage instances ordered by performance (fastest first)
1190
+ * @zh 按性价比排序的存储实例数组,排在前面的成本低,排在后面的成本高
1191
+ */
1192
+ constructor(options) {
1193
+ super();
1194
+ _defineProperty(this, "storages", void 0);
1195
+ if (!options.tiers || options.tiers.length === 0) throw new Error("At least one storage instance is required");
1196
+ this.storages = [...options.tiers];
1197
+ }
1198
+ /**
1199
+ * @en Get cache entry, searching from lowest to highest tier
1200
+ * @zh 获取缓存条目,从最底层到高层依次搜索
1201
+ */
1202
+ async get(key) {
1203
+ for (let i = 0; i < this.storages.length; i++) {
1204
+ const entry = await this.storages[i].get(key);
1205
+ if (entry) {
1206
+ if (i > 0) await this.syncToLowerTiers(entry, i);
1207
+ return entry;
1208
+ }
1209
+ }
1210
+ }
1211
+ /**
1212
+ * @en Set cache entry to all tiers concurrently
1213
+ * @zh 并发写入所有层的缓存
1214
+ */
1215
+ async set(entry) {
1216
+ const promises = this.storages.map(async (storage) => storage.set(entry));
1217
+ await Promise.all(promises);
1218
+ }
1219
+ /**
1220
+ * @en Remove cache entry from all tiers
1221
+ * @zh 从所有层删除缓存条目
1222
+ */
1223
+ async remove(key) {
1224
+ const promises = this.storages.map(async (storage) => storage.remove(key));
1225
+ await Promise.all(promises);
1226
+ }
1227
+ /**
1228
+ * @en Sync cache entry to all lower tiers (tiers with index < currentTierIndex)
1229
+ * @zh 将缓存条目同步到所有低层存储(索引小于当前层的存储)
1230
+ */
1231
+ async syncToLowerTiers(entry, currentTierIndex) {
1232
+ const lowerTierStorages = this.storages.slice(0, currentTierIndex);
1233
+ if (lowerTierStorages.length === 0) return;
1234
+ const promises = lowerTierStorages.map(async (storage) => storage.set(entry.clone()));
1235
+ try {
1236
+ await Promise.all(promises);
1237
+ } catch (error) {
1238
+ console.warn("Failed to sync cache entry to lower tiers:", error);
1239
+ }
1240
+ }
1304
1241
  };
1305
-
1306
- // src/storage/tier-storage/tier-storage.ts
1242
+ //#endregion
1243
+ //#region src/storage/tier-storage/tier-storage.ts
1244
+ /**
1245
+ * @en Two-tier cache storage that combines MemoryStorage (L1) and IndexedDBStorage (L2)
1246
+ * @zh 二级缓存存储,结合了MemoryStorage(一级)和IndexedDBStorage(二级)
1247
+ *
1248
+ * This is a convenience wrapper around MultiTierStorage that provides:
1249
+ * - Fast in-memory cache (L1)
1250
+ * - Persistent IndexedDB cache (L2)
1251
+ * - Simplified configuration options
1252
+ */
1307
1253
  var TierStorage = class extends MultiTierStorage {
1308
- constructor(options) {
1309
- const memoryStorage = (options == null ? void 0 : options.memory) instanceof MemoryStorage ? options.memory : new MemoryStorage(options == null ? void 0 : options.memory);
1310
- const indexedDBStorage = (options == null ? void 0 : options.indexedDB) instanceof IndexedDBStorage ? options.indexedDB : new IndexedDBStorage(options == null ? void 0 : options.indexedDB);
1311
- super({
1312
- tiers: [memoryStorage, indexedDBStorage]
1313
- });
1314
- }
1254
+ constructor(options) {
1255
+ const memoryStorage = options?.memory instanceof MemoryStorage ? options.memory : new MemoryStorage(options?.memory);
1256
+ const indexedDBStorage = options?.indexedDB instanceof IndexedDBStorage ? options.indexedDB : new IndexedDBStorage(options?.indexedDB);
1257
+ super({ tiers: [memoryStorage, indexedDBStorage] });
1258
+ }
1315
1259
  };
1260
+ //#endregion
1261
+ exports.Eviction = Eviction;
1262
+ exports.IndexedDBStorage = IndexedDBStorage;
1263
+ exports.KeqCacheStorage = KeqCacheStorage;
1264
+ exports.MemoryStorage = MemoryStorage;
1265
+ exports.MultiTierStorage = MultiTierStorage;
1266
+ exports.Size = Size;
1267
+ exports.Strategy = Strategy;
1268
+ exports.TierStorage = TierStorage;
1269
+ exports.cache = cache;
1270
+
1316
1271
  //# sourceMappingURL=index.js.map