@openclaw/whatsapp 2026.7.1-beta.2 → 2026.7.1-beta.4

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 (516) hide show
  1. package/dist/{access-control-88UPniDc.js → access-control-DYE5dXna.js} +5 -3
  2. package/dist/{accounts-DgViSyJx.js → accounts-4YgwroRU.js} +1 -1
  3. package/dist/{action-runtime-hqza0J8B.js → action-runtime-DPahAqxV.js} +2 -2
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/action-runtime.runtime.js +1 -1
  6. package/dist/{active-listener-CFwkn3ho.js → active-listener-B4SDebQ6.js} +1 -1
  7. package/dist/api.js +14 -13
  8. package/dist/{approval-handler.runtime-9_SV7vhc.js → approval-handler.runtime-DNWS4aYQ.js} +1 -1
  9. package/dist/auth-presence.js +1 -1
  10. package/dist/{auth-store-ECx4h57q.js → auth-store-Db-wfApd.js} +23 -13
  11. package/dist/call-tool-api.js +233 -0
  12. package/dist/{channel-fcXxWXic.js → channel-BWp7h1uY.js} +44 -18
  13. package/dist/channel-config-api.js +1 -1
  14. package/dist/channel-plugin-api.js +1 -1
  15. package/dist/{channel-react-action-Dgy9uUMl.js → channel-react-action-CKJHL_Wf.js} +3 -3
  16. package/dist/{channel.runtime-B4ThooGF.js → channel.runtime-CAssfx9p.js} +5 -5
  17. package/dist/{channel.setup-C_WEdyJR.js → channel.setup-CURc5rEt.js} +2 -2
  18. package/dist/{config-schema-CROZuhT-.js → config-schema-mBX2nmn1.js} +4 -0
  19. package/dist/{connection-controller-u-tfAFhJ.js → connection-controller-DkbrFSIn.js} +6 -5
  20. package/dist/connection-controller-registry-TSX_udJp.js +22 -0
  21. package/dist/contract-api.js +1 -1
  22. package/dist/{quoted-message-CpA_ujXK.js → group-session-key-BhC1RQOE.js} +31 -2
  23. package/dist/{identity-CmsTmkKR.js → identity-Dqft3mFA.js} +2 -1
  24. package/dist/index.js +9 -2
  25. package/dist/light-runtime-api.js +3 -3
  26. package/dist/{login-8lHwLmXj.js → login-C48y0jlx.js} +14 -7
  27. package/dist/{login-qr-BEZZqrTb.js → login-qr-BjId7dll.js} +7 -7
  28. package/dist/login-qr-runtime.js +1 -1
  29. package/dist/{monitor-BqkJ4MpT.js → monitor-DD8bXohk.js} +249 -160
  30. package/dist/runtime-api.js +9 -9
  31. package/dist/{send-i8Xk5mBQ.js → send-C5CpFcBG.js} +27 -9
  32. package/dist/{send-api-DndiBJhN.js → send-api-DLlXl8CH.js} +6 -5
  33. package/dist/{session-WU4SVP8f.js → session-DriaHt7V.js} +3 -3
  34. package/dist/{session-errors-CbsoQqoy.js → session-errors-BAj9D2La.js} +1 -22
  35. package/dist/{setup-core-KjSBbWX4.js → setup-core-DH-DFPLY.js} +4 -4
  36. package/dist/{setup-finalize-WedNP30s.js → setup-finalize-c8dl34sO.js} +3 -3
  37. package/dist/setup-plugin-api.js +1 -1
  38. package/dist/{setup-surface-IOdkbWsQ.js → setup-surface-DlWb0Z09.js} +3 -3
  39. package/dist/{socket-timing-DvMNkIge.js → socket-timing-DhbVFjah.js} +17 -5
  40. package/dist/{text-runtime-C88QkuU9.js → targets-runtime-C-GiVn6Y.js} +2 -3
  41. package/dist/text-runtime-DdX6-mC_.js +4 -0
  42. package/node_modules/@cacheable/memory/README.md +177 -0
  43. package/node_modules/@cacheable/memory/dist/index.cjs +867 -820
  44. package/node_modules/@cacheable/memory/dist/index.d.cts +382 -280
  45. package/node_modules/@cacheable/memory/dist/index.d.mts +412 -0
  46. package/node_modules/@cacheable/memory/dist/index.mjs +841 -0
  47. package/node_modules/@cacheable/memory/package.json +9 -9
  48. package/node_modules/@cacheable/utils/README.md +342 -8
  49. package/node_modules/@cacheable/utils/dist/index.cjs +1322 -619
  50. package/node_modules/@cacheable/utils/dist/index.d.cts +769 -173
  51. package/node_modules/@cacheable/utils/dist/index.d.mts +903 -0
  52. package/node_modules/@cacheable/utils/dist/index.mjs +1355 -0
  53. package/node_modules/@cacheable/utils/package.json +8 -8
  54. package/node_modules/@types/node/README.md +1 -1
  55. package/node_modules/@types/node/assert/strict.d.ts +10 -1
  56. package/node_modules/@types/node/assert.d.ts +144 -17
  57. package/node_modules/@types/node/async_hooks.d.ts +9 -9
  58. package/node_modules/@types/node/buffer.d.ts +64 -30
  59. package/node_modules/@types/node/child_process.d.ts +17 -21
  60. package/node_modules/@types/node/cluster.d.ts +13 -13
  61. package/node_modules/@types/node/console.d.ts +1 -1
  62. package/node_modules/@types/node/crypto.d.ts +471 -575
  63. package/node_modules/@types/node/diagnostics_channel.d.ts +274 -32
  64. package/node_modules/@types/node/dns.d.ts +15 -15
  65. package/node_modules/@types/node/events.d.ts +3 -3
  66. package/node_modules/@types/node/ffi.d.ts +486 -0
  67. package/node_modules/@types/node/fs/promises.d.ts +7 -4
  68. package/node_modules/@types/node/fs.d.ts +24 -18
  69. package/node_modules/@types/node/globals.d.ts +4 -4
  70. package/node_modules/@types/node/http.d.ts +30 -5
  71. package/node_modules/@types/node/http2.d.ts +5 -1
  72. package/node_modules/@types/node/index.d.ts +1 -3
  73. package/node_modules/@types/node/inspector.d.ts +1 -1
  74. package/node_modules/@types/node/module.d.ts +16 -45
  75. package/node_modules/@types/node/net.d.ts +1 -1
  76. package/node_modules/@types/node/os.d.ts +2 -2
  77. package/node_modules/@types/node/package.json +4 -4
  78. package/node_modules/@types/node/perf_hooks.d.ts +1 -9
  79. package/node_modules/@types/node/process.d.ts +25 -12
  80. package/node_modules/@types/node/quic.d.ts +92 -11
  81. package/node_modules/@types/node/readline.d.ts +12 -11
  82. package/node_modules/@types/node/repl.d.ts +10 -10
  83. package/node_modules/@types/node/sqlite.d.ts +56 -1
  84. package/node_modules/@types/node/stream/iter.d.ts +150 -0
  85. package/node_modules/@types/node/stream/promises.d.ts +2 -2
  86. package/node_modules/@types/node/stream/web.d.ts +1 -1
  87. package/node_modules/@types/node/stream.d.ts +37 -5
  88. package/node_modules/@types/node/test/reporters.d.ts +1 -1
  89. package/node_modules/@types/node/test.d.ts +120 -10
  90. package/node_modules/@types/node/tls.d.ts +1 -1
  91. package/node_modules/@types/node/ts5.6/index.d.ts +2 -4
  92. package/node_modules/@types/node/ts5.7/index.d.ts +1 -3
  93. package/node_modules/@types/node/url.d.ts +3 -3
  94. package/node_modules/@types/node/util/types.d.ts +1 -1
  95. package/node_modules/@types/node/util.d.ts +22 -22
  96. package/node_modules/@types/node/v8.d.ts +85 -3
  97. package/node_modules/@types/node/vm.d.ts +9 -9
  98. package/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
  99. package/node_modules/@types/node/worker_threads.d.ts +10 -12
  100. package/node_modules/@types/node/zlib.d.ts +3 -3
  101. package/node_modules/cacheable/README.md +309 -30
  102. package/node_modules/cacheable/dist/index.cjs +1307 -1153
  103. package/node_modules/cacheable/dist/index.d.cts +741 -469
  104. package/node_modules/cacheable/dist/index.d.mts +766 -0
  105. package/node_modules/cacheable/dist/index.mjs +1210 -0
  106. package/node_modules/cacheable/package.json +10 -10
  107. package/node_modules/content-type/README.md +32 -57
  108. package/node_modules/content-type/dist/index.d.ts +26 -0
  109. package/node_modules/content-type/dist/index.js +170 -0
  110. package/node_modules/content-type/dist/index.js.map +1 -0
  111. package/node_modules/content-type/package.json +35 -25
  112. package/node_modules/media-typer/README.md +19 -33
  113. package/node_modules/media-typer/dist/index.d.ts +29 -0
  114. package/node_modules/media-typer/dist/index.js +64 -0
  115. package/node_modules/media-typer/dist/index.js.map +1 -0
  116. package/node_modules/media-typer/package.json +37 -22
  117. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
  118. package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
  119. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
  120. package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
  121. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
  122. package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
  123. package/node_modules/music-metadata/package.json +5 -5
  124. package/node_modules/typebox/build/compile/validator.d.mts +2 -7
  125. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  126. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  127. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  128. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  129. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  130. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  131. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  132. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  133. package/node_modules/typebox/build/guard/guard.d.mts +4 -8
  134. package/node_modules/typebox/build/guard/guard.mjs +5 -13
  135. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  136. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  137. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  138. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  139. package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
  140. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  141. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  142. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  143. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  144. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  145. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  146. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  147. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  148. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  149. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  150. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  151. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  152. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  153. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  154. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  155. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  156. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  157. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  158. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  159. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  160. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  161. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  162. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  163. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  164. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  165. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  166. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  167. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  168. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  169. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  170. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  171. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  172. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  173. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  174. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  175. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  176. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  177. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  178. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  179. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  180. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  181. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  182. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  183. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  184. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  185. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  186. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  187. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  188. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  189. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  190. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  191. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  192. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  193. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  194. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  195. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  196. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  197. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  198. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  199. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  200. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  201. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  202. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  203. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  204. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  205. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  206. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  207. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  208. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  209. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
  210. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  211. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  212. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  213. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  214. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  215. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  216. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  217. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  218. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  219. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  220. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  221. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  222. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  223. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  224. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  225. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  226. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  227. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  228. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  229. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  230. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  231. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  232. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  233. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  234. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  235. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  236. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  237. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  238. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  239. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  240. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  241. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  242. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  243. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  244. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  245. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  246. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  247. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  248. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  249. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  250. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  251. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  252. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  253. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  254. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  255. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  256. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  257. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  258. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  259. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  260. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  261. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  262. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  263. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  264. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  265. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  266. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  267. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  268. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  269. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  270. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  271. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  272. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  273. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  274. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  275. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  276. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  277. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  278. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  279. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  280. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  281. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  282. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  283. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  284. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  285. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  286. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  287. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  288. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  289. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  290. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  291. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  292. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  293. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  294. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  295. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  296. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  297. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  298. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  299. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  300. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  301. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  302. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  303. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  304. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  305. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  306. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  307. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  308. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  309. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  310. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  311. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  312. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  313. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  314. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  315. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  316. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  317. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  318. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  319. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  320. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  321. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  322. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  323. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  324. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  325. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  326. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  327. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  328. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  329. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  330. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  331. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  332. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  333. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  334. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  335. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  336. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  337. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  338. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  339. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  340. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  341. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  342. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  343. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  344. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  345. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  346. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  347. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  348. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  349. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  350. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  351. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  352. package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
  353. package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
  354. package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
  355. package/node_modules/typebox/build/type/script/parser.mjs +22 -22
  356. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  357. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  358. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  359. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  360. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  361. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  362. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  363. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  364. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  365. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  366. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  367. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  368. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  369. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  370. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  371. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  372. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  373. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  374. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  375. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  376. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  377. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  378. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  379. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  380. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  381. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  382. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  383. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  384. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  385. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  386. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  387. package/node_modules/typebox/build/typebox.d.mts +4 -8
  388. package/node_modules/typebox/build/typebox.mjs +4 -8
  389. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  390. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  391. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  392. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  393. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  394. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  395. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  396. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  397. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  398. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  399. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  400. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  401. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  402. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  403. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  404. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  405. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  406. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  407. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  408. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  409. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  410. package/node_modules/typebox/build/value/index.d.mts +0 -1
  411. package/node_modules/typebox/build/value/index.mjs +0 -1
  412. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  413. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  414. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  415. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  416. package/node_modules/typebox/build/value/value.d.mts +0 -1
  417. package/node_modules/typebox/build/value/value.mjs +0 -1
  418. package/node_modules/typebox/package.json +25 -25
  419. package/node_modules/typebox/readme.md +97 -80
  420. package/node_modules/undici-types/agent.d.ts +0 -2
  421. package/node_modules/undici-types/client.d.ts +25 -19
  422. package/node_modules/undici-types/dispatcher.d.ts +7 -33
  423. package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
  424. package/node_modules/undici-types/fetch.d.ts +24 -4
  425. package/node_modules/undici-types/h2c-client.d.ts +6 -6
  426. package/node_modules/undici-types/handlers.d.ts +1 -2
  427. package/node_modules/undici-types/header.d.ts +5 -0
  428. package/node_modules/undici-types/index.d.ts +3 -1
  429. package/node_modules/undici-types/interceptors.d.ts +1 -1
  430. package/node_modules/undici-types/package.json +1 -1
  431. package/node_modules/undici-types/pool.d.ts +0 -2
  432. package/node_modules/undici-types/proxy-agent.d.ts +2 -2
  433. package/node_modules/undici-types/round-robin-pool.d.ts +0 -2
  434. package/node_modules/undici-types/snapshot-agent.d.ts +4 -0
  435. package/node_modules/undici-types/socks5-proxy-agent.d.ts +2 -2
  436. package/node_modules/undici-types/webidl.d.ts +0 -1
  437. package/npm-shrinkwrap.json +49 -41
  438. package/openclaw.plugin.json +12 -0
  439. package/package.json +5 -5
  440. package/node_modules/@cacheable/memory/dist/index.d.ts +0 -310
  441. package/node_modules/@cacheable/memory/dist/index.js +0 -807
  442. package/node_modules/@cacheable/utils/dist/index.d.ts +0 -307
  443. package/node_modules/@cacheable/utils/dist/index.js +0 -630
  444. package/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
  445. package/node_modules/cacheable/dist/index.d.ts +0 -494
  446. package/node_modules/cacheable/dist/index.js +0 -1141
  447. package/node_modules/content-type/HISTORY.md +0 -29
  448. package/node_modules/content-type/index.js +0 -225
  449. package/node_modules/media-typer/HISTORY.md +0 -50
  450. package/node_modules/media-typer/index.js +0 -143
  451. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  452. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  453. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  454. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  455. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  456. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  457. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  458. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  459. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  460. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  461. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  462. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  463. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  464. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  465. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  466. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  467. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  468. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  469. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  470. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  471. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  472. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  473. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  474. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  475. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  476. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  477. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  478. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  479. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  480. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  481. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  482. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  483. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  484. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  485. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  486. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  487. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  488. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  489. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  490. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  491. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  492. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  493. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  494. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  495. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  496. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  497. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  498. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  499. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  500. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  501. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  502. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  503. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  504. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  505. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  506. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  507. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  508. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  509. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  510. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  511. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  512. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  513. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  514. package/dist/{approval-resolver-e1hAVRRy.js → approval-resolver-DF-lu8k5.js} +1 -1
  515. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  516. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -0,0 +1,1210 @@
1
+ import { CacheableMemory, KeyvCacheableMemory, createKeyv, createKeyv as createKeyv$1 } from "@cacheable/memory";
2
+ import { CacheTags, CacheTags as CacheTags$1, HashAlgorithm, HashAlgorithm as HashAlgorithm$1, Stats, Stats as CacheableStats, calculateTtlFromExpiration, calculateTtlFromExpiration as calculateTtlFromExpiration$1, getCascadingTtl, getCascadingTtl as getCascadingTtl$1, getOrSet, getOrSet as getOrSet$1, hash, hash as hash$1, hashSync, isKeyvInstance, resolvePerStoreTtl, shorthandToMilliseconds, shorthandToMilliseconds as shorthandToMilliseconds$1, shorthandToTime, wrap, wrap as wrap$1, wrapSync } from "@cacheable/utils";
3
+ import { Hookified } from "hookified";
4
+ import { Keyv, Keyv as Keyv$1, KeyvHooks } from "keyv";
5
+ import { Qified } from "qified";
6
+ //#region src/enums.ts
7
+ let CacheableHooks = /* @__PURE__ */ function(CacheableHooks) {
8
+ CacheableHooks["BEFORE_SET"] = "BEFORE_SET";
9
+ CacheableHooks["AFTER_SET"] = "AFTER_SET";
10
+ CacheableHooks["BEFORE_SET_MANY"] = "BEFORE_SET_MANY";
11
+ CacheableHooks["AFTER_SET_MANY"] = "AFTER_SET_MANY";
12
+ CacheableHooks["BEFORE_GET"] = "BEFORE_GET";
13
+ CacheableHooks["AFTER_GET"] = "AFTER_GET";
14
+ CacheableHooks["BEFORE_GET_MANY"] = "BEFORE_GET_MANY";
15
+ CacheableHooks["AFTER_GET_MANY"] = "AFTER_GET_MANY";
16
+ CacheableHooks["BEFORE_SECONDARY_SETS_PRIMARY"] = "BEFORE_SECONDARY_SETS_PRIMARY";
17
+ return CacheableHooks;
18
+ }({});
19
+ let CacheableEvents = /* @__PURE__ */ function(CacheableEvents) {
20
+ CacheableEvents["ERROR"] = "error";
21
+ CacheableEvents["CACHE_HIT"] = "cache:hit";
22
+ CacheableEvents["CACHE_MISS"] = "cache:miss";
23
+ return CacheableEvents;
24
+ }({});
25
+ //#endregion
26
+ //#region src/sync.ts
27
+ /**
28
+ * Events emitted by CacheableSync
29
+ */
30
+ let CacheableSyncEvents = /* @__PURE__ */ function(CacheableSyncEvents) {
31
+ CacheableSyncEvents["ERROR"] = "error";
32
+ CacheableSyncEvents["SET"] = "cache:set";
33
+ CacheableSyncEvents["DELETE"] = "cache:delete";
34
+ return CacheableSyncEvents;
35
+ }({});
36
+ /**
37
+ * CacheableSync provides synchronization capabilities for cacheable items
38
+ * using message providers from Qified
39
+ */
40
+ var CacheableSync = class extends Hookified {
41
+ _qified = new Qified();
42
+ _namespace;
43
+ _storage;
44
+ _cacheId;
45
+ /**
46
+ * Creates an instance of CacheableSync
47
+ * @param options - Configuration options for CacheableSync
48
+ */
49
+ constructor(options) {
50
+ super(options);
51
+ this._namespace = options.namespace;
52
+ this._qified = this.createQified(options.qified);
53
+ }
54
+ /**
55
+ * Gets the Qified instance used for synchronization
56
+ * @returns The Qified instance
57
+ */
58
+ get qified() {
59
+ return this._qified;
60
+ }
61
+ /**
62
+ * Sets the Qified instance used for synchronization
63
+ * @param value - Either an existing Qified instance or MessageProvider(s)
64
+ */
65
+ set qified(value) {
66
+ this._qified = this.createQified(value);
67
+ }
68
+ /**
69
+ * Gets the namespace for sync events
70
+ * @returns The namespace or undefined if not set
71
+ */
72
+ get namespace() {
73
+ return this._namespace;
74
+ }
75
+ /**
76
+ * Sets the namespace for sync events and resubscribes if needed
77
+ * @param namespace - The namespace string or function
78
+ */
79
+ set namespace(namespace) {
80
+ if (this._storage && this._cacheId) {
81
+ const oldSetEvent = this.getPrefixedEvent("cache:set");
82
+ const oldDeleteEvent = this.getPrefixedEvent("cache:delete");
83
+ this._qified.unsubscribeMessage(oldSetEvent);
84
+ this._qified.unsubscribeMessage(oldDeleteEvent);
85
+ }
86
+ this._namespace = namespace;
87
+ if (this._storage && this._cacheId) this.subscribe(this._storage, this._cacheId);
88
+ }
89
+ /**
90
+ * Publishes a cache event to all the cache instances
91
+ * @param data - The cache item data containing cacheId, key, value, and optional ttl
92
+ */
93
+ async publish(event, data) {
94
+ const eventName = this.getPrefixedEvent(event);
95
+ await this._qified.publish(eventName, {
96
+ id: crypto.randomUUID(),
97
+ data
98
+ });
99
+ }
100
+ /**
101
+ * Subscribes to sync events and updates the provided storage
102
+ * @param storage - The Keyv storage instance to update
103
+ * @param cacheId - The cache ID to identify this instance
104
+ */
105
+ subscribe(storage, cacheId) {
106
+ this._storage = storage;
107
+ this._cacheId = cacheId;
108
+ const setEvent = this.getPrefixedEvent("cache:set");
109
+ const deleteEvent = this.getPrefixedEvent("cache:delete");
110
+ this._qified.subscribe(setEvent, { handler: async (message) => {
111
+ const data = message.data;
112
+ if (data.cacheId !== cacheId) await storage.set(data.key, data.value, data.ttl);
113
+ } });
114
+ this._qified.subscribe(deleteEvent, { handler: async (message) => {
115
+ const data = message.data;
116
+ if (data.cacheId !== cacheId) await storage.delete(data.key);
117
+ } });
118
+ }
119
+ /**
120
+ * Creates or returns a Qified instance from the provided value
121
+ * @param value - Either an existing Qified instance or MessageProvider(s)
122
+ * @returns A Qified instance configured with the provided message provider(s)
123
+ */
124
+ createQified(value) {
125
+ if (value instanceof Qified) return value;
126
+ return new Qified({ messageProviders: Array.isArray(value) ? value : [value] });
127
+ }
128
+ /**
129
+ * Gets the namespace prefix to use for event names
130
+ * @returns The resolved namespace string or undefined
131
+ */
132
+ getNamespace() {
133
+ if (typeof this._namespace === "function") return this._namespace();
134
+ return this._namespace;
135
+ }
136
+ /**
137
+ * Prefixes an event name with the namespace if one is set
138
+ * @param event - The event to prefix
139
+ * @returns The prefixed event name or the original event
140
+ */
141
+ getPrefixedEvent(event) {
142
+ const ns = this.getNamespace();
143
+ return ns ? `${ns}::${event}` : event;
144
+ }
145
+ };
146
+ //#endregion
147
+ //#region src/index.ts
148
+ var Cacheable = class Cacheable extends Hookified {
149
+ static _instance;
150
+ _primary = createKeyv$1();
151
+ _secondary;
152
+ _nonBlocking = false;
153
+ _ttl;
154
+ _maxTtl;
155
+ _stats = new Stats({ enabled: false });
156
+ _namespace;
157
+ _cacheId = Math.random().toString(36).slice(2);
158
+ _sync;
159
+ _tags = this.createCacheTags();
160
+ /**
161
+ * Creates a new cacheable instance
162
+ * @param {CacheableOptions} [options] The options for the cacheable instance
163
+ */
164
+ constructor(options) {
165
+ super();
166
+ if (options?.primary) this.setPrimary(options.primary);
167
+ if (options?.secondary) this.setSecondary(options.secondary);
168
+ if (options?.nonBlocking) this._nonBlocking = options.nonBlocking;
169
+ if (options?.stats) this._stats.enabled = options.stats;
170
+ if (options?.ttl) this.setTtl(options.ttl);
171
+ if (options?.maxTtl !== void 0) this.setMaxTtl(options.maxTtl);
172
+ if (options?.cacheId) this._cacheId = options.cacheId;
173
+ if (options?.namespace) {
174
+ this._namespace = options.namespace;
175
+ this._primary.namespace = this.getNameSpace();
176
+ if (this._secondary) this._secondary.namespace = this.getNameSpace();
177
+ }
178
+ if (options?.tags) this._tags.enabled = true;
179
+ if (options?.sync) {
180
+ this._sync = options.sync instanceof CacheableSync ? options.sync : new CacheableSync({
181
+ ...options.sync,
182
+ namespace: options.namespace
183
+ });
184
+ this._sync.subscribe(this._primary, this._cacheId);
185
+ }
186
+ }
187
+ /**
188
+ * Gets a shared static (singleton) instance of {@link Cacheable}. The first call creates the
189
+ * instance using the provided options; every later call returns that same instance. Passing
190
+ * `options` again after the instance already exists does NOT reconfigure it — the options are
191
+ * ignored and a {@link CacheableEvents.ERROR} event is emitted on the instance to surface the
192
+ * conflict (listen with `instance.on("error", ...)`). To reconfigure, replace it via
193
+ * {@link Cacheable.setStaticInstance} (clear with `undefined`, then call this again).
194
+ *
195
+ * Note: this package ships separate CommonJS and ESM builds, so an app that loads both formats
196
+ * gets one shared instance per build. For a single shared cache, use one module format or share
197
+ * an explicit instance via {@link Cacheable.setStaticInstance}.
198
+ * @param {CacheableOptions} [options] Options applied only when the instance is first created
199
+ * @returns {Cacheable} The shared static instance
200
+ * @example
201
+ * ```ts
202
+ * const cache = Cacheable.getStaticInstance({ ttl: "1h" });
203
+ * await cache.set("key", "value");
204
+ * ```
205
+ */
206
+ static getStaticInstance(options) {
207
+ if (options && Cacheable._instance) {
208
+ Cacheable._instance.emit("error", /* @__PURE__ */ new Error("Cacheable static instance is already initialized; the options passed were ignored. To reconfigure, use Cacheable.setStaticInstance()."));
209
+ return Cacheable._instance;
210
+ }
211
+ Cacheable._instance ??= new Cacheable(options);
212
+ return Cacheable._instance;
213
+ }
214
+ /**
215
+ * Sets or clears the shared static instance returned by {@link Cacheable.getStaticInstance}.
216
+ * Pass a {@link Cacheable} instance to make it the shared instance, or `undefined` to clear it
217
+ * so the next {@link Cacheable.getStaticInstance} call creates a fresh one. Clearing only drops
218
+ * the reference — it does not `disconnect()` or `clear()` the previous instance, so disconnect
219
+ * it first if it holds open connections.
220
+ * @param {Cacheable} [instance] The instance to share, or `undefined` to clear it
221
+ */
222
+ static setStaticInstance(instance) {
223
+ Cacheable._instance = instance;
224
+ }
225
+ onHook(event, handler) {
226
+ super.onHook(event, handler);
227
+ }
228
+ /**
229
+ * The namespace for the cacheable instance
230
+ * @returns {string | (() => string) | undefined} The namespace for the cacheable instance
231
+ */
232
+ get namespace() {
233
+ return this._namespace;
234
+ }
235
+ /**
236
+ * Sets the namespace for the cacheable instance
237
+ * @param {string | (() => string) | undefined} namespace The namespace for the cacheable instance
238
+ * @returns {void}
239
+ */
240
+ set namespace(namespace) {
241
+ this._namespace = namespace;
242
+ this._primary.namespace = this.getNameSpace();
243
+ if (this._secondary) this._secondary.namespace = this.getNameSpace();
244
+ if (this._sync) this._sync.namespace = namespace;
245
+ }
246
+ /**
247
+ * The statistics for the cacheable instance
248
+ * @returns {CacheableStats} The statistics for the cacheable instance
249
+ */
250
+ get stats() {
251
+ return this._stats;
252
+ }
253
+ /**
254
+ * The primary store for the cacheable instance
255
+ * @returns {Keyv} The primary store for the cacheable instance
256
+ */
257
+ get primary() {
258
+ return this._primary;
259
+ }
260
+ /**
261
+ * Sets the primary store for the cacheable instance
262
+ * @param {Keyv} primary The primary store for the cacheable instance
263
+ */
264
+ set primary(primary) {
265
+ this._primary = primary;
266
+ this._tags = this.createCacheTags();
267
+ }
268
+ /**
269
+ * The secondary store for the cacheable instance
270
+ * @returns {Keyv | undefined} The secondary store for the cacheable instance
271
+ */
272
+ get secondary() {
273
+ return this._secondary;
274
+ }
275
+ /**
276
+ * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
277
+ * @param {Keyv | undefined} secondary The secondary store for the cacheable instance
278
+ * @returns {void}
279
+ */
280
+ set secondary(secondary) {
281
+ this._secondary = secondary;
282
+ this._tags = this.createCacheTags();
283
+ }
284
+ /**
285
+ * Gets whether the secondary store is non-blocking mode. It is set to false by default.
286
+ * If it is set to true then the secondary store will not block the primary store.
287
+ *
288
+ * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
289
+ *
290
+ * @returns {boolean} Whether the cacheable instance is non-blocking
291
+ */
292
+ get nonBlocking() {
293
+ return this._nonBlocking;
294
+ }
295
+ /**
296
+ * Sets whether the secondary store is non-blocking mode. It is set to false by default.
297
+ * If it is set to true then the secondary store will not block the primary store.
298
+ *
299
+ * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
300
+ *
301
+ * @param {boolean} nonBlocking Whether the cacheable instance is non-blocking
302
+ * @returns {void}
303
+ */
304
+ set nonBlocking(nonBlocking) {
305
+ this._nonBlocking = nonBlocking;
306
+ }
307
+ /**
308
+ * The time-to-live for the cacheable instance and will be used as the default value.
309
+ * can be a number in milliseconds or a human-readable format such as `1s` for 1 second or `1h` for 1 hour
310
+ * or undefined if there is no time-to-live.
311
+ *
312
+ * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
313
+ *
314
+ * @returns {number | string | undefined} The time-to-live for the cacheable instance in milliseconds, human-readable format or undefined
315
+ * @example
316
+ * ```typescript
317
+ * const cacheable = new Cacheable({ ttl: '1h' });
318
+ * console.log(cacheable.ttl); // 1h
319
+ * ```
320
+ */
321
+ get ttl() {
322
+ return this._ttl;
323
+ }
324
+ /**
325
+ * Sets the time-to-live for the cacheable instance and will be used as the default value.
326
+ * If you set a number it is miliseconds, if you set a string it is a human-readable
327
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that
328
+ * there is no time-to-live.
329
+ *
330
+ * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
331
+ *
332
+ * @param {number | string | undefined} ttl The time-to-live for the cacheable instance
333
+ * @example
334
+ * ```typescript
335
+ * const cacheable = new Cacheable();
336
+ * cacheable.ttl = '1h'; // Set the time-to-live to 1 hour
337
+ * ```
338
+ * or setting the time-to-live in milliseconds
339
+ * ```typescript
340
+ * const cacheable = new Cacheable();
341
+ * cacheable.ttl = 3600000; // Set the time-to-live to 1 hour
342
+ * ```
343
+ */
344
+ set ttl(ttl) {
345
+ this.setTtl(ttl);
346
+ }
347
+ /**
348
+ * Gets the maximum time-to-live for the cacheable instance. When set, any TTL that exceeds this
349
+ * value is capped to maxTtl. Entries with no TTL will also be capped to maxTtl.
350
+ * Can be a number in milliseconds or a human-readable format such as `1s`, `1m`, `1h`, `1d`.
351
+ * Default is `undefined` (no maximum).
352
+ *
353
+ * @returns {number | string | undefined} The maximum time-to-live or undefined if not set
354
+ * @example
355
+ * ```typescript
356
+ * const cacheable = new Cacheable({ maxTtl: '1h' });
357
+ * console.log(cacheable.maxTtl); // '1h'
358
+ * ```
359
+ */
360
+ get maxTtl() {
361
+ return this._maxTtl;
362
+ }
363
+ /**
364
+ * Sets the maximum time-to-live for the cacheable instance. When set, any TTL that exceeds this
365
+ * value is capped to maxTtl. Entries with no TTL will also be capped to maxTtl.
366
+ * If you set a number it is milliseconds, if you set a string it is a human-readable
367
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined disables the maximum.
368
+ *
369
+ * @param {number | string | undefined} maxTtl The maximum time-to-live
370
+ * @example
371
+ * ```typescript
372
+ * const cacheable = new Cacheable();
373
+ * cacheable.maxTtl = '1h'; // Set the max TTL to 1 hour
374
+ * ```
375
+ */
376
+ set maxTtl(maxTtl) {
377
+ this.setMaxTtl(maxTtl);
378
+ }
379
+ /**
380
+ * The cacheId for the cacheable instance. This is primarily used for the wrap function to not have conflicts.
381
+ * If it is not set then it will be a random string that is generated
382
+ * @returns {string} The cacheId for the cacheable instance
383
+ */
384
+ get cacheId() {
385
+ return this._cacheId;
386
+ }
387
+ /**
388
+ * Sets the cacheId for the cacheable instance. This is primarily used for the wrap function to not have conflicts.
389
+ * If it is not set then it will be a random string that is generated
390
+ * @param {string} cacheId The cacheId for the cacheable instance
391
+ */
392
+ set cacheId(cacheId) {
393
+ this._cacheId = cacheId;
394
+ }
395
+ /**
396
+ * Gets the sync instance for the cacheable instance
397
+ * @returns {CacheableSync | undefined} The sync instance for the cacheable instance
398
+ */
399
+ get sync() {
400
+ return this._sync;
401
+ }
402
+ /**
403
+ * Sets the sync instance for the cacheable instance
404
+ * @param {CacheableSync | undefined} sync The sync instance for the cacheable instance
405
+ */
406
+ set sync(sync) {
407
+ this._sync = sync;
408
+ if (this._sync) this._sync.subscribe(this._primary, this._cacheId);
409
+ }
410
+ /**
411
+ * The tag service for the cacheable instance, used for tag-based invalidation. It is created
412
+ * by default in the constructor and persists tag metadata in the secondary store when one is
413
+ * configured (so invalidations are shared across instances), otherwise the primary store.
414
+ *
415
+ * The service starts disabled so untagged workloads pay no extra store reads, and must be
416
+ * explicitly enabled to use tags — via the `tags: true` option or the `tags.enabled`
417
+ * property. While disabled, all tag operations are no-ops. Enable it on every instance that
418
+ * shares the store so behavior is consistent across distributed instances. While enabled,
419
+ * `get` / `getMany` perform tag freshness checks and remove stale entries.
420
+ *
421
+ * [Learn more about tag-based invalidation](https://cacheable.org/docs/cacheable/#tag-based-invalidation).
422
+ *
423
+ * @returns {CacheTags} The tag service for the cacheable instance
424
+ * @example
425
+ * ```typescript
426
+ * const cache = new Cacheable({ tags: true });
427
+ * await cache.set('page:/products', html, { tags: ['entity:42'] });
428
+ * await cache.tags.invalidateTag('entity:42');
429
+ * await cache.get('page:/products'); // undefined
430
+ * ```
431
+ */
432
+ get tags() {
433
+ return this._tags;
434
+ }
435
+ /**
436
+ * Creates the tag service backed by the secondary store when one is configured, otherwise the
437
+ * primary store, preserving the enabled state of any previous service and reporting
438
+ * non-blocking failures as error events.
439
+ */
440
+ createCacheTags() {
441
+ return new CacheTags$1({
442
+ store: this._secondary ?? this._primary,
443
+ enabled: this._tags?.enabled ?? false,
444
+ onError: (error) => {
445
+ this.emit("error", error);
446
+ }
447
+ });
448
+ }
449
+ /**
450
+ * Sets the primary store for the cacheable instance
451
+ * @param {Keyv | KeyvStoreAdapter} primary The primary store for the cacheable instance
452
+ * @returns {void}
453
+ */
454
+ setPrimary(primary) {
455
+ if (isKeyvInstance(primary)) this._primary = primary;
456
+ else this._primary = new Keyv$1(primary);
457
+ /* v8 ignore next -- @preserve */
458
+ this._primary.on("error", (error) => {
459
+ this.emit("error", error);
460
+ });
461
+ this._tags = this.createCacheTags();
462
+ }
463
+ /**
464
+ * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
465
+ * @param {Keyv | KeyvStoreAdapter} secondary The secondary store for the cacheable instance
466
+ * @returns {void}
467
+ */
468
+ setSecondary(secondary) {
469
+ if (isKeyvInstance(secondary)) this._secondary = secondary;
470
+ else this._secondary = new Keyv$1(secondary);
471
+ /* v8 ignore next -- @preserve */
472
+ this._secondary.on("error", (error) => {
473
+ this.emit("error", error);
474
+ });
475
+ this._tags = this.createCacheTags();
476
+ }
477
+ getNameSpace() {
478
+ if (typeof this._namespace === "function") return this._namespace();
479
+ return this._namespace;
480
+ }
481
+ /**
482
+ * Retrieves an entry from the cache.
483
+ *
484
+ * Checks the primary store first; if not found and a secondary store is configured,
485
+ * it will fetch from the secondary, repopulate the primary, and return the result.
486
+ *
487
+ * @typeParam T - The expected type of the stored value.
488
+ * @param {string} key - The cache key to retrieve.
489
+ * @param {GetOptions} - options such as to bypass `nonBlocking` for this call
490
+ * @returns {Promise<T | undefined>}
491
+ * A promise that resolves to the cached value if found, or `undefined`.
492
+ */
493
+ async get(key, options) {
494
+ return (await this.getRaw(key, options))?.value;
495
+ }
496
+ /**
497
+ * Retrieves the raw entry from the cache including metadata like expiration.
498
+ *
499
+ * Checks the primary store first; if not found and a secondary store is configured,
500
+ * it will fetch from the secondary, repopulate the primary, and return the result.
501
+ *
502
+ * @typeParam T - The expected type of the stored value.
503
+ * @param {string} key - The cache key to retrieve.
504
+ * @param {GetOptions} - options such as to bypass `nonBlocking` for this call
505
+ * @returns {Promise<StoredDataRaw<T>>}
506
+ * A promise that resolves to the full raw data object if found, or undefined.
507
+ */
508
+ async getRaw(key, options) {
509
+ let result;
510
+ try {
511
+ await this.hook("BEFORE_GET", key);
512
+ result = await this._primary.getRaw(key);
513
+ let ttl;
514
+ if (result) this.emit("cache:hit", {
515
+ key,
516
+ value: result.value,
517
+ store: "primary"
518
+ });
519
+ else this.emit("cache:miss", {
520
+ key,
521
+ store: "primary"
522
+ });
523
+ const nonBlocking = options?.nonBlocking ?? this._nonBlocking;
524
+ if (!result && this._secondary) {
525
+ let secondaryProcessResult;
526
+ if (nonBlocking) secondaryProcessResult = await this.processSecondaryForGetRawNonBlocking(this._primary, this._secondary, key);
527
+ else secondaryProcessResult = await this.processSecondaryForGetRaw(this._primary, this._secondary, key);
528
+ if (secondaryProcessResult) {
529
+ result = secondaryProcessResult.result;
530
+ ttl = secondaryProcessResult.ttl;
531
+ }
532
+ }
533
+ if (result && this._tags.enabled && await this._tags.isKeyStale(key)) {
534
+ await this.delete(key);
535
+ result = void 0;
536
+ }
537
+ await this.hook("AFTER_GET", {
538
+ key,
539
+ result,
540
+ ttl
541
+ });
542
+ } catch (error) {
543
+ this.emit("error", error);
544
+ }
545
+ if (this.stats.enabled) {
546
+ if (result) this._stats.incrementHits();
547
+ else this._stats.incrementMisses();
548
+ this.stats.incrementGets();
549
+ }
550
+ return result;
551
+ }
552
+ /**
553
+ * Retrieves multiple raw entries from the cache including metadata like expiration.
554
+ *
555
+ * Checks the primary store for each key; if a key is missing and a secondary store is configured,
556
+ * it will fetch from the secondary store, repopulate the primary store, and return the results.
557
+ *
558
+ * @typeParam T - The expected type of the stored values.
559
+ * @param {string[]} keys - The cache keys to retrieve.
560
+ * @param {GetOptions} - options such as to bypass `nonBlocking` on this call
561
+ * @returns {Promise<Array<StoredDataRaw<T>>>}
562
+ * A promise that resolves to an array of raw data objects.
563
+ */
564
+ async getManyRaw(keys, options) {
565
+ let result = [];
566
+ try {
567
+ await this.hook("BEFORE_GET_MANY", keys);
568
+ result = await this._primary.getManyRaw(keys);
569
+ for (const [i, key] of keys.entries()) if (result[i]) this.emit("cache:hit", {
570
+ key,
571
+ value: result[i].value,
572
+ store: "primary"
573
+ });
574
+ else this.emit("cache:miss", {
575
+ key,
576
+ store: "primary"
577
+ });
578
+ const nonBlocking = options?.nonBlocking ?? this._nonBlocking;
579
+ if (this._secondary) if (nonBlocking) await this.processSecondaryForGetManyRawNonBlocking(this._primary, this._secondary, keys, result);
580
+ else await this.processSecondaryForGetManyRaw(this._primary, this._secondary, keys, result);
581
+ if (this._tags.enabled) {
582
+ const presentKeys = keys.filter((_, i) => result[i] !== void 0);
583
+ const staleKeys = await this._tags.getStaleKeys(presentKeys);
584
+ if (staleKeys.length > 0) {
585
+ const staleSet = new Set(staleKeys);
586
+ for (const [i, key] of keys.entries()) if (staleSet.has(key)) result[i] = void 0;
587
+ await this.deleteMany(staleKeys);
588
+ }
589
+ }
590
+ await this.hook("AFTER_GET_MANY", {
591
+ keys,
592
+ result
593
+ });
594
+ } catch (error) {
595
+ this.emit("error", error);
596
+ }
597
+ if (this.stats.enabled) {
598
+ for (const item of result) if (item) this._stats.incrementHits();
599
+ else this._stats.incrementMisses();
600
+ this.stats.incrementGets();
601
+ }
602
+ return result;
603
+ }
604
+ /**
605
+ * Retrieves multiple entries from the cache.
606
+ * Checks the primary store for each key; if a key is missing and a secondary store is configured,
607
+ * it will fetch from the secondary store, repopulate the primary store, and return the results.
608
+ *
609
+ * @typeParam T - The expected type of the stored values.
610
+ * @param {string[]} keys - The cache keys to retrieve.
611
+ * @param {GetOptions} - options such as to bypass `nonBlocking` on this call
612
+ * @returns {Promise<Array<T | undefined>>}
613
+ * A promise that resolves to an array of cached values or `undefined` for misses.
614
+ */
615
+ async getMany(keys, options) {
616
+ return (await this.getManyRaw(keys, options)).map((item) => item?.value);
617
+ }
618
+ /**
619
+ * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store.
620
+ * @param {string} key the key to set the value of
621
+ * @param {T} value The value to set
622
+ * @param {number | string | SetOptions} [ttlOrOptions] set a number it is miliseconds, set a string it is a human-readable
623
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live.
624
+ * You can also pass a {@link SetOptions} object such as `{ ttl: '1h', tags: ['user:42'] }` to associate the entry with
625
+ * tags for tag-based invalidation. To give each store its own TTL for this operation, pass a per-store object as the
626
+ * `ttl`, such as `{ ttl: { primary: '10s', secondary: '5m' } }`.
627
+ * @returns {boolean} Whether the value was set
628
+ */
629
+ async set(key, value, ttlOrOptions) {
630
+ let result = false;
631
+ const options = typeof ttlOrOptions === "object" && ttlOrOptions !== null ? ttlOrOptions : { ttl: ttlOrOptions ?? void 0 };
632
+ const nonBlocking = options.nonBlocking ?? this._nonBlocking;
633
+ const { primary: explicitPrimaryTtl, secondary: explicitSecondaryTtl } = resolvePerStoreTtl(options.ttl);
634
+ const maxTtlMs = shorthandToMilliseconds$1(this._maxTtl);
635
+ try {
636
+ let primaryTtl = getCascadingTtl$1(this._ttl, this._primary.ttl, explicitPrimaryTtl);
637
+ primaryTtl = this.capTtl(primaryTtl, maxTtlMs);
638
+ let hookTtl = primaryTtl;
639
+ let ttlOverridden = false;
640
+ const item = {
641
+ key,
642
+ value,
643
+ tags: options.tags,
644
+ get ttl() {
645
+ return hookTtl;
646
+ },
647
+ set ttl(value) {
648
+ hookTtl = value;
649
+ ttlOverridden = true;
650
+ }
651
+ };
652
+ await this.hook("BEFORE_SET", item);
653
+ let primaryTtlEffective;
654
+ let secondaryTtlEffective;
655
+ if (!ttlOverridden) {
656
+ primaryTtlEffective = primaryTtl;
657
+ secondaryTtlEffective = this._secondary ? getCascadingTtl$1(this._ttl, this._secondary.ttl, explicitSecondaryTtl) : void 0;
658
+ } else if (typeof hookTtl === "object" && hookTtl !== null) {
659
+ const { primary: hookPrimaryTtl, secondary: hookSecondaryTtl } = resolvePerStoreTtl(hookTtl);
660
+ primaryTtlEffective = hookPrimaryTtl ?? getCascadingTtl$1(this._ttl, this._primary.ttl, explicitPrimaryTtl);
661
+ secondaryTtlEffective = this._secondary ? hookSecondaryTtl ?? getCascadingTtl$1(this._ttl, this._secondary.ttl, explicitSecondaryTtl) : void 0;
662
+ } else {
663
+ const hookScalarTtl = shorthandToMilliseconds$1(hookTtl);
664
+ primaryTtlEffective = hookScalarTtl;
665
+ secondaryTtlEffective = this._secondary ? hookScalarTtl : void 0;
666
+ }
667
+ primaryTtlEffective = this.capTtl(primaryTtlEffective, maxTtlMs);
668
+ secondaryTtlEffective = this.capTtl(secondaryTtlEffective, maxTtlMs);
669
+ hookTtl = primaryTtlEffective;
670
+ const tagTtl = this.maxStoreTtl(primaryTtlEffective, secondaryTtlEffective);
671
+ const promises = [];
672
+ promises.push(this._primary.set(item.key, item.value, primaryTtlEffective));
673
+ if (this._secondary) promises.push(this._secondary.set(item.key, item.value, secondaryTtlEffective));
674
+ if (nonBlocking) {
675
+ result = await Promise.race(promises);
676
+ for (const promise of promises) promise.catch((error) => {
677
+ this.emit("error", error);
678
+ });
679
+ } else result = (await Promise.all(promises))[0];
680
+ if (this._tags.enabled) if (item.tags && item.tags.length > 0) await this._tags.setKeyTags(item.key, item.tags, {
681
+ ttl: tagTtl,
682
+ nonBlocking
683
+ });
684
+ else await this._tags.removeKeys([item.key], { nonBlocking });
685
+ await this.hook("AFTER_SET", item);
686
+ if (this._sync && result) await this._sync.publish("cache:set", {
687
+ cacheId: this._cacheId,
688
+ key: item.key,
689
+ value: item.value,
690
+ ttl: primaryTtlEffective
691
+ });
692
+ } catch (error) {
693
+ this.emit("error", error);
694
+ }
695
+ if (this.stats.enabled) {
696
+ this.stats.incrementKSize(key);
697
+ this.stats.incrementCount();
698
+ this.stats.incrementVSize(value);
699
+ this.stats.incrementSets();
700
+ }
701
+ return result;
702
+ }
703
+ /**
704
+ * Sets the values of the keys. If the secondary store is set then it will also set the values in the secondary store.
705
+ * Items can include `tags` to associate the entry with tags for tag-based invalidation.
706
+ * @param {CacheableSetItem[]} items The items to set
707
+ * @returns {boolean} Whether the values were set
708
+ */
709
+ async setMany(items) {
710
+ let result = false;
711
+ try {
712
+ await this.hook("BEFORE_SET_MANY", items);
713
+ result = await this.setManyKeyv(this._primary, items, "primary");
714
+ if (this._secondary) if (this._nonBlocking)
715
+ /* v8 ignore next -- @preserve */
716
+ this.setManyKeyv(this._secondary, items, "secondary").catch((error) => {
717
+ /* v8 ignore next -- @preserve */
718
+ this.emit("error", error);
719
+ });
720
+ else await this.setManyKeyv(this._secondary, items, "secondary");
721
+ if (this._tags.enabled) await this.setManyKeyTags(items);
722
+ await this.hook("AFTER_SET_MANY", items);
723
+ if (this._sync && result) {
724
+ const maxTtlMs = shorthandToMilliseconds$1(this._maxTtl);
725
+ for (const item of items) await this._sync.publish("cache:set", {
726
+ cacheId: this._cacheId,
727
+ key: item.key,
728
+ value: item.value,
729
+ ttl: this.resolveStoreTtl(item.ttl, this._primary.ttl, "primary", maxTtlMs)
730
+ });
731
+ }
732
+ } catch (error) {
733
+ this.emit("error", error);
734
+ }
735
+ if (this.stats.enabled) for (const item of items) {
736
+ this.stats.incrementKSize(item.key);
737
+ this.stats.incrementCount();
738
+ this.stats.incrementVSize(item.value);
739
+ }
740
+ return result;
741
+ }
742
+ /**
743
+ * Takes the value of the key and deletes the key. If the key does not exist then it will return undefined.
744
+ * @param {string} key The key to take the value of
745
+ * @returns {Promise<T | undefined>} The value of the key or undefined if the key does not exist
746
+ */
747
+ async take(key) {
748
+ const result = await this.get(key);
749
+ await this.delete(key);
750
+ return result;
751
+ }
752
+ /**
753
+ * Takes the values of the keys and deletes the keys. If the key does not exist then it will return undefined.
754
+ * @param {string[]} keys The keys to take the values of
755
+ * @returns {Promise<Array<T | undefined>>} The values of the keys or undefined if the key does not exist
756
+ */
757
+ async takeMany(keys) {
758
+ const result = await this.getMany(keys);
759
+ await this.deleteMany(keys);
760
+ return result;
761
+ }
762
+ /**
763
+ * Checks if the key exists in the primary store. If it does not exist then it will check the secondary store.
764
+ * @param {string} key The key to check
765
+ * @returns {Promise<boolean>} Whether the key exists
766
+ */
767
+ async has(key) {
768
+ const promises = [];
769
+ promises.push(this._primary.has(key));
770
+ if (this._secondary) promises.push(this._secondary.has(key));
771
+ const resultAll = await Promise.all(promises);
772
+ for (const result of resultAll) if (result) return true;
773
+ return false;
774
+ }
775
+ /**
776
+ * Checks if the keys exist in the primary store. If it does not exist then it will check the secondary store.
777
+ * @param {string[]} keys The keys to check
778
+ * @returns {Promise<boolean[]>} Whether the keys exist
779
+ */
780
+ async hasMany(keys) {
781
+ const result = await this._primary.hasMany(keys);
782
+ const missingKeys = [];
783
+ for (const [i, key] of keys.entries()) if (!result[i] && this._secondary) missingKeys.push(key);
784
+ if (missingKeys.length > 0 && this._secondary) {
785
+ const secondary = await this._secondary.hasMany(keys);
786
+ for (const [i, _key] of keys.entries()) if (!result[i] && secondary[i]) result[i] = secondary[i];
787
+ }
788
+ return result;
789
+ }
790
+ /**
791
+ * Deletes the key from the primary store. If the secondary store is set then it will also delete the key from the secondary store.
792
+ * @param {string} key The key to delete
793
+ * @returns {Promise<boolean>} Whether the key was deleted
794
+ */
795
+ async delete(key) {
796
+ let result = false;
797
+ const promises = [];
798
+ if (this.stats.enabled) {
799
+ const statResult = await this._primary.get(key);
800
+ /* v8 ignore next -- @preserve */
801
+ if (statResult) {
802
+ this.stats.decreaseKSize(key);
803
+ this.stats.decreaseVSize(statResult);
804
+ this.stats.decreaseCount();
805
+ this.stats.incrementDeletes();
806
+ }
807
+ }
808
+ promises.push(this._primary.delete(key));
809
+ if (this._secondary) promises.push(this._secondary.delete(key));
810
+ if (this.nonBlocking) {
811
+ result = await Promise.race(promises);
812
+ for (const promise of promises) promise.catch((error) => {
813
+ this.emit("error", error);
814
+ });
815
+ } else result = (await Promise.all(promises))[0];
816
+ if (this._tags.enabled) await this._tags.removeKeys([key], { nonBlocking: this.nonBlocking });
817
+ if (this._sync && result) await this._sync.publish("cache:delete", {
818
+ cacheId: this._cacheId,
819
+ key
820
+ });
821
+ return result;
822
+ }
823
+ /**
824
+ * Deletes the keys from the primary store. If the secondary store is set then it will also delete the keys from the secondary store.
825
+ * @param {string[]} keys The keys to delete
826
+ * @returns {Promise<boolean>} Whether the keys were deleted
827
+ */
828
+ async deleteMany(keys) {
829
+ if (this.stats.enabled) {
830
+ const statResult = await this._primary.get(keys);
831
+ for (const key of keys) {
832
+ this.stats.decreaseKSize(key);
833
+ this.stats.decreaseVSize(statResult);
834
+ this.stats.decreaseCount();
835
+ this.stats.incrementDeletes();
836
+ }
837
+ }
838
+ const result = await this._primary.deleteMany(keys);
839
+ if (this._secondary) if (this._nonBlocking) this._secondary.deleteMany(keys).catch((error) => {
840
+ this.emit("error", error);
841
+ });
842
+ else await this._secondary.deleteMany(keys);
843
+ if (this._tags.enabled) await this._tags.removeKeys(keys, { nonBlocking: this._nonBlocking });
844
+ if (this._sync && result) for (const key of keys) await this._sync.publish("cache:delete", {
845
+ cacheId: this._cacheId,
846
+ key
847
+ });
848
+ return result;
849
+ }
850
+ /**
851
+ * Clears the primary store. If the secondary store is set then it will also clear the secondary store.
852
+ * @returns {Promise<void>}
853
+ */
854
+ async clear() {
855
+ const promises = [];
856
+ promises.push(this._primary.clear());
857
+ if (this._secondary) promises.push(this._secondary.clear());
858
+ await (this._nonBlocking ? Promise.race(promises) : Promise.all(promises));
859
+ if (this.stats.enabled) {
860
+ this._stats.resetStoreValues();
861
+ this._stats.incrementClears();
862
+ }
863
+ }
864
+ /**
865
+ * Disconnects the primary store. If the secondary store is set then it will also disconnect the secondary store.
866
+ * @returns {Promise<void>}
867
+ */
868
+ async disconnect() {
869
+ const promises = [];
870
+ promises.push(this._primary.disconnect());
871
+ /* v8 ignore next -- @preserve */
872
+ if (this._secondary) promises.push(this._secondary.disconnect());
873
+ promises.push(this._sync?.qified.disconnect());
874
+ await (this._nonBlocking ? Promise.race(promises) : Promise.all(promises));
875
+ }
876
+ /**
877
+ * Wraps a function with caching
878
+ *
879
+ * [Learn more about wrapping functions](https://cacheable.org/docs/cacheable/#wrap--memoization-for-sync-and-async-functions).
880
+ * @param {Function} function_ The function to wrap
881
+ * @param {WrapOptions} [options] The options for the wrap function
882
+ * @returns {Function} The wrapped function
883
+ */
884
+ wrap(function_, options) {
885
+ return wrap$1(function_, {
886
+ ttl: options?.ttl ?? this._ttl,
887
+ keyPrefix: options?.keyPrefix,
888
+ createKey: options?.createKey,
889
+ cacheErrors: options?.cacheErrors,
890
+ cache: {
891
+ get: async (key) => this.get(key),
892
+ /* v8 ignore next -- @preserve */
893
+ has: async (key) => this.has(key),
894
+ set: async (key, value, ttl) => {
895
+ await this.set(key, value, { ttl });
896
+ },
897
+ /* v8 ignore next -- @preserve */
898
+ on: (event, listener) => {
899
+ this.on(event, listener);
900
+ },
901
+ /* v8 ignore next -- @preserve */
902
+ emit: (event, ...args) => this.emit(event, ...args)
903
+ },
904
+ cacheId: this._cacheId,
905
+ serialize: options?.serialize
906
+ });
907
+ }
908
+ /**
909
+ * Retrieves the value associated with the given key from the cache. If the key is not found,
910
+ * invokes the provided function to calculate the value, stores it in the cache, and then returns it.
911
+ *
912
+ * @param {GetOrSetKey} key - The key to retrieve or set in the cache. This can also be a function that returns a string key.
913
+ * If a function is provided, it will be called with the cache options to generate the key.
914
+ * @param {() => Promise<T>} function_ - The asynchronous function that computes the value to be cached if the key does not exist.
915
+ * @param {GetOrSetFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors.
916
+ * @return {Promise<T | undefined>} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors.
917
+ */
918
+ async getOrSet(key, function_, options) {
919
+ const getOptions = options?.nonBlocking === void 0 ? void 0 : { nonBlocking: options.nonBlocking };
920
+ return getOrSet$1(key, function_, {
921
+ cache: {
922
+ get: async (key) => this.get(key, getOptions),
923
+ /* v8 ignore next -- @preserve */
924
+ has: async (key) => this.has(key),
925
+ set: async (key, value, ttl) => {
926
+ await this.set(key, value, { ttl });
927
+ },
928
+ /* v8 ignore next -- @preserve */
929
+ on: (event, listener) => {
930
+ /* v8 ignore next -- @preserve */
931
+ this.on(event, listener);
932
+ },
933
+ emit: (event, ...args) => this.emit(event, ...args)
934
+ },
935
+ cacheId: this._cacheId,
936
+ ttl: options?.ttl ?? this._ttl,
937
+ cacheErrors: options?.cacheErrors,
938
+ throwErrors: options?.throwErrors,
939
+ nonBlocking: options?.nonBlocking
940
+ });
941
+ }
942
+ /**
943
+ * Will hash an object asynchronously using the specified cryptographic algorithm.
944
+ * Use this for cryptographic algorithms (SHA-256, SHA-384, SHA-512).
945
+ * For non-cryptographic algorithms, use hashSync() for better performance.
946
+ * @param {any} object the object to hash
947
+ * @param {string} algorithm the hash algorithm to use. The default is 'SHA-256'
948
+ * @returns {Promise<string>} the hash of the object
949
+ */
950
+ async hash(object, algorithm = HashAlgorithm$1.SHA256) {
951
+ return hash$1(object, { algorithm });
952
+ }
953
+ /**
954
+ * Will hash an object synchronously using the specified non-cryptographic algorithm.
955
+ * Use this for non-cryptographic algorithms (DJB2, FNV1, MURMER, CRC32).
956
+ * For cryptographic algorithms, use hash() instead.
957
+ * @param {any} object the object to hash
958
+ * @param {string} algorithm the hash algorithm to use. The default is 'djb2'
959
+ * @returns {string} the hash of the object
960
+ */
961
+ hashSync(object, algorithm = HashAlgorithm$1.DJB2) {
962
+ return hashSync(object, { algorithm });
963
+ }
964
+ async setManyKeyv(keyv, items, store) {
965
+ const maxTtlMs = shorthandToMilliseconds$1(this._maxTtl);
966
+ const entries = [];
967
+ for (const item of items) {
968
+ const finalTtl = this.resolveStoreTtl(item.ttl, keyv.ttl, store, maxTtlMs);
969
+ entries.push({
970
+ key: item.key,
971
+ value: item.value,
972
+ ttl: finalTtl
973
+ });
974
+ }
975
+ await keyv.setMany(entries);
976
+ return true;
977
+ }
978
+ /**
979
+ * Writes tag snapshots for `setMany` items that carry tags and removes any previous snapshots
980
+ * for items that do not.
981
+ */
982
+ async setManyKeyTags(items) {
983
+ const maxTtlMs = shorthandToMilliseconds$1(this._maxTtl);
984
+ const promises = [];
985
+ const untaggedKeys = [];
986
+ for (const item of items) {
987
+ if (!item.tags || item.tags.length === 0) {
988
+ untaggedKeys.push(item.key);
989
+ continue;
990
+ }
991
+ const primaryTtl = this.resolveStoreTtl(item.ttl, this._primary.ttl, "primary", maxTtlMs);
992
+ const secondaryTtl = this._secondary ? this.resolveStoreTtl(item.ttl, this._secondary.ttl, "secondary", maxTtlMs) : void 0;
993
+ const ttl = this.maxStoreTtl(primaryTtl, secondaryTtl);
994
+ promises.push(this._tags.setKeyTags(item.key, item.tags, {
995
+ ttl,
996
+ nonBlocking: this._nonBlocking
997
+ }));
998
+ }
999
+ if (untaggedKeys.length > 0) promises.push(this._tags.removeKeys(untaggedKeys, { nonBlocking: this._nonBlocking }));
1000
+ await Promise.all(promises);
1001
+ }
1002
+ /**
1003
+ * Processes a single key from secondary store for getRaw operation
1004
+ * @param primary - the primary store to use
1005
+ * @param secondary - the secondary store to use
1006
+ * @param key - The key to retrieve from secondary store
1007
+ * @returns Promise containing the result and TTL information
1008
+ */
1009
+ async processSecondaryForGetRaw(primary, secondary, key) {
1010
+ const secondaryResult = await secondary.getRaw(key);
1011
+ if (secondaryResult?.value) {
1012
+ this.emit("cache:hit", {
1013
+ key,
1014
+ value: secondaryResult.value,
1015
+ store: "secondary"
1016
+ });
1017
+ const ttl = calculateTtlFromExpiration$1(getCascadingTtl$1(this._ttl, this._primary.ttl), secondaryResult.expires ?? void 0);
1018
+ const setItem = {
1019
+ key,
1020
+ value: secondaryResult.value,
1021
+ ttl
1022
+ };
1023
+ await this.hook("BEFORE_SECONDARY_SETS_PRIMARY", setItem);
1024
+ await primary.set(setItem.key, setItem.value, resolvePerStoreTtl(setItem.ttl).primary);
1025
+ return {
1026
+ result: secondaryResult,
1027
+ ttl
1028
+ };
1029
+ } else {
1030
+ this.emit("cache:miss", {
1031
+ key,
1032
+ store: "secondary"
1033
+ });
1034
+ return;
1035
+ }
1036
+ }
1037
+ /**
1038
+ * Processes a single key from secondary store for getRaw operation in non-blocking mode
1039
+ * Non-blocking mode means we don't wait for secondary operations that update primary store
1040
+ * @param primary - the primary store to use
1041
+ * @param secondary - the secondary store to use
1042
+ * @param key - The key to retrieve from secondary store
1043
+ * @returns Promise containing the result and TTL information
1044
+ */
1045
+ async processSecondaryForGetRawNonBlocking(primary, secondary, key) {
1046
+ const secondaryResult = await secondary.getRaw(key);
1047
+ if (secondaryResult?.value) {
1048
+ this.emit("cache:hit", {
1049
+ key,
1050
+ value: secondaryResult.value,
1051
+ store: "secondary"
1052
+ });
1053
+ const ttl = calculateTtlFromExpiration$1(getCascadingTtl$1(this._ttl, this._primary.ttl), secondaryResult.expires ?? void 0);
1054
+ const setItem = {
1055
+ key,
1056
+ value: secondaryResult.value,
1057
+ ttl
1058
+ };
1059
+ /* v8 ignore next -- @preserve */
1060
+ this.hook("BEFORE_SECONDARY_SETS_PRIMARY", setItem).then(async () => {
1061
+ await primary.set(setItem.key, setItem.value, resolvePerStoreTtl(setItem.ttl).primary);
1062
+ }).catch((error) => {
1063
+ /* v8 ignore next -- @preserve */
1064
+ this.emit("error", error);
1065
+ });
1066
+ return {
1067
+ result: secondaryResult,
1068
+ ttl
1069
+ };
1070
+ } else {
1071
+ this.emit("cache:miss", {
1072
+ key,
1073
+ store: "secondary"
1074
+ });
1075
+ return;
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Processes missing keys from secondary store for getManyRaw operation
1080
+ * @param primary - the primary store to use
1081
+ * @param secondary - the secondary store to use
1082
+ * @param keys - The original array of keys requested
1083
+ * @param result - The result array from primary store (will be modified)
1084
+ * @returns Promise<void>
1085
+ */
1086
+ async processSecondaryForGetManyRaw(primary, secondary, keys, result) {
1087
+ const missingKeys = [];
1088
+ for (const [i, key] of keys.entries()) if (!result[i]) missingKeys.push(key);
1089
+ const secondaryResults = await secondary.getManyRaw(missingKeys);
1090
+ let secondaryIndex = 0;
1091
+ for await (const [i, key] of keys.entries()) if (!result[i]) {
1092
+ const secondaryResult = secondaryResults[secondaryIndex];
1093
+ if (secondaryResult && secondaryResult.value !== void 0) {
1094
+ result[i] = secondaryResult;
1095
+ this.emit("cache:hit", {
1096
+ key,
1097
+ value: secondaryResult.value,
1098
+ store: "secondary"
1099
+ });
1100
+ const cascadeTtl = getCascadingTtl$1(this._ttl, this._primary.ttl);
1101
+ let { expires } = secondaryResult;
1102
+ /* v8 ignore next -- @preserve */
1103
+ if (expires === null) expires = void 0;
1104
+ const ttl = calculateTtlFromExpiration$1(cascadeTtl, expires);
1105
+ const setItem = {
1106
+ key,
1107
+ value: secondaryResult.value,
1108
+ ttl
1109
+ };
1110
+ await this.hook("BEFORE_SECONDARY_SETS_PRIMARY", setItem);
1111
+ await primary.set(setItem.key, setItem.value, resolvePerStoreTtl(setItem.ttl).primary);
1112
+ } else this.emit("cache:miss", {
1113
+ key,
1114
+ store: "secondary"
1115
+ });
1116
+ secondaryIndex++;
1117
+ }
1118
+ }
1119
+ /**
1120
+ * Processes missing keys from secondary store for getManyRaw operation in non-blocking mode
1121
+ * Non-blocking mode means we don't wait for secondary operations that update primary store
1122
+ * @param secondary - the secondary store to use
1123
+ * @param keys - The original array of keys requested
1124
+ * @param result - The result array from primary store (will be modified)
1125
+ * @returns Promise<void>
1126
+ */
1127
+ async processSecondaryForGetManyRawNonBlocking(primary, secondary, keys, result) {
1128
+ const missingKeys = [];
1129
+ for (const [i, key] of keys.entries()) if (!result[i]) missingKeys.push(key);
1130
+ const secondaryResults = await secondary.getManyRaw(missingKeys);
1131
+ let secondaryIndex = 0;
1132
+ for await (const [i, key] of keys.entries()) if (!result[i]) {
1133
+ const secondaryResult = secondaryResults[secondaryIndex];
1134
+ if (secondaryResult && secondaryResult.value !== void 0) {
1135
+ result[i] = secondaryResult;
1136
+ this.emit("cache:hit", {
1137
+ key,
1138
+ value: secondaryResult.value,
1139
+ store: "secondary"
1140
+ });
1141
+ const cascadeTtl = getCascadingTtl$1(this._ttl, this._primary.ttl);
1142
+ let { expires } = secondaryResult;
1143
+ /* v8 ignore next -- @preserve */
1144
+ if (expires === null) expires = void 0;
1145
+ const ttl = calculateTtlFromExpiration$1(cascadeTtl, expires);
1146
+ const setItem = {
1147
+ key,
1148
+ value: secondaryResult.value,
1149
+ ttl
1150
+ };
1151
+ /* v8 ignore next -- @preserve */
1152
+ this.hook("BEFORE_SECONDARY_SETS_PRIMARY", setItem).then(async () => {
1153
+ await primary.set(setItem.key, setItem.value, resolvePerStoreTtl(setItem.ttl).primary);
1154
+ }).catch((error) => {
1155
+ /* v8 ignore next -- @preserve */
1156
+ this.emit("error", error);
1157
+ });
1158
+ } else this.emit("cache:miss", {
1159
+ key,
1160
+ store: "secondary"
1161
+ });
1162
+ secondaryIndex++;
1163
+ }
1164
+ }
1165
+ setTtl(ttl) {
1166
+ if (typeof ttl === "string" || ttl === void 0) this._ttl = ttl;
1167
+ else if (ttl > 0) this._ttl = ttl;
1168
+ else this._ttl = void 0;
1169
+ }
1170
+ setMaxTtl(maxTtl) {
1171
+ if (typeof maxTtl === "string" || maxTtl === void 0) this._maxTtl = maxTtl;
1172
+ else if (maxTtl > 0) this._maxTtl = maxTtl;
1173
+ else this._maxTtl = void 0;
1174
+ }
1175
+ capTtl(ttl, maxTtlMs) {
1176
+ if (ttl !== void 0 && (Number.isNaN(ttl) || ttl < 0)) ttl = void 0;
1177
+ if (maxTtlMs === void 0) return ttl;
1178
+ if (ttl === void 0) return maxTtlMs;
1179
+ return Math.min(ttl, maxTtlMs);
1180
+ }
1181
+ /**
1182
+ * Resolves the ttl for a tag snapshot so it outlives the longest-lived copy of the value across
1183
+ * the stores. With a secondary store the snapshot uses the larger of the two ttls and never
1184
+ * expires if either copy never expires; with only a primary store it tracks the primary ttl.
1185
+ * @param primaryTtl - the resolved primary store ttl in milliseconds, or undefined for no expiry
1186
+ * @param secondaryTtl - the resolved secondary store ttl in milliseconds, or undefined for no expiry
1187
+ * @returns {number | undefined} The tag snapshot ttl in milliseconds, or undefined for no expiry
1188
+ */
1189
+ maxStoreTtl(primaryTtl, secondaryTtl) {
1190
+ if (!this._secondary) return primaryTtl;
1191
+ if (!primaryTtl || !secondaryTtl) return;
1192
+ return Math.max(primaryTtl, secondaryTtl);
1193
+ }
1194
+ /**
1195
+ * Resolves the effective ttl actually written to one store for a `setMany` item: the per-store
1196
+ * explicit value (a scalar applies to both stores; a `{ primary, secondary }` object is honored
1197
+ * per field) cascaded with the store default and instance ttl, then capped by maxTtl.
1198
+ * @param itemTtl - the item's ttl (number, shorthand string, or per-store object)
1199
+ * @param storeTtl - the target store's default ttl in milliseconds
1200
+ * @param store - which store's field to resolve from a per-store object
1201
+ * @param maxTtlMs - the resolved maxTtl in milliseconds, or undefined for no cap
1202
+ * @returns {number | undefined} The effective ttl in milliseconds, or undefined for no expiry
1203
+ */
1204
+ resolveStoreTtl(itemTtl, storeTtl, store, maxTtlMs) {
1205
+ const explicitTtl = resolvePerStoreTtl(itemTtl)[store];
1206
+ return this.capTtl(getCascadingTtl$1(this._ttl, storeTtl, explicitTtl), maxTtlMs);
1207
+ }
1208
+ };
1209
+ //#endregion
1210
+ export { CacheTags, Cacheable, CacheableEvents, CacheableHooks, CacheableMemory, CacheableStats, CacheableSync, CacheableSyncEvents, HashAlgorithm, Keyv, KeyvCacheableMemory, KeyvHooks, calculateTtlFromExpiration, createKeyv, getCascadingTtl, getOrSet, hash, shorthandToMilliseconds, shorthandToTime, wrap, wrapSync };