@zuplo/cli 6.69.4 → 6.69.5

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 (333) hide show
  1. package/dist/__tests__/integration/jest-mocks-setup.js +29 -10
  2. package/dist/__tests__/integration/jest-mocks-setup.js.map +1 -1
  3. package/dist/cmds/custom-domain/index.d.ts.map +1 -1
  4. package/dist/cmds/custom-domain/index.js +6 -10
  5. package/dist/cmds/custom-domain/index.js.map +1 -1
  6. package/dist/cmds/mtls-certificates/index.d.ts.map +1 -1
  7. package/dist/cmds/mtls-certificates/index.js +8 -12
  8. package/dist/cmds/mtls-certificates/index.js.map +1 -1
  9. package/dist/cmds/open-api/index.d.ts.map +1 -1
  10. package/dist/cmds/open-api/index.js +2 -5
  11. package/dist/cmds/open-api/index.js.map +1 -1
  12. package/dist/cmds/project/index.d.ts.map +1 -1
  13. package/dist/cmds/project/index.js +2 -5
  14. package/dist/cmds/project/index.js.map +1 -1
  15. package/dist/cmds/proxies/index.d.ts +4 -4
  16. package/dist/cmds/proxies/index.d.ts.map +1 -1
  17. package/dist/cmds/proxies/index.js +6 -10
  18. package/dist/cmds/proxies/index.js.map +1 -1
  19. package/dist/cmds/source/index.d.ts.map +1 -1
  20. package/dist/cmds/source/index.js +2 -9
  21. package/dist/cmds/source/index.js.map +1 -1
  22. package/dist/cmds/source/migrate.d.ts +4 -4
  23. package/dist/cmds/source/migrate.d.ts.map +1 -1
  24. package/dist/cmds/source/migrate.js +3 -6
  25. package/dist/cmds/source/migrate.js.map +1 -1
  26. package/dist/cmds/tunnel/index.d.ts.map +1 -1
  27. package/dist/cmds/tunnel/index.js +8 -12
  28. package/dist/cmds/tunnel/index.js.map +1 -1
  29. package/dist/cmds/tunnel/services/index.d.ts.map +1 -1
  30. package/dist/cmds/tunnel/services/index.js +2 -5
  31. package/dist/cmds/tunnel/services/index.js.map +1 -1
  32. package/dist/cmds/variable/index.d.ts.map +1 -1
  33. package/dist/cmds/variable/index.js +2 -5
  34. package/dist/cmds/variable/index.js.map +1 -1
  35. package/dist/common/handler.d.ts +4 -1
  36. package/dist/common/handler.d.ts.map +1 -1
  37. package/dist/common/handler.js +11 -2
  38. package/dist/common/handler.js.map +1 -1
  39. package/dist/common/middleware/get-environment-param.d.ts.map +1 -1
  40. package/dist/common/middleware/get-environment-param.js +2 -18
  41. package/dist/common/middleware/get-environment-param.js.map +1 -1
  42. package/dist/common/utils/build-environment-prompt-choices.d.ts +13 -0
  43. package/dist/common/utils/build-environment-prompt-choices.d.ts.map +1 -0
  44. package/dist/common/utils/build-environment-prompt-choices.js +66 -0
  45. package/dist/common/utils/build-environment-prompt-choices.js.map +1 -0
  46. package/dist/common/utils/build-environment-prompt-choices.test.d.ts +2 -0
  47. package/dist/common/utils/build-environment-prompt-choices.test.d.ts.map +1 -0
  48. package/dist/common/utils/build-environment-prompt-choices.test.js +97 -0
  49. package/dist/common/utils/build-environment-prompt-choices.test.js.map +1 -0
  50. package/dist/common/utils/pretty-print-environment-prompt.d.ts +1 -4
  51. package/dist/common/utils/pretty-print-environment-prompt.d.ts.map +1 -1
  52. package/dist/common/utils/pretty-print-environment-prompt.js +3 -8
  53. package/dist/common/utils/pretty-print-environment-prompt.js.map +1 -1
  54. package/dist/common/utils/pretty-print-environment-prompt.test.js +15 -17
  55. package/dist/common/utils/pretty-print-environment-prompt.test.js.map +1 -1
  56. package/dist/common/utils/sort-environments-for-prompt.d.ts +5 -0
  57. package/dist/common/utils/sort-environments-for-prompt.d.ts.map +1 -0
  58. package/dist/common/utils/sort-environments-for-prompt.js +27 -0
  59. package/dist/common/utils/sort-environments-for-prompt.js.map +1 -0
  60. package/dist/common/utils/sort-environments-for-prompt.test.d.ts +2 -0
  61. package/dist/common/utils/sort-environments-for-prompt.test.d.ts.map +1 -0
  62. package/dist/common/utils/sort-environments-for-prompt.test.js +82 -0
  63. package/dist/common/utils/sort-environments-for-prompt.test.js.map +1 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/README.md +1 -5
  66. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/ipaddr.min.js +1 -1
  67. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js +21 -6
  68. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/package.json +1 -1
  69. package/node_modules/@zuplo/core/index.minified.js +141 -137
  70. package/node_modules/@zuplo/core/package.json +1 -1
  71. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/workflows/ci.yml +1 -1
  72. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  73. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/LICENSE +1 -3
  74. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +60 -44
  75. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/index.js +2 -2
  76. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/package.json +7 -7
  77. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/anyof.test.js +20 -0
  78. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/array.test.js +22 -0
  79. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/debug-mode.test.js +21 -0
  80. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/if-then-else.test.js +72 -0
  81. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/invalidSchema.test.js +20 -0
  82. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  83. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -57
  84. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/oneof.test.js +20 -0
  85. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/ref.test.js +31 -0
  86. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/typebox.test.js +1 -1
  87. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/types/{index.test-d.ts → index.tst.ts} +17 -17
  88. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
  89. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
  90. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
  91. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  92. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1380 -0
  93. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
  94. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.js +1686 -0
  95. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
  96. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  97. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
  98. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
  99. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
  100. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.js +11 -0
  101. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
  102. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
  103. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  104. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +2 -2
  105. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +4 -7
  106. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -3
  107. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  108. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.js +10 -16
  109. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  110. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  111. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.min.js.map +4 -4
  112. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
  113. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
  114. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
  115. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  116. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1380 -0
  117. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
  118. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.js +1686 -0
  119. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
  120. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  121. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
  122. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
  123. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
  124. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.js +11 -0
  125. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
  126. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
  127. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
  128. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.js +11 -0
  129. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
  130. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
  131. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
  132. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +1 -1
  133. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +1 -1
  134. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -3
  135. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  136. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.js +9 -15
  137. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  138. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  139. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.min.js.map +4 -4
  140. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
  141. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
  142. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.js +8 -0
  143. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
  144. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -1
  145. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -1
  146. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.d.ts +2 -3
  147. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  148. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.js +9 -15
  149. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  150. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  151. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.min.js.map +4 -4
  152. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
  153. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
  154. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +1 -1
  155. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +2 -3
  156. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -3
  157. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  158. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.js +9 -15
  159. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  160. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  161. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.min.js.map +4 -4
  162. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
  163. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
  164. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.js +8 -0
  165. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
  166. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
  167. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
  168. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.js +8 -0
  169. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
  170. package/node_modules/@zuplo/editor/node_modules/lru-cache/package.json +44 -16
  171. package/node_modules/@zuplo/graphql/package.json +1 -1
  172. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  173. package/node_modules/@zuplo/otel/package.json +1 -1
  174. package/node_modules/@zuplo/runtime/out/esm/index.js +54 -54
  175. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  176. package/node_modules/@zuplo/runtime/out/types/index.d.ts +4 -0
  177. package/node_modules/@zuplo/runtime/package.json +1 -1
  178. package/node_modules/axios/CHANGELOG.md +32 -6
  179. package/node_modules/axios/README.md +356 -20
  180. package/node_modules/axios/dist/axios.js +1389 -1071
  181. package/node_modules/axios/dist/axios.js.map +1 -1
  182. package/node_modules/axios/dist/axios.min.js +3 -3
  183. package/node_modules/axios/dist/axios.min.js.map +1 -1
  184. package/node_modules/axios/dist/browser/axios.cjs +1486 -1123
  185. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  186. package/node_modules/axios/dist/esm/axios.js +1488 -1124
  187. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  188. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  189. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  190. package/node_modules/axios/dist/node/axios.cjs +1230 -871
  191. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  192. package/node_modules/axios/index.d.cts +25 -13
  193. package/node_modules/axios/index.d.ts +21 -4
  194. package/node_modules/axios/index.js +2 -0
  195. package/node_modules/axios/lib/adapters/adapters.js +4 -2
  196. package/node_modules/axios/lib/adapters/fetch.js +126 -10
  197. package/node_modules/axios/lib/adapters/http.js +178 -59
  198. package/node_modules/axios/lib/adapters/xhr.js +6 -2
  199. package/node_modules/axios/lib/core/Axios.js +7 -3
  200. package/node_modules/axios/lib/core/AxiosError.js +86 -1
  201. package/node_modules/axios/lib/core/AxiosHeaders.js +3 -0
  202. package/node_modules/axios/lib/core/dispatchRequest.js +19 -7
  203. package/node_modules/axios/lib/core/mergeConfig.js +6 -3
  204. package/node_modules/axios/lib/core/settle.js +7 -11
  205. package/node_modules/axios/lib/defaults/index.js +1 -1
  206. package/node_modules/axios/lib/env/data.js +1 -1
  207. package/node_modules/axios/lib/helpers/buildURL.js +1 -1
  208. package/node_modules/axios/lib/helpers/cookies.js +14 -2
  209. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
  210. package/node_modules/axios/lib/helpers/formDataToStream.js +1 -1
  211. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  212. package/node_modules/axios/lib/helpers/resolveConfig.js +33 -17
  213. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +26 -1
  214. package/node_modules/axios/lib/helpers/validator.js +1 -1
  215. package/node_modules/axios/lib/utils.js +27 -15
  216. package/node_modules/axios/package.json +17 -24
  217. package/node_modules/fast-uri/.github/workflows/ci.yml +12 -7
  218. package/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
  219. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +1 -1
  220. package/node_modules/fast-uri/LICENSE +1 -3
  221. package/node_modules/fast-uri/README.md +13 -4
  222. package/node_modules/fast-uri/index.js +90 -24
  223. package/node_modules/fast-uri/lib/utils.js +129 -22
  224. package/node_modules/fast-uri/package.json +3 -4
  225. package/node_modules/fast-uri/test/equal.test.js +9 -0
  226. package/node_modules/fast-uri/test/parse.test.js +5 -0
  227. package/node_modules/fast-uri/test/resolve.test.js +9 -0
  228. package/node_modules/fast-uri/test/security-normalization.test.js +39 -0
  229. package/node_modules/fast-uri/test/security.test.js +133 -0
  230. package/node_modules/is-core-module/CHANGELOG.md +244 -113
  231. package/node_modules/is-core-module/README.md +1 -1
  232. package/node_modules/is-core-module/core.json +12 -12
  233. package/node_modules/is-core-module/package.json +5 -5
  234. package/node_modules/is-core-module/test/index.js +101 -0
  235. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
  236. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
  237. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
  238. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  239. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1380 -0
  240. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
  241. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.js +1686 -0
  242. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
  243. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  244. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
  245. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
  246. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
  247. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.js +11 -0
  248. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
  249. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
  250. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  251. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +2 -2
  252. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +4 -7
  253. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -3
  254. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  255. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.js +10 -16
  256. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  257. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  258. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.min.js.map +4 -4
  259. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
  260. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
  261. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
  262. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  263. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1380 -0
  264. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
  265. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.js +1686 -0
  266. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
  267. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  268. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
  269. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
  270. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
  271. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.js +11 -0
  272. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
  273. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
  274. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
  275. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.js +11 -0
  276. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
  277. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
  278. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
  279. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +1 -1
  280. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +1 -1
  281. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -3
  282. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  283. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.js +9 -15
  284. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  285. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  286. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.min.js.map +4 -4
  287. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
  288. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
  289. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.js +8 -0
  290. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
  291. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -1
  292. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -1
  293. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.d.ts +2 -3
  294. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  295. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.js +9 -15
  296. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  297. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  298. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.min.js.map +4 -4
  299. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
  300. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
  301. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +1 -1
  302. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +2 -3
  303. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -3
  304. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  305. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.js +9 -15
  306. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  307. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  308. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.min.js.map +4 -4
  309. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
  310. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
  311. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.js +8 -0
  312. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
  313. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
  314. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
  315. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.js +8 -0
  316. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
  317. package/node_modules/rimraf/node_modules/lru-cache/package.json +44 -16
  318. package/package.json +6 -6
  319. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/stale.yml +0 -21
  320. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts.map +0 -1
  321. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js.map +0 -1
  322. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.mts.map +0 -1
  323. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.mjs.map +0 -1
  324. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.mts.map +0 -1
  325. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.mjs.map +0 -1
  326. package/node_modules/fast-uri/.github/.stale.yml +0 -21
  327. package/node_modules/fast-uri/.github/tests_checker.yml +0 -8
  328. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts.map +0 -1
  329. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js.map +0 -1
  330. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.mts.map +0 -1
  331. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.mjs.map +0 -1
  332. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.mts.map +0 -1
  333. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.mjs.map +0 -1
@@ -0,0 +1,1380 @@
1
+ /**
2
+ * @module LRUCache
3
+ */
4
+ import type { Perf } from './perf.js';
5
+ export type { Perf } from './perf.js';
6
+ declare const TYPE: unique symbol;
7
+ export type PosInt = number & {
8
+ [TYPE]: 'Positive Integer';
9
+ };
10
+ export type Index = number & {
11
+ [TYPE]: 'LRUCache Index';
12
+ };
13
+ export type UintArray = Uint8Array | Uint16Array | Uint32Array;
14
+ export type NumberArray = UintArray | number[];
15
+ declare class ZeroArray extends Array<number> {
16
+ constructor(size: number);
17
+ }
18
+ export type { ZeroArray };
19
+ export type { Stack };
20
+ export type StackLike = Stack | Index[];
21
+ declare class Stack {
22
+ #private;
23
+ heap: NumberArray;
24
+ length: number;
25
+ static create(max: number): StackLike;
26
+ constructor(max: number, HeapCls: {
27
+ new (n: number): NumberArray;
28
+ });
29
+ push(n: Index): void;
30
+ pop(): Index;
31
+ }
32
+ /**
33
+ * Promise representing an in-progress {@link LRUCache#fetch} call
34
+ */
35
+ export type BackgroundFetch<V> = Promise<V | undefined> & {
36
+ __returned: BackgroundFetch<V> | undefined;
37
+ __abortController: AbortController;
38
+ __staleWhileFetching: V | undefined;
39
+ };
40
+ export type DisposeTask<K, V> = [
41
+ value: V,
42
+ key: K,
43
+ reason: LRUCache.DisposeReason
44
+ ];
45
+ export declare namespace LRUCache {
46
+ /**
47
+ * An integer greater than 0, reflecting the calculated size of items
48
+ */
49
+ type Size = number;
50
+ /**
51
+ * Integer greater than 0, representing some number of milliseconds, or the
52
+ * time at which a TTL started counting from.
53
+ */
54
+ type Milliseconds = number;
55
+ /**
56
+ * An integer greater than 0, reflecting a number of items
57
+ */
58
+ type Count = number;
59
+ /**
60
+ * The reason why an item was removed from the cache, passed
61
+ * to the {@link Disposer} methods.
62
+ *
63
+ * - `evict`: The item was evicted because it is the least recently used,
64
+ * and the cache is full.
65
+ * - `set`: A new value was set, overwriting the old value being disposed.
66
+ * - `delete`: The item was explicitly deleted, either by calling
67
+ * {@link LRUCache#delete}, {@link LRUCache#clear}, or
68
+ * {@link LRUCache#set} with an undefined value.
69
+ * - `expire`: The item was removed due to exceeding its TTL.
70
+ * - `fetch`: A {@link OptionsBase#fetchMethod} operation returned
71
+ * `undefined` or was aborted, causing the item to be deleted.
72
+ */
73
+ type DisposeReason = 'evict' | 'set' | 'delete' | 'expire' | 'fetch';
74
+ /**
75
+ * A method called upon item removal, passed as the
76
+ * {@link OptionsBase.dispose} and/or
77
+ * {@link OptionsBase.disposeAfter} options.
78
+ */
79
+ type Disposer<K, V> = (value: V, key: K, reason: DisposeReason) => void;
80
+ /**
81
+ * The reason why an item was added to the cache, passed
82
+ * to the {@link Inserter} methods.
83
+ *
84
+ * - `add`: the item was not found in the cache, and was added
85
+ * - `update`: the item was in the cache, with the same value provided
86
+ * - `replace`: the item was in the cache, and replaced
87
+ */
88
+ type InsertReason = 'add' | 'update' | 'replace';
89
+ /**
90
+ * A method called upon item insertion, passed as the
91
+ * {@link OptionsBase.insert}
92
+ */
93
+ type Inserter<K, V> = (value: V, key: K, reason: InsertReason) => void;
94
+ /**
95
+ * A function that returns the effective calculated size
96
+ * of an entry in the cache.
97
+ */
98
+ type SizeCalculator<K, V> = (value: V, key: K) => Size;
99
+ /**
100
+ * Options provided to the
101
+ * {@link OptionsBase.fetchMethod} function.
102
+ */
103
+ interface FetcherOptions<K, V, FC = unknown> {
104
+ signal: AbortSignal;
105
+ options: FetcherFetchOptions<K, V, FC>;
106
+ /**
107
+ * Object provided in the {@link FetchOptions.context} option to
108
+ * {@link LRUCache#fetch}
109
+ */
110
+ context: FC;
111
+ }
112
+ /**
113
+ * Occasionally, it may be useful to track the internal behavior of the
114
+ * cache, particularly for logging, debugging, or for behavior within the
115
+ * `fetchMethod`. To do this, you can pass a `status` object to the
116
+ * {@link LRUCache#fetch}, {@link LRUCache#get}, {@link LRUCache#set},
117
+ * {@link LRUCache#memo}, and {@link LRUCache#has} methods.
118
+ *
119
+ * The `status` option should be a plain JavaScript object. The following
120
+ * fields will be set on it appropriately, depending on the situation.
121
+ *
122
+ * These objects are also the context objects passed to listeners on the
123
+ * `lru-cache:metrics` diagnostic channel, and the `lru-cache` tracing
124
+ * channels, in platforms that support them.
125
+ */
126
+ interface Status<K, V> {
127
+ /**
128
+ * The operation being performed
129
+ */
130
+ op?: 'get' | 'set' | 'memo' | 'fetch' | 'delete' | 'has' | 'peek';
131
+ /**
132
+ * The status of a set() operation.
133
+ *
134
+ * - add: the item was not found in the cache, and was added
135
+ * - update: the item was in the cache, with the same value provided
136
+ * - replace: the item was in the cache, and replaced
137
+ * - miss: the item was not added to the cache for some reason
138
+ */
139
+ set?: 'add' | 'update' | 'replace' | 'miss' | 'deleted';
140
+ /**
141
+ * The status of a delete() operation.
142
+ */
143
+ delete?: LRUCache.DisposeReason;
144
+ /**
145
+ * The result of a peek() operation
146
+ *
147
+ * - hit: the item was found and returned
148
+ * - stale: the item is in the cache, but past its ttl and not returned
149
+ * - miss: item not in the cache
150
+ */
151
+ peek?: 'hit' | 'miss' | 'stale';
152
+ /**
153
+ * The status of a memo() operation.
154
+ *
155
+ * - 'hit': the item was found in the cache and returned
156
+ * - 'miss': the `memoMethod` function was called
157
+ */
158
+ memo?: 'hit' | 'miss';
159
+ /**
160
+ * The `context` option provided to a memo or fetch operation
161
+ *
162
+ * In practice, of course, this will be the same type as the `FC`
163
+ * fetch context param used to instantiate the LRUCache, but the
164
+ * convolutions of threading that through would get quite complicated,
165
+ * and preclude forcing/forbidding the passing of a `context` param
166
+ * where it is/isn't expected, which is more valuable for error
167
+ * prevention.
168
+ */
169
+ context?: unknown;
170
+ /**
171
+ * the ttl stored for the item, or undefined if ttls are not used.
172
+ */
173
+ ttl?: Milliseconds;
174
+ /**
175
+ * the start time for the item, or undefined if ttls are not used.
176
+ */
177
+ start?: Milliseconds;
178
+ /**
179
+ * The timestamp used for TTL calculation
180
+ */
181
+ now?: Milliseconds;
182
+ /**
183
+ * the remaining ttl for the item, or undefined if ttls are not used.
184
+ */
185
+ remainingTTL?: Milliseconds;
186
+ /**
187
+ * The calculated size for the item, if sizes are used.
188
+ */
189
+ entrySize?: Size;
190
+ /**
191
+ * The total calculated size of the cache, if sizes are used.
192
+ */
193
+ totalCalculatedSize?: Size;
194
+ /**
195
+ * A flag indicating that the item was not stored, due to exceeding the
196
+ * {@link OptionsBase.maxEntrySize}
197
+ */
198
+ maxEntrySizeExceeded?: true;
199
+ /**
200
+ * The key that was set or retrieved
201
+ */
202
+ key?: K;
203
+ /**
204
+ * The value that was set
205
+ */
206
+ value?: V;
207
+ /**
208
+ * The old value, specified in the case of `set:'replace'`
209
+ */
210
+ oldValue?: V;
211
+ /**
212
+ * The results of a {@link LRUCache#has} operation
213
+ *
214
+ * - hit: the item was found in the cache
215
+ * - stale: the item was found in the cache, but is stale
216
+ * - miss: the item was not found in the cache
217
+ */
218
+ has?: 'hit' | 'stale' | 'miss';
219
+ /**
220
+ * The status of a {@link LRUCache#fetch} operation.
221
+ * Note that this can change as the underlying fetch() moves through
222
+ * various states.
223
+ *
224
+ * - inflight: there is another fetch() for this key which is in process
225
+ * - get: there is no {@link OptionsBase.fetchMethod}, so
226
+ * {@link LRUCache#get} was called.
227
+ * - miss: the item is not in cache, and will be fetched.
228
+ * - hit: the item is in the cache, and was resolved immediately.
229
+ * - stale: the item is in the cache, but stale.
230
+ * - refresh: the item is in the cache, and not stale, but
231
+ * {@link FetchOptions.forceRefresh} was specified.
232
+ */
233
+ fetch?: 'get' | 'inflight' | 'miss' | 'hit' | 'stale' | 'refresh';
234
+ /**
235
+ * `forceRefresh` option was used for either a fetch or memo operation
236
+ */
237
+ forceRefresh?: boolean;
238
+ /**
239
+ * The {@link OptionsBase.fetchMethod} was called
240
+ */
241
+ fetchDispatched?: true;
242
+ /**
243
+ * The cached value was updated after a successful call to
244
+ * {@link OptionsBase.fetchMethod}
245
+ */
246
+ fetchUpdated?: true;
247
+ /**
248
+ * The reason for a fetch() rejection. Either the error raised by the
249
+ * {@link OptionsBase.fetchMethod}, or the reason for an
250
+ * AbortSignal.
251
+ */
252
+ fetchError?: Error;
253
+ /**
254
+ * The fetch received an abort signal
255
+ */
256
+ fetchAborted?: true;
257
+ /**
258
+ * The abort signal received was ignored, and the fetch was allowed to
259
+ * continue in the background.
260
+ */
261
+ fetchAbortIgnored?: true;
262
+ /**
263
+ * The fetchMethod promise resolved successfully
264
+ */
265
+ fetchResolved?: true;
266
+ /**
267
+ * The fetchMethod promise was rejected
268
+ */
269
+ fetchRejected?: true;
270
+ /**
271
+ * The status of a {@link LRUCache#get} operation.
272
+ *
273
+ * - fetching: The item is currently being fetched. If a previous value
274
+ * is present and allowed, that will be returned.
275
+ * - stale: The item is in the cache, and is stale. If it was returned,
276
+ * then the `returnedStale` flag will be set.
277
+ * - stale-fetching: The value is being fetched in the background, but is
278
+ * currently stale. If the stale value was returned, then the
279
+ * `returnedStale` flag will be set.
280
+ * - hit: the item is in the cache
281
+ * - miss: the item is not in the cache
282
+ */
283
+ get?: 'stale' | 'hit' | 'miss' | 'fetching' | 'stale-fetching';
284
+ /**
285
+ * A fetch or get operation returned a stale value.
286
+ */
287
+ returnedStale?: true;
288
+ /**
289
+ * A tracingChannel trace was started for this operation
290
+ */
291
+ trace?: boolean;
292
+ }
293
+ /**
294
+ * options which override the options set in the LRUCache constructor
295
+ * when calling {@link LRUCache#fetch}.
296
+ *
297
+ * This is the union of {@link GetOptions} and {@link SetOptions}, plus
298
+ * {@link OptionsBase.noDeleteOnFetchRejection},
299
+ * {@link OptionsBase.allowStaleOnFetchRejection},
300
+ * {@link FetchOptions.forceRefresh}, and
301
+ * {@link FetcherOptions.context}
302
+ *
303
+ * Any of these may be modified in the {@link OptionsBase.fetchMethod}
304
+ * function, but the {@link GetOptions} fields will of course have no
305
+ * effect, as the {@link LRUCache#get} call already happened by the time
306
+ * the fetchMethod is called.
307
+ */
308
+ interface FetcherFetchOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
309
+ status?: Status<K, V>;
310
+ size?: Size;
311
+ }
312
+ /**
313
+ * Options that may be passed to the {@link LRUCache#fetch} method.
314
+ */
315
+ interface FetchOptions<K, V, FC> extends FetcherFetchOptions<K, V, FC> {
316
+ /**
317
+ * Set to true to force a re-load of the existing data, even if it
318
+ * is not yet stale.
319
+ */
320
+ forceRefresh?: boolean;
321
+ /**
322
+ * Context provided to the {@link OptionsBase.fetchMethod} as
323
+ * the {@link FetcherOptions.context} param.
324
+ *
325
+ * If the FC type is specified as unknown (the default),
326
+ * undefined or void, then this is optional. Otherwise, it will
327
+ * be required.
328
+ */
329
+ context?: FC;
330
+ signal?: AbortSignal;
331
+ status?: Status<K, V>;
332
+ }
333
+ /**
334
+ * Options provided to {@link LRUCache#fetch} when the FC type is something
335
+ * other than `unknown`, `undefined`, or `void`
336
+ */
337
+ interface FetchOptionsWithContext<K, V, FC> extends FetchOptions<K, V, FC> {
338
+ context: FC;
339
+ }
340
+ /**
341
+ * Options provided to {@link LRUCache#fetch} when the FC type is
342
+ * `undefined` or `void`
343
+ */
344
+ interface FetchOptionsNoContext<K, V> extends FetchOptions<K, V, undefined> {
345
+ context?: undefined;
346
+ }
347
+ interface MemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
348
+ /**
349
+ * Set to true to force a re-load of the existing data, even if it
350
+ * is not yet stale.
351
+ */
352
+ forceRefresh?: boolean;
353
+ /**
354
+ * Context provided to the {@link OptionsBase.memoMethod} as
355
+ * the {@link MemoizerOptions.context} param.
356
+ *
357
+ * If the FC type is specified as unknown (the default),
358
+ * undefined or void, then this is optional. Otherwise, it will
359
+ * be required.
360
+ */
361
+ context?: FC;
362
+ status?: Status<K, V>;
363
+ }
364
+ /**
365
+ * Options provided to {@link LRUCache#memo} when the FC type is something
366
+ * other than `unknown`, `undefined`, or `void`
367
+ */
368
+ interface MemoOptionsWithContext<K, V, FC> extends MemoOptions<K, V, FC> {
369
+ context: FC;
370
+ }
371
+ /**
372
+ * Options provided to {@link LRUCache#memo} when the FC type is
373
+ * `undefined` or `void`
374
+ */
375
+ interface MemoOptionsNoContext<K, V> extends MemoOptions<K, V, undefined> {
376
+ context?: undefined;
377
+ }
378
+ /**
379
+ * Options provided to the
380
+ * {@link OptionsBase.memoMethod} function.
381
+ */
382
+ interface MemoizerOptions<K, V, FC = unknown> {
383
+ options: MemoizerMemoOptions<K, V, FC>;
384
+ /**
385
+ * Object provided in the {@link MemoOptions.context} option to
386
+ * {@link LRUCache#memo}
387
+ */
388
+ context: FC;
389
+ }
390
+ /**
391
+ * options which override the options set in the LRUCache constructor
392
+ * when calling {@link LRUCache#memo}.
393
+ *
394
+ * This is the union of {@link GetOptions} and {@link SetOptions}, plus
395
+ * {@link MemoOptions.forceRefresh}, and
396
+ * {@link MemoOptions.context}
397
+ *
398
+ * Any of these may be modified in the {@link OptionsBase.memoMethod}
399
+ * function, but the {@link GetOptions} fields will of course have no
400
+ * effect, as the {@link LRUCache#get} call already happened by the time
401
+ * the memoMethod is called.
402
+ */
403
+ interface MemoizerMemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
404
+ status?: Status<K, V>;
405
+ size?: Size;
406
+ start?: Milliseconds;
407
+ }
408
+ /**
409
+ * Options that may be passed to the {@link LRUCache#has} method.
410
+ */
411
+ interface HasOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'updateAgeOnHas'> {
412
+ status?: Status<K, V>;
413
+ }
414
+ /**
415
+ * Options that may be passed to the {@link LRUCache#get} method.
416
+ */
417
+ interface GetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet'> {
418
+ status?: Status<K, V>;
419
+ }
420
+ /**
421
+ * Options that may be passed to the {@link LRUCache#peek} method.
422
+ */
423
+ interface PeekOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale'> {
424
+ status?: Status<K, V>;
425
+ }
426
+ /**
427
+ * Options that may be passed to the {@link LRUCache#set} method.
428
+ */
429
+ interface SetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
430
+ /**
431
+ * If size tracking is enabled, then setting an explicit size
432
+ * in the {@link LRUCache#set} call will prevent calling the
433
+ * {@link OptionsBase.sizeCalculation} function.
434
+ */
435
+ size?: Size;
436
+ /**
437
+ * If TTL tracking is enabled, then setting an explicit start
438
+ * time in the {@link LRUCache#set} call will override the
439
+ * default time from `performance.now()` or `Date.now()`.
440
+ *
441
+ * Note that it must be a valid value for whichever time-tracking
442
+ * method is in use.
443
+ */
444
+ start?: Milliseconds;
445
+ status?: Status<K, V>;
446
+ }
447
+ /**
448
+ * The type signature for the {@link OptionsBase.fetchMethod} option.
449
+ */
450
+ type Fetcher<K, V, FC = unknown> = (key: K, staleValue: V | undefined, options: FetcherOptions<K, V, FC>) => Promise<V | undefined | void> | V | undefined | void;
451
+ /**
452
+ * the type signature for the {@link OptionsBase.memoMethod} option.
453
+ */
454
+ type Memoizer<K, V, FC = unknown> = (key: K, staleValue: V | undefined, options: MemoizerOptions<K, V, FC>) => V;
455
+ /**
456
+ * Options which may be passed to the {@link LRUCache} constructor.
457
+ *
458
+ * Most of these may be overridden in the various options that use
459
+ * them.
460
+ *
461
+ * Despite all being technically optional, the constructor requires that
462
+ * a cache is at minimum limited by one or more of {@link OptionsBase.max},
463
+ * {@link OptionsBase.ttl}, or {@link OptionsBase.maxSize}.
464
+ *
465
+ * If {@link OptionsBase.ttl} is used alone, then it is strongly advised
466
+ * (and in fact required by the type definitions here) that the cache
467
+ * also set {@link OptionsBase.ttlAutopurge}, to prevent potentially
468
+ * unbounded storage.
469
+ *
470
+ * All options are also available on the {@link LRUCache} instance, making
471
+ * it safe to pass an LRUCache instance as the options argumemnt to
472
+ * make another empty cache of the same type.
473
+ *
474
+ * Some options are marked as read-only, because changing them after
475
+ * instantiation is not safe. Changing any of the other options will of
476
+ * course only have an effect on subsequent method calls.
477
+ */
478
+ interface OptionsBase<K, V, FC> {
479
+ /**
480
+ * The maximum number of items to store in the cache before evicting
481
+ * old entries. This is read-only on the {@link LRUCache} instance,
482
+ * and may not be overridden.
483
+ *
484
+ * If set, then storage space will be pre-allocated at construction
485
+ * time, and the cache will perform significantly faster.
486
+ *
487
+ * Note that significantly fewer items may be stored, if
488
+ * {@link OptionsBase.maxSize} and/or {@link OptionsBase.ttl} are also
489
+ * set.
490
+ *
491
+ * **It is strongly recommended to set a `max` to prevent unbounded growth
492
+ * of the cache.**
493
+ */
494
+ max?: Count;
495
+ /**
496
+ * Max time in milliseconds for items to live in cache before they are
497
+ * considered stale. Note that stale items are NOT preemptively removed by
498
+ * default, and MAY live in the cache, contributing to its LRU max, long
499
+ * after they have expired, unless {@link OptionsBase.ttlAutopurge} is
500
+ * set.
501
+ *
502
+ * If set to `0` (the default value), then that means "do not track
503
+ * TTL", not "expire immediately".
504
+ *
505
+ * Also, as this cache is optimized for LRU/MRU operations, some of
506
+ * the staleness/TTL checks will reduce performance, as they will incur
507
+ * overhead by deleting items.
508
+ *
509
+ * This is not primarily a TTL cache, and does not make strong TTL
510
+ * guarantees. There is no pre-emptive pruning of expired items, but you
511
+ * _may_ set a TTL on the cache, and it will treat expired items as missing
512
+ * when they are fetched, and delete them.
513
+ *
514
+ * Optional, but must be a non-negative integer in ms if specified.
515
+ *
516
+ * This may be overridden by passing an options object to `cache.set()`.
517
+ *
518
+ * At least one of `max`, `maxSize`, or `TTL` is required. This must be a
519
+ * positive integer if set.
520
+ *
521
+ * Even if ttl tracking is enabled, **it is strongly recommended to set a
522
+ * `max` to prevent unbounded growth of the cache.**
523
+ *
524
+ * If ttl tracking is enabled, and `max` and `maxSize` are not set,
525
+ * and `ttlAutopurge` is not set, then a warning will be emitted
526
+ * cautioning about the potential for unbounded memory consumption.
527
+ * (The TypeScript definitions will also discourage this.)
528
+ */
529
+ ttl?: Milliseconds;
530
+ /**
531
+ * Minimum amount of time in ms in which to check for staleness.
532
+ * Defaults to 1, which means that the current time is checked
533
+ * at most once per millisecond.
534
+ *
535
+ * Set to 0 to check the current time every time staleness is tested.
536
+ * (This reduces performance, and is theoretically unnecessary.)
537
+ *
538
+ * Setting this to a higher value will improve performance somewhat
539
+ * while using ttl tracking, albeit at the expense of keeping stale
540
+ * items around a bit longer than their TTLs would indicate.
541
+ *
542
+ * @default 1
543
+ */
544
+ ttlResolution?: Milliseconds;
545
+ /**
546
+ * Preemptively remove stale items from the cache.
547
+ *
548
+ * Note that this may *significantly* degrade performance, especially if
549
+ * the cache is storing a large number of items. It is almost always best
550
+ * to just leave the stale items in the cache, and let them fall out as new
551
+ * items are added.
552
+ *
553
+ * Note that this means that {@link OptionsBase.allowStale} is a bit
554
+ * pointless, as stale items will be deleted almost as soon as they
555
+ * expire.
556
+ *
557
+ * Use with caution!
558
+ */
559
+ ttlAutopurge?: boolean;
560
+ /**
561
+ * When using time-expiring entries with `ttl`, setting this to `true` will
562
+ * make each item's age reset to 0 whenever it is retrieved from cache with
563
+ * {@link LRUCache#get}, causing it to not expire. (It can still fall out
564
+ * of cache based on recency of use, of course.)
565
+ *
566
+ * Has no effect if {@link OptionsBase.ttl} is not set.
567
+ *
568
+ * This may be overridden by passing an options object to `cache.get()`.
569
+ */
570
+ updateAgeOnGet?: boolean;
571
+ /**
572
+ * When using time-expiring entries with `ttl`, setting this to `true` will
573
+ * make each item's age reset to 0 whenever its presence in the cache is
574
+ * checked with {@link LRUCache#has}, causing it to not expire. (It can
575
+ * still fall out of cache based on recency of use, of course.)
576
+ *
577
+ * Has no effect if {@link OptionsBase.ttl} is not set.
578
+ */
579
+ updateAgeOnHas?: boolean;
580
+ /**
581
+ * Allow {@link LRUCache#get} and {@link LRUCache#fetch} calls to return
582
+ * stale data, if available.
583
+ *
584
+ * By default, if you set `ttl`, stale items will only be deleted from the
585
+ * cache when you `get(key)`. That is, it's not preemptively pruning items,
586
+ * unless {@link OptionsBase.ttlAutopurge} is set.
587
+ *
588
+ * If you set `allowStale:true`, it'll return the stale value *as well as*
589
+ * deleting it. If you don't set this, then it'll return `undefined` when
590
+ * you try to get a stale entry.
591
+ *
592
+ * Note that when a stale entry is fetched, _even if it is returned due to
593
+ * `allowStale` being set_, it is removed from the cache immediately. You
594
+ * can suppress this behavior by setting
595
+ * {@link OptionsBase.noDeleteOnStaleGet}, either in the constructor, or in
596
+ * the options provided to {@link LRUCache#get}.
597
+ *
598
+ * This may be overridden by passing an options object to `cache.get()`.
599
+ * The `cache.has()` method will always return `false` for stale items.
600
+ *
601
+ * Only relevant if a ttl is set.
602
+ */
603
+ allowStale?: boolean;
604
+ /**
605
+ * Function that is called on items when they are dropped from the
606
+ * cache, as `dispose(value, key, reason)`.
607
+ *
608
+ * This can be handy if you want to close file descriptors or do
609
+ * other cleanup tasks when items are no longer stored in the cache.
610
+ *
611
+ * **NOTE**: It is called _before_ the item has been fully removed
612
+ * from the cache, so if you want to put it right back in, you need
613
+ * to wait until the next tick. If you try to add it back in during
614
+ * the `dispose()` function call, it will break things in subtle and
615
+ * weird ways.
616
+ *
617
+ * Unlike several other options, this may _not_ be overridden by
618
+ * passing an option to `set()`, for performance reasons.
619
+ *
620
+ * The `reason` will be one of the following strings, corresponding
621
+ * to the reason for the item's deletion:
622
+ *
623
+ * - `evict` Item was evicted to make space for a new addition
624
+ * - `set` Item was overwritten by a new value
625
+ * - `expire` Item expired its TTL
626
+ * - `fetch` Item was deleted due to a failed or aborted fetch, or a
627
+ * fetchMethod returning `undefined.
628
+ * - `delete` Item was removed by explicit `cache.delete(key)`,
629
+ * `cache.clear()`, or `cache.set(key, undefined)`.
630
+ */
631
+ dispose?: Disposer<K, V>;
632
+ /**
633
+ * Function that is called when new items are inserted into the cache,
634
+ * as `onInsert(value, key, reason)`.
635
+ *
636
+ * This can be useful if you need to perform actions when an item is
637
+ * added, such as logging or tracking insertions.
638
+ *
639
+ * Unlike some other options, this may _not_ be overridden by passing
640
+ * an option to `set()`, for performance and consistency reasons.
641
+ */
642
+ onInsert?: Inserter<K, V>;
643
+ /**
644
+ * The same as {@link OptionsBase.dispose}, but called *after* the entry
645
+ * is completely removed and the cache is once again in a clean state.
646
+ *
647
+ * It is safe to add an item right back into the cache at this point.
648
+ * However, note that it is *very* easy to inadvertently create infinite
649
+ * recursion this way.
650
+ */
651
+ disposeAfter?: Disposer<K, V>;
652
+ /**
653
+ * Set to true to suppress calling the
654
+ * {@link OptionsBase.dispose} function if the entry key is
655
+ * still accessible within the cache.
656
+ *
657
+ * This may be overridden by passing an options object to
658
+ * {@link LRUCache#set}.
659
+ *
660
+ * Only relevant if `dispose` or `disposeAfter` are set.
661
+ */
662
+ noDisposeOnSet?: boolean;
663
+ /**
664
+ * Boolean flag to tell the cache to not update the TTL when setting a new
665
+ * value for an existing key (ie, when updating a value rather than
666
+ * inserting a new value). Note that the TTL value is _always_ set (if
667
+ * provided) when adding a new entry into the cache.
668
+ *
669
+ * Has no effect if a {@link OptionsBase.ttl} is not set.
670
+ *
671
+ * May be passed as an option to {@link LRUCache#set}.
672
+ */
673
+ noUpdateTTL?: boolean;
674
+ /**
675
+ * Set to a positive integer to track the sizes of items added to the
676
+ * cache, and automatically evict items in order to stay below this size.
677
+ * Note that this may result in fewer than `max` items being stored.
678
+ *
679
+ * Attempting to add an item to the cache whose calculated size is greater
680
+ * that this amount will be a no-op. The item will not be cached, and no
681
+ * other items will be evicted.
682
+ *
683
+ * Optional, must be a positive integer if provided.
684
+ *
685
+ * Sets `maxEntrySize` to the same value, unless a different value is
686
+ * provided for `maxEntrySize`.
687
+ *
688
+ * At least one of `max`, `maxSize`, or `TTL` is required. This must be a
689
+ * positive integer if set.
690
+ *
691
+ * Even if size tracking is enabled, **it is strongly recommended to set a
692
+ * `max` to prevent unbounded growth of the cache.**
693
+ *
694
+ * Note also that size tracking can negatively impact performance,
695
+ * though for most cases, only minimally.
696
+ */
697
+ maxSize?: Size;
698
+ /**
699
+ * The maximum allowed size for any single item in the cache.
700
+ *
701
+ * If a larger item is passed to {@link LRUCache#set} or returned by a
702
+ * {@link OptionsBase.fetchMethod} or {@link OptionsBase.memoMethod}, then
703
+ * it will not be stored in the cache.
704
+ *
705
+ * Attempting to add an item whose calculated size is greater than
706
+ * this amount will not cache the item or evict any old items, but
707
+ * WILL delete an existing value if one is already present.
708
+ *
709
+ * Optional, must be a positive integer if provided. Defaults to
710
+ * the value of `maxSize` if provided.
711
+ */
712
+ maxEntrySize?: Size;
713
+ /**
714
+ * A function that returns a number indicating the item's size.
715
+ *
716
+ * Requires {@link OptionsBase.maxSize} to be set.
717
+ *
718
+ * If not provided, and {@link OptionsBase.maxSize} or
719
+ * {@link OptionsBase.maxEntrySize} are set, then all
720
+ * {@link LRUCache#set} calls **must** provide an explicit
721
+ * {@link SetOptions.size} or sizeCalculation param.
722
+ */
723
+ sizeCalculation?: SizeCalculator<K, V>;
724
+ /**
725
+ * Method that provides the implementation for {@link LRUCache#fetch}
726
+ *
727
+ * ```ts
728
+ * fetchMethod(key, staleValue, { signal, options, context })
729
+ * ```
730
+ *
731
+ * If `fetchMethod` is not provided, then `cache.fetch(key)` is equivalent
732
+ * to `Promise.resolve(cache.get(key))`.
733
+ *
734
+ * If at any time, `signal.aborted` is set to `true`, or if the
735
+ * `signal.onabort` method is called, or if it emits an `'abort'` event
736
+ * which you can listen to with `addEventListener`, then that means that
737
+ * the fetch should be abandoned. This may be passed along to async
738
+ * functions aware of AbortController/AbortSignal behavior.
739
+ *
740
+ * The `fetchMethod` should **only** return `undefined` or a Promise
741
+ * resolving to `undefined` if the AbortController signaled an `abort`
742
+ * event. In all other cases, it should return or resolve to a value
743
+ * suitable for adding to the cache.
744
+ *
745
+ * The `options` object is a union of the options that may be provided to
746
+ * `set()` and `get()`. If they are modified, then that will result in
747
+ * modifying the settings to `cache.set()` when the value is resolved, and
748
+ * in the case of
749
+ * {@link OptionsBase.noDeleteOnFetchRejection} and
750
+ * {@link OptionsBase.allowStaleOnFetchRejection}, the handling of
751
+ * `fetchMethod` failures.
752
+ *
753
+ * For example, a DNS cache may update the TTL based on the value returned
754
+ * from a remote DNS server by changing `options.ttl` in the `fetchMethod`.
755
+ */
756
+ fetchMethod?: Fetcher<K, V, FC>;
757
+ /**
758
+ * Method that provides the implementation for {@link LRUCache#memo}
759
+ */
760
+ memoMethod?: Memoizer<K, V, FC>;
761
+ /**
762
+ * Set to true to suppress the deletion of stale data when a
763
+ * {@link OptionsBase.fetchMethod} returns a rejected promise.
764
+ */
765
+ noDeleteOnFetchRejection?: boolean;
766
+ /**
767
+ * Do not delete stale items when they are retrieved with
768
+ * {@link LRUCache#get}.
769
+ *
770
+ * Note that the `get` return value will still be `undefined`
771
+ * unless {@link OptionsBase.allowStale} is true.
772
+ *
773
+ * When using time-expiring entries with `ttl`, by default stale
774
+ * items will be removed from the cache when the key is accessed
775
+ * with `cache.get()`.
776
+ *
777
+ * Setting this option will cause stale items to remain in the cache, until
778
+ * they are explicitly deleted with `cache.delete(key)`, or retrieved with
779
+ * `noDeleteOnStaleGet` set to `false`.
780
+ *
781
+ * This may be overridden by passing an options object to `cache.get()`.
782
+ *
783
+ * Only relevant if a ttl is used.
784
+ */
785
+ noDeleteOnStaleGet?: boolean;
786
+ /**
787
+ * Set to true to allow returning stale data when a
788
+ * {@link OptionsBase.fetchMethod} throws an error or returns a rejected
789
+ * promise.
790
+ *
791
+ * This differs from using {@link OptionsBase.allowStale} in that stale
792
+ * data will ONLY be returned in the case that the {@link LRUCache#fetch}
793
+ * fails, not any other times.
794
+ *
795
+ * If a `fetchMethod` fails, and there is no stale value available, the
796
+ * `fetch()` will resolve to `undefined`. Ie, all `fetchMethod` errors are
797
+ * suppressed.
798
+ *
799
+ * Implies `noDeleteOnFetchRejection`.
800
+ *
801
+ * This may be set in calls to `fetch()`, or defaulted on the constructor,
802
+ * or overridden by modifying the options object in the `fetchMethod`.
803
+ */
804
+ allowStaleOnFetchRejection?: boolean;
805
+ /**
806
+ * Set to true to return a stale value from the cache when the
807
+ * `AbortSignal` passed to the {@link OptionsBase.fetchMethod} dispatches
808
+ * an `'abort'` event, whether user-triggered, or due to internal cache
809
+ * behavior.
810
+ *
811
+ * Unless {@link OptionsBase.ignoreFetchAbort} is also set, the underlying
812
+ * {@link OptionsBase.fetchMethod} will still be considered canceled, and
813
+ * any value it returns will be ignored and not cached.
814
+ *
815
+ * Caveat: since fetches are aborted when a new value is explicitly
816
+ * set in the cache, this can lead to fetch returning a stale value,
817
+ * since that was the fallback value _at the moment the `fetch()` was
818
+ * initiated_, even though the new updated value is now present in
819
+ * the cache.
820
+ *
821
+ * For example:
822
+ *
823
+ * ```ts
824
+ * const cache = new LRUCache<string, any>({
825
+ * ttl: 100,
826
+ * fetchMethod: async (url, oldValue, { signal }) => {
827
+ * const res = await fetch(url, { signal })
828
+ * return await res.json()
829
+ * }
830
+ * })
831
+ * cache.set('https://example.com/', { some: 'data' })
832
+ * // 100ms go by...
833
+ * const result = cache.fetch('https://example.com/')
834
+ * cache.set('https://example.com/', { other: 'thing' })
835
+ * console.log(await result) // { some: 'data' }
836
+ * console.log(cache.get('https://example.com/')) // { other: 'thing' }
837
+ * ```
838
+ */
839
+ allowStaleOnFetchAbort?: boolean;
840
+ /**
841
+ * Set to true to ignore the `abort` event emitted by the `AbortSignal`
842
+ * object passed to {@link OptionsBase.fetchMethod}, and still cache the
843
+ * resulting resolution value, as long as it is not `undefined`.
844
+ *
845
+ * When used on its own, this means aborted {@link LRUCache#fetch} calls
846
+ * are not immediately resolved or rejected when they are aborted, and
847
+ * instead take the full time to await.
848
+ *
849
+ * When used with {@link OptionsBase.allowStaleOnFetchAbort}, aborted
850
+ * {@link LRUCache#fetch} calls will resolve immediately to their stale
851
+ * cached value or `undefined`, and will continue to process and eventually
852
+ * update the cache when they resolve, as long as the resulting value is
853
+ * not `undefined`, thus supporting a "return stale on timeout while
854
+ * refreshing" mechanism by passing `AbortSignal.timeout(n)` as the signal.
855
+ *
856
+ * For example:
857
+ *
858
+ * ```ts
859
+ * const c = new LRUCache({
860
+ * ttl: 100,
861
+ * ignoreFetchAbort: true,
862
+ * allowStaleOnFetchAbort: true,
863
+ * fetchMethod: async (key, oldValue, { signal }) => {
864
+ * // note: do NOT pass the signal to fetch()!
865
+ * // let's say this fetch can take a long time.
866
+ * const res = await fetch(`https://slow-backend-server/${key}`)
867
+ * return await res.json()
868
+ * },
869
+ * })
870
+ *
871
+ * // this will return the stale value after 100ms, while still
872
+ * // updating in the background for next time.
873
+ * const val = await c.fetch('key', { signal: AbortSignal.timeout(100) })
874
+ * ```
875
+ *
876
+ * **Note**: regardless of this setting, an `abort` event _is still
877
+ * emitted on the `AbortSignal` object_, so may result in invalid results
878
+ * when passed to other underlying APIs that use AbortSignals.
879
+ *
880
+ * This may be overridden in the {@link OptionsBase.fetchMethod} or the
881
+ * call to {@link LRUCache#fetch}.
882
+ */
883
+ ignoreFetchAbort?: boolean;
884
+ /**
885
+ * In some cases, you may want to swap out the performance/Date object
886
+ * used for TTL tracking. This should almost certainly NOT be done in
887
+ * production environments!
888
+ *
889
+ * This value defaults to `global.performance` if it has a `now()` method,
890
+ * or the `global.Date` object otherwise.
891
+ */
892
+ perf?: Perf;
893
+ }
894
+ interface OptionsMaxLimit<K, V, FC> extends OptionsBase<K, V, FC> {
895
+ max: Count;
896
+ }
897
+ interface OptionsTTLLimit<K, V, FC> extends OptionsBase<K, V, FC> {
898
+ ttl: Milliseconds;
899
+ ttlAutopurge: boolean;
900
+ }
901
+ interface OptionsSizeLimit<K, V, FC> extends OptionsBase<K, V, FC> {
902
+ maxSize: Size;
903
+ }
904
+ /**
905
+ * The valid safe options for the {@link LRUCache} constructor
906
+ */
907
+ type Options<K, V, FC> = OptionsMaxLimit<K, V, FC> | OptionsSizeLimit<K, V, FC> | OptionsTTLLimit<K, V, FC>;
908
+ /**
909
+ * Entry objects used by {@link LRUCache#load} and {@link LRUCache#dump},
910
+ * and returned by {@link LRUCache#info}.
911
+ */
912
+ interface Entry<V> {
913
+ value: V;
914
+ ttl?: Milliseconds;
915
+ size?: Size;
916
+ start?: Milliseconds;
917
+ }
918
+ }
919
+ /**
920
+ * Default export, the thing you're using this module to get.
921
+ *
922
+ * The `K` and `V` types define the key and value types, respectively. The
923
+ * optional `FC` type defines the type of the `context` object passed to
924
+ * `cache.fetch()` and `cache.memo()`.
925
+ *
926
+ * Keys and values **must not** be `null` or `undefined`.
927
+ *
928
+ * All properties from the options object (with the exception of `max`,
929
+ * `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
930
+ * added as normal public members. (The listed options are read-only getters.)
931
+ *
932
+ * Changing any of these will alter the defaults for subsequent method calls.
933
+ */
934
+ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
935
+ #private;
936
+ /**
937
+ * {@link LRUCache.OptionsBase.perf}
938
+ */
939
+ get perf(): Perf;
940
+ /**
941
+ * {@link LRUCache.OptionsBase.ttl}
942
+ */
943
+ ttl: LRUCache.Milliseconds;
944
+ /**
945
+ * {@link LRUCache.OptionsBase.ttlResolution}
946
+ */
947
+ ttlResolution: LRUCache.Milliseconds;
948
+ /**
949
+ * {@link LRUCache.OptionsBase.ttlAutopurge}
950
+ */
951
+ ttlAutopurge: boolean;
952
+ /**
953
+ * {@link LRUCache.OptionsBase.updateAgeOnGet}
954
+ */
955
+ updateAgeOnGet: boolean;
956
+ /**
957
+ * {@link LRUCache.OptionsBase.updateAgeOnHas}
958
+ */
959
+ updateAgeOnHas: boolean;
960
+ /**
961
+ * {@link LRUCache.OptionsBase.allowStale}
962
+ */
963
+ allowStale: boolean;
964
+ /**
965
+ * {@link LRUCache.OptionsBase.noDisposeOnSet}
966
+ */
967
+ noDisposeOnSet: boolean;
968
+ /**
969
+ * {@link LRUCache.OptionsBase.noUpdateTTL}
970
+ */
971
+ noUpdateTTL: boolean;
972
+ /**
973
+ * {@link LRUCache.OptionsBase.maxEntrySize}
974
+ */
975
+ maxEntrySize: LRUCache.Size;
976
+ /**
977
+ * {@link LRUCache.OptionsBase.sizeCalculation}
978
+ */
979
+ sizeCalculation?: LRUCache.SizeCalculator<K, V>;
980
+ /**
981
+ * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
982
+ */
983
+ noDeleteOnFetchRejection: boolean;
984
+ /**
985
+ * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
986
+ */
987
+ noDeleteOnStaleGet: boolean;
988
+ /**
989
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
990
+ */
991
+ allowStaleOnFetchAbort: boolean;
992
+ /**
993
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
994
+ */
995
+ allowStaleOnFetchRejection: boolean;
996
+ /**
997
+ * {@link LRUCache.OptionsBase.ignoreFetchAbort}
998
+ */
999
+ ignoreFetchAbort: boolean;
1000
+ /**
1001
+ * Do not call this method unless you need to inspect the
1002
+ * inner workings of the cache. If anything returned by this
1003
+ * object is modified in any way, strange breakage may occur.
1004
+ *
1005
+ * These fields are private for a reason!
1006
+ *
1007
+ * @internal
1008
+ */
1009
+ static unsafeExposeInternals<K extends {}, V extends {}, FC extends unknown = unknown>(c: LRUCache<K, V, FC>): {
1010
+ starts: ZeroArray | undefined;
1011
+ ttls: ZeroArray | undefined;
1012
+ autopurgeTimers: (NodeJS.Timeout | undefined)[] | undefined;
1013
+ sizes: ZeroArray | undefined;
1014
+ keyMap: Map<K, number>;
1015
+ keyList: (K | undefined)[];
1016
+ valList: (V | BackgroundFetch<V> | undefined)[];
1017
+ next: NumberArray;
1018
+ prev: NumberArray;
1019
+ readonly head: Index;
1020
+ readonly tail: Index;
1021
+ free: StackLike;
1022
+ isBackgroundFetch: (p: unknown) => p is BackgroundFetch<V>;
1023
+ backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: unknown) => BackgroundFetch<V>;
1024
+ moveToTail: (index: number) => void;
1025
+ indexes: (options?: {
1026
+ allowStale: boolean;
1027
+ }) => Generator<Index, void, unknown>;
1028
+ rindexes: (options?: {
1029
+ allowStale: boolean;
1030
+ }) => Generator<Index, void, unknown>;
1031
+ isStale: (index: number | undefined) => boolean;
1032
+ };
1033
+ /**
1034
+ * {@link LRUCache.OptionsBase.max} (read-only)
1035
+ */
1036
+ get max(): LRUCache.Count;
1037
+ /**
1038
+ * {@link LRUCache.OptionsBase.maxSize} (read-only)
1039
+ */
1040
+ get maxSize(): LRUCache.Count;
1041
+ /**
1042
+ * The total computed size of items in the cache (read-only)
1043
+ */
1044
+ get calculatedSize(): LRUCache.Size;
1045
+ /**
1046
+ * The number of items stored in the cache (read-only)
1047
+ */
1048
+ get size(): LRUCache.Count;
1049
+ /**
1050
+ * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
1051
+ */
1052
+ get fetchMethod(): LRUCache.Fetcher<K, V, FC> | undefined;
1053
+ get memoMethod(): LRUCache.Memoizer<K, V, FC> | undefined;
1054
+ /**
1055
+ * {@link LRUCache.OptionsBase.dispose} (read-only)
1056
+ */
1057
+ get dispose(): LRUCache.Disposer<K, V> | undefined;
1058
+ /**
1059
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
1060
+ */
1061
+ get onInsert(): LRUCache.Inserter<K, V> | undefined;
1062
+ /**
1063
+ * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
1064
+ */
1065
+ get disposeAfter(): LRUCache.Disposer<K, V> | undefined;
1066
+ constructor(options: LRUCache.Options<K, V, FC> | LRUCache<K, V, FC>);
1067
+ /**
1068
+ * Return the number of ms left in the item's TTL. If item is not in cache,
1069
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
1070
+ */
1071
+ getRemainingTTL(key: K): number;
1072
+ /**
1073
+ * Return a generator yielding `[key, value]` pairs,
1074
+ * in order from most recently used to least recently used.
1075
+ */
1076
+ entries(): Generator<[K, V], void, unknown>;
1077
+ /**
1078
+ * Inverse order version of {@link LRUCache.entries}
1079
+ *
1080
+ * Return a generator yielding `[key, value]` pairs,
1081
+ * in order from least recently used to most recently used.
1082
+ */
1083
+ rentries(): Generator<(K | V)[], void, unknown>;
1084
+ /**
1085
+ * Return a generator yielding the keys in the cache,
1086
+ * in order from most recently used to least recently used.
1087
+ */
1088
+ keys(): Generator<K, void, unknown>;
1089
+ /**
1090
+ * Inverse order version of {@link LRUCache.keys}
1091
+ *
1092
+ * Return a generator yielding the keys in the cache,
1093
+ * in order from least recently used to most recently used.
1094
+ */
1095
+ rkeys(): Generator<K, void, unknown>;
1096
+ /**
1097
+ * Return a generator yielding the values in the cache,
1098
+ * in order from most recently used to least recently used.
1099
+ */
1100
+ values(): Generator<V, void, unknown>;
1101
+ /**
1102
+ * Inverse order version of {@link LRUCache.values}
1103
+ *
1104
+ * Return a generator yielding the values in the cache,
1105
+ * in order from least recently used to most recently used.
1106
+ */
1107
+ rvalues(): Generator<V | undefined, void, unknown>;
1108
+ /**
1109
+ * Iterating over the cache itself yields the same results as
1110
+ * {@link LRUCache.entries}
1111
+ */
1112
+ [Symbol.iterator](): Generator<[K, V], void, unknown>;
1113
+ /**
1114
+ * A String value that is used in the creation of the default string
1115
+ * description of an object. Called by the built-in method
1116
+ * `Object.prototype.toString`.
1117
+ */
1118
+ [Symbol.toStringTag]: string;
1119
+ /**
1120
+ * Find a value for which the supplied fn method returns a truthy value,
1121
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
1122
+ */
1123
+ find(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => boolean, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
1124
+ /**
1125
+ * Call the supplied function on each item in the cache, in order from most
1126
+ * recently used to least recently used.
1127
+ *
1128
+ * `fn` is called as `fn(value, key, cache)`.
1129
+ *
1130
+ * If `thisp` is provided, function will be called in the `this`-context of
1131
+ * the provided object, or the cache if no `thisp` object is provided.
1132
+ *
1133
+ * Does not update age or recenty of use, or iterate over stale values.
1134
+ */
1135
+ forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
1136
+ /**
1137
+ * The same as {@link LRUCache.forEach} but items are iterated over in
1138
+ * reverse order. (ie, less recently used items are iterated over first.)
1139
+ */
1140
+ rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
1141
+ /**
1142
+ * Delete any stale entries. Returns true if anything was removed,
1143
+ * false otherwise.
1144
+ */
1145
+ purgeStale(): boolean;
1146
+ /**
1147
+ * Get the extended info about a given entry, to get its value, size, and
1148
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
1149
+ *
1150
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
1151
+ * serialization, the `start` value is always the current timestamp, and the
1152
+ * `ttl` is a calculated remaining time to live (negative if expired).
1153
+ *
1154
+ * Always returns stale values, if their info is found in the cache, so be
1155
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
1156
+ * if relevant.
1157
+ */
1158
+ info(key: K): LRUCache.Entry<V> | undefined;
1159
+ /**
1160
+ * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
1161
+ * passed to {@link LRUCache#load}.
1162
+ *
1163
+ * The `start` fields are calculated relative to a portable `Date.now()`
1164
+ * timestamp, even if `performance.now()` is available.
1165
+ *
1166
+ * Stale entries are always included in the `dump`, even if
1167
+ * {@link LRUCache.OptionsBase.allowStale} is false.
1168
+ *
1169
+ * Note: this returns an actual array, not a generator, so it can be more
1170
+ * easily passed around.
1171
+ */
1172
+ dump(): [K, LRUCache.Entry<V>][];
1173
+ /**
1174
+ * Reset the cache and load in the items in entries in the order listed.
1175
+ *
1176
+ * The shape of the resulting cache may be different if the same options are
1177
+ * not used in both caches.
1178
+ *
1179
+ * The `start` fields are assumed to be calculated relative to a portable
1180
+ * `Date.now()` timestamp, even if `performance.now()` is available.
1181
+ */
1182
+ load(arr: [K, LRUCache.Entry<V>][]): void;
1183
+ /**
1184
+ * Add a value to the cache.
1185
+ *
1186
+ * Note: if `undefined` is specified as a value, this is an alias for
1187
+ * {@link LRUCache#delete}
1188
+ *
1189
+ * Fields on the {@link LRUCache.SetOptions} options param will override
1190
+ * their corresponding values in the constructor options for the scope
1191
+ * of this single `set()` operation.
1192
+ *
1193
+ * If `start` is provided, then that will set the effective start
1194
+ * time for the TTL calculation. Note that this must be a previous
1195
+ * value of `performance.now()` if supported, or a previous value of
1196
+ * `Date.now()` if not.
1197
+ *
1198
+ * Options object may also include `size`, which will prevent
1199
+ * calling the `sizeCalculation` function and just use the specified
1200
+ * number if it is a positive integer, and `noDisposeOnSet` which
1201
+ * will prevent calling a `dispose` function in the case of
1202
+ * overwrites.
1203
+ *
1204
+ * If the `size` (or return value of `sizeCalculation`) for a given
1205
+ * entry is greater than `maxEntrySize`, then the item will not be
1206
+ * added to the cache.
1207
+ *
1208
+ * Will update the recency of the entry.
1209
+ *
1210
+ * If the value is `undefined`, then this is an alias for
1211
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
1212
+ */
1213
+ set(k: K, v: V | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
1214
+ /**
1215
+ * Evict the least recently used item, returning its value or
1216
+ * `undefined` if cache is empty.
1217
+ */
1218
+ pop(): V | undefined;
1219
+ /**
1220
+ * Check if a key is in the cache, without updating the recency of use.
1221
+ * Will return false if the item is stale, even though it is technically
1222
+ * in the cache.
1223
+ *
1224
+ * Check if a key is in the cache, without updating the recency of
1225
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
1226
+ * to `true` in either the options or the constructor.
1227
+ *
1228
+ * Will return `false` if the item is stale, even though it is technically in
1229
+ * the cache. The difference can be determined (if it matters) by using a
1230
+ * `status` argument, and inspecting the `has` field.
1231
+ *
1232
+ * Will not update item age unless
1233
+ * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
1234
+ */
1235
+ has(k: K, hasOptions?: LRUCache.HasOptions<K, V, FC>): boolean;
1236
+ /**
1237
+ * Like {@link LRUCache#get} but doesn't update recency or delete stale
1238
+ * items.
1239
+ *
1240
+ * Returns `undefined` if the item is stale, unless
1241
+ * {@link LRUCache.OptionsBase.allowStale} is set.
1242
+ */
1243
+ peek(k: K, peekOptions?: LRUCache.PeekOptions<K, V, FC>): V | undefined;
1244
+ /**
1245
+ * Make an asynchronous cached fetch using the
1246
+ * {@link LRUCache.OptionsBase.fetchMethod} function.
1247
+ *
1248
+ * If the value is in the cache and not stale, then the returned
1249
+ * Promise resolves to the value.
1250
+ *
1251
+ * If not in the cache, or beyond its TTL staleness, then
1252
+ * `fetchMethod(key, staleValue, { options, signal, context })` is
1253
+ * called, and the value returned will be added to the cache once
1254
+ * resolved.
1255
+ *
1256
+ * If called with `allowStale`, and an asynchronous fetch is
1257
+ * currently in progress to reload a stale value, then the former
1258
+ * stale value will be returned.
1259
+ *
1260
+ * If called with `forceRefresh`, then the cached item will be
1261
+ * re-fetched, even if it is not stale. However, if `allowStale` is also
1262
+ * set, then the old value will still be returned. This is useful
1263
+ * in cases where you want to force a reload of a cached value. If
1264
+ * a background fetch is already in progress, then `forceRefresh`
1265
+ * has no effect.
1266
+ *
1267
+ * If multiple fetches for the same key are issued, then they will all be
1268
+ * coalesced into a single call to fetchMethod.
1269
+ *
1270
+ * Note that this means that handling options such as
1271
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort},
1272
+ * {@link LRUCache.FetchOptions.signal},
1273
+ * and {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} will be
1274
+ * determined by the FIRST fetch() call for a given key.
1275
+ *
1276
+ * This is a known (fixable) shortcoming which will be addresed on when
1277
+ * someone complains about it, as the fix would involve added complexity and
1278
+ * may not be worth the costs for this edge case.
1279
+ *
1280
+ * If {@link LRUCache.OptionsBase.fetchMethod} is not specified, then this is
1281
+ * effectively an alias for `Promise.resolve(cache.get(key))`.
1282
+ *
1283
+ * When the fetch method resolves to a value, if the fetch has not
1284
+ * been aborted due to deletion, eviction, or being overwritten,
1285
+ * then it is added to the cache using the options provided.
1286
+ *
1287
+ * If the key is evicted or deleted before the `fetchMethod`
1288
+ * resolves, then the AbortSignal passed to the `fetchMethod` will
1289
+ * receive an `abort` event, and the promise returned by `fetch()`
1290
+ * will reject with the reason for the abort.
1291
+ *
1292
+ * If a `signal` is passed to the `fetch()` call, then aborting the
1293
+ * signal will abort the fetch and cause the `fetch()` promise to
1294
+ * reject with the reason provided.
1295
+ *
1296
+ * **Setting `context`**
1297
+ *
1298
+ * If an `FC` type is set to a type other than `unknown`, `void`, or
1299
+ * `undefined` in the {@link LRUCache} constructor, then all
1300
+ * calls to `cache.fetch()` _must_ provide a `context` option. If
1301
+ * set to `undefined` or `void`, then calls to fetch _must not_
1302
+ * provide a `context` option.
1303
+ *
1304
+ * The `context` param allows you to provide arbitrary data that
1305
+ * might be relevant in the course of fetching the data. It is only
1306
+ * relevant for the course of a single `fetch()` operation, and
1307
+ * discarded afterwards.
1308
+ *
1309
+ * **Note: `fetch()` calls are inflight-unique**
1310
+ *
1311
+ * If you call `fetch()` multiple times with the same key value,
1312
+ * then every call after the first will resolve on the same
1313
+ * promise<sup>1</sup>,
1314
+ * _even if they have different settings that would otherwise change
1315
+ * the behavior of the fetch_, such as `noDeleteOnFetchRejection`
1316
+ * or `ignoreFetchAbort`.
1317
+ *
1318
+ * In most cases, this is not a problem (in fact, only fetching
1319
+ * something once is what you probably want, if you're caching in
1320
+ * the first place). If you are changing the fetch() options
1321
+ * dramatically between runs, there's a good chance that you might
1322
+ * be trying to fit divergent semantics into a single object, and
1323
+ * would be better off with multiple cache instances.
1324
+ *
1325
+ * **1**: Ie, they're not the "same Promise", but they resolve at
1326
+ * the same time, because they're both waiting on the same
1327
+ * underlying fetchMethod response.
1328
+ */
1329
+ fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
1330
+ fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<undefined | V>;
1331
+ /**
1332
+ * In some cases, `cache.fetch()` may resolve to `undefined`, either because
1333
+ * a {@link LRUCache.OptionsBase#fetchMethod} was not provided (turning
1334
+ * `cache.fetch(k)` into just an async wrapper around `cache.get(k)`) or
1335
+ * because `ignoreFetchAbort` was specified (either to the constructor or
1336
+ * in the {@link LRUCache.FetchOptions}). Also, the
1337
+ * {@link LRUCache.OptionsBase.fetchMethod} may return `undefined` or `void`, making
1338
+ * the test even more complicated.
1339
+ *
1340
+ * Because inferring the cases where `undefined` might be returned are so
1341
+ * cumbersome, but testing for `undefined` can also be annoying, this method
1342
+ * can be used, which will reject if `this.fetch()` resolves to undefined.
1343
+ */
1344
+ forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
1345
+ forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<V>;
1346
+ /**
1347
+ * If the key is found in the cache, then this is equivalent to
1348
+ * {@link LRUCache#get}. If not, in the cache, then calculate the value using
1349
+ * the {@link LRUCache.OptionsBase.memoMethod}, and add it to the cache.
1350
+ *
1351
+ * If an `FC` type is set to a type other than `unknown`, `void`, or
1352
+ * `undefined` in the LRUCache constructor, then all calls to `cache.memo()`
1353
+ * _must_ provide a `context` option. If set to `undefined` or `void`, then
1354
+ * calls to memo _must not_ provide a `context` option.
1355
+ *
1356
+ * The `context` param allows you to provide arbitrary data that might be
1357
+ * relevant in the course of fetching the data. It is only relevant for the
1358
+ * course of a single `memo()` operation, and discarded afterwards.
1359
+ */
1360
+ memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
1361
+ memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : never): V;
1362
+ /**
1363
+ * Return a value from the cache. Will update the recency of the cache
1364
+ * entry found.
1365
+ *
1366
+ * If the key is not found, get() will return `undefined`.
1367
+ */
1368
+ get(k: K, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
1369
+ /**
1370
+ * Deletes a key out of the cache.
1371
+ *
1372
+ * Returns true if the key was deleted, false otherwise.
1373
+ */
1374
+ delete(k: K): boolean;
1375
+ /**
1376
+ * Clear the cache entirely, throwing away all values.
1377
+ */
1378
+ clear(): void;
1379
+ }
1380
+ //# sourceMappingURL=index.d.ts.map