@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
package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts
CHANGED
|
@@ -4,33 +4,23 @@
|
|
|
4
4
|
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
5
|
import type { IDeinitizable } from "../../../../utilities/_module";
|
|
6
6
|
import { type TimeSpan, type IInitizable } from "../../../../utilities/_module";
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
7
|
+
import type { CollectionOptions, Db } from "mongodb";
|
|
8
|
+
import type { ISerde } from "../../../../serde/contracts/_module";
|
|
9
|
+
/**
|
|
10
|
+
* @group Adapters
|
|
11
|
+
*/
|
|
12
|
+
export type MongodbCacheAdapterSettings = {
|
|
13
|
+
database: Db;
|
|
14
|
+
serde: ISerde<string>;
|
|
15
|
+
rootGroup: string;
|
|
16
|
+
collectionName?: string;
|
|
17
|
+
collectionSettings?: CollectionOptions;
|
|
18
|
+
};
|
|
9
19
|
/**
|
|
10
20
|
* To utilize the <i>MongodbCacheAdapter</i>, you must install the <i>"mongodb"</i> package and supply a <i>{@link ISerde | ISerde<string> }</i>, such as <i>{@link SuperJsonSerde}</i>.
|
|
11
21
|
* @group Adapters
|
|
12
22
|
*/
|
|
13
23
|
export declare class MongodbCacheAdapter<TType = unknown> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
14
|
-
/**
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { MongodbCacheAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
18
|
-
* import { MongoClient } from "mongodb";
|
|
19
|
-
*
|
|
20
|
-
* (async () => {
|
|
21
|
-
* const client = await MongoClient.connect("YOUR_MONGODB_CONNECTION_STRING");
|
|
22
|
-
* const cacheAdapter = new MongodbCacheAdapter(
|
|
23
|
-
* MongodbCacheAdapter
|
|
24
|
-
* .settings()
|
|
25
|
-
* .setDatabase(client.db("database"))
|
|
26
|
-
* .setSerde(new SuperJsonSerde())
|
|
27
|
-
* .setRootGroup("@global")
|
|
28
|
-
* .build()
|
|
29
|
-
* );
|
|
30
|
-
* })();
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
static settings<TSettings extends Partial<MongodbCacheAdapterSettings>>(): MongodbCacheAdapterSettingsBuilder<TSettings>;
|
|
34
24
|
private static isMongodbIncrementError;
|
|
35
25
|
private readonly mongodbSerde;
|
|
36
26
|
private readonly group;
|
|
@@ -38,6 +28,7 @@ export declare class MongodbCacheAdapter<TType = unknown> implements ICacheAdapt
|
|
|
38
28
|
private readonly database;
|
|
39
29
|
private readonly collection;
|
|
40
30
|
private readonly collectionName;
|
|
31
|
+
private readonly collectionSettings?;
|
|
41
32
|
/**
|
|
42
33
|
* @example
|
|
43
34
|
* ```ts
|
|
@@ -53,25 +44,23 @@ export declare class MongodbCacheAdapter<TType = unknown> implements ICacheAdapt
|
|
|
53
44
|
* serde,
|
|
54
45
|
* rootGroup: "@global"
|
|
55
46
|
* });
|
|
56
|
-
*
|
|
57
47
|
* await cacheAdapter.init();
|
|
58
|
-
* await cacheAdapter.add("a", 1);
|
|
59
|
-
* await cacheAdapter.deInit();
|
|
60
48
|
* })();
|
|
61
49
|
* ```
|
|
62
50
|
*/
|
|
63
|
-
constructor(
|
|
51
|
+
constructor(settings: MongodbCacheAdapterSettings);
|
|
64
52
|
getGroup(): string;
|
|
65
53
|
withGroup(group: string): ICacheAdapter<TType>;
|
|
66
54
|
/**
|
|
67
55
|
* Creates all related indexes.
|
|
56
|
+
* Note the <i>init</i> method needs to be called before using the adapter.
|
|
68
57
|
*/
|
|
69
58
|
init(): Promise<void>;
|
|
70
59
|
/**
|
|
71
60
|
* Removes the collection where the cache values are stored and all it's related indexes.
|
|
61
|
+
* Note all cache data will be removed.
|
|
72
62
|
*/
|
|
73
63
|
deInit(): Promise<void>;
|
|
74
|
-
exists(key: string): Promise<boolean>;
|
|
75
64
|
get(key: string): Promise<TType | null>;
|
|
76
65
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
77
66
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { TimeSpan } from "../../../../utilities/_module";
|
|
|
10
10
|
export declare class NoOpCacheAdapter<TType = unknown> implements ICacheAdapter<TType> {
|
|
11
11
|
getGroup(): string;
|
|
12
12
|
withGroup(_group: string): ICacheAdapter<TType>;
|
|
13
|
-
exists(_key: string): Promise<boolean>;
|
|
14
13
|
get(_key: string): Promise<TType | null>;
|
|
15
14
|
add(_key: string, _value: TType, _ttl: TimeSpan | null): Promise<boolean>;
|
|
16
15
|
update(_key: string, _value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts
CHANGED
|
@@ -3,36 +3,26 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
5
|
import { type TimeSpan } from "../../../../utilities/_module";
|
|
6
|
-
import { type Result } from "ioredis";
|
|
7
|
-
import type {
|
|
8
|
-
import { RedisCacheAdapterSettingsBuilder } from "../../../../cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings";
|
|
6
|
+
import { type Redis, type Result } from "ioredis";
|
|
7
|
+
import type { ISerde } from "../../../../serde/contracts/_module";
|
|
9
8
|
declare module "ioredis" {
|
|
10
9
|
interface RedisCommander<Context> {
|
|
11
10
|
daiso_cache_increment(key: string, number: string): Result<number, Context>;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* @group Adapters
|
|
15
|
+
*/
|
|
16
|
+
export type RedisCacheAdapterSettings = {
|
|
17
|
+
database: Redis;
|
|
18
|
+
serde: ISerde<string>;
|
|
19
|
+
rootGroup: string;
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
22
|
* To utilize the <i>RedisCacheAdapter</i>, you must install the <i>"ioredis"</i> package and supply a <i>{@link ISerde | ISerde<string> }</i>, such as <i>{@link SuperJsonSerde}</i>.
|
|
16
23
|
* @group Adapters
|
|
17
24
|
*/
|
|
18
25
|
export declare class RedisCacheAdapter<TType = unknown> implements ICacheAdapter<TType> {
|
|
19
|
-
/**
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { RedisCacheAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
23
|
-
* import Redis from "ioredis";
|
|
24
|
-
*
|
|
25
|
-
* const cacheAdapter = new RedisCacheAdapter(
|
|
26
|
-
* RedisCacheAdapter
|
|
27
|
-
* .settings()
|
|
28
|
-
* .setDatabase(new Redis("YOUR_REDIS_CONNECTION_STRING"))
|
|
29
|
-
* .setSerde(new SuperJsonSerde())
|
|
30
|
-
* .setRootGroup("@global")
|
|
31
|
-
* .build()
|
|
32
|
-
* );
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
static settings<TSettings extends Partial<RedisCacheAdapterSettings>>(): RedisCacheAdapterSettingsBuilder<TSettings>;
|
|
36
26
|
private static isRedisTypeError;
|
|
37
27
|
private readonly baseSerde;
|
|
38
28
|
private readonly redisSerde;
|
|
@@ -53,10 +43,9 @@ export declare class RedisCacheAdapter<TType = unknown> implements ICacheAdapter
|
|
|
53
43
|
* });
|
|
54
44
|
* ```
|
|
55
45
|
*/
|
|
56
|
-
constructor(
|
|
57
|
-
private
|
|
46
|
+
constructor(settings: RedisCacheAdapterSettings);
|
|
47
|
+
private getPrefix;
|
|
58
48
|
private withPrefix;
|
|
59
|
-
exists(key: string): Promise<boolean>;
|
|
60
49
|
get(key: string): Promise<TType | null>;
|
|
61
50
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
62
51
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts
CHANGED
|
@@ -3,30 +3,25 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
5
|
import type { TimeSpan, IInitizable, IDeinitizable } from "../../../../utilities/_module";
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
6
|
+
import type { SqliteDatabase } from "kysely";
|
|
7
|
+
import type { ISerde } from "../../../../serde/contracts/_module";
|
|
8
|
+
/**
|
|
9
|
+
* @group Adapters
|
|
10
|
+
*/
|
|
11
|
+
export type SqliteCacheAdapterSettings = {
|
|
12
|
+
database: SqliteDatabase;
|
|
13
|
+
tableName?: string;
|
|
14
|
+
serde: ISerde<string>;
|
|
15
|
+
enableTransactions?: boolean;
|
|
16
|
+
expiredKeysRemovalInterval?: TimeSpan;
|
|
17
|
+
shouldRemoveExpiredKeys?: boolean;
|
|
18
|
+
rootGroup: string;
|
|
19
|
+
};
|
|
8
20
|
/**
|
|
9
21
|
* To utilize the <i>SqliteCacheAdapter</i>, you must install the <i>"better-sqlite3"</i> package and supply a <i>{@link ISerde | ISerde<string> }</i>, such as <i>{@link SuperJsonSerde}</i>.
|
|
10
22
|
* @group Adapters
|
|
11
23
|
*/
|
|
12
24
|
export declare class SqliteCacheAdapter<TType = unknown> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
13
|
-
/**
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { SqliteCacheAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
17
|
-
* import Sqlite from "better-sqlite3";
|
|
18
|
-
*
|
|
19
|
-
* const cacheAdapter = new SqliteCacheAdapter(
|
|
20
|
-
* SqliteCacheAdapter
|
|
21
|
-
* .settings()
|
|
22
|
-
* .setDatabase(new Sqlite("local.db"))
|
|
23
|
-
* .setSerde(new SuperJsonSerde())
|
|
24
|
-
* .setRootGroup("@global")
|
|
25
|
-
* .build()
|
|
26
|
-
* );
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
static settings<TSettings extends Partial<SqliteCacheAdapterSettings>>(): SqliteCacheAdapterSettingsBuilder<TSettings>;
|
|
30
25
|
private readonly cacheAdapter;
|
|
31
26
|
/**
|
|
32
27
|
* @example
|
|
@@ -34,18 +29,15 @@ export declare class SqliteCacheAdapter<TType = unknown> implements ICacheAdapte
|
|
|
34
29
|
* import { SqliteCacheAdapter, SuperJsonSerde } from "@daiso-tech/core";
|
|
35
30
|
* import Sqlite from "better-sqlite3";
|
|
36
31
|
*
|
|
37
|
-
* const database = new Sqlite("local.db");
|
|
38
|
-
* const serde = new SuperJsonSerde();
|
|
39
|
-
* const cacheAdapter = new SqliteCacheAdapter({
|
|
40
|
-
* database,
|
|
41
|
-
* serde,
|
|
42
|
-
* rootGroup: "@global"
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
32
|
* (async () => {
|
|
33
|
+
* const database = new Sqlite("local.db");
|
|
34
|
+
* const serde = new SuperJsonSerde();
|
|
35
|
+
* const cacheAdapter = new SqliteCacheAdapter({
|
|
36
|
+
* database,
|
|
37
|
+
* serde,
|
|
38
|
+
* rootGroup: "@global"
|
|
39
|
+
* });
|
|
46
40
|
* await cacheAdapter.init();
|
|
47
|
-
* await cacheAdapter.add("a", 1);
|
|
48
|
-
* await cacheAdapter.deInit();
|
|
49
41
|
* })();
|
|
50
42
|
* ```
|
|
51
43
|
*/
|
|
@@ -55,13 +47,14 @@ export declare class SqliteCacheAdapter<TType = unknown> implements ICacheAdapte
|
|
|
55
47
|
removeExpiredKeys(): Promise<void>;
|
|
56
48
|
/**
|
|
57
49
|
* Removes the table where the cache values are stored and removes the table indexes.
|
|
50
|
+
* Note all cache data will be removed.
|
|
58
51
|
*/
|
|
59
52
|
deInit(): Promise<void>;
|
|
60
53
|
/**
|
|
61
54
|
* Creates the table where the cache values are stored and it's related indexes.
|
|
55
|
+
* Note the <i>init</i> method needs to be called before using the adapter.
|
|
62
56
|
*/
|
|
63
57
|
init(): Promise<void>;
|
|
64
|
-
exists(key: string): Promise<boolean>;
|
|
65
58
|
get(key: string): Promise<TType | null>;
|
|
66
59
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
67
60
|
update(key: string, value: TType): Promise<boolean>;
|
|
@@ -2,34 +2,53 @@
|
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
import type { CacheEvents, WithTtlValue } from "../../../../cache/contracts/_module";
|
|
5
|
-
import { type ICache } from "../../../../cache/contracts/_module";
|
|
5
|
+
import { type ICache, type ICacheAdapter } from "../../../../cache/contracts/_module";
|
|
6
6
|
import { type IGroupableCache } from "../../../../cache/contracts/_module";
|
|
7
7
|
import type { AsyncLazyable, GetOrAddValue, OneOrMore } from "../../../../utilities/_module";
|
|
8
8
|
import type { TimeSpan } from "../../../../utilities/_module";
|
|
9
|
+
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module";
|
|
9
10
|
import { LazyPromise } from "../../../../async/_module";
|
|
10
|
-
import type { Listener, Unsubscribe, EventClass, EventInstance } from "../../../../event-bus/contracts/_module";
|
|
11
|
-
import type { CacheSettings } from "../../../../cache/implementations/derivables/cache/cache-settings";
|
|
12
|
-
import { CacheSettingsBuilder } from "../../../../cache/implementations/derivables/cache/cache-settings";
|
|
11
|
+
import type { IGroupableEventBus, Listener, Unsubscribe, EventClass, EventInstance } from "../../../../event-bus/contracts/_module";
|
|
13
12
|
/**
|
|
14
|
-
* <i>Cache</i> class can be derived from any <i>{@link ICacheAdapter}</i>.
|
|
15
13
|
* @group Derivables
|
|
16
14
|
*/
|
|
17
|
-
export
|
|
15
|
+
export type CacheSettings = {
|
|
16
|
+
adapter: ICacheAdapter<any>;
|
|
18
17
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { Cache, MemoryCacheAdapter, TimeSpan, SuperJsonSerde } from "@daiso-tech/core";
|
|
22
|
-
*
|
|
23
|
-
* const cache = new Cache(
|
|
24
|
-
* Cache
|
|
25
|
-
* .settings()
|
|
26
|
-
* .setAdapter(new MemoryCacheAdapter({ rootGroup: "@global" }))
|
|
27
|
-
* .setEventBus(new EventBus(new MemoryEventBusAdapter({ rootGroup: "@global" })))
|
|
28
|
-
* .build()
|
|
29
|
-
* );
|
|
30
|
-
* ```
|
|
18
|
+
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
31
19
|
*/
|
|
32
|
-
|
|
20
|
+
eventBus?: IGroupableEventBus<any>;
|
|
21
|
+
/**
|
|
22
|
+
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
23
|
+
* @default {null}
|
|
24
|
+
*/
|
|
25
|
+
defaultTtl?: TimeSpan | null;
|
|
26
|
+
/**
|
|
27
|
+
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
28
|
+
* @default {null}
|
|
29
|
+
*/
|
|
30
|
+
retryAttempts?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
33
|
+
* @default {null}
|
|
34
|
+
*/
|
|
35
|
+
backoffPolicy?: BackoffPolicy | null;
|
|
36
|
+
/**
|
|
37
|
+
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
38
|
+
* @default {null}
|
|
39
|
+
*/
|
|
40
|
+
retryPolicy?: RetryPolicy | null;
|
|
41
|
+
/**
|
|
42
|
+
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
43
|
+
* @default {null}
|
|
44
|
+
*/
|
|
45
|
+
timeout?: TimeSpan | null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* <i>Cache</i> class can be derived from any <i>{@link ICacheAdapter}</i>.
|
|
49
|
+
* @group Derivables
|
|
50
|
+
*/
|
|
51
|
+
export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
33
52
|
private static defaultRetryPolicy;
|
|
34
53
|
private readonly groupdEventBus;
|
|
35
54
|
private readonly eventBus;
|
|
@@ -60,14 +79,6 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
60
79
|
*/
|
|
61
80
|
constructor(settings: CacheSettings);
|
|
62
81
|
private createLayPromise;
|
|
63
|
-
private createKeyFoundEvent;
|
|
64
|
-
private createKeyNotFoundEvent;
|
|
65
|
-
private createKeyAddedEvent;
|
|
66
|
-
private createKeyUpdatedEvent;
|
|
67
|
-
private createKeyRemovedEvent;
|
|
68
|
-
private createKeysClearedEvent;
|
|
69
|
-
private createKeyIncrementedEvent;
|
|
70
|
-
private createKeyDecrementedEvent;
|
|
71
82
|
addListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Listener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
72
83
|
addListenerMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Listener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
73
84
|
removeListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Listener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
@@ -1,38 +1,72 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
+
import type { IGroupableEventBus } from "../../../../event-bus/contracts/_module";
|
|
5
|
+
import type { ICacheAdapter } from "../../../../cache/contracts/_module";
|
|
4
6
|
import { type ICacheFactory, type IGroupableCache } from "../../../../cache/contracts/_module";
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
7
|
+
import type { OneOrMore, TimeSpan } from "../../../../utilities/_module";
|
|
8
|
+
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module";
|
|
9
|
+
import type { IFlexibleSerde } from "../../../../serde/contracts/_module";
|
|
7
10
|
/**
|
|
8
11
|
* @group Derivables
|
|
9
12
|
*/
|
|
10
|
-
export
|
|
13
|
+
export type CacheAdapters<TAdapters extends string> = Partial<Record<TAdapters, ICacheAdapter<any>>>;
|
|
14
|
+
/**
|
|
15
|
+
* @group Derivables
|
|
16
|
+
*/
|
|
17
|
+
export type CacheFactorySettings<TAdapters extends string = string> = {
|
|
11
18
|
/**
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* client: new Redis("YOUR_REDIS_CONNECTION"),
|
|
27
|
-
* serde,
|
|
28
|
-
* rootGroup: "@global"
|
|
29
|
-
* }))
|
|
30
|
-
* .setDefaultAdapter("memory")
|
|
31
|
-
* .build()
|
|
32
|
-
* );
|
|
33
|
-
* ```
|
|
19
|
+
* You can pass one or more <i>{@link IFlexibleSerde}</i> that will be used to register all <i>{@link IGroupableCache}</i> related errors and events.
|
|
20
|
+
* @default {true}
|
|
21
|
+
*/
|
|
22
|
+
serde: OneOrMore<IFlexibleSerde>;
|
|
23
|
+
/**
|
|
24
|
+
* If set to true, all <i>{@link IGroupableCache}</i> related errors will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
25
|
+
* This ensures that all <i>{@link IGroupableCache}</i> related errors will be serialized correctly.
|
|
26
|
+
* @default {true}
|
|
27
|
+
*/
|
|
28
|
+
shouldRegisterErrors?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If set to true, all <i>{@link IGroupableCache}</i> related events will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
31
|
+
* This ensures that all <i>{@link IGroupableCache}</i> related events will be serialized correctly.
|
|
32
|
+
* @default {true}
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
shouldRegisterEvents?: boolean;
|
|
35
|
+
adapters: CacheAdapters<TAdapters>;
|
|
36
|
+
defaultAdapter?: NoInfer<TAdapters>;
|
|
37
|
+
/**
|
|
38
|
+
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
39
|
+
*/
|
|
40
|
+
defaultTtl?: TimeSpan;
|
|
41
|
+
/**
|
|
42
|
+
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
43
|
+
*/
|
|
44
|
+
eventBus: IGroupableEventBus<any>;
|
|
45
|
+
/**
|
|
46
|
+
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
47
|
+
* @default {null}
|
|
48
|
+
*/
|
|
49
|
+
retryAttempts?: number | null;
|
|
50
|
+
/**
|
|
51
|
+
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
52
|
+
* @default {null}
|
|
53
|
+
*/
|
|
54
|
+
backoffPolicy?: BackoffPolicy | null;
|
|
55
|
+
/**
|
|
56
|
+
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
57
|
+
* @default {null}
|
|
58
|
+
*/
|
|
59
|
+
retryPolicy?: RetryPolicy | null;
|
|
60
|
+
/**
|
|
61
|
+
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
62
|
+
* @default {null}
|
|
63
|
+
*/
|
|
64
|
+
timeout?: TimeSpan | null;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @group Derivables
|
|
68
|
+
*/
|
|
69
|
+
export declare class CacheFactory<TAdapters extends string = string> implements ICacheFactory<TAdapters> {
|
|
36
70
|
private readonly cacheRecord;
|
|
37
71
|
private readonly defaultAdapter?;
|
|
38
72
|
private readonly eventBus;
|
|
@@ -1485,6 +1485,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1485
1485
|
* // 3
|
|
1486
1486
|
* }
|
|
1487
1487
|
* ```
|
|
1488
|
+
* You can pass a function as default value.
|
|
1488
1489
|
* @example
|
|
1489
1490
|
* ```ts
|
|
1490
1491
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1493,10 +1494,11 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1493
1494
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1494
1495
|
* await collection
|
|
1495
1496
|
* .append([1, 2, 3, 4])
|
|
1496
|
-
* .firstOr(-1, item => item > 10);
|
|
1497
|
+
* .firstOr(() => -1, item => item > 10);
|
|
1497
1498
|
* // -1
|
|
1498
1499
|
* }
|
|
1499
1500
|
* ```
|
|
1501
|
+
* You can pass an async function as default value.
|
|
1500
1502
|
* @example
|
|
1501
1503
|
* ```ts
|
|
1502
1504
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1505,7 +1507,20 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1505
1507
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1506
1508
|
* await collection
|
|
1507
1509
|
* .append([1, 2, 3, 4])
|
|
1508
|
-
* .firstOr(() => -1, item => item > 10);
|
|
1510
|
+
* .firstOr(async () => -1, item => item > 10);
|
|
1511
|
+
* // -1
|
|
1512
|
+
* }
|
|
1513
|
+
* ```
|
|
1514
|
+
* You can pass a <i>{@link LazyPromise}</i> as default value.
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
1518
|
+
*
|
|
1519
|
+
* // Asume the inputed collection is empty.
|
|
1520
|
+
* async function main(collection: IAsyncCollection<number>, cache: ICache<number>): Promise<void> {
|
|
1521
|
+
* await collection
|
|
1522
|
+
* .append([1, 2, 3, 4])
|
|
1523
|
+
* .firstOr(cache.get("a"), item => item > 10);
|
|
1509
1524
|
* // -1
|
|
1510
1525
|
* }
|
|
1511
1526
|
* ```
|
|
@@ -1621,6 +1636,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1621
1636
|
* // 3
|
|
1622
1637
|
* }
|
|
1623
1638
|
* ```
|
|
1639
|
+
* You can pass a function as default value.
|
|
1624
1640
|
* @example
|
|
1625
1641
|
* ```ts
|
|
1626
1642
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1629,10 +1645,11 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1629
1645
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1630
1646
|
* await collection
|
|
1631
1647
|
* .append([1, 2, 3, 4])
|
|
1632
|
-
* .lastOr(-1, item => item > 10);
|
|
1648
|
+
* .lastOr(() => -1, item => item > 10);
|
|
1633
1649
|
* // -1
|
|
1634
1650
|
* }
|
|
1635
1651
|
* ```
|
|
1652
|
+
* You can pass an async function as default value.
|
|
1636
1653
|
* @example
|
|
1637
1654
|
* ```ts
|
|
1638
1655
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1641,7 +1658,20 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1641
1658
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1642
1659
|
* await collection
|
|
1643
1660
|
* .append([1, 2, 3, 4])
|
|
1644
|
-
* .lastOr(() => -1, item => item > 10);
|
|
1661
|
+
* .lastOr(async () => -1, item => item > 10);
|
|
1662
|
+
* // -1
|
|
1663
|
+
* }
|
|
1664
|
+
* ```
|
|
1665
|
+
* You can pass a <i>{@link LazyPromise}</i> as default value.
|
|
1666
|
+
* @example
|
|
1667
|
+
* ```ts
|
|
1668
|
+
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
1669
|
+
*
|
|
1670
|
+
* // Asume the inputed collection is empty.
|
|
1671
|
+
* async function main(collection: IAsyncCollection<number>, cache: ICache<number>): Promise<void> {
|
|
1672
|
+
* await collection
|
|
1673
|
+
* .append([1, 2, 3, 4])
|
|
1674
|
+
* .lastOr(cache.get("a"), item => item > 10);
|
|
1645
1675
|
* // -1
|
|
1646
1676
|
* }
|
|
1647
1677
|
* ```
|
|
@@ -1733,6 +1763,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1733
1763
|
* // 1
|
|
1734
1764
|
* }
|
|
1735
1765
|
* ```
|
|
1766
|
+
* You can pass a function as default value.
|
|
1736
1767
|
* @example
|
|
1737
1768
|
* ```ts
|
|
1738
1769
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1741,10 +1772,11 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1741
1772
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1742
1773
|
* await collection
|
|
1743
1774
|
* .append([1, 2, 3, 4])
|
|
1744
|
-
* .beforeOr(-1, item => item === 1);
|
|
1775
|
+
* .beforeOr(() => -1, item => item === 1);
|
|
1745
1776
|
* // -1
|
|
1746
1777
|
* }
|
|
1747
1778
|
* ```
|
|
1779
|
+
* You can pass an async function as default value.
|
|
1748
1780
|
* @example
|
|
1749
1781
|
* ```ts
|
|
1750
1782
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1753,7 +1785,20 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1753
1785
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1754
1786
|
* await collection
|
|
1755
1787
|
* .append([1, 2, 3, 4])
|
|
1756
|
-
* .beforeOr(() => -1, item => item === 1);
|
|
1788
|
+
* .beforeOr(async () => -1, item => item === 1);
|
|
1789
|
+
* // -1
|
|
1790
|
+
* }
|
|
1791
|
+
* ```
|
|
1792
|
+
* You can pass a <i>{@link LazyPromise}</i> as default value.
|
|
1793
|
+
* @example
|
|
1794
|
+
* ```ts
|
|
1795
|
+
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
1796
|
+
*
|
|
1797
|
+
* // Asume the inputed collection is empty.
|
|
1798
|
+
* async function main(collection: IAsyncCollection<number>, cache: ICache<number>): Promise<void> {
|
|
1799
|
+
* await collection
|
|
1800
|
+
* .append([1, 2, 3, 4])
|
|
1801
|
+
* .beforeOr(cache.get("a"), item => item > 10);
|
|
1757
1802
|
* // -1
|
|
1758
1803
|
* }
|
|
1759
1804
|
* ```
|
|
@@ -1833,6 +1878,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1833
1878
|
* // 3
|
|
1834
1879
|
* }
|
|
1835
1880
|
* ```
|
|
1881
|
+
* You can pass a function as default value.
|
|
1836
1882
|
* @example
|
|
1837
1883
|
* ```ts
|
|
1838
1884
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1841,10 +1887,11 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1841
1887
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1842
1888
|
* await collection
|
|
1843
1889
|
* .append([1, 2, 3, 4])
|
|
1844
|
-
* .afterOr(-1, item => item === 4);
|
|
1890
|
+
* .afterOr(() => -1, item => item === 4);
|
|
1845
1891
|
* // -1
|
|
1846
1892
|
* }
|
|
1847
1893
|
* ```
|
|
1894
|
+
* You can pass an async function as default value.
|
|
1848
1895
|
* @example
|
|
1849
1896
|
* ```ts
|
|
1850
1897
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1853,7 +1900,20 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1853
1900
|
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1854
1901
|
* await collection
|
|
1855
1902
|
* .append([1, 2, 3, 4])
|
|
1856
|
-
* .afterOr(() => -1, item => item === 4);
|
|
1903
|
+
* .afterOr(async () => -1, item => item === 4);
|
|
1904
|
+
* // -1
|
|
1905
|
+
* }
|
|
1906
|
+
* ```
|
|
1907
|
+
* You can pass a <i>{@link LazyPromise}</i> as default value.
|
|
1908
|
+
* @example
|
|
1909
|
+
* ```ts
|
|
1910
|
+
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
1911
|
+
*
|
|
1912
|
+
* // Asume the inputed collection is empty.
|
|
1913
|
+
* async function main(collection: IAsyncCollection<number>, cache: ICache<number>): Promise<void> {
|
|
1914
|
+
* await collection
|
|
1915
|
+
* .append([1, 2, 3, 4])
|
|
1916
|
+
* .afterOr(cache.get("a"), item => item > 10);
|
|
1857
1917
|
* // -1
|
|
1858
1918
|
* }
|
|
1859
1919
|
* ```
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
-
import type { ISerializable } from "../../serde/contracts/_module";
|
|
5
4
|
import type { Promisable } from "../../utilities/_module";
|
|
6
5
|
/**
|
|
7
6
|
* @group Contracts
|
|
@@ -10,7 +9,7 @@ export type Listener<TEvent> = (event: TEvent) => Promisable<void>;
|
|
|
10
9
|
/**
|
|
11
10
|
* @group Contracts
|
|
12
11
|
*/
|
|
13
|
-
export declare abstract class BaseEvent<
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export declare abstract class BaseEvent<TFields extends Record<string, unknown> = Record<string, unknown>> {
|
|
13
|
+
readonly fields: TFields;
|
|
14
|
+
constructor(fields: TFields);
|
|
16
15
|
}
|
|
@@ -5,7 +5,7 @@ import type { Listener } from "../../event-bus/contracts/_shared";
|
|
|
5
5
|
import type { BaseEvent } from "../../event-bus/contracts/_shared";
|
|
6
6
|
/**
|
|
7
7
|
* The <i>IEventBusAdapter</i> contract defines a way for dispatching and listening to events independent of underlying technology.
|
|
8
|
-
* This
|
|
8
|
+
* This contract is not meant to be used directly, instead you should use <i>IEventBus</i>
|
|
9
9
|
* @group Contracts
|
|
10
10
|
*/
|
|
11
11
|
export type IEventBusAdapter = {
|