@daiso-tech/core 0.26.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/async/utilities/delay/delay.d.ts +1 -12
- package/dist/async/utilities/delay/delay.js +1 -12
- package/dist/async/utilities/delay/delay.js.map +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +143 -71
- package/dist/async/utilities/lazy-promise/lazy-promise.js +223 -142
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +2 -0
- package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
- package/dist/cache/contracts/_module-exports.d.ts +1 -0
- package/dist/cache/contracts/_module-exports.js +1 -0
- package/dist/cache/contracts/_module-exports.js.map +1 -1
- package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
- package/dist/cache/contracts/cache-adapter.contract.js +1 -4
- package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +144 -96
- package/dist/cache/contracts/cache.contract.js +1 -2
- package/dist/cache/contracts/cache.contract.js.map +1 -1
- package/dist/cache/contracts/cache.errors.js +2 -5
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +10 -10
- package/dist/cache/contracts/cache.events.js +2 -5
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
- package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +14 -13
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +19 -17
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -41
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +269 -507
- package/dist/cache/implementations/derivables/cache/cache.js +538 -822
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +69 -105
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +117 -87
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
- package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
- package/dist/collection/contracts/async-collection.contract.js +1 -12
- package/dist/collection/contracts/async-collection.contract.js.map +1 -1
- package/dist/collection/contracts/collection.contract.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.js +3 -6
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/collection/implementations/_shared.d.ts +4 -4
- package/dist/collection/implementations/_shared.js +6 -9
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +5 -21
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +12 -8
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
- package/dist/collection/implementations/list-collection/list-collection.js +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
- package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.js +2 -5
- package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -4
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -8
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +85 -289
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +128 -325
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +103 -86
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +135 -77
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -48
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-provider.contract.d.ts +20 -6
- package/dist/lock/contracts/lock.contract.d.ts +37 -8
- package/dist/lock/contracts/lock.errors.js +2 -5
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.js +2 -5
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.d.ts +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js +2 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js.map +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +17 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +24 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +14 -20
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +1 -5
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +181 -369
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +259 -407
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +15 -17
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +194 -680
- package/dist/lock/implementations/derivables/lock-provider/lock.js +284 -744
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +106 -143
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +173 -101
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +295 -145
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +3 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +14 -14
- package/dist/serde/implementations/derivables/serde.js +14 -15
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
- package/dist/utilities/_module-exports.d.ts +2 -3
- package/dist/utilities/_module-exports.js +2 -3
- package/dist/utilities/_module-exports.js.map +1 -1
- package/dist/utilities/classes/_module.d.ts +4 -0
- package/dist/utilities/classes/_module.js +5 -0
- package/dist/utilities/classes/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
- package/dist/utilities/classes/key-prefixer/_module.js +3 -0
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
- package/dist/utilities/classes/pipeline/_module.js +2 -0
- package/dist/utilities/classes/pipeline/_module.js.map +1 -0
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
- package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
- package/dist/utilities/classes/time-span/_module.d.ts +1 -0
- package/dist/utilities/classes/time-span/_module.js +2 -0
- package/dist/utilities/classes/time-span/_module.js.map +1 -0
- package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
- package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
- package/dist/utilities/classes/time-span/time-span.js.map +1 -0
- package/dist/utilities/{_constants.d.ts → constants.d.ts} +0 -3
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +3 -1
- package/dist/utilities/contracts/_module.js +3 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
- package/dist/utilities/contracts/prunable.contract.js +5 -0
- package/dist/utilities/contracts/prunable.contract.js.map +1 -0
- package/dist/utilities/contracts/sqlite-database.contract.d.ts +26 -0
- package/dist/utilities/contracts/sqlite-database.contract.js +5 -0
- package/dist/utilities/contracts/sqlite-database.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +34 -2
- package/dist/utilities/functions.js +72 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +49 -16
- package/package.json +14 -13
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
- package/dist/utilities/_constants.js +0 -8
- package/dist/utilities/_constants.js.map +0 -1
- package/dist/utilities/kysely/_module.d.ts +0 -1
- package/dist/utilities/kysely/_module.js +0 -2
- package/dist/utilities/kysely/_module.js.map +0 -1
- package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
- package/dist/utilities/pipeline/_module.d.ts +0 -1
- package/dist/utilities/pipeline/_module.js +0 -2
- package/dist/utilities/pipeline/_module.js.map +0 -1
- package/dist/utilities/pipeline/pipeline.js.map +0 -1
- package/dist/utilities/time-span/_module.d.ts +0 -1
- package/dist/utilities/time-span/_module.js +0 -2
- package/dist/utilities/time-span/_module.js.map +0 -1
- package/dist/utilities/time-span/time-span.js.map +0 -1
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
|
@@ -2,137 +2,154 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module-exports.js";
|
|
5
|
-
import { type
|
|
6
|
-
import type
|
|
7
|
-
import type {
|
|
5
|
+
import { type IGroupableEventBus, type IEventBusFactory, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
+
import { type EventBusAdapterFactoryable, type EventBusSettingsBase } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
7
|
+
import type { KeyPrefixer, TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus
|
|
10
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
|
-
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters,
|
|
13
|
+
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, EventBusAdapterFactoryable>>;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus
|
|
16
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
17
17
|
* @group Derivables
|
|
18
18
|
*/
|
|
19
|
-
export type EventBusFactorySettings<TAdapters extends string = string> = {
|
|
20
|
-
/**
|
|
21
|
-
* You can pass one or more <i>{@link IFlexibleSerde}</i> that will be used to register all <i>{@link IGroupableEventBus}</i> related errors.
|
|
22
|
-
* @default {true}
|
|
23
|
-
*/
|
|
24
|
-
serde: OneOrMore<IFlexibleSerde>;
|
|
25
|
-
/**
|
|
26
|
-
* If set to true, all <i>{@link IGroupableEventBus}</i> related errors will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
27
|
-
* This ensures that all <i>{@link IGroupableEventBus}</i> related errors will be serialized correctly.
|
|
28
|
-
* @default {true}
|
|
29
|
-
*/
|
|
30
|
-
shouldRegisterErrors?: boolean;
|
|
19
|
+
export type EventBusFactorySettings<TAdapters extends string = string> = EventBusSettingsBase & {
|
|
31
20
|
adapters: EventBusAdapters<TAdapters>;
|
|
32
21
|
defaultAdapter?: NoInfer<TAdapters>;
|
|
33
|
-
/**
|
|
34
|
-
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
35
|
-
*/
|
|
36
|
-
eventBus?: IGroupableEventBus<any>;
|
|
37
|
-
/**
|
|
38
|
-
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
39
|
-
* @default {null}
|
|
40
|
-
*/
|
|
41
|
-
retryAttempts?: number | null;
|
|
42
|
-
/**
|
|
43
|
-
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
44
|
-
* @default {null}
|
|
45
|
-
*/
|
|
46
|
-
backoffPolicy?: BackoffPolicy | null;
|
|
47
|
-
/**
|
|
48
|
-
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
49
|
-
* @default {null}
|
|
50
|
-
*/
|
|
51
|
-
retryPolicy?: RetryPolicy | null;
|
|
52
|
-
/**
|
|
53
|
-
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
54
|
-
* @default {null}
|
|
55
|
-
*/
|
|
56
|
-
timeout?: TimeSpan | null;
|
|
57
22
|
};
|
|
58
23
|
/**
|
|
59
24
|
*
|
|
60
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus
|
|
25
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
61
26
|
* @group Derivables
|
|
62
27
|
*/
|
|
63
28
|
export declare class EventBusFactory<TAdapters extends string = string> implements IEventBusFactory<TAdapters> {
|
|
64
|
-
private readonly
|
|
65
|
-
private readonly serde;
|
|
66
|
-
private readonly defaultAdapter?;
|
|
67
|
-
private readonly retryAttempts?;
|
|
68
|
-
private readonly backoffPolicy?;
|
|
69
|
-
private readonly retryPolicy?;
|
|
70
|
-
private readonly timeout?;
|
|
71
|
-
private readonly shouldRegisterErrors?;
|
|
29
|
+
private readonly settings;
|
|
72
30
|
/**
|
|
73
31
|
* @example
|
|
74
32
|
* ```ts
|
|
75
|
-
* import {
|
|
76
|
-
* import {
|
|
77
|
-
* import {
|
|
78
|
-
* import {
|
|
33
|
+
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
34
|
+
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
35
|
+
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
36
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
|
|
37
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
38
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
79
39
|
* import Redis from "ioredis";
|
|
80
40
|
*
|
|
41
|
+
* type Store = Partial<Record<string, IEventBusAdapter>> = {};
|
|
42
|
+
*
|
|
43
|
+
* async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
44
|
+
* return (prefix) => {
|
|
45
|
+
* let adapter = store[prefix];
|
|
46
|
+
* if (adapter === undefined) {
|
|
47
|
+
* adapter = new MemoryEventBusAdapter();
|
|
48
|
+
* store[prefix] = adapter;
|
|
49
|
+
* }
|
|
50
|
+
* return adapter;
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
81
54
|
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
82
|
-
* const
|
|
83
|
-
*
|
|
55
|
+
* const store: Store = {};
|
|
56
|
+
* const eventBusFactory = new EventBusFactory({
|
|
57
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
84
58
|
* adapters: {
|
|
85
|
-
* memory:new MemoryEventBusAdapter(
|
|
86
|
-
*
|
|
87
|
-
* }),
|
|
59
|
+
* memory: new MemoryEventBusAdapter(),
|
|
60
|
+
* memoryFactory: cahceAdapterFactory(store),
|
|
88
61
|
* redis: new RedisPubSubEventBusAdapter({
|
|
89
|
-
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
|
|
90
|
-
* listenerClient: new Redis("YOUR_REDIS_CONNECTION")
|
|
91
62
|
* serde,
|
|
92
|
-
*
|
|
63
|
+
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
64
|
+
* listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
93
65
|
* }),
|
|
94
|
-
*
|
|
95
|
-
*
|
|
66
|
+
* },
|
|
67
|
+
* defaultAdapter: "memory"
|
|
96
68
|
* });
|
|
97
69
|
* ```
|
|
98
70
|
*/
|
|
99
71
|
constructor(settings: EventBusFactorySettings<TAdapters>);
|
|
100
|
-
|
|
72
|
+
setKeyPrefixer(keyPrefixer: KeyPrefixer): EventBusFactory<TAdapters>;
|
|
73
|
+
setRetryAttempts(attempts: number): EventBusFactory<TAdapters>;
|
|
74
|
+
setBackoffPolicy(policy: BackoffPolicy): EventBusFactory<TAdapters>;
|
|
75
|
+
setRetryPolicy(policy: RetryPolicy): EventBusFactory<TAdapters>;
|
|
76
|
+
setRetryTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
|
|
77
|
+
setTotalTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
|
|
101
78
|
/**
|
|
102
79
|
* @example
|
|
103
80
|
* ```ts
|
|
104
|
-
* import { BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
105
|
-
* import { EventBusFactory } from "@daiso-tech/core/event-bus
|
|
106
|
-
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/
|
|
107
|
-
* import {
|
|
108
|
-
* import {
|
|
81
|
+
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
82
|
+
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
83
|
+
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
84
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
|
|
85
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
86
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
109
87
|
* import Redis from "ioredis";
|
|
110
88
|
*
|
|
89
|
+
* type Store = Partial<Record<string, IEventBusAdapter>> = {};
|
|
90
|
+
*
|
|
91
|
+
* async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
92
|
+
* return (prefix) => {
|
|
93
|
+
* let adapter = store[prefix];
|
|
94
|
+
* if (adapter === undefined) {
|
|
95
|
+
* adapter = new MemoryEventBusAdapter();
|
|
96
|
+
* store[prefix] = adapter;
|
|
97
|
+
* }
|
|
98
|
+
* return adapter;
|
|
99
|
+
* }
|
|
100
|
+
* }
|
|
101
|
+
*
|
|
102
|
+
* const dispatcherClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
103
|
+
* const listenerClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
111
104
|
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
112
|
-
* const
|
|
113
|
-
*
|
|
105
|
+
* const store: Store = {};
|
|
106
|
+
* const eventBusFactory = new EventBusFactory({
|
|
107
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
114
108
|
* adapters: {
|
|
115
|
-
* memory:new MemoryEventBusAdapter(
|
|
116
|
-
*
|
|
117
|
-
* }),
|
|
109
|
+
* memory: new MemoryEventBusAdapter(),
|
|
110
|
+
* memoryFactory: cahceAdapterFactory(store),
|
|
118
111
|
* redis: new RedisPubSubEventBusAdapter({
|
|
119
|
-
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
|
|
120
|
-
* listenerClient: new Redis("YOUR_REDIS_CONNECTION")
|
|
121
112
|
* serde,
|
|
122
|
-
*
|
|
113
|
+
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
114
|
+
* listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
123
115
|
* }),
|
|
124
|
-
*
|
|
125
|
-
*
|
|
116
|
+
* },
|
|
117
|
+
* defaultAdapter: "memory"
|
|
126
118
|
* });
|
|
127
119
|
*
|
|
128
120
|
* class AddEvent extends BaseEvent<{ a: number, b: number }> {}
|
|
129
|
-
* serde.registerEvent(AddEvent);
|
|
130
121
|
*
|
|
131
|
-
* // Will
|
|
132
|
-
* await
|
|
122
|
+
* // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
|
|
123
|
+
* await eventBusFactory
|
|
124
|
+
* .use()
|
|
125
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
126
|
+
*
|
|
127
|
+
* // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
|
|
128
|
+
* await eventBusFactory
|
|
129
|
+
* .use("redis")
|
|
130
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
131
|
+
*
|
|
132
|
+
* // You can change the default settings of the returned EventBus instance.
|
|
133
|
+
* await eventBusFactory
|
|
134
|
+
* .setRetryAttempts(4)
|
|
135
|
+
* .use("memoryFactory")
|
|
136
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
137
|
+
*
|
|
138
|
+
* // You can reuse the settings
|
|
139
|
+
* const retryableEventBusFactory = eventBusFactory
|
|
140
|
+
* .setRetryAttempts(4);
|
|
141
|
+
*
|
|
142
|
+
* await retryableEventBusFactory
|
|
143
|
+
* .use()
|
|
144
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
145
|
+
*
|
|
146
|
+
* // You can extend the settings
|
|
147
|
+
* const extendedEventBusFactory = retryableEventBusFactory
|
|
148
|
+
* .setRetryTimeout(TimeSpan.fromSeconds(1));
|
|
133
149
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
150
|
+
* await extendedEventBusFactory
|
|
151
|
+
* .use()
|
|
152
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
136
153
|
* ```
|
|
137
154
|
*/
|
|
138
155
|
use<TEvents extends BaseEvent = BaseEvent>(adapterName?: TAdapters | undefined): IGroupableEventBus<TEvents>;
|
|
@@ -1,127 +1,185 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { EventBus } from "../../../../event-bus/implementations/derivables/event-bus/
|
|
4
|
+
import {} from "../../../../event-bus/contracts/_module-exports.js";
|
|
5
|
+
import { EventBus, } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
6
6
|
import { DefaultAdapterNotDefinedError, UnregisteredAdapterError, } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus
|
|
9
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
10
10
|
* @group Derivables
|
|
11
11
|
*/
|
|
12
12
|
export class EventBusFactory {
|
|
13
|
-
|
|
14
|
-
serde;
|
|
15
|
-
defaultAdapter;
|
|
16
|
-
retryAttempts;
|
|
17
|
-
backoffPolicy;
|
|
18
|
-
retryPolicy;
|
|
19
|
-
timeout;
|
|
20
|
-
shouldRegisterErrors;
|
|
13
|
+
settings;
|
|
21
14
|
/**
|
|
22
15
|
* @example
|
|
23
16
|
* ```ts
|
|
24
|
-
* import {
|
|
25
|
-
* import {
|
|
26
|
-
* import {
|
|
27
|
-
* import {
|
|
17
|
+
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
18
|
+
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
19
|
+
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
20
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
|
|
21
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
22
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
28
23
|
* import Redis from "ioredis";
|
|
29
24
|
*
|
|
25
|
+
* type Store = Partial<Record<string, IEventBusAdapter>> = {};
|
|
26
|
+
*
|
|
27
|
+
* async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
28
|
+
* return (prefix) => {
|
|
29
|
+
* let adapter = store[prefix];
|
|
30
|
+
* if (adapter === undefined) {
|
|
31
|
+
* adapter = new MemoryEventBusAdapter();
|
|
32
|
+
* store[prefix] = adapter;
|
|
33
|
+
* }
|
|
34
|
+
* return adapter;
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
30
38
|
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
31
|
-
* const
|
|
32
|
-
*
|
|
39
|
+
* const store: Store = {};
|
|
40
|
+
* const eventBusFactory = new EventBusFactory({
|
|
41
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
33
42
|
* adapters: {
|
|
34
|
-
* memory:new MemoryEventBusAdapter(
|
|
35
|
-
*
|
|
36
|
-
* }),
|
|
43
|
+
* memory: new MemoryEventBusAdapter(),
|
|
44
|
+
* memoryFactory: cahceAdapterFactory(store),
|
|
37
45
|
* redis: new RedisPubSubEventBusAdapter({
|
|
38
|
-
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
|
|
39
|
-
* listenerClient: new Redis("YOUR_REDIS_CONNECTION")
|
|
40
46
|
* serde,
|
|
41
|
-
*
|
|
47
|
+
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
48
|
+
* listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
42
49
|
* }),
|
|
43
|
-
*
|
|
44
|
-
*
|
|
50
|
+
* },
|
|
51
|
+
* defaultAdapter: "memory"
|
|
45
52
|
* });
|
|
46
53
|
* ```
|
|
47
54
|
*/
|
|
48
55
|
constructor(settings) {
|
|
49
|
-
|
|
50
|
-
this.shouldRegisterErrors = shouldRegisterErrors;
|
|
51
|
-
this.serde = serde;
|
|
52
|
-
this.retryAttempts = retryAttempts;
|
|
53
|
-
this.backoffPolicy = backoffPolicy;
|
|
54
|
-
this.retryPolicy = retryPolicy;
|
|
55
|
-
this.timeout = timeout;
|
|
56
|
-
this.defaultAdapter = defaultAdapter;
|
|
57
|
-
this.eventBusRecord = this.init(adapters);
|
|
56
|
+
this.settings = settings;
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
setKeyPrefixer(keyPrefixer) {
|
|
59
|
+
return new EventBusFactory({
|
|
60
|
+
...this.settings,
|
|
61
|
+
keyPrefixer,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
setRetryAttempts(attempts) {
|
|
65
|
+
return new EventBusFactory({
|
|
66
|
+
...this.settings,
|
|
67
|
+
retryAttempts: attempts,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
setBackoffPolicy(policy) {
|
|
71
|
+
return new EventBusFactory({
|
|
72
|
+
...this.settings,
|
|
73
|
+
backoffPolicy: policy,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
setRetryPolicy(policy) {
|
|
77
|
+
return new EventBusFactory({
|
|
78
|
+
...this.settings,
|
|
79
|
+
retryPolicy: policy,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
setRetryTimeout(timeout) {
|
|
83
|
+
return new EventBusFactory({
|
|
84
|
+
...this.settings,
|
|
85
|
+
retryTimeout: timeout,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
setTotalTimeout(timeout) {
|
|
89
|
+
return new EventBusFactory({
|
|
90
|
+
...this.settings,
|
|
91
|
+
totalTimeout: timeout,
|
|
92
|
+
});
|
|
78
93
|
}
|
|
79
94
|
/**
|
|
80
95
|
* @example
|
|
81
96
|
* ```ts
|
|
82
|
-
* import { BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
83
|
-
* import { EventBusFactory } from "@daiso-tech/core/event-bus
|
|
84
|
-
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/
|
|
85
|
-
* import {
|
|
86
|
-
* import {
|
|
97
|
+
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
98
|
+
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
99
|
+
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
100
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
|
|
101
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
102
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
87
103
|
* import Redis from "ioredis";
|
|
88
104
|
*
|
|
105
|
+
* type Store = Partial<Record<string, IEventBusAdapter>> = {};
|
|
106
|
+
*
|
|
107
|
+
* async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
108
|
+
* return (prefix) => {
|
|
109
|
+
* let adapter = store[prefix];
|
|
110
|
+
* if (adapter === undefined) {
|
|
111
|
+
* adapter = new MemoryEventBusAdapter();
|
|
112
|
+
* store[prefix] = adapter;
|
|
113
|
+
* }
|
|
114
|
+
* return adapter;
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* const dispatcherClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
119
|
+
* const listenerClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
89
120
|
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
90
|
-
* const
|
|
91
|
-
*
|
|
121
|
+
* const store: Store = {};
|
|
122
|
+
* const eventBusFactory = new EventBusFactory({
|
|
123
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
92
124
|
* adapters: {
|
|
93
|
-
* memory:new MemoryEventBusAdapter(
|
|
94
|
-
*
|
|
95
|
-
* }),
|
|
125
|
+
* memory: new MemoryEventBusAdapter(),
|
|
126
|
+
* memoryFactory: cahceAdapterFactory(store),
|
|
96
127
|
* redis: new RedisPubSubEventBusAdapter({
|
|
97
|
-
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
|
|
98
|
-
* listenerClient: new Redis("YOUR_REDIS_CONNECTION")
|
|
99
128
|
* serde,
|
|
100
|
-
*
|
|
129
|
+
* dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
130
|
+
* listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
|
|
101
131
|
* }),
|
|
102
|
-
*
|
|
103
|
-
*
|
|
132
|
+
* },
|
|
133
|
+
* defaultAdapter: "memory"
|
|
104
134
|
* });
|
|
105
135
|
*
|
|
106
136
|
* class AddEvent extends BaseEvent<{ a: number, b: number }> {}
|
|
107
|
-
* serde.registerEvent(AddEvent);
|
|
108
137
|
*
|
|
109
|
-
* // Will
|
|
110
|
-
* await
|
|
138
|
+
* // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
|
|
139
|
+
* await eventBusFactory
|
|
140
|
+
* .use()
|
|
141
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
142
|
+
*
|
|
143
|
+
* // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
|
|
144
|
+
* await eventBusFactory
|
|
145
|
+
* .use("redis")
|
|
146
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
147
|
+
*
|
|
148
|
+
* // You can change the default settings of the returned EventBus instance.
|
|
149
|
+
* await eventBusFactory
|
|
150
|
+
* .setRetryAttempts(4)
|
|
151
|
+
* .use("memoryFactory")
|
|
152
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
153
|
+
*
|
|
154
|
+
* // You can reuse the settings
|
|
155
|
+
* const retryableEventBusFactory = eventBusFactory
|
|
156
|
+
* .setRetryAttempts(4);
|
|
157
|
+
*
|
|
158
|
+
* await retryableEventBusFactory
|
|
159
|
+
* .use()
|
|
160
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
161
|
+
*
|
|
162
|
+
* // You can extend the settings
|
|
163
|
+
* const extendedEventBusFactory = retryableEventBusFactory
|
|
164
|
+
* .setRetryTimeout(TimeSpan.fromSeconds(1));
|
|
111
165
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
166
|
+
* await extendedEventBusFactory
|
|
167
|
+
* .use()
|
|
168
|
+
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
114
169
|
* ```
|
|
115
170
|
*/
|
|
116
|
-
use(adapterName = this.defaultAdapter) {
|
|
171
|
+
use(adapterName = this.settings.defaultAdapter) {
|
|
117
172
|
if (adapterName === undefined) {
|
|
118
173
|
throw new DefaultAdapterNotDefinedError(EventBusFactory.name);
|
|
119
174
|
}
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
175
|
+
const adapter = this.settings.adapters[adapterName];
|
|
176
|
+
if (adapter === undefined) {
|
|
122
177
|
throw new UnregisteredAdapterError(adapterName);
|
|
123
178
|
}
|
|
124
|
-
return
|
|
179
|
+
return new EventBus({
|
|
180
|
+
adapter,
|
|
181
|
+
...this.settings,
|
|
182
|
+
});
|
|
125
183
|
}
|
|
126
184
|
}
|
|
127
185
|
//# sourceMappingURL=event-bus-factory.js.map
|
package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAGX,MAAM,6DAA6D,CAAC;AAErE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA6CH;IA1CrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,YACqB,QAA4C;QAA5C,aAAQ,GAAR,QAAQ,CAAoC;IAC9D,CAAC;IAEJ,cAAc,CAAC,WAAwB;QACnC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW;SACd,CAAC,CAAC;IACP,CAAC;IAED,gBAAgB,CAAC,QAAgB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,aAAa,EAAE,QAAQ;SAC1B,CAAC,CAAC;IACP,CAAC;IAED,gBAAgB,CAAC,MAAqB;QAClC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,aAAa,EAAE,MAAM;SACxB,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAmB;QAC9B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW,EAAE,MAAM;SACtB,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,OAAiB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,YAAY,EAAE,OAAO;SACxB,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,OAAiB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,YAAY,EAAE,OAAO;SACxB,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4EG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAEjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC;YAChB,OAAO;YACP,GAAG,IAAI,CAAC,QAAQ;SACnB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -7,7 +7,7 @@ import { type Promisable } from "../../../utilities/_module-exports.js";
|
|
|
7
7
|
import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/
|
|
10
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
11
11
|
* @group Test utilities
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusAdapterTestSuiteSettings = {
|
|
@@ -21,53 +21,7 @@ export type EventBusAdapterTestSuiteSettings = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The <i>eventBusAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBusAdapter}</i> with vitest.
|
|
23
23
|
*
|
|
24
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/
|
|
24
|
+
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
25
25
|
* @group Test utilities
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { describe, test, beforeEach, expect, afterEach } from "vitest";
|
|
29
|
-
* import type { StartedRedisContainer } from "@testcontainers/redis";
|
|
30
|
-
* import { RedisContainer } from "@testcontainers/redis";
|
|
31
|
-
* import Redis from "ioredis";
|
|
32
|
-
* import { RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
33
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
34
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
35
|
-
* import { eventBusAdapterTestSuite } from "@daiso-tech/core/event-bus/implementations/test-utilities";
|
|
36
|
-
*
|
|
37
|
-
* const TIMEOUT = TimeSpan.fromMinutes(2);
|
|
38
|
-
* describe("class: RedisPubSubEventBusAdapter", () => {
|
|
39
|
-
* let dispatcherClient: Redis;
|
|
40
|
-
* let listenerClient: Redis;
|
|
41
|
-
* let startedContainer: StartedRedisContainer;
|
|
42
|
-
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
43
|
-
*
|
|
44
|
-
* beforeEach(async () => {
|
|
45
|
-
* startedContainer = await new RedisContainer().start();
|
|
46
|
-
* dispatcherClient = new Redis(startedContainer.getConnectionUrl());
|
|
47
|
-
* listenerClient = new Redis(startedContainer.getConnectionUrl());
|
|
48
|
-
* }, TIMEOUT.toMilliseconds());
|
|
49
|
-
*
|
|
50
|
-
* afterEach(async () => {
|
|
51
|
-
* await dispatcherClient.quit();
|
|
52
|
-
* await listenerClient.quit();
|
|
53
|
-
* await startedContainer.stop();
|
|
54
|
-
* }, TIMEOUT.toMilliseconds());
|
|
55
|
-
*
|
|
56
|
-
* eventBusAdapterTestSuite({
|
|
57
|
-
* createAdapter: () =>
|
|
58
|
-
* new RedisPubSubEventBusAdapter({
|
|
59
|
-
* dispatcherClient,
|
|
60
|
-
* listenerClient,
|
|
61
|
-
* serde,
|
|
62
|
-
* rootGroup: "@global"
|
|
63
|
-
* }),
|
|
64
|
-
* serde,
|
|
65
|
-
* test,
|
|
66
|
-
* beforeEach,
|
|
67
|
-
* expect,
|
|
68
|
-
* describe,
|
|
69
|
-
* });
|
|
70
|
-
* });
|
|
71
|
-
* ```
|
|
72
26
|
*/
|
|
73
27
|
export declare function eventBusAdapterTestSuite(settings: EventBusAdapterTestSuiteSettings): void;
|