@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
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import type { BaseEvent, EventListenerFn, IEventBusAdapter } from "../../../../event-bus/contracts/_module-exports.js";
|
|
5
5
|
import { EventEmitter } from "node:events";
|
|
6
6
|
/**
|
|
7
|
-
* To utilize the
|
|
7
|
+
* To utilize the `MemoryEventBusAdapter`, you must create instance of it.
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
10
10
|
* @group Adapters
|
|
11
11
|
*/
|
|
12
12
|
export declare class MemoryEventBusAdapter implements IEventBusAdapter {
|
|
@@ -18,7 +18,7 @@ export declare class MemoryEventBusAdapter implements IEventBusAdapter {
|
|
|
18
18
|
*
|
|
19
19
|
* const eventBusAdapter = new MemoryEventBusAdapter();
|
|
20
20
|
* ```
|
|
21
|
-
* You can also provide an
|
|
21
|
+
* You can also provide an {@link EventEmitter | `EventEmitter`} that will be used for storing the data.
|
|
22
22
|
* @example
|
|
23
23
|
* ```ts
|
|
24
24
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { EventEmitter } from "node:events";
|
|
5
5
|
/**
|
|
6
|
-
* To utilize the
|
|
6
|
+
* To utilize the `MemoryEventBusAdapter`, you must create instance of it.
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
9
9
|
* @group Adapters
|
|
10
10
|
*/
|
|
11
11
|
export class MemoryEventBusAdapter {
|
|
@@ -17,7 +17,7 @@ export class MemoryEventBusAdapter {
|
|
|
17
17
|
*
|
|
18
18
|
* const eventBusAdapter = new MemoryEventBusAdapter();
|
|
19
19
|
* ```
|
|
20
|
-
* You can also provide an
|
|
20
|
+
* You can also provide an {@link EventEmitter | `EventEmitter`} that will be used for storing the data.
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
23
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import type { BaseEvent, EventListenerFn } from "../../../../event-bus/contracts/_module-exports.js";
|
|
5
5
|
import type { IEventBusAdapter } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
/**
|
|
7
|
-
* This
|
|
7
|
+
* This `NoOpEventBusAdapter` will do nothing and is used for easily mocking {@link IEventBus | `IEventBus`} for testing.
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
10
10
|
* @group Adapters
|
|
11
11
|
*/
|
|
12
12
|
export declare class NoOpEventBusAdapter implements IEventBusAdapter {
|
package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* This
|
|
5
|
+
* This `NoOpEventBusAdapter` will do nothing and is used for easily mocking {@link IEventBus | `IEventBus`} for testing.
|
|
6
6
|
*
|
|
7
|
-
* IMPORT_PATH:
|
|
7
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
8
8
|
* @group Adapters
|
|
9
9
|
*/
|
|
10
10
|
export class NoOpEventBusAdapter {
|
|
@@ -6,7 +6,7 @@ import type { BaseEvent, EventListenerFn, IEventBusAdapter } from "../../../../e
|
|
|
6
6
|
import type { Redis } from "ioredis";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
10
10
|
* @group Adapters
|
|
11
11
|
*/
|
|
12
12
|
export type RedisPubSubEventBusAdapterSettings = {
|
|
@@ -15,9 +15,9 @@ export type RedisPubSubEventBusAdapterSettings = {
|
|
|
15
15
|
serde: ISerde<string>;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* To utilize the
|
|
18
|
+
* To utilize the `RedisPubSubEventBusAdapter`, you must install the `"ioredis"` package and supply a {@link ISerde | `ISerde<string>`}, with a {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
19
19
|
*
|
|
20
|
-
* IMPORT_PATH:
|
|
20
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
21
21
|
* @group Adapters
|
|
22
22
|
*/
|
|
23
23
|
export declare class RedisPubSubEventBusAdapter implements IEventBusAdapter {
|
|
@@ -7,9 +7,9 @@ import { RedisSerde,
|
|
|
7
7
|
SuperJsonSerdeAdapter, } from "../../../../serde/implementations/adapters/_module-exports.js";
|
|
8
8
|
import { EventEmitter } from "node:events";
|
|
9
9
|
/**
|
|
10
|
-
* To utilize the
|
|
10
|
+
* To utilize the `RedisPubSubEventBusAdapter`, you must install the `"ioredis"` package and supply a {@link ISerde | `ISerde<string>`}, with a {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
11
11
|
*
|
|
12
|
-
* IMPORT_PATH:
|
|
12
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/adapters"`
|
|
13
13
|
* @group Adapters
|
|
14
14
|
*/
|
|
15
15
|
export class RedisPubSubEventBusAdapter {
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
|
-
import type {
|
|
6
|
-
import { type IEventBus, type IEventBusAdapter
|
|
5
|
+
import type { BaseEventMap, EventListener, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
+
import { type IEventBus, type IEventBusAdapter } from "../../../../event-bus/contracts/_module-exports.js";
|
|
7
7
|
import type { KeyPrefixer, Factory, AsyncLazy } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
|
-
* IMPORT_PATH:
|
|
10
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusSettingsBase = {
|
|
14
14
|
keyPrefixer: KeyPrefixer;
|
|
15
15
|
/**
|
|
16
|
-
* You can pass a
|
|
16
|
+
* You can pass a {@link Factory | `Factory`} of {@link LazyPromise| `LazyPromise`} to configure default settings for all {@link LazyPromise| `LazyPromise`} instances used in the `EventBus` class.
|
|
17
17
|
* @default
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { LazyPromise } from "@daiso-tech/core/async";
|
|
@@ -25,19 +25,19 @@ export type EventBusSettingsBase = {
|
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
28
|
-
* IMPORT_PATH:
|
|
28
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
29
29
|
* @group Derivables
|
|
30
30
|
*/
|
|
31
31
|
export type EventBusSettings = EventBusSettingsBase & {
|
|
32
32
|
adapter: IEventBusAdapter;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* `EventBus` class can be derived from any {@link IEventBusAdapter | `IEventBusAdapter`}.
|
|
36
36
|
*
|
|
37
|
-
* IMPORT_PATH:
|
|
37
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
38
38
|
* @group Derivables
|
|
39
39
|
*/
|
|
40
|
-
export declare class EventBus<
|
|
40
|
+
export declare class EventBus<TEventMap extends BaseEventMap> implements IEventBus<TEventMap> {
|
|
41
41
|
private readonly store;
|
|
42
42
|
private readonly adapter;
|
|
43
43
|
private readonly lazyPromiseFactory;
|
|
@@ -57,11 +57,11 @@ export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements
|
|
|
57
57
|
*/
|
|
58
58
|
constructor(settings: EventBusSettings);
|
|
59
59
|
private createLazyPromise;
|
|
60
|
-
addListener<
|
|
61
|
-
removeListener<
|
|
62
|
-
listenOnce<
|
|
63
|
-
asPromise<
|
|
64
|
-
subscribeOnce<
|
|
65
|
-
subscribe<
|
|
66
|
-
dispatch(event:
|
|
60
|
+
addListener<TEventName extends keyof TEventMap>(eventName: TEventName, listener: EventListener<TEventMap[TEventName]>): LazyPromise<void>;
|
|
61
|
+
removeListener<TEventName extends keyof TEventMap>(eventName: TEventName, listener: EventListener<TEventMap[TEventName]>): LazyPromise<void>;
|
|
62
|
+
listenOnce<TEventName extends keyof TEventMap>(eventName: TEventName, listener: EventListener<TEventMap[TEventName]>): LazyPromise<void>;
|
|
63
|
+
asPromise<TEventName extends keyof TEventMap>(eventName: TEventName): LazyPromise<TEventMap[TEventName]>;
|
|
64
|
+
subscribeOnce<TEventName extends keyof TEventMap>(eventName: TEventName, listener: EventListener<TEventMap[TEventName]>): LazyPromise<Unsubscribe>;
|
|
65
|
+
subscribe<TEventName extends keyof TEventMap>(eventName: TEventName, listener: EventListener<TEventMap[TEventName]>): LazyPromise<Unsubscribe>;
|
|
66
|
+
dispatch<TEventName extends keyof TEventMap>(eventName: TEventName, event: TEventMap[TEventName]): LazyPromise<void>;
|
|
67
67
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
5
|
import { UnableToDispatchEventBusError, UnableToRemoveListenerEventBusError, UnableToAddListenerEventBusError, } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
-
import {
|
|
6
|
+
import { resolveFactory, resolveInvokable, } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
import { ListenerStore } from "../../../../event-bus/implementations/derivables/event-bus/listener-store.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* `EventBus` class can be derived from any {@link IEventBusAdapter | `IEventBusAdapter`}.
|
|
10
10
|
*
|
|
11
|
-
* IMPORT_PATH:
|
|
11
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
12
12
|
* @group Derivables
|
|
13
13
|
*/
|
|
14
14
|
export class EventBus {
|
|
@@ -38,38 +38,38 @@ export class EventBus {
|
|
|
38
38
|
createLazyPromise(asyncFn) {
|
|
39
39
|
return this.lazyPromiseFactory(asyncFn);
|
|
40
40
|
}
|
|
41
|
-
addListener(
|
|
41
|
+
addListener(eventName, listener) {
|
|
42
42
|
return this.createLazyPromise(async () => {
|
|
43
|
-
const
|
|
44
|
-
const resolvedListener = this.store.getOrAdd([
|
|
43
|
+
const key = this.keyPrefixer.create(String(eventName));
|
|
44
|
+
const resolvedListener = this.store.getOrAdd([key.prefixed, listener], resolveInvokable(listener));
|
|
45
45
|
try {
|
|
46
|
-
await this.adapter.addListener(
|
|
46
|
+
await this.adapter.addListener(key.prefixed, resolvedListener);
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
|
-
this.store.getAndRemove([
|
|
50
|
-
throw new UnableToAddListenerEventBusError(`A listener with name of "${
|
|
49
|
+
this.store.getAndRemove([key.prefixed, listener]);
|
|
50
|
+
throw new UnableToAddListenerEventBusError(`A listener with name of "${String(eventName)}" could not added for "${String(eventName)}" event`, error);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
removeListener(
|
|
54
|
+
removeListener(eventName, listener) {
|
|
55
55
|
return this.createLazyPromise(async () => {
|
|
56
|
-
const
|
|
56
|
+
const key = this.keyPrefixer.create(String(eventName));
|
|
57
57
|
const resolvedListener = this.store.getAndRemove([
|
|
58
|
-
|
|
58
|
+
key.prefixed,
|
|
59
59
|
listener,
|
|
60
60
|
]);
|
|
61
61
|
if (resolvedListener === null) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
try {
|
|
65
|
-
await this.adapter.removeListener(
|
|
65
|
+
await this.adapter.removeListener(key.prefixed, resolvedListener);
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
|
-
throw new UnableToRemoveListenerEventBusError(`A listener with name of "${
|
|
68
|
+
throw new UnableToRemoveListenerEventBusError(`A listener with name of "${String(eventName)}" could not removed of "${String(eventName)}" event`, error);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
listenOnce(
|
|
72
|
+
listenOnce(eventName, listener) {
|
|
73
73
|
return this.createLazyPromise(async () => {
|
|
74
74
|
const wrappedListener = async (event_) => {
|
|
75
75
|
try {
|
|
@@ -77,54 +77,54 @@ export class EventBus {
|
|
|
77
77
|
await resolvedListener(event_);
|
|
78
78
|
}
|
|
79
79
|
finally {
|
|
80
|
-
await this.removeListener(
|
|
80
|
+
await this.removeListener(eventName, listener);
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
const
|
|
84
|
-
const resolvedListener = this.store.getOrAdd([
|
|
83
|
+
const key = this.keyPrefixer.create(String(eventName));
|
|
84
|
+
const resolvedListener = this.store.getOrAdd([key.prefixed, listener], wrappedListener);
|
|
85
85
|
try {
|
|
86
|
-
await this.adapter.addListener(
|
|
86
|
+
await this.adapter.addListener(key.prefixed, resolvedListener);
|
|
87
87
|
}
|
|
88
88
|
catch (error) {
|
|
89
|
-
this.store.getAndRemove([
|
|
90
|
-
throw new UnableToAddListenerEventBusError(`A listener with name of "${
|
|
89
|
+
this.store.getAndRemove([key.prefixed, listener]);
|
|
90
|
+
throw new UnableToAddListenerEventBusError(`A listener with name of "${String(eventName)}" could not added for "${String(eventName)}" event`, error);
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
asPromise(
|
|
94
|
+
asPromise(eventName) {
|
|
95
95
|
return LazyPromise.fromCallback((resolve, reject) => {
|
|
96
|
-
this.listenOnce(
|
|
96
|
+
this.listenOnce(eventName, resolve).then(() => { }, reject);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
subscribeOnce(
|
|
99
|
+
subscribeOnce(eventName, listener) {
|
|
100
100
|
return this.createLazyPromise(async () => {
|
|
101
|
-
await this.listenOnce(
|
|
101
|
+
await this.listenOnce(eventName, listener);
|
|
102
102
|
const unsubscribe = () => {
|
|
103
103
|
return this.createLazyPromise(async () => {
|
|
104
|
-
await this.removeListener(
|
|
104
|
+
await this.removeListener(eventName, listener);
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
107
|
return unsubscribe;
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
subscribe(
|
|
110
|
+
subscribe(eventName, listener) {
|
|
111
111
|
return this.createLazyPromise(async () => {
|
|
112
|
-
await this.addListener(
|
|
112
|
+
await this.addListener(eventName, listener);
|
|
113
113
|
const unsubscribe = () => {
|
|
114
114
|
return this.createLazyPromise(async () => {
|
|
115
|
-
await this.removeListener(
|
|
115
|
+
await this.removeListener(eventName, listener);
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
118
|
return unsubscribe;
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
dispatch(event) {
|
|
121
|
+
dispatch(eventName, event) {
|
|
122
122
|
return this.createLazyPromise(async () => {
|
|
123
123
|
try {
|
|
124
|
-
await this.adapter.dispatch(this.keyPrefixer.create(
|
|
124
|
+
await this.adapter.dispatch(this.keyPrefixer.create(String(eventName)).prefixed, event);
|
|
125
125
|
}
|
|
126
126
|
catch (error) {
|
|
127
|
-
throw new UnableToDispatchEventBusError(`Events of type "${
|
|
127
|
+
throw new UnableToDispatchEventBusError(`Events of type "${String(eventName)}" could not be dispatched`, error);
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,OAAO,
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,OAAO,EAGH,6BAA6B,EAC7B,mCAAmC,EACnC,gCAAgC,GACnC,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACH,cAAc,EACd,gBAAgB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oEAAoE,CAAC;AA+BnG;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IAGA,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;IAC5B,OAAO,CAAmB;IAC1B,kBAAkB,CAGjC;IACM,WAAW,CAAc;IAEjC;;;;;;;;;;;;OAYG;IACH,YAAY,QAA0B;QAClC,MAAM,EACF,WAAW,EACX,OAAO,EACP,kBAAkB,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,GACjE,GAAG,QAAQ,CAAC;QACb,IAAI,CAAC,kBAAkB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC7D,IAAI,CAAC,OAAO,GAA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BACnD,CAAC,CAAC,CAAC;YACP,CAAC,CAAC;YACF,OAAO,WAAW,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CACJ,SAAqB,EACrB,KAA4B;QAE5B,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE;YACrC,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CACvB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACnD,KAAK,CACR,CAAC;YACN,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACtB,MAAM,IAAI,6BAA6B,CACnC,mBAAmB,MAAM,CAAC,SAAS,CAAC,2BAA2B,EAC/D,KAAK,CACR,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import type { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
|
-
import { type IEventBus, type IEventBusFactory, type
|
|
5
|
+
import { type IEventBus, type IEventBusFactory, type BaseEventMap, type IEventBusAdapter } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
import { type EventBusSettingsBase } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
7
7
|
import type { AsyncLazy, Factory, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
|
-
* IMPORT_PATH:
|
|
10
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, IEventBusAdapter>>;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
|
-
* IMPORT_PATH:
|
|
16
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
17
17
|
* @group Derivables
|
|
18
18
|
*/
|
|
19
19
|
export type EventBusFactorySettings<TAdapters extends string = string> = EventBusSettingsBase & {
|
|
@@ -21,8 +21,9 @@ export type EventBusFactorySettings<TAdapters extends string = string> = EventBu
|
|
|
21
21
|
defaultAdapter?: NoInfer<TAdapters>;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
+
* The `EventBusFactory` class is immutable.
|
|
24
25
|
*
|
|
25
|
-
* IMPORT_PATH:
|
|
26
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
26
27
|
* @group Derivables
|
|
27
28
|
*/
|
|
28
29
|
export declare class EventBusFactory<TAdapters extends string = string> implements IEventBusFactory<TAdapters> {
|
|
@@ -113,18 +114,24 @@ export declare class EventBusFactory<TAdapters extends string = string> implemen
|
|
|
113
114
|
* defaultAdapter: "memory"
|
|
114
115
|
* });
|
|
115
116
|
*
|
|
116
|
-
*
|
|
117
|
+
* type AddEvent = {
|
|
118
|
+
* a: number;
|
|
119
|
+
* b: number;
|
|
120
|
+
* };
|
|
121
|
+
* type EventMap = {
|
|
122
|
+
* add: AddEvent;
|
|
123
|
+
* };
|
|
117
124
|
*
|
|
118
125
|
* // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
|
|
119
126
|
* await eventBusFactory
|
|
120
|
-
* .use()
|
|
121
|
-
* .dispatch(
|
|
127
|
+
* .use<EventMap>()
|
|
128
|
+
* .dispatch("add", { a: 1, b: 2 });
|
|
122
129
|
*
|
|
123
130
|
* // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
|
|
124
131
|
* await eventBusFactory
|
|
125
|
-
* .use("redis")
|
|
126
|
-
* .dispatch(
|
|
132
|
+
* .use<EventMap>("redis")
|
|
133
|
+
* .dispatch("add", { a: 1, b: 2 });
|
|
127
134
|
* ```
|
|
128
135
|
*/
|
|
129
|
-
use<
|
|
136
|
+
use<TEventMap extends BaseEventMap>(adapterName?: TAdapters | undefined): IEventBus<TEventMap>;
|
|
130
137
|
}
|
|
@@ -5,8 +5,9 @@ import {} from "../../../../event-bus/contracts/_module-exports.js";
|
|
|
5
5
|
import { EventBus, } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
6
6
|
import { DefaultAdapterNotDefinedError, UnregisteredAdapterError, } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
/**
|
|
8
|
+
* The `EventBusFactory` class is immutable.
|
|
8
9
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
10
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus"`
|
|
10
11
|
* @group Derivables
|
|
11
12
|
*/
|
|
12
13
|
export class EventBusFactory {
|
|
@@ -109,17 +110,23 @@ export class EventBusFactory {
|
|
|
109
110
|
* defaultAdapter: "memory"
|
|
110
111
|
* });
|
|
111
112
|
*
|
|
112
|
-
*
|
|
113
|
+
* type AddEvent = {
|
|
114
|
+
* a: number;
|
|
115
|
+
* b: number;
|
|
116
|
+
* };
|
|
117
|
+
* type EventMap = {
|
|
118
|
+
* add: AddEvent;
|
|
119
|
+
* };
|
|
113
120
|
*
|
|
114
121
|
* // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
|
|
115
122
|
* await eventBusFactory
|
|
116
|
-
* .use()
|
|
117
|
-
* .dispatch(
|
|
123
|
+
* .use<EventMap>()
|
|
124
|
+
* .dispatch("add", { a: 1, b: 2 });
|
|
118
125
|
*
|
|
119
126
|
* // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
|
|
120
127
|
* await eventBusFactory
|
|
121
|
-
* .use("redis")
|
|
122
|
-
* .dispatch(
|
|
128
|
+
* .use<EventMap>("redis")
|
|
129
|
+
* .dispatch("add", { a: 1, b: 2 });
|
|
123
130
|
* ```
|
|
124
131
|
*/
|
|
125
132
|
use(adapterName = this.settings.defaultAdapter) {
|
package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAKN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAEX,MAAM,6DAA6D,CAAC;AAMrE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC
|
|
1
|
+
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAKN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAEX,MAAM,6DAA6D,CAAC;AAMrE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IA6CH;IA1CrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,YACqB,QAA4C;QAA5C,aAAQ,GAAR,QAAQ,CAAoC;IAC9D,CAAC;IAEJ,cAAc,CAAC,WAAwB;QACnC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW;SACd,CAAC,CAAC;IACP,CAAC;IAED,qBAAqB,CACjB,OAAkD;QAElD,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,kBAAkB,EAAE,OAAO;SAC9B,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4DG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAEjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC;YAChB,OAAO;YACP,GAAG,IAAI,CAAC,QAAQ;SACnB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -4,24 +4,22 @@
|
|
|
4
4
|
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
5
|
import type { IEventBusAdapter } from "../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
import { type Promisable } from "../../../utilities/_module-exports.js";
|
|
7
|
-
import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js";
|
|
8
7
|
/**
|
|
9
8
|
*
|
|
10
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/test-utilities"`
|
|
11
10
|
* @group TestUtilities
|
|
12
11
|
*/
|
|
13
12
|
export type EventBusAdapterTestSuiteSettings = {
|
|
14
13
|
expect: ExpectStatic;
|
|
15
|
-
serde?: IFlexibleSerde;
|
|
16
14
|
test: TestAPI;
|
|
17
15
|
describe: SuiteAPI;
|
|
18
16
|
beforeEach: typeof beforeEach;
|
|
19
17
|
createAdapter: () => Promisable<IEventBusAdapter>;
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
22
|
-
* The
|
|
20
|
+
* The `eventBusAdapterTestSuite` function simplifies the process of testing your custom implementation of {@link IEventBusAdapter | `IEventBusAdapter`} with vitest.
|
|
23
21
|
*
|
|
24
|
-
* IMPORT_PATH:
|
|
22
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/test-utilities"`
|
|
25
23
|
* @group TestUtilities
|
|
26
24
|
*/
|
|
27
25
|
export declare function eventBusAdapterTestSuite(settings: EventBusAdapterTestSuiteSettings): void;
|
|
@@ -2,60 +2,53 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import { describe, } from "vitest";
|
|
5
|
-
import { BaseEvent } from "../../../event-bus/contracts/_module-exports.js";
|
|
6
5
|
import {} from "../../../utilities/_module-exports.js";
|
|
7
6
|
import { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
8
7
|
import { LazyPromise } from "../../../async/_module-exports.js";
|
|
9
|
-
import { Serde } from "../../../serde/implementations/derivables/_module-exports.js";
|
|
10
|
-
import { NoOpSerdeAdapter } from "../../../serde/implementations/adapters/_module-exports.js";
|
|
11
8
|
/**
|
|
12
|
-
* The
|
|
9
|
+
* The `eventBusAdapterTestSuite` function simplifies the process of testing your custom implementation of {@link IEventBusAdapter | `IEventBusAdapter`} with vitest.
|
|
13
10
|
*
|
|
14
|
-
* IMPORT_PATH:
|
|
11
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/test-utilities"`
|
|
15
12
|
* @group TestUtilities
|
|
16
13
|
*/
|
|
17
14
|
export function eventBusAdapterTestSuite(settings) {
|
|
18
|
-
const { expect, test, createAdapter, beforeEach
|
|
15
|
+
const { expect, test, createAdapter, beforeEach } = settings;
|
|
19
16
|
let adapter;
|
|
20
17
|
beforeEach(async () => {
|
|
21
18
|
adapter = await createAdapter();
|
|
22
19
|
});
|
|
23
20
|
const TTL = TimeSpan.fromMilliseconds(50);
|
|
24
|
-
class TestEvent extends BaseEvent {
|
|
25
|
-
}
|
|
26
|
-
serde.registerEvent(TestEvent);
|
|
27
21
|
describe("method: addListener, removeListener, dispatch", () => {
|
|
28
22
|
test("Should be null when listener added and event is not triggered", async () => {
|
|
29
23
|
let result = null;
|
|
30
|
-
await adapter.addListener(
|
|
24
|
+
await adapter.addListener("event", (event) => {
|
|
31
25
|
result = event;
|
|
32
26
|
});
|
|
33
27
|
expect(result).toBeNull();
|
|
34
28
|
});
|
|
35
29
|
test("Should be TestEvent when listener added and event is triggered", async () => {
|
|
36
30
|
let result = null;
|
|
37
|
-
await adapter.addListener(
|
|
31
|
+
await adapter.addListener("event", (event) => {
|
|
38
32
|
result = event;
|
|
39
33
|
});
|
|
40
|
-
const event =
|
|
41
|
-
type:
|
|
42
|
-
}
|
|
43
|
-
await adapter.dispatch(
|
|
34
|
+
const event = {
|
|
35
|
+
type: "event",
|
|
36
|
+
};
|
|
37
|
+
await adapter.dispatch("event", event);
|
|
44
38
|
await LazyPromise.delay(TTL);
|
|
45
39
|
expect(result).toEqual(event);
|
|
46
|
-
expect(result).toBeInstanceOf(TestEvent);
|
|
47
40
|
});
|
|
48
41
|
test("Should be null when listener removed and event is triggered", async () => {
|
|
49
42
|
let result = null;
|
|
50
43
|
const listener = (event) => {
|
|
51
44
|
result = event;
|
|
52
45
|
};
|
|
53
|
-
await adapter.addListener(
|
|
54
|
-
await adapter.removeListener(
|
|
55
|
-
const event =
|
|
56
|
-
type:
|
|
57
|
-
}
|
|
58
|
-
await adapter.dispatch(
|
|
46
|
+
await adapter.addListener("event", listener);
|
|
47
|
+
await adapter.removeListener("event", listener);
|
|
48
|
+
const event = {
|
|
49
|
+
type: "event",
|
|
50
|
+
};
|
|
51
|
+
await adapter.dispatch("event", event);
|
|
59
52
|
await LazyPromise.delay(TTL);
|
|
60
53
|
expect(result).toBeNull();
|
|
61
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-adapter.test-suite.js","sourceRoot":"","sources":["../../../../src/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAKH,QAAQ,GACX,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"event-bus-adapter.test-suite.js","sourceRoot":"","sources":["../../../../src/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAKH,QAAQ,GACX,MA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CAAC,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;YAC3E,IAAI,MAAM,GAAqB,IAAI,CAAC;YACpC,MAAM,QAAQ,GAAG,CAAC,KAAgB,EAAE,EAAE;gBAClC,MAAM,GAAG,KAAK,CAAC;YACnB,CAAC,CAAC;YACF,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC7C,MAAM,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG;gBACV,IAAI,EAAE,OAAO;aAChB,CAAC;YACF,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACvC,MAAM,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -4,24 +4,22 @@
|
|
|
4
4
|
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
5
|
import { type IEventBus } from "../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
import { type Promisable } from "../../../utilities/_module-exports.js";
|
|
7
|
-
import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js";
|
|
8
7
|
/**
|
|
9
8
|
*
|
|
10
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/test-utilities"`
|
|
11
10
|
* @group TestUtilities
|
|
12
11
|
*/
|
|
13
12
|
export type EventBusTestSuiteSettings = {
|
|
14
13
|
expect: ExpectStatic;
|
|
15
|
-
serde?: IFlexibleSerde;
|
|
16
14
|
test: TestAPI;
|
|
17
15
|
describe: SuiteAPI;
|
|
18
16
|
beforeEach: typeof beforeEach;
|
|
19
17
|
createEventBus: () => Promisable<IEventBus>;
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
22
|
-
* The
|
|
20
|
+
* The `eventBusTestSuite` function simplifies the process of testing your custom implementation of {@link IEventBus | `IEventBus`} with vitest.
|
|
23
21
|
*
|
|
24
|
-
* IMPORT_PATH:
|
|
22
|
+
* IMPORT_PATH: `"@daiso-tech/core/event-bus/test-utilities"`
|
|
25
23
|
* @group TestUtilities
|
|
26
24
|
*/
|
|
27
25
|
export declare function eventBusTestSuite(settings: EventBusTestSuiteSettings): void;
|