@daiso-tech/core 0.26.1 → 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.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 +115 -371
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +198 -436
- 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,408 +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
|
|
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;
|
|
99
126
|
private readonly createOwnerId;
|
|
100
|
-
private readonly adapter;
|
|
101
127
|
private readonly defaultTtl;
|
|
102
128
|
private readonly defaultBlockingInterval;
|
|
103
129
|
private readonly defaultBlockingTime;
|
|
104
130
|
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;
|
|
131
|
+
private readonly serde;
|
|
112
132
|
/**
|
|
113
133
|
* @example
|
|
114
134
|
* ```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";
|
|
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";
|
|
122
138
|
*
|
|
123
|
-
* const
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
127
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
128
|
-
* serde,
|
|
129
|
-
* adapter: new MemoryLockAdapter({
|
|
130
|
-
* rootGroup: "@global"
|
|
131
|
-
* }),
|
|
132
|
-
* eventBus,
|
|
139
|
+
* const database = new Sqlite("local.db");
|
|
140
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
141
|
+
* database,
|
|
133
142
|
* });
|
|
134
|
-
*
|
|
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
|
-
*
|
|
141
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
142
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
143
|
-
* @example
|
|
144
|
-
* ```ts
|
|
145
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
146
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
147
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
148
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
149
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
150
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
151
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
152
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
143
|
+
* // You need initialize the adapter once before using it.
|
|
144
|
+
* await lockAdapter.init();
|
|
153
145
|
*
|
|
154
|
-
* const
|
|
155
|
-
*
|
|
146
|
+
* const lockProvider = new LockProvider({
|
|
147
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
148
|
+
* adapter: lockAdapter,
|
|
156
149
|
* });
|
|
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
150
|
* ```
|
|
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
151
|
*
|
|
178
|
-
*
|
|
179
|
-
* 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.
|
|
180
153
|
* @example
|
|
181
154
|
* ```ts
|
|
182
|
-
* import {
|
|
183
|
-
* import { LockProvider } from "@daiso-tech/core/lock
|
|
184
|
-
* import {
|
|
185
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
186
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
187
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
188
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
189
|
-
* 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";
|
|
190
158
|
*
|
|
191
|
-
* const
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
195
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
196
|
-
* serde,
|
|
197
|
-
* adapter: new MemoryLockAdapter({
|
|
198
|
-
* rootGroup: "@global"
|
|
199
|
-
* }),
|
|
200
|
-
* eventBus,
|
|
159
|
+
* const database = new Sqlite("local.db");
|
|
160
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
161
|
+
* database,
|
|
201
162
|
* });
|
|
163
|
+
* // You need initialize the adapter once before using it.
|
|
164
|
+
* await lockAdapter.init();
|
|
202
165
|
*
|
|
203
|
-
* const
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* await lockProvider.removeListenerMany([KeyAcquiredLockEvent], listener);
|
|
208
|
-
* await lockProvider.create("a").acquire();
|
|
166
|
+
* const lockProvider = new LockProvider({
|
|
167
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
168
|
+
* adapter: lockAdapter,
|
|
169
|
+
* });
|
|
209
170
|
* ```
|
|
210
|
-
*/
|
|
211
|
-
addListenerMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
212
|
-
/**
|
|
213
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
214
171
|
*
|
|
215
|
-
*
|
|
216
|
-
* 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.
|
|
217
173
|
* @example
|
|
218
174
|
* ```ts
|
|
219
|
-
* import {
|
|
220
|
-
* import {
|
|
221
|
-
* import {
|
|
222
|
-
* import type
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* adapter: new MemoryLockAdapter({
|
|
235
|
-
* rootGroup: "@global"
|
|
236
|
-
* }),
|
|
237
|
-
* eventBus,
|
|
238
|
-
* });
|
|
239
|
-
*
|
|
240
|
-
* const listener: Invokable<LockEvents> = event => {
|
|
241
|
-
* 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;
|
|
242
190
|
* }
|
|
243
|
-
* await lockProvider.addListener(KeyAcquiredLockEvent, listener);
|
|
244
|
-
* await lockProvider.removeListener(KeyAcquiredLockEvent, listener);
|
|
245
|
-
* await lockProvider.create("a").acquire();
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
251
191
|
*
|
|
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
192
|
*
|
|
265
|
-
* const
|
|
266
|
-
*
|
|
193
|
+
* const lockProvider = new LockProvider({
|
|
194
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
195
|
+
* adapter: lockAdapterFactory,
|
|
267
196
|
* });
|
|
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
197
|
* ```
|
|
284
|
-
*/
|
|
285
|
-
removeListenerMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
288
198
|
*
|
|
289
|
-
*
|
|
290
|
-
* 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.
|
|
291
200
|
* @example
|
|
292
201
|
* ```ts
|
|
293
|
-
* import {
|
|
294
|
-
* import {
|
|
295
|
-
* import {
|
|
296
|
-
* import type
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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
|
+
* }
|
|
301
220
|
*
|
|
302
|
-
* const
|
|
303
|
-
*
|
|
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,
|
|
221
|
+
* const lockProvider = new LockProvider({
|
|
222
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
223
|
+
* adapter: new LockAdapterFactory(),
|
|
312
224
|
* });
|
|
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
225
|
* ```
|
|
320
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>;
|
|
321
232
|
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
322
233
|
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
323
|
-
/**
|
|
324
|
-
* You can listen to different events of all locks created by <i>LockProvider</i> class instance.
|
|
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
|
-
* ```
|
|
358
|
-
*/
|
|
359
234
|
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
* ```
|
|
395
|
-
*/
|
|
396
|
-
subscribeMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
397
|
-
/**
|
|
398
|
-
* ```ts
|
|
399
|
-
* import type { IGroupableLockProvider } from "@daiso-tech/core/lock/contracts";
|
|
400
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
401
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
402
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
403
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
404
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
405
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
406
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
407
|
-
*
|
|
408
|
-
* const eventBus = new EventBus({
|
|
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,
|
|
418
|
-
* });
|
|
419
|
-
*
|
|
420
|
-
* // You can use the lock
|
|
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
|
-
* });
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
235
|
+
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
236
|
+
private createLazyPromise;
|
|
434
237
|
create(key: OneOrMore<string>, settings?: LockProviderCreateSettings): ILock;
|
|
435
|
-
|
|
436
|
-
* @example
|
|
437
|
-
* ```ts
|
|
438
|
-
* import type { IGroupableLockProvider } from "@daiso-tech/core/lock/contracts";
|
|
439
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
440
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
441
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
442
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
443
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
444
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
445
|
-
*
|
|
446
|
-
* const eventBus = new EventBus({
|
|
447
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
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,
|
|
456
|
-
* });
|
|
457
|
-
*
|
|
458
|
-
* // Will print "@global"
|
|
459
|
-
* console.log(lockProvider.getGroup());
|
|
460
|
-
* ```
|
|
461
|
-
*/
|
|
462
|
-
getGroup(): string;
|
|
463
|
-
/**
|
|
464
|
-
* @example
|
|
465
|
-
* ```ts
|
|
466
|
-
* import type { IGroupableLockProvider, ILockProvider } from "@daiso-tech/core/lock/contracts";
|
|
467
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
468
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
469
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
470
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
471
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
472
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
473
|
-
*
|
|
474
|
-
* const eventBus = new EventBus({
|
|
475
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
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,
|
|
484
|
-
* });
|
|
485
|
-
*
|
|
486
|
-
* // Will print "@global"
|
|
487
|
-
* console.log(lockProvider.getGroup());
|
|
488
|
-
*
|
|
489
|
-
* const groupedLockProvider: ILockProvider = lockProvider.withGroup("company-1");
|
|
490
|
-
*
|
|
491
|
-
* // Will print "@global/company-1"
|
|
492
|
-
* console.log(groupedLockProvider.getGroup());
|
|
493
|
-
* ```
|
|
494
|
-
*/
|
|
238
|
+
getGroup(): string | null;
|
|
495
239
|
withGroup(group: OneOrMore<string>): ILockProvider;
|
|
496
240
|
}
|