@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,57 +2,44 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @module Cache
|
|
4
4
|
*/
|
|
5
|
-
import { TypeCacheError } from "../../../../cache/contracts/
|
|
6
|
-
import {} from "../../../../cache/contracts/cache-adapter.contract.js";
|
|
7
|
-
import { resolveOneOrMoreStr, } from "../../../../utilities/_module-exports.js";
|
|
5
|
+
import { TypeCacheError, } from "../../../../cache/contracts/_module-exports.js";
|
|
8
6
|
/**
|
|
9
7
|
* To utilize the <i>MemoryCacheAdapter</i>, you must create instance of it.
|
|
10
8
|
*
|
|
11
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache/
|
|
9
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache/adapters"```
|
|
12
10
|
* @group Adapters
|
|
13
11
|
*/
|
|
14
12
|
export class MemoryCacheAdapter {
|
|
15
|
-
group;
|
|
16
|
-
timeoutMap = new Map();
|
|
17
13
|
map;
|
|
14
|
+
timeoutMap = new Map();
|
|
18
15
|
/**
|
|
19
16
|
* @example
|
|
20
17
|
* ```ts
|
|
21
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/
|
|
18
|
+
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
22
19
|
*
|
|
23
|
-
* const cacheAdapter = new MemoryCacheAdapter(
|
|
24
|
-
* rootGroup: "@cache"
|
|
25
|
-
* });
|
|
20
|
+
* const cacheAdapter = new MemoryCacheAdapter();
|
|
26
21
|
* ```
|
|
27
|
-
* You can also provide an <i>Map</i
|
|
22
|
+
* You can also provide an <i>{@link Map}</i> that will be used for storing the data.
|
|
28
23
|
* @example
|
|
29
24
|
* ```ts
|
|
30
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/
|
|
25
|
+
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
31
26
|
*
|
|
32
27
|
* const map = new Map<any, any>();
|
|
33
|
-
* const cacheAdapter = new MemoryCacheAdapter(
|
|
34
|
-
* rootGroup: "@cache",
|
|
35
|
-
* map
|
|
36
|
-
* });
|
|
28
|
+
* const cacheAdapter = new MemoryCacheAdapter(map);
|
|
37
29
|
* ```
|
|
38
30
|
*/
|
|
39
|
-
constructor(
|
|
40
|
-
const { rootGroup, map = new Map() } = settings;
|
|
31
|
+
constructor(map = new Map()) {
|
|
41
32
|
this.map = map;
|
|
42
|
-
this.group = rootGroup;
|
|
43
|
-
}
|
|
44
|
-
getPrefix() {
|
|
45
|
-
return resolveOneOrMoreStr([this.group, "__KEY__"]);
|
|
46
|
-
}
|
|
47
|
-
withPrefix(key) {
|
|
48
|
-
return resolveOneOrMoreStr([this.getPrefix(), key]);
|
|
49
33
|
}
|
|
50
34
|
async get(key) {
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
return (this.map.get(key) ?? null);
|
|
36
|
+
}
|
|
37
|
+
async getAndRemove(key) {
|
|
38
|
+
const value = await this.get(key);
|
|
39
|
+
await this.remove(key);
|
|
40
|
+
return value;
|
|
53
41
|
}
|
|
54
42
|
async add(key, value, ttl) {
|
|
55
|
-
key = this.withPrefix(key);
|
|
56
43
|
const hasNotKey = !this.map.has(key);
|
|
57
44
|
if (hasNotKey) {
|
|
58
45
|
this.map.set(key, value);
|
|
@@ -65,27 +52,19 @@ export class MemoryCacheAdapter {
|
|
|
65
52
|
}
|
|
66
53
|
return hasNotKey;
|
|
67
54
|
}
|
|
55
|
+
async put(key, value, ttl) {
|
|
56
|
+
const hasKey = await this.remove(key);
|
|
57
|
+
await this.add(key, value, ttl);
|
|
58
|
+
return hasKey;
|
|
59
|
+
}
|
|
68
60
|
async update(key, value) {
|
|
69
|
-
key = this.withPrefix(key);
|
|
70
61
|
const hasKey = this.map.has(key);
|
|
71
62
|
if (hasKey) {
|
|
72
63
|
this.map.set(key, value);
|
|
73
64
|
}
|
|
74
65
|
return hasKey;
|
|
75
66
|
}
|
|
76
|
-
async put(key, value, ttl) {
|
|
77
|
-
const hasKey = await this.remove(key);
|
|
78
|
-
await this.add(key, value, ttl);
|
|
79
|
-
return hasKey;
|
|
80
|
-
}
|
|
81
|
-
async remove(key) {
|
|
82
|
-
key = this.withPrefix(key);
|
|
83
|
-
clearTimeout(this.timeoutMap.get(key));
|
|
84
|
-
this.timeoutMap.delete(key);
|
|
85
|
-
return this.map.delete(key);
|
|
86
|
-
}
|
|
87
67
|
async increment(key, value) {
|
|
88
|
-
key = this.withPrefix(key);
|
|
89
68
|
const prevValue = this.map.get(key);
|
|
90
69
|
const hasKey = prevValue !== undefined;
|
|
91
70
|
if (hasKey) {
|
|
@@ -97,23 +76,35 @@ export class MemoryCacheAdapter {
|
|
|
97
76
|
}
|
|
98
77
|
return hasKey;
|
|
99
78
|
}
|
|
100
|
-
async
|
|
79
|
+
async remove(key) {
|
|
80
|
+
clearTimeout(this.timeoutMap.get(key));
|
|
81
|
+
this.timeoutMap.delete(key);
|
|
82
|
+
return this.map.delete(key);
|
|
83
|
+
}
|
|
84
|
+
async removeMany(keys) {
|
|
85
|
+
let deleteCount = 0;
|
|
86
|
+
for (const key of keys) {
|
|
87
|
+
clearTimeout(this.timeoutMap.get(key));
|
|
88
|
+
this.timeoutMap.delete(key);
|
|
89
|
+
const hasDeleted = this.map.delete(key);
|
|
90
|
+
if (hasDeleted) {
|
|
91
|
+
deleteCount++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return deleteCount > 0;
|
|
95
|
+
}
|
|
96
|
+
async removeAll() {
|
|
97
|
+
this.map.clear();
|
|
98
|
+
this.timeoutMap.clear();
|
|
99
|
+
}
|
|
100
|
+
async removeByKeyPrefix(prefix) {
|
|
101
101
|
for (const key of this.map.keys()) {
|
|
102
|
-
if (key.startsWith(
|
|
102
|
+
if (key.startsWith(prefix)) {
|
|
103
103
|
clearTimeout(this.timeoutMap.get(key));
|
|
104
104
|
this.timeoutMap.delete(key);
|
|
105
105
|
this.map.delete(key);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
getGroup() {
|
|
110
|
-
return this.group;
|
|
111
|
-
}
|
|
112
|
-
withGroup(group) {
|
|
113
|
-
return new MemoryCacheAdapter({
|
|
114
|
-
map: this.map,
|
|
115
|
-
rootGroup: resolveOneOrMoreStr([this.group, group]),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
109
|
}
|
|
119
110
|
//# sourceMappingURL=memory-cache-adapter.js.map
|
package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"memory-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.ts"],"names":[],"mappings":"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"}
|
package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Serde
|
|
3
|
+
*/
|
|
4
|
+
import { type ISerde } from "../../../../serde/contracts/_module-exports.js";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class MongodbCacheAdapterSerde implements ISerde<string | number> {
|
|
9
|
+
private readonly serde;
|
|
10
|
+
constructor(serde: ISerde<string>);
|
|
11
|
+
serialize<TValue>(value: TValue): string | number;
|
|
12
|
+
deserialize<TValue>(value: string | number): TValue;
|
|
13
|
+
}
|
package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Serde
|
|
3
|
+
*/
|
|
4
|
+
import { DeserializationError, SerializationError, } from "../../../../serde/contracts/_module-exports.js";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export class MongodbCacheAdapterSerde {
|
|
9
|
+
serde;
|
|
10
|
+
constructor(serde) {
|
|
11
|
+
this.serde = serde;
|
|
12
|
+
}
|
|
13
|
+
serialize(value) {
|
|
14
|
+
try {
|
|
15
|
+
if (typeof value === "number" &&
|
|
16
|
+
!Number.isNaN(value) &&
|
|
17
|
+
Number.isFinite(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return this.serde.serialize(value);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new SerializationError(`Serialization error "${String(error)}" occured`, error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
deserialize(value) {
|
|
27
|
+
try {
|
|
28
|
+
if (typeof value === "number") {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
return this.serde.deserialize(value);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
throw new DeserializationError(`Serialization error "${String(error)}" occured`, error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=mongodb-cache-adapter-serde.js.map
|
package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb-cache-adapter-serde.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEH,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACJ;IAA7B,YAA6B,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;IAAG,CAAC;IAEtD,SAAS,CAAS,KAAa;QAC3B,IAAI,CAAC;YACD,IACI,OAAO,KAAK,KAAK,QAAQ;gBACzB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;gBACpB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EACxB,CAAC;gBACC,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,IAAI,kBAAkB,CACxB,wBAAwB,MAAM,CAAC,KAAK,CAAC,WAAW,EAChD,KAAK,CACR,CAAC;QACN,CAAC;IACL,CAAC;IAED,WAAW,CAAS,KAAsB;QACtC,IAAI,CAAC;YACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,OAAO,KAAe,CAAC;YAC3B,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,IAAI,oBAAoB,CAC1B,wBAAwB,MAAM,CAAC,KAAK,CAAC,WAAW,EAChD,KAAK,CACR,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts
CHANGED
|
@@ -1,62 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import { type ICacheAdapter } from "../../../../cache/contracts/
|
|
5
|
-
import type { IDeinitizable } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import { type TimeSpan, type IInitizable } from "../../../../utilities/_module-exports.js";
|
|
7
|
-
import type { CollectionOptions, Db } from "mongodb";
|
|
4
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
8
5
|
import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
|
|
6
|
+
import type { IDeinitizable, IInitizable, TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
7
|
+
import { type CollectionOptions, type Db } from "mongodb";
|
|
9
8
|
/**
|
|
10
9
|
*
|
|
11
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache/
|
|
10
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache/adapters"```
|
|
12
11
|
* @group Adapters
|
|
13
12
|
*/
|
|
14
13
|
export type MongodbCacheAdapterSettings = {
|
|
15
14
|
database: Db;
|
|
16
15
|
serde: ISerde<string>;
|
|
17
|
-
rootGroup: string;
|
|
18
16
|
collectionName?: string;
|
|
19
17
|
collectionSettings?: CollectionOptions;
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
22
20
|
* To utilize the <i>MongodbCacheAdapter</i>, you must install the <i>"mongodb"</i> package and supply a <i>{@link ISerde | ISerde<string> }</i>, with an adapter like <i>{@link SuperJsonSerdeAdapter}</i>.
|
|
23
21
|
*
|
|
24
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache/
|
|
22
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache/adapters"```
|
|
25
23
|
* @group Adapters
|
|
26
24
|
*/
|
|
27
|
-
export declare class MongodbCacheAdapter<TType
|
|
25
|
+
export declare class MongodbCacheAdapter<TType> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
26
|
+
private static filterUnexpiredKeys;
|
|
28
27
|
private static isMongodbIncrementError;
|
|
29
|
-
private readonly
|
|
30
|
-
private readonly group;
|
|
31
|
-
private readonly baseSerde;
|
|
32
|
-
private readonly database;
|
|
28
|
+
private readonly serde;
|
|
33
29
|
private readonly collection;
|
|
34
|
-
private readonly collectionName;
|
|
35
|
-
private readonly collectionSettings?;
|
|
36
30
|
/**
|
|
37
31
|
* @example
|
|
38
32
|
* ```ts
|
|
39
|
-
* import { MongodbCacheAdapter } from "@daiso-tech/core/cache/
|
|
40
|
-
* import { Serde } from "@daiso-tech/core/serde
|
|
41
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/
|
|
33
|
+
* import { MongodbCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
34
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
35
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
42
36
|
* import { MongoClient } from "mongodb";
|
|
43
37
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* await cacheAdapter.init();
|
|
54
|
-
* })();
|
|
38
|
+
* const client = await MongoClient.connect("YOUR_MONGODB_CONNECTION_STRING");
|
|
39
|
+
* const database = client.db("database");
|
|
40
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
41
|
+
* const cacheAdapter = new MongodbCacheAdapter({
|
|
42
|
+
* database,
|
|
43
|
+
* serde,
|
|
44
|
+
* });
|
|
45
|
+
* // You need initialize the adapter once before using it.
|
|
46
|
+
* await cacheAdapter.init();
|
|
55
47
|
* ```
|
|
56
48
|
*/
|
|
57
49
|
constructor(settings: MongodbCacheAdapterSettings);
|
|
58
|
-
getGroup(): string;
|
|
59
|
-
withGroup(group: string): ICacheAdapter<TType>;
|
|
60
50
|
/**
|
|
61
51
|
* Creates all related indexes.
|
|
62
52
|
* Note the <i>init</i> method needs to be called before using the adapter.
|
|
@@ -67,11 +57,15 @@ export declare class MongodbCacheAdapter<TType = unknown> implements ICacheAdapt
|
|
|
67
57
|
* Note all cache data will be removed.
|
|
68
58
|
*/
|
|
69
59
|
deInit(): Promise<void>;
|
|
60
|
+
private getDocValue;
|
|
70
61
|
get(key: string): Promise<TType | null>;
|
|
62
|
+
getAndRemove(key: string): Promise<TType | null>;
|
|
63
|
+
private isDocExpired;
|
|
71
64
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
72
|
-
update(key: string, value: TType): Promise<boolean>;
|
|
73
65
|
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
74
|
-
|
|
66
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
75
67
|
increment(key: string, value: number): Promise<boolean>;
|
|
76
|
-
|
|
68
|
+
removeMany(keys: string[]): Promise<boolean>;
|
|
69
|
+
removeAll(): Promise<void>;
|
|
70
|
+
removeByKeyPrefix(prefix: string): Promise<void>;
|
|
77
71
|
}
|