@daiso-tech/core 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -45
- package/dist/async/_module-exports.d.ts +1 -1
- package/dist/async/_module-exports.js +1 -1
- package/dist/async/_module-exports.js.map +1 -1
- package/dist/async/async.errors.d.ts +27 -19
- package/dist/async/async.errors.js +33 -20
- package/dist/async/async.errors.js.map +1 -1
- package/dist/async/backof-policies/_shared.d.ts +6 -2
- package/dist/async/backof-policies/_shared.js +1 -0
- package/dist/async/backof-policies/_shared.js.map +1 -1
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
- package/dist/async/middlewares/_module.d.ts +8 -0
- package/dist/async/middlewares/_module.js +9 -0
- package/dist/async/middlewares/_module.js.map +1 -0
- package/dist/async/middlewares/_shared.d.ts +10 -0
- package/dist/async/middlewares/_shared.js +5 -0
- package/dist/async/middlewares/_shared.js.map +1 -0
- package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
- package/dist/async/middlewares/bulkhead/_module.js +2 -0
- package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
- package/dist/async/middlewares/dynamic/_module.d.ts +1 -0
- package/dist/async/middlewares/dynamic/_module.js +2 -0
- package/dist/async/middlewares/dynamic/_module.js.map +1 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +34 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.js +36 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -0
- package/dist/async/middlewares/fallback/_module.d.ts +1 -0
- package/dist/async/middlewares/fallback/_module.js +2 -0
- package/dist/async/middlewares/fallback/_module.js.map +1 -0
- package/dist/async/middlewares/fallback/fallback.middleware.d.ts +78 -0
- package/dist/async/middlewares/fallback/fallback.middleware.js +52 -0
- package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -0
- package/dist/async/middlewares/hedging/_module.d.ts +2 -0
- package/dist/async/middlewares/hedging/_module.js +3 -0
- package/dist/async/middlewares/hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
- package/dist/async/middlewares/hedging/_shared.js +5 -0
- package/dist/async/middlewares/hedging/_shared.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/observe/_module.d.ts +1 -0
- package/dist/async/middlewares/observe/_module.js +2 -0
- package/dist/async/middlewares/observe/_module.js.map +1 -0
- package/dist/async/middlewares/observe/observe.middleware.d.ts +130 -0
- package/dist/async/middlewares/observe/observe.middleware.js +80 -0
- package/dist/async/middlewares/observe/observe.middleware.js.map +1 -0
- package/dist/async/middlewares/retry/_module.d.ts +1 -0
- package/dist/async/middlewares/retry/_module.js +2 -0
- package/dist/async/middlewares/retry/_module.js.map +1 -0
- package/dist/async/middlewares/retry/retry.middleware.d.ts +117 -0
- package/dist/async/middlewares/retry/retry.middleware.js +82 -0
- package/dist/async/middlewares/retry/retry.middleware.js.map +1 -0
- package/dist/async/middlewares/timeout/_module.d.ts +1 -0
- package/dist/async/middlewares/timeout/_module.js +2 -0
- package/dist/async/middlewares/timeout/_module.js.map +1 -0
- package/dist/async/middlewares/timeout/timeout.middleware.d.ts +83 -0
- package/dist/async/middlewares/timeout/timeout.middleware.js +60 -0
- package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -0
- package/dist/async/utilities/_module.d.ts +3 -4
- package/dist/async/utilities/_module.js +3 -4
- package/dist/async/utilities/_module.js.map +1 -1
- package/dist/async/utilities/abort-and-fail/_module.d.ts +1 -0
- package/dist/async/utilities/abort-and-fail/_module.js +2 -0
- package/dist/async/utilities/abort-and-fail/_module.js.map +1 -0
- package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +7 -0
- package/dist/async/utilities/{abort → abort-and-fail}/abort-and-fail.js +6 -6
- package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -0
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +37 -194
- package/dist/async/utilities/lazy-promise/lazy-promise.js +62 -359
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
- package/dist/async/utilities/promise-queue/_module.js +2 -0
- package/dist/async/utilities/promise-queue/_module.js.map +1 -0
- package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
- package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
- package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
- package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
- package/dist/cache/contracts/cache-adapter.contract.d.ts +14 -14
- package/dist/cache/contracts/cache-factory.contract.d.ts +3 -3
- package/dist/cache/contracts/cache.contract.d.ts +73 -73
- package/dist/cache/contracts/cache.errors.d.ts +7 -7
- package/dist/cache/contracts/cache.errors.js +7 -7
- package/dist/cache/contracts/cache.events.d.ts +54 -58
- package/dist/cache/contracts/cache.events.js +6 -104
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +16 -16
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +3 -9
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +3 -9
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +4 -4
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +3 -3
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +2 -2
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +2 -2
- package/dist/cache/implementations/derivables/cache/cache.d.ts +26 -27
- package/dist/cache/implementations/derivables/cache/cache.js +102 -91
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +5 -4
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +2 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +2 -2
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +140 -149
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +2 -2
- package/dist/collection/contracts/_shared/compartor.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/cross-join-result.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/ensure-map.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/ensure-record.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/foreach.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/map.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/modifier.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/predicate.type.d.ts +7 -7
- package/dist/collection/contracts/_shared/reduce.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/tap.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/transform.type.d.ts +2 -2
- package/dist/collection/contracts/async-collection.contract.d.ts +109 -198
- package/dist/collection/contracts/collection.contract.d.ts +103 -103
- package/dist/collection/contracts/collection.errors.d.ts +11 -11
- package/dist/collection/contracts/collection.errors.js +11 -11
- package/dist/collection/implementations/_shared.d.ts +8 -8
- package/dist/collection/implementations/_shared.js +8 -8
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.d.ts +0 -4
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js +0 -4
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js +21 -19
- package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +15 -19
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +15 -30
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.d.ts +3 -3
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js +18 -20
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +11 -12
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +11 -12
- package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +11 -11
- package/dist/collection/implementations/list-collection/list-collection.js +24 -30
- package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
- package/dist/event-bus/contracts/_module-exports.js +0 -1
- package/dist/event-bus/contracts/_module-exports.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +13 -8
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +6 -7
- package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.contract.d.ts +30 -41
- package/dist/event-bus/contracts/event-bus.errors.d.ts +8 -8
- package/dist/event-bus/contracts/event-bus.errors.js +8 -8
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +3 -3
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +3 -3
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -2
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -2
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +3 -3
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +2 -2
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +15 -15
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +32 -32
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +17 -10
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +13 -6
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +3 -5
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +15 -22
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +3 -5
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +189 -209
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +9 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +7 -7
- package/dist/lock/contracts/lock-provider-factory.contract.d.ts +4 -4
- package/dist/lock/contracts/lock-provider.contract.d.ts +14 -14
- package/dist/lock/contracts/lock.contract.d.ts +22 -22
- package/dist/lock/contracts/lock.errors.d.ts +10 -10
- package/dist/lock/contracts/lock.errors.js +10 -10
- package/dist/lock/contracts/lock.events.d.ts +45 -54
- package/dist/lock/contracts/lock.events.js +9 -91
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +4 -4
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +3 -3
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +3 -3
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +4 -4
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +2 -2
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +2 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +3 -3
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +3 -3
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +4 -4
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +33 -33
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +30 -30
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -2
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock.js +77 -58
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +5 -4
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +2 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +2 -2
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +2 -2
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +214 -214
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/contracts/deserializer.contract.d.ts +2 -2
- package/dist/serde/contracts/flexible-serde-adapter.contract.d.ts +4 -4
- package/dist/serde/contracts/flexible-serde.contract.d.ts +8 -19
- package/dist/serde/contracts/serde.contract.d.ts +2 -2
- package/dist/serde/contracts/serde.errors.d.ts +4 -4
- package/dist/serde/contracts/serde.errors.js +4 -4
- package/dist/serde/contracts/serializable.contract.d.ts +2 -2
- package/dist/serde/contracts/serializer.contract.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +4 -35
- package/dist/serde/implementations/derivables/serde.js +2 -47
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +2 -2
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +2 -2
- package/dist/utilities/classes/_module.d.ts +1 -1
- package/dist/utilities/classes/_module.js +1 -1
- package/dist/utilities/classes/_module.js.map +1 -1
- package/dist/utilities/classes/hooks/_module.d.ts +3 -0
- package/dist/utilities/classes/hooks/_module.js +4 -0
- package/dist/utilities/classes/hooks/_module.js.map +1 -0
- package/dist/utilities/classes/hooks/async-hooks.d.ts +209 -0
- package/dist/utilities/classes/hooks/async-hooks.js +145 -0
- package/dist/utilities/classes/hooks/async-hooks.js.map +1 -0
- package/dist/utilities/classes/hooks/hooks.d.ts +139 -0
- package/dist/utilities/classes/hooks/hooks.js +116 -0
- package/dist/utilities/classes/hooks/hooks.js.map +1 -0
- package/dist/utilities/classes/hooks/types.d.ts +9 -0
- package/dist/utilities/classes/hooks/types.js +5 -0
- package/dist/utilities/classes/hooks/types.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +3 -3
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +4 -4
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/dist/utilities/classes/time-span/time-span.d.ts +5 -5
- package/dist/utilities/classes/time-span/time-span.js +5 -5
- package/dist/utilities/contracts/_module.d.ts +0 -1
- package/dist/utilities/contracts/_module.js +0 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/deinitizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/initizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +1 -1
- package/dist/utilities/contracts/serialized-error.contract.d.ts +1 -1
- package/dist/utilities/contracts/sqlite-database.contract.d.ts +2 -2
- package/dist/utilities/errors.d.ts +5 -5
- package/dist/utilities/errors.js +5 -5
- package/dist/utilities/functions/factory.js +3 -3
- package/dist/utilities/functions/factory.js.map +1 -1
- package/dist/utilities/functions/invokable.d.ts +9 -5
- package/dist/utilities/functions/invokable.js +12 -2
- package/dist/utilities/functions/invokable.js.map +1 -1
- package/dist/utilities/functions/lazy.d.ts +5 -0
- package/dist/utilities/functions/lazy.js +12 -3
- package/dist/utilities/functions/lazy.js.map +1 -1
- package/dist/utilities/types/async-iterable-value.type.d.ts +1 -1
- package/dist/utilities/types/at-least-one.type.d.ts +1 -1
- package/dist/utilities/types/factory.type.d.ts +8 -8
- package/dist/utilities/types/invokable.type.d.ts +3 -3
- package/dist/utilities/types/items.type.d.ts +1 -1
- package/dist/utilities/types/lazy.type.d.ts +5 -5
- package/dist/utilities/types/none-func.type.d.ts +1 -1
- package/dist/utilities/types/one-or-more.type.d.ts +1 -1
- package/dist/utilities/types/promiseable.type.d.ts +1 -1
- package/dist/utilities/types/result.type.d.ts +1 -1
- package/package.json +22 -2
- package/dist/async/async.events.d.ts +0 -105
- package/dist/async/async.events.js +0 -82
- package/dist/async/async.events.js.map +0 -1
- package/dist/async/utilities/abort/_module.d.ts +0 -2
- package/dist/async/utilities/abort/_module.js +0 -3
- package/dist/async/utilities/abort/_module.js.map +0 -1
- package/dist/async/utilities/abort/abort-and-fail.d.ts +0 -4
- package/dist/async/utilities/abort/abort-and-fail.js.map +0 -1
- package/dist/async/utilities/abort/abort.d.ts +0 -9
- package/dist/async/utilities/abort/abort.js +0 -18
- package/dist/async/utilities/abort/abort.js.map +0 -1
- package/dist/async/utilities/delay/_module.d.ts +0 -1
- package/dist/async/utilities/delay/_module.js +0 -2
- package/dist/async/utilities/delay/_module.js.map +0 -1
- package/dist/async/utilities/delay/delay.d.ts +0 -10
- package/dist/async/utilities/delay/delay.js +0 -34
- package/dist/async/utilities/delay/delay.js.map +0 -1
- package/dist/async/utilities/retry/_module.d.ts +0 -2
- package/dist/async/utilities/retry/_module.js +0 -3
- package/dist/async/utilities/retry/_module.js.map +0 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +0 -29
- package/dist/async/utilities/retry/retry-or-fail.js +0 -39
- package/dist/async/utilities/retry/retry-or-fail.js.map +0 -1
- package/dist/async/utilities/retry/retry.d.ts +0 -10
- package/dist/async/utilities/retry/retry.js +0 -21
- package/dist/async/utilities/retry/retry.js.map +0 -1
- package/dist/async/utilities/timeout/_module.d.ts +0 -2
- package/dist/async/utilities/timeout/_module.js +0 -3
- package/dist/async/utilities/timeout/_module.js.map +0 -1
- package/dist/async/utilities/timeout/timeout-and-fail.d.ts +0 -5
- package/dist/async/utilities/timeout/timeout-and-fail.js +0 -28
- package/dist/async/utilities/timeout/timeout-and-fail.js.map +0 -1
- package/dist/async/utilities/timeout/timeout.d.ts +0 -10
- package/dist/async/utilities/timeout/timeout.js +0 -21
- package/dist/async/utilities/timeout/timeout.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +0 -30
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +0 -36
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.d.ts +0 -9
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +0 -39
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +0 -52
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +0 -1
- package/dist/event-bus/contracts/_shared.d.ts +0 -12
- package/dist/event-bus/contracts/_shared.js +0 -15
- package/dist/event-bus/contracts/_shared.js.map +0 -1
- package/dist/utilities/classes/sync-event-bus/_module.d.ts +0 -1
- package/dist/utilities/classes/sync-event-bus/_module.js +0 -2
- package/dist/utilities/classes/sync-event-bus/_module.js.map +0 -1
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.d.ts +0 -16
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js +0 -53
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js.map +0 -1
- package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
- package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
- package/dist/utilities/contracts/sync-event-bus-listenable.js.map +0 -1
|
@@ -6,7 +6,7 @@ import { type TimeSpan, type IInitizable, type IDeinitizable, type IPrunable, ty
|
|
|
6
6
|
import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
10
10
|
* @group Adapters
|
|
11
11
|
*/
|
|
12
12
|
export type SqliteCacheAdapterSettings = {
|
|
@@ -17,9 +17,9 @@ export type SqliteCacheAdapterSettings = {
|
|
|
17
17
|
shouldRemoveExpiredKeys?: boolean;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* To utilize the
|
|
20
|
+
* To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
21
21
|
*
|
|
22
|
-
* IMPORT_PATH:
|
|
22
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
23
23
|
* @group Adapters
|
|
24
24
|
*/
|
|
25
25
|
export declare class SqliteCacheAdapter<TType = unknown> implements IDatabaseCacheAdapter<TType>, IInitizable, IDeinitizable, IPrunable {
|
|
@@ -8,9 +8,9 @@ import { KyselyTableNameTransformerPlugin, } from "../../../../utilities/_module
|
|
|
8
8
|
import { Kysely, SqliteDialect } from "kysely";
|
|
9
9
|
import { KyselyCacheAdapter } from "../../../../cache/implementations/adapters/kysely-cache-adapter/_module.js";
|
|
10
10
|
/**
|
|
11
|
-
* To utilize the
|
|
11
|
+
* To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
12
12
|
*
|
|
13
|
-
* IMPORT_PATH:
|
|
13
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
14
14
|
* @group Adapters
|
|
15
15
|
*/
|
|
16
16
|
export class SqliteCacheAdapter {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { CacheEventMap, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
5
5
|
import { type ICache, type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
6
6
|
import { type AsyncLazyable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
import { type NoneFunc, type TimeSpan, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
9
|
-
import type { IEventBus, Unsubscribe,
|
|
9
|
+
import type { IEventBus, Unsubscribe, EventListener } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
10
|
import type { AsyncLazy, Factory } from "../../../../utilities/_module-exports.js";
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
|
-
* IMPORT_PATH:
|
|
13
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache"`
|
|
14
14
|
* @group Derivables
|
|
15
15
|
*/
|
|
16
16
|
export type CacheSettingsBase = {
|
|
17
17
|
keyPrefixer: KeyPrefixer;
|
|
18
18
|
/**
|
|
19
|
-
* You can pass a
|
|
19
|
+
* You can pass a {@link Factory | `Factory`} of {@link LazyPromise| `LazyPromise`} to configure default settings for all {@link LazyPromise| `LazyPromise`} instances used in the `Cache` class.
|
|
20
20
|
* @default
|
|
21
21
|
* ```ts
|
|
22
22
|
* import { LazyPromise } from "@daiso-tech/core/async";
|
|
@@ -38,7 +38,7 @@ export type CacheSettingsBase = {
|
|
|
38
38
|
* })
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
eventBus?: IEventBus
|
|
41
|
+
eventBus?: IEventBus;
|
|
42
42
|
/**
|
|
43
43
|
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
44
44
|
* @default {null}
|
|
@@ -47,13 +47,13 @@ export type CacheSettingsBase = {
|
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
*
|
|
50
|
-
* IMPORT_PATH:
|
|
50
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache"`
|
|
51
51
|
* @group Derivables
|
|
52
52
|
*/
|
|
53
53
|
export type CacheAdapter<TType> = ICacheAdapter<TType> | IDatabaseCacheAdapter<TType>;
|
|
54
54
|
/**
|
|
55
55
|
*
|
|
56
|
-
* IMPORT_PATH:
|
|
56
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache"`
|
|
57
57
|
* @group Derivables
|
|
58
58
|
*/
|
|
59
59
|
export type CacheSettings = CacheSettingsBase & {
|
|
@@ -61,11 +61,10 @@ export type CacheSettings = CacheSettingsBase & {
|
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
*
|
|
64
|
-
* IMPORT_PATH:
|
|
64
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache"`
|
|
65
65
|
* @group Derivables
|
|
66
66
|
*/
|
|
67
67
|
export declare class Cache<TType = unknown> implements ICache<TType> {
|
|
68
|
-
private static defaultRetryPolicy;
|
|
69
68
|
private readonly eventBus;
|
|
70
69
|
private readonly adapterFactoryable;
|
|
71
70
|
private readonly adapter;
|
|
@@ -100,35 +99,35 @@ export declare class Cache<TType = unknown> implements ICache<TType> {
|
|
|
100
99
|
*/
|
|
101
100
|
constructor(settings: CacheSettings);
|
|
102
101
|
/**
|
|
103
|
-
* You can listen to the following
|
|
104
|
-
* To understand how this method works, refer to
|
|
102
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
103
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
105
104
|
*/
|
|
106
|
-
addListener<
|
|
105
|
+
addListener<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
107
106
|
/**
|
|
108
|
-
* You can listen to the following
|
|
109
|
-
* To understand how this method works, refer to
|
|
107
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
108
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
110
109
|
*/
|
|
111
|
-
removeListener<
|
|
110
|
+
removeListener<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
112
111
|
/**
|
|
113
|
-
* You can listen to the following
|
|
114
|
-
* To understand how this method works, refer to
|
|
112
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
113
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
115
114
|
*/
|
|
116
|
-
listenOnce<
|
|
115
|
+
listenOnce<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
117
116
|
/**
|
|
118
|
-
* You can listen to the following
|
|
119
|
-
* To understand how this method works, refer to
|
|
117
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
118
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
120
119
|
*/
|
|
121
|
-
asPromise<
|
|
120
|
+
asPromise<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName): LazyPromise<CacheEventMap<TType>[TEventName]>;
|
|
122
121
|
/**
|
|
123
|
-
* You can listen to the following
|
|
124
|
-
* To understand how this method works, refer to
|
|
122
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
123
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
125
124
|
*/
|
|
126
|
-
subscribeOnce<
|
|
125
|
+
subscribeOnce<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<Unsubscribe>;
|
|
127
126
|
/**
|
|
128
|
-
* You can listen to the following
|
|
129
|
-
* To understand how this method works, refer to
|
|
127
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
128
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
130
129
|
*/
|
|
131
|
-
subscribe<
|
|
130
|
+
subscribe<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<Unsubscribe>;
|
|
132
131
|
private createLazyPromise;
|
|
133
132
|
exists(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
134
133
|
missing(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @module Cache
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { CACHE_EVENTS, } from "../../../../cache/contracts/_module-exports.js";
|
|
6
6
|
import { KeyNotFoundCacheError, TypeCacheError, } from "../../../../cache/contracts/_module-exports.js";
|
|
7
7
|
import { isAsyncFactory, resolveAsyncLazyable, resolveFactory, } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
import {} from "../../../../utilities/_module-exports.js";
|
|
@@ -14,14 +14,10 @@ import { isDatabaseCacheAdapter } from "../../../../cache/implementations/deriva
|
|
|
14
14
|
import { DatabaseCacheAdapter } from "../../../../cache/implementations/derivables/cache/database-cache-adapter.js";
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
|
-
* IMPORT_PATH:
|
|
17
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache"`
|
|
18
18
|
* @group Derivables
|
|
19
19
|
*/
|
|
20
20
|
export class Cache {
|
|
21
|
-
static defaultRetryPolicy = (error) => {
|
|
22
|
-
return !(error instanceof TypeCacheError ||
|
|
23
|
-
error instanceof KeyNotFoundCacheError);
|
|
24
|
-
};
|
|
25
21
|
eventBus;
|
|
26
22
|
adapterFactoryable;
|
|
27
23
|
adapter;
|
|
@@ -72,49 +68,49 @@ export class Cache {
|
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
/**
|
|
75
|
-
* You can listen to the following
|
|
76
|
-
* To understand how this method works, refer to
|
|
71
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
72
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
77
73
|
*/
|
|
78
|
-
addListener(
|
|
79
|
-
return this.eventBus.addListener(
|
|
74
|
+
addListener(eventName, listener) {
|
|
75
|
+
return this.eventBus.addListener(eventName, listener);
|
|
80
76
|
}
|
|
81
77
|
/**
|
|
82
|
-
* You can listen to the following
|
|
83
|
-
* To understand how this method works, refer to
|
|
78
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
79
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
84
80
|
*/
|
|
85
|
-
removeListener(
|
|
86
|
-
return this.eventBus.removeListener(
|
|
81
|
+
removeListener(eventName, listener) {
|
|
82
|
+
return this.eventBus.removeListener(eventName, listener);
|
|
87
83
|
}
|
|
88
84
|
/**
|
|
89
|
-
* You can listen to the following
|
|
90
|
-
* To understand how this method works, refer to
|
|
85
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
86
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
91
87
|
*/
|
|
92
|
-
listenOnce(
|
|
93
|
-
return this.eventBus.listenOnce(
|
|
88
|
+
listenOnce(eventName, listener) {
|
|
89
|
+
return this.eventBus.listenOnce(eventName, listener);
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
96
|
-
* You can listen to the following
|
|
97
|
-
* To understand how this method works, refer to
|
|
92
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
93
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
98
94
|
*/
|
|
99
|
-
asPromise(
|
|
100
|
-
return this.eventBus.asPromise(
|
|
95
|
+
asPromise(eventName) {
|
|
96
|
+
return this.eventBus.asPromise(eventName);
|
|
101
97
|
}
|
|
102
98
|
/**
|
|
103
|
-
* You can listen to the following
|
|
104
|
-
* To understand how this method works, refer to
|
|
99
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
100
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
105
101
|
*/
|
|
106
|
-
subscribeOnce(
|
|
107
|
-
return this.eventBus.subscribeOnce(
|
|
102
|
+
subscribeOnce(eventName, listener) {
|
|
103
|
+
return this.eventBus.subscribeOnce(eventName, listener);
|
|
108
104
|
}
|
|
109
105
|
/**
|
|
110
|
-
* You can listen to the following
|
|
111
|
-
* To understand how this method works, refer to
|
|
106
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
107
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
112
108
|
*/
|
|
113
|
-
subscribe(
|
|
114
|
-
return this.eventBus.subscribe(
|
|
109
|
+
subscribe(eventName, listener) {
|
|
110
|
+
return this.eventBus.subscribe(eventName, listener);
|
|
115
111
|
}
|
|
116
112
|
createLazyPromise(asyncFn) {
|
|
117
|
-
return this.lazyPromiseFactory(asyncFn)
|
|
113
|
+
return this.lazyPromiseFactory(asyncFn);
|
|
118
114
|
}
|
|
119
115
|
exists(key) {
|
|
120
116
|
return new LazyPromise(async () => {
|
|
@@ -135,28 +131,28 @@ export class Cache {
|
|
|
135
131
|
const value = await this.adapter.get(keyObj.prefixed);
|
|
136
132
|
if (value === null) {
|
|
137
133
|
this.eventBus
|
|
138
|
-
.dispatch(
|
|
134
|
+
.dispatch(CACHE_EVENTS.NOT_FOUND, {
|
|
139
135
|
key: keyObj.resolved,
|
|
140
|
-
})
|
|
136
|
+
})
|
|
141
137
|
.defer();
|
|
142
138
|
}
|
|
143
139
|
else {
|
|
144
140
|
this.eventBus
|
|
145
|
-
.dispatch(
|
|
141
|
+
.dispatch(CACHE_EVENTS.FOUND, {
|
|
146
142
|
key: keyObj.resolved,
|
|
147
143
|
value,
|
|
148
|
-
})
|
|
144
|
+
})
|
|
149
145
|
.defer();
|
|
150
146
|
}
|
|
151
147
|
return value;
|
|
152
148
|
}
|
|
153
149
|
catch (error) {
|
|
154
150
|
this.eventBus
|
|
155
|
-
.dispatch(
|
|
151
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
156
152
|
keys: [keyObj.resolved],
|
|
157
153
|
method: this.get.name,
|
|
158
154
|
error,
|
|
159
|
-
})
|
|
155
|
+
})
|
|
160
156
|
.defer();
|
|
161
157
|
throw error;
|
|
162
158
|
}
|
|
@@ -178,33 +174,34 @@ export class Cache {
|
|
|
178
174
|
const value = await this.adapter.getAndRemove(keyObj.prefixed);
|
|
179
175
|
if (value === null) {
|
|
180
176
|
this.eventBus
|
|
181
|
-
.dispatch(
|
|
177
|
+
.dispatch(CACHE_EVENTS.NOT_FOUND, {
|
|
182
178
|
key: keyObj.resolved,
|
|
183
|
-
})
|
|
179
|
+
})
|
|
184
180
|
.defer();
|
|
185
181
|
}
|
|
186
182
|
else {
|
|
187
183
|
this.eventBus
|
|
188
|
-
.dispatch(
|
|
184
|
+
.dispatch(CACHE_EVENTS.FOUND, {
|
|
189
185
|
key: keyObj.resolved,
|
|
190
186
|
value,
|
|
191
|
-
})
|
|
187
|
+
})
|
|
192
188
|
.defer();
|
|
193
189
|
this.eventBus
|
|
194
|
-
.dispatch(
|
|
190
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
191
|
+
type: "removed",
|
|
195
192
|
key: keyObj.resolved,
|
|
196
|
-
})
|
|
193
|
+
})
|
|
197
194
|
.defer();
|
|
198
195
|
}
|
|
199
196
|
return value;
|
|
200
197
|
}
|
|
201
198
|
catch (error) {
|
|
202
199
|
this.eventBus
|
|
203
|
-
.dispatch(
|
|
200
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
204
201
|
keys: [keyObj.resolved],
|
|
205
202
|
method: this.get.name,
|
|
206
203
|
error,
|
|
207
|
-
})
|
|
204
|
+
})
|
|
208
205
|
.defer();
|
|
209
206
|
throw error;
|
|
210
207
|
}
|
|
@@ -238,23 +235,24 @@ export class Cache {
|
|
|
238
235
|
const hasAdded = await this.adapter.add(keyObj.prefixed, value, ttl);
|
|
239
236
|
if (hasAdded) {
|
|
240
237
|
this.eventBus
|
|
241
|
-
.dispatch(
|
|
238
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
239
|
+
type: "added",
|
|
242
240
|
key: keyObj.resolved,
|
|
243
241
|
value,
|
|
244
242
|
ttl,
|
|
245
|
-
})
|
|
243
|
+
})
|
|
246
244
|
.defer();
|
|
247
245
|
}
|
|
248
246
|
return hasAdded;
|
|
249
247
|
}
|
|
250
248
|
catch (error) {
|
|
251
249
|
this.eventBus
|
|
252
|
-
.dispatch(
|
|
250
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
253
251
|
keys: [keyObj.resolved],
|
|
254
252
|
value,
|
|
255
253
|
method: this.add.name,
|
|
256
254
|
error,
|
|
257
|
-
})
|
|
255
|
+
})
|
|
258
256
|
.defer();
|
|
259
257
|
throw error;
|
|
260
258
|
}
|
|
@@ -267,31 +265,33 @@ export class Cache {
|
|
|
267
265
|
const hasUpdated = await this.adapter.put(keyObj.prefixed, value, ttl);
|
|
268
266
|
if (hasUpdated) {
|
|
269
267
|
this.eventBus
|
|
270
|
-
.dispatch(
|
|
268
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
269
|
+
type: "updated",
|
|
271
270
|
key: keyObj.resolved,
|
|
272
271
|
value,
|
|
273
|
-
})
|
|
272
|
+
})
|
|
274
273
|
.defer();
|
|
275
274
|
}
|
|
276
275
|
else {
|
|
277
276
|
this.eventBus
|
|
278
|
-
.dispatch(
|
|
277
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
278
|
+
type: "added",
|
|
279
279
|
key: keyObj.resolved,
|
|
280
280
|
value,
|
|
281
281
|
ttl,
|
|
282
|
-
})
|
|
282
|
+
})
|
|
283
283
|
.defer();
|
|
284
284
|
}
|
|
285
285
|
return hasUpdated;
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
288
288
|
this.eventBus
|
|
289
|
-
.dispatch(
|
|
289
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
290
290
|
keys: [keyObj.resolved],
|
|
291
291
|
value,
|
|
292
292
|
method: this.put.name,
|
|
293
293
|
error,
|
|
294
|
-
})
|
|
294
|
+
})
|
|
295
295
|
.defer();
|
|
296
296
|
throw error;
|
|
297
297
|
}
|
|
@@ -304,29 +304,30 @@ export class Cache {
|
|
|
304
304
|
const hasUpdated = await this.adapter.update(keyObj.prefixed, value);
|
|
305
305
|
if (hasUpdated) {
|
|
306
306
|
this.eventBus
|
|
307
|
-
.dispatch(
|
|
307
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
308
|
+
type: "updated",
|
|
308
309
|
key: keyObj.resolved,
|
|
309
310
|
value,
|
|
310
|
-
})
|
|
311
|
+
})
|
|
311
312
|
.defer();
|
|
312
313
|
}
|
|
313
314
|
else {
|
|
314
315
|
this.eventBus
|
|
315
|
-
.dispatch(
|
|
316
|
+
.dispatch(CACHE_EVENTS.NOT_FOUND, {
|
|
316
317
|
key: keyObj.resolved,
|
|
317
|
-
})
|
|
318
|
+
})
|
|
318
319
|
.defer();
|
|
319
320
|
}
|
|
320
321
|
return hasUpdated;
|
|
321
322
|
}
|
|
322
323
|
catch (error) {
|
|
323
324
|
this.eventBus
|
|
324
|
-
.dispatch(
|
|
325
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
325
326
|
keys: [keyObj.resolved],
|
|
326
327
|
value,
|
|
327
328
|
method: this.update.name,
|
|
328
329
|
error,
|
|
329
|
-
})
|
|
330
|
+
})
|
|
330
331
|
.defer();
|
|
331
332
|
throw error;
|
|
332
333
|
}
|
|
@@ -339,39 +340,41 @@ export class Cache {
|
|
|
339
340
|
const hasUpdated = await this.adapter.increment(keyObj.prefixed, value);
|
|
340
341
|
if (hasUpdated && value > 0) {
|
|
341
342
|
this.eventBus
|
|
342
|
-
.dispatch(
|
|
343
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
344
|
+
type: "incremented",
|
|
343
345
|
key: keyObj.resolved,
|
|
344
346
|
value,
|
|
345
|
-
})
|
|
347
|
+
})
|
|
346
348
|
.defer();
|
|
347
349
|
}
|
|
348
350
|
if (hasUpdated && value < 0) {
|
|
349
351
|
this.eventBus
|
|
350
|
-
.dispatch(
|
|
352
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
353
|
+
type: "decremented",
|
|
351
354
|
key: keyObj.resolved,
|
|
352
355
|
value: -value,
|
|
353
|
-
})
|
|
356
|
+
})
|
|
354
357
|
.defer();
|
|
355
358
|
}
|
|
356
359
|
if (!hasUpdated) {
|
|
357
360
|
this.eventBus
|
|
358
|
-
.dispatch(
|
|
361
|
+
.dispatch(CACHE_EVENTS.NOT_FOUND, {
|
|
359
362
|
key: keyObj.resolved,
|
|
360
|
-
})
|
|
363
|
+
})
|
|
361
364
|
.defer();
|
|
362
365
|
}
|
|
363
366
|
return hasUpdated;
|
|
364
367
|
}
|
|
365
368
|
catch (error) {
|
|
366
369
|
this.eventBus
|
|
367
|
-
.dispatch(
|
|
370
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
368
371
|
keys: [keyObj.resolved],
|
|
369
372
|
value,
|
|
370
373
|
method: this.increment.name,
|
|
371
374
|
error,
|
|
372
|
-
})
|
|
375
|
+
})
|
|
373
376
|
.defer();
|
|
374
|
-
throw error;
|
|
377
|
+
throw new TypeCacheError(`Unable to increment or decrement none number type key "${keyObj.resolved}"`, error);
|
|
375
378
|
}
|
|
376
379
|
});
|
|
377
380
|
}
|
|
@@ -389,27 +392,28 @@ export class Cache {
|
|
|
389
392
|
]);
|
|
390
393
|
if (hasRemoved) {
|
|
391
394
|
this.eventBus
|
|
392
|
-
.dispatch(
|
|
395
|
+
.dispatch(CACHE_EVENTS.WRITTEN, {
|
|
396
|
+
type: "removed",
|
|
393
397
|
key: keyObj.resolved,
|
|
394
|
-
})
|
|
398
|
+
})
|
|
395
399
|
.defer();
|
|
396
400
|
}
|
|
397
401
|
else {
|
|
398
402
|
this.eventBus
|
|
399
|
-
.dispatch(
|
|
403
|
+
.dispatch(CACHE_EVENTS.NOT_FOUND, {
|
|
400
404
|
key: keyObj.resolved,
|
|
401
|
-
})
|
|
405
|
+
})
|
|
402
406
|
.defer();
|
|
403
407
|
}
|
|
404
408
|
return hasRemoved;
|
|
405
409
|
}
|
|
406
410
|
catch (error) {
|
|
407
411
|
this.eventBus
|
|
408
|
-
.dispatch(
|
|
412
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
409
413
|
keys: [keyObj.resolved],
|
|
410
414
|
method: this.remove.name,
|
|
411
415
|
error,
|
|
412
|
-
})
|
|
416
|
+
})
|
|
413
417
|
.defer();
|
|
414
418
|
throw error;
|
|
415
419
|
}
|
|
@@ -425,30 +429,37 @@ export class Cache {
|
|
|
425
429
|
try {
|
|
426
430
|
const hasRemovedAtLeastOne = await this.adapter.removeMany(keyObjArr.map((keyObj) => keyObj.prefixed));
|
|
427
431
|
if (hasRemovedAtLeastOne) {
|
|
428
|
-
const events = keyObjArr.map((keyObj) =>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
432
|
+
const events = keyObjArr.map((keyObj) => [
|
|
433
|
+
CACHE_EVENTS.WRITTEN,
|
|
434
|
+
{
|
|
435
|
+
type: "removed",
|
|
436
|
+
key: keyObj.resolved,
|
|
437
|
+
},
|
|
438
|
+
]);
|
|
439
|
+
for (const [eventName, event] of events) {
|
|
440
|
+
this.eventBus.dispatch(eventName, event).defer();
|
|
433
441
|
}
|
|
434
442
|
}
|
|
435
443
|
else {
|
|
436
|
-
const events = keyObjArr.map((keyObj) =>
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
444
|
+
const events = keyObjArr.map((keyObj) => [
|
|
445
|
+
CACHE_EVENTS.NOT_FOUND,
|
|
446
|
+
{
|
|
447
|
+
key: keyObj.resolved,
|
|
448
|
+
},
|
|
449
|
+
]);
|
|
450
|
+
for (const [eventName, event] of events) {
|
|
451
|
+
this.eventBus.dispatch(eventName, event).defer();
|
|
441
452
|
}
|
|
442
453
|
}
|
|
443
454
|
return hasRemovedAtLeastOne;
|
|
444
455
|
}
|
|
445
456
|
catch (error) {
|
|
446
457
|
this.eventBus
|
|
447
|
-
.dispatch(
|
|
458
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
448
459
|
keys: keyObjArr.map((keyObj) => keyObj.resolved),
|
|
449
460
|
method: this.remove.name,
|
|
450
461
|
error,
|
|
451
|
-
})
|
|
462
|
+
})
|
|
452
463
|
.defer();
|
|
453
464
|
throw error;
|
|
454
465
|
}
|
|
@@ -457,7 +468,7 @@ export class Cache {
|
|
|
457
468
|
clear() {
|
|
458
469
|
return this.createLazyPromise(async () => {
|
|
459
470
|
try {
|
|
460
|
-
const promise = this.eventBus.dispatch(
|
|
471
|
+
const promise = this.eventBus.dispatch(CACHE_EVENTS.CLEARED, {});
|
|
461
472
|
if (isAsyncFactory(this.adapterFactoryable)) {
|
|
462
473
|
await this.adapter.removeAll();
|
|
463
474
|
promise.defer();
|
|
@@ -468,10 +479,10 @@ export class Cache {
|
|
|
468
479
|
}
|
|
469
480
|
catch (error) {
|
|
470
481
|
this.eventBus
|
|
471
|
-
.dispatch(
|
|
482
|
+
.dispatch(CACHE_EVENTS.UNEXPECTED_ERROR, {
|
|
472
483
|
method: this.clear.name,
|
|
473
484
|
error,
|
|
474
|
-
})
|
|
485
|
+
})
|
|
475
486
|
.defer();
|
|
476
487
|
throw error;
|
|
477
488
|
}
|