@daiso-tech/core 0.11.0 → 0.13.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/dist/cjs/_module.js +2 -2
- package/dist/cjs/_module.js.map +1 -1
- package/dist/cjs/{storage/implementations/adapters/sqlite/libsql-storage-adapter → cache/contracts}/_module.js +5 -1
- package/dist/cjs/cache/contracts/_module.js.map +1 -0
- package/dist/cjs/{storage/contracts/storage-factory.contract.js → cache/contracts/cache-adapter.contract.js} +1 -1
- package/dist/cjs/cache/contracts/cache-adapter.contract.js.map +1 -0
- package/dist/cjs/{storage/contracts/storage-adapter.contract.js → cache/contracts/cache-factory.contract.js} +1 -1
- package/dist/cjs/cache/contracts/cache-factory.contract.js.map +1 -0
- package/dist/cjs/{storage/contracts/storage.contract.js → cache/contracts/cache.contract.js} +1 -1
- package/dist/cjs/cache/contracts/cache.contract.js.map +1 -0
- package/dist/cjs/cache/contracts/cache.errors.js +32 -0
- package/dist/cjs/cache/contracts/cache.errors.js.map +1 -0
- package/dist/cjs/{storage/contracts/storage.events.js → cache/contracts/cache.events.js} +3 -3
- package/dist/cjs/cache/contracts/cache.events.js.map +1 -0
- package/dist/cjs/{storage → cache}/implementations/_module.js +3 -3
- package/dist/cjs/cache/implementations/_module.js.map +1 -0
- package/dist/cjs/{storage/implementations/_shared/test-utilities → cache/implementations/_shared}/_module.js +1 -1
- package/dist/cjs/cache/implementations/_shared/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js +192 -0
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -0
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js +1009 -0
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js.map +1 -0
- package/dist/cjs/{storage/contracts → cache/implementations/adapters}/_module.js +5 -5
- package/dist/cjs/cache/implementations/adapters/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +18 -0
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +291 -0
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -0
- package/dist/cjs/{storage/implementations/adapters/redis-storage-adapter → cache/implementations/adapters/libsql-cache-adapter}/_module.js +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +61 -0
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -0
- package/dist/cjs/{storage/implementations/adapters/memory-storage-adapter → cache/implementations/adapters/memory-cache-adapter}/_module.js +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -0
- package/dist/{esm/storage/implementations/adapters/memory-storage-adapter/memory-storage-adapter.js → cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js} +24 -6
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -0
- package/dist/cjs/{storage/implementations/adapters/sqlite/_shared → cache/implementations/adapters/mongodb-cache-adapter}/_module.js +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +262 -0
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js +18 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +147 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js +18 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +60 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -0
- package/dist/cjs/cache/implementations/derivables/_module.js +20 -0
- package/dist/cjs/cache/implementations/derivables/_module.js.map +1 -0
- package/dist/cjs/{storage/implementations/derivables/storage.js → cache/implementations/derivables/base-cache.js} +30 -197
- package/dist/cjs/cache/implementations/derivables/base-cache.js.map +1 -0
- package/dist/cjs/{storage/implementations/derivables/storage-factory.js → cache/implementations/derivables/cache-factory.js} +11 -14
- package/dist/cjs/cache/implementations/derivables/cache-factory.js.map +1 -0
- package/dist/cjs/cache/implementations/derivables/cache.js +191 -0
- package/dist/cjs/cache/implementations/derivables/cache.js.map +1 -0
- package/dist/cjs/collection/contracts/_module.js +1 -0
- package/dist/cjs/collection/contracts/_module.js.map +1 -1
- package/dist/cjs/collection/contracts/_shared.js +0 -43
- package/dist/cjs/collection/contracts/_shared.js.map +1 -1
- package/dist/cjs/collection/contracts/collection.errors.js +46 -0
- package/dist/cjs/collection/contracts/collection.errors.js.map +1 -0
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-update-iterable.js +3 -3
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js +38 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/update-iterable.js +3 -3
- package/dist/cjs/collection/implementations/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js +34 -1
- package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/cjs/collection/implementations/list-collection/list-collection.js +34 -1
- package/dist/cjs/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/cjs/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +1 -1
- package/dist/esm/_module.js +2 -2
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/cache/contracts/_module.js +6 -0
- package/dist/esm/cache/contracts/_module.js.map +1 -0
- package/dist/esm/cache/contracts/cache-adapter.contract.js +1 -0
- package/dist/esm/cache/contracts/cache-adapter.contract.js.map +1 -0
- package/dist/esm/cache/contracts/cache-factory.contract.js +1 -0
- package/dist/esm/cache/contracts/cache-factory.contract.js.map +1 -0
- package/dist/esm/cache/contracts/cache.contract.js +1 -0
- package/dist/esm/cache/contracts/cache.contract.js.map +1 -0
- package/dist/esm/cache/contracts/cache.errors.js +25 -0
- package/dist/esm/cache/contracts/cache.errors.js.map +1 -0
- package/dist/esm/{storage/contracts/storage.events.js → cache/contracts/cache.events.js} +2 -2
- package/dist/esm/cache/contracts/cache.events.js.map +1 -0
- package/dist/esm/cache/implementations/_module.js +4 -0
- package/dist/esm/cache/implementations/_module.js.map +1 -0
- package/dist/esm/cache/implementations/_shared/_module.js +2 -0
- package/dist/esm/cache/implementations/_shared/_module.js.map +1 -0
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js +189 -0
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -0
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js +1006 -0
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/_module.js +6 -0
- package/dist/esm/cache/implementations/adapters/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +287 -0
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +57 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -0
- package/dist/{cjs/storage/implementations/adapters/memory-storage-adapter/memory-storage-adapter.js → esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js} +20 -10
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +255 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +143 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js +2 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +56 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -0
- package/dist/esm/cache/implementations/derivables/_module.js +4 -0
- package/dist/esm/cache/implementations/derivables/_module.js.map +1 -0
- package/dist/esm/cache/implementations/derivables/base-cache.js +258 -0
- package/dist/esm/cache/implementations/derivables/base-cache.js.map +1 -0
- package/dist/esm/{storage/implementations/derivables/storage-factory.js → cache/implementations/derivables/cache-factory.js} +9 -12
- package/dist/esm/cache/implementations/derivables/cache-factory.js.map +1 -0
- package/dist/esm/cache/implementations/derivables/cache.js +187 -0
- package/dist/esm/cache/implementations/derivables/cache.js.map +1 -0
- package/dist/esm/collection/contracts/_module.js +1 -0
- package/dist/esm/collection/contracts/_module.js.map +1 -1
- package/dist/esm/collection/contracts/_shared.js +0 -36
- package/dist/esm/collection/contracts/_shared.js.map +1 -1
- package/dist/esm/collection/contracts/collection.errors.js +37 -0
- package/dist/esm/collection/contracts/collection.errors.js.map +1 -0
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-update-iterable.js +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js +39 -2
- package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/update-iterable.js +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js +35 -2
- package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/esm/collection/implementations/list-collection/list-collection.js +34 -1
- package/dist/esm/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/esm/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +1 -1
- package/dist/types/_module.d.ts +2 -2
- package/dist/types/_shared/types.d.ts +0 -1
- package/dist/types/cache/contracts/_module.d.ts +5 -0
- package/dist/types/{storage/contracts/storage-adapter.contract.d.ts → cache/contracts/cache-adapter.contract.d.ts} +10 -7
- package/dist/types/cache/contracts/cache-factory.contract.d.ts +48 -0
- package/dist/types/{storage/contracts/storage.contract.d.ts → cache/contracts/cache.contract.d.ts} +69 -56
- package/dist/types/{storage/contracts/storage.errors.d.ts → cache/contracts/cache.errors.d.ts} +5 -5
- package/dist/types/cache/contracts/cache.events.d.ts +96 -0
- package/dist/types/cache/implementations/_module.d.ts +3 -0
- package/dist/types/cache/implementations/_shared/_module.d.ts +1 -0
- package/dist/types/cache/implementations/_shared/cache-adapter.test-suite.d.ts +51 -0
- package/dist/types/cache/implementations/_shared/cache.test-suite.d.ts +60 -0
- package/dist/types/cache/implementations/adapters/_module.d.ts +5 -0
- package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +55 -0
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +35 -0
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +20 -0
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +41 -0
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/_module.d.ts +1 -0
- package/dist/types/{storage/implementations/adapters/redis-storage-adapter/redis-storage-adapter.d.ts → cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts} +11 -11
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +35 -0
- package/dist/types/cache/implementations/derivables/_module.d.ts +3 -0
- package/dist/types/cache/implementations/derivables/base-cache.d.ts +57 -0
- package/dist/types/cache/implementations/derivables/cache-factory.d.ts +56 -0
- package/dist/types/cache/implementations/derivables/cache.d.ts +88 -0
- package/dist/types/collection/contracts/_module.d.ts +1 -0
- package/dist/types/collection/contracts/_shared.d.ts +2 -36
- package/dist/types/collection/contracts/async-collection.contract.d.ts +39 -60
- package/dist/types/collection/contracts/collection.contract.d.ts +36 -55
- package/dist/types/collection/contracts/collection.errors.d.ts +39 -0
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-error-handler-iterable.d.ts +3 -0
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-group-by-iterable.d.ts +6 -3
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-update-iterable.d.ts +1 -1
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +8 -6
- package/dist/types/collection/implementations/iterable-collection/_shared/count-by-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/iterable-collection/_shared/cross-join-iterable.d.ts +3 -0
- package/dist/types/collection/implementations/iterable-collection/_shared/entries-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/iterable-collection/_shared/group-by-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/iterable-collection/_shared/update-iterable.d.ts +1 -1
- package/dist/types/collection/implementations/iterable-collection/_shared/zip-iterable.d.ts +2 -3
- package/dist/types/collection/implementations/iterable-collection/iterable-collection.d.ts +8 -6
- package/dist/types/collection/implementations/list-collection/list-collection.d.ts +7 -5
- package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/storage/contracts/_module.js.map +0 -1
- package/dist/cjs/storage/contracts/storage-adapter.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage-factory.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage.errors.js +0 -32
- package/dist/cjs/storage/contracts/storage.errors.js.map +0 -1
- package/dist/cjs/storage/contracts/storage.events.js.map +0 -1
- package/dist/cjs/storage/implementations/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/_shared/test-utilities/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js +0 -130
- package/dist/cjs/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/_module.js +0 -21
- package/dist/cjs/storage/implementations/adapters/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/memory-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/memory-storage-adapter/memory-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/mongodb-storage-adapter/_module.js +0 -6
- package/dist/cjs/storage/implementations/adapters/mongodb-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -132
- package/dist/cjs/storage/implementations/adapters/mongodb-storage-adapter/mongodb-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/redis-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/redis-storage-adapter/redis-storage-adapter.js +0 -89
- package/dist/cjs/storage/implementations/adapters/redis-storage-adapter/redis-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/_module.js +0 -19
- package/dist/cjs/storage/implementations/adapters/sqlite/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/_shared/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/_shared/base-sqlite-storage-adapter.js +0 -119
- package/dist/cjs/storage/implementations/adapters/sqlite/_shared/base-sqlite-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/libsql-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +0 -53
- package/dist/cjs/storage/implementations/adapters/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/sqlite-storage-adapter/_module.js +0 -18
- package/dist/cjs/storage/implementations/adapters/sqlite/sqlite-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/adapters/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +0 -52
- package/dist/cjs/storage/implementations/adapters/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/derivables/_module.js +0 -19
- package/dist/cjs/storage/implementations/derivables/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/derivables/storage-factory.js.map +0 -1
- package/dist/cjs/storage/implementations/derivables/storage.js.map +0 -1
- package/dist/esm/storage/contracts/_module.js +0 -6
- package/dist/esm/storage/contracts/_module.js.map +0 -1
- package/dist/esm/storage/contracts/storage-adapter.contract.js +0 -1
- package/dist/esm/storage/contracts/storage-adapter.contract.js.map +0 -1
- package/dist/esm/storage/contracts/storage-factory.contract.js +0 -1
- package/dist/esm/storage/contracts/storage-factory.contract.js.map +0 -1
- package/dist/esm/storage/contracts/storage.contract.js +0 -1
- package/dist/esm/storage/contracts/storage.contract.js.map +0 -1
- package/dist/esm/storage/contracts/storage.errors.js +0 -25
- package/dist/esm/storage/contracts/storage.errors.js.map +0 -1
- package/dist/esm/storage/contracts/storage.events.js.map +0 -1
- package/dist/esm/storage/implementations/_module.js +0 -4
- package/dist/esm/storage/implementations/_module.js.map +0 -1
- package/dist/esm/storage/implementations/_shared/test-utilities/_module.js +0 -2
- package/dist/esm/storage/implementations/_shared/test-utilities/_module.js.map +0 -1
- package/dist/esm/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js +0 -127
- package/dist/esm/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/_module.js +0 -5
- package/dist/esm/storage/implementations/adapters/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/memory-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/memory-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/memory-storage-adapter/memory-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/mongodb-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/mongodb-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -125
- package/dist/esm/storage/implementations/adapters/mongodb-storage-adapter/mongodb-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/redis-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/redis-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/redis-storage-adapter/redis-storage-adapter.js +0 -85
- package/dist/esm/storage/implementations/adapters/redis-storage-adapter/redis-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/_module.js +0 -3
- package/dist/esm/storage/implementations/adapters/sqlite/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/_shared/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/sqlite/_shared/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/_shared/base-sqlite-storage-adapter.js +0 -115
- package/dist/esm/storage/implementations/adapters/sqlite/_shared/base-sqlite-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/libsql-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/sqlite/libsql-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +0 -49
- package/dist/esm/storage/implementations/adapters/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/sqlite-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/adapters/sqlite/sqlite-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/adapters/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +0 -48
- package/dist/esm/storage/implementations/adapters/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/derivables/_module.js +0 -3
- package/dist/esm/storage/implementations/derivables/_module.js.map +0 -1
- package/dist/esm/storage/implementations/derivables/storage-factory.js.map +0 -1
- package/dist/esm/storage/implementations/derivables/storage.js +0 -425
- package/dist/esm/storage/implementations/derivables/storage.js.map +0 -1
- package/dist/types/storage/contracts/_module.d.ts +0 -5
- package/dist/types/storage/contracts/storage-factory.contract.d.ts +0 -67
- package/dist/types/storage/contracts/storage.events.d.ts +0 -94
- package/dist/types/storage/implementations/_module.d.ts +0 -3
- package/dist/types/storage/implementations/_shared/test-utilities/_module.d.ts +0 -1
- package/dist/types/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.d.ts +0 -36
- package/dist/types/storage/implementations/adapters/_module.d.ts +0 -4
- package/dist/types/storage/implementations/adapters/memory-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/memory-storage-adapter/memory-storage-adapter.d.ts +0 -18
- package/dist/types/storage/implementations/adapters/mongodb-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/mongodb-storage-adapter/mongodb-storage-adapter.d.ts +0 -40
- package/dist/types/storage/implementations/adapters/redis-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/sqlite/_module.d.ts +0 -2
- package/dist/types/storage/implementations/adapters/sqlite/_shared/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/sqlite/_shared/base-sqlite-storage-adapter.d.ts +0 -45
- package/dist/types/storage/implementations/adapters/sqlite/libsql-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/sqlite/libsql-storage-adapter/libsql-storage-adapter.d.ts +0 -37
- package/dist/types/storage/implementations/adapters/sqlite/sqlite-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/adapters/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.d.ts +0 -37
- package/dist/types/storage/implementations/derivables/_module.d.ts +0 -2
- package/dist/types/storage/implementations/derivables/storage-factory.d.ts +0 -47
- package/dist/types/storage/implementations/derivables/storage.d.ts +0 -119
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/_module";
|
|
5
|
+
import { type Kysely } from "kysely";
|
|
6
|
+
import { type ISerializer } from "../../../../serializer/contracts/_module";
|
|
7
|
+
import type { IDeinitizable, IInitizable } from "../../../../_shared/types";
|
|
8
|
+
import { TimeSpan } from "../../../../utilities/_module";
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
type KyselySqliteCacheTable = {
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
expiresAt: number | null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
type KyselySqliteTables = {
|
|
21
|
+
cache: KyselySqliteCacheTable;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
type KyselySqliteSettings = {
|
|
27
|
+
serializer: ISerializer<string>;
|
|
28
|
+
enableTransactions: boolean;
|
|
29
|
+
expiredKeysRemovalInterval?: TimeSpan;
|
|
30
|
+
shouldRemoveExpiredKeys?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare class KyselySqliteCacheAdapter<TType> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
36
|
+
private readonly db;
|
|
37
|
+
private readonly serializer;
|
|
38
|
+
private readonly enableTransactions;
|
|
39
|
+
private readonly expiredKeysRemovalInterval;
|
|
40
|
+
private readonly shouldRemoveExpiredKeys;
|
|
41
|
+
private timeoutId;
|
|
42
|
+
constructor(db: Kysely<KyselySqliteTables>, settings: KyselySqliteSettings);
|
|
43
|
+
private withTransaction;
|
|
44
|
+
removeExpiredKeys(): Promise<void>;
|
|
45
|
+
init(): Promise<void>;
|
|
46
|
+
deInit(): Promise<void>;
|
|
47
|
+
get(key: string): Promise<TType | null>;
|
|
48
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
49
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
50
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
51
|
+
remove(key: string): Promise<boolean>;
|
|
52
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
53
|
+
clear(prefix: string): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter";
|
package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { IDeinitizable, IInitizable } from "../../../../_shared/types";
|
|
5
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
6
|
+
import type { ISerializer } from "../../../../serializer/contracts/_module";
|
|
7
|
+
import type { TimeSpan } from "../../../../utilities/_module";
|
|
8
|
+
import type { Client } from "@libsql/client";
|
|
9
|
+
/**
|
|
10
|
+
* @group Adapters
|
|
11
|
+
*/
|
|
12
|
+
export type LibsqlCacheAdapterSettings = {
|
|
13
|
+
tableName?: string;
|
|
14
|
+
serializer?: ISerializer<string>;
|
|
15
|
+
enableTransactions?: boolean;
|
|
16
|
+
expiredKeysRemovalInterval?: TimeSpan;
|
|
17
|
+
shouldRemoveExpiredKeys?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @group Adapters
|
|
21
|
+
*/
|
|
22
|
+
export declare class LibsqlCacheAdapter<TType> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
23
|
+
private readonly cacheAdapter;
|
|
24
|
+
constructor(client: Client, settings?: LibsqlCacheAdapterSettings);
|
|
25
|
+
removeExpiredKeys(): Promise<void>;
|
|
26
|
+
deInit(): Promise<void>;
|
|
27
|
+
init(): Promise<void>;
|
|
28
|
+
get(key: string): Promise<TType | null>;
|
|
29
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
30
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
31
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
32
|
+
remove(key: string): Promise<boolean>;
|
|
33
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
34
|
+
clear(prefix: string): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter";
|
package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
|
+
import type { TimeSpan } from "../../../../utilities/_module";
|
|
6
|
+
/**
|
|
7
|
+
* @group Adapters
|
|
8
|
+
*/
|
|
9
|
+
export declare class MemoryCacheAdapter<TType> implements ICacheAdapter<TType> {
|
|
10
|
+
private readonly map;
|
|
11
|
+
constructor(map?: Map<string, TType>);
|
|
12
|
+
private readonly timeoutIdMap;
|
|
13
|
+
get(key: string): Promise<TType | null>;
|
|
14
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
15
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
16
|
+
put(key: string, value: TType, _ttl: TimeSpan | null): Promise<boolean>;
|
|
17
|
+
remove(key: string): Promise<boolean>;
|
|
18
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
19
|
+
clear(prefix: string): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter";
|
package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
|
+
import type { TimeSpan } from "../../../../utilities/_module";
|
|
6
|
+
import type { IInitizable } from "../../../../_shared/types";
|
|
7
|
+
import type { ObjectId } from "mongodb";
|
|
8
|
+
import { type Collection } from "mongodb";
|
|
9
|
+
import type { ISerializer } from "../../../../serializer/contracts/_module";
|
|
10
|
+
/**
|
|
11
|
+
* @group Adapters
|
|
12
|
+
*/
|
|
13
|
+
export type MongodbCacheDocument = {
|
|
14
|
+
_id: ObjectId;
|
|
15
|
+
key: string;
|
|
16
|
+
value: number | string;
|
|
17
|
+
expiresAt: Date | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @group Adapters
|
|
21
|
+
*/
|
|
22
|
+
export type MongodbCacheAdapterSettings = {
|
|
23
|
+
serializer?: ISerializer<string>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @group Adapters
|
|
27
|
+
*/
|
|
28
|
+
export declare class MongodbCacheAdapter<TType> implements ICacheAdapter<TType>, IInitizable {
|
|
29
|
+
private readonly collection;
|
|
30
|
+
private static isMongodbIncrementError;
|
|
31
|
+
private serializer;
|
|
32
|
+
constructor(collection: Collection<MongodbCacheDocument>, { serializer, }?: MongodbCacheAdapterSettings);
|
|
33
|
+
init(): Promise<void>;
|
|
34
|
+
get(key: string): Promise<TType | null>;
|
|
35
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
36
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
37
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
38
|
+
remove(key: string): Promise<boolean>;
|
|
39
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
40
|
+
clear(prefix: string): Promise<void>;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
5
|
-
import {
|
|
6
|
-
import type Redis from "ioredis";
|
|
7
|
-
import {
|
|
4
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
5
|
+
import type { TimeSpan } from "../../../../utilities/_module";
|
|
6
|
+
import { type Redis, type Result } from "ioredis";
|
|
7
|
+
import type { ISerializer } from "../../../../serializer/contracts/_module";
|
|
8
8
|
declare module "ioredis" {
|
|
9
9
|
interface RedisCommander<Context> {
|
|
10
10
|
daiso_storage_increment(key: string, number: string): Result<number, Context>;
|
|
@@ -15,21 +15,21 @@ declare module "ioredis" {
|
|
|
15
15
|
/**
|
|
16
16
|
* @group Adapters
|
|
17
17
|
*/
|
|
18
|
-
export type
|
|
18
|
+
export type RedisCacheAdapterSettings = {
|
|
19
19
|
serializer?: ISerializer<string>;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* @group Adapters
|
|
23
23
|
*/
|
|
24
|
-
export declare class
|
|
24
|
+
export declare class RedisCacheAdapter<TType> implements ICacheAdapter<TType> {
|
|
25
25
|
private readonly client;
|
|
26
|
+
private static isRedisTypeError;
|
|
26
27
|
private serializer;
|
|
27
|
-
constructor(client: Redis, { serializer, }?:
|
|
28
|
+
constructor(client: Redis, { serializer, }?: RedisCacheAdapterSettings);
|
|
28
29
|
get(key: string): Promise<TType | null>;
|
|
29
|
-
add(key: string, value: TType): Promise<boolean>;
|
|
30
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
30
31
|
update(key: string, value: TType): Promise<boolean>;
|
|
31
|
-
|
|
32
|
-
put(key: string, value: TType): Promise<boolean>;
|
|
32
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
33
33
|
remove(key: string): Promise<boolean>;
|
|
34
34
|
private initIncrementCommand;
|
|
35
35
|
increment(key: string, value: number): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter";
|
package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { IDeinitizable, IInitizable } from "../../../../_shared/types";
|
|
5
|
+
import { type ICacheAdapter } from "../../../../cache/contracts/cache-adapter.contract";
|
|
6
|
+
import type { ISerializer } from "../../../../serializer/contracts/_module";
|
|
7
|
+
import type { TimeSpan } from "../../../../utilities/_module";
|
|
8
|
+
import { type Database } from "better-sqlite3";
|
|
9
|
+
/**
|
|
10
|
+
* @group Adapters
|
|
11
|
+
*/
|
|
12
|
+
export type SqliteStorageAdapterSettings = {
|
|
13
|
+
tableName?: string;
|
|
14
|
+
serializer?: ISerializer<string>;
|
|
15
|
+
enableTransactions?: boolean;
|
|
16
|
+
expiredKeysRemovalInterval?: TimeSpan;
|
|
17
|
+
shouldRemoveExpiredKeys?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @group Adapters
|
|
21
|
+
*/
|
|
22
|
+
export declare class SqliteCacheAdapter<TType> implements ICacheAdapter<TType>, IInitizable, IDeinitizable {
|
|
23
|
+
private readonly cacheAdapter;
|
|
24
|
+
constructor(database: Database, settings: SqliteStorageAdapterSettings);
|
|
25
|
+
removeExpiredKeys(): Promise<void>;
|
|
26
|
+
deInit(): Promise<void>;
|
|
27
|
+
init(): Promise<void>;
|
|
28
|
+
get(key: string): Promise<TType | null>;
|
|
29
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
30
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
31
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
32
|
+
remove(key: string): Promise<boolean>;
|
|
33
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
34
|
+
clear(prefix: string): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { CacheEventNames, WithTtlValue } from "../../../cache/contracts/_module";
|
|
5
|
+
import { type ICache } from "../../../cache/contracts/_module";
|
|
6
|
+
import { type INamespacedCache, type AllCacheEvents } from "../../../cache/contracts/_module";
|
|
7
|
+
import type { OneOrMore } from "../../../_shared/types";
|
|
8
|
+
import { type AsyncLazyable, type GetOrAddValue } from "../../../_shared/types";
|
|
9
|
+
import type { TimeSpan } from "../../../utilities/_module";
|
|
10
|
+
import { LazyPromise } from "../../../utilities/_module";
|
|
11
|
+
import type { Listener, SelectEvent, Unsubscribe, INamespacedEventBus } from "../../../event-bus/contracts/_module";
|
|
12
|
+
/**
|
|
13
|
+
* @group Derivables
|
|
14
|
+
*/
|
|
15
|
+
export type BaseCacheSettings<TType> = {
|
|
16
|
+
namespace: string;
|
|
17
|
+
eventBus: INamespacedEventBus<AllCacheEvents<TType>>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The BaseCache class serves as an abstract base class that provides implementations for redundant methods.
|
|
21
|
+
* It simplifies implementing the {@link INamespacedCache} interface without using an {@link ICacheAdapter}.
|
|
22
|
+
* @group Derivables
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class BaseCache<TType = unknown> implements INamespacedCache<TType> {
|
|
25
|
+
private readonly listenable;
|
|
26
|
+
constructor(settings: BaseCacheSettings<TType>);
|
|
27
|
+
addListener<TEventType extends CacheEventNames>(event: TEventType, listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<void>;
|
|
28
|
+
addListenerMany<TEventType extends CacheEventNames>(events: TEventType[], listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<void>;
|
|
29
|
+
removeListener<TEventType extends CacheEventNames>(event: TEventType, listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<void>;
|
|
30
|
+
removeListenerMany<TEventType extends CacheEventNames>(events: TEventType[], listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<void>;
|
|
31
|
+
subscribe<TEventType extends CacheEventNames>(event: TEventType, listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<Unsubscribe>;
|
|
32
|
+
subscribeMany<TEventType extends CacheEventNames>(events: TEventType[], listener: Listener<SelectEvent<AllCacheEvents<TType>, TEventType>>): LazyPromise<Unsubscribe>;
|
|
33
|
+
abstract withNamespace(namespace: OneOrMore<string>): ICache<TType>;
|
|
34
|
+
abstract getNamespace(): string;
|
|
35
|
+
exists(key: string): LazyPromise<boolean>;
|
|
36
|
+
existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
37
|
+
missing(key: string): LazyPromise<boolean>;
|
|
38
|
+
missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
39
|
+
abstract get(key: string): LazyPromise<TType | null>;
|
|
40
|
+
getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
|
|
41
|
+
getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
|
|
42
|
+
getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
|
|
43
|
+
getOrFail(key: string): LazyPromise<TType>;
|
|
44
|
+
abstract add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
45
|
+
addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
46
|
+
abstract update(key: string, value: TType): LazyPromise<boolean>;
|
|
47
|
+
updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
|
|
48
|
+
abstract put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
49
|
+
putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
50
|
+
abstract remove(key: string): LazyPromise<boolean>;
|
|
51
|
+
removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
52
|
+
getAndRemove(key: string): LazyPromise<TType | null>;
|
|
53
|
+
getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: TimeSpan): LazyPromise<TType>;
|
|
54
|
+
abstract increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
55
|
+
decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
56
|
+
abstract clear(): LazyPromise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { INamespacedEventBus } from "../../../event-bus/contracts/_module";
|
|
5
|
+
import type { ICacheFactory, INamespacedCache, ICacheAdapter } from "../../../cache/contracts/_module";
|
|
6
|
+
import type { TimeSpan } from "../../../utilities/_module";
|
|
7
|
+
/**
|
|
8
|
+
* @group Derivables
|
|
9
|
+
*/
|
|
10
|
+
export type CacheDrivers<TDrivers extends string> = Partial<Record<TDrivers, ICacheAdapter<any>>>;
|
|
11
|
+
/**
|
|
12
|
+
* @group Derivables
|
|
13
|
+
*/
|
|
14
|
+
export type CacheFactorySettings<TDrivers extends string = string> = {
|
|
15
|
+
drivers: CacheDrivers<TDrivers>;
|
|
16
|
+
defaultDriver?: NoInfer<TDrivers>;
|
|
17
|
+
/**
|
|
18
|
+
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
19
|
+
*/
|
|
20
|
+
defaultTtl?: TimeSpan;
|
|
21
|
+
/**
|
|
22
|
+
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link INamespacedEventBus}</i>.
|
|
23
|
+
*/
|
|
24
|
+
eventBus?: INamespacedEventBus<any>;
|
|
25
|
+
/**
|
|
26
|
+
* You can prefix all keys with a given <i>rootNamespace</i>.
|
|
27
|
+
*/
|
|
28
|
+
rootNamespace?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @group Derivables
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { CacheFactory } from "@daiso-tech/core";
|
|
35
|
+
* import Redis from "ioredis"
|
|
36
|
+
*
|
|
37
|
+
* const cacheFactory = new CacheFactory({
|
|
38
|
+
* drivers: {
|
|
39
|
+
* memory: new MemoryCacheAdapter(),
|
|
40
|
+
* redis: new RedisCacheAdapter(new Redis()),
|
|
41
|
+
* },
|
|
42
|
+
* defaultDriver: "memory",
|
|
43
|
+
* rootNamespace: "@events"
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class CacheFactory<TDrivers extends string = string, TType = unknown> implements ICacheFactory<TDrivers, TType> {
|
|
48
|
+
private readonly rootNamespace?;
|
|
49
|
+
private readonly drivers;
|
|
50
|
+
private readonly defaultDriver?;
|
|
51
|
+
private readonly eventBus?;
|
|
52
|
+
private defaultTtl;
|
|
53
|
+
constructor(settings: CacheFactorySettings<TDrivers>);
|
|
54
|
+
use(driverName?: TDrivers | undefined): INamespacedCache<TType>;
|
|
55
|
+
withType<TOutput extends TType = TType>(): ICacheFactory<TDrivers, TOutput>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type ICache, type ICacheAdapter } from "../../../cache/contracts/_module";
|
|
5
|
+
import { type INamespacedCache, type AllCacheEvents } from "../../../cache/contracts/_module";
|
|
6
|
+
import type { OneOrMore } from "../../../_shared/types";
|
|
7
|
+
import type { TimeSpan } from "../../../utilities/_module";
|
|
8
|
+
import { LazyPromise } from "../../../utilities/_module";
|
|
9
|
+
import type { INamespacedEventBus } from "../../../event-bus/contracts/_module";
|
|
10
|
+
import { BaseCache } from "../../../cache/implementations/derivables/base-cache";
|
|
11
|
+
/**
|
|
12
|
+
* @group Derivables
|
|
13
|
+
*/
|
|
14
|
+
export type CacheSettings<TType> = {
|
|
15
|
+
/**
|
|
16
|
+
* You can prefix all keys with a given <i>rootNamespace</i>.
|
|
17
|
+
* This useful if you want to add multitenancy but still use the same database.
|
|
18
|
+
* @default {""}
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Cache, MemoryCacheAdapter } from "@daiso-tech/core";
|
|
22
|
+
*
|
|
23
|
+
* const memoryCacheAdapter = new MemoryCacheAdapter();
|
|
24
|
+
* const cacheA = new Cache(memoryCacheAdapter, {
|
|
25
|
+
* rootNamespace: "@a"
|
|
26
|
+
* });
|
|
27
|
+
* const cacheB = new Cache(memoryCacheAdapter, {
|
|
28
|
+
* rootNamespace: "@b"
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* (async () => {
|
|
32
|
+
* await cacheA.add("a", 1);
|
|
33
|
+
*
|
|
34
|
+
* // Will be "a"
|
|
35
|
+
* console.log(await cacheA.get("a"));
|
|
36
|
+
*
|
|
37
|
+
* // Will be "null"
|
|
38
|
+
* console.log(await cacheB.get("a"));
|
|
39
|
+
* })();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
rootNamespace?: OneOrMore<string>;
|
|
43
|
+
/**
|
|
44
|
+
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link INamespacedEventBus}</i>.
|
|
45
|
+
*/
|
|
46
|
+
eventBus?: INamespacedEventBus<AllCacheEvents<TType>>;
|
|
47
|
+
/**
|
|
48
|
+
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
49
|
+
*/
|
|
50
|
+
defaultTtl?: TimeSpan | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* <i>Cache</i> class can be derived from any <i>{@link ICacheAdapter}</i>.
|
|
54
|
+
* @group Derivables
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { Cache, MemoryCacheAdapter } from "@daiso-tech/core";
|
|
58
|
+
*
|
|
59
|
+
* const cache = new Cache(new MemoryCacheAdapter());
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare class Cache<TType = unknown> extends BaseCache<TType> implements INamespacedCache<TType> {
|
|
63
|
+
private readonly namespace;
|
|
64
|
+
private readonly namespacedEventBus;
|
|
65
|
+
private readonly eventBus;
|
|
66
|
+
private readonly cacheAdapter;
|
|
67
|
+
private readonly eventAttributes;
|
|
68
|
+
private readonly defaultTtl;
|
|
69
|
+
constructor(cacheAdapter: ICacheAdapter<any>, settings?: CacheSettings<TType>);
|
|
70
|
+
private createKeyFoundEvent;
|
|
71
|
+
private createKeyNotFoundEvent;
|
|
72
|
+
private createKeyAddedEvent;
|
|
73
|
+
private createKeyUpdatedEvent;
|
|
74
|
+
private createKeyRemovedEvent;
|
|
75
|
+
private createKeysClearedEvent;
|
|
76
|
+
private createKeyIncrementedEvent;
|
|
77
|
+
private createKeyDecrementedEvent;
|
|
78
|
+
private keyWithNamespace;
|
|
79
|
+
withNamespace(namespace: OneOrMore<string>): ICache<TType>;
|
|
80
|
+
getNamespace(): string;
|
|
81
|
+
get(key: string): LazyPromise<TType | null>;
|
|
82
|
+
add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
83
|
+
update(key: string, value: TType): LazyPromise<boolean>;
|
|
84
|
+
put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
85
|
+
remove(key: string): LazyPromise<boolean>;
|
|
86
|
+
increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
87
|
+
clear(): LazyPromise<void>;
|
|
88
|
+
}
|
|
@@ -1,42 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Collection
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* @group Errors
|
|
6
|
-
*/
|
|
7
|
-
export declare class CollectionError extends Error {
|
|
8
|
-
constructor(message: string, cause?: unknown);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @group Errors
|
|
12
|
-
*/
|
|
13
|
-
export declare class UnexpectedCollectionError extends CollectionError {
|
|
14
|
-
constructor(message: string, cause?: unknown);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @group Errors
|
|
18
|
-
*/
|
|
19
|
-
export declare class ItemNotFoundCollectionError extends CollectionError {
|
|
20
|
-
constructor(message: string, cause?: unknown);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @group Errors
|
|
24
|
-
*/
|
|
25
|
-
export declare class MultipleItemsFoundCollectionError extends CollectionError {
|
|
26
|
-
constructor(message: string, cause?: unknown);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @group Errors
|
|
30
|
-
*/
|
|
31
|
-
export declare class TypeCollectionError extends CollectionError {
|
|
32
|
-
constructor(message: string, cause?: unknown);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @group Errors
|
|
36
|
-
*/
|
|
37
|
-
export declare class EmptyCollectionError extends CollectionError {
|
|
38
|
-
constructor(message: string, cause?: unknown);
|
|
39
|
-
}
|
|
40
4
|
export type Comparator<TItem> = (itemA: TItem, itemB: TItem) => number;
|
|
41
5
|
export type Predicate_<TInput, TCollection> = (item: TInput, index: number, collection: TCollection) => boolean;
|
|
42
6
|
export type PredicateGuard<TInput, TCollection, TOutput extends TInput = TInput> = (item: TInput, index: number, collection: TCollection) => item is TOutput;
|
|
@@ -65,3 +29,5 @@ export type CrossJoinResult<TInput, TExtended> = TInput extends [
|
|
|
65
29
|
infer R,
|
|
66
30
|
...infer L
|
|
67
31
|
] ? [R, ...L, TExtended] : [TInput, TExtended];
|
|
32
|
+
export type EnsureRecord<TInput> = TInput extends [infer TKey, infer TValue] | readonly [infer TKey, infer TValue] ? TKey extends string | number | symbol ? Record<TKey, TValue> : never : never;
|
|
33
|
+
export type EnsureMap<TInput> = TInput extends [infer TKey, infer TValue] | readonly [infer TKey, infer TValue] ? globalThis.Map<TKey, TValue> : never;
|