@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
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { TimeSpan, type Factory, type AsyncLazy } from "../../../../utilities/_module-exports.js";
|
|
5
5
|
import { KeyPrefixer, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import type { IDatabaseLockAdapter,
|
|
6
|
+
import type { IDatabaseLockAdapter, LockEventMap } from "../../../../lock/contracts/_module-exports.js";
|
|
7
7
|
import { type ILock, type LockProviderCreateSettings, type ILockProvider, type ILockAdapter } from "../../../../lock/contracts/_module-exports.js";
|
|
8
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { EventListener, IEventBus, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
10
|
import type { IFlexibleSerde } from "../../../../serde/contracts/_module-exports.js";
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
|
-
* IMPORT_PATH:
|
|
13
|
+
* IMPORT_PATH: `"@daiso-tech/core/lock"`
|
|
14
14
|
* @group Derivables
|
|
15
15
|
*/
|
|
16
16
|
export type LockProviderSettingsBase = {
|
|
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 `LockProvider` class.
|
|
20
20
|
* @default
|
|
21
21
|
* ```ts
|
|
22
22
|
* import { LazyPromise } from "@daiso-tech/core/async";
|
|
@@ -47,9 +47,9 @@ export type LockProviderSettingsBase = {
|
|
|
47
47
|
* })
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
eventBus?: IEventBus
|
|
50
|
+
eventBus?: IEventBus;
|
|
51
51
|
/**
|
|
52
|
-
* You can decide the default ttl value for
|
|
52
|
+
* You can decide the default ttl value for {@link ILock | `ILock`} expiration. If null is passed then no ttl will be used by default.
|
|
53
53
|
* @default
|
|
54
54
|
* ```ts
|
|
55
55
|
* TimeSpan.fromMinutes(5);
|
|
@@ -57,7 +57,7 @@ export type LockProviderSettingsBase = {
|
|
|
57
57
|
*/
|
|
58
58
|
defaultTtl?: TimeSpan | null;
|
|
59
59
|
/**
|
|
60
|
-
* The default refresh time used in the
|
|
60
|
+
* The default refresh time used in the {@link ILock | `ILock`} `acquireBlocking` and `runBlocking` methods.
|
|
61
61
|
* @default
|
|
62
62
|
* ```ts
|
|
63
63
|
* TimeSpan.fromSeconds(1);
|
|
@@ -65,7 +65,7 @@ export type LockProviderSettingsBase = {
|
|
|
65
65
|
*/
|
|
66
66
|
defaultBlockingInterval?: TimeSpan;
|
|
67
67
|
/**
|
|
68
|
-
* The default refresh time used in the
|
|
68
|
+
* The default refresh time used in the {@link ILock | `ILock`} `acquireBlocking` and `runBlocking` methods.
|
|
69
69
|
* @default
|
|
70
70
|
* ```ts
|
|
71
71
|
* TimeSpan.fromMinutes(1);
|
|
@@ -73,7 +73,7 @@ export type LockProviderSettingsBase = {
|
|
|
73
73
|
*/
|
|
74
74
|
defaultBlockingTime?: TimeSpan;
|
|
75
75
|
/**
|
|
76
|
-
* The default refresh time used in the
|
|
76
|
+
* The default refresh time used in the {@link ILock | `ILock`} `referesh` method.
|
|
77
77
|
* ```ts
|
|
78
78
|
* TimeSpan.fromMinutes(5);
|
|
79
79
|
* ```
|
|
@@ -82,26 +82,26 @@ export type LockProviderSettingsBase = {
|
|
|
82
82
|
};
|
|
83
83
|
/**
|
|
84
84
|
*
|
|
85
|
-
* IMPORT_PATH:
|
|
85
|
+
* IMPORT_PATH: `"@daiso-tech/core/lock"`
|
|
86
86
|
* @group Derivables
|
|
87
87
|
*/
|
|
88
88
|
export type LockAdapter = ILockAdapter | IDatabaseLockAdapter;
|
|
89
89
|
/**
|
|
90
90
|
*
|
|
91
|
-
* IMPORT_PATH:
|
|
91
|
+
* IMPORT_PATH: `"@daiso-tech/core/lock"`
|
|
92
92
|
* @group Derivables
|
|
93
93
|
*/
|
|
94
94
|
export type LockProviderSettings = LockProviderSettingsBase & {
|
|
95
95
|
adapter: LockAdapter;
|
|
96
96
|
};
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
98
|
+
* `LockProvider` class can be derived from any {@link ILockAdapter | `ILockAdapter`} or {@link IDatabaseLockAdapter | `IDatabaseLockAdapter`}.
|
|
99
99
|
*
|
|
100
|
-
* Note the
|
|
100
|
+
* Note the {@link ILock | `ILock`} instances created by the `LockProvider` class are serializable and deserializable,
|
|
101
101
|
* allowing them to be seamlessly transferred across different servers, processes, and databases.
|
|
102
|
-
* This can be done directly using
|
|
102
|
+
* This can be done directly using {@link IFlexibleSerde | `IFlexibleSerde`} or indirectly through components that rely on {@link IFlexibleSerde | `IFlexibleSerde`} internally.
|
|
103
103
|
*
|
|
104
|
-
* IMPORT_PATH:
|
|
104
|
+
* IMPORT_PATH: `"@daiso-tech/core/lock"`
|
|
105
105
|
* @group Derivables
|
|
106
106
|
*/
|
|
107
107
|
export declare class LockProvider implements ILockProvider {
|
|
@@ -145,35 +145,35 @@ export declare class LockProvider implements ILockProvider {
|
|
|
145
145
|
constructor(settings: LockProviderSettings);
|
|
146
146
|
private registerToSerde;
|
|
147
147
|
/**
|
|
148
|
-
* You can listen to the following
|
|
149
|
-
* To understand how this method works, refer to
|
|
148
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
149
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
150
150
|
*/
|
|
151
|
-
addListener<
|
|
151
|
+
addListener<TEventName extends keyof LockEventMap>(eventName: TEventName, listener: EventListener<LockEventMap[TEventName]>): LazyPromise<void>;
|
|
152
152
|
/**
|
|
153
|
-
* You can listen to the following
|
|
154
|
-
* To understand how this method works, refer to
|
|
153
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
154
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
155
155
|
*/
|
|
156
|
-
removeListener<
|
|
156
|
+
removeListener<TEventName extends keyof LockEventMap>(eventName: TEventName, listener: EventListener<LockEventMap[TEventName]>): LazyPromise<void>;
|
|
157
157
|
/**
|
|
158
|
-
* You can listen to the following
|
|
159
|
-
* To understand how this method works, refer to
|
|
158
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
159
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
160
160
|
*/
|
|
161
|
-
listenOnce<
|
|
161
|
+
listenOnce<TEventName extends keyof LockEventMap>(eventName: TEventName, listener: EventListener<LockEventMap[TEventName]>): LazyPromise<void>;
|
|
162
162
|
/**
|
|
163
|
-
* You can listen to the following
|
|
164
|
-
* To understand how this method works, refer to
|
|
163
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
164
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
165
165
|
*/
|
|
166
|
-
asPromise<
|
|
166
|
+
asPromise<TEventName extends keyof LockEventMap>(eventName: TEventName): LazyPromise<LockEventMap[TEventName]>;
|
|
167
167
|
/**
|
|
168
|
-
* You can listen to the following
|
|
169
|
-
* To understand how this method works, refer to
|
|
168
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
169
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
170
170
|
*/
|
|
171
|
-
subscribeOnce<
|
|
171
|
+
subscribeOnce<TEventName extends keyof LockEventMap>(eventName: TEventName, listener: EventListener<LockEventMap[TEventName]>): LazyPromise<Unsubscribe>;
|
|
172
172
|
/**
|
|
173
|
-
* You can listen to the following
|
|
174
|
-
* To understand how this method works, refer to
|
|
173
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
174
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
175
175
|
*/
|
|
176
|
-
subscribe<
|
|
176
|
+
subscribe<TEventName extends keyof LockEventMap>(eventName: TEventName, listener: EventListener<LockEventMap[TEventName]>): LazyPromise<Unsubscribe>;
|
|
177
177
|
private createLazyPromise;
|
|
178
178
|
/**
|
|
179
179
|
* @example
|
|
@@ -14,13 +14,13 @@ import { isDatabaseLockAdapter } from "../../../../lock/implementations/derivabl
|
|
|
14
14
|
import { DatabaseLockAdapter } from "../../../../lock/implementations/derivables/lock-provider/database-lock-adapter.js";
|
|
15
15
|
import { LockSerdeTransformer } from "../../../../lock/implementations/derivables/lock-provider/lock-serde-transformer.js";
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* `LockProvider` class can be derived from any {@link ILockAdapter | `ILockAdapter`} or {@link IDatabaseLockAdapter | `IDatabaseLockAdapter`}.
|
|
18
18
|
*
|
|
19
|
-
* Note the
|
|
19
|
+
* Note the {@link ILock | `ILock`} instances created by the `LockProvider` class are serializable and deserializable,
|
|
20
20
|
* allowing them to be seamlessly transferred across different servers, processes, and databases.
|
|
21
|
-
* This can be done directly using
|
|
21
|
+
* This can be done directly using {@link IFlexibleSerde | `IFlexibleSerde`} or indirectly through components that rely on {@link IFlexibleSerde | `IFlexibleSerde`} internally.
|
|
22
22
|
*
|
|
23
|
-
* IMPORT_PATH:
|
|
23
|
+
* IMPORT_PATH: `"@daiso-tech/core/lock"`
|
|
24
24
|
* @group Derivables
|
|
25
25
|
*/
|
|
26
26
|
export class LockProvider {
|
|
@@ -87,7 +87,7 @@ export class LockProvider {
|
|
|
87
87
|
registerToSerde() {
|
|
88
88
|
const transformer = new LockSerdeTransformer({
|
|
89
89
|
adapter: this.adapter,
|
|
90
|
-
createLazyPromise: this.createLazyPromise
|
|
90
|
+
createLazyPromise: (asyncFn) => this.createLazyPromise(asyncFn),
|
|
91
91
|
defaultBlockingInterval: this.defaultBlockingInterval,
|
|
92
92
|
defaultBlockingTime: this.defaultBlockingTime,
|
|
93
93
|
defaultRefreshTime: this.defaultRefreshTime,
|
|
@@ -101,46 +101,46 @@ export class LockProvider {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* You can listen to the following
|
|
105
|
-
* To understand how this method works, refer to
|
|
104
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
105
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
106
106
|
*/
|
|
107
|
-
addListener(
|
|
108
|
-
return this.eventBus.addListener(
|
|
107
|
+
addListener(eventName, listener) {
|
|
108
|
+
return this.eventBus.addListener(eventName, listener);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* You can listen to the following
|
|
112
|
-
* To understand how this method works, refer to
|
|
111
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
112
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
113
113
|
*/
|
|
114
|
-
removeListener(
|
|
115
|
-
return this.eventBus.removeListener(
|
|
114
|
+
removeListener(eventName, listener) {
|
|
115
|
+
return this.eventBus.removeListener(eventName, listener);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* You can listen to the following
|
|
119
|
-
* To understand how this method works, refer to
|
|
118
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
119
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
120
120
|
*/
|
|
121
|
-
listenOnce(
|
|
122
|
-
return this.eventBus.listenOnce(
|
|
121
|
+
listenOnce(eventName, listener) {
|
|
122
|
+
return this.eventBus.listenOnce(eventName, listener);
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* You can listen to the following
|
|
126
|
-
* To understand how this method works, refer to
|
|
125
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
126
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
127
127
|
*/
|
|
128
|
-
asPromise(
|
|
129
|
-
return this.eventBus.asPromise(
|
|
128
|
+
asPromise(eventName) {
|
|
129
|
+
return this.eventBus.asPromise(eventName);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* You can listen to the following
|
|
133
|
-
* To understand how this method works, refer to
|
|
132
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
133
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
134
134
|
*/
|
|
135
|
-
subscribeOnce(
|
|
136
|
-
return this.eventBus.subscribeOnce(
|
|
135
|
+
subscribeOnce(eventName, listener) {
|
|
136
|
+
return this.eventBus.subscribeOnce(eventName, listener);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
|
-
* You can listen to the following
|
|
140
|
-
* To understand how this method works, refer to
|
|
139
|
+
* You can listen to the following {@link LockEvents | `LockEvents`} of all {@link ILock | `ILock`} instances created by the {@link ILockProvider | `ILockProvider`}.
|
|
140
|
+
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
141
141
|
*/
|
|
142
|
-
subscribe(
|
|
143
|
-
return this.eventBus.subscribe(
|
|
142
|
+
subscribe(eventName, listener) {
|
|
143
|
+
return this.eventBus.subscribe(eventName, listener);
|
|
144
144
|
}
|
|
145
145
|
createLazyPromise(asyncFn) {
|
|
146
146
|
return new LazyPromise(asyncFn);
|
|
@@ -168,7 +168,7 @@ export class LockProvider {
|
|
|
168
168
|
const keyObj = this.keyPrefixer.create(key);
|
|
169
169
|
return new Lock({
|
|
170
170
|
adapter: this.adapter,
|
|
171
|
-
createLazyPromise: this.createLazyPromise
|
|
171
|
+
createLazyPromise: (asyncFn) => this.createLazyPromise(asyncFn),
|
|
172
172
|
lockState: new LockState(this.lockStore, keyObj.prefixed),
|
|
173
173
|
eventDispatcher: this.eventBus,
|
|
174
174
|
key: keyObj,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-provider.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,QAAQ,EACR,IAAI,EAIJ,cAAc,EACd,gBAAgB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAkB,MAAM,gCAAgC,CAAC;AAK7E,OAAO,EAKN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"lock-provider.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,QAAQ,EACR,IAAI,EAIJ,cAAc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AS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;IAEO,iBAAiB,CACrB,OAAkC;QAElC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CACF,GAAsB,EACtB,WAAuC,EAAE;QAEzC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,GACzD,QAAQ,CAAC;QAEb,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAE5C,OAAO,IAAI,IAAI,CAAC;YACZ,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAC/D,SAAS,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC;YACzD,eAAe,EAAE,IAAI,CAAC,QAAQ;YAC9B,GAAG,EAAE,MAAM;YACX,KAAK;YACL,GAAG;YACH,cAAc,EAAE,IAAI;YACpB,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC9C,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { ISerdeTransformer } from "../../../../serde/contracts/_module-exports.js";
|
|
5
5
|
import { Lock, type ISerializedLock } from "../../../../lock/implementations/derivables/lock-provider/lock.js";
|
|
6
6
|
import type { OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
7
|
-
import type { ILockAdapter,
|
|
7
|
+
import type { ILockAdapter, LockEventMap } from "../../../../lock/contracts/_module-exports.js";
|
|
8
8
|
import { type ILockStore } from "../../../../lock/implementations/derivables/lock-provider/lock-state.js";
|
|
9
9
|
import { TimeSpan, type KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
10
10
|
import type { LazyPromise } from "../../../../async/_module-exports.js";
|
|
@@ -20,7 +20,7 @@ export type LockSerdeTransformerSettings = {
|
|
|
20
20
|
defaultBlockingInterval: TimeSpan;
|
|
21
21
|
defaultBlockingTime: TimeSpan;
|
|
22
22
|
defaultRefreshTime: TimeSpan;
|
|
23
|
-
eventBus: IEventBus<
|
|
23
|
+
eventBus: IEventBus<LockEventMap>;
|
|
24
24
|
serdeTransformerName: string;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-serde-transformer.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-serde-transformer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACH,IAAI,GAEP,MAAM,yDAAyD,CAAC;AAMjE,OAAO,EACH,SAAS,GAEZ,MAAM,+DAA+D,CAAC;AACvE,OAAO,EACH,kBAAkB,EAClB,QAAQ,GAEX,MAAM,gCAAgC,CAAC;AAqBxC;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAGZ,OAAO,CAAe;IACtB,SAAS,CAAa;IACtB,WAAW,CAAc;IACzB,iBAAiB,CAET;IACR,uBAAuB,CAAW;IAClC,mBAAmB,CAAW;IAC9B,kBAAkB,CAAW;IAC7B,QAAQ,
|
|
1
|
+
{"version":3,"file":"lock-serde-transformer.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-serde-transformer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACH,IAAI,GAEP,MAAM,yDAAyD,CAAC;AAMjE,OAAO,EACH,SAAS,GAEZ,MAAM,+DAA+D,CAAC;AACvE,OAAO,EACH,kBAAkB,EAClB,QAAQ,GAEX,MAAM,gCAAgC,CAAC;AAqBxC;;GAEG;AACH,MAAM,OAAO,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QAE5C,OAAO,IAAI,IAAI,CAAC;YACZ,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC;YACzD,eAAe,EAAE,IAAI,CAAC,QAAQ;YAC9B,GAAG,EAAE,MAAM;YACX,KAAK;YACL,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;YACxD,cAAc;YACd,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC9C,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAC,iBAAuB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC7C,CAAC;CACJ"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
5
5
|
import { type Key, type AsyncLazy, type OneOrMore, type Result } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import { KeyAlreadyAcquiredLockError, type AquireBlockingSettings, type
|
|
6
|
+
import { KeyAlreadyAcquiredLockError, type AquireBlockingSettings, type LockEventMap } from "../../../../lock/contracts/_module-exports.js";
|
|
7
7
|
import { type ILock, type ILockAdapter } from "../../../../lock/contracts/_module-exports.js";
|
|
8
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
9
9
|
import type { IEventDispatcher } from "../../../../event-bus/contracts/_module-exports.js";
|
|
@@ -24,7 +24,7 @@ export type LockSettings = {
|
|
|
24
24
|
createLazyPromise: <TValue = void>(asyncFn: () => PromiseLike<TValue>) => LazyPromise<TValue>;
|
|
25
25
|
adapter: ILockAdapter;
|
|
26
26
|
lockState: LockState;
|
|
27
|
-
eventDispatcher: IEventDispatcher<
|
|
27
|
+
eventDispatcher: IEventDispatcher<LockEventMap>;
|
|
28
28
|
key: Key;
|
|
29
29
|
owner: OneOrMore<string>;
|
|
30
30
|
ttl: TimeSpan | null;
|
|
@@ -34,7 +34,7 @@ export type LockSettings = {
|
|
|
34
34
|
defaultRefreshTime: TimeSpan;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* IMPORTANT: This class is not intended to be instantiated directly, instead it should be created by the
|
|
37
|
+
* IMPORTANT: This class is not intended to be instantiated directly, instead it should be created by the `LockProvider` class instance.
|
|
38
38
|
* @group Derivables
|
|
39
39
|
*/
|
|
40
40
|
export declare class Lock implements ILock {
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { resolveLazyable, } from "../../../../utilities/_module-exports.js";
|
|
5
5
|
import { resolveOneOrMoreStr } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import {
|
|
6
|
+
import { KeyAlreadyAcquiredLockError, LOCK_EVENTS, UnableToAquireLockError, UnableToReleaseLockError, UnownedRefreshLockError, UnownedReleaseLockError, } from "../../../../lock/contracts/_module-exports.js";
|
|
7
7
|
import {} from "../../../../lock/contracts/_module-exports.js";
|
|
8
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
9
9
|
/**
|
|
10
|
-
* IMPORTANT: This class is not intended to be instantiated directly, instead it should be created by the
|
|
10
|
+
* IMPORTANT: This class is not intended to be instantiated directly, instead it should be created by the `LockProvider` class instance.
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
13
|
export class Lock {
|
|
@@ -64,7 +64,7 @@ export class Lock {
|
|
|
64
64
|
finally {
|
|
65
65
|
await this.release();
|
|
66
66
|
}
|
|
67
|
-
})
|
|
67
|
+
});
|
|
68
68
|
}
|
|
69
69
|
runOrFail(asyncFn) {
|
|
70
70
|
return this.createLazyPromise(async () => {
|
|
@@ -75,8 +75,7 @@ export class Lock {
|
|
|
75
75
|
finally {
|
|
76
76
|
await this.release();
|
|
77
77
|
}
|
|
78
|
-
})
|
|
79
|
-
error instanceof KeyAlreadyAcquiredLockError);
|
|
78
|
+
});
|
|
80
79
|
}
|
|
81
80
|
runBlocking(asyncFn, settings) {
|
|
82
81
|
return this.createLazyPromise(async () => {
|
|
@@ -93,7 +92,7 @@ export class Lock {
|
|
|
93
92
|
finally {
|
|
94
93
|
await this.release();
|
|
95
94
|
}
|
|
96
|
-
})
|
|
95
|
+
});
|
|
97
96
|
}
|
|
98
97
|
runBlockingOrFail(asyncFn, settings) {
|
|
99
98
|
return new LazyPromise(async () => {
|
|
@@ -104,43 +103,48 @@ export class Lock {
|
|
|
104
103
|
finally {
|
|
105
104
|
await this.release();
|
|
106
105
|
}
|
|
107
|
-
})
|
|
106
|
+
});
|
|
108
107
|
}
|
|
109
108
|
acquire() {
|
|
110
109
|
return this.createLazyPromise(async () => {
|
|
110
|
+
const prevState = this.lockState.get()?.getTime() ?? null;
|
|
111
111
|
try {
|
|
112
112
|
this.lockState.remove();
|
|
113
113
|
const hasAquired = await this.adapter.acquire(this.key.prefixed, this.owner, this.ttl);
|
|
114
114
|
if (hasAquired) {
|
|
115
115
|
this.lockState.set(this.ttl);
|
|
116
|
-
const event =
|
|
116
|
+
const event = {
|
|
117
117
|
key: this.key.resolved,
|
|
118
118
|
owner: this.owner,
|
|
119
119
|
ttl: this.ttl,
|
|
120
|
-
}
|
|
121
|
-
this.eventDispatcher
|
|
122
|
-
|
|
120
|
+
};
|
|
121
|
+
this.eventDispatcher
|
|
122
|
+
.dispatch(LOCK_EVENTS.ACQUIRED, event)
|
|
123
|
+
.defer();
|
|
123
124
|
}
|
|
124
125
|
else {
|
|
125
|
-
const event =
|
|
126
|
+
const event = {
|
|
126
127
|
key: this.key.resolved,
|
|
127
128
|
owner: this.owner,
|
|
128
|
-
}
|
|
129
|
-
this.eventDispatcher
|
|
130
|
-
|
|
129
|
+
};
|
|
130
|
+
this.eventDispatcher
|
|
131
|
+
.dispatch(LOCK_EVENTS.NOT_AVAILABLE, event)
|
|
132
|
+
.defer();
|
|
131
133
|
}
|
|
132
134
|
return hasAquired;
|
|
133
135
|
}
|
|
134
136
|
catch (error) {
|
|
135
|
-
|
|
137
|
+
this.lockState.set(prevState);
|
|
138
|
+
const event = {
|
|
136
139
|
key: this.key.resolved,
|
|
137
140
|
owner: this.owner,
|
|
138
141
|
ttl: this.ttl,
|
|
139
142
|
error,
|
|
140
|
-
}
|
|
141
|
-
this.eventDispatcher
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
};
|
|
144
|
+
this.eventDispatcher
|
|
145
|
+
.dispatch(LOCK_EVENTS.UNEXPECTED_ERROR, event)
|
|
146
|
+
.defer();
|
|
147
|
+
throw new UnableToAquireLockError(`A Lock with name of "${this.key.resolved}" could not be acquired.`, error);
|
|
144
148
|
}
|
|
145
149
|
});
|
|
146
150
|
}
|
|
@@ -176,37 +180,42 @@ export class Lock {
|
|
|
176
180
|
}
|
|
177
181
|
release() {
|
|
178
182
|
return this.createLazyPromise(async () => {
|
|
183
|
+
const prevState = this.lockState.get()?.getTime() ?? null;
|
|
179
184
|
try {
|
|
180
185
|
const hasReleased = await this.adapter.release(this.key.prefixed, this.owner);
|
|
181
186
|
if (hasReleased) {
|
|
182
187
|
this.lockState.remove();
|
|
183
|
-
const event =
|
|
188
|
+
const event = {
|
|
184
189
|
key: this.key.resolved,
|
|
185
190
|
owner: this.owner,
|
|
186
|
-
}
|
|
187
|
-
this.eventDispatcher
|
|
188
|
-
|
|
191
|
+
};
|
|
192
|
+
this.eventDispatcher
|
|
193
|
+
.dispatch(LOCK_EVENTS.RELEASED, event)
|
|
194
|
+
.defer();
|
|
189
195
|
}
|
|
190
196
|
else {
|
|
191
|
-
const event =
|
|
197
|
+
const event = {
|
|
192
198
|
key: this.key.resolved,
|
|
193
199
|
owner: this.owner,
|
|
194
|
-
}
|
|
195
|
-
this.eventDispatcher
|
|
196
|
-
|
|
200
|
+
};
|
|
201
|
+
this.eventDispatcher
|
|
202
|
+
.dispatch(LOCK_EVENTS.UNOWNED_RELEASE_TRY, event)
|
|
203
|
+
.defer();
|
|
197
204
|
}
|
|
198
205
|
return hasReleased;
|
|
199
206
|
}
|
|
200
207
|
catch (error) {
|
|
201
|
-
|
|
208
|
+
this.lockState.set(prevState);
|
|
209
|
+
const event = {
|
|
202
210
|
key: this.key.resolved,
|
|
203
211
|
owner: this.owner,
|
|
204
212
|
ttl: this.ttl,
|
|
205
213
|
error,
|
|
206
|
-
}
|
|
207
|
-
this.eventDispatcher
|
|
208
|
-
|
|
209
|
-
|
|
214
|
+
};
|
|
215
|
+
this.eventDispatcher
|
|
216
|
+
.dispatch(LOCK_EVENTS.UNEXPECTED_ERROR, event)
|
|
217
|
+
.defer();
|
|
218
|
+
throw new UnableToReleaseLockError(`A Lock with name of "${this.key.resolved}" could not be released.`, error);
|
|
210
219
|
}
|
|
211
220
|
});
|
|
212
221
|
}
|
|
@@ -220,25 +229,29 @@ export class Lock {
|
|
|
220
229
|
}
|
|
221
230
|
forceRelease() {
|
|
222
231
|
return this.createLazyPromise(async () => {
|
|
232
|
+
const prevState = this.lockState.get()?.getTime() ?? null;
|
|
223
233
|
try {
|
|
224
234
|
await this.adapter.forceRelease(this.key.prefixed);
|
|
225
235
|
this.lockState.remove();
|
|
226
|
-
const event =
|
|
236
|
+
const event = {
|
|
227
237
|
key: this.key.resolved,
|
|
228
|
-
}
|
|
229
|
-
this.eventDispatcher
|
|
230
|
-
|
|
238
|
+
};
|
|
239
|
+
this.eventDispatcher
|
|
240
|
+
.dispatch(LOCK_EVENTS.FORCE_RELEASED, event)
|
|
241
|
+
.defer();
|
|
231
242
|
}
|
|
232
243
|
catch (error) {
|
|
233
|
-
|
|
244
|
+
this.lockState.set(prevState);
|
|
245
|
+
const event = {
|
|
234
246
|
key: this.key.resolved,
|
|
235
247
|
owner: this.owner,
|
|
236
248
|
ttl: this.ttl,
|
|
237
249
|
error,
|
|
238
|
-
}
|
|
239
|
-
this.eventDispatcher
|
|
240
|
-
|
|
241
|
-
|
|
250
|
+
};
|
|
251
|
+
this.eventDispatcher
|
|
252
|
+
.dispatch(LOCK_EVENTS.UNEXPECTED_ERROR, event)
|
|
253
|
+
.defer();
|
|
254
|
+
throw new UnableToReleaseLockError(`A Lock with name of "${this.key.resolved}" could not be released.`, error);
|
|
242
255
|
}
|
|
243
256
|
});
|
|
244
257
|
}
|
|
@@ -249,14 +262,15 @@ export class Lock {
|
|
|
249
262
|
return this.lockState.isExpired();
|
|
250
263
|
}
|
|
251
264
|
catch (error) {
|
|
252
|
-
const event =
|
|
265
|
+
const event = {
|
|
253
266
|
key: this.key.resolved,
|
|
254
267
|
owner: this.owner,
|
|
255
268
|
ttl: this.ttl,
|
|
256
269
|
error,
|
|
257
|
-
}
|
|
258
|
-
this.eventDispatcher
|
|
259
|
-
|
|
270
|
+
};
|
|
271
|
+
this.eventDispatcher
|
|
272
|
+
.dispatch(LOCK_EVENTS.UNEXPECTED_ERROR, event)
|
|
273
|
+
.defer();
|
|
260
274
|
throw error;
|
|
261
275
|
}
|
|
262
276
|
});
|
|
@@ -269,37 +283,42 @@ export class Lock {
|
|
|
269
283
|
}
|
|
270
284
|
refresh(ttl = this.defaultRefreshTime) {
|
|
271
285
|
return this.createLazyPromise(async () => {
|
|
286
|
+
const prevState = this.lockState.get()?.getTime() ?? null;
|
|
272
287
|
try {
|
|
273
288
|
const hasRefreshed = await this.adapter.refresh(this.key.prefixed, this.owner, ttl);
|
|
274
289
|
if (hasRefreshed) {
|
|
275
|
-
const event =
|
|
290
|
+
const event = {
|
|
276
291
|
key: this.key.resolved,
|
|
277
292
|
owner: this.owner,
|
|
278
293
|
ttl,
|
|
279
|
-
}
|
|
294
|
+
};
|
|
280
295
|
this.lockState.set(ttl);
|
|
281
|
-
this.eventDispatcher
|
|
282
|
-
|
|
296
|
+
this.eventDispatcher
|
|
297
|
+
.dispatch(LOCK_EVENTS.REFRESHED, event)
|
|
298
|
+
.defer();
|
|
283
299
|
}
|
|
284
300
|
else {
|
|
285
|
-
const event =
|
|
301
|
+
const event = {
|
|
286
302
|
key: this.key.resolved,
|
|
287
303
|
owner: this.owner,
|
|
288
|
-
}
|
|
289
|
-
this.eventDispatcher
|
|
290
|
-
|
|
304
|
+
};
|
|
305
|
+
this.eventDispatcher
|
|
306
|
+
.dispatch(LOCK_EVENTS.UNOWNED_REFRESH_TRY, event)
|
|
307
|
+
.defer();
|
|
291
308
|
}
|
|
292
309
|
return hasRefreshed;
|
|
293
310
|
}
|
|
294
311
|
catch (error) {
|
|
295
|
-
|
|
312
|
+
this.lockState.set(prevState);
|
|
313
|
+
const event = {
|
|
296
314
|
key: this.key.resolved,
|
|
297
315
|
owner: this.owner,
|
|
298
316
|
ttl: this.ttl,
|
|
299
317
|
error,
|
|
300
|
-
}
|
|
301
|
-
this.eventDispatcher
|
|
302
|
-
|
|
318
|
+
};
|
|
319
|
+
this.eventDispatcher
|
|
320
|
+
.dispatch(LOCK_EVENTS.UNEXPECTED_ERROR, event)
|
|
321
|
+
.defer();
|
|
303
322
|
throw error;
|
|
304
323
|
}
|
|
305
324
|
});
|