@daiso-tech/core 0.21.0 → 0.22.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/dist/cjs/_module.js +2 -0
- package/dist/cjs/_module.js.map +1 -1
- package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js +16 -9
- package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cjs/cache/contracts/cache.events.js +13 -139
- package/dist/cjs/cache/contracts/cache.events.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js +5 -24
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js +729 -21
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +1 -21
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js +0 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -7
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js +0 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +3 -11
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js +0 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +6 -28
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -3
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js +0 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +5 -13
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js +0 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -7
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache/_module.js +0 -1
- package/dist/cjs/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache/cache.js +215 -103
- package/dist/cjs/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory/_module.js +0 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory.js +0 -4
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_shared.js +3 -2
- package/dist/cjs/event-bus/contracts/_shared.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +4 -15
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js +6 -27
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +0 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +0 -4
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js +0 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +0 -4
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/_module.js +0 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus.js +0 -4
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/_module.js +0 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +0 -4
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/cjs/lock/contracts/_module.js +24 -0
- package/dist/cjs/lock/contracts/_module.js.map +1 -0
- package/dist/cjs/lock/contracts/database-lock-adapter.contract.js +3 -0
- package/dist/cjs/lock/contracts/database-lock-adapter.contract.js.map +1 -0
- package/dist/cjs/lock/contracts/lock-adapter.contract.js +3 -0
- package/dist/cjs/lock/contracts/lock-adapter.contract.js.map +1 -0
- package/dist/cjs/lock/contracts/lock-provider-factory.contract.js +3 -0
- package/dist/cjs/lock/contracts/lock-provider-factory.contract.js.map +1 -0
- package/dist/cjs/lock/contracts/lock-provider.contract.js +3 -0
- package/dist/cjs/lock/contracts/lock-provider.contract.js.map +1 -0
- package/dist/cjs/lock/contracts/lock.contract.js +3 -0
- package/dist/cjs/lock/contracts/lock.contract.js.map +1 -0
- package/dist/cjs/lock/contracts/lock.errors.js +131 -0
- package/dist/cjs/lock/contracts/lock.errors.js.map +1 -0
- package/dist/cjs/lock/contracts/lock.events.js +44 -0
- package/dist/cjs/lock/contracts/lock.events.js.map +1 -0
- package/dist/cjs/lock/implementations/_module.js +20 -0
- package/dist/cjs/lock/implementations/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/_shared/_module.js +20 -0
- package/dist/cjs/lock/implementations/_shared/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/_shared/database-lock-adapter.test-suite.js +285 -0
- package/dist/cjs/lock/implementations/_shared/database-lock-adapter.test-suite.js.map +1 -0
- package/dist/cjs/lock/implementations/_shared/lock-adapter.test-suite.js +238 -0
- package/dist/cjs/lock/implementations/_shared/lock-adapter.test-suite.js.map +1 -0
- package/dist/cjs/lock/implementations/_shared/lock-provider.test-suite.js +1841 -0
- package/dist/cjs/lock/implementations/_shared/lock-provider.test-suite.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/_module.js +22 -0
- package/dist/cjs/lock/implementations/adapters/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/kysely-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/kysely-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +126 -0
- package/dist/cjs/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/libsql-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/libsql-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +61 -0
- package/dist/cjs/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/memory-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/memory-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +107 -0
- package/dist/cjs/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/mongodb-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/mongodb-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +148 -0
- package/dist/cjs/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/redis-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/redis-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +131 -0
- package/dist/cjs/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/sqlite-lock-adapter/_module.js +18 -0
- package/dist/cjs/lock/implementations/adapters/sqlite-lock-adapter/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +60 -0
- package/dist/cjs/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/_module.js +19 -0
- package/dist/cjs/lock/implementations/derivables/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/_module.js +18 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/database-lock-adapter.js +80 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/lock-provider.js +162 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/lock.js +306 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider/lock.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider-factory/_module.js +18 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider-factory/_module.js.map +1 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +78 -0
- package/dist/cjs/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -0
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js +3 -0
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js.map +1 -1
- package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js +15 -0
- package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
- package/dist/cjs/utilities/contracts/_module.js +1 -0
- package/dist/cjs/utilities/contracts/_module.js.map +1 -1
- package/dist/cjs/utilities/contracts/serde-registrable.contract.js +3 -0
- package/dist/cjs/utilities/contracts/serde-registrable.contract.js.map +1 -0
- package/dist/cjs/utilities/functions.js +4 -0
- package/dist/cjs/utilities/functions.js.map +1 -1
- package/dist/esm/_module.js +2 -0
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js +16 -9
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/esm/cache/contracts/cache.events.js +11 -138
- package/dist/esm/cache/contracts/cache.events.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js +5 -24
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js +731 -23
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +1 -21
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js +0 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -7
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js +0 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +3 -11
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js +0 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +6 -28
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -3
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js +0 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +5 -13
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js +0 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -7
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache/_module.js +0 -1
- package/dist/esm/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache/cache.js +216 -104
- package/dist/esm/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache-factory/_module.js +0 -1
- package/dist/esm/cache/implementations/derivables/cache-factory/_module.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory.js +0 -4
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/esm/event-bus/contracts/_shared.js +3 -2
- package/dist/esm/event-bus/contracts/_shared.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +4 -15
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js +7 -28
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +0 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +0 -4
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js +0 -1
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +0 -4
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/_module.js +0 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus.js +0 -4
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/_module.js +0 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +0 -4
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/esm/lock/contracts/_module.js +8 -0
- package/dist/esm/lock/contracts/_module.js.map +1 -0
- package/dist/esm/lock/contracts/database-lock-adapter.contract.js +1 -0
- package/dist/esm/lock/contracts/database-lock-adapter.contract.js.map +1 -0
- package/dist/esm/lock/contracts/lock-adapter.contract.js +1 -0
- package/dist/esm/lock/contracts/lock-adapter.contract.js.map +1 -0
- package/dist/esm/lock/contracts/lock-provider-factory.contract.js +1 -0
- package/dist/esm/lock/contracts/lock-provider-factory.contract.js.map +1 -0
- package/dist/esm/lock/contracts/lock-provider.contract.js +1 -0
- package/dist/esm/lock/contracts/lock-provider.contract.js.map +1 -0
- package/dist/esm/lock/contracts/lock.contract.js +1 -0
- package/dist/esm/lock/contracts/lock.contract.js.map +1 -0
- package/dist/esm/lock/contracts/lock.errors.js +120 -0
- package/dist/esm/lock/contracts/lock.errors.js.map +1 -0
- package/dist/esm/lock/contracts/lock.events.js +32 -0
- package/dist/esm/lock/contracts/lock.events.js.map +1 -0
- package/dist/esm/lock/implementations/_module.js +4 -0
- package/dist/esm/lock/implementations/_module.js.map +1 -0
- package/dist/esm/lock/implementations/_shared/_module.js +4 -0
- package/dist/esm/lock/implementations/_shared/_module.js.map +1 -0
- package/dist/esm/lock/implementations/_shared/database-lock-adapter.test-suite.js +282 -0
- package/dist/esm/lock/implementations/_shared/database-lock-adapter.test-suite.js.map +1 -0
- package/dist/esm/lock/implementations/_shared/lock-adapter.test-suite.js +235 -0
- package/dist/esm/lock/implementations/_shared/lock-adapter.test-suite.js.map +1 -0
- package/dist/esm/lock/implementations/_shared/lock-provider.test-suite.js +1838 -0
- package/dist/esm/lock/implementations/_shared/lock-provider.test-suite.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/_module.js +6 -0
- package/dist/esm/lock/implementations/adapters/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/kysely-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/kysely-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +122 -0
- package/dist/esm/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/libsql-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/libsql-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +57 -0
- package/dist/esm/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/memory-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/memory-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +103 -0
- package/dist/esm/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/mongodb-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/mongodb-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +144 -0
- package/dist/esm/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/redis-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/redis-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +127 -0
- package/dist/esm/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/sqlite-lock-adapter/_module.js +2 -0
- package/dist/esm/lock/implementations/adapters/sqlite-lock-adapter/_module.js.map +1 -0
- package/dist/esm/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +56 -0
- package/dist/esm/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/_module.js +3 -0
- package/dist/esm/lock/implementations/derivables/_module.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/_module.js +2 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/_module.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/database-lock-adapter.js +76 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/lock-provider.js +158 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/lock.js +302 -0
- package/dist/esm/lock/implementations/derivables/lock-provider/lock.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider-factory/_module.js +2 -0
- package/dist/esm/lock/implementations/derivables/lock-provider-factory/_module.js.map +1 -0
- package/dist/esm/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +74 -0
- package/dist/esm/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -0
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js +3 -0
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js.map +1 -1
- package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js +15 -0
- package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
- package/dist/esm/utilities/contracts/_module.js +1 -0
- package/dist/esm/utilities/contracts/_module.js.map +1 -1
- package/dist/esm/utilities/contracts/serde-registrable.contract.js +1 -0
- package/dist/esm/utilities/contracts/serde-registrable.contract.js.map +1 -0
- package/dist/esm/utilities/functions.js +4 -0
- package/dist/esm/utilities/functions.js.map +1 -1
- package/dist/types/_module.d.ts +2 -0
- package/dist/types/async/utilities/lazy-promise/lazy-promise.d.ts +2 -2
- package/dist/types/cache/contracts/cache-adapter.contract.d.ts +2 -6
- package/dist/types/cache/contracts/cache-factory.contract.d.ts +1 -2
- package/dist/types/cache/contracts/cache.contract.d.ts +116 -8
- package/dist/types/cache/contracts/cache.events.d.ts +24 -90
- package/dist/types/cache/implementations/_shared/cache-adapter.test-suite.d.ts +2 -9
- package/dist/types/cache/implementations/_shared/cache.test-suite.d.ts +5 -15
- package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +23 -30
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/_module.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +8 -19
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/_module.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +16 -27
- package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/_module.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +12 -23
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +23 -30
- package/dist/types/cache/implementations/derivables/cache/_module.d.ts +0 -1
- package/dist/types/cache/implementations/derivables/cache/cache.d.ts +38 -27
- package/dist/types/cache/implementations/derivables/cache-factory/_module.d.ts +0 -1
- package/dist/types/cache/implementations/derivables/cache-factory/cache-factory.d.ts +60 -26
- package/dist/types/collection/contracts/async-collection.contract.d.ts +68 -8
- package/dist/types/event-bus/contracts/_shared.d.ts +3 -4
- package/dist/types/event-bus/contracts/event-bus-adapter.contract.d.ts +1 -1
- package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +5 -24
- package/dist/types/event-bus/implementations/_shared/event-bus-adapter.test-suite.d.ts +2 -10
- package/dist/types/event-bus/implementations/_shared/event-bus.test-suite.d.ts +3 -13
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +8 -18
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +11 -20
- package/dist/types/event-bus/implementations/derivables/event-bus/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/derivables/event-bus/event-bus.d.ts +29 -20
- package/dist/types/event-bus/implementations/derivables/event-bus-factory/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +49 -46
- package/dist/types/lock/contracts/_module.d.ts +7 -0
- package/dist/types/lock/contracts/database-lock-adapter.contract.d.ts +49 -0
- package/dist/types/lock/contracts/lock-adapter.contract.d.ts +48 -0
- package/dist/types/lock/contracts/lock-provider-factory.contract.d.ts +36 -0
- package/dist/types/lock/contracts/lock-provider.contract.d.ts +92 -0
- package/dist/types/lock/contracts/lock.contract.d.ts +219 -0
- package/dist/types/lock/contracts/lock.errors.d.ts +66 -0
- package/dist/types/lock/contracts/lock.events.d.ts +83 -0
- package/dist/types/lock/implementations/_module.d.ts +3 -0
- package/dist/types/lock/implementations/_shared/_module.d.ts +3 -0
- package/dist/types/lock/implementations/_shared/database-lock-adapter.test-suite.d.ts +21 -0
- package/dist/types/lock/implementations/_shared/lock-adapter.test-suite.d.ts +21 -0
- package/dist/types/lock/implementations/_shared/lock-provider.test-suite.d.ts +23 -0
- package/dist/types/lock/implementations/adapters/_module.d.ts +5 -0
- package/dist/types/lock/implementations/adapters/kysely-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +52 -0
- package/dist/types/lock/implementations/adapters/libsql-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +58 -0
- package/dist/types/lock/implementations/adapters/memory-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +52 -0
- package/dist/types/lock/implementations/adapters/mongodb-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +60 -0
- package/dist/types/lock/implementations/adapters/redis-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +57 -0
- package/dist/types/lock/implementations/adapters/sqlite-lock-adapter/_module.d.ts +1 -0
- package/dist/types/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +57 -0
- package/dist/types/lock/implementations/derivables/_module.d.ts +2 -0
- package/dist/types/lock/implementations/derivables/lock-provider/_module.d.ts +1 -0
- package/dist/types/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +23 -0
- package/dist/types/lock/implementations/derivables/lock-provider/lock-provider.d.ts +89 -0
- package/dist/types/lock/implementations/derivables/lock-provider/lock.d.ts +73 -0
- package/dist/types/lock/implementations/derivables/lock-provider-factory/_module.d.ts +1 -0
- package/dist/types/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +98 -0
- package/dist/types/serde/contracts/flexible-serde.contract.d.ts +3 -2
- package/dist/types/serde/implementations/no-op-serde/no-op-serde.d.ts +2 -1
- package/dist/types/serde/implementations/super-json-serde/super-json-serde.d.ts +2 -1
- package/dist/types/utilities/contracts/_module.d.ts +1 -0
- package/dist/types/utilities/contracts/serde-registrable.contract.d.ts +11 -0
- package/dist/types/utilities/types.d.ts +3 -1
- package/package.json +5 -3
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +0 -56
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +0 -26
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +0 -44
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +0 -32
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +0 -56
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/derivables/cache/cache-settings.js +0 -56
- package/dist/cjs/cache/implementations/derivables/cache/cache-settings.js.map +0 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory-settings.js +0 -83
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory-settings.js.map +0 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +0 -26
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +0 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +0 -38
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +0 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus-settings.js +0 -56
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus-settings.js.map +0 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings.js +0 -71
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings.js.map +0 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +0 -52
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +0 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +0 -22
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +0 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +0 -40
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +0 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +0 -28
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +0 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +0 -52
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +0 -1
- package/dist/esm/cache/implementations/derivables/cache/cache-settings.js +0 -52
- package/dist/esm/cache/implementations/derivables/cache/cache-settings.js.map +0 -1
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory-settings.js +0 -79
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory-settings.js.map +0 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +0 -22
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +0 -1
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +0 -34
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +0 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus-settings.js +0 -52
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus-settings.js.map +0 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings.js +0 -67
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings.js.map +0 -1
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.d.ts +0 -48
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.d.ts +0 -26
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.d.ts +0 -50
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.d.ts +0 -32
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.d.ts +0 -48
- package/dist/types/cache/implementations/derivables/cache/cache-settings.d.ts +0 -73
- package/dist/types/cache/implementations/derivables/cache-factory/cache-factory-settings.d.ts +0 -108
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.d.ts +0 -27
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.d.ts +0 -36
- package/dist/types/event-bus/implementations/derivables/event-bus/event-bus-settings.d.ts +0 -62
- package/dist/types/event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings.d.ts +0 -92
|
@@ -15,31 +15,12 @@ export type IEventBusFactory<TAdapters extends string = string> = {
|
|
|
15
15
|
* @throws {DefaultAdapterNotDefinedError} {@link DefaultAdapterNotDefinedError}
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
|
-
* import { type IEventBusFactory } from "@daiso-tech/core";
|
|
18
|
+
* import { type IEventBusFactory, BaseEvent } from "@daiso-tech/core";
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* class AddEvent extends BaseEvent<{
|
|
21
21
|
* a: number;
|
|
22
22
|
* b: number;
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* class AddEvent extends BaseEvent<SerializedAddEvent> {
|
|
26
|
-
* // This needed for adapters that need to deserialize like the redis dapter.
|
|
27
|
-
* static override deserialize({ a, b }: SerializedAddEvent): AddEvent {
|
|
28
|
-
* return new AddEvent(a, b);
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* constructor(public readonly a: number, public readonly b: number) {
|
|
32
|
-
* super();
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // This needed for adapters that need to serialize like the redis adapter.
|
|
36
|
-
* override serialize(): SerializedAddEvent {
|
|
37
|
-
* return {
|
|
38
|
-
* a: this.a,
|
|
39
|
-
* b: this.b
|
|
40
|
-
* };
|
|
41
|
-
* }
|
|
42
|
-
* }
|
|
23
|
+
* }> {}
|
|
43
24
|
*
|
|
44
25
|
* // Asume the inputed eventFactory has registered both a memory and Redis IEventBusAdapter.
|
|
45
26
|
* // The memory IEventBusAdapter adapter is the default.
|
|
@@ -47,11 +28,11 @@ export type IEventBusFactory<TAdapters extends string = string> = {
|
|
|
47
28
|
* // Will dispatch envent using the default adapter
|
|
48
29
|
* await eventBusFactory
|
|
49
30
|
* .use()
|
|
50
|
-
* .dispatch(new AddEvent(1, 2));
|
|
31
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
51
32
|
* // Will dispatch envent using the redis addapter
|
|
52
33
|
* await eventBusFactory
|
|
53
34
|
* .use("redis")
|
|
54
|
-
* .dispatch(new AddEvent(1, 2));
|
|
35
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
55
36
|
* }
|
|
56
37
|
* ```
|
|
57
38
|
*/
|
|
@@ -14,8 +14,7 @@ export type EventBusAdapterTestSuiteSettings = {
|
|
|
14
14
|
test: TestAPI;
|
|
15
15
|
describe: SuiteAPI;
|
|
16
16
|
beforeEach: typeof beforeEach;
|
|
17
|
-
|
|
18
|
-
createAdapterB: () => Promisable<IEventBusAdapter>;
|
|
17
|
+
createAdapter: () => Promisable<IEventBusAdapter>;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
20
|
* The <i>eventBusAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBusAdapter}</i> with vitest.
|
|
@@ -45,14 +44,7 @@ export type EventBusAdapterTestSuiteSettings = {
|
|
|
45
44
|
* await startedContainer.stop();
|
|
46
45
|
* }, TIMEOUT.toMilliseconds());
|
|
47
46
|
* eventBusAdapterTestSuite({
|
|
48
|
-
*
|
|
49
|
-
* new RedisPubSubEventBusAdapter({
|
|
50
|
-
* dispatcherClient,
|
|
51
|
-
* listenerClient,
|
|
52
|
-
* serde,
|
|
53
|
-
* rootGroup: "@global"
|
|
54
|
-
* }),
|
|
55
|
-
* createAdapterB: () =>
|
|
47
|
+
* createAdapter: () =>
|
|
56
48
|
* new RedisPubSubEventBusAdapter({
|
|
57
49
|
* dispatcherClient,
|
|
58
50
|
* listenerClient,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
|
-
import { type
|
|
5
|
+
import { type IGroupableEventBus } from "../../../event-bus/contracts/_module";
|
|
6
6
|
import { type Promisable } from "../../../utilities/_module";
|
|
7
7
|
import type { IFlexibleSerde } from "../../../serde/contracts/_module";
|
|
8
8
|
/**
|
|
@@ -14,8 +14,7 @@ export type EventBusTestSuiteSettings = {
|
|
|
14
14
|
test: TestAPI;
|
|
15
15
|
describe: SuiteAPI;
|
|
16
16
|
beforeEach: typeof beforeEach;
|
|
17
|
-
|
|
18
|
-
createEventBusB: () => Promisable<IEventBus>;
|
|
17
|
+
createEventBus: () => Promisable<IGroupableEventBus>;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
20
|
* The <i>eventBusTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBus}</i> with vitest.
|
|
@@ -45,7 +44,7 @@ export type EventBusTestSuiteSettings = {
|
|
|
45
44
|
* await startedContainer.stop();
|
|
46
45
|
* }, TIMEOUT.toMilliseconds());
|
|
47
46
|
* eventBusTestSuite({
|
|
48
|
-
*
|
|
47
|
+
* createEventBus: () =>
|
|
49
48
|
* new EventBus(
|
|
50
49
|
* new RedisPubSubEventBusAdapter({
|
|
51
50
|
* dispatcherClient,
|
|
@@ -54,15 +53,6 @@ export type EventBusTestSuiteSettings = {
|
|
|
54
53
|
* rootGroup: "@global"
|
|
55
54
|
* })
|
|
56
55
|
* ),
|
|
57
|
-
* createEventBusB: () =>
|
|
58
|
-
* new EventBus(
|
|
59
|
-
* new RedisPubSubEventBusAdapter({
|
|
60
|
-
* dispatcherClient,
|
|
61
|
-
* listenerClient,
|
|
62
|
-
* serde,
|
|
63
|
-
* rootGroup: "@global"
|
|
64
|
-
* }),
|
|
65
|
-
* ),
|
|
66
56
|
* serde,
|
|
67
57
|
* test,
|
|
68
58
|
* beforeEach,
|
|
@@ -2,29 +2,19 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import type { BaseEvent, IEventBusAdapter, Listener } from "../../../../event-bus/contracts/_module";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { EventEmitter } from "node:events";
|
|
6
|
+
/**
|
|
7
|
+
* @group Adapters
|
|
8
|
+
*/
|
|
9
|
+
export type MemoryEventBusAdapterSettings = {
|
|
10
|
+
rootGroup: string;
|
|
11
|
+
eventEmitter?: EventEmitter;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* To utilize the <i>MemoryEventBusAdapter</i>, you must create instance of it.
|
|
9
15
|
* @group Adapters
|
|
10
16
|
*/
|
|
11
17
|
export declare class MemoryEventBusAdapter implements IEventBusAdapter {
|
|
12
|
-
/**
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { MemoryEventBusAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
16
|
-
* import { EventEmitter } from "node:events";
|
|
17
|
-
*
|
|
18
|
-
* const cacheAdapter = new MemoryEventBusAdapter(
|
|
19
|
-
* MemoryEventBusAdapter
|
|
20
|
-
* .settings()
|
|
21
|
-
* .setEventEmitter(new EventEmitter())
|
|
22
|
-
* .setRootGroup("@global")
|
|
23
|
-
* .build()
|
|
24
|
-
* );
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
static settings<TSettings extends Partial<MemoryEventBusAdapterSettings>>(): MemoryEventBusAdapterSettingsBuilder<TSettings>;
|
|
28
18
|
private readonly group;
|
|
29
19
|
private readonly eventEmitter;
|
|
30
20
|
/**
|
|
@@ -1,32 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
+
import { type ISerde } from "../../../../serde/contracts/_module";
|
|
4
5
|
import type { BaseEvent, IEventBusAdapter, Listener } from "../../../../event-bus/contracts/_module";
|
|
5
|
-
import type
|
|
6
|
-
|
|
6
|
+
import type Redis from "ioredis";
|
|
7
|
+
/**
|
|
8
|
+
* @group Adapters
|
|
9
|
+
*/
|
|
10
|
+
export type RedisPubSubEventBusAdapterSettings = {
|
|
11
|
+
dispatcherClient: Redis;
|
|
12
|
+
listenerClient: Redis;
|
|
13
|
+
serde: ISerde<string>;
|
|
14
|
+
rootGroup: string;
|
|
15
|
+
};
|
|
7
16
|
/**
|
|
8
17
|
* To utilize the <i>RedisPubSubEventBusAdapter</i>, you must install the <i>"ioredis"</i> package and supply a <i>{@link ISerde | ISerde<string> }</i>, such as <i>{@link SuperJsonSerde}</i>.
|
|
9
18
|
* @group Adapters
|
|
10
19
|
*/
|
|
11
20
|
export declare class RedisPubSubEventBusAdapter implements IEventBusAdapter {
|
|
12
|
-
/**
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { RedisPubSubEventBusAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
16
|
-
* import Redis from "ioredis";
|
|
17
|
-
*
|
|
18
|
-
* const cacheAdapter = new RedisPubSubEventBusAdapter(
|
|
19
|
-
* RedisPubSubEventBusAdapter
|
|
20
|
-
* .settings()
|
|
21
|
-
* .setDispatcherClient(new Redis("YOUR REDIS CONNECTION"))
|
|
22
|
-
* .setListenerClient(new Redis("YOUR REDIS CONNECTION"))
|
|
23
|
-
* .setSerde(new SuperJsonSerde())
|
|
24
|
-
* .setRootGroup("@global")
|
|
25
|
-
* .build()
|
|
26
|
-
* );
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
static settings<TSettings extends Partial<RedisPubSubEventBusAdapterSettings>>(): RedisPubSubEventBusAdapterSettingsBuilder<TSettings>;
|
|
30
21
|
private readonly group;
|
|
31
22
|
private readonly baseSerde;
|
|
32
23
|
private readonly redisSerde;
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
+
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module";
|
|
4
5
|
import { LazyPromise } from "../../../../async/_module";
|
|
5
6
|
import type { EventClass, EventInstance, Unsubscribe } from "../../../../event-bus/contracts/_module";
|
|
6
|
-
import { type IEventBus, type IGroupableEventBus, type Listener, type BaseEvent } from "../../../../event-bus/contracts/_module";
|
|
7
|
-
import type { OneOrMore } from "../../../../utilities/_module";
|
|
8
|
-
import type { EventBusSettings } from "../../../../event-bus/implementations/derivables/event-bus/event-bus-settings";
|
|
9
|
-
import { EventBusSettingsBuilder } from "../../../../event-bus/implementations/derivables/event-bus/event-bus-settings";
|
|
7
|
+
import { type IEventBus, type IGroupableEventBus, type IEventBusAdapter, type Listener, type BaseEvent } from "../../../../event-bus/contracts/_module";
|
|
8
|
+
import type { OneOrMore, TimeSpan } from "../../../../utilities/_module";
|
|
10
9
|
/**
|
|
11
|
-
* <i>EventBus</i> class can be derived from any <i>{@link IEventBusAdapter}</i>.
|
|
12
10
|
* @group Derivables
|
|
13
11
|
*/
|
|
14
|
-
export
|
|
12
|
+
export type EventBusSettings = {
|
|
13
|
+
adapter: IEventBusAdapter;
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
15
|
+
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
16
|
+
* @default {null}
|
|
17
|
+
*/
|
|
18
|
+
retryAttempts?: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
21
|
+
* @default {null}
|
|
22
|
+
*/
|
|
23
|
+
backoffPolicy?: BackoffPolicy | null;
|
|
24
|
+
/**
|
|
25
|
+
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
26
|
+
* @default {null}
|
|
27
|
+
*/
|
|
28
|
+
retryPolicy?: RetryPolicy | null;
|
|
29
|
+
/**
|
|
30
|
+
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
31
|
+
* @default {null}
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
timeout?: TimeSpan | null;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* <i>EventBus</i> class can be derived from any <i>{@link IEventBusAdapter}</i>.
|
|
37
|
+
* @group Derivables
|
|
38
|
+
*/
|
|
39
|
+
export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements IGroupableEventBus<TEvents> {
|
|
31
40
|
private readonly adapter;
|
|
32
41
|
private readonly retryAttempts;
|
|
33
42
|
private readonly backoffPolicy;
|
package/dist/types/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts
CHANGED
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
import { type
|
|
4
|
+
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module";
|
|
5
|
+
import { type IEventBusAdapter, type IGroupableEventBus, type IEventBusFactory, type BaseEvent } from "../../../../event-bus/contracts/_module";
|
|
6
|
+
import type { OneOrMore, TimeSpan } from "../../../../utilities/_module";
|
|
7
|
+
import type { IFlexibleSerde } from "../../../../serde/contracts/_module";
|
|
6
8
|
/**
|
|
7
9
|
* @group Derivables
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { EventBusFactory } from "@daiso-tech/core";
|
|
11
|
-
* import Redis from "ioredis"
|
|
12
|
-
*
|
|
13
|
-
* const eventBusFactory = new EventBusFactory({
|
|
14
|
-
* adapters: {
|
|
15
|
-
* memory: new MemoryEventBusAdapter({ rootGroup: "@global" }),
|
|
16
|
-
* redis: new RedisPubSubEventBusAdapter({
|
|
17
|
-
* dispatcherClient: new Redis(),
|
|
18
|
-
* listenerClient: new Redis(),
|
|
19
|
-
* serde: new SuperJsonSerde(),
|
|
20
|
-
* rootGroup: "@global"
|
|
21
|
-
* }),
|
|
22
|
-
* },
|
|
23
|
-
* defaultAdapter: "memory",
|
|
24
|
-
* serde: new SuperJsonSerde()
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
10
|
*/
|
|
28
|
-
export
|
|
11
|
+
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, IEventBusAdapter>>;
|
|
12
|
+
/**
|
|
13
|
+
* @group Derivables
|
|
14
|
+
*/
|
|
15
|
+
export type EventBusFactorySettings<TAdapters extends string = string> = {
|
|
29
16
|
/**
|
|
30
|
-
* @
|
|
31
|
-
*
|
|
32
|
-
* import { EventBusFactory, SuperJsonSerde. MemoryEventBusAdapter, RedisPubSubEventBusAdapter, EventBus, MemoryEventBusAdapter } from "@daiso-tech/core";
|
|
33
|
-
* import Redis from "ioredis";
|
|
34
|
-
*
|
|
35
|
-
* const serde = new SuperJsonSerde();
|
|
36
|
-
* const cacheFactory = new EventBusFactory(
|
|
37
|
-
* EventBusFactory
|
|
38
|
-
* .settings()
|
|
39
|
-
* .setSerde(serde)
|
|
40
|
-
* .setAdapter("memory", new MemoryEventBusAdapter({
|
|
41
|
-
* rootGroup: "@global"
|
|
42
|
-
* }))
|
|
43
|
-
* .setAdapter("redis", new RedisPubSubEventBusAdapter({
|
|
44
|
-
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
|
|
45
|
-
* listenerClient: new Redis("YOUR_REDIS_CONNECTION")
|
|
46
|
-
* serde,
|
|
47
|
-
* rootGroup: "@global"
|
|
48
|
-
* }))
|
|
49
|
-
* .setDefaultAdapter("memory")
|
|
50
|
-
* .build()
|
|
51
|
-
* );
|
|
52
|
-
* ```
|
|
17
|
+
* You can pass one or more <i>{@link IFlexibleSerde}</i> that will be used to register all <i>{@link IGroupableEventBus}</i> related errors.
|
|
18
|
+
* @default {true}
|
|
53
19
|
*/
|
|
54
|
-
|
|
20
|
+
serde: OneOrMore<IFlexibleSerde>;
|
|
21
|
+
/**
|
|
22
|
+
* If set to true, all <i>{@link IGroupableEventBus}</i> related errors will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
23
|
+
* This ensures that all <i>{@link IGroupableEventBus}</i> related errors will be serialized correctly.
|
|
24
|
+
* @default {true}
|
|
25
|
+
*/
|
|
26
|
+
shouldRegisterErrors?: boolean;
|
|
27
|
+
adapters: EventBusAdapters<TAdapters>;
|
|
28
|
+
defaultAdapter?: NoInfer<TAdapters>;
|
|
29
|
+
/**
|
|
30
|
+
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
31
|
+
*/
|
|
32
|
+
eventBus?: IGroupableEventBus<any>;
|
|
33
|
+
/**
|
|
34
|
+
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
35
|
+
* @default {null}
|
|
36
|
+
*/
|
|
37
|
+
retryAttempts?: number | null;
|
|
38
|
+
/**
|
|
39
|
+
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
40
|
+
* @default {null}
|
|
41
|
+
*/
|
|
42
|
+
backoffPolicy?: BackoffPolicy | null;
|
|
43
|
+
/**
|
|
44
|
+
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
45
|
+
* @default {null}
|
|
46
|
+
*/
|
|
47
|
+
retryPolicy?: RetryPolicy | null;
|
|
48
|
+
/**
|
|
49
|
+
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
50
|
+
* @default {null}
|
|
51
|
+
*/
|
|
52
|
+
timeout?: TimeSpan | null;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* @group Derivables
|
|
56
|
+
*/
|
|
57
|
+
export declare class EventBusFactory<TAdapters extends string = string> implements IEventBusFactory<TAdapters> {
|
|
55
58
|
private readonly eventBusRecord;
|
|
56
59
|
private readonly serde;
|
|
57
60
|
private readonly defaultAdapter?;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "../../lock/contracts/lock-adapter.contract";
|
|
2
|
+
export * from "../../lock/contracts/database-lock-adapter.contract";
|
|
3
|
+
export * from "../../lock/contracts/lock-provider.contract";
|
|
4
|
+
export * from "../../lock/contracts/lock-provider-factory.contract";
|
|
5
|
+
export * from "../../lock/contracts/lock.contract";
|
|
6
|
+
export * from "../../lock/contracts/lock.errors";
|
|
7
|
+
export * from "../../lock/contracts/lock.events";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Lock
|
|
3
|
+
*/
|
|
4
|
+
import type { IDeinitizable, IInitizable } from "../../utilities/_module";
|
|
5
|
+
/**
|
|
6
|
+
* @group Contracts
|
|
7
|
+
*/
|
|
8
|
+
export type ILockData = {
|
|
9
|
+
owner: string;
|
|
10
|
+
expiration: Date | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The <i>ILockAdapter</i> contract defines a way for managing locks independent of data storage.
|
|
14
|
+
* This contract is not meant to be used directly, instead you should use <i>{@link ILockProvider}</i> contract.
|
|
15
|
+
* @group Contracts
|
|
16
|
+
*/
|
|
17
|
+
export type IDatabaseLockAdapter = IDeinitizable & IInitizable & {
|
|
18
|
+
/**
|
|
19
|
+
* The <i>insert</i> method will create a lock if one does not already exist.
|
|
20
|
+
*/
|
|
21
|
+
insert(key: string, owner: string, expiration: Date | null): PromiseLike<void>;
|
|
22
|
+
/**
|
|
23
|
+
* The <i>update</i> method will update a lock if it has expired, matches the given <i>key</i> and matches the given <i>owner</i>.
|
|
24
|
+
* Returns number of updated rows or documents.
|
|
25
|
+
*/
|
|
26
|
+
update(key: string, owner: string, expiration: Date | null): PromiseLike<number>;
|
|
27
|
+
/**
|
|
28
|
+
* The <i>remove</i> method will remove a lock if it matches the given <i>key</i> and matches the given <i>owner</i>.
|
|
29
|
+
*/
|
|
30
|
+
remove(key: string, owner: string | null): PromiseLike<void>;
|
|
31
|
+
/**
|
|
32
|
+
* The <i>refresh</i> method will upadte expiration of lock if it matches the given <i>key</i> and matches the given <i>owner</i>.
|
|
33
|
+
* Returns number of updated rows or documents.
|
|
34
|
+
*/
|
|
35
|
+
refresh(key: string, owner: string, expiration: Date): PromiseLike<number>;
|
|
36
|
+
/**
|
|
37
|
+
* The <i>find</i> method will return a lock by the given <i>key</i>.
|
|
38
|
+
*/
|
|
39
|
+
find(key: string): PromiseLike<ILockData | null>;
|
|
40
|
+
/**
|
|
41
|
+
* The <i>getGroup</i> method returns the group name.
|
|
42
|
+
*/
|
|
43
|
+
getGroup(): string;
|
|
44
|
+
/**
|
|
45
|
+
* The <i>withGroup</i> method returns a new <i>{@link IDatabaseLockAdapter}</i> instance that groups locks together.
|
|
46
|
+
* Only locks in the same group will be acquired and released, leaving locks outside the group unaffected.
|
|
47
|
+
*/
|
|
48
|
+
withGroup(group: string): IDatabaseLockAdapter;
|
|
49
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Lock
|
|
3
|
+
*/
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
5
|
+
/**
|
|
6
|
+
* The <i>ILockAdapter</i> contract defines a way for managing locks independent of the underlying technology.
|
|
7
|
+
* This contract is not meant to be used directly, instead you should use <i>{@link ILockProvider}</i> contract.
|
|
8
|
+
* @group Contracts
|
|
9
|
+
*/
|
|
10
|
+
export type ILockAdapter = {
|
|
11
|
+
/**
|
|
12
|
+
* The <i>acquire</i> method acquires a lock only if the lock is not already acquired.
|
|
13
|
+
* Returns true if not already acquired othewise false is returned.
|
|
14
|
+
*/
|
|
15
|
+
acquire(key: string, owner: string, ttl: TimeSpan | null): PromiseLike<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* The <i>release</i> method releases a lock if the owner matches.
|
|
18
|
+
* Returns true if released otherwise false is returned.
|
|
19
|
+
*/
|
|
20
|
+
release(key: string, owner: string): PromiseLike<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* The <i>forceRelease</i> method releases a lock regardless of the owner.
|
|
23
|
+
*/
|
|
24
|
+
forceRelease(key: string): PromiseLike<void>;
|
|
25
|
+
/**
|
|
26
|
+
* The <i>isLocked</i> method return true if locked otherwise false is returned.
|
|
27
|
+
*/
|
|
28
|
+
isLocked(key: string): PromiseLike<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* The <i>getRemainingTime</i> return the reaming time as <i>{@link TimeSpan}</i>.
|
|
31
|
+
* Returns null if the key doesnt exist, key has no expiration and key has expired.
|
|
32
|
+
*/
|
|
33
|
+
getRemainingTime(key: string): PromiseLike<TimeSpan | null>;
|
|
34
|
+
/**
|
|
35
|
+
* The <i>refresh</i> method will upadte ttl of lock if it matches the given <i>key</i> and matches the given <i>owner</i>.
|
|
36
|
+
* Returns true if the update occured otherwise false is returned.
|
|
37
|
+
*/
|
|
38
|
+
refresh(key: string, owner: string, ttl: TimeSpan): PromiseLike<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* The <i>getGroup</i> method returns the group name.
|
|
41
|
+
*/
|
|
42
|
+
getGroup(): string;
|
|
43
|
+
/**
|
|
44
|
+
* The <i>withGroup</i> method returns a new <i>{@link IDatabaseLockAdapter}</i> instance that groups locks together.
|
|
45
|
+
* Only locks in the same group will be acquired and released, leaving locks outside the group unaffected.
|
|
46
|
+
*/
|
|
47
|
+
withGroup(group: string): ILockAdapter;
|
|
48
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Lock
|
|
3
|
+
*/
|
|
4
|
+
import type { IGroupableLockProvider } from "../../lock/contracts/lock-provider.contract";
|
|
5
|
+
/**
|
|
6
|
+
* The <i>ILockProviderFactory</i> contract makes it easy to configure and switch between different <i>{@link IGroupableLockProvider}</i> dynamically.
|
|
7
|
+
* @group Contracts
|
|
8
|
+
*/
|
|
9
|
+
export type ILockProviderFactory<TAdapters extends string = string> = {
|
|
10
|
+
/**
|
|
11
|
+
* The <i>use</i> method will throw an error if you provide it unregisted adapter.
|
|
12
|
+
* If no default adapter is defined an error will be thrown by <i>use</i> method.
|
|
13
|
+
* @throws {UnregisteredAdapterError} {@link UnregisteredAdapterError}
|
|
14
|
+
* @throws {DefaultAdapterNotDefinedError} {@link DefaultAdapterNotDefinedError}
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import type { ILockProviderFactory } from "@daiso-tech/core";
|
|
18
|
+
*
|
|
19
|
+
* // Asume the inputed lockProviderFactory has registered both a memory and Redis ILockAdapter.
|
|
20
|
+
* // The memory ILockAdapter adapter is the default.
|
|
21
|
+
* async function main(lockProviderFactory: ILockProviderFactory): Promise<void> {
|
|
22
|
+
* // Will create and acquire the lock with default adapter
|
|
23
|
+
* await lockProviderFactory
|
|
24
|
+
* .use()
|
|
25
|
+
* .create("a")
|
|
26
|
+
* .acquireOrFail();
|
|
27
|
+
* // Will create and acquire the lock with redis addapter
|
|
28
|
+
* await lockProviderFactory
|
|
29
|
+
* .use("redis")
|
|
30
|
+
* .create("a")
|
|
31
|
+
* .acquireOrFail();
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
use(adapterName?: TAdapters): IGroupableLockProvider;
|
|
36
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Lock
|
|
3
|
+
*/
|
|
4
|
+
import type { OneOrMore, TimeSpan } from "../../utilities/_module";
|
|
5
|
+
import type { ILock, ILockListener } from "../../lock/contracts/lock.contract";
|
|
6
|
+
/**
|
|
7
|
+
* @group Contracts
|
|
8
|
+
*/
|
|
9
|
+
export type LockProviderCreateSettings = {
|
|
10
|
+
ttl?: TimeSpan | null;
|
|
11
|
+
owner?: OneOrMore<string>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The <i>ILockProvider</i> contract defines a way for managing locks independent of the underlying technology.
|
|
15
|
+
* It commes with more convient methods compared to <i>ILockAdapter</i>.
|
|
16
|
+
* @group Contracts
|
|
17
|
+
*/
|
|
18
|
+
export type ILockProvider = ILockListener & {
|
|
19
|
+
/**
|
|
20
|
+
* The <i>create</i> method is used to create an instance of <i>{@link ILock}</i>.
|
|
21
|
+
* You can provide a custom owner using the <i>settings.owner</i> field. If not specified a unique owner will be generated by default.
|
|
22
|
+
* You can also provide a TTL value using the <i>settings.ttl</i> field. If not specified it defaults to null, meaning no TTL is applied.
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { type ILockProvider, delay, TimeSpan } from "@daiso-tech/core";
|
|
26
|
+
*
|
|
27
|
+
* // Asume the inputed lockProvider is empty.
|
|
28
|
+
* async function main(lockProvider: ILockProvider): Promise<void> {
|
|
29
|
+
* const lock = await lockProvider.create("a");
|
|
30
|
+
*
|
|
31
|
+
* // You can now use the lock as you want.
|
|
32
|
+
* await lock.acquire();
|
|
33
|
+
* console.log("Hello world");
|
|
34
|
+
* await lock.release();
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
create(key: OneOrMore<string>, settings?: LockProviderCreateSettings): ILock;
|
|
39
|
+
/**
|
|
40
|
+
* The <i>getGroup</i> method returns the group name.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import type { ILockProvider } from "@daiso-tech/core";
|
|
44
|
+
*
|
|
45
|
+
* // Asume the inputed lockProvider is empty and the default rootGroup is "@global"
|
|
46
|
+
* async function main(lockProvider: ILockProvider): Promise<void> {
|
|
47
|
+
* console.log(lockProvider.getGroup())
|
|
48
|
+
*
|
|
49
|
+
* const lockProviderA = lockProvider.withGroup("a");
|
|
50
|
+
*
|
|
51
|
+
* // Will be "@global/a"
|
|
52
|
+
* console.log(lockProviderA.getGroup())
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getGroup(): string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The <i>IGroupableLockProvider</i> contract defines a way for managing locks independent of the underlying technology.
|
|
60
|
+
* It commes with one extra method which is useful for multitennat applications compared to <i>{@link ILockProvider}</i>.
|
|
61
|
+
* @group Contracts
|
|
62
|
+
*/
|
|
63
|
+
export type IGroupableLockProvider = ILockProvider & {
|
|
64
|
+
/**
|
|
65
|
+
* The <i>withGroup</i> method returns a new <i>{@link ILockProvider}</i> instance that groups locks together.
|
|
66
|
+
* Only locks in the same group will be acquired and released, leaving locks outside the group unaffected.
|
|
67
|
+
* This useful for multitennat applications.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import type { IGroupableLockProvider } from "@daiso-tech/core";
|
|
71
|
+
*
|
|
72
|
+
* // Asume the inputed lockProvider is empty and the default rootGroup is "@global"
|
|
73
|
+
* async function main(lockProvider: IGroupableLockProvider): Promise<void> {
|
|
74
|
+
* const key = "a";
|
|
75
|
+
*
|
|
76
|
+
* const lockProviderA = lockProvider.withGroup("a");
|
|
77
|
+
* const lockA = lockProviderA.create(key);
|
|
78
|
+
*
|
|
79
|
+
* const lockProviderB = lockProvider.withGroup("b");
|
|
80
|
+
* const lockB = lockProviderB.create(key);
|
|
81
|
+
*
|
|
82
|
+
* const resultA = await lockA.acquire();
|
|
83
|
+
* const resultB = await lockB.acquire();
|
|
84
|
+
*
|
|
85
|
+
* // Will print out true for both lockA.acquire() and lockB.acquire()
|
|
86
|
+
* console.log("resultA:", resultA);
|
|
87
|
+
* console.log("resultB", resultB);
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
withGroup(group: OneOrMore<string>): ILockProvider;
|
|
92
|
+
};
|