@daiso-tech/core 0.10.0 → 0.12.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/_shared/utilities.js +7 -0
- package/dist/cjs/_shared/utilities.js.map +1 -1
- package/dist/cjs/cache/contracts/_module.js +22 -0
- package/dist/cjs/cache/contracts/_module.js.map +1 -0
- package/dist/cjs/{storage/contracts/storage-adapter.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-manager.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/cache/contracts/cache.events.js +14 -0
- package/dist/cjs/cache/contracts/cache.events.js.map +1 -0
- package/dist/cjs/cache/implementations/_module.js +20 -0
- package/dist/cjs/cache/implementations/_module.js.map +1 -0
- package/dist/cjs/{event-bus/implementations/memory-event-bus-adapter → 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/cache/implementations/adapters/_module.js +22 -0
- 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/{event-bus/implementations/redis-event-bus-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/cache/implementations/adapters/memory-cache-adapter/_module.js +18 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +72 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js +18 -0
- 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/{event-bus/implementations/no-op-event-bus-adapter → cache/implementations/adapters/redis-cache-adapter}/_module.js +1 -1
- 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/cache/implementations/derivables/base-cache.js +262 -0
- package/dist/cjs/cache/implementations/derivables/base-cache.js.map +1 -0
- package/dist/cjs/cache/implementations/derivables/cache-factory.js +39 -0
- 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/implementations/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_module.js +2 -1
- package/dist/cjs/event-bus/contracts/_module.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_shared.js +0 -36
- package/dist/cjs/event-bus/contracts/_shared.js.map +1 -1
- package/dist/cjs/event-bus/contracts/{event-bus-manager.contract.js → event-bus-factory.contract.js} +1 -1
- package/dist/cjs/event-bus/contracts/event-bus-factory.contract.js.map +1 -0
- package/dist/cjs/event-bus/contracts/event-bus.errors.js +39 -0
- package/dist/cjs/event-bus/contracts/event-bus.errors.js.map +1 -0
- package/dist/cjs/event-bus/implementations/_module.js +2 -4
- package/dist/cjs/event-bus/implementations/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/_module.js +20 -0
- package/dist/cjs/event-bus/implementations/adapters/_module.js.map +1 -0
- package/dist/cjs/{storage/implementations/redis-storage-adapter → event-bus/implementations/adapters/memory-event-bus-adapter}/_module.js +1 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -0
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -0
- package/dist/cjs/{storage/implementations/_shared/test-utilities → event-bus/implementations/adapters/no-op-event-bus-adapter}/_module.js +1 -1
- package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/_module.js.map +1 -0
- package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -0
- package/dist/cjs/{storage/implementations/memory-storage-adapter → event-bus/implementations/adapters/redis-event-bus-adapter}/_module.js +1 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js.map +1 -0
- package/dist/cjs/event-bus/implementations/{redis-event-bus-adapter → adapters/redis-event-bus-adapter}/redis-event-bus-adapter.js +2 -2
- package/dist/cjs/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js.map +1 -0
- package/dist/cjs/event-bus/implementations/{event-bus → derivables}/_module.js +2 -2
- package/dist/cjs/event-bus/implementations/derivables/_module.js.map +1 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js +39 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js.map +1 -0
- package/dist/cjs/event-bus/implementations/{event-bus → derivables}/event-bus.js +11 -8
- package/dist/cjs/event-bus/implementations/derivables/event-bus.js.map +1 -0
- package/dist/cjs/event-bus/implementations/{event-bus → derivables}/with-namespace-event-bus-adapter.js +1 -0
- package/dist/cjs/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js.map +1 -0
- package/dist/cjs/event-bus/implementations/derivables/with-validation-event-bus-adapter.js.map +1 -0
- package/dist/cjs/serializer/contracts/_module.js +1 -0
- package/dist/cjs/serializer/contracts/_module.js.map +1 -1
- package/dist/cjs/serializer/contracts/serializer.contract.js +0 -22
- package/dist/cjs/serializer/contracts/serializer.contract.js.map +1 -1
- package/dist/cjs/serializer/contracts/serializer.errors.js +25 -0
- package/dist/cjs/serializer/contracts/serializer.errors.js.map +1 -0
- package/dist/cjs/serializer/implementations/mongodb-serializer/mongodb-serializer.js +3 -3
- package/dist/cjs/serializer/implementations/mongodb-serializer/mongodb-serializer.js.map +1 -1
- package/dist/cjs/serializer/implementations/redis-serializer/redis-serializer.js +3 -3
- package/dist/cjs/serializer/implementations/redis-serializer/redis-serializer.js.map +1 -1
- package/dist/cjs/serializer/implementations/sql-serializer/sql-serializer.js +3 -3
- package/dist/cjs/serializer/implementations/sql-serializer/sql-serializer.js.map +1 -1
- package/dist/cjs/serializer/implementations/super-json-serializer/super-json-serializer.js +21 -21
- package/dist/cjs/serializer/implementations/super-json-serializer/super-json-serializer.js.map +1 -1
- package/dist/cjs/utilities/_module.js +1 -0
- package/dist/cjs/utilities/_module.js.map +1 -1
- package/dist/cjs/utilities/global-errors.js +25 -0
- package/dist/cjs/utilities/global-errors.js.map +1 -0
- package/dist/cjs/utilities/time-span/time-span.js.map +1 -1
- package/dist/esm/_module.js +2 -2
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/_shared/utilities.js +6 -0
- package/dist/esm/_shared/utilities.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/cache/contracts/cache.events.js +11 -0
- 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/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +68 -0
- 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/cache/implementations/derivables/cache-factory.js +35 -0
- 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/implementations/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/esm/event-bus/contracts/_module.js +2 -1
- package/dist/esm/event-bus/contracts/_module.js.map +1 -1
- package/dist/esm/event-bus/contracts/_shared.js +0 -30
- package/dist/esm/event-bus/contracts/_shared.js.map +1 -1
- package/dist/esm/event-bus/contracts/event-bus-factory.contract.js +1 -0
- package/dist/esm/event-bus/contracts/event-bus-factory.contract.js.map +1 -0
- package/dist/esm/event-bus/contracts/event-bus.errors.js +31 -0
- package/dist/esm/event-bus/contracts/event-bus.errors.js.map +1 -0
- package/dist/esm/event-bus/implementations/_module.js +2 -4
- package/dist/esm/event-bus/implementations/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/_module.js +4 -0
- package/dist/esm/event-bus/implementations/adapters/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +2 -0
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/_module.js +2 -0
- package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js +2 -0
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/{redis-event-bus-adapter → adapters/redis-event-bus-adapter}/redis-event-bus-adapter.js +2 -2
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/_module.js +3 -0
- package/dist/esm/event-bus/implementations/derivables/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js +35 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js.map +1 -0
- package/dist/esm/event-bus/implementations/{event-bus → derivables}/event-bus.js +12 -9
- package/dist/esm/event-bus/implementations/derivables/event-bus.js.map +1 -0
- package/dist/esm/event-bus/implementations/{event-bus → derivables}/with-namespace-event-bus-adapter.js +1 -0
- package/dist/esm/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/with-validation-event-bus-adapter.js.map +1 -0
- package/dist/esm/serializer/contracts/_module.js +1 -0
- package/dist/esm/serializer/contracts/_module.js.map +1 -1
- package/dist/esm/serializer/contracts/serializer.contract.js +0 -18
- package/dist/esm/serializer/contracts/serializer.contract.js.map +1 -1
- package/dist/esm/serializer/contracts/serializer.errors.js +19 -0
- package/dist/esm/serializer/contracts/serializer.errors.js.map +1 -0
- package/dist/esm/serializer/implementations/mongodb-serializer/mongodb-serializer.js +1 -1
- package/dist/esm/serializer/implementations/mongodb-serializer/mongodb-serializer.js.map +1 -1
- package/dist/esm/serializer/implementations/redis-serializer/redis-serializer.js +1 -1
- package/dist/esm/serializer/implementations/redis-serializer/redis-serializer.js.map +1 -1
- package/dist/esm/serializer/implementations/sql-serializer/sql-serializer.js +1 -1
- package/dist/esm/serializer/implementations/sql-serializer/sql-serializer.js.map +1 -1
- package/dist/esm/serializer/implementations/super-json-serializer/super-json-serializer.js +1 -1
- package/dist/esm/serializer/implementations/super-json-serializer/super-json-serializer.js.map +1 -1
- package/dist/esm/utilities/_module.js +1 -0
- package/dist/esm/utilities/_module.js.map +1 -1
- package/dist/esm/utilities/global-errors.js +19 -0
- package/dist/esm/utilities/global-errors.js.map +1 -0
- package/dist/esm/utilities/time-span/time-span.js.map +1 -1
- package/dist/types/_module.d.ts +2 -2
- package/dist/types/_shared/types.d.ts +4 -0
- package/dist/types/_shared/utilities.d.ts +5 -1
- package/dist/types/cache/contracts/_module.d.ts +5 -0
- package/dist/types/cache/contracts/cache-adapter.contract.d.ts +44 -0
- package/dist/types/cache/contracts/cache-factory.contract.d.ts +48 -0
- package/dist/types/cache/contracts/cache.contract.d.ts +195 -0
- package/dist/types/{storage/contracts/_shared.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/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +37 -0
- 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/implementations/async-iterable-collection/_shared/async-error-handler-iterable.d.ts +3 -0
- package/dist/types/collection/implementations/iterable-collection/_shared/cross-join-iterable.d.ts +3 -0
- package/dist/types/event-bus/contracts/_module.d.ts +2 -1
- package/dist/types/event-bus/contracts/_shared.d.ts +0 -30
- package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +78 -0
- package/dist/types/event-bus/contracts/event-bus.contract.d.ts +21 -18
- package/dist/types/event-bus/contracts/event-bus.errors.d.ts +33 -0
- package/dist/types/event-bus/implementations/_module.d.ts +2 -4
- package/dist/types/event-bus/implementations/adapters/_module.d.ts +3 -0
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/_module.d.ts +1 -0
- package/dist/types/event-bus/implementations/{memory-event-bus-adapter → adapters/memory-event-bus-adapter}/memory-event-bus-adapter.d.ts +1 -1
- package/dist/types/event-bus/implementations/adapters/no-op-event-bus-adapter/_module.d.ts +1 -0
- package/dist/types/event-bus/implementations/{no-op-event-bus-adapter → adapters/no-op-event-bus-adapter}/no-op-event-bus-adapter.d.ts +3 -3
- package/dist/types/event-bus/implementations/adapters/redis-event-bus-adapter/_module.d.ts +1 -0
- package/dist/types/event-bus/implementations/{redis-event-bus-adapter → adapters/redis-event-bus-adapter}/redis-event-bus-adapter.d.ts +2 -2
- package/dist/types/event-bus/implementations/derivables/_module.d.ts +2 -0
- package/dist/types/event-bus/implementations/derivables/event-bus-factory.d.ts +47 -0
- package/dist/types/event-bus/implementations/{event-bus → derivables}/event-bus.d.ts +8 -7
- package/dist/types/serializer/contracts/_module.d.ts +1 -0
- package/dist/types/serializer/contracts/serializer.contract.d.ts +0 -18
- package/dist/types/serializer/contracts/serializer.errors.d.ts +21 -0
- package/dist/types/utilities/_module.d.ts +1 -0
- package/dist/types/utilities/global-errors.d.ts +12 -0
- package/dist/types/utilities/time-span/time-span.d.ts +2 -0
- package/package.json +12 -2
- package/dist/cjs/event-bus/contracts/event-bus-manager.contract.js.map +0 -1
- package/dist/cjs/event-bus/implementations/event-bus/_module.js.map +0 -1
- package/dist/cjs/event-bus/implementations/event-bus/event-bus-manager.js +0 -31
- package/dist/cjs/event-bus/implementations/event-bus/event-bus-manager.js.map +0 -1
- package/dist/cjs/event-bus/implementations/event-bus/event-bus.js.map +0 -1
- package/dist/cjs/event-bus/implementations/event-bus/with-namespace-event-bus-adapter.js.map +0 -1
- package/dist/cjs/event-bus/implementations/event-bus/with-validation-event-bus-adapter.js.map +0 -1
- package/dist/cjs/event-bus/implementations/memory-event-bus-adapter/_module.js.map +0 -1
- package/dist/cjs/event-bus/implementations/memory-event-bus-adapter/memory-event-bus-adapter.js.map +0 -1
- package/dist/cjs/event-bus/implementations/no-op-event-bus-adapter/_module.js.map +0 -1
- package/dist/cjs/event-bus/implementations/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +0 -1
- package/dist/cjs/event-bus/implementations/redis-event-bus-adapter/_module.js.map +0 -1
- package/dist/cjs/event-bus/implementations/redis-event-bus-adapter/redis-event-bus-adapter.js.map +0 -1
- package/dist/cjs/storage/contracts/_module.js +0 -22
- package/dist/cjs/storage/contracts/_module.js.map +0 -1
- package/dist/cjs/storage/contracts/_shared.js +0 -32
- package/dist/cjs/storage/contracts/_shared.js.map +0 -1
- package/dist/cjs/storage/contracts/storage-adapter.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage-events.contract.js +0 -14
- package/dist/cjs/storage/contracts/storage-events.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage-manager.contract.js.map +0 -1
- package/dist/cjs/storage/contracts/storage.contract.js.map +0 -1
- package/dist/cjs/storage/implementations/_module.js +0 -23
- 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 -298
- package/dist/cjs/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js.map +0 -1
- package/dist/cjs/storage/implementations/memory-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/memory-storage-adapter/memory-storage-adapter.js +0 -85
- package/dist/cjs/storage/implementations/memory-storage-adapter/memory-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/mongodb-storage-adapter/_module.js +0 -6
- package/dist/cjs/storage/implementations/mongodb-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -203
- package/dist/cjs/storage/implementations/mongodb-storage-adapter/mongodb-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/redis-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/redis-storage-adapter/redis-storage-adapter.js +0 -228
- package/dist/cjs/storage/implementations/redis-storage-adapter/redis-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/_module.js +0 -19
- package/dist/cjs/storage/implementations/sqlite/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/_shared/_module.js +0 -18
- package/dist/cjs/storage/implementations/sqlite/_shared/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/_shared/base-sqlite-storage-adapter.js +0 -190
- package/dist/cjs/storage/implementations/sqlite/_shared/base-sqlite-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/libsql-storage-adapter/_module.js +0 -18
- package/dist/cjs/storage/implementations/sqlite/libsql-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +0 -53
- package/dist/cjs/storage/implementations/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/sqlite-storage-adapter/_module.js +0 -18
- package/dist/cjs/storage/implementations/sqlite/sqlite-storage-adapter/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +0 -52
- package/dist/cjs/storage/implementations/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/_module.js +0 -19
- package/dist/cjs/storage/implementations/storage/_module.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/storage-manager.js +0 -34
- package/dist/cjs/storage/implementations/storage/storage-manager.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/storage.js +0 -265
- package/dist/cjs/storage/implementations/storage/storage.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/with-event-storage-adapter.js +0 -255
- package/dist/cjs/storage/implementations/storage/with-event-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/with-namespace-storage-adapter.js +0 -53
- package/dist/cjs/storage/implementations/storage/with-namespace-storage-adapter.js.map +0 -1
- package/dist/cjs/storage/implementations/storage/with-validation-storage-adapter.js +0 -48
- package/dist/cjs/storage/implementations/storage/with-validation-storage-adapter.js.map +0 -1
- package/dist/esm/event-bus/contracts/event-bus-manager.contract.js +0 -1
- package/dist/esm/event-bus/contracts/event-bus-manager.contract.js.map +0 -1
- package/dist/esm/event-bus/implementations/event-bus/_module.js +0 -3
- package/dist/esm/event-bus/implementations/event-bus/_module.js.map +0 -1
- package/dist/esm/event-bus/implementations/event-bus/event-bus-manager.js +0 -27
- package/dist/esm/event-bus/implementations/event-bus/event-bus-manager.js.map +0 -1
- package/dist/esm/event-bus/implementations/event-bus/event-bus.js.map +0 -1
- package/dist/esm/event-bus/implementations/event-bus/with-namespace-event-bus-adapter.js.map +0 -1
- package/dist/esm/event-bus/implementations/event-bus/with-validation-event-bus-adapter.js.map +0 -1
- package/dist/esm/event-bus/implementations/memory-event-bus-adapter/_module.js +0 -2
- package/dist/esm/event-bus/implementations/memory-event-bus-adapter/_module.js.map +0 -1
- package/dist/esm/event-bus/implementations/memory-event-bus-adapter/memory-event-bus-adapter.js.map +0 -1
- package/dist/esm/event-bus/implementations/no-op-event-bus-adapter/_module.js +0 -2
- package/dist/esm/event-bus/implementations/no-op-event-bus-adapter/_module.js.map +0 -1
- package/dist/esm/event-bus/implementations/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +0 -1
- package/dist/esm/event-bus/implementations/redis-event-bus-adapter/_module.js +0 -2
- package/dist/esm/event-bus/implementations/redis-event-bus-adapter/_module.js.map +0 -1
- package/dist/esm/event-bus/implementations/redis-event-bus-adapter/redis-event-bus-adapter.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/_shared.js +0 -25
- package/dist/esm/storage/contracts/_shared.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-events.contract.js +0 -11
- package/dist/esm/storage/contracts/storage-events.contract.js.map +0 -1
- package/dist/esm/storage/contracts/storage-manager.contract.js +0 -1
- package/dist/esm/storage/contracts/storage-manager.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/implementations/_module.js +0 -7
- 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 -295
- package/dist/esm/storage/implementations/_shared/test-utilities/storage-adapter.test-suite.js.map +0 -1
- package/dist/esm/storage/implementations/memory-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/memory-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/memory-storage-adapter/memory-storage-adapter.js +0 -81
- package/dist/esm/storage/implementations/memory-storage-adapter/memory-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/mongodb-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/mongodb-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -196
- package/dist/esm/storage/implementations/mongodb-storage-adapter/mongodb-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/redis-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/redis-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/redis-storage-adapter/redis-storage-adapter.js +0 -224
- package/dist/esm/storage/implementations/redis-storage-adapter/redis-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/_module.js +0 -3
- package/dist/esm/storage/implementations/sqlite/_module.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/_shared/_module.js +0 -2
- package/dist/esm/storage/implementations/sqlite/_shared/_module.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/_shared/base-sqlite-storage-adapter.js +0 -186
- package/dist/esm/storage/implementations/sqlite/_shared/base-sqlite-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/libsql-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/sqlite/libsql-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +0 -49
- package/dist/esm/storage/implementations/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/sqlite-storage-adapter/_module.js +0 -2
- package/dist/esm/storage/implementations/sqlite/sqlite-storage-adapter/_module.js.map +0 -1
- package/dist/esm/storage/implementations/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +0 -48
- package/dist/esm/storage/implementations/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/storage/_module.js +0 -3
- package/dist/esm/storage/implementations/storage/_module.js.map +0 -1
- package/dist/esm/storage/implementations/storage/storage-manager.js +0 -30
- package/dist/esm/storage/implementations/storage/storage-manager.js.map +0 -1
- package/dist/esm/storage/implementations/storage/storage.js +0 -261
- package/dist/esm/storage/implementations/storage/storage.js.map +0 -1
- package/dist/esm/storage/implementations/storage/with-event-storage-adapter.js +0 -251
- package/dist/esm/storage/implementations/storage/with-event-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/storage/with-namespace-storage-adapter.js +0 -49
- package/dist/esm/storage/implementations/storage/with-namespace-storage-adapter.js.map +0 -1
- package/dist/esm/storage/implementations/storage/with-validation-storage-adapter.js +0 -44
- package/dist/esm/storage/implementations/storage/with-validation-storage-adapter.js.map +0 -1
- package/dist/types/event-bus/contracts/event-bus-manager.contract.d.ts +0 -120
- package/dist/types/event-bus/implementations/event-bus/_module.d.ts +0 -2
- package/dist/types/event-bus/implementations/event-bus/event-bus-manager.d.ts +0 -26
- package/dist/types/event-bus/implementations/memory-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/no-op-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/redis-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/storage/contracts/_module.d.ts +0 -5
- package/dist/types/storage/contracts/storage-adapter.contract.d.ts +0 -41
- package/dist/types/storage/contracts/storage-events.contract.d.ts +0 -91
- package/dist/types/storage/contracts/storage-manager.contract.d.ts +0 -100
- package/dist/types/storage/contracts/storage.contract.d.ts +0 -185
- package/dist/types/storage/implementations/_module.d.ts +0 -6
- 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/memory-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/memory-storage-adapter/memory-storage-adapter.d.ts +0 -18
- package/dist/types/storage/implementations/mongodb-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/mongodb-storage-adapter/mongodb-storage-adapter.d.ts +0 -43
- package/dist/types/storage/implementations/redis-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/redis-storage-adapter/redis-storage-adapter.d.ts +0 -38
- package/dist/types/storage/implementations/sqlite/_module.d.ts +0 -2
- package/dist/types/storage/implementations/sqlite/_shared/_module.d.ts +0 -1
- package/dist/types/storage/implementations/sqlite/_shared/base-sqlite-storage-adapter.d.ts +0 -39
- package/dist/types/storage/implementations/sqlite/libsql-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/sqlite/libsql-storage-adapter/libsql-storage-adapter.d.ts +0 -30
- package/dist/types/storage/implementations/sqlite/sqlite-storage-adapter/_module.d.ts +0 -1
- package/dist/types/storage/implementations/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.d.ts +0 -30
- package/dist/types/storage/implementations/storage/_module.d.ts +0 -2
- package/dist/types/storage/implementations/storage/storage-manager.d.ts +0 -29
- package/dist/types/storage/implementations/storage/storage.d.ts +0 -114
- package/dist/types/storage/implementations/storage/with-event-storage-adapter.d.ts +0 -31
- package/dist/types/storage/implementations/storage/with-namespace-storage-adapter.d.ts +0 -24
- package/dist/types/storage/implementations/storage/with-validation-storage-adapter.d.ts +0 -22
- /package/dist/cjs/event-bus/implementations/{memory-event-bus-adapter → adapters/memory-event-bus-adapter}/memory-event-bus-adapter.js +0 -0
- /package/dist/cjs/event-bus/implementations/{no-op-event-bus-adapter → adapters/no-op-event-bus-adapter}/no-op-event-bus-adapter.js +0 -0
- /package/dist/cjs/event-bus/implementations/{event-bus → derivables}/with-validation-event-bus-adapter.js +0 -0
- /package/dist/esm/event-bus/implementations/{memory-event-bus-adapter → adapters/memory-event-bus-adapter}/memory-event-bus-adapter.js +0 -0
- /package/dist/esm/event-bus/implementations/{no-op-event-bus-adapter → adapters/no-op-event-bus-adapter}/no-op-event-bus-adapter.js +0 -0
- /package/dist/esm/event-bus/implementations/{event-bus → derivables}/with-validation-event-bus-adapter.js +0 -0
- /package/dist/types/event-bus/implementations/{event-bus → derivables}/with-namespace-event-bus-adapter.d.ts +0 -0
- /package/dist/types/event-bus/implementations/{event-bus → derivables}/with-validation-event-bus-adapter.d.ts +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { IListenable } from "../../event-bus/contracts/_module";
|
|
5
|
+
import type { OneOrMore } from "../../_shared/types";
|
|
6
|
+
import { type AsyncLazyable, type GetOrAddValue } from "../../_shared/types";
|
|
7
|
+
import type { AllCacheEvents } from "../../cache/contracts/_module";
|
|
8
|
+
import type { LazyPromise, TimeSpan } from "../../utilities/_module";
|
|
9
|
+
/**
|
|
10
|
+
* The <i>ICacheListenable</i> contract defines a way for listening <i>{@link ICache}</i> crud operations.
|
|
11
|
+
* @group Contracts
|
|
12
|
+
*/
|
|
13
|
+
export type ICacheListenable<TType = unknown> = IListenable<AllCacheEvents<TType>>;
|
|
14
|
+
/**
|
|
15
|
+
* @group Contracts
|
|
16
|
+
*/
|
|
17
|
+
export type WithTtlValue<TType> = {
|
|
18
|
+
value: TType;
|
|
19
|
+
/**
|
|
20
|
+
* You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
|
|
21
|
+
*/
|
|
22
|
+
ttl?: TimeSpan | null;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The <i>ICache</i> contract defines a way for storing data as key-value pairs independent of data storage.
|
|
26
|
+
* It commes with more convient methods compared to <i>ICacheAdapter</i>.
|
|
27
|
+
* @group Contracts
|
|
28
|
+
*/
|
|
29
|
+
export type ICache<TType = unknown> = ICacheListenable & {
|
|
30
|
+
/**
|
|
31
|
+
* The <i>exists</i> method returns true when <i>key</i> is found otherwise false will be returned.
|
|
32
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
33
|
+
*/
|
|
34
|
+
exists(key: string): LazyPromise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* The <i>existsMany</i> method returns true for the <i>keys</i> that are found otherwise false will be returned.
|
|
37
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
38
|
+
*/
|
|
39
|
+
existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
40
|
+
/**
|
|
41
|
+
* The <i>missing</i> method returns true when <i>key</i> is not found otherwise false will be returned.
|
|
42
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
43
|
+
*/
|
|
44
|
+
missing(key: string): LazyPromise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* The <i>missingMany</i> method returns true for the <i>keys</i> that are not found otherwise false will be returned.
|
|
47
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
48
|
+
*/
|
|
49
|
+
missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
50
|
+
/**
|
|
51
|
+
* The <i>get</i> method returns the value when <i>key</i> is found otherwise null will be returned.
|
|
52
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
53
|
+
*/
|
|
54
|
+
get(key: string): LazyPromise<TType | null>;
|
|
55
|
+
/**
|
|
56
|
+
* The <i>getMany</i> returns the value for the <i>keys</i> that are found otherwise null will be returned.
|
|
57
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
58
|
+
*/
|
|
59
|
+
getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
|
|
60
|
+
/**
|
|
61
|
+
* The <i>getOr</i> method returns the value when <i>key</i> is found otherwise <i>defaultValue</i> will be returned.
|
|
62
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
63
|
+
*/
|
|
64
|
+
getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
|
|
65
|
+
/**
|
|
66
|
+
* The <i>getOrMany</i> method returns the value for the keys that are found otherwise defaultValue will be returned.
|
|
67
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
68
|
+
*/
|
|
69
|
+
getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
|
|
70
|
+
/**
|
|
71
|
+
* The <i>getOrFail</i> method returns the value when <i>key</i> is found otherwise an error will be thrown.
|
|
72
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
73
|
+
* @throws {KeyNotFoundCacheError} {@link KeyNotFoundCacheError}
|
|
74
|
+
*/
|
|
75
|
+
getOrFail(key: string): LazyPromise<TType>;
|
|
76
|
+
/**
|
|
77
|
+
* The <i>add</i> method adds a <i>key</i> with given <i>value</i> when key doesn't exists. Returns true when key doesn't exists otherwise false will be returned.
|
|
78
|
+
* You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
|
|
79
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
80
|
+
*/
|
|
81
|
+
add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* The <i>addMany</i> method adds new keys. Returns true for the keys that where added otherwise false will be returned.
|
|
84
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
85
|
+
*/
|
|
86
|
+
addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
87
|
+
/**
|
|
88
|
+
* The <i>update</i> method updates the given <i>key</i> with given <i>value</i>. Returns true when key otherwise false will be returned.
|
|
89
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
90
|
+
*/
|
|
91
|
+
update(key: string, value: TType): LazyPromise<boolean>;
|
|
92
|
+
/**
|
|
93
|
+
* The <i>updateMany</i> method updates the given keys. Returns true for the keys that where updated otherwise false will be returned.
|
|
94
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
95
|
+
*/
|
|
96
|
+
updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
|
|
97
|
+
/**
|
|
98
|
+
* The <i>put</i> method replaces the key with given <i>value</i> if found. If the <i>key</i> is not found it will just be added. True is returned if the key is found otherwise false will be returned.
|
|
99
|
+
* You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
|
|
100
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
101
|
+
*/
|
|
102
|
+
put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* The <i>putMany</i> method replaces the keys that exists. Adds keys that do not exists. Return true for all the keys that where updated otherwise false is returned.
|
|
105
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
106
|
+
*/
|
|
107
|
+
putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
108
|
+
/**
|
|
109
|
+
* The <i>remove</i> method removes the given <i>key</i> when found. Returns true if the key is found otherwise false is returned.
|
|
110
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
111
|
+
*/
|
|
112
|
+
remove(key: string): LazyPromise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* The <i>removeMany</i> method removes keys. Returns true for the keys that are removed otherwise false is returned.
|
|
115
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
116
|
+
*/
|
|
117
|
+
removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
118
|
+
/**
|
|
119
|
+
* The <i>getAndRemove</i> method removes the given <i>key</i> and returns it when found otherwise null will be returned.
|
|
120
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
121
|
+
*/
|
|
122
|
+
getAndRemove(key: string): LazyPromise<TType | null>;
|
|
123
|
+
/**
|
|
124
|
+
* The <i>getOrAdd</i> method will retrieve the given <i>key</i> if found otherwise <i>valueToAdd</i> will be added and returned.
|
|
125
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
126
|
+
*/
|
|
127
|
+
getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
|
|
128
|
+
/**
|
|
129
|
+
* The <i>increment</i> method will increment the given <i>key</i> if found otherwise nonthing will occur.
|
|
130
|
+
* Returns true if key is incremented otherwise false will be returned.
|
|
131
|
+
* An error will thrown if the key is not a number.
|
|
132
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
133
|
+
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
134
|
+
*/
|
|
135
|
+
increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* The <i>decrement</i> method will decrement the given <i>key</i> if found otherwise nonthing will occur.
|
|
138
|
+
* Returns true if key exists otherwise false will be returned.
|
|
139
|
+
* An error will thrown if the key is not a number.
|
|
140
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
141
|
+
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
142
|
+
* An error will thrown if the key is not a number.
|
|
143
|
+
*/
|
|
144
|
+
decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* The <i>clear</i> method removes all the keys in the cache.
|
|
147
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
148
|
+
*/
|
|
149
|
+
clear(): LazyPromise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* The <i>getNamespace</i> method returns the complete namespace.
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* import type { ICache } from "@daiso-tech/core";
|
|
155
|
+
*
|
|
156
|
+
* async function main(cache: ICache) {
|
|
157
|
+
* // Will be "@root"
|
|
158
|
+
* console.log(cache.getNamespace())
|
|
159
|
+
*
|
|
160
|
+
* const cacheA = cache.withNamespace("a");
|
|
161
|
+
*
|
|
162
|
+
* // Will be "@root/a"
|
|
163
|
+
* console.log(cacheA.getNamespace())
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
getNamespace(): string;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* The <i>INamespacedCache</i> contract defines a way for storing data as key-value pairs independent of data storage.
|
|
171
|
+
* It commes with one extra method which is useful for multitennat applications compared to <i>ICache</i>.
|
|
172
|
+
* @group Contracts
|
|
173
|
+
*/
|
|
174
|
+
export type INamespacedCache<TType = unknown> = ICache<TType> & {
|
|
175
|
+
/**
|
|
176
|
+
* The <i>withNamespace</i> method returns new instance of <i>{@link ICache}</i> where all the keys will be prefixed with a given <i>namespace</i>.
|
|
177
|
+
* This useful for multitennat applications.
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { type ICache } from "@daiso-tech/core";
|
|
181
|
+
*
|
|
182
|
+
* async function main(cache: ICache): Promise<void> {
|
|
183
|
+
* const cacheA = cache.withNamespace("a");
|
|
184
|
+
* await cacheA.add("a", 1);
|
|
185
|
+
*
|
|
186
|
+
* const cacheB = cache.withNamespace("b");
|
|
187
|
+
* await cacheB.add("b", 2);
|
|
188
|
+
*
|
|
189
|
+
* // Will print { a: 1, b: null }
|
|
190
|
+
* console.log(await cacheA.getMany(["a", "b"]));
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
withNamespace(namespace: OneOrMore<string>): ICache<TType>;
|
|
195
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* @group Errors
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class CacheError extends Error {
|
|
8
8
|
constructor(message: string, cause?: unknown);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* @group Errors
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class UnexpectedCacheError extends CacheError {
|
|
14
14
|
constructor(message: string, cause?: unknown);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* @group Errors
|
|
18
18
|
*/
|
|
19
|
-
export declare class
|
|
19
|
+
export declare class TypeCacheError extends CacheError {
|
|
20
20
|
constructor(message: string, cause?: unknown);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @group Errors
|
|
24
24
|
*/
|
|
25
|
-
export declare class
|
|
25
|
+
export declare class KeyNotFoundCacheError extends CacheError {
|
|
26
26
|
constructor(message: string, cause?: unknown);
|
|
27
27
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
5
|
+
import type { ICacheAdapter } from "../../cache/contracts/cache-adapter.contract";
|
|
6
|
+
/**
|
|
7
|
+
* Name of all the events of <i>{@link ICache}</i>.
|
|
8
|
+
* @group Events
|
|
9
|
+
*/
|
|
10
|
+
export declare const CACHE_EVENTS: {
|
|
11
|
+
readonly KEY_FOUND: "key_found";
|
|
12
|
+
readonly KEY_NOT_FOUND: "key_not_found";
|
|
13
|
+
readonly KEY_ADDED: "key_added";
|
|
14
|
+
readonly KEY_UPDATED: "key_updated";
|
|
15
|
+
readonly KEY_REMOVED: "key_removed";
|
|
16
|
+
readonly KEYS_CLEARED: "keys_cleared";
|
|
17
|
+
readonly KEY_INCREMENTED: "key_incremented";
|
|
18
|
+
readonly KEY_DECREMENTED: "key_decremented";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @group Events
|
|
22
|
+
*/
|
|
23
|
+
export type CacheEventNames = (typeof CACHE_EVENTS)[keyof typeof CACHE_EVENTS];
|
|
24
|
+
/**
|
|
25
|
+
* @group Events
|
|
26
|
+
*/
|
|
27
|
+
export type CacheEvent = {
|
|
28
|
+
namespace: string;
|
|
29
|
+
adapter: ICacheAdapter<any>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @group Events
|
|
33
|
+
*/
|
|
34
|
+
export type KeyFoundCacheEvent<TType = unknown> = CacheEvent & {
|
|
35
|
+
type: (typeof CACHE_EVENTS)["KEY_FOUND"];
|
|
36
|
+
key: string;
|
|
37
|
+
value: TType;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @group Events
|
|
41
|
+
*/
|
|
42
|
+
export type KeyNotFoundCacheEvent = CacheEvent & {
|
|
43
|
+
type: (typeof CACHE_EVENTS)["KEY_NOT_FOUND"];
|
|
44
|
+
key: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* @group Events
|
|
48
|
+
*/
|
|
49
|
+
export type KeyAddedCacheEvent<TType = unknown> = CacheEvent & {
|
|
50
|
+
type: (typeof CACHE_EVENTS)["KEY_ADDED"];
|
|
51
|
+
key: string;
|
|
52
|
+
value: TType;
|
|
53
|
+
ttl: TimeSpan | null;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @group Events
|
|
57
|
+
*/
|
|
58
|
+
export type KeyUpdatedCacheEvent<TType = unknown> = CacheEvent & {
|
|
59
|
+
type: (typeof CACHE_EVENTS)["KEY_UPDATED"];
|
|
60
|
+
key: string;
|
|
61
|
+
value: TType;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @group Events
|
|
65
|
+
*/
|
|
66
|
+
export type KeyIncrementedCacheEvent = CacheEvent & {
|
|
67
|
+
type: (typeof CACHE_EVENTS)["KEY_INCREMENTED"];
|
|
68
|
+
key: string;
|
|
69
|
+
value: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @group Events
|
|
73
|
+
*/
|
|
74
|
+
export type KeyDecrementedCacheEvent = CacheEvent & {
|
|
75
|
+
type: (typeof CACHE_EVENTS)["KEY_DECREMENTED"];
|
|
76
|
+
key: string;
|
|
77
|
+
value: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* @group Events
|
|
81
|
+
*/
|
|
82
|
+
export type KeyRemovedCacheEvent = CacheEvent & {
|
|
83
|
+
type: (typeof CACHE_EVENTS)["KEY_REMOVED"];
|
|
84
|
+
key: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* This event will be triggered when cache is cleared.
|
|
88
|
+
* @group Events
|
|
89
|
+
*/
|
|
90
|
+
export type KeysClearedCacheEvent = CacheEvent & {
|
|
91
|
+
type: (typeof CACHE_EVENTS)["KEYS_CLEARED"];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* @group Events
|
|
95
|
+
*/
|
|
96
|
+
export type AllCacheEvents<TType> = KeyFoundCacheEvent<TType> | KeyNotFoundCacheEvent | KeyAddedCacheEvent<TType> | KeyUpdatedCacheEvent<TType> | KeyRemovedCacheEvent | KeysClearedCacheEvent | KeyIncrementedCacheEvent | KeyDecrementedCacheEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../cache/implementations/_shared/cache-adapter.test-suite";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
|
+
import { type ICacheAdapter } from "../../../cache/contracts/_module";
|
|
6
|
+
import { type Promisable } from "../../../_shared/types";
|
|
7
|
+
/**
|
|
8
|
+
* @group Utilities
|
|
9
|
+
*/
|
|
10
|
+
export type CacheAdapterTestSuiteSettings = {
|
|
11
|
+
expect: ExpectStatic;
|
|
12
|
+
test: TestAPI;
|
|
13
|
+
describe: SuiteAPI;
|
|
14
|
+
beforeEach: typeof beforeEach;
|
|
15
|
+
createAdapter: () => Promisable<ICacheAdapter>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The <i>cacheAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link ICacheAdapter}</i>.
|
|
19
|
+
* @group Utilities
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
23
|
+
* import { cacheAdapterTestSuite, SqliteCacheAdapter } from "@daiso-tech/core";
|
|
24
|
+
* import Sqlite, { type Database } from "better-sqlite3";
|
|
25
|
+
*
|
|
26
|
+
* describe("class: SqliteCacheAdapter", () => {
|
|
27
|
+
* let database: Database;
|
|
28
|
+
* beforeEach(() => {
|
|
29
|
+
* database = new Sqlite(":memory:");
|
|
30
|
+
* });
|
|
31
|
+
* afterEach(() => {
|
|
32
|
+
* database.close();
|
|
33
|
+
* });
|
|
34
|
+
* cacheAdapterTestSuite({
|
|
35
|
+
* createAdapter: async () => {
|
|
36
|
+
* const cacheAdapter = new SqliteCacheAdapter(database, {
|
|
37
|
+
* tableName: "custom_table",
|
|
38
|
+
* enableTransactions: true,
|
|
39
|
+
* });
|
|
40
|
+
* await cacheAdapter.init();
|
|
41
|
+
* return cacheAdapter;
|
|
42
|
+
* },
|
|
43
|
+
* test,
|
|
44
|
+
* beforeEach,
|
|
45
|
+
* expect,
|
|
46
|
+
* describe,
|
|
47
|
+
* });
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function cacheAdapterTestSuite(settings: CacheAdapterTestSuiteSettings): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Cache
|
|
3
|
+
*/
|
|
4
|
+
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
|
+
import { type ICache } from "../../../cache/contracts/_module";
|
|
6
|
+
import { type Promisable } from "../../../_shared/types";
|
|
7
|
+
/**
|
|
8
|
+
* @group Utilities
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
12
|
+
* import { cacheAdapterTestSuite, SqliteCacheAdapter } from "@daiso-tech/core";
|
|
13
|
+
* import Sqlite, { type Database } from "better-sqlite3";
|
|
14
|
+
*
|
|
15
|
+
* describe("class: Cache", () => {
|
|
16
|
+
* let database: Database;
|
|
17
|
+
* beforeEach(() => {
|
|
18
|
+
* database = new Sqlite(":memory:");
|
|
19
|
+
* });
|
|
20
|
+
* afterEach(() => {
|
|
21
|
+
* database.close();
|
|
22
|
+
* });
|
|
23
|
+
* cacheAdapterTestSuite({
|
|
24
|
+
* createCacheA: async () => {
|
|
25
|
+
* const cacheAdapterA = new SqliteCacheAdapter(database, {
|
|
26
|
+
* tableName: "custom_table",
|
|
27
|
+
* enableTransactions: true,
|
|
28
|
+
* });
|
|
29
|
+
* await cacheAdapterA.init();
|
|
30
|
+
* return new Cache(cacheAdapterA, {
|
|
31
|
+
* rootNamespace: "@a"
|
|
32
|
+
* });
|
|
33
|
+
* },
|
|
34
|
+
* createCacheB: async () => {
|
|
35
|
+
* const cacheAdapterB = new SqliteCacheAdapter(database, {
|
|
36
|
+
* tableName: "custom_table",
|
|
37
|
+
* enableTransactions: true,
|
|
38
|
+
* });
|
|
39
|
+
* await cacheAdapterB.init();
|
|
40
|
+
* return new Cache(cacheAdapterB, {
|
|
41
|
+
* rootNamespace: "@b"
|
|
42
|
+
* });
|
|
43
|
+
* },
|
|
44
|
+
* test,
|
|
45
|
+
* beforeEach,
|
|
46
|
+
* expect,
|
|
47
|
+
* describe,
|
|
48
|
+
* });
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export type CacheTestSuiteSettings = {
|
|
53
|
+
expect: ExpectStatic;
|
|
54
|
+
test: TestAPI;
|
|
55
|
+
describe: SuiteAPI;
|
|
56
|
+
beforeEach: typeof beforeEach;
|
|
57
|
+
createCacheA: () => Promisable<ICache>;
|
|
58
|
+
createCacheB: () => Promisable<ICache>;
|
|
59
|
+
};
|
|
60
|
+
export declare function cacheTestSuite(settings: CacheTestSuiteSettings): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "../../../cache/implementations/adapters/libsql-cache-adapter/_module";
|
|
2
|
+
export * from "../../../cache/implementations/adapters/memory-cache-adapter/_module";
|
|
3
|
+
export * from "../../../cache/implementations/adapters/mongodb-cache-adapter/_module";
|
|
4
|
+
export * from "../../../cache/implementations/adapters/redis-cache-adapter/_module";
|
|
5
|
+
export * from "../../../cache/implementations/adapters/sqlite-cache-adapter/_module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter";
|
|
@@ -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";
|
package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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 Redis, type Result } from "ioredis";
|
|
7
|
+
import type { ISerializer } from "../../../../serializer/contracts/_module";
|
|
8
|
+
declare module "ioredis" {
|
|
9
|
+
interface RedisCommander<Context> {
|
|
10
|
+
daiso_storage_increment(key: string, number: string): Result<number, Context>;
|
|
11
|
+
daiso_storage_put(key: string, value: string): Result<string, Context>;
|
|
12
|
+
daiso_storage_getOrAdd(key: string, valueToAdd: string): Result<string, Context>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @group Adapters
|
|
17
|
+
*/
|
|
18
|
+
export type RedisCacheAdapterSettings = {
|
|
19
|
+
serializer?: ISerializer<string>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @group Adapters
|
|
23
|
+
*/
|
|
24
|
+
export declare class RedisCacheAdapter<TType> implements ICacheAdapter<TType> {
|
|
25
|
+
private readonly client;
|
|
26
|
+
private static isRedisTypeError;
|
|
27
|
+
private serializer;
|
|
28
|
+
constructor(client: Redis, { serializer, }?: RedisCacheAdapterSettings);
|
|
29
|
+
get(key: string): Promise<TType | null>;
|
|
30
|
+
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
31
|
+
update(key: string, value: TType): Promise<boolean>;
|
|
32
|
+
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
33
|
+
remove(key: string): Promise<boolean>;
|
|
34
|
+
private initIncrementCommand;
|
|
35
|
+
increment(key: string, value: number): Promise<boolean>;
|
|
36
|
+
clear(prefix: string): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter";
|