@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
@@ -1,1141 +0,0 @@
1
- // src/index.ts
2
- import { createKeyv } from "@cacheable/memory";
3
- import {
4
- Stats as CacheableStats,
5
- calculateTtlFromExpiration,
6
- getCascadingTtl,
7
- getOrSet,
8
- HashAlgorithm,
9
- hash,
10
- hashSync,
11
- isKeyvInstance,
12
- shorthandToMilliseconds,
13
- wrap
14
- } from "@cacheable/utils";
15
- import { Hookified as Hookified2 } from "hookified";
16
- import {
17
- Keyv
18
- } from "keyv";
19
-
20
- // src/enums.ts
21
- var CacheableHooks = /* @__PURE__ */ ((CacheableHooks2) => {
22
- CacheableHooks2["BEFORE_SET"] = "BEFORE_SET";
23
- CacheableHooks2["AFTER_SET"] = "AFTER_SET";
24
- CacheableHooks2["BEFORE_SET_MANY"] = "BEFORE_SET_MANY";
25
- CacheableHooks2["AFTER_SET_MANY"] = "AFTER_SET_MANY";
26
- CacheableHooks2["BEFORE_GET"] = "BEFORE_GET";
27
- CacheableHooks2["AFTER_GET"] = "AFTER_GET";
28
- CacheableHooks2["BEFORE_GET_MANY"] = "BEFORE_GET_MANY";
29
- CacheableHooks2["AFTER_GET_MANY"] = "AFTER_GET_MANY";
30
- CacheableHooks2["BEFORE_SECONDARY_SETS_PRIMARY"] = "BEFORE_SECONDARY_SETS_PRIMARY";
31
- return CacheableHooks2;
32
- })(CacheableHooks || {});
33
- var CacheableEvents = /* @__PURE__ */ ((CacheableEvents2) => {
34
- CacheableEvents2["ERROR"] = "error";
35
- CacheableEvents2["CACHE_HIT"] = "cache:hit";
36
- CacheableEvents2["CACHE_MISS"] = "cache:miss";
37
- return CacheableEvents2;
38
- })(CacheableEvents || {});
39
-
40
- // src/sync.ts
41
- import { Hookified } from "hookified";
42
- import { Qified } from "qified";
43
- var CacheableSyncEvents = /* @__PURE__ */ ((CacheableSyncEvents2) => {
44
- CacheableSyncEvents2["ERROR"] = "error";
45
- CacheableSyncEvents2["SET"] = "cache:set";
46
- CacheableSyncEvents2["DELETE"] = "cache:delete";
47
- return CacheableSyncEvents2;
48
- })(CacheableSyncEvents || {});
49
- var CacheableSync = class extends Hookified {
50
- _qified = new Qified();
51
- _namespace;
52
- _storage;
53
- _cacheId;
54
- /**
55
- * Creates an instance of CacheableSync
56
- * @param options - Configuration options for CacheableSync
57
- */
58
- constructor(options) {
59
- super(options);
60
- this._namespace = options.namespace;
61
- this._qified = this.createQified(options.qified);
62
- }
63
- /**
64
- * Gets the Qified instance used for synchronization
65
- * @returns The Qified instance
66
- */
67
- get qified() {
68
- return this._qified;
69
- }
70
- /**
71
- * Sets the Qified instance used for synchronization
72
- * @param value - Either an existing Qified instance or MessageProvider(s)
73
- */
74
- set qified(value) {
75
- this._qified = this.createQified(value);
76
- }
77
- /**
78
- * Gets the namespace for sync events
79
- * @returns The namespace or undefined if not set
80
- */
81
- get namespace() {
82
- return this._namespace;
83
- }
84
- /**
85
- * Sets the namespace for sync events and resubscribes if needed
86
- * @param namespace - The namespace string or function
87
- */
88
- set namespace(namespace) {
89
- if (this._storage && this._cacheId) {
90
- const oldSetEvent = this.getPrefixedEvent("cache:set" /* SET */);
91
- const oldDeleteEvent = this.getPrefixedEvent("cache:delete" /* DELETE */);
92
- void this._qified.unsubscribeMessage(oldSetEvent);
93
- void this._qified.unsubscribeMessage(oldDeleteEvent);
94
- }
95
- this._namespace = namespace;
96
- if (this._storage && this._cacheId) {
97
- this.subscribe(this._storage, this._cacheId);
98
- }
99
- }
100
- /**
101
- * Publishes a cache event to all the cache instances
102
- * @param data - The cache item data containing cacheId, key, value, and optional ttl
103
- */
104
- async publish(event, data) {
105
- const eventName = this.getPrefixedEvent(event);
106
- await this._qified.publish(eventName, {
107
- id: crypto.randomUUID(),
108
- data
109
- });
110
- }
111
- /**
112
- * Subscribes to sync events and updates the provided storage
113
- * @param storage - The Keyv storage instance to update
114
- * @param cacheId - The cache ID to identify this instance
115
- */
116
- subscribe(storage, cacheId) {
117
- this._storage = storage;
118
- this._cacheId = cacheId;
119
- const setEvent = this.getPrefixedEvent("cache:set" /* SET */);
120
- const deleteEvent = this.getPrefixedEvent("cache:delete" /* DELETE */);
121
- this._qified.subscribe(setEvent, {
122
- handler: async (message) => {
123
- const data = message.data;
124
- if (data.cacheId !== cacheId) {
125
- await storage.set(data.key, data.value, data.ttl);
126
- }
127
- }
128
- });
129
- this._qified.subscribe(deleteEvent, {
130
- handler: async (message) => {
131
- const data = message.data;
132
- if (data.cacheId !== cacheId) {
133
- await storage.delete(data.key);
134
- }
135
- }
136
- });
137
- }
138
- /**
139
- * Creates or returns a Qified instance from the provided value
140
- * @param value - Either an existing Qified instance or MessageProvider(s)
141
- * @returns A Qified instance configured with the provided message provider(s)
142
- */
143
- createQified(value) {
144
- if (value instanceof Qified) {
145
- return value;
146
- }
147
- const providers = Array.isArray(value) ? value : [value];
148
- return new Qified({ messageProviders: providers });
149
- }
150
- /**
151
- * Gets the namespace prefix to use for event names
152
- * @returns The resolved namespace string or undefined
153
- */
154
- getNamespace() {
155
- if (typeof this._namespace === "function") {
156
- return this._namespace();
157
- }
158
- return this._namespace;
159
- }
160
- /**
161
- * Prefixes an event name with the namespace if one is set
162
- * @param event - The event to prefix
163
- * @returns The prefixed event name or the original event
164
- */
165
- getPrefixedEvent(event) {
166
- const ns = this.getNamespace();
167
- return ns ? `${ns}::${event}` : event;
168
- }
169
- };
170
-
171
- // src/index.ts
172
- import {
173
- CacheableMemory,
174
- createKeyv as createKeyv2,
175
- KeyvCacheableMemory
176
- } from "@cacheable/memory";
177
- import {
178
- calculateTtlFromExpiration as calculateTtlFromExpiration2,
179
- getCascadingTtl as getCascadingTtl2,
180
- getOrSet as getOrSet2,
181
- HashAlgorithm as HashAlgorithm2,
182
- hash as hash2,
183
- Stats,
184
- shorthandToMilliseconds as shorthandToMilliseconds2,
185
- shorthandToTime,
186
- wrap as wrap2,
187
- wrapSync
188
- } from "@cacheable/utils";
189
- import { Keyv as Keyv2, KeyvHooks } from "keyv";
190
- var Cacheable = class extends Hookified2 {
191
- _primary = createKeyv();
192
- _secondary;
193
- _nonBlocking = false;
194
- _ttl;
195
- _stats = new CacheableStats({ enabled: false });
196
- _namespace;
197
- _cacheId = Math.random().toString(36).slice(2);
198
- _sync;
199
- /**
200
- * Creates a new cacheable instance
201
- * @param {CacheableOptions} [options] The options for the cacheable instance
202
- */
203
- constructor(options) {
204
- super();
205
- if (options?.primary) {
206
- this.setPrimary(options.primary);
207
- }
208
- if (options?.secondary) {
209
- this.setSecondary(options.secondary);
210
- }
211
- if (options?.nonBlocking) {
212
- this._nonBlocking = options.nonBlocking;
213
- }
214
- if (options?.stats) {
215
- this._stats.enabled = options.stats;
216
- }
217
- if (options?.ttl) {
218
- this.setTtl(options.ttl);
219
- }
220
- if (options?.cacheId) {
221
- this._cacheId = options.cacheId;
222
- }
223
- if (options?.namespace) {
224
- this._namespace = options.namespace;
225
- this._primary.namespace = this.getNameSpace();
226
- if (this._secondary) {
227
- this._secondary.namespace = this.getNameSpace();
228
- }
229
- }
230
- if (options?.sync) {
231
- this._sync = options.sync instanceof CacheableSync ? options.sync : new CacheableSync({
232
- ...options.sync,
233
- namespace: options.namespace
234
- });
235
- this._sync.subscribe(this._primary, this._cacheId);
236
- }
237
- }
238
- /**
239
- * The namespace for the cacheable instance
240
- * @returns {string | (() => string) | undefined} The namespace for the cacheable instance
241
- */
242
- get namespace() {
243
- return this._namespace;
244
- }
245
- /**
246
- * Sets the namespace for the cacheable instance
247
- * @param {string | (() => string) | undefined} namespace The namespace for the cacheable instance
248
- * @returns {void}
249
- */
250
- set namespace(namespace) {
251
- this._namespace = namespace;
252
- this._primary.namespace = this.getNameSpace();
253
- if (this._secondary) {
254
- this._secondary.namespace = this.getNameSpace();
255
- }
256
- if (this._sync) {
257
- this._sync.namespace = namespace;
258
- }
259
- }
260
- /**
261
- * The statistics for the cacheable instance
262
- * @returns {CacheableStats} The statistics for the cacheable instance
263
- */
264
- get stats() {
265
- return this._stats;
266
- }
267
- /**
268
- * The primary store for the cacheable instance
269
- * @returns {Keyv} The primary store for the cacheable instance
270
- */
271
- get primary() {
272
- return this._primary;
273
- }
274
- /**
275
- * Sets the primary store for the cacheable instance
276
- * @param {Keyv} primary The primary store for the cacheable instance
277
- */
278
- set primary(primary) {
279
- this._primary = primary;
280
- }
281
- /**
282
- * The secondary store for the cacheable instance
283
- * @returns {Keyv | undefined} The secondary store for the cacheable instance
284
- */
285
- get secondary() {
286
- return this._secondary;
287
- }
288
- /**
289
- * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
290
- * @param {Keyv | undefined} secondary The secondary store for the cacheable instance
291
- * @returns {void}
292
- */
293
- set secondary(secondary) {
294
- this._secondary = secondary;
295
- }
296
- /**
297
- * Gets whether the secondary store is non-blocking mode. It is set to false by default.
298
- * If it is set to true then the secondary store will not block the primary store.
299
- *
300
- * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
301
- *
302
- * @returns {boolean} Whether the cacheable instance is non-blocking
303
- */
304
- get nonBlocking() {
305
- return this._nonBlocking;
306
- }
307
- /**
308
- * Sets whether the secondary store is non-blocking mode. It is set to false by default.
309
- * If it is set to true then the secondary store will not block the primary store.
310
- *
311
- * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
312
- *
313
- * @param {boolean} nonBlocking Whether the cacheable instance is non-blocking
314
- * @returns {void}
315
- */
316
- set nonBlocking(nonBlocking) {
317
- this._nonBlocking = nonBlocking;
318
- }
319
- /**
320
- * The time-to-live for the cacheable instance and will be used as the default value.
321
- * can be a number in milliseconds or a human-readable format such as `1s` for 1 second or `1h` for 1 hour
322
- * or undefined if there is no time-to-live.
323
- *
324
- * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
325
- *
326
- * @returns {number | string | undefined} The time-to-live for the cacheable instance in milliseconds, human-readable format or undefined
327
- * @example
328
- * ```typescript
329
- * const cacheable = new Cacheable({ ttl: '1h' });
330
- * console.log(cacheable.ttl); // 1h
331
- * ```
332
- */
333
- get ttl() {
334
- return this._ttl;
335
- }
336
- /**
337
- * Sets the time-to-live for the cacheable instance and will be used as the default value.
338
- * If you set a number it is miliseconds, if you set a string it is a human-readable
339
- * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that
340
- * there is no time-to-live.
341
- *
342
- * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
343
- *
344
- * @param {number | string | undefined} ttl The time-to-live for the cacheable instance
345
- * @example
346
- * ```typescript
347
- * const cacheable = new Cacheable();
348
- * cacheable.ttl = '1h'; // Set the time-to-live to 1 hour
349
- * ```
350
- * or setting the time-to-live in milliseconds
351
- * ```typescript
352
- * const cacheable = new Cacheable();
353
- * cacheable.ttl = 3600000; // Set the time-to-live to 1 hour
354
- * ```
355
- */
356
- set ttl(ttl) {
357
- this.setTtl(ttl);
358
- }
359
- /**
360
- * The cacheId for the cacheable instance. This is primarily used for the wrap function to not have conflicts.
361
- * If it is not set then it will be a random string that is generated
362
- * @returns {string} The cacheId for the cacheable instance
363
- */
364
- get cacheId() {
365
- return this._cacheId;
366
- }
367
- /**
368
- * Sets the cacheId for the cacheable instance. This is primarily used for the wrap function to not have conflicts.
369
- * If it is not set then it will be a random string that is generated
370
- * @param {string} cacheId The cacheId for the cacheable instance
371
- */
372
- set cacheId(cacheId) {
373
- this._cacheId = cacheId;
374
- }
375
- /**
376
- * Gets the sync instance for the cacheable instance
377
- * @returns {CacheableSync | undefined} The sync instance for the cacheable instance
378
- */
379
- get sync() {
380
- return this._sync;
381
- }
382
- /**
383
- * Sets the sync instance for the cacheable instance
384
- * @param {CacheableSync | undefined} sync The sync instance for the cacheable instance
385
- */
386
- set sync(sync) {
387
- this._sync = sync;
388
- if (this._sync) {
389
- this._sync.subscribe(this._primary, this._cacheId);
390
- }
391
- }
392
- /**
393
- * Sets the primary store for the cacheable instance
394
- * @param {Keyv | KeyvStoreAdapter} primary The primary store for the cacheable instance
395
- * @returns {void}
396
- */
397
- setPrimary(primary) {
398
- if (isKeyvInstance(primary)) {
399
- this._primary = primary;
400
- } else {
401
- this._primary = new Keyv(primary);
402
- }
403
- this._primary.on("error", (error) => {
404
- this.emit("error" /* ERROR */, error);
405
- });
406
- }
407
- /**
408
- * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
409
- * @param {Keyv | KeyvStoreAdapter} secondary The secondary store for the cacheable instance
410
- * @returns {void}
411
- */
412
- setSecondary(secondary) {
413
- if (isKeyvInstance(secondary)) {
414
- this._secondary = secondary;
415
- } else {
416
- this._secondary = new Keyv(secondary);
417
- }
418
- this._secondary.on("error", (error) => {
419
- this.emit("error" /* ERROR */, error);
420
- });
421
- }
422
- getNameSpace() {
423
- if (typeof this._namespace === "function") {
424
- return this._namespace();
425
- }
426
- return this._namespace;
427
- }
428
- /**
429
- * Retrieves an entry from the cache.
430
- *
431
- * Checks the primary store first; if not found and a secondary store is configured,
432
- * it will fetch from the secondary, repopulate the primary, and return the result.
433
- *
434
- * @typeParam T - The expected type of the stored value.
435
- * @param {string} key - The cache key to retrieve.
436
- * @param {GetOptions} - options such as to bypass `nonBlocking` for this call
437
- * @returns {Promise<T | undefined>}
438
- * A promise that resolves to the cached value if found, or `undefined`.
439
- */
440
- async get(key, options) {
441
- const result = await this.getRaw(key, options);
442
- return result?.value;
443
- }
444
- /**
445
- * Retrieves the raw entry from the cache including metadata like expiration.
446
- *
447
- * Checks the primary store first; if not found and a secondary store is configured,
448
- * it will fetch from the secondary, repopulate the primary, and return the result.
449
- *
450
- * @typeParam T - The expected type of the stored value.
451
- * @param {string} key - The cache key to retrieve.
452
- * @param {GetOptions} - options such as to bypass `nonBlocking` for this call
453
- * @returns {Promise<StoredDataRaw<T>>}
454
- * A promise that resolves to the full raw data object if found, or undefined.
455
- */
456
- async getRaw(key, options) {
457
- let result;
458
- try {
459
- await this.hook("BEFORE_GET" /* BEFORE_GET */, key);
460
- result = await this._primary.getRaw(key);
461
- let ttl;
462
- if (result) {
463
- this.emit("cache:hit" /* CACHE_HIT */, {
464
- key,
465
- value: result.value,
466
- store: "primary"
467
- });
468
- } else {
469
- this.emit("cache:miss" /* CACHE_MISS */, { key, store: "primary" });
470
- }
471
- const nonBlocking = options?.nonBlocking ?? this._nonBlocking;
472
- if (!result && this._secondary) {
473
- let secondaryProcessResult;
474
- if (nonBlocking) {
475
- secondaryProcessResult = await this.processSecondaryForGetRawNonBlocking(
476
- this._primary,
477
- this._secondary,
478
- key
479
- );
480
- } else {
481
- secondaryProcessResult = await this.processSecondaryForGetRaw(
482
- this._primary,
483
- this._secondary,
484
- key
485
- );
486
- }
487
- if (secondaryProcessResult) {
488
- result = secondaryProcessResult.result;
489
- ttl = secondaryProcessResult.ttl;
490
- }
491
- }
492
- await this.hook("AFTER_GET" /* AFTER_GET */, { key, result, ttl });
493
- } catch (error) {
494
- this.emit("error" /* ERROR */, error);
495
- }
496
- if (this.stats.enabled) {
497
- if (result) {
498
- this._stats.incrementHits();
499
- } else {
500
- this._stats.incrementMisses();
501
- }
502
- this.stats.incrementGets();
503
- }
504
- return result;
505
- }
506
- /**
507
- * Retrieves multiple raw entries from the cache including metadata like expiration.
508
- *
509
- * Checks the primary store for each key; if a key is missing and a secondary store is configured,
510
- * it will fetch from the secondary store, repopulate the primary store, and return the results.
511
- *
512
- * @typeParam T - The expected type of the stored values.
513
- * @param {string[]} keys - The cache keys to retrieve.
514
- * @param {GetOptions} - options such as to bypass `nonBlocking` on this call
515
- * @returns {Promise<Array<StoredDataRaw<T>>>}
516
- * A promise that resolves to an array of raw data objects.
517
- */
518
- async getManyRaw(keys, options) {
519
- let result = [];
520
- try {
521
- await this.hook("BEFORE_GET_MANY" /* BEFORE_GET_MANY */, keys);
522
- result = await this._primary.getManyRaw(keys);
523
- for (const [i, key] of keys.entries()) {
524
- if (result[i]) {
525
- this.emit("cache:hit" /* CACHE_HIT */, {
526
- key,
527
- value: result[i].value,
528
- store: "primary"
529
- });
530
- } else {
531
- this.emit("cache:miss" /* CACHE_MISS */, { key, store: "primary" });
532
- }
533
- }
534
- const nonBlocking = options?.nonBlocking ?? this._nonBlocking;
535
- if (this._secondary) {
536
- if (nonBlocking) {
537
- await this.processSecondaryForGetManyRawNonBlocking(
538
- this._primary,
539
- this._secondary,
540
- keys,
541
- result
542
- );
543
- } else {
544
- await this.processSecondaryForGetManyRaw(
545
- this._primary,
546
- this._secondary,
547
- keys,
548
- result
549
- );
550
- }
551
- }
552
- await this.hook("AFTER_GET_MANY" /* AFTER_GET_MANY */, { keys, result });
553
- } catch (error) {
554
- this.emit("error" /* ERROR */, error);
555
- }
556
- if (this.stats.enabled) {
557
- for (const item of result) {
558
- if (item) {
559
- this._stats.incrementHits();
560
- } else {
561
- this._stats.incrementMisses();
562
- }
563
- }
564
- this.stats.incrementGets();
565
- }
566
- return result;
567
- }
568
- /**
569
- * Retrieves multiple entries from the cache.
570
- * Checks the primary store for each key; if a key is missing and a secondary store is configured,
571
- * it will fetch from the secondary store, repopulate the primary store, and return the results.
572
- *
573
- * @typeParam T - The expected type of the stored values.
574
- * @param {string[]} keys - The cache keys to retrieve.
575
- * @param {GetOptions} - options such as to bypass `nonBlocking` on this call
576
- * @returns {Promise<Array<T | undefined>>}
577
- * A promise that resolves to an array of cached values or `undefined` for misses.
578
- */
579
- async getMany(keys, options) {
580
- const result = await this.getManyRaw(keys, options);
581
- return result.map((item) => item?.value);
582
- }
583
- /**
584
- * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store.
585
- * @param {string} key the key to set the value of
586
- * @param {T} value The value to set
587
- * @param {number | string} [ttl] set a number it is miliseconds, set a string it is a human-readable
588
- * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live.
589
- * @returns {boolean} Whether the value was set
590
- */
591
- async set(key, value, ttl) {
592
- let result = false;
593
- const explicitTtl = shorthandToMilliseconds(ttl);
594
- try {
595
- const primaryTtl = getCascadingTtl(
596
- this._ttl,
597
- this._primary.ttl,
598
- explicitTtl
599
- );
600
- const item = { key, value, ttl: primaryTtl };
601
- await this.hook("BEFORE_SET" /* BEFORE_SET */, item);
602
- const hookOverridden = item.ttl !== primaryTtl;
603
- const promises = [];
604
- promises.push(this._primary.set(item.key, item.value, item.ttl));
605
- if (this._secondary) {
606
- const secondaryTtl = hookOverridden ? item.ttl : getCascadingTtl(this._ttl, this._secondary.ttl, explicitTtl);
607
- promises.push(this._secondary.set(item.key, item.value, secondaryTtl));
608
- }
609
- if (this._nonBlocking) {
610
- result = await Promise.race(promises);
611
- for (const promise of promises) {
612
- promise.catch((error) => {
613
- this.emit("error" /* ERROR */, error);
614
- });
615
- }
616
- } else {
617
- const results = await Promise.all(promises);
618
- result = results[0];
619
- }
620
- await this.hook("AFTER_SET" /* AFTER_SET */, item);
621
- if (this._sync && result) {
622
- await this._sync.publish("cache:set" /* SET */, {
623
- cacheId: this._cacheId,
624
- key: item.key,
625
- value: item.value,
626
- ttl: item.ttl
627
- });
628
- }
629
- } catch (error) {
630
- this.emit("error" /* ERROR */, error);
631
- }
632
- if (this.stats.enabled) {
633
- this.stats.incrementKSize(key);
634
- this.stats.incrementCount();
635
- this.stats.incrementVSize(value);
636
- this.stats.incrementSets();
637
- }
638
- return result;
639
- }
640
- /**
641
- * Sets the values of the keys. If the secondary store is set then it will also set the values in the secondary store.
642
- * @param {CacheableItem[]} items The items to set
643
- * @returns {boolean} Whether the values were set
644
- */
645
- async setMany(items) {
646
- let result = false;
647
- try {
648
- await this.hook("BEFORE_SET_MANY" /* BEFORE_SET_MANY */, items);
649
- result = await this.setManyKeyv(this._primary, items);
650
- if (this._secondary) {
651
- if (this._nonBlocking) {
652
- this.setManyKeyv(this._secondary, items).catch((error) => {
653
- this.emit("error" /* ERROR */, error);
654
- });
655
- } else {
656
- await this.setManyKeyv(this._secondary, items);
657
- }
658
- }
659
- await this.hook("AFTER_SET_MANY" /* AFTER_SET_MANY */, items);
660
- if (this._sync && result) {
661
- for (const item of items) {
662
- await this._sync.publish("cache:set" /* SET */, {
663
- cacheId: this._cacheId,
664
- key: item.key,
665
- value: item.value,
666
- ttl: shorthandToMilliseconds(item.ttl)
667
- });
668
- }
669
- }
670
- } catch (error) {
671
- this.emit("error" /* ERROR */, error);
672
- }
673
- if (this.stats.enabled) {
674
- for (const item of items) {
675
- this.stats.incrementKSize(item.key);
676
- this.stats.incrementCount();
677
- this.stats.incrementVSize(item.value);
678
- }
679
- }
680
- return result;
681
- }
682
- /**
683
- * Takes the value of the key and deletes the key. If the key does not exist then it will return undefined.
684
- * @param {string} key The key to take the value of
685
- * @returns {Promise<T | undefined>} The value of the key or undefined if the key does not exist
686
- */
687
- async take(key) {
688
- const result = await this.get(key);
689
- await this.delete(key);
690
- return result;
691
- }
692
- /**
693
- * Takes the values of the keys and deletes the keys. If the key does not exist then it will return undefined.
694
- * @param {string[]} keys The keys to take the values of
695
- * @returns {Promise<Array<T | undefined>>} The values of the keys or undefined if the key does not exist
696
- */
697
- async takeMany(keys) {
698
- const result = await this.getMany(keys);
699
- await this.deleteMany(keys);
700
- return result;
701
- }
702
- /**
703
- * Checks if the key exists in the primary store. If it does not exist then it will check the secondary store.
704
- * @param {string} key The key to check
705
- * @returns {Promise<boolean>} Whether the key exists
706
- */
707
- async has(key) {
708
- const promises = [];
709
- promises.push(this._primary.has(key));
710
- if (this._secondary) {
711
- promises.push(this._secondary.has(key));
712
- }
713
- const resultAll = await Promise.all(promises);
714
- for (const result of resultAll) {
715
- if (result) {
716
- return true;
717
- }
718
- }
719
- return false;
720
- }
721
- /**
722
- * Checks if the keys exist in the primary store. If it does not exist then it will check the secondary store.
723
- * @param {string[]} keys The keys to check
724
- * @returns {Promise<boolean[]>} Whether the keys exist
725
- */
726
- async hasMany(keys) {
727
- const result = await this._primary.hasMany(keys);
728
- const missingKeys = [];
729
- for (const [i, key] of keys.entries()) {
730
- if (!result[i] && this._secondary) {
731
- missingKeys.push(key);
732
- }
733
- }
734
- if (missingKeys.length > 0 && this._secondary) {
735
- const secondary = await this._secondary.hasMany(keys);
736
- for (const [i, _key] of keys.entries()) {
737
- if (!result[i] && secondary[i]) {
738
- result[i] = secondary[i];
739
- }
740
- }
741
- }
742
- return result;
743
- }
744
- /**
745
- * Deletes the key from the primary store. If the secondary store is set then it will also delete the key from the secondary store.
746
- * @param {string} key The key to delete
747
- * @returns {Promise<boolean>} Whether the key was deleted
748
- */
749
- async delete(key) {
750
- let result = false;
751
- const promises = [];
752
- if (this.stats.enabled) {
753
- const statResult = await this._primary.get(key);
754
- if (statResult) {
755
- this.stats.decreaseKSize(key);
756
- this.stats.decreaseVSize(statResult);
757
- this.stats.decreaseCount();
758
- this.stats.incrementDeletes();
759
- }
760
- }
761
- promises.push(this._primary.delete(key));
762
- if (this._secondary) {
763
- promises.push(this._secondary.delete(key));
764
- }
765
- if (this.nonBlocking) {
766
- result = await Promise.race(promises);
767
- for (const promise of promises) {
768
- promise.catch((error) => {
769
- this.emit("error" /* ERROR */, error);
770
- });
771
- }
772
- } else {
773
- const resultAll = await Promise.all(promises);
774
- result = resultAll[0];
775
- }
776
- if (this._sync && result) {
777
- await this._sync.publish("cache:delete" /* DELETE */, {
778
- cacheId: this._cacheId,
779
- key
780
- });
781
- }
782
- return result;
783
- }
784
- /**
785
- * Deletes the keys from the primary store. If the secondary store is set then it will also delete the keys from the secondary store.
786
- * @param {string[]} keys The keys to delete
787
- * @returns {Promise<boolean>} Whether the keys were deleted
788
- */
789
- async deleteMany(keys) {
790
- if (this.stats.enabled) {
791
- const statResult = await this._primary.get(keys);
792
- for (const key of keys) {
793
- this.stats.decreaseKSize(key);
794
- this.stats.decreaseVSize(statResult);
795
- this.stats.decreaseCount();
796
- this.stats.incrementDeletes();
797
- }
798
- }
799
- const result = await this._primary.deleteMany(keys);
800
- if (this._secondary) {
801
- if (this._nonBlocking) {
802
- this._secondary.deleteMany(keys).catch((error) => {
803
- this.emit("error" /* ERROR */, error);
804
- });
805
- } else {
806
- await this._secondary.deleteMany(keys);
807
- }
808
- }
809
- if (this._sync && result) {
810
- for (const key of keys) {
811
- await this._sync.publish("cache:delete" /* DELETE */, {
812
- cacheId: this._cacheId,
813
- key
814
- });
815
- }
816
- }
817
- return result;
818
- }
819
- /**
820
- * Clears the primary store. If the secondary store is set then it will also clear the secondary store.
821
- * @returns {Promise<void>}
822
- */
823
- async clear() {
824
- const promises = [];
825
- promises.push(this._primary.clear());
826
- if (this._secondary) {
827
- promises.push(this._secondary.clear());
828
- }
829
- await (this._nonBlocking ? Promise.race(promises) : Promise.all(promises));
830
- if (this.stats.enabled) {
831
- this._stats.resetStoreValues();
832
- this._stats.incrementClears();
833
- }
834
- }
835
- /**
836
- * Disconnects the primary store. If the secondary store is set then it will also disconnect the secondary store.
837
- * @returns {Promise<void>}
838
- */
839
- async disconnect() {
840
- const promises = [];
841
- promises.push(this._primary.disconnect());
842
- if (this._secondary) {
843
- promises.push(this._secondary.disconnect());
844
- }
845
- promises.push(this._sync?.qified.disconnect());
846
- await (this._nonBlocking ? Promise.race(promises) : Promise.all(promises));
847
- }
848
- /**
849
- * Wraps a function with caching
850
- *
851
- * [Learn more about wrapping functions](https://cacheable.org/docs/cacheable/#wrap--memoization-for-sync-and-async-functions).
852
- * @param {Function} function_ The function to wrap
853
- * @param {WrapOptions} [options] The options for the wrap function
854
- * @returns {Function} The wrapped function
855
- */
856
- // biome-ignore lint/suspicious/noExplicitAny: type format
857
- wrap(function_, options) {
858
- const cacheAdapter = {
859
- get: async (key) => this.get(key),
860
- /* v8 ignore next -- @preserve */
861
- has: async (key) => this.has(key),
862
- set: async (key, value, ttl) => {
863
- await this.set(key, value, ttl);
864
- },
865
- /* v8 ignore next -- @preserve */
866
- on: (event, listener) => {
867
- this.on(event, listener);
868
- },
869
- /* v8 ignore next -- @preserve */
870
- emit: (event, ...args) => this.emit(event, ...args)
871
- };
872
- const wrapOptions = {
873
- ttl: options?.ttl ?? this._ttl,
874
- keyPrefix: options?.keyPrefix,
875
- createKey: options?.createKey,
876
- cacheErrors: options?.cacheErrors,
877
- cache: cacheAdapter,
878
- cacheId: this._cacheId,
879
- serialize: options?.serialize
880
- };
881
- return wrap(function_, wrapOptions);
882
- }
883
- /**
884
- * Retrieves the value associated with the given key from the cache. If the key is not found,
885
- * invokes the provided function to calculate the value, stores it in the cache, and then returns it.
886
- *
887
- * @param {GetOrSetKey} key - The key to retrieve or set in the cache. This can also be a function that returns a string key.
888
- * If a function is provided, it will be called with the cache options to generate the key.
889
- * @param {() => Promise<T>} function_ - The asynchronous function that computes the value to be cached if the key does not exist.
890
- * @param {GetOrSetFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors.
891
- * @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.
892
- */
893
- async getOrSet(key, function_, options) {
894
- const getOptions = options?.nonBlocking === void 0 ? void 0 : { nonBlocking: options.nonBlocking };
895
- const cacheAdapter = {
896
- get: async (key2) => this.get(key2, getOptions),
897
- /* v8 ignore next -- @preserve */
898
- has: async (key2) => this.has(key2),
899
- set: async (key2, value, ttl) => {
900
- await this.set(key2, value, ttl);
901
- },
902
- /* v8 ignore next -- @preserve */
903
- on: (event, listener) => {
904
- this.on(event, listener);
905
- },
906
- emit: (event, ...args) => this.emit(event, ...args)
907
- };
908
- const getOrSetOptions = {
909
- cache: cacheAdapter,
910
- cacheId: this._cacheId,
911
- ttl: options?.ttl ?? this._ttl,
912
- cacheErrors: options?.cacheErrors,
913
- throwErrors: options?.throwErrors,
914
- nonBlocking: options?.nonBlocking
915
- };
916
- return getOrSet(key, function_, getOrSetOptions);
917
- }
918
- /**
919
- * Will hash an object asynchronously using the specified cryptographic algorithm.
920
- * Use this for cryptographic algorithms (SHA-256, SHA-384, SHA-512).
921
- * For non-cryptographic algorithms, use hashSync() for better performance.
922
- * @param {any} object the object to hash
923
- * @param {string} algorithm the hash algorithm to use. The default is 'SHA-256'
924
- * @returns {Promise<string>} the hash of the object
925
- */
926
- async hash(object, algorithm = HashAlgorithm.SHA256) {
927
- return hash(object, { algorithm });
928
- }
929
- /**
930
- * Will hash an object synchronously using the specified non-cryptographic algorithm.
931
- * Use this for non-cryptographic algorithms (DJB2, FNV1, MURMER, CRC32).
932
- * For cryptographic algorithms, use hash() instead.
933
- * @param {any} object the object to hash
934
- * @param {string} algorithm the hash algorithm to use. The default is 'djb2'
935
- * @returns {string} the hash of the object
936
- */
937
- hashSync(object, algorithm = HashAlgorithm.DJB2) {
938
- return hashSync(object, { algorithm });
939
- }
940
- async setManyKeyv(keyv, items) {
941
- const entries = [];
942
- for (const item of items) {
943
- const finalTtl = getCascadingTtl(
944
- this._ttl,
945
- keyv.ttl,
946
- shorthandToMilliseconds(item.ttl)
947
- );
948
- entries.push({ key: item.key, value: item.value, ttl: finalTtl });
949
- }
950
- await keyv.setMany(entries);
951
- return true;
952
- }
953
- /**
954
- * Processes a single key from secondary store for getRaw operation
955
- * @param primary - the primary store to use
956
- * @param secondary - the secondary store to use
957
- * @param key - The key to retrieve from secondary store
958
- * @returns Promise containing the result and TTL information
959
- */
960
- async processSecondaryForGetRaw(primary, secondary, key) {
961
- const secondaryResult = await secondary.getRaw(key);
962
- if (secondaryResult?.value) {
963
- this.emit("cache:hit" /* CACHE_HIT */, {
964
- key,
965
- value: secondaryResult.value,
966
- store: "secondary"
967
- });
968
- const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl);
969
- const expires = secondaryResult.expires ?? void 0;
970
- const ttl = calculateTtlFromExpiration(cascadeTtl, expires);
971
- const setItem = { key, value: secondaryResult.value, ttl };
972
- await this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem);
973
- await primary.set(setItem.key, setItem.value, setItem.ttl);
974
- return { result: secondaryResult, ttl };
975
- } else {
976
- this.emit("cache:miss" /* CACHE_MISS */, { key, store: "secondary" });
977
- return void 0;
978
- }
979
- }
980
- /**
981
- * Processes a single key from secondary store for getRaw operation in non-blocking mode
982
- * Non-blocking mode means we don't wait for secondary operations that update primary store
983
- * @param primary - the primary store to use
984
- * @param secondary - the secondary store to use
985
- * @param key - The key to retrieve from secondary store
986
- * @returns Promise containing the result and TTL information
987
- */
988
- async processSecondaryForGetRawNonBlocking(primary, secondary, key) {
989
- const secondaryResult = await secondary.getRaw(key);
990
- if (secondaryResult?.value) {
991
- this.emit("cache:hit" /* CACHE_HIT */, {
992
- key,
993
- value: secondaryResult.value,
994
- store: "secondary"
995
- });
996
- const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl);
997
- const expires = secondaryResult.expires ?? void 0;
998
- const ttl = calculateTtlFromExpiration(cascadeTtl, expires);
999
- const setItem = { key, value: secondaryResult.value, ttl };
1000
- this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem).then(async () => {
1001
- await primary.set(setItem.key, setItem.value, setItem.ttl);
1002
- }).catch((error) => {
1003
- this.emit("error" /* ERROR */, error);
1004
- });
1005
- return { result: secondaryResult, ttl };
1006
- } else {
1007
- this.emit("cache:miss" /* CACHE_MISS */, { key, store: "secondary" });
1008
- return void 0;
1009
- }
1010
- }
1011
- /**
1012
- * Processes missing keys from secondary store for getManyRaw operation
1013
- * @param primary - the primary store to use
1014
- * @param secondary - the secondary store to use
1015
- * @param keys - The original array of keys requested
1016
- * @param result - The result array from primary store (will be modified)
1017
- * @returns Promise<void>
1018
- */
1019
- async processSecondaryForGetManyRaw(primary, secondary, keys, result) {
1020
- const missingKeys = [];
1021
- for (const [i, key] of keys.entries()) {
1022
- if (!result[i]) {
1023
- missingKeys.push(key);
1024
- }
1025
- }
1026
- const secondaryResults = await secondary.getManyRaw(missingKeys);
1027
- let secondaryIndex = 0;
1028
- for await (const [i, key] of keys.entries()) {
1029
- if (!result[i]) {
1030
- const secondaryResult = secondaryResults[secondaryIndex];
1031
- if (secondaryResult && secondaryResult.value !== void 0) {
1032
- result[i] = secondaryResult;
1033
- this.emit("cache:hit" /* CACHE_HIT */, {
1034
- key,
1035
- value: secondaryResult.value,
1036
- store: "secondary"
1037
- });
1038
- const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl);
1039
- let { expires } = secondaryResult;
1040
- if (expires === null) {
1041
- expires = void 0;
1042
- }
1043
- const ttl = calculateTtlFromExpiration(cascadeTtl, expires);
1044
- const setItem = { key, value: secondaryResult.value, ttl };
1045
- await this.hook(
1046
- "BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */,
1047
- setItem
1048
- );
1049
- await primary.set(setItem.key, setItem.value, setItem.ttl);
1050
- } else {
1051
- this.emit("cache:miss" /* CACHE_MISS */, {
1052
- key,
1053
- store: "secondary"
1054
- });
1055
- }
1056
- secondaryIndex++;
1057
- }
1058
- }
1059
- }
1060
- /**
1061
- * Processes missing keys from secondary store for getManyRaw operation in non-blocking mode
1062
- * Non-blocking mode means we don't wait for secondary operations that update primary store
1063
- * @param secondary - the secondary store to use
1064
- * @param keys - The original array of keys requested
1065
- * @param result - The result array from primary store (will be modified)
1066
- * @returns Promise<void>
1067
- */
1068
- async processSecondaryForGetManyRawNonBlocking(primary, secondary, keys, result) {
1069
- const missingKeys = [];
1070
- for (const [i, key] of keys.entries()) {
1071
- if (!result[i]) {
1072
- missingKeys.push(key);
1073
- }
1074
- }
1075
- const secondaryResults = await secondary.getManyRaw(missingKeys);
1076
- let secondaryIndex = 0;
1077
- for await (const [i, key] of keys.entries()) {
1078
- if (!result[i]) {
1079
- const secondaryResult = secondaryResults[secondaryIndex];
1080
- if (secondaryResult && secondaryResult.value !== void 0) {
1081
- result[i] = secondaryResult;
1082
- this.emit("cache:hit" /* CACHE_HIT */, {
1083
- key,
1084
- value: secondaryResult.value,
1085
- store: "secondary"
1086
- });
1087
- const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl);
1088
- let { expires } = secondaryResult;
1089
- if (expires === null) {
1090
- expires = void 0;
1091
- }
1092
- const ttl = calculateTtlFromExpiration(cascadeTtl, expires);
1093
- const setItem = { key, value: secondaryResult.value, ttl };
1094
- this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem).then(async () => {
1095
- await primary.set(setItem.key, setItem.value, setItem.ttl);
1096
- }).catch((error) => {
1097
- this.emit("error" /* ERROR */, error);
1098
- });
1099
- } else {
1100
- this.emit("cache:miss" /* CACHE_MISS */, {
1101
- key,
1102
- store: "secondary"
1103
- });
1104
- }
1105
- secondaryIndex++;
1106
- }
1107
- }
1108
- }
1109
- setTtl(ttl) {
1110
- if (typeof ttl === "string" || ttl === void 0) {
1111
- this._ttl = ttl;
1112
- } else if (ttl > 0) {
1113
- this._ttl = ttl;
1114
- } else {
1115
- this._ttl = void 0;
1116
- }
1117
- }
1118
- };
1119
- export {
1120
- Cacheable,
1121
- CacheableEvents,
1122
- CacheableHooks,
1123
- CacheableMemory,
1124
- Stats as CacheableStats,
1125
- CacheableSync,
1126
- CacheableSyncEvents,
1127
- HashAlgorithm2 as HashAlgorithm,
1128
- Keyv2 as Keyv,
1129
- KeyvCacheableMemory,
1130
- KeyvHooks,
1131
- calculateTtlFromExpiration2 as calculateTtlFromExpiration,
1132
- createKeyv2 as createKeyv,
1133
- getCascadingTtl2 as getCascadingTtl,
1134
- getOrSet2 as getOrSet,
1135
- hash2 as hash,
1136
- shorthandToMilliseconds2 as shorthandToMilliseconds,
1137
- shorthandToTime,
1138
- wrap2 as wrap,
1139
- wrapSync
1140
- };
1141
- /* v8 ignore next -- @preserve */