@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.
- package/dist/{access-control-88UPniDc.js → access-control-DYE5dXna.js} +5 -3
- package/dist/{accounts-DgViSyJx.js → accounts-4YgwroRU.js} +1 -1
- package/dist/{action-runtime-hqza0J8B.js → action-runtime-DPahAqxV.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{active-listener-CFwkn3ho.js → active-listener-B4SDebQ6.js} +1 -1
- package/dist/api.js +14 -13
- package/dist/{approval-handler.runtime-9_SV7vhc.js → approval-handler.runtime-DNWS4aYQ.js} +1 -1
- package/dist/auth-presence.js +1 -1
- package/dist/{auth-store-ECx4h57q.js → auth-store-Db-wfApd.js} +23 -13
- package/dist/call-tool-api.js +233 -0
- package/dist/{channel-fcXxWXic.js → channel-BWp7h1uY.js} +44 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-Dgy9uUMl.js → channel-react-action-CKJHL_Wf.js} +3 -3
- package/dist/{channel.runtime-B4ThooGF.js → channel.runtime-CAssfx9p.js} +5 -5
- package/dist/{channel.setup-C_WEdyJR.js → channel.setup-CURc5rEt.js} +2 -2
- package/dist/{config-schema-CROZuhT-.js → config-schema-mBX2nmn1.js} +4 -0
- package/dist/{connection-controller-u-tfAFhJ.js → connection-controller-DkbrFSIn.js} +6 -5
- package/dist/connection-controller-registry-TSX_udJp.js +22 -0
- package/dist/contract-api.js +1 -1
- package/dist/{quoted-message-CpA_ujXK.js → group-session-key-BhC1RQOE.js} +31 -2
- package/dist/{identity-CmsTmkKR.js → identity-Dqft3mFA.js} +2 -1
- package/dist/index.js +9 -2
- package/dist/light-runtime-api.js +3 -3
- package/dist/{login-8lHwLmXj.js → login-C48y0jlx.js} +14 -7
- package/dist/{login-qr-BEZZqrTb.js → login-qr-BjId7dll.js} +7 -7
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BqkJ4MpT.js → monitor-DD8bXohk.js} +249 -160
- package/dist/runtime-api.js +9 -9
- package/dist/{send-i8Xk5mBQ.js → send-C5CpFcBG.js} +27 -9
- package/dist/{send-api-DndiBJhN.js → send-api-DLlXl8CH.js} +6 -5
- package/dist/{session-WU4SVP8f.js → session-DriaHt7V.js} +3 -3
- package/dist/{session-errors-CbsoQqoy.js → session-errors-BAj9D2La.js} +1 -22
- package/dist/{setup-core-KjSBbWX4.js → setup-core-DH-DFPLY.js} +4 -4
- package/dist/{setup-finalize-WedNP30s.js → setup-finalize-c8dl34sO.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-IOdkbWsQ.js → setup-surface-DlWb0Z09.js} +3 -3
- package/dist/{socket-timing-DvMNkIge.js → socket-timing-DhbVFjah.js} +17 -5
- package/dist/{text-runtime-C88QkuU9.js → targets-runtime-C-GiVn6Y.js} +2 -3
- package/dist/text-runtime-DdX6-mC_.js +4 -0
- package/node_modules/@cacheable/memory/README.md +177 -0
- package/node_modules/@cacheable/memory/dist/index.cjs +867 -820
- package/node_modules/@cacheable/memory/dist/index.d.cts +382 -280
- package/node_modules/@cacheable/memory/dist/index.d.mts +412 -0
- package/node_modules/@cacheable/memory/dist/index.mjs +841 -0
- package/node_modules/@cacheable/memory/package.json +9 -9
- package/node_modules/@cacheable/utils/README.md +342 -8
- package/node_modules/@cacheable/utils/dist/index.cjs +1322 -619
- package/node_modules/@cacheable/utils/dist/index.d.cts +769 -173
- package/node_modules/@cacheable/utils/dist/index.d.mts +903 -0
- package/node_modules/@cacheable/utils/dist/index.mjs +1355 -0
- package/node_modules/@cacheable/utils/package.json +8 -8
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/assert/strict.d.ts +10 -1
- package/node_modules/@types/node/assert.d.ts +144 -17
- package/node_modules/@types/node/async_hooks.d.ts +9 -9
- package/node_modules/@types/node/buffer.d.ts +64 -30
- package/node_modules/@types/node/child_process.d.ts +17 -21
- package/node_modules/@types/node/cluster.d.ts +13 -13
- package/node_modules/@types/node/console.d.ts +1 -1
- package/node_modules/@types/node/crypto.d.ts +471 -575
- package/node_modules/@types/node/diagnostics_channel.d.ts +274 -32
- package/node_modules/@types/node/dns.d.ts +15 -15
- package/node_modules/@types/node/events.d.ts +3 -3
- package/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/@types/node/fs/promises.d.ts +7 -4
- package/node_modules/@types/node/fs.d.ts +24 -18
- package/node_modules/@types/node/globals.d.ts +4 -4
- package/node_modules/@types/node/http.d.ts +30 -5
- package/node_modules/@types/node/http2.d.ts +5 -1
- package/node_modules/@types/node/index.d.ts +1 -3
- package/node_modules/@types/node/inspector.d.ts +1 -1
- package/node_modules/@types/node/module.d.ts +16 -45
- package/node_modules/@types/node/net.d.ts +1 -1
- package/node_modules/@types/node/os.d.ts +2 -2
- package/node_modules/@types/node/package.json +4 -4
- package/node_modules/@types/node/perf_hooks.d.ts +1 -9
- package/node_modules/@types/node/process.d.ts +25 -12
- package/node_modules/@types/node/quic.d.ts +92 -11
- package/node_modules/@types/node/readline.d.ts +12 -11
- package/node_modules/@types/node/repl.d.ts +10 -10
- package/node_modules/@types/node/sqlite.d.ts +56 -1
- package/node_modules/@types/node/stream/iter.d.ts +150 -0
- package/node_modules/@types/node/stream/promises.d.ts +2 -2
- package/node_modules/@types/node/stream/web.d.ts +1 -1
- package/node_modules/@types/node/stream.d.ts +37 -5
- package/node_modules/@types/node/test/reporters.d.ts +1 -1
- package/node_modules/@types/node/test.d.ts +120 -10
- package/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/node/ts5.6/index.d.ts +2 -4
- package/node_modules/@types/node/ts5.7/index.d.ts +1 -3
- package/node_modules/@types/node/url.d.ts +3 -3
- package/node_modules/@types/node/util/types.d.ts +1 -1
- package/node_modules/@types/node/util.d.ts +22 -22
- package/node_modules/@types/node/v8.d.ts +85 -3
- package/node_modules/@types/node/vm.d.ts +9 -9
- package/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
- package/node_modules/@types/node/worker_threads.d.ts +10 -12
- package/node_modules/@types/node/zlib.d.ts +3 -3
- package/node_modules/cacheable/README.md +309 -30
- package/node_modules/cacheable/dist/index.cjs +1307 -1153
- package/node_modules/cacheable/dist/index.d.cts +741 -469
- package/node_modules/cacheable/dist/index.d.mts +766 -0
- package/node_modules/cacheable/dist/index.mjs +1210 -0
- package/node_modules/cacheable/package.json +10 -10
- package/node_modules/content-type/README.md +32 -57
- package/node_modules/content-type/dist/index.d.ts +26 -0
- package/node_modules/content-type/dist/index.js +170 -0
- package/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/content-type/package.json +35 -25
- package/node_modules/media-typer/README.md +19 -33
- package/node_modules/media-typer/dist/index.d.ts +29 -0
- package/node_modules/media-typer/dist/index.js +64 -0
- package/node_modules/media-typer/dist/index.js.map +1 -0
- package/node_modules/media-typer/package.json +37 -22
- package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
- package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
- package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
- package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
- package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
- package/node_modules/music-metadata/package.json +5 -5
- package/node_modules/typebox/build/compile/validator.d.mts +2 -7
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +4 -8
- package/node_modules/typebox/build/guard/guard.mjs +5 -13
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
- package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
- package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
- package/node_modules/typebox/build/type/script/parser.mjs +22 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +4 -8
- package/node_modules/typebox/build/typebox.mjs +4 -8
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +25 -25
- package/node_modules/typebox/readme.md +97 -80
- package/node_modules/undici-types/agent.d.ts +0 -2
- package/node_modules/undici-types/client.d.ts +25 -19
- package/node_modules/undici-types/dispatcher.d.ts +7 -33
- package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici-types/fetch.d.ts +24 -4
- package/node_modules/undici-types/h2c-client.d.ts +6 -6
- package/node_modules/undici-types/handlers.d.ts +1 -2
- package/node_modules/undici-types/header.d.ts +5 -0
- package/node_modules/undici-types/index.d.ts +3 -1
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/pool.d.ts +0 -2
- package/node_modules/undici-types/proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/round-robin-pool.d.ts +0 -2
- package/node_modules/undici-types/snapshot-agent.d.ts +4 -0
- package/node_modules/undici-types/socks5-proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/webidl.d.ts +0 -1
- package/npm-shrinkwrap.json +49 -41
- package/openclaw.plugin.json +12 -0
- package/package.json +5 -5
- package/node_modules/@cacheable/memory/dist/index.d.ts +0 -310
- package/node_modules/@cacheable/memory/dist/index.js +0 -807
- package/node_modules/@cacheable/utils/dist/index.d.ts +0 -307
- package/node_modules/@cacheable/utils/dist/index.js +0 -630
- package/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
- package/node_modules/cacheable/dist/index.d.ts +0 -494
- package/node_modules/cacheable/dist/index.js +0 -1141
- package/node_modules/content-type/HISTORY.md +0 -29
- package/node_modules/content-type/index.js +0 -225
- package/node_modules/media-typer/HISTORY.md +0 -50
- package/node_modules/media-typer/index.js +0 -143
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- package/dist/{approval-resolver-e1hAVRRy.js → approval-resolver-DF-lu8k5.js} +1 -1
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -1,830 +1,877 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
CacheableMemory: () => CacheableMemory,
|
|
24
|
-
HashAlgorithm: () => import_utils2.HashAlgorithm,
|
|
25
|
-
KeyvCacheableMemory: () => KeyvCacheableMemory,
|
|
26
|
-
createKeyv: () => createKeyv,
|
|
27
|
-
defaultStoreHashSize: () => defaultStoreHashSize,
|
|
28
|
-
hash: () => import_utils2.hash,
|
|
29
|
-
hashToNumber: () => import_utils2.hashToNumber,
|
|
30
|
-
maximumMapSize: () => maximumMapSize
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(index_exports);
|
|
33
|
-
var import_utils = require("@cacheable/utils");
|
|
34
|
-
var import_hookified = require("hookified");
|
|
35
|
-
|
|
36
|
-
// src/memory-lru.ts
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _cacheable_utils = require("@cacheable/utils");
|
|
3
|
+
let hookified = require("hookified");
|
|
4
|
+
let keyv = require("keyv");
|
|
5
|
+
//#region src/memory-lru.ts
|
|
37
6
|
var ListNode = class {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
7
|
+
value;
|
|
8
|
+
prev = void 0;
|
|
9
|
+
next = void 0;
|
|
10
|
+
constructor(value) {
|
|
11
|
+
this.value = value;
|
|
12
|
+
}
|
|
44
13
|
};
|
|
45
14
|
var DoublyLinkedList = class {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
|
-
this.head = node.next;
|
|
113
|
-
if (this.head) {
|
|
114
|
-
this.head.prev = void 0;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (node.next) {
|
|
118
|
-
node.next.prev = node.prev;
|
|
119
|
-
} else {
|
|
120
|
-
this.tail = node.prev;
|
|
121
|
-
if (this.tail) {
|
|
122
|
-
this.tail.next = void 0;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
this.nodesMap.delete(value);
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
get size() {
|
|
129
|
-
return this.nodesMap.size;
|
|
130
|
-
}
|
|
15
|
+
head = void 0;
|
|
16
|
+
tail = void 0;
|
|
17
|
+
nodesMap = /* @__PURE__ */ new Map();
|
|
18
|
+
addToFront(value) {
|
|
19
|
+
const newNode = new ListNode(value);
|
|
20
|
+
if (this.head) {
|
|
21
|
+
newNode.next = this.head;
|
|
22
|
+
this.head.prev = newNode;
|
|
23
|
+
this.head = newNode;
|
|
24
|
+
} else this.head = this.tail = newNode;
|
|
25
|
+
this.nodesMap.set(value, newNode);
|
|
26
|
+
}
|
|
27
|
+
moveToFront(value) {
|
|
28
|
+
const node = this.nodesMap.get(value);
|
|
29
|
+
if (!node || this.head === node) return;
|
|
30
|
+
/* v8 ignore next -- @preserve */
|
|
31
|
+
if (node.prev) node.prev.next = node.next;
|
|
32
|
+
/* v8 ignore next -- @preserve */
|
|
33
|
+
if (node.next) node.next.prev = node.prev;
|
|
34
|
+
/* v8 ignore next -- @preserve */
|
|
35
|
+
if (node === this.tail) this.tail = node.prev;
|
|
36
|
+
node.prev = void 0;
|
|
37
|
+
node.next = this.head;
|
|
38
|
+
/* v8 ignore next -- @preserve */
|
|
39
|
+
if (this.head) this.head.prev = node;
|
|
40
|
+
this.head = node;
|
|
41
|
+
this.tail ??= node;
|
|
42
|
+
}
|
|
43
|
+
getOldest() {
|
|
44
|
+
/* v8 ignore next -- @preserve */
|
|
45
|
+
return this.tail ? this.tail.value : void 0;
|
|
46
|
+
}
|
|
47
|
+
removeOldest() {
|
|
48
|
+
/* v8 ignore next -- @preserve */
|
|
49
|
+
if (!this.tail) return;
|
|
50
|
+
const oldValue = this.tail.value;
|
|
51
|
+
/* v8 ignore next -- @preserve */
|
|
52
|
+
if (this.tail.prev) {
|
|
53
|
+
this.tail = this.tail.prev;
|
|
54
|
+
this.tail.next = void 0;
|
|
55
|
+
} else
|
|
56
|
+
/* v8 ignore next -- @preserve */
|
|
57
|
+
this.head = this.tail = void 0;
|
|
58
|
+
this.nodesMap.delete(oldValue);
|
|
59
|
+
return oldValue;
|
|
60
|
+
}
|
|
61
|
+
remove(value) {
|
|
62
|
+
const node = this.nodesMap.get(value);
|
|
63
|
+
if (!node) return false;
|
|
64
|
+
if (node.prev) node.prev.next = node.next;
|
|
65
|
+
else {
|
|
66
|
+
this.head = node.next;
|
|
67
|
+
if (this.head) this.head.prev = void 0;
|
|
68
|
+
}
|
|
69
|
+
if (node.next) node.next.prev = node.prev;
|
|
70
|
+
else {
|
|
71
|
+
this.tail = node.prev;
|
|
72
|
+
if (this.tail) this.tail.next = void 0;
|
|
73
|
+
}
|
|
74
|
+
this.nodesMap.delete(value);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
get size() {
|
|
78
|
+
return this.nodesMap.size;
|
|
79
|
+
}
|
|
131
80
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var import_utils2 = require("@cacheable/utils");
|
|
135
|
-
|
|
136
|
-
// src/keyv-memory.ts
|
|
137
|
-
var import_keyv = require("keyv");
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/keyv-memory.ts
|
|
138
83
|
var KeyvCacheableMemory = class {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
getStore(namespace) {
|
|
205
|
-
if (!namespace) {
|
|
206
|
-
return this._defaultCache;
|
|
207
|
-
}
|
|
208
|
-
if (!this._nCache.has(namespace)) {
|
|
209
|
-
this._nCache.set(namespace, new CacheableMemory(this.opts));
|
|
210
|
-
}
|
|
211
|
-
return this._nCache.get(namespace);
|
|
212
|
-
}
|
|
84
|
+
opts = {
|
|
85
|
+
ttl: 0,
|
|
86
|
+
useClone: true,
|
|
87
|
+
lruSize: 0,
|
|
88
|
+
checkInterval: 0
|
|
89
|
+
};
|
|
90
|
+
_defaultCache = new CacheableMemory();
|
|
91
|
+
_nCache = /* @__PURE__ */ new Map();
|
|
92
|
+
_namespace;
|
|
93
|
+
constructor(options) {
|
|
94
|
+
if (options) {
|
|
95
|
+
this.opts = options;
|
|
96
|
+
this._defaultCache = new CacheableMemory(options);
|
|
97
|
+
if (options.namespace) {
|
|
98
|
+
this._namespace = options.namespace;
|
|
99
|
+
this._nCache.set(this._namespace, new CacheableMemory(options));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
get namespace() {
|
|
104
|
+
return this._namespace;
|
|
105
|
+
}
|
|
106
|
+
set namespace(value) {
|
|
107
|
+
this._namespace = value;
|
|
108
|
+
}
|
|
109
|
+
get store() {
|
|
110
|
+
return this.getStore(this._namespace);
|
|
111
|
+
}
|
|
112
|
+
async get(key) {
|
|
113
|
+
const result = this.getStore(this._namespace).get(key);
|
|
114
|
+
if (result) return result;
|
|
115
|
+
}
|
|
116
|
+
async getMany(keys) {
|
|
117
|
+
return this.getStore(this._namespace).getMany(keys);
|
|
118
|
+
}
|
|
119
|
+
async set(key, value, ttl) {
|
|
120
|
+
this.getStore(this._namespace).set(key, value, ttl);
|
|
121
|
+
}
|
|
122
|
+
async setMany(values) {
|
|
123
|
+
this.getStore(this._namespace).setMany(values);
|
|
124
|
+
}
|
|
125
|
+
async delete(key) {
|
|
126
|
+
this.getStore(this._namespace).delete(key);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
async deleteMany(key) {
|
|
130
|
+
this.getStore(this._namespace).deleteMany(key);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
async clear() {
|
|
134
|
+
this.getStore(this._namespace).clear();
|
|
135
|
+
}
|
|
136
|
+
async has(key) {
|
|
137
|
+
return this.getStore(this._namespace).has(key);
|
|
138
|
+
}
|
|
139
|
+
on(event, listener) {
|
|
140
|
+
this.getStore(this._namespace).on(event, listener);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
getStore(namespace) {
|
|
144
|
+
if (!namespace) return this._defaultCache;
|
|
145
|
+
if (!this._nCache.has(namespace)) this._nCache.set(namespace, new CacheableMemory(this.opts));
|
|
146
|
+
return this._nCache.get(namespace);
|
|
147
|
+
}
|
|
213
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Creates a new Keyv instance with a new KeyvCacheableMemory store. This also removes the serialize/deserialize methods from the Keyv instance for optimization.
|
|
151
|
+
* @param options
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
214
154
|
function createKeyv(options) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
155
|
+
const store = new KeyvCacheableMemory(options);
|
|
156
|
+
const namespace = options?.namespace;
|
|
157
|
+
let ttl;
|
|
158
|
+
/* v8 ignore next -- @preserve */
|
|
159
|
+
if (options?.ttl && Number.isInteger(options.ttl)) ttl = options?.ttl;
|
|
160
|
+
const keyv$1 = new keyv.Keyv({
|
|
161
|
+
store,
|
|
162
|
+
namespace,
|
|
163
|
+
ttl
|
|
164
|
+
});
|
|
165
|
+
keyv$1.serialize = void 0;
|
|
166
|
+
keyv$1.deserialize = void 0;
|
|
167
|
+
return keyv$1;
|
|
225
168
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/index.ts
|
|
171
|
+
/**
|
|
172
|
+
* Lifecycle hooks fired by {@link CacheableMemory}. Register handlers with the inherited
|
|
173
|
+
* `onHook(hook, handler)` method. Hooks are dispatched synchronously via `hookSync`, which skips
|
|
174
|
+
* `async` handler functions entirely — register only synchronous handlers.
|
|
175
|
+
*/
|
|
176
|
+
let CacheableMemoryHooks = /* @__PURE__ */ function(CacheableMemoryHooks) {
|
|
177
|
+
CacheableMemoryHooks["BEFORE_SET"] = "BEFORE_SET";
|
|
178
|
+
CacheableMemoryHooks["AFTER_SET"] = "AFTER_SET";
|
|
179
|
+
CacheableMemoryHooks["BEFORE_SET_MANY"] = "BEFORE_SET_MANY";
|
|
180
|
+
CacheableMemoryHooks["AFTER_SET_MANY"] = "AFTER_SET_MANY";
|
|
181
|
+
CacheableMemoryHooks["BEFORE_GET"] = "BEFORE_GET";
|
|
182
|
+
CacheableMemoryHooks["AFTER_GET"] = "AFTER_GET";
|
|
183
|
+
CacheableMemoryHooks["BEFORE_GET_MANY"] = "BEFORE_GET_MANY";
|
|
184
|
+
CacheableMemoryHooks["AFTER_GET_MANY"] = "AFTER_GET_MANY";
|
|
185
|
+
CacheableMemoryHooks["BEFORE_DELETE"] = "BEFORE_DELETE";
|
|
186
|
+
CacheableMemoryHooks["AFTER_DELETE"] = "AFTER_DELETE";
|
|
187
|
+
CacheableMemoryHooks["BEFORE_DELETE_MANY"] = "BEFORE_DELETE_MANY";
|
|
188
|
+
CacheableMemoryHooks["AFTER_DELETE_MANY"] = "AFTER_DELETE_MANY";
|
|
189
|
+
CacheableMemoryHooks["BEFORE_CLEAR"] = "BEFORE_CLEAR";
|
|
190
|
+
CacheableMemoryHooks["AFTER_CLEAR"] = "AFTER_CLEAR";
|
|
191
|
+
return CacheableMemoryHooks;
|
|
192
|
+
}({});
|
|
193
|
+
const defaultStoreHashSize = 16;
|
|
194
|
+
const maximumMapSize = 16777216;
|
|
195
|
+
var CacheableMemory = class extends hookified.Hookified {
|
|
196
|
+
_lru = new DoublyLinkedList();
|
|
197
|
+
_storeHashSize = 16;
|
|
198
|
+
_storeHashAlgorithm = _cacheable_utils.HashAlgorithm.DJB2;
|
|
199
|
+
_store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
|
|
200
|
+
_ttl;
|
|
201
|
+
_maxTtl;
|
|
202
|
+
_useClone = true;
|
|
203
|
+
_lruSize = 0;
|
|
204
|
+
_checkInterval = 0;
|
|
205
|
+
_interval = 0;
|
|
206
|
+
_stats = new _cacheable_utils.Stats({ enabled: false });
|
|
207
|
+
/**
|
|
208
|
+
* @constructor
|
|
209
|
+
* @param {CacheableMemoryOptions} [options] - The options for the CacheableMemory
|
|
210
|
+
*/
|
|
211
|
+
constructor(options) {
|
|
212
|
+
super();
|
|
213
|
+
if (options?.ttl) this.setTtl(options.ttl);
|
|
214
|
+
if (options?.maxTtl !== void 0) this.setMaxTtl(options.maxTtl);
|
|
215
|
+
if (options?.useClone !== void 0) this._useClone = options.useClone;
|
|
216
|
+
if (options?.stats) this._stats.enabled = options.stats;
|
|
217
|
+
if (options?.storeHashSize && options.storeHashSize > 0) this._storeHashSize = options.storeHashSize;
|
|
218
|
+
if (options?.lruSize) if (options.lruSize > 16777216) this.emit("error", /* @__PURE__ */ new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`));
|
|
219
|
+
else this._lruSize = options.lruSize;
|
|
220
|
+
if (options?.checkInterval) this._checkInterval = options.checkInterval;
|
|
221
|
+
if (options?.storeHashAlgorithm) this._storeHashAlgorithm = options.storeHashAlgorithm;
|
|
222
|
+
this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
|
|
223
|
+
this.startIntervalCheck();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Gets the time-to-live
|
|
227
|
+
* @returns {number|string|undefined} - The time-to-live in miliseconds or a human-readable format. If undefined, it will not have a time-to-live.
|
|
228
|
+
*/
|
|
229
|
+
get ttl() {
|
|
230
|
+
return this._ttl;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Sets the time-to-live
|
|
234
|
+
* @param {number|string|undefined} value - The time-to-live in miliseconds or a human-readable format (example '1s' = 1 second, '1h' = 1 hour). If undefined, it will not have a time-to-live.
|
|
235
|
+
*/
|
|
236
|
+
set ttl(value) {
|
|
237
|
+
this.setTtl(value);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Gets the maximum time-to-live. When set, any TTL that exceeds this value is capped to maxTtl.
|
|
241
|
+
* Entries with no TTL will also be capped to maxTtl. Default is `undefined` (no maximum).
|
|
242
|
+
* @returns {number|string|undefined} - The maximum TTL in milliseconds, human-readable format, or undefined.
|
|
243
|
+
*/
|
|
244
|
+
get maxTtl() {
|
|
245
|
+
return this._maxTtl;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Sets the maximum time-to-live. When set, any TTL that exceeds this value is capped to maxTtl.
|
|
249
|
+
* Entries with no TTL will also be capped to maxTtl.
|
|
250
|
+
* @param {number|string|undefined} value - The maximum TTL in milliseconds or human-readable format (e.g. '1s', '1h'). If undefined, no maximum is enforced.
|
|
251
|
+
*/
|
|
252
|
+
set maxTtl(value) {
|
|
253
|
+
this.setMaxTtl(value);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Gets whether to use clone
|
|
257
|
+
* @returns {boolean} - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
|
|
258
|
+
*/
|
|
259
|
+
get useClone() {
|
|
260
|
+
return this._useClone;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Sets whether to use clone
|
|
264
|
+
* @param {boolean} value - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
|
|
265
|
+
*/
|
|
266
|
+
set useClone(value) {
|
|
267
|
+
this._useClone = value;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Gets the size of the LRU cache
|
|
271
|
+
* @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm.
|
|
272
|
+
*/
|
|
273
|
+
get lruSize() {
|
|
274
|
+
return this._lruSize;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Sets the size of the LRU cache
|
|
278
|
+
* @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm.
|
|
279
|
+
*/
|
|
280
|
+
set lruSize(value) {
|
|
281
|
+
if (value > 16777216) {
|
|
282
|
+
this.emit("error", /* @__PURE__ */ new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`));
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this._lruSize = value;
|
|
286
|
+
if (this._lruSize === 0) {
|
|
287
|
+
this._lru = new DoublyLinkedList();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.lruResize();
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Gets the check interval
|
|
294
|
+
* @returns {number} - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
|
|
295
|
+
*/
|
|
296
|
+
get checkInterval() {
|
|
297
|
+
return this._checkInterval;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Sets the check interval
|
|
301
|
+
* @param {number} value - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
|
|
302
|
+
*/
|
|
303
|
+
set checkInterval(value) {
|
|
304
|
+
this._checkInterval = value;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Gets the size of the cache
|
|
308
|
+
* @returns {number} - The size of the cache
|
|
309
|
+
*/
|
|
310
|
+
get size() {
|
|
311
|
+
let size = 0;
|
|
312
|
+
for (const store of this._store) size += store.size;
|
|
313
|
+
return size;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Gets the statistics of the cache. Statistics track aggregate counters such as `hits`, `misses`,
|
|
317
|
+
* `gets`, `sets`, `deletes`, `clears`, `count`, `ksize`, and `vsize`. They are disabled by default;
|
|
318
|
+
* enable them via the `stats` option or by setting `cache.stats.enabled = true`.
|
|
319
|
+
* @returns {Stats} - The statistics for this CacheableMemory instance
|
|
320
|
+
*/
|
|
321
|
+
get stats() {
|
|
322
|
+
return this._stats;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Gets the number of hash stores
|
|
326
|
+
* @returns {number} - The number of hash stores
|
|
327
|
+
*/
|
|
328
|
+
get storeHashSize() {
|
|
329
|
+
return this._storeHashSize;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Sets the number of hash stores. This will recreate the store and all data will be cleared
|
|
333
|
+
* @param {number} value - The number of hash stores
|
|
334
|
+
*/
|
|
335
|
+
set storeHashSize(value) {
|
|
336
|
+
if (value === this._storeHashSize) return;
|
|
337
|
+
this._storeHashSize = value;
|
|
338
|
+
this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
|
|
339
|
+
if (this._stats.enabled) this._stats.resetStoreValues();
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Gets the store hash algorithm
|
|
343
|
+
* @returns {HashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm
|
|
344
|
+
*/
|
|
345
|
+
get storeHashAlgorithm() {
|
|
346
|
+
return this._storeHashAlgorithm;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Sets the store hash algorithm. This will recreate the store and all data will be cleared
|
|
350
|
+
* @param {HashAlgorithm | HashAlgorithmFunction} value - The store hash algorithm
|
|
351
|
+
*/
|
|
352
|
+
set storeHashAlgorithm(value) {
|
|
353
|
+
this._storeHashAlgorithm = value;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Gets the keys
|
|
357
|
+
* @returns {IterableIterator<string>} - The keys
|
|
358
|
+
*/
|
|
359
|
+
get keys() {
|
|
360
|
+
const keys = [];
|
|
361
|
+
for (const store of this._store) for (const key of store.keys()) {
|
|
362
|
+
const item = store.get(key);
|
|
363
|
+
if (item && this.hasExpired(item)) {
|
|
364
|
+
this.recordExpiration(item);
|
|
365
|
+
store.delete(key);
|
|
366
|
+
this.lruRemove(key);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
keys.push(key);
|
|
370
|
+
}
|
|
371
|
+
return keys.values();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Gets the items
|
|
375
|
+
* @returns {IterableIterator<CacheableStoreItem>} - The items
|
|
376
|
+
*/
|
|
377
|
+
get items() {
|
|
378
|
+
const items = [];
|
|
379
|
+
for (const store of this._store) for (const item of store.values()) {
|
|
380
|
+
if (this.hasExpired(item)) {
|
|
381
|
+
this.recordExpiration(item);
|
|
382
|
+
store.delete(item.key);
|
|
383
|
+
this.lruRemove(item.key);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
items.push(item);
|
|
387
|
+
}
|
|
388
|
+
return items.values();
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Gets the store
|
|
392
|
+
* @returns {Array<Map<string, CacheableStoreItem>>} - The store
|
|
393
|
+
*/
|
|
394
|
+
get store() {
|
|
395
|
+
return this._store;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Gets the value of the key
|
|
399
|
+
* @param {string} key - The key to get the value
|
|
400
|
+
* @returns {T | undefined} - The value of the key
|
|
401
|
+
*/
|
|
402
|
+
get(key) {
|
|
403
|
+
this.hookSync("BEFORE_GET", key);
|
|
404
|
+
const store = this.getStore(key);
|
|
405
|
+
const item = store.get(key);
|
|
406
|
+
if (!item) {
|
|
407
|
+
this.recordRead(false);
|
|
408
|
+
this.hookSync("AFTER_GET", {
|
|
409
|
+
key,
|
|
410
|
+
result: void 0
|
|
411
|
+
});
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (item.expires && Date.now() > item.expires) {
|
|
415
|
+
this.recordExpiration(item);
|
|
416
|
+
store.delete(key);
|
|
417
|
+
this.lruRemove(key);
|
|
418
|
+
this.recordRead(false);
|
|
419
|
+
this.hookSync("AFTER_GET", {
|
|
420
|
+
key,
|
|
421
|
+
result: void 0
|
|
422
|
+
});
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this.lruMoveToFront(key);
|
|
426
|
+
let result;
|
|
427
|
+
if (!this._useClone) result = item.value;
|
|
428
|
+
else result = this.clone(item.value);
|
|
429
|
+
this.recordRead(true);
|
|
430
|
+
this.hookSync("AFTER_GET", {
|
|
431
|
+
key,
|
|
432
|
+
result
|
|
433
|
+
});
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Gets the values of the keys
|
|
438
|
+
* @param {string[]} keys - The keys to get the values
|
|
439
|
+
* @returns {T[]} - The values of the keys
|
|
440
|
+
*/
|
|
441
|
+
getMany(keys) {
|
|
442
|
+
this.hookSync("BEFORE_GET_MANY", keys);
|
|
443
|
+
const result = [];
|
|
444
|
+
for (const key of keys) result.push(this.get(key));
|
|
445
|
+
this.hookSync("AFTER_GET_MANY", {
|
|
446
|
+
keys,
|
|
447
|
+
result
|
|
448
|
+
});
|
|
449
|
+
return result;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Gets the raw value of the key
|
|
453
|
+
* @param {string} key - The key to get the value
|
|
454
|
+
* @returns {CacheableStoreItem | undefined} - The raw value of the key
|
|
455
|
+
*/
|
|
456
|
+
getRaw(key) {
|
|
457
|
+
const store = this.getStore(key);
|
|
458
|
+
const item = store.get(key);
|
|
459
|
+
if (!item) {
|
|
460
|
+
this.recordRead(false);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (item.expires && Date.now() > item.expires) {
|
|
464
|
+
this.recordExpiration(item);
|
|
465
|
+
store.delete(key);
|
|
466
|
+
this.lruRemove(key);
|
|
467
|
+
this.recordRead(false);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
this.lruMoveToFront(key);
|
|
471
|
+
this.recordRead(true);
|
|
472
|
+
return item;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Gets the raw values of the keys
|
|
476
|
+
* @param {string[]} keys - The keys to get the values
|
|
477
|
+
* @returns {CacheableStoreItem[]} - The raw values of the keys
|
|
478
|
+
*/
|
|
479
|
+
getManyRaw(keys) {
|
|
480
|
+
const result = [];
|
|
481
|
+
for (const key of keys) result.push(this.getRaw(key));
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Sets the value of the key
|
|
486
|
+
* @param {string} key - The key to set the value
|
|
487
|
+
* @param {any} value - The value to set
|
|
488
|
+
* @param {number|string|SetOptions} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable.
|
|
489
|
+
* If you want to set expire directly you can do that by setting the expire property in the SetOptions.
|
|
490
|
+
* If you set undefined, it will use the default time-to-live. If both are undefined then it will not have a time-to-live.
|
|
491
|
+
* @returns {void}
|
|
492
|
+
*/
|
|
493
|
+
set(key, value, ttl) {
|
|
494
|
+
const hookItem = {
|
|
495
|
+
key,
|
|
496
|
+
value,
|
|
497
|
+
ttl
|
|
498
|
+
};
|
|
499
|
+
this.hookSync("BEFORE_SET", hookItem);
|
|
500
|
+
const store = this.getStore(hookItem.key);
|
|
501
|
+
let expires;
|
|
502
|
+
const effectiveTtl = hookItem.ttl;
|
|
503
|
+
if (effectiveTtl !== void 0 || this._ttl !== void 0) if (typeof effectiveTtl === "object") {
|
|
504
|
+
if (effectiveTtl.expire) expires = typeof effectiveTtl.expire === "number" ? effectiveTtl.expire : effectiveTtl.expire.getTime();
|
|
505
|
+
if (effectiveTtl.ttl) {
|
|
506
|
+
const finalTtl = (0, _cacheable_utils.shorthandToTime)(effectiveTtl.ttl);
|
|
507
|
+
/* v8 ignore next -- @preserve */
|
|
508
|
+
if (finalTtl !== void 0) expires = finalTtl;
|
|
509
|
+
}
|
|
510
|
+
} else {
|
|
511
|
+
const finalTtl = (0, _cacheable_utils.shorthandToTime)(effectiveTtl ?? this._ttl);
|
|
512
|
+
/* v8 ignore next -- @preserve */
|
|
513
|
+
if (finalTtl !== void 0) expires = finalTtl;
|
|
514
|
+
}
|
|
515
|
+
if (this._maxTtl !== void 0) {
|
|
516
|
+
const maxExpires = (0, _cacheable_utils.shorthandToTime)(this._maxTtl);
|
|
517
|
+
if (expires === void 0) expires = maxExpires;
|
|
518
|
+
else if (expires > maxExpires) expires = maxExpires;
|
|
519
|
+
}
|
|
520
|
+
if (this._lruSize > 0) if (store.has(hookItem.key)) this.lruMoveToFront(hookItem.key);
|
|
521
|
+
else {
|
|
522
|
+
this.lruAddToFront(hookItem.key);
|
|
523
|
+
if (this._lru.size > this._lruSize) {
|
|
524
|
+
const oldestKey = this._lru.getOldest();
|
|
525
|
+
/* v8 ignore next -- @preserve */
|
|
526
|
+
if (oldestKey) {
|
|
527
|
+
this._lru.removeOldest();
|
|
528
|
+
this.delete(oldestKey);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (this._stats.enabled) {
|
|
533
|
+
const existing = store.get(hookItem.key);
|
|
534
|
+
if (existing) this._stats.decreaseVSize(existing.value);
|
|
535
|
+
else {
|
|
536
|
+
this._stats.incrementKSize(hookItem.key);
|
|
537
|
+
this._stats.incrementCount();
|
|
538
|
+
}
|
|
539
|
+
this._stats.incrementVSize(hookItem.value);
|
|
540
|
+
this._stats.incrementSets();
|
|
541
|
+
}
|
|
542
|
+
const item = {
|
|
543
|
+
key: hookItem.key,
|
|
544
|
+
value: hookItem.value,
|
|
545
|
+
expires
|
|
546
|
+
};
|
|
547
|
+
store.set(hookItem.key, item);
|
|
548
|
+
this.hookSync("AFTER_SET", hookItem);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Sets the values of the keys
|
|
552
|
+
* @param {CacheableItem[]} items - The items to set
|
|
553
|
+
* @returns {void}
|
|
554
|
+
*/
|
|
555
|
+
setMany(items) {
|
|
556
|
+
this.hookSync("BEFORE_SET_MANY", items);
|
|
557
|
+
for (const item of items) this.set(item.key, item.value, item.ttl);
|
|
558
|
+
this.hookSync("AFTER_SET_MANY", items);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Checks if the key exists
|
|
562
|
+
* @param {string} key - The key to check
|
|
563
|
+
* @returns {boolean} - If true, the key exists. If false, the key does not exist.
|
|
564
|
+
*/
|
|
565
|
+
has(key) {
|
|
566
|
+
const item = this.get(key);
|
|
567
|
+
return Boolean(item);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* @function hasMany
|
|
571
|
+
* @param {string[]} keys - The keys to check
|
|
572
|
+
* @returns {boolean[]} - If true, the key exists. If false, the key does not exist.
|
|
573
|
+
*/
|
|
574
|
+
hasMany(keys) {
|
|
575
|
+
const result = [];
|
|
576
|
+
for (const key of keys) {
|
|
577
|
+
const item = this.get(key);
|
|
578
|
+
result.push(Boolean(item));
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Take will get the key and delete the entry from cache
|
|
584
|
+
* @param {string} key - The key to take
|
|
585
|
+
* @returns {T | undefined} - The value of the key
|
|
586
|
+
*/
|
|
587
|
+
take(key) {
|
|
588
|
+
const item = this.get(key);
|
|
589
|
+
if (!item) return;
|
|
590
|
+
this.delete(key);
|
|
591
|
+
return item;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* TakeMany will get the keys and delete the entries from cache
|
|
595
|
+
* @param {string[]} keys - The keys to take
|
|
596
|
+
* @returns {T[]} - The values of the keys
|
|
597
|
+
*/
|
|
598
|
+
takeMany(keys) {
|
|
599
|
+
const result = [];
|
|
600
|
+
for (const key of keys) result.push(this.take(key));
|
|
601
|
+
return result;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Delete the key
|
|
605
|
+
* @param {string} key - The key to delete
|
|
606
|
+
* @returns {void}
|
|
607
|
+
*/
|
|
608
|
+
delete(key) {
|
|
609
|
+
this.hookSync("BEFORE_DELETE", key);
|
|
610
|
+
const store = this.getStore(key);
|
|
611
|
+
if (this._stats.enabled) {
|
|
612
|
+
const item = store.get(key);
|
|
613
|
+
if (item) {
|
|
614
|
+
this._stats.decreaseKSize(key);
|
|
615
|
+
this._stats.decreaseVSize(item.value);
|
|
616
|
+
this._stats.decreaseCount();
|
|
617
|
+
this._stats.incrementDeletes();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
store.delete(key);
|
|
621
|
+
this.lruRemove(key);
|
|
622
|
+
this.hookSync("AFTER_DELETE", key);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Delete the keys
|
|
626
|
+
* @param {string[]} keys - The keys to delete
|
|
627
|
+
* @returns {void}
|
|
628
|
+
*/
|
|
629
|
+
deleteMany(keys) {
|
|
630
|
+
this.hookSync("BEFORE_DELETE_MANY", keys);
|
|
631
|
+
for (const key of keys) this.delete(key);
|
|
632
|
+
this.hookSync("AFTER_DELETE_MANY", keys);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Clear the cache
|
|
636
|
+
* @returns {void}
|
|
637
|
+
*/
|
|
638
|
+
clear() {
|
|
639
|
+
this.hookSync("BEFORE_CLEAR");
|
|
640
|
+
this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
|
|
641
|
+
this._lru = new DoublyLinkedList();
|
|
642
|
+
if (this._stats.enabled) {
|
|
643
|
+
this._stats.resetStoreValues();
|
|
644
|
+
this._stats.incrementClears();
|
|
645
|
+
}
|
|
646
|
+
this.hookSync("AFTER_CLEAR");
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Get the store based on the key (internal use)
|
|
650
|
+
* @param {string} key - The key to get the store
|
|
651
|
+
* @returns {CacheableHashStore} - The store
|
|
652
|
+
*/
|
|
653
|
+
getStore(key) {
|
|
654
|
+
const hash = this.getKeyStoreHash(key);
|
|
655
|
+
this._store[hash] ||= /* @__PURE__ */ new Map();
|
|
656
|
+
return this._store[hash];
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Hash the key for which store to go to (internal use)
|
|
660
|
+
* @param {string} key - The key to hash
|
|
661
|
+
* Available algorithms are: SHA256, SHA1, MD5, and djb2Hash.
|
|
662
|
+
* @returns {number} - The hashed key as a number
|
|
663
|
+
*/
|
|
664
|
+
getKeyStoreHash(key) {
|
|
665
|
+
if (this._store.length === 1) return 0;
|
|
666
|
+
if (typeof this._storeHashAlgorithm === "function") return this._storeHashAlgorithm(key, this._storeHashSize);
|
|
667
|
+
return (0, _cacheable_utils.hashToNumberSync)(key, {
|
|
668
|
+
min: 0,
|
|
669
|
+
max: this._storeHashSize - 1,
|
|
670
|
+
algorithm: this._storeHashAlgorithm
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Clone the value. This is for internal use
|
|
675
|
+
* @param {any} value - The value to clone
|
|
676
|
+
* @returns {any} - The cloned value
|
|
677
|
+
*/
|
|
678
|
+
clone(value) {
|
|
679
|
+
if (this.isPrimitive(value)) return value;
|
|
680
|
+
return structuredClone(value);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Add to the front of the LRU cache. This is for internal use
|
|
684
|
+
* @param {string} key - The key to add to the front
|
|
685
|
+
* @returns {void}
|
|
686
|
+
*/
|
|
687
|
+
lruAddToFront(key) {
|
|
688
|
+
if (this._lruSize === 0) return;
|
|
689
|
+
this._lru.addToFront(key);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Move to the front of the LRU cache. This is for internal use
|
|
693
|
+
* @param {string} key - The key to move to the front
|
|
694
|
+
* @returns {void}
|
|
695
|
+
*/
|
|
696
|
+
lruMoveToFront(key) {
|
|
697
|
+
if (this._lruSize === 0) return;
|
|
698
|
+
this._lru.moveToFront(key);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Remove a key from the LRU cache. This is for internal use
|
|
702
|
+
* @param {string} key - The key to remove
|
|
703
|
+
* @returns {void}
|
|
704
|
+
*/
|
|
705
|
+
lruRemove(key) {
|
|
706
|
+
if (this._lruSize === 0) return;
|
|
707
|
+
this._lru.remove(key);
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Resize the LRU cache. This is for internal use.
|
|
711
|
+
* @returns {void}
|
|
712
|
+
*/
|
|
713
|
+
lruResize() {
|
|
714
|
+
while (this._lru.size > this._lruSize) {
|
|
715
|
+
const oldestKey = this._lru.getOldest();
|
|
716
|
+
/* v8 ignore next -- @preserve */
|
|
717
|
+
if (oldestKey) {
|
|
718
|
+
this._lru.removeOldest();
|
|
719
|
+
this.delete(oldestKey);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Check for expiration. This is for internal use
|
|
725
|
+
* @returns {void}
|
|
726
|
+
*/
|
|
727
|
+
checkExpiration() {
|
|
728
|
+
for (const store of this._store) for (const item of store.values()) if (item.expires && Date.now() > item.expires) {
|
|
729
|
+
this.recordExpiration(item);
|
|
730
|
+
store.delete(item.key);
|
|
731
|
+
this.lruRemove(item.key);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Start the interval check. This is for internal use
|
|
736
|
+
* @returns {void}
|
|
737
|
+
*/
|
|
738
|
+
startIntervalCheck() {
|
|
739
|
+
if (this._checkInterval > 0) {
|
|
740
|
+
/* v8 ignore next -- @preserve */
|
|
741
|
+
if (this._interval)
|
|
742
|
+
/* v8 ignore next -- @preserve */
|
|
743
|
+
clearInterval(this._interval);
|
|
744
|
+
this._interval = setInterval(() => {
|
|
745
|
+
this.checkExpiration();
|
|
746
|
+
}, this._checkInterval).unref();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Stop the interval check. This is for internal use
|
|
751
|
+
* @returns {void}
|
|
752
|
+
*/
|
|
753
|
+
stopIntervalCheck() {
|
|
754
|
+
/* v8 ignore next -- @preserve */
|
|
755
|
+
if (this._interval) clearInterval(this._interval);
|
|
756
|
+
this._interval = 0;
|
|
757
|
+
this._checkInterval = 0;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Wrap the function for caching
|
|
761
|
+
* @param {Function} function_ - The function to wrap
|
|
762
|
+
* @param {Object} [options] - The options to wrap
|
|
763
|
+
* @returns {Function} - The wrapped function
|
|
764
|
+
*/
|
|
765
|
+
wrap(function_, options) {
|
|
766
|
+
return (0, _cacheable_utils.wrapSync)(function_, {
|
|
767
|
+
ttl: options?.ttl ?? this._ttl,
|
|
768
|
+
keyPrefix: options?.keyPrefix,
|
|
769
|
+
createKey: options?.createKey,
|
|
770
|
+
cache: this
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Gets the value of the key, or computes and stores it on a cache miss. This is the synchronous
|
|
775
|
+
* cache-aside helper: if the key is present its value is returned, otherwise `function_` is
|
|
776
|
+
* invoked, its result is stored, and that result is returned.
|
|
777
|
+
*
|
|
778
|
+
* The value is stored using `options.ttl`, falling back to the instance default `ttl`. Because
|
|
779
|
+
* the cache is synchronous there is no request coalescing — concurrent callers cannot stampede
|
|
780
|
+
* the setter the way they can with an async cache.
|
|
781
|
+
* @param {GetOrSetSyncKey} key - The key to get or set. Can also be a function that returns the key.
|
|
782
|
+
* @param {() => T} function_ - The function that computes the value on a cache miss.
|
|
783
|
+
* @param {GetOrSetFunctionOptions} [options] - Options such as `ttl`, `cacheErrors`, and `throwErrors`.
|
|
784
|
+
* @returns {T | undefined} - The cached or freshly computed value
|
|
785
|
+
*/
|
|
786
|
+
getOrSet(key, function_, options) {
|
|
787
|
+
return (0, _cacheable_utils.getOrSetSync)(key, function_, {
|
|
788
|
+
cache: this,
|
|
789
|
+
ttl: options?.ttl ?? this._ttl,
|
|
790
|
+
cacheErrors: options?.cacheErrors,
|
|
791
|
+
throwErrors: options?.throwErrors
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Records a single read against the statistics counters. Each read increments `gets` and either
|
|
796
|
+
* `hits` or `misses`. No-op when statistics are disabled. This is for internal use.
|
|
797
|
+
* @param {boolean} hit - Whether the read found a (non-expired) value
|
|
798
|
+
* @returns {void}
|
|
799
|
+
*/
|
|
800
|
+
recordRead(hit) {
|
|
801
|
+
if (!this._stats.enabled) return;
|
|
802
|
+
if (hit) this._stats.incrementHits();
|
|
803
|
+
else this._stats.incrementMisses();
|
|
804
|
+
this._stats.incrementGets();
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Decrements the size statistics (`count`, `ksize`, and `vsize`) for an entry that is being removed
|
|
808
|
+
* because it expired. Expirations are not counted as `deletes` since they are not user-initiated.
|
|
809
|
+
* No-op when statistics are disabled. This is for internal use.
|
|
810
|
+
* @param {CacheableStoreItem} item - The expired item being removed from the store
|
|
811
|
+
* @returns {void}
|
|
812
|
+
*/
|
|
813
|
+
recordExpiration(item) {
|
|
814
|
+
if (!this._stats.enabled) return;
|
|
815
|
+
this._stats.decreaseKSize(item.key);
|
|
816
|
+
this._stats.decreaseVSize(item.value);
|
|
817
|
+
this._stats.decreaseCount();
|
|
818
|
+
}
|
|
819
|
+
isPrimitive(value) {
|
|
820
|
+
const result = false;
|
|
821
|
+
/* v8 ignore next -- @preserve */
|
|
822
|
+
if (value === null || value === void 0) return true;
|
|
823
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return true;
|
|
824
|
+
return result;
|
|
825
|
+
}
|
|
826
|
+
setTtl(ttl) {
|
|
827
|
+
if (typeof ttl === "string" || ttl === void 0) this._ttl = ttl;
|
|
828
|
+
else if (ttl > 0) this._ttl = ttl;
|
|
829
|
+
else this._ttl = void 0;
|
|
830
|
+
}
|
|
831
|
+
setMaxTtl(maxTtl) {
|
|
832
|
+
if (typeof maxTtl === "string" || maxTtl === void 0) this._maxTtl = maxTtl;
|
|
833
|
+
else if (maxTtl > 0) this._maxTtl = maxTtl;
|
|
834
|
+
else this._maxTtl = void 0;
|
|
835
|
+
}
|
|
836
|
+
hasExpired(item) {
|
|
837
|
+
if (item.expires && Date.now() > item.expires) return true;
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
818
840
|
};
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
841
|
+
//#endregion
|
|
842
|
+
exports.CacheableMemory = CacheableMemory;
|
|
843
|
+
exports.CacheableMemoryHooks = CacheableMemoryHooks;
|
|
844
|
+
Object.defineProperty(exports, "HashAlgorithm", {
|
|
845
|
+
enumerable: true,
|
|
846
|
+
get: function() {
|
|
847
|
+
return _cacheable_utils.HashAlgorithm;
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
exports.KeyvCacheableMemory = KeyvCacheableMemory;
|
|
851
|
+
Object.defineProperty(exports, "Stats", {
|
|
852
|
+
enumerable: true,
|
|
853
|
+
get: function() {
|
|
854
|
+
return _cacheable_utils.Stats;
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
exports.createKeyv = createKeyv;
|
|
858
|
+
exports.defaultStoreHashSize = defaultStoreHashSize;
|
|
859
|
+
Object.defineProperty(exports, "getOrSetSync", {
|
|
860
|
+
enumerable: true,
|
|
861
|
+
get: function() {
|
|
862
|
+
return _cacheable_utils.getOrSetSync;
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
Object.defineProperty(exports, "hash", {
|
|
866
|
+
enumerable: true,
|
|
867
|
+
get: function() {
|
|
868
|
+
return _cacheable_utils.hash;
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
Object.defineProperty(exports, "hashToNumber", {
|
|
872
|
+
enumerable: true,
|
|
873
|
+
get: function() {
|
|
874
|
+
return _cacheable_utils.hashToNumber;
|
|
875
|
+
}
|
|
829
876
|
});
|
|
830
|
-
|
|
877
|
+
exports.maximumMapSize = maximumMapSize;
|