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