@daiso-tech/core 0.26.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/async/utilities/delay/delay.d.ts +1 -12
- package/dist/async/utilities/delay/delay.js +1 -12
- package/dist/async/utilities/delay/delay.js.map +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +143 -71
- package/dist/async/utilities/lazy-promise/lazy-promise.js +223 -142
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +2 -0
- package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
- package/dist/cache/contracts/_module-exports.d.ts +1 -0
- package/dist/cache/contracts/_module-exports.js +1 -0
- package/dist/cache/contracts/_module-exports.js.map +1 -1
- package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
- package/dist/cache/contracts/cache-adapter.contract.js +1 -4
- package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +144 -96
- package/dist/cache/contracts/cache.contract.js +1 -2
- package/dist/cache/contracts/cache.contract.js.map +1 -1
- package/dist/cache/contracts/cache.errors.js +2 -5
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +10 -10
- package/dist/cache/contracts/cache.events.js +2 -5
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
- package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +14 -13
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +19 -17
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -41
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +269 -507
- package/dist/cache/implementations/derivables/cache/cache.js +538 -822
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +69 -105
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +117 -87
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
- package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
- package/dist/collection/contracts/async-collection.contract.js +1 -12
- package/dist/collection/contracts/async-collection.contract.js.map +1 -1
- package/dist/collection/contracts/collection.contract.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.js +3 -6
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/collection/implementations/_shared.d.ts +4 -4
- package/dist/collection/implementations/_shared.js +6 -9
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +5 -21
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +12 -8
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
- package/dist/collection/implementations/list-collection/list-collection.js +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
- package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.js +2 -5
- package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -4
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -8
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +85 -289
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +128 -325
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +103 -86
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +135 -77
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -48
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-provider.contract.d.ts +20 -6
- package/dist/lock/contracts/lock.contract.d.ts +37 -8
- package/dist/lock/contracts/lock.errors.js +2 -5
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.js +2 -5
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.d.ts +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js +2 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js.map +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +17 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +24 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +14 -20
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +1 -5
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +181 -369
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +259 -407
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +15 -17
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +194 -680
- package/dist/lock/implementations/derivables/lock-provider/lock.js +284 -744
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +106 -143
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +173 -101
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +295 -145
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +3 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +14 -14
- package/dist/serde/implementations/derivables/serde.js +14 -15
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
- package/dist/utilities/_module-exports.d.ts +2 -3
- package/dist/utilities/_module-exports.js +2 -3
- package/dist/utilities/_module-exports.js.map +1 -1
- package/dist/utilities/classes/_module.d.ts +4 -0
- package/dist/utilities/classes/_module.js +5 -0
- package/dist/utilities/classes/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
- package/dist/utilities/classes/key-prefixer/_module.js +3 -0
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
- package/dist/utilities/classes/pipeline/_module.js +2 -0
- package/dist/utilities/classes/pipeline/_module.js.map +1 -0
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
- package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
- package/dist/utilities/classes/time-span/_module.d.ts +1 -0
- package/dist/utilities/classes/time-span/_module.js +2 -0
- package/dist/utilities/classes/time-span/_module.js.map +1 -0
- package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
- package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
- package/dist/utilities/classes/time-span/time-span.js.map +1 -0
- package/dist/utilities/{_constants.d.ts → constants.d.ts} +0 -3
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +3 -1
- package/dist/utilities/contracts/_module.js +3 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
- package/dist/utilities/contracts/prunable.contract.js +5 -0
- package/dist/utilities/contracts/prunable.contract.js.map +1 -0
- package/dist/utilities/contracts/sqlite-database.contract.d.ts +26 -0
- package/dist/utilities/contracts/sqlite-database.contract.js +5 -0
- package/dist/utilities/contracts/sqlite-database.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +34 -2
- package/dist/utilities/functions.js +72 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +49 -16
- package/package.json +14 -13
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
- package/dist/utilities/_constants.js +0 -8
- package/dist/utilities/_constants.js.map +0 -1
- package/dist/utilities/kysely/_module.d.ts +0 -1
- package/dist/utilities/kysely/_module.js +0 -2
- package/dist/utilities/kysely/_module.js.map +0 -1
- package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
- package/dist/utilities/pipeline/_module.d.ts +0 -1
- package/dist/utilities/pipeline/_module.js +0 -2
- package/dist/utilities/pipeline/_module.js.map +0 -1
- package/dist/utilities/pipeline/pipeline.js.map +0 -1
- package/dist/utilities/time-span/_module.d.ts +0 -1
- package/dist/utilities/time-span/_module.js +0 -2
- package/dist/utilities/time-span/_module.js.map +0 -1
- package/dist/utilities/time-span/time-span.js.map +0 -1
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Lock
|
|
3
3
|
*/
|
|
4
|
-
import { TimeSpan, type
|
|
4
|
+
import { TimeSpan, type Factoryable, type IKeyPrefixer, type Items } from "../../../../utilities/_module-exports.js";
|
|
5
|
+
import { type Invokable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
5
6
|
import type { IDatabaseLockAdapter, LockEvents } from "../../../../lock/contracts/_module-exports.js";
|
|
6
7
|
import { type ILock, type IGroupableLockProvider, type LockProviderCreateSettings, type ILockProvider, type ILockAdapter } from "../../../../lock/contracts/_module-exports.js";
|
|
7
|
-
import
|
|
8
|
+
import { LazyPromise, type LazyPromiseSettingsBase } from "../../../../async/_module-exports.js";
|
|
8
9
|
import type { EventClass, EventInstance, IGroupableEventBus, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
9
10
|
import type { IFlexibleSerde } from "../../../../serde/contracts/_module-exports.js";
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
12
|
-
* IMPORT_PATH: ```"@daiso-tech/core/lock
|
|
13
|
+
* IMPORT_PATH: ```"@daiso-tech/core/lock"```
|
|
13
14
|
* @group Derivables
|
|
14
15
|
*/
|
|
15
|
-
export type
|
|
16
|
+
export type LockProviderSettingsBase = LazyPromiseSettingsBase & {
|
|
17
|
+
keyPrefixer: IKeyPrefixer;
|
|
18
|
+
serde: OneOrMore<IFlexibleSerde>;
|
|
16
19
|
/**
|
|
17
20
|
* You can pass your owner id generator function.
|
|
18
21
|
*/
|
|
19
22
|
createOwnerId?: () => string;
|
|
20
|
-
adapter: ILockAdapter | IDatabaseLockAdapter;
|
|
21
|
-
serde: OneOrMore<IFlexibleSerde>;
|
|
22
23
|
/**
|
|
23
24
|
* @default
|
|
24
25
|
* ```ts
|
|
26
|
+
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
27
|
+
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
28
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
29
|
+
*
|
|
25
30
|
* new EventBus({
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* })
|
|
31
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
32
|
+
* adapter: new MemoryEventBusAdapter()
|
|
29
33
|
* })
|
|
30
34
|
* ```
|
|
31
35
|
*/
|
|
@@ -55,32 +59,26 @@ export type LockProviderSettings = {
|
|
|
55
59
|
*/
|
|
56
60
|
defaultBlockingTime?: TimeSpan;
|
|
57
61
|
/**
|
|
58
|
-
* The default refresh time used in the <i>{@link ILock}</i> <i>
|
|
62
|
+
* The default refresh time used in the <i>{@link ILock}</i> <i>referesh</i> method.
|
|
59
63
|
* ```ts
|
|
60
64
|
* TimeSpan.fromMinutes(5);
|
|
61
65
|
* ```
|
|
62
66
|
*/
|
|
63
67
|
defaultRefreshTime?: TimeSpan;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
retryPolicy?: RetryPolicy | null;
|
|
79
|
-
/**
|
|
80
|
-
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
81
|
-
* @default {null}
|
|
82
|
-
*/
|
|
83
|
-
timeout?: TimeSpan | null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* IMPORT_PATH: ```"@daiso-tech/core/lock"```
|
|
72
|
+
* @group Derivables
|
|
73
|
+
*/
|
|
74
|
+
export type LockAdapterFactoryable = Factoryable<string, ILockAdapter | IDatabaseLockAdapter>;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* IMPORT_PATH: ```"@daiso-tech/core/lock"```
|
|
78
|
+
* @group Derivables
|
|
79
|
+
*/
|
|
80
|
+
export type LockProviderSettings = LockProviderSettingsBase & {
|
|
81
|
+
adapter: LockAdapterFactoryable;
|
|
84
82
|
};
|
|
85
83
|
/**
|
|
86
84
|
* <i>LockProvider</i> class can be derived from any <i>{@link ILockAdapter}</i> or <i>{@link IDatabaseLockAdapter}</i>.
|
|
@@ -89,407 +87,221 @@ export type LockProviderSettings = {
|
|
|
89
87
|
* allowing them to be seamlessly transferred across different servers, processes, and databases.
|
|
90
88
|
* This can be done directly using <i>{@link IFlexibleSerde}</i> or indirectly through components that rely on <i>{@link IFlexibleSerde}</i> internally.
|
|
91
89
|
*
|
|
92
|
-
* IMPORT_PATH: ```"@daiso-tech/core/lock
|
|
90
|
+
* IMPORT_PATH: ```"@daiso-tech/core/lock"```
|
|
93
91
|
* @group Derivables
|
|
94
92
|
*/
|
|
95
93
|
export declare class LockProvider implements IGroupableLockProvider {
|
|
96
|
-
private static
|
|
97
|
-
private static
|
|
98
|
-
private
|
|
94
|
+
private static resolveLockAdapter;
|
|
95
|
+
private static resolveLockAdapterFactoryable;
|
|
96
|
+
private lockStore;
|
|
97
|
+
private readonly groupableEventBus;
|
|
98
|
+
private readonly eventBus;
|
|
99
|
+
private readonly adapterFactoryable;
|
|
100
|
+
private readonly adapterPromise;
|
|
101
|
+
private readonly retryAttempts;
|
|
102
|
+
private readonly backoffPolicy;
|
|
103
|
+
private readonly retryPolicy;
|
|
104
|
+
private readonly retryTimeout;
|
|
105
|
+
private readonly totalTimeout;
|
|
106
|
+
private readonly keyPrefixer;
|
|
99
107
|
private readonly createOwnerId;
|
|
100
|
-
private readonly adapter;
|
|
101
108
|
private readonly defaultTtl;
|
|
102
109
|
private readonly defaultBlockingInterval;
|
|
103
110
|
private readonly defaultBlockingTime;
|
|
104
111
|
private readonly defaultRefreshTime;
|
|
105
|
-
private readonly
|
|
106
|
-
private readonly backoffPolicy;
|
|
107
|
-
private readonly retryPolicy;
|
|
108
|
-
private readonly timeout;
|
|
109
|
-
private readonly eventBus;
|
|
110
|
-
private readonly lockProviderEventBus;
|
|
111
|
-
private stateRecord;
|
|
112
|
+
private readonly serde;
|
|
112
113
|
/**
|
|
113
114
|
* @example
|
|
114
115
|
* ```ts
|
|
115
|
-
* import
|
|
116
|
-
* import { LockProvider } from "@daiso-tech/core/lock
|
|
117
|
-
* import {
|
|
118
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
119
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
120
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
121
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
116
|
+
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
117
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
118
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
122
119
|
*
|
|
123
|
-
* const
|
|
124
|
-
*
|
|
120
|
+
* const database = new Sqlite("local.db");
|
|
121
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
122
|
+
* database,
|
|
125
123
|
* });
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* eventBus,
|
|
124
|
+
* // You need initialize the adapter once before using it.
|
|
125
|
+
* await lockAdapter.init();
|
|
126
|
+
*
|
|
127
|
+
* const lockProvider = new LockProvider({
|
|
128
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
129
|
+
* adapter: lockAdapter,
|
|
133
130
|
* });
|
|
134
131
|
* ```
|
|
135
|
-
*/
|
|
136
|
-
constructor(settings: LockProviderSettings);
|
|
137
|
-
private registerToSerde;
|
|
138
|
-
/**
|
|
139
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
140
132
|
*
|
|
141
|
-
*
|
|
142
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
133
|
+
* You can pass factory function that will create an adapter for every group.
|
|
143
134
|
* @example
|
|
144
135
|
* ```ts
|
|
145
|
-
* import {
|
|
146
|
-
* import {
|
|
147
|
-
* import {
|
|
148
|
-
* import type
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
136
|
+
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
137
|
+
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
138
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
139
|
+
* import { KeyPrefixer, type ISqliteDatabase, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
140
|
+
*
|
|
141
|
+
* async function lockAdapterFactory(database: ISqliteDatabase): FactoryFn<string, ILockAdapter> {
|
|
142
|
+
* return async (prefix) => {
|
|
143
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
144
|
+
* database,
|
|
145
|
+
* tableName: `lock_${prefix}`,
|
|
146
|
+
* });
|
|
147
|
+
* // You need initialize the adapter once before using it.
|
|
148
|
+
* await lockAdapter.init();
|
|
149
|
+
* return lockAdapter;
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
153
152
|
*
|
|
154
|
-
* const
|
|
155
|
-
*
|
|
153
|
+
* const database = new Sqlite("local.db");
|
|
154
|
+
* const lockProvider = new LockProvider({
|
|
155
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
156
|
+
* adapter: lockAdapterFactory(database),
|
|
156
157
|
* });
|
|
157
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
158
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
159
|
-
* serde,
|
|
160
|
-
* adapter: new MemoryLockAdapter({
|
|
161
|
-
* rootGroup: "@global"
|
|
162
|
-
* }),
|
|
163
|
-
* eventBus,
|
|
164
|
-
* });
|
|
165
|
-
*
|
|
166
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
167
|
-
* console.log(event);
|
|
168
|
-
* }
|
|
169
|
-
* await lockProvider.addListener(KeyAcquiredLockEvent, listener);
|
|
170
|
-
* await lockProvider.removeListener(KeyAcquiredLockEvent, listener);
|
|
171
|
-
* await lockProvider.create("a").acquire();
|
|
172
158
|
* ```
|
|
173
|
-
*/
|
|
174
|
-
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
175
|
-
/**
|
|
176
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
177
159
|
*
|
|
178
|
-
*
|
|
179
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
160
|
+
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
180
161
|
* @example
|
|
181
162
|
* ```ts
|
|
182
|
-
* import {
|
|
183
|
-
* import {
|
|
184
|
-
* import {
|
|
185
|
-
* import type
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
163
|
+
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
164
|
+
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
165
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
166
|
+
* import { KeyPrefixer, type ISqliteDatabase, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
167
|
+
*
|
|
168
|
+
* class LockAdapterFactory implements IFactoryObject<string, ILockAdapter> {
|
|
169
|
+
* constructor(private readonly database: ISqliteDatabase) {}
|
|
170
|
+
*
|
|
171
|
+
* async use(prefix: string): Promiseable<ILockAdapter> {
|
|
172
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
173
|
+
* database,
|
|
174
|
+
* tableName: `lock_${prefix}`,
|
|
175
|
+
* });
|
|
176
|
+
* // You need initialize the adapter once before using it.
|
|
177
|
+
* await lockAdapter.init();
|
|
178
|
+
* return lockAdapter;
|
|
179
|
+
* }
|
|
180
|
+
* }
|
|
190
181
|
*
|
|
191
|
-
* const
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
196
|
-
* serde,
|
|
197
|
-
* adapter: new MemoryLockAdapter({
|
|
198
|
-
* rootGroup: "@global"
|
|
199
|
-
* }),
|
|
200
|
-
* eventBus,
|
|
182
|
+
* const database = new Sqlite("local.db");
|
|
183
|
+
* const lockProvider = new LockProvider({
|
|
184
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
185
|
+
* adapter: new LockAdapterFactory(database),
|
|
201
186
|
* });
|
|
202
|
-
*
|
|
203
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
204
|
-
* console.log(event);
|
|
205
|
-
* }
|
|
206
|
-
* await lockProvider.addListenerMany([KeyAcquiredLockEvent], listener);
|
|
207
|
-
* await lockProvider.removeListenerMany([KeyAcquiredLockEvent], listener);
|
|
208
|
-
* await lockProvider.create("a").acquire();
|
|
209
187
|
* ```
|
|
210
188
|
*/
|
|
211
|
-
|
|
189
|
+
constructor(settings: LockProviderSettings);
|
|
212
190
|
/**
|
|
213
|
-
* You can listen to
|
|
214
|
-
*
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
226
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
227
|
-
*
|
|
228
|
-
* const eventBus = new EventBus({
|
|
229
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
230
|
-
* });
|
|
231
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
232
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
233
|
-
* serde,
|
|
234
|
-
* adapter: new MemoryLockAdapter({
|
|
235
|
-
* rootGroup: "@global"
|
|
236
|
-
* }),
|
|
237
|
-
* eventBus,
|
|
238
|
-
* });
|
|
239
|
-
*
|
|
240
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
241
|
-
* console.log(event);
|
|
242
|
-
* }
|
|
243
|
-
* await lockProvider.addListener(KeyAcquiredLockEvent, listener);
|
|
244
|
-
* await lockProvider.removeListener(KeyAcquiredLockEvent, listener);
|
|
245
|
-
* await lockProvider.create("a").acquire();
|
|
246
|
-
* ```
|
|
191
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
192
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
193
|
+
*/
|
|
194
|
+
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
197
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
198
|
+
*/
|
|
199
|
+
addListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
202
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
247
203
|
*/
|
|
248
204
|
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
249
205
|
/**
|
|
250
|
-
* You can listen to
|
|
251
|
-
*
|
|
252
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
253
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
257
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
258
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
259
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
260
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
261
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
262
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
263
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
264
|
-
*
|
|
265
|
-
* const eventBus = new EventBus({
|
|
266
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
267
|
-
* });
|
|
268
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
269
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
270
|
-
* serde,
|
|
271
|
-
* adapter: new MemoryLockAdapter({
|
|
272
|
-
* rootGroup: "@global"
|
|
273
|
-
* }),
|
|
274
|
-
* eventBus,
|
|
275
|
-
* });
|
|
276
|
-
*
|
|
277
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
278
|
-
* console.log(event);
|
|
279
|
-
* }
|
|
280
|
-
* await lockProvider.addListenerMany(KeyAcquiredLockEvent, listener);
|
|
281
|
-
* await lockProvider.removeListenerMany([KeyAcquiredLockEvent], listener);
|
|
282
|
-
* await lockProvider.create("a").acquire();
|
|
283
|
-
* ```
|
|
206
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
207
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
284
208
|
*/
|
|
285
|
-
removeListenerMany<
|
|
209
|
+
removeListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
286
210
|
/**
|
|
287
|
-
* You can listen to
|
|
288
|
-
*
|
|
289
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
290
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
291
|
-
* @example
|
|
292
|
-
* ```ts
|
|
293
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
294
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
295
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
296
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
297
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
298
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
299
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
300
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
301
|
-
*
|
|
302
|
-
* const eventBus = new EventBus({
|
|
303
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
304
|
-
* });
|
|
305
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
306
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
307
|
-
* serde,
|
|
308
|
-
* adapter: new MemoryLockAdapter({
|
|
309
|
-
* rootGroup: "@global"
|
|
310
|
-
* }),
|
|
311
|
-
* eventBus,
|
|
312
|
-
* });
|
|
313
|
-
*
|
|
314
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
315
|
-
* console.log(event);
|
|
316
|
-
* }
|
|
317
|
-
* await lockProvider.listenOnce(KeyAcquiredLockEvent, listener);
|
|
318
|
-
* await lockProvider.create("a").acquire();
|
|
319
|
-
* ```
|
|
211
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
212
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
320
213
|
*/
|
|
321
214
|
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
217
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
218
|
+
*/
|
|
322
219
|
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
323
220
|
/**
|
|
324
|
-
* You can listen to
|
|
325
|
-
*
|
|
326
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
327
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
328
|
-
* @example
|
|
329
|
-
* ```ts
|
|
330
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
331
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
332
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
333
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
334
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
335
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
336
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
337
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
338
|
-
*
|
|
339
|
-
* const eventBus = new EventBus({
|
|
340
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
341
|
-
* });
|
|
342
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
343
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
344
|
-
* serde,
|
|
345
|
-
* adapter: new MemoryLockAdapter({
|
|
346
|
-
* rootGroup: "@global"
|
|
347
|
-
* }),
|
|
348
|
-
* eventBus,
|
|
349
|
-
* });
|
|
350
|
-
*
|
|
351
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
352
|
-
* console.log(event);
|
|
353
|
-
* }
|
|
354
|
-
* const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, listener);
|
|
355
|
-
* await lockProvider.create("a").acquire();
|
|
356
|
-
* await unsubscribe();
|
|
357
|
-
* ```
|
|
221
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
222
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
358
223
|
*/
|
|
359
224
|
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
360
225
|
/**
|
|
361
|
-
* You can listen to
|
|
362
|
-
*
|
|
363
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
364
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
365
|
-
* @example
|
|
366
|
-
* ```ts
|
|
367
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
368
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
369
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
370
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
371
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
372
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
373
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
374
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
375
|
-
*
|
|
376
|
-
* const eventBus = new EventBus({
|
|
377
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
378
|
-
* });
|
|
379
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
380
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
381
|
-
* serde,
|
|
382
|
-
* adapter: new MemoryLockAdapter({
|
|
383
|
-
* rootGroup: "@global"
|
|
384
|
-
* }),
|
|
385
|
-
* eventBus,
|
|
386
|
-
* });
|
|
387
|
-
*
|
|
388
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
389
|
-
* console.log(event);
|
|
390
|
-
* }
|
|
391
|
-
* const unsubscribe = await lockProvider.subscribeMany([KeyAcquiredLockEvent], listener);
|
|
392
|
-
* await lockProvider.create("a").acquire();
|
|
393
|
-
* await unsubscribe();
|
|
394
|
-
* ```
|
|
226
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
227
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
395
228
|
*/
|
|
396
|
-
subscribeMany<
|
|
229
|
+
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
230
|
+
private createLazyPromise;
|
|
397
231
|
/**
|
|
232
|
+
* @example
|
|
398
233
|
* ```ts
|
|
399
|
-
* import
|
|
400
|
-
* import {
|
|
401
|
-
* import {
|
|
402
|
-
* import {
|
|
403
|
-
* import {
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
410
|
-
* });
|
|
411
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
412
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
413
|
-
* serde,
|
|
414
|
-
* adapter: new MemoryLockAdapter({
|
|
415
|
-
* rootGroup: "@global"
|
|
416
|
-
* }),
|
|
417
|
-
* eventBus,
|
|
234
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
235
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
236
|
+
* import { KeyPrefixer, TimeSpan } from "@daiso-tech/core/utilities";
|
|
237
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
238
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
239
|
+
*
|
|
240
|
+
* const lockProvider = new LockProvider({
|
|
241
|
+
* adapter: new MemoryLockAdapter(),
|
|
242
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
243
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
418
244
|
* });
|
|
419
245
|
*
|
|
420
|
-
*
|
|
421
|
-
* const lockA = lockProvider.create("a");
|
|
422
|
-
*
|
|
423
|
-
* // You can provide ttl
|
|
424
|
-
* const lockB = lockProvider.create("b", {
|
|
425
|
-
* ttl: TimeSpan.fromMinutes(2),
|
|
426
|
-
* });
|
|
427
|
-
*
|
|
428
|
-
* // You can provide a custom owner. By default the owner will be unique random value.
|
|
429
|
-
* const lockC = lockProvider.create("b", {
|
|
430
|
-
* owner: "user-1"
|
|
431
|
-
* });
|
|
246
|
+
* const lock = lockProvider.create("a");
|
|
432
247
|
* ```
|
|
433
248
|
*/
|
|
434
249
|
create(key: OneOrMore<string>, settings?: LockProviderCreateSettings): ILock;
|
|
435
250
|
/**
|
|
436
251
|
* @example
|
|
437
252
|
* ```ts
|
|
438
|
-
* import
|
|
439
|
-
* import {
|
|
440
|
-
* import {
|
|
441
|
-
* import {
|
|
442
|
-
* import {
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* });
|
|
449
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
450
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
451
|
-
* serde,
|
|
452
|
-
* adapter: new MemoryLockAdapter({
|
|
453
|
-
* rootGroup: "@global"
|
|
454
|
-
* }),
|
|
455
|
-
* eventBus,
|
|
253
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
254
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
255
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
256
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
257
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
258
|
+
*
|
|
259
|
+
* const lockProvider = new LockProvider({
|
|
260
|
+
* adapter: new MemoryLockAdapter(),
|
|
261
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
262
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
456
263
|
* });
|
|
457
264
|
*
|
|
458
|
-
* // Will
|
|
265
|
+
* // Will log null because the lockProvider is not in a group
|
|
459
266
|
* console.log(lockProvider.getGroup());
|
|
267
|
+
*
|
|
268
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
269
|
+
*
|
|
270
|
+
* // Will log "group-a" because the groupedLockProvider is in a group
|
|
271
|
+
* console.log(groupedLockProvider.getGroup());
|
|
460
272
|
* ```
|
|
461
273
|
*/
|
|
462
|
-
getGroup(): string;
|
|
274
|
+
getGroup(): string | null;
|
|
463
275
|
/**
|
|
464
276
|
* @example
|
|
465
277
|
* ```ts
|
|
466
|
-
* import
|
|
467
|
-
* import {
|
|
468
|
-
* import {
|
|
469
|
-
* import {
|
|
470
|
-
* import {
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* });
|
|
477
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
478
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
479
|
-
* serde,
|
|
480
|
-
* adapter: new MemoryLockAdapter({
|
|
481
|
-
* rootGroup: "@global"
|
|
482
|
-
* }),
|
|
483
|
-
* eventBus,
|
|
278
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
279
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
280
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
281
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
282
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
283
|
+
*
|
|
284
|
+
* const lockProvider = new LockProvider({
|
|
285
|
+
* adapter: new MemoryLockAdapter(),
|
|
286
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
287
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
484
288
|
* });
|
|
485
289
|
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
290
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
291
|
+
*
|
|
292
|
+
* // Will log true because they are in different groups.
|
|
293
|
+
* console.log(
|
|
294
|
+
* await lockProvider
|
|
295
|
+
* .create("a")
|
|
296
|
+
* .acquire()
|
|
297
|
+
* );
|
|
298
|
+
*
|
|
299
|
+
* // Will log true because the lockProviders are in different groups.
|
|
300
|
+
* console.log(
|
|
301
|
+
* await groupedLockProvider
|
|
302
|
+
* .create("a")
|
|
303
|
+
* .acquire()
|
|
304
|
+
* );
|
|
493
305
|
* ```
|
|
494
306
|
*/
|
|
495
307
|
withGroup(group: OneOrMore<string>): ILockProvider;
|