@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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import {} from "../../../utilities/_module-exports.js";
|
|
5
|
+
import { LazyPromise } from "../../../async/utilities/_module.js";
|
|
6
|
+
import { v4 } from "uuid";
|
|
7
|
+
import { CapacityFullAsyncError } from "../../../async/async.errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
class Queue {
|
|
12
|
+
array = [];
|
|
13
|
+
size() {
|
|
14
|
+
return this.array.length;
|
|
15
|
+
}
|
|
16
|
+
enqueue(value) {
|
|
17
|
+
this.array.push(value);
|
|
18
|
+
}
|
|
19
|
+
dequeue() {
|
|
20
|
+
return this.array.shift() ?? null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export class PromiseQueue {
|
|
27
|
+
settings;
|
|
28
|
+
queue = new Queue();
|
|
29
|
+
listeners = new Map();
|
|
30
|
+
constructor(settings) {
|
|
31
|
+
this.settings = settings;
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
33
|
+
this.start();
|
|
34
|
+
}
|
|
35
|
+
async start() {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition
|
|
37
|
+
while (true) {
|
|
38
|
+
await Promise.all(this.getItems().map((item) => this.process(item)));
|
|
39
|
+
await LazyPromise.delay(this.settings.interval);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getItems() {
|
|
43
|
+
const values = [];
|
|
44
|
+
for (let i = 0; i < this.settings.maxConcurrency; i++) {
|
|
45
|
+
const item = this.queue.dequeue();
|
|
46
|
+
if (item === null) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
values.push(item);
|
|
50
|
+
}
|
|
51
|
+
return values;
|
|
52
|
+
}
|
|
53
|
+
async process(item) {
|
|
54
|
+
const listener = this.listeners.get(item.id);
|
|
55
|
+
try {
|
|
56
|
+
if (item.signal.aborted) {
|
|
57
|
+
listener?.([null, item.signal.reason]);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const value = await item.func(item.signal);
|
|
61
|
+
listener?.([value, null]);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
listener?.([null, error]);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
enqueue(func, signal) {
|
|
69
|
+
const id = v4();
|
|
70
|
+
if (this.settings.maxCapacity === null) {
|
|
71
|
+
this.queue.enqueue({
|
|
72
|
+
id,
|
|
73
|
+
func,
|
|
74
|
+
signal,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else if (this.queue.size() <= this.settings.maxCapacity) {
|
|
78
|
+
this.queue.enqueue({ id, func, signal });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new CapacityFullAsyncError(`Max capacity reached, ${String(this.settings.maxCapacity)} items allowed.`);
|
|
82
|
+
}
|
|
83
|
+
return id;
|
|
84
|
+
}
|
|
85
|
+
listenOnce(id, listener) {
|
|
86
|
+
this.listeners.set(id, listener);
|
|
87
|
+
}
|
|
88
|
+
asPromise(id) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
this.listenOnce(id, ([value, error]) => {
|
|
91
|
+
if (value === null) {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
93
|
+
reject(error);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
resolve(value);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @throws {CapacityFullAsyncError} {@link CapacityFullAsyncError}
|
|
102
|
+
*/
|
|
103
|
+
add(func, signal) {
|
|
104
|
+
return this.asPromise(this.enqueue(func, signal));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=promise-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-queue.js","sourceRoot":"","sources":["../../../../src/async/utilities/promise-queue/promise-queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIN,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;GAEG;AACH,MAAM,KAAK;IACU,KAAK,GAAa,EAAE,CAAC;IAEtC,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,KAAa;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC;IACtC,CAAC;CACJ;AA2BD;;GAEG;AACH,MAAM,OAAO,YAAY;IAKQ;IAJZ,KAAK,GAAG,IAAI,KAAK,EAA6B,CAAC;IAE/C,SAAS,GAAG,IAAI,GAAG,EAAqC,CAAC;IAE1E,YAA6B,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;QACvD,mEAAmE;QACnE,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,KAAK;QACf,8FAA8F;QAC9F,OAAO,IAAI,EAAE,CAAC;YACV,MAAM,OAAO,CAAC,GAAG,CACb,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACpD,CAAC;YACF,MAAM,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAEO,QAAQ;QACZ,MAAM,MAAM,GAA+B,EAAE,CAAC;QAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,MAAM,IAAI,GACN,IAAI,CAAC,KAAK,CAAC,OAAO,EAAqC,CAAC;YAC5D,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChB,SAAS;YACb,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,OAAO,CACjB,IAA8B;QAE9B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACtB,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvC,OAAO;YACX,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3C,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAE1B,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAEO,OAAO,CACX,IAA4D,EAC5D,MAAmB;QAEnB,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;gBACf,EAAE;gBACF,IAAI;gBACJ,MAAM;aACT,CAAC,CAAC;QACP,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,sBAAsB,CAC5B,yBAAyB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAC9E,CAAC;QACN,CAAC;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAEO,UAAU,CACd,EAAU,EACV,QAAsC;QAEtC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAEO,SAAS,CAAS,EAAU;QAChC,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE;gBACnC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACjB,2EAA2E;oBAC3E,MAAM,CAAC,KAAK,CAAC,CAAC;oBACd,OAAO;gBACX,CAAC;gBACD,OAAO,CAAC,KAAe,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,GAAG,CACC,IAA4D,EAC5D,MAAmB;QAEnB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../async/utilities/timeout-and-fail/timeout-and-fail.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/utilities/timeout-and-fail/_module.ts"],"names":[],"mappings":"AAAA,cAAc,wDAAwD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
2
|
+
/**
|
|
3
|
+
* @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function timeoutAndFail<TValue>(promise: PromiseLike<TValue>, time: TimeSpan, abort: (rejection: unknown) => void, signal: AbortSignal): Promise<TValue>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TimeoutAsyncError } from "../../../async/async.errors.js";
|
|
2
|
+
import { abortAndFail } from "../../../async/utilities/abort-and-fail/_module.js";
|
|
3
|
+
/**
|
|
4
|
+
* @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export async function timeoutAndFail(promise, time, abort, signal) {
|
|
9
|
+
const timeoutId = setTimeout(() => {
|
|
10
|
+
abort(new TimeoutAsyncError("The promise exceded time"));
|
|
11
|
+
}, time.toMilliseconds());
|
|
12
|
+
try {
|
|
13
|
+
return await abortAndFail(promise, signal);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
clearTimeout(timeoutId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=timeout-and-fail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout-and-fail.js","sourceRoot":"","sources":["../../../../src/async/utilities/timeout-and-fail/timeout-and-fail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,OAA4B,EAC5B,IAAc,EACd,KAAmC,EACnC,MAAmB;IAEnB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;QAC9B,KAAK,CAAC,IAAI,iBAAiB,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAC7D,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC1B,IAAI,CAAC;QACD,OAAO,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACP,YAAY,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;AACL,CAAC"}
|
|
@@ -3,52 +3,52 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { TimeSpan } from "../../utilities/_module-exports.js";
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The `ICacheAdapter` contract defines a way for key-value pairs independent of data storage.
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
9
9
|
* @group Contracts
|
|
10
10
|
*/
|
|
11
11
|
export type ICacheAdapter<TType = unknown> = {
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The `get` method returns the value when `key` is found otherwise null will be returned.
|
|
14
14
|
*/
|
|
15
15
|
get(key: string): PromiseLike<TType | null>;
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
17
|
+
* The `getAndRemove` method returns the value when `key` is found otherwise null will be returned.
|
|
18
18
|
* The key will be removed after it is returned.
|
|
19
19
|
*/
|
|
20
20
|
getAndRemove(key: string): PromiseLike<TType | null>;
|
|
21
21
|
/**
|
|
22
|
-
* The
|
|
23
|
-
* You can provide a
|
|
22
|
+
* The `add` method adds a `key` with given `value` when key doesn't exists. Returns true when key doesn't exists otherwise false will be returned.
|
|
23
|
+
* You can provide a `ttl` value. If null is passed, the item will not expire.
|
|
24
24
|
*/
|
|
25
25
|
add(key: string, value: TType, ttl: TimeSpan | null): PromiseLike<boolean>;
|
|
26
26
|
/**
|
|
27
|
-
* The
|
|
28
|
-
* Returns true if the
|
|
27
|
+
* The `put` method replaces th given `key` with the given `value` and `ttl` if the `key` exists othwerwise it will add the given `value` and `ttl`.
|
|
28
|
+
* Returns true if the `key` where replaced otherwise false is returned.
|
|
29
29
|
*/
|
|
30
30
|
put(key: string, value: TType, ttl: TimeSpan | null): PromiseLike<boolean>;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The `update` method updates the given `key` with given `value`. Returns true if the `key` where updated otherwise false will be returned.
|
|
33
33
|
*/
|
|
34
34
|
update(key: string, value: TType): PromiseLike<boolean>;
|
|
35
35
|
/**
|
|
36
|
-
* The
|
|
37
|
-
* If
|
|
36
|
+
* The `increment` method increments the given `key` with given `value`. Returns true if the `key` where incremented otherwise false will be returned.
|
|
37
|
+
* If `values` is not defined then it will increment the key with 1.
|
|
38
38
|
* An error will thrown if the key is not a number.
|
|
39
39
|
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
40
40
|
*/
|
|
41
41
|
increment(key: string, value: number): PromiseLike<boolean>;
|
|
42
42
|
/**
|
|
43
|
-
* The
|
|
43
|
+
* The `removeMany` method removes many keys. Returns true if one of the keys where deleted otherwise false is returned.
|
|
44
44
|
*/
|
|
45
45
|
removeMany(keys: string[]): PromiseLike<boolean>;
|
|
46
46
|
/**
|
|
47
|
-
* The
|
|
47
|
+
* The `removeAll` method removes all keys from the cache.
|
|
48
48
|
*/
|
|
49
49
|
removeAll(): PromiseLike<void>;
|
|
50
50
|
/**
|
|
51
|
-
* The
|
|
51
|
+
* The `removeByKeyPrefix` method removes all the keys in the cache that starts with the given `prefix`.
|
|
52
52
|
*/
|
|
53
53
|
removeByKeyPrefix(prefix: string): PromiseLike<void>;
|
|
54
54
|
};
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ICache } from "../../cache/contracts/cache.contract.js";
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The `ICacheFactory` contract makes it easy to configure and switch between different {@link ICache | `ICache`} dynamically.
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
9
9
|
* @group Contracts
|
|
10
10
|
*/
|
|
11
11
|
export type ICacheFactory<TAdapters extends string = string> = {
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The `use` method will throw an error if you provide it unregisted adapter.
|
|
14
14
|
* If no default adapter is defined an error will be thrown.
|
|
15
15
|
* @throws {UnregisteredAdapterError} {@link UnregisteredAdapterError}
|
|
16
16
|
* @throws {DefaultAdapterNotDefinedError} {@link DefaultAdapterNotDefinedError}
|
|
@@ -4,91 +4,91 @@
|
|
|
4
4
|
import type { LazyPromise } from "../../async/_module-exports.js";
|
|
5
5
|
import type { TimeSpan } from "../../utilities/_module-exports.js";
|
|
6
6
|
import type { AsyncLazyable, NoneFunc, OneOrMore } from "../../utilities/_module-exports.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { CacheEventMap } from "../../cache/contracts/cache.events.js";
|
|
8
8
|
import type { IEventListenable } from "../../event-bus/contracts/_module-exports.js";
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
10
|
+
* The `ICacheListenable` contract defines a way for listening {@link ICache | `ICache`} operation events.
|
|
11
11
|
*
|
|
12
|
-
* IMPORT_PATH:
|
|
12
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
13
13
|
* @group Contracts
|
|
14
14
|
*/
|
|
15
|
-
export type ICacheListenable<TType = unknown> = IEventListenable<
|
|
15
|
+
export type ICacheListenable<TType = unknown> = IEventListenable<CacheEventMap<TType>>;
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
17
|
+
* The `ICacheBase` contract defines a way for as key-value pairs independent of data storage.
|
|
18
18
|
*
|
|
19
|
-
* IMPORT_PATH:
|
|
19
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
20
20
|
* @group Contracts
|
|
21
21
|
*/
|
|
22
22
|
export type ICacheBase<TType = unknown> = {
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
24
|
+
* The `exists` method returns true when `key` is found otherwise false will be returned.
|
|
25
25
|
*
|
|
26
|
-
* @param key - can be a string or an
|
|
27
|
-
* If it's an
|
|
28
|
-
* Think of an
|
|
26
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
27
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
28
|
+
* Think of an `Iterable` as representing a path.
|
|
29
29
|
*/
|
|
30
30
|
exists(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The `missing` method returns true when `key` is not found otherwise false will be returned.
|
|
33
33
|
*
|
|
34
|
-
* @param key - can be a string or an
|
|
35
|
-
* If it's an
|
|
36
|
-
* Think of an
|
|
34
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
35
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
36
|
+
* Think of an `Iterable` as representing a path.
|
|
37
37
|
*/
|
|
38
38
|
missing(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
39
39
|
/**
|
|
40
|
-
* The
|
|
40
|
+
* The `get` method returns the value when `key` is found otherwise null will be returned.
|
|
41
41
|
*
|
|
42
|
-
* @param key - can be a string or an
|
|
43
|
-
* If it's an
|
|
44
|
-
* Think of an
|
|
42
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
43
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
44
|
+
* Think of an `Iterable` as representing a path.
|
|
45
45
|
*/
|
|
46
46
|
get(key: OneOrMore<string>): LazyPromise<TType | null>;
|
|
47
47
|
/**
|
|
48
|
-
* The
|
|
48
|
+
* The `getOrFail` method returns the value when `key` is found otherwise an error will be thrown.
|
|
49
49
|
*
|
|
50
|
-
* @param key - can be a string or an
|
|
51
|
-
* If it's an
|
|
52
|
-
* Think of an
|
|
50
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
51
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
52
|
+
* Think of an `Iterable` as representing a path.
|
|
53
53
|
*
|
|
54
54
|
* @throws {KeyNotFoundCacheError} {@link KeyNotFoundCacheError}
|
|
55
55
|
*/
|
|
56
56
|
getOrFail(key: OneOrMore<string>): LazyPromise<TType>;
|
|
57
57
|
/**
|
|
58
|
-
* The
|
|
58
|
+
* The `getAndRemove` method returns the value when `key` is found otherwise null will be returned.
|
|
59
59
|
* The key will be removed after it is returned.
|
|
60
60
|
*
|
|
61
|
-
* @param key - can be a string or an
|
|
62
|
-
* If it's an
|
|
63
|
-
* Think of an
|
|
61
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
62
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
63
|
+
* Think of an `Iterable` as representing a path.
|
|
64
64
|
*/
|
|
65
65
|
getAndRemove(key: OneOrMore<string>): LazyPromise<TType | null>;
|
|
66
66
|
/**
|
|
67
|
-
* The
|
|
67
|
+
* The `getOr` method will retrieve the given `key` if found otherwise `defaultValue` will be returned.
|
|
68
68
|
*
|
|
69
|
-
* @param key - can be a string or an
|
|
70
|
-
* If it's an
|
|
71
|
-
* Think of an
|
|
69
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
70
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
71
|
+
* Think of an `Iterable` as representing a path.
|
|
72
72
|
*
|
|
73
|
-
* @param defaultValue - can be regular value, sync or async
|
|
73
|
+
* @param defaultValue - can be regular value, sync or async {@link Invokable | `Invokable`} value and {@link LazyPromise| `LazyPromise`} value.
|
|
74
74
|
*/
|
|
75
75
|
getOr(key: OneOrMore<string>, defaultValue: AsyncLazyable<NoneFunc<TType>>): LazyPromise<TType>;
|
|
76
76
|
/**
|
|
77
|
-
* The
|
|
77
|
+
* The `getOrAdd` method will retrieve the given `key` if found otherwise `valueToAdd` will be added and returned.
|
|
78
78
|
*
|
|
79
|
-
* @param key - can be a string or an
|
|
80
|
-
* If it's an
|
|
81
|
-
* Think of an
|
|
79
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
80
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
81
|
+
* Think of an `Iterable` as representing a path.
|
|
82
82
|
*
|
|
83
|
-
* @param valueToAdd - can be regular value, sync or async
|
|
83
|
+
* @param valueToAdd - can be regular value, sync or async {@link Invokable | `Invokable`} value and {@link LazyPromise| `LazyPromise`} value.
|
|
84
84
|
*/
|
|
85
85
|
getOrAdd(key: OneOrMore<string>, valueToAdd: AsyncLazyable<NoneFunc<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
|
|
86
86
|
/**
|
|
87
|
-
* The
|
|
87
|
+
* The `add` method adds a `key` with given `value` when key doesn't exists.
|
|
88
88
|
*
|
|
89
|
-
* @param key - can be a string or an
|
|
90
|
-
* If it's an
|
|
91
|
-
* Think of an
|
|
89
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
90
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
91
|
+
* Think of an `Iterable` as representing a path.
|
|
92
92
|
*
|
|
93
93
|
* @param ttl - If null is passed, the item will not expire.
|
|
94
94
|
*
|
|
@@ -96,87 +96,87 @@ export type ICacheBase<TType = unknown> = {
|
|
|
96
96
|
*/
|
|
97
97
|
add(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
98
98
|
/**
|
|
99
|
-
* The
|
|
100
|
-
* othwerwise it will add the given
|
|
99
|
+
* The `put` method replaces th given `key` with the given `value` and `ttl` if the `key` exists
|
|
100
|
+
* othwerwise it will add the given `value` with the given `ttl`.
|
|
101
101
|
*
|
|
102
|
-
* @param key - can be a string or an
|
|
103
|
-
* If it's an
|
|
104
|
-
* Think of an
|
|
102
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
103
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
104
|
+
* Think of an `Iterable` as representing a path.
|
|
105
105
|
*
|
|
106
106
|
* @param ttl - If null is passed, the item will not expire.
|
|
107
107
|
*
|
|
108
|
-
* @returns true if the
|
|
108
|
+
* @returns true if the `key` where replaced otherwise false is returned.
|
|
109
109
|
*/
|
|
110
110
|
put(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
111
111
|
/**
|
|
112
|
-
* The
|
|
112
|
+
* The `update` method updates the given `key` with given `value`.
|
|
113
113
|
*
|
|
114
|
-
* @param key - can be a string or an
|
|
115
|
-
* If it's an
|
|
116
|
-
* Think of an
|
|
114
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
115
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
116
|
+
* Think of an `Iterable` as representing a path.
|
|
117
117
|
*
|
|
118
|
-
* @returns true if the
|
|
118
|
+
* @returns true if the `key` where updated otherwise false will be returned.
|
|
119
119
|
*/
|
|
120
120
|
update(key: OneOrMore<string>, value: TType): LazyPromise<boolean>;
|
|
121
121
|
/**
|
|
122
|
-
* The
|
|
122
|
+
* The `increment` method increments the given `key` with given `value`.
|
|
123
123
|
* An error will thrown if the key is not a number.
|
|
124
124
|
*
|
|
125
|
-
* @param key - can be a string or an
|
|
126
|
-
* If it's an
|
|
127
|
-
* Think of an
|
|
125
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
126
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
127
|
+
* Think of an `Iterable` as representing a path.
|
|
128
128
|
*
|
|
129
129
|
* @param value - If not defined then it will be defaulted to 1.
|
|
130
130
|
*
|
|
131
|
-
* @returns true if the
|
|
131
|
+
* @returns true if the `key` where incremented otherwise false will be returned.
|
|
132
132
|
*
|
|
133
133
|
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
134
134
|
*/
|
|
135
135
|
increment(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
136
136
|
/**
|
|
137
|
-
* The
|
|
137
|
+
* The `decrement` method decrements the given `key` with given `value`.
|
|
138
138
|
* An error will thrown if the key is not a number.
|
|
139
139
|
*
|
|
140
|
-
* @param key - can be a string or an
|
|
141
|
-
* If it's an
|
|
142
|
-
* Think of an
|
|
140
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
141
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
142
|
+
* Think of an `Iterable` as representing a path.
|
|
143
143
|
*
|
|
144
144
|
* @param value - If not defined then it will be defaulted to 1.
|
|
145
145
|
*
|
|
146
|
-
* @returns true if the
|
|
146
|
+
* @returns true if the `key` where decremented otherwise false will be returned.
|
|
147
147
|
*
|
|
148
148
|
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
149
149
|
*/
|
|
150
150
|
decrement(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
151
151
|
/**
|
|
152
|
-
* The
|
|
152
|
+
* The `remove` method removes the given `key`.
|
|
153
153
|
*
|
|
154
|
-
* @param key - can be a string or an
|
|
155
|
-
* If it's an
|
|
156
|
-
* Think of an
|
|
154
|
+
* @param key - can be a string or an `Iterable` of strings.
|
|
155
|
+
* If it's an `Iterable`, it will be joined into a single string.
|
|
156
|
+
* Think of an `Iterable` as representing a path.
|
|
157
157
|
*
|
|
158
158
|
* @returns true if the key is found otherwise false is returned.
|
|
159
159
|
*/
|
|
160
160
|
remove(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
161
161
|
/**
|
|
162
|
-
* The
|
|
162
|
+
* The `removeMany` method removes many keys.
|
|
163
163
|
*
|
|
164
|
-
* @param keys - The param items can be a string or an
|
|
165
|
-
* If the param items are an
|
|
166
|
-
* Think of an
|
|
164
|
+
* @param keys - The param items can be a string or an `Iterable` of strings.
|
|
165
|
+
* If the param items are an `Iterable`, it will be joined into a single string.
|
|
166
|
+
* Think of an `Iterable` as representing a path.
|
|
167
167
|
*
|
|
168
168
|
* @returns true if one of the keys where deleted otherwise false is returned.
|
|
169
169
|
*/
|
|
170
|
-
removeMany(keys: Iterable<OneOrMore<string>>):
|
|
170
|
+
removeMany(keys: Iterable<OneOrMore<string>>): LazyPromise<boolean>;
|
|
171
171
|
/**
|
|
172
|
-
* The
|
|
172
|
+
* The `clear` method removes all the keys in the cache. If a cache is in a group then only the keys part of the group will be removed.
|
|
173
173
|
*/
|
|
174
174
|
clear(): LazyPromise<void>;
|
|
175
175
|
};
|
|
176
176
|
/**
|
|
177
|
-
* The
|
|
177
|
+
* The `ICache` contract defines a way for as key-value pairs independent of data storage and listening to operation events.
|
|
178
178
|
*
|
|
179
|
-
* IMPORT_PATH:
|
|
179
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
180
180
|
* @group Contracts
|
|
181
181
|
*/
|
|
182
182
|
export type ICache<TType = unknown> = ICacheListenable<TType> & ICacheBase<TType>;
|
|
@@ -5,7 +5,7 @@ import type { IFlexibleSerde, ISerializable } from "../../serde/contracts/_modul
|
|
|
5
5
|
import { type ISerializedError, type OneOrMore } from "../../utilities/_module-exports.js";
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
9
9
|
* @group Errors
|
|
10
10
|
*/
|
|
11
11
|
export declare class CacheError extends Error implements ISerializable<ISerializedError> {
|
|
@@ -15,7 +15,7 @@ export declare class CacheError extends Error implements ISerializable<ISerializ
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
|
-
* IMPORT_PATH:
|
|
18
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
19
19
|
* @group Errors
|
|
20
20
|
*/
|
|
21
21
|
export declare class UnexpectedCacheError extends CacheError implements ISerializable<ISerializedError> {
|
|
@@ -25,7 +25,7 @@ export declare class UnexpectedCacheError extends CacheError implements ISeriali
|
|
|
25
25
|
/**
|
|
26
26
|
* The error is thrown when attempting to increment or decrement a key that is not of number type.
|
|
27
27
|
*
|
|
28
|
-
* IMPORT_PATH:
|
|
28
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
29
29
|
* @group Errors
|
|
30
30
|
*/
|
|
31
31
|
export declare class TypeCacheError extends CacheError implements ISerializable<ISerializedError> {
|
|
@@ -35,7 +35,7 @@ export declare class TypeCacheError extends CacheError implements ISerializable<
|
|
|
35
35
|
/**
|
|
36
36
|
* The error is thrown when a key is not found
|
|
37
37
|
*
|
|
38
|
-
* IMPORT_PATH:
|
|
38
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
39
39
|
* @group Errors
|
|
40
40
|
*/
|
|
41
41
|
export declare class KeyNotFoundCacheError extends CacheError implements ISerializable<ISerializedError> {
|
|
@@ -44,7 +44,7 @@ export declare class KeyNotFoundCacheError extends CacheError implements ISerial
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
*
|
|
47
|
-
* IMPORT_PATH:
|
|
47
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
48
48
|
* @group Errors
|
|
49
49
|
*/
|
|
50
50
|
export declare const CACHE_ERRORS: {
|
|
@@ -54,9 +54,9 @@ export declare const CACHE_ERRORS: {
|
|
|
54
54
|
readonly KeyNotFound: typeof KeyNotFoundCacheError;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* The
|
|
57
|
+
* The `registerCacheErrorsToSerde` function registers all {@link ICache | `ICache`} related errors with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized.
|
|
58
58
|
*
|
|
59
|
-
* IMPORT_PATH:
|
|
59
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
60
60
|
* @group Errors
|
|
61
61
|
*/
|
|
62
62
|
export declare function registerCacheErrorsToSerde(serde: OneOrMore<IFlexibleSerde>): void;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { CORE, resolveOneOrMore, } from "../../utilities/_module-exports.js";
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
|
-
* IMPORT_PATH:
|
|
7
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
8
8
|
* @group Errors
|
|
9
9
|
*/
|
|
10
10
|
export class CacheError extends Error {
|
|
@@ -25,7 +25,7 @@ export class CacheError extends Error {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
28
|
-
* IMPORT_PATH:
|
|
28
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
29
29
|
* @group Errors
|
|
30
30
|
*/
|
|
31
31
|
export class UnexpectedCacheError extends CacheError {
|
|
@@ -40,7 +40,7 @@ export class UnexpectedCacheError extends CacheError {
|
|
|
40
40
|
/**
|
|
41
41
|
* The error is thrown when attempting to increment or decrement a key that is not of number type.
|
|
42
42
|
*
|
|
43
|
-
* IMPORT_PATH:
|
|
43
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
44
44
|
* @group Errors
|
|
45
45
|
*/
|
|
46
46
|
export class TypeCacheError extends CacheError {
|
|
@@ -55,7 +55,7 @@ export class TypeCacheError extends CacheError {
|
|
|
55
55
|
/**
|
|
56
56
|
* The error is thrown when a key is not found
|
|
57
57
|
*
|
|
58
|
-
* IMPORT_PATH:
|
|
58
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
59
59
|
* @group Errors
|
|
60
60
|
*/
|
|
61
61
|
export class KeyNotFoundCacheError extends CacheError {
|
|
@@ -69,7 +69,7 @@ export class KeyNotFoundCacheError extends CacheError {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
*
|
|
72
|
-
* IMPORT_PATH:
|
|
72
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
73
73
|
* @group Errors
|
|
74
74
|
*/
|
|
75
75
|
export const CACHE_ERRORS = {
|
|
@@ -79,9 +79,9 @@ export const CACHE_ERRORS = {
|
|
|
79
79
|
KeyNotFound: KeyNotFoundCacheError,
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* The
|
|
82
|
+
* The `registerCacheErrorsToSerde` function registers all {@link ICache | `ICache`} related errors with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized.
|
|
83
83
|
*
|
|
84
|
-
* IMPORT_PATH:
|
|
84
|
+
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
85
85
|
* @group Errors
|
|
86
86
|
*/
|
|
87
87
|
export function registerCacheErrorsToSerde(serde) {
|