@daiso-tech/core 0.11.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/{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/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/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/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/types/_module.d.ts +2 -2
- 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/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/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
package/dist/types/{storage/contracts/storage.contract.d.ts → cache/contracts/cache.contract.d.ts}
RENAMED
|
@@ -1,182 +1,195 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
import type { IListenable } from "../../event-bus/contracts/_module";
|
|
5
5
|
import type { OneOrMore } from "../../_shared/types";
|
|
6
6
|
import { type AsyncLazyable, type GetOrAddValue } from "../../_shared/types";
|
|
7
|
-
import type {
|
|
8
|
-
import type { LazyPromise } from "../../utilities/_module";
|
|
7
|
+
import type { AllCacheEvents } from "../../cache/contracts/_module";
|
|
8
|
+
import type { LazyPromise, TimeSpan } from "../../utilities/_module";
|
|
9
9
|
/**
|
|
10
|
-
* The <i>
|
|
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
|
|
11
16
|
*/
|
|
12
|
-
export type
|
|
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
|
+
};
|
|
13
24
|
/**
|
|
14
|
-
* The <i>
|
|
15
|
-
* It commes with more convient methods compared to <i>
|
|
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>.
|
|
16
27
|
* @group Contracts
|
|
17
28
|
*/
|
|
18
|
-
export type
|
|
29
|
+
export type ICache<TType = unknown> = ICacheListenable & {
|
|
19
30
|
/**
|
|
20
31
|
* The <i>exists</i> method returns true when <i>key</i> is found otherwise false will be returned.
|
|
21
|
-
* @throws {
|
|
32
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
22
33
|
*/
|
|
23
34
|
exists(key: string): LazyPromise<boolean>;
|
|
24
35
|
/**
|
|
25
36
|
* The <i>existsMany</i> method returns true for the <i>keys</i> that are found otherwise false will be returned.
|
|
26
|
-
* @throws {
|
|
37
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
27
38
|
*/
|
|
28
39
|
existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
29
40
|
/**
|
|
30
41
|
* The <i>missing</i> method returns true when <i>key</i> is not found otherwise false will be returned.
|
|
31
|
-
* @throws {
|
|
42
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
32
43
|
*/
|
|
33
44
|
missing(key: string): LazyPromise<boolean>;
|
|
34
45
|
/**
|
|
35
46
|
* The <i>missingMany</i> method returns true for the <i>keys</i> that are not found otherwise false will be returned.
|
|
36
|
-
* @throws {
|
|
47
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
37
48
|
*/
|
|
38
49
|
missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
39
50
|
/**
|
|
40
51
|
* The <i>get</i> method returns the value when <i>key</i> is found otherwise null will be returned.
|
|
41
|
-
* @throws {
|
|
52
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
42
53
|
*/
|
|
43
54
|
get(key: string): LazyPromise<TType | null>;
|
|
44
55
|
/**
|
|
45
56
|
* The <i>getMany</i> returns the value for the <i>keys</i> that are found otherwise null will be returned.
|
|
46
|
-
* @throws {
|
|
57
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
47
58
|
*/
|
|
48
59
|
getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
|
|
49
60
|
/**
|
|
50
61
|
* The <i>getOr</i> method returns the value when <i>key</i> is found otherwise <i>defaultValue</i> will be returned.
|
|
51
|
-
* @throws {
|
|
62
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
52
63
|
*/
|
|
53
64
|
getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
|
|
54
65
|
/**
|
|
55
66
|
* The <i>getOrMany</i> method returns the value for the keys that are found otherwise defaultValue will be returned.
|
|
56
|
-
* @throws {
|
|
67
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
57
68
|
*/
|
|
58
69
|
getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
|
|
59
70
|
/**
|
|
60
71
|
* The <i>getOrFail</i> method returns the value when <i>key</i> is found otherwise an error will be thrown.
|
|
61
|
-
* @throws {
|
|
62
|
-
* @throws {
|
|
72
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
73
|
+
* @throws {KeyNotFoundCacheError} {@link KeyNotFoundCacheError}
|
|
63
74
|
*/
|
|
64
75
|
getOrFail(key: string): LazyPromise<TType>;
|
|
65
76
|
/**
|
|
66
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.
|
|
67
|
-
*
|
|
78
|
+
* You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
|
|
79
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
68
80
|
*/
|
|
69
|
-
add(key: string, value: TType): LazyPromise<boolean>;
|
|
81
|
+
add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
70
82
|
/**
|
|
71
83
|
* The <i>addMany</i> method adds new keys. Returns true for the keys that where added otherwise false will be returned.
|
|
72
|
-
* @throws {
|
|
84
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
73
85
|
*/
|
|
74
|
-
addMany<TKeys extends string>(values: Record<TKeys, TType
|
|
86
|
+
addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
75
87
|
/**
|
|
76
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.
|
|
77
|
-
* @throws {
|
|
89
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
78
90
|
*/
|
|
79
91
|
update(key: string, value: TType): LazyPromise<boolean>;
|
|
80
92
|
/**
|
|
81
93
|
* The <i>updateMany</i> method updates the given keys. Returns true for the keys that where updated otherwise false will be returned.
|
|
82
|
-
* @throws {
|
|
94
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
83
95
|
*/
|
|
84
96
|
updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
|
|
85
97
|
/**
|
|
86
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.
|
|
87
|
-
*
|
|
99
|
+
* You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
|
|
100
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
88
101
|
*/
|
|
89
|
-
put(key: string, value: TType): LazyPromise<boolean>;
|
|
102
|
+
put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
90
103
|
/**
|
|
91
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.
|
|
92
|
-
* @throws {
|
|
105
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
93
106
|
*/
|
|
94
|
-
putMany<TKeys extends string>(values: Record<TKeys, TType
|
|
107
|
+
putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
95
108
|
/**
|
|
96
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.
|
|
97
|
-
* @throws {
|
|
110
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
98
111
|
*/
|
|
99
112
|
remove(key: string): LazyPromise<boolean>;
|
|
100
113
|
/**
|
|
101
114
|
* The <i>removeMany</i> method removes keys. Returns true for the keys that are removed otherwise false is returned.
|
|
102
|
-
* @throws {
|
|
115
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
103
116
|
*/
|
|
104
117
|
removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
105
118
|
/**
|
|
106
119
|
* The <i>getAndRemove</i> method removes the given <i>key</i> and returns it when found otherwise null will be returned.
|
|
107
|
-
* @throws {
|
|
120
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
108
121
|
*/
|
|
109
122
|
getAndRemove(key: string): LazyPromise<TType | null>;
|
|
110
123
|
/**
|
|
111
124
|
* The <i>getOrAdd</i> method will retrieve the given <i>key</i> if found otherwise <i>valueToAdd</i> will be added and returned.
|
|
112
|
-
* @throws {
|
|
125
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
113
126
|
*/
|
|
114
|
-
getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType
|
|
127
|
+
getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
|
|
115
128
|
/**
|
|
116
129
|
* The <i>increment</i> method will increment the given <i>key</i> if found otherwise nonthing will occur.
|
|
117
130
|
* Returns true if key is incremented otherwise false will be returned.
|
|
118
131
|
* An error will thrown if the key is not a number.
|
|
119
|
-
* @throws {
|
|
120
|
-
* @throws {
|
|
132
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
133
|
+
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
121
134
|
*/
|
|
122
135
|
increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
123
136
|
/**
|
|
124
137
|
* The <i>decrement</i> method will decrement the given <i>key</i> if found otherwise nonthing will occur.
|
|
125
138
|
* Returns true if key exists otherwise false will be returned.
|
|
126
139
|
* An error will thrown if the key is not a number.
|
|
127
|
-
* @throws {
|
|
128
|
-
* @throws {
|
|
140
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
141
|
+
* @throws {TypeCacheError} {@link TypeCacheError}
|
|
129
142
|
* An error will thrown if the key is not a number.
|
|
130
143
|
*/
|
|
131
144
|
decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
132
145
|
/**
|
|
133
|
-
* The <i>clear</i> method removes all the keys in the
|
|
134
|
-
* @throws {
|
|
146
|
+
* The <i>clear</i> method removes all the keys in the cache.
|
|
147
|
+
* @throws {UnexpectedCacheError} {@link UnexpectedCacheError}
|
|
135
148
|
*/
|
|
136
149
|
clear(): LazyPromise<void>;
|
|
137
150
|
/**
|
|
138
151
|
* The <i>getNamespace</i> method returns the complete namespace.
|
|
139
152
|
* @example
|
|
140
153
|
* ```ts
|
|
141
|
-
* import type {
|
|
154
|
+
* import type { ICache } from "@daiso-tech/core";
|
|
142
155
|
*
|
|
143
|
-
* async function main(
|
|
156
|
+
* async function main(cache: ICache) {
|
|
144
157
|
* // Will be "@root"
|
|
145
|
-
* console.log(
|
|
158
|
+
* console.log(cache.getNamespace())
|
|
146
159
|
*
|
|
147
|
-
* const
|
|
160
|
+
* const cacheA = cache.withNamespace("a");
|
|
148
161
|
*
|
|
149
162
|
* // Will be "@root/a"
|
|
150
|
-
* console.log(
|
|
163
|
+
* console.log(cacheA.getNamespace())
|
|
151
164
|
* }
|
|
152
165
|
* ```
|
|
153
166
|
*/
|
|
154
167
|
getNamespace(): string;
|
|
155
168
|
};
|
|
156
169
|
/**
|
|
157
|
-
* The <i>
|
|
158
|
-
* It commes with one extra method which is useful for multitennat applications compared to <i>
|
|
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>.
|
|
159
172
|
* @group Contracts
|
|
160
173
|
*/
|
|
161
|
-
export type
|
|
174
|
+
export type INamespacedCache<TType = unknown> = ICache<TType> & {
|
|
162
175
|
/**
|
|
163
|
-
* The <i>withNamespace</i> method returns new instance of <i>{@link
|
|
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>.
|
|
164
177
|
* This useful for multitennat applications.
|
|
165
178
|
* @example
|
|
166
179
|
* ```ts
|
|
167
|
-
* import { type
|
|
180
|
+
* import { type ICache } from "@daiso-tech/core";
|
|
168
181
|
*
|
|
169
|
-
* async function main(
|
|
170
|
-
* const
|
|
171
|
-
* await
|
|
182
|
+
* async function main(cache: ICache): Promise<void> {
|
|
183
|
+
* const cacheA = cache.withNamespace("a");
|
|
184
|
+
* await cacheA.add("a", 1);
|
|
172
185
|
*
|
|
173
|
-
* const
|
|
174
|
-
* await
|
|
186
|
+
* const cacheB = cache.withNamespace("b");
|
|
187
|
+
* await cacheB.add("b", 2);
|
|
175
188
|
*
|
|
176
189
|
* // Will print { a: 1, b: null }
|
|
177
|
-
* console.log(await
|
|
190
|
+
* console.log(await cacheA.getMany(["a", "b"]));
|
|
178
191
|
* }
|
|
179
192
|
* ```
|
|
180
193
|
*/
|
|
181
|
-
withNamespace(namespace: OneOrMore<string>):
|
|
194
|
+
withNamespace(namespace: OneOrMore<string>): ICache<TType>;
|
|
182
195
|
};
|
package/dist/types/{storage/contracts/storage.errors.d.ts → cache/contracts/cache.errors.d.ts}
RENAMED
|
@@ -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";
|