@daiso-tech/core 0.35.4 → 0.37.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.
Files changed (194) hide show
  1. package/README.md +22 -54
  2. package/dist/async/backof-policies/_shared.d.ts +8 -2
  3. package/dist/async/backof-policies/_shared.js +0 -1
  4. package/dist/async/backof-policies/_shared.js.map +1 -1
  5. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +3 -3
  6. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +10 -4
  7. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -1
  8. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +3 -3
  9. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +10 -4
  10. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -1
  11. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +3 -3
  12. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +10 -4
  13. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -1
  14. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +3 -3
  15. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +10 -4
  16. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -1
  17. package/dist/async/middlewares/_shared.d.ts +6 -1
  18. package/dist/async/middlewares/_shared.js +11 -1
  19. package/dist/async/middlewares/_shared.js.map +1 -1
  20. package/dist/async/middlewares/fallback/fallback.middleware.d.ts +3 -3
  21. package/dist/async/middlewares/fallback/fallback.middleware.js +3 -2
  22. package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
  23. package/dist/async/middlewares/hedging/_shared.d.ts +7 -7
  24. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +7 -7
  25. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -1
  26. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +6 -6
  27. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -1
  28. package/dist/async/middlewares/observe/observe.middleware.d.ts +4 -4
  29. package/dist/async/middlewares/retry/retry.middleware.d.ts +5 -4
  30. package/dist/async/middlewares/retry/retry.middleware.js +10 -10
  31. package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
  32. package/dist/async/middlewares/timeout/timeout.middleware.d.ts +4 -2
  33. package/dist/async/middlewares/timeout/timeout.middleware.js +3 -1
  34. package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -1
  35. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +1 -1
  36. package/dist/async/utilities/lazy-promise/lazy-promise.js +1 -1
  37. package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -1
  38. package/dist/cache/contracts/cache-factory.contract.d.ts +2 -2
  39. package/dist/cache/contracts/cache.errors.d.ts +3 -3
  40. package/dist/cache/contracts/cache.errors.js +1 -1
  41. package/dist/cache/contracts/cache.errors.js.map +1 -1
  42. package/dist/cache/implementations/adapters/_module-exports.d.ts +1 -2
  43. package/dist/cache/implementations/adapters/_module-exports.js +1 -2
  44. package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
  45. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +41 -16
  46. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +102 -57
  47. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -1
  48. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +1 -1
  49. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  50. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +4 -1
  51. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  52. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +1 -1
  53. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +1 -1
  54. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  55. package/dist/cache/implementations/derivables/cache/cache.d.ts +27 -11
  56. package/dist/cache/implementations/derivables/cache/cache.js +38 -34
  57. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  58. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +15 -47
  59. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +19 -45
  60. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  61. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +4 -5
  62. package/dist/cache/implementations/test-utilities/cache.test-suite.js +4 -5
  63. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  64. package/dist/collection/contracts/async-collection.contract.d.ts +127 -121
  65. package/dist/collection/contracts/collection.contract.d.ts +126 -120
  66. package/dist/collection/contracts/collection.errors.d.ts +3 -3
  67. package/dist/collection/contracts/collection.errors.js +1 -1
  68. package/dist/collection/contracts/collection.errors.js.map +1 -1
  69. package/dist/collection/implementations/_shared.d.ts +4 -4
  70. package/dist/collection/implementations/_shared.js +2 -2
  71. package/dist/collection/implementations/_shared.js.map +1 -1
  72. package/dist/collection/implementations/async-iterable-collection/_shared/_module.d.ts +1 -0
  73. package/dist/collection/implementations/async-iterable-collection/_shared/_module.js +1 -0
  74. package/dist/collection/implementations/async-iterable-collection/_shared/_module.js.map +1 -1
  75. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.d.ts +7 -0
  76. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js +17 -0
  77. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js.map +1 -0
  78. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +15 -13
  79. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +19 -16
  80. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  81. package/dist/collection/implementations/iterable-collection/_shared/_module.d.ts +1 -0
  82. package/dist/collection/implementations/iterable-collection/_shared/_module.js +1 -0
  83. package/dist/collection/implementations/iterable-collection/_shared/_module.js.map +1 -1
  84. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.d.ts +7 -0
  85. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js +21 -0
  86. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js.map +1 -0
  87. package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +14 -12
  88. package/dist/collection/implementations/iterable-collection/iterable-collection.js +16 -13
  89. package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  90. package/dist/collection/implementations/list-collection/list-collection.d.ts +14 -12
  91. package/dist/collection/implementations/list-collection/list-collection.js +26 -13
  92. package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
  93. package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +2 -2
  94. package/dist/event-bus/contracts/event-bus.contract.d.ts +2 -2
  95. package/dist/event-bus/contracts/event-bus.errors.d.ts +3 -3
  96. package/dist/event-bus/contracts/event-bus.errors.js +1 -1
  97. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  98. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +1 -1
  99. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +1 -1
  100. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +46 -9
  101. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +64 -22
  102. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  103. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +12 -41
  104. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +15 -35
  105. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  106. package/dist/lock/contracts/lock.errors.d.ts +2 -2
  107. package/dist/lock/contracts/lock.errors.js.map +1 -1
  108. package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -2
  109. package/dist/lock/implementations/adapters/_module-exports.js +1 -2
  110. package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
  111. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +40 -15
  112. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +75 -34
  113. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
  114. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +6 -3
  115. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +1 -1
  116. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
  117. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +22 -18
  118. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +20 -22
  119. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  120. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +3 -3
  121. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +12 -6
  122. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  123. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +4 -2
  124. package/dist/lock/implementations/derivables/lock-provider/lock.js +16 -18
  125. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  126. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +6 -50
  127. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +10 -54
  128. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  129. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +1 -9
  130. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +1 -9
  131. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  132. package/dist/serde/contracts/flexible-serde.contract.d.ts +9 -2
  133. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +1 -1
  134. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  135. package/dist/utilities/classes/_module.d.ts +1 -1
  136. package/dist/utilities/classes/_module.js +1 -1
  137. package/dist/utilities/classes/_module.js.map +1 -1
  138. package/dist/utilities/classes/hooks/hooks.d.ts +2 -2
  139. package/dist/utilities/classes/hooks/hooks.js +2 -2
  140. package/dist/utilities/classes/namespace/_module.d.ts +1 -0
  141. package/dist/utilities/classes/namespace/_module.js +2 -0
  142. package/dist/utilities/classes/namespace/_module.js.map +1 -0
  143. package/dist/utilities/classes/{key-prefixer/key-prefixer.d.ts → namespace/namespace.d.ts} +38 -17
  144. package/dist/utilities/classes/{key-prefixer/key-prefixer.js → namespace/namespace.js} +51 -19
  145. package/dist/utilities/classes/namespace/namespace.js.map +1 -0
  146. package/dist/utilities/classes/time-span/time-span.d.ts +1 -2
  147. package/dist/utilities/classes/time-span/time-span.js +1 -4
  148. package/dist/utilities/classes/time-span/time-span.js.map +1 -1
  149. package/dist/utilities/functions/_module-exports.d.ts +2 -1
  150. package/dist/utilities/functions/_module-exports.js +2 -1
  151. package/dist/utilities/functions/_module-exports.js.map +1 -1
  152. package/dist/utilities/functions/lazy.d.ts +4 -0
  153. package/dist/utilities/functions/lazy.js +9 -3
  154. package/dist/utilities/functions/lazy.js.map +1 -1
  155. package/dist/utilities/functions/result.d.ts +11 -0
  156. package/dist/utilities/functions/result.js +15 -0
  157. package/dist/utilities/functions/result.js.map +1 -0
  158. package/dist/utilities/functions/validate.d.ts +8 -0
  159. package/dist/utilities/functions/validate.js +17 -0
  160. package/dist/utilities/functions/validate.js.map +1 -0
  161. package/dist/utilities/types/factory.type.d.ts +13 -18
  162. package/dist/utilities/types/result.type.d.ts +11 -1
  163. package/package.json +15 -11
  164. package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +0 -1
  165. package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.js +0 -2
  166. package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +0 -1
  167. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +0 -61
  168. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -95
  169. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +0 -1
  170. package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +0 -1
  171. package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.js +0 -2
  172. package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +0 -1
  173. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +0 -59
  174. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -94
  175. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +0 -1
  176. package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.d.ts +0 -1
  177. package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.js +0 -2
  178. package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.js.map +0 -1
  179. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +0 -60
  180. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +0 -84
  181. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +0 -1
  182. package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.d.ts +0 -1
  183. package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.js +0 -2
  184. package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.js.map +0 -1
  185. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +0 -59
  186. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +0 -83
  187. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +0 -1
  188. package/dist/utilities/classes/key-prefixer/_module.d.ts +0 -1
  189. package/dist/utilities/classes/key-prefixer/_module.js +0 -2
  190. package/dist/utilities/classes/key-prefixer/_module.js.map +0 -1
  191. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +0 -1
  192. package/dist/utilities/functions/factory.d.ts +0 -44
  193. package/dist/utilities/functions/factory.js +0 -80
  194. package/dist/utilities/functions/factory.js.map +0 -1
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@daiso-tech/core",
3
3
  "private": false,
4
- "version": "0.35.4",
4
+ "version": "0.37.0",
5
5
  "author": "Yousif Abdulkarim",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
- "homepage": "https://yousif-khalil-abdulkarim.github.io/daiso-core/modules.html",
8
+ "homepage": "http://daiso-core.vercel.app/",
9
9
  "description": "The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -158,10 +158,12 @@
158
158
  },
159
159
  "devDependencies": {
160
160
  "@changesets/cli": "^2.27.7",
161
- "@libsql/client": "^0.14.0",
162
161
  "@testcontainers/mongodb": "^10.13.2",
162
+ "@testcontainers/mysql": "^11.0.0",
163
+ "@testcontainers/postgresql": "^11.0.0",
163
164
  "@testcontainers/redis": "^10.13.2",
164
165
  "@types/better-sqlite3": "^7.6.11",
166
+ "@types/pg": "^8.15.4",
165
167
  "@types/uuid": "^10.0.0",
166
168
  "@typescript-eslint/eslint-plugin": "^8.1.0",
167
169
  "@typescript-eslint/parser": "^8.1.0",
@@ -176,7 +178,10 @@
176
178
  "eslint-plugin-typescript-enum": "^2.1.0",
177
179
  "eslint-plugin-vitest": "^0.5.4",
178
180
  "ioredis": "^5.4.1",
181
+ "kysely": "^0.28.2",
179
182
  "mongodb": "^6.10.0",
183
+ "mysql2": "^3.14.1",
184
+ "pg": "^8.16.0",
180
185
  "publint": "^0.3.8",
181
186
  "rimraf": "^6.0.1",
182
187
  "tsc-alias": "^1.8.10",
@@ -184,13 +189,13 @@
184
189
  "typedoc-plugin-merge-modules": "6.1.0",
185
190
  "typescript": "^5.5.4",
186
191
  "vite-tsconfig-paths": "^4.3.2",
187
- "vitest": "^3.0.2"
192
+ "vitest": "^3.0.2",
193
+ "zod": "^3.25.49"
188
194
  },
189
195
  "peerDependencies": {
190
- "@libsql/client": "^0.4.1",
191
- "better-sqlite3": "^11.5.0",
192
- "ioredis": "^5.4.1",
193
- "mongodb": "^6.10.0"
196
+ "ioredis": "^5.0.0",
197
+ "mongodb": "^6.0.0",
198
+ "kysely": "^0.28.0"
194
199
  },
195
200
  "peerDependenciesMeta": {
196
201
  "mongodb": {
@@ -207,10 +212,9 @@
207
212
  }
208
213
  },
209
214
  "dependencies": {
210
- "@libsql/kysely-libsql": "^0.4.0",
215
+ "@standard-schema/spec": "^1.0.0",
211
216
  "escape-string-regexp": "^5.0.0",
212
- "kysely": "^0.27.0",
213
- "superjson-cjs": "^2.2.3",
217
+ "superjson": "^2.2.2",
214
218
  "uuid": "^11.0.5"
215
219
  }
216
220
  }
@@ -1 +0,0 @@
1
- export * from "../../../../cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js";
@@ -1,2 +0,0 @@
1
- export * from "../../../../cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js";
2
- //# sourceMappingURL=_module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/libsql-cache-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+EAA+E,CAAC"}
@@ -1,61 +0,0 @@
1
- /**
2
- * @module Cache
3
- */
4
- import type { ICacheData, ICacheInsert, ICacheUpdate, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
5
- import type { TimeSpan, IDeinitizable, IInitizable, IPrunable } from "../../../../utilities/_module-exports.js";
6
- import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
7
- import type { Client } from "@libsql/client";
8
- /**
9
- *
10
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
11
- * @group Adapters
12
- */
13
- export type LibsqlCacheAdapterSettings = {
14
- database: Client;
15
- tableName?: string;
16
- serde: ISerde<string>;
17
- disableTransaction?: boolean;
18
- expiredKeysRemovalInterval?: TimeSpan;
19
- shouldRemoveExpiredKeys?: boolean;
20
- };
21
- /**
22
- * To utilize the `LibsqlCacheAdapter`, you must install the `"@libsql/client"` package and supply a {@link ISerde | `ISerde<string>`}, with an adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
23
- *
24
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
25
- * @group Adapters
26
- */
27
- export declare class LibsqlCacheAdapter<TType = unknown> implements IDatabaseCacheAdapter<TType>, IInitizable, IDeinitizable, IPrunable {
28
- private readonly adapter;
29
- /***
30
- * @example
31
- * ```ts
32
- * import { LibsqlCacheAdapter } from "@daiso-tech/core/cache/adapters";
33
- * import { Serde } from "@daiso-tech/core/serde";
34
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
35
- * import { createClient } from "@libsql/client";
36
- *
37
- * const database = createClient({ url: "file:local.db" });
38
- * const serde = new Serde(new SuperJsonSerdeAdapter());
39
- * const cacheAdapter = new LibsqlCacheAdapter({
40
- * database,
41
- * serde,
42
- * });
43
- * // You need initialize the adapter once before using it.
44
- * await cacheAdapter.init();
45
- * ```
46
- */
47
- constructor(settings: LibsqlCacheAdapterSettings);
48
- removeAllExpired(): Promise<void>;
49
- deInit(): Promise<void>;
50
- init(): Promise<void>;
51
- insert(data: ICacheInsert<TType>): Promise<void>;
52
- upsert(data: ICacheInsert<TType>): Promise<ICacheData<TType> | null>;
53
- find(key: string): Promise<ICacheData<TType> | null>;
54
- updateExpired(data: ICacheInsert<TType>): Promise<number>;
55
- updateUnexpired(data: ICacheUpdate<TType>): Promise<number>;
56
- incrementUnexpired(data: ICacheUpdate<number>): Promise<number>;
57
- removeUnexpiredMany(keys: string[]): Promise<number>;
58
- removeExpiredMany(keys: string[]): Promise<number>;
59
- removeAll(): Promise<void>;
60
- removeByKeyPrefix(prefix: string): Promise<void>;
61
- }
@@ -1,95 +0,0 @@
1
- /**
2
- * @module Cache
3
- */
4
- import { KyselyCacheAdapter } from "../../../../cache/implementations/adapters/kysely-cache-adapter/_module.js";
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- import { SuperJsonSerdeAdapter } from "../../../../serde/implementations/adapters/_module-exports.js";
7
- import { Kysely } from "kysely";
8
- import { LibsqlDialect } from "@libsql/kysely-libsql";
9
- import { KyselyTableNameTransformerPlugin } from "../../../../utilities/_module-exports.js";
10
- /**
11
- * To utilize the `LibsqlCacheAdapter`, you must install the `"@libsql/client"` package and supply a {@link ISerde | `ISerde<string>`}, with an adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
12
- *
13
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
14
- * @group Adapters
15
- */
16
- export class LibsqlCacheAdapter {
17
- adapter;
18
- /***
19
- * @example
20
- * ```ts
21
- * import { LibsqlCacheAdapter } from "@daiso-tech/core/cache/adapters";
22
- * import { Serde } from "@daiso-tech/core/serde";
23
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
24
- * import { createClient } from "@libsql/client";
25
- *
26
- * const database = createClient({ url: "file:local.db" });
27
- * const serde = new Serde(new SuperJsonSerdeAdapter());
28
- * const cacheAdapter = new LibsqlCacheAdapter({
29
- * database,
30
- * serde,
31
- * });
32
- * // You need initialize the adapter once before using it.
33
- * await cacheAdapter.init();
34
- * ```
35
- */
36
- constructor(settings) {
37
- const { database, tableName = "cache", serde, disableTransaction, expiredKeysRemovalInterval, shouldRemoveExpiredKeys, } = settings;
38
- this.adapter = new KyselyCacheAdapter({
39
- database: new Kysely({
40
- dialect: new LibsqlDialect({
41
- client: database,
42
- }),
43
- plugins: [
44
- new KyselyTableNameTransformerPlugin({
45
- cache: tableName,
46
- }),
47
- ],
48
- }),
49
- serde,
50
- disableTransaction,
51
- expiredKeysRemovalInterval,
52
- shouldRemoveExpiredKeys,
53
- });
54
- }
55
- async removeAllExpired() {
56
- await this.adapter.removeAllExpired();
57
- }
58
- async deInit() {
59
- await this.adapter.deInit();
60
- }
61
- async init() {
62
- await this.adapter.init();
63
- }
64
- async insert(data) {
65
- await this.adapter.insert(data);
66
- }
67
- async upsert(data) {
68
- return await this.adapter.upsert(data);
69
- }
70
- async find(key) {
71
- return await this.adapter.find(key);
72
- }
73
- async updateExpired(data) {
74
- return await this.adapter.updateExpired(data);
75
- }
76
- async updateUnexpired(data) {
77
- return await this.adapter.updateUnexpired(data);
78
- }
79
- async incrementUnexpired(data) {
80
- return await this.adapter.incrementUnexpired(data);
81
- }
82
- async removeUnexpiredMany(keys) {
83
- return await this.adapter.removeUnexpiredMany(keys);
84
- }
85
- async removeExpiredMany(keys) {
86
- return await this.adapter.removeExpiredMany(keys);
87
- }
88
- async removeAll() {
89
- await this.adapter.removeAll();
90
- }
91
- async removeByKeyPrefix(prefix) {
92
- await this.adapter.removeByKeyPrefix(prefix);
93
- }
94
- }
95
- //# sourceMappingURL=libsql-cache-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libsql-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AACtG,6DAA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AClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QAClB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAyB;QACzC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,IAAyB;QAC3C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAA0B;QAC/C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAc;QACpC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAc;QAClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ"}
@@ -1 +0,0 @@
1
- export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js";
@@ -1,2 +0,0 @@
1
- export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js";
2
- //# sourceMappingURL=_module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/sqlite-cache-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+EAA+E,CAAC"}
@@ -1,59 +0,0 @@
1
- /**
2
- * @module Cache
3
- */
4
- import { type ICacheData, type ICacheInsert, type ICacheUpdate, type IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
5
- import { type TimeSpan, type IInitizable, type IDeinitizable, type IPrunable, type ISqliteDatabase } from "../../../../utilities/_module-exports.js";
6
- import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
7
- /**
8
- *
9
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
10
- * @group Adapters
11
- */
12
- export type SqliteCacheAdapterSettings = {
13
- database: ISqliteDatabase;
14
- tableName?: string;
15
- serde: ISerde<string>;
16
- expiredKeysRemovalInterval?: TimeSpan;
17
- shouldRemoveExpiredKeys?: boolean;
18
- };
19
- /**
20
- * To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
21
- *
22
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
23
- * @group Adapters
24
- */
25
- export declare class SqliteCacheAdapter<TType = unknown> implements IDatabaseCacheAdapter<TType>, IInitizable, IDeinitizable, IPrunable {
26
- private readonly adapter;
27
- /**
28
- * @example
29
- * ```ts
30
- * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
31
- * import { Serde } from "@daiso-tech/core/serde";
32
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
33
- * import Sqlite from "better-sqlite3";
34
- *
35
- * const database = new Sqlite("local.db");
36
- * const serde = new Serde(new SuperJsonSerdeAdapter());
37
- * const cacheAdapter = new SqliteCacheAdapter({
38
- * database,
39
- * serde,
40
- * });
41
- * // You need initialize the adapter once before using it.
42
- * await cacheAdapter.init();
43
- * ```
44
- */
45
- constructor(settings: SqliteCacheAdapterSettings);
46
- removeAllExpired(): Promise<void>;
47
- deInit(): Promise<void>;
48
- init(): Promise<void>;
49
- insert(data: ICacheInsert<TType>): Promise<void>;
50
- upsert(data: ICacheInsert<TType>): Promise<ICacheData<TType> | null>;
51
- find(key: string): Promise<ICacheData<TType> | null>;
52
- updateExpired(data: ICacheInsert<TType>): Promise<number>;
53
- updateUnexpired(data: ICacheUpdate<TType>): Promise<number>;
54
- incrementUnexpired(data: ICacheUpdate<number>): Promise<number>;
55
- removeUnexpiredMany(keys: string[]): Promise<number>;
56
- removeExpiredMany(keys: string[]): Promise<number>;
57
- removeAll(): Promise<void>;
58
- removeByKeyPrefix(prefix: string): Promise<void>;
59
- }
@@ -1,94 +0,0 @@
1
- /**
2
- * @module Cache
3
- */
4
- import {} from "../../../../cache/contracts/_module-exports.js";
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- import { SuperJsonSerdeAdapter } from "../../../../serde/implementations/adapters/_module-exports.js";
7
- import { KyselyTableNameTransformerPlugin, } from "../../../../utilities/_module-exports.js";
8
- import { Kysely, SqliteDialect } from "kysely";
9
- import { KyselyCacheAdapter } from "../../../../cache/implementations/adapters/kysely-cache-adapter/_module.js";
10
- /**
11
- * To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
12
- *
13
- * IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
14
- * @group Adapters
15
- */
16
- export class SqliteCacheAdapter {
17
- adapter;
18
- /**
19
- * @example
20
- * ```ts
21
- * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
22
- * import { Serde } from "@daiso-tech/core/serde";
23
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
24
- * import Sqlite from "better-sqlite3";
25
- *
26
- * const database = new Sqlite("local.db");
27
- * const serde = new Serde(new SuperJsonSerdeAdapter());
28
- * const cacheAdapter = new SqliteCacheAdapter({
29
- * database,
30
- * serde,
31
- * });
32
- * // You need initialize the adapter once before using it.
33
- * await cacheAdapter.init();
34
- * ```
35
- */
36
- constructor(settings) {
37
- const { database, tableName = "cache", serde, expiredKeysRemovalInterval, shouldRemoveExpiredKeys, } = settings;
38
- this.adapter = new KyselyCacheAdapter({
39
- database: new Kysely({
40
- dialect: new SqliteDialect({
41
- database: database,
42
- }),
43
- plugins: [
44
- new KyselyTableNameTransformerPlugin({
45
- cache: tableName,
46
- }),
47
- ],
48
- }),
49
- serde,
50
- expiredKeysRemovalInterval,
51
- shouldRemoveExpiredKeys,
52
- });
53
- }
54
- async removeAllExpired() {
55
- await this.adapter.removeAllExpired();
56
- }
57
- async deInit() {
58
- await this.adapter.deInit();
59
- }
60
- async init() {
61
- await this.adapter.init();
62
- }
63
- async insert(data) {
64
- await this.adapter.insert(data);
65
- }
66
- async upsert(data) {
67
- return await this.adapter.upsert(data);
68
- }
69
- async find(key) {
70
- return await this.adapter.find(key);
71
- }
72
- async updateExpired(data) {
73
- return await this.adapter.updateExpired(data);
74
- }
75
- async updateUnexpired(data) {
76
- return await this.adapter.updateUnexpired(data);
77
- }
78
- async incrementUnexpired(data) {
79
- return await this.adapter.incrementUnexpired(data);
80
- }
81
- async removeUnexpiredMany(keys) {
82
- return await this.adapter.removeUnexpiredMany(keys);
83
- }
84
- async removeExpiredMany(keys) {
85
- return await this.adapter.removeExpiredMany(keys);
86
- }
87
- async removeAll() {
88
- await this.adapter.removeAll();
89
- }
90
- async removeByKeyPrefix(prefix) {
91
- await this.adapter.removeByKeyPrefix(prefix);
92
- }
93
- }
94
- //# sourceMappingURL=sqlite-cache-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAKN,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AM,CAAC,IAAyB;QAClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QAClB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAyB;QACzC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,IAAyB;QAC3C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAA0B;QAC/C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAc;QACpC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAc;QAClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ"}
@@ -1 +0,0 @@
1
- export * from "../../../../lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js";
@@ -1,2 +0,0 @@
1
- export * from "../../../../lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js";
2
- //# sourceMappingURL=_module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/libsql-lock-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,4EAA4E,CAAC"}
@@ -1,60 +0,0 @@
1
- /**
2
- * @module Lock
3
- */
4
- import type { IDatabaseLockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js";
5
- import { type IDeinitizable, type IInitizable, TimeSpan } from "../../../../utilities/_module-exports.js";
6
- import type { Client } from "@libsql/client";
7
- /**
8
- *
9
- * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
10
- * @group Adapters
11
- */
12
- export type LibsqlLockAdapterSettings = {
13
- database: Client;
14
- tableName?: string;
15
- expiredKeysRemovalInterval?: TimeSpan;
16
- shouldRemoveExpiredKeys?: boolean;
17
- };
18
- /**
19
- * To utilize the `LibsqlLockAdapter`, you must install the `"@libsql/client"` package.
20
- *
21
- * Note in order to use `LibsqlLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
22
- * This means you can't use libsql embedded replicas.
23
- *
24
- * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
25
- * @group Adapters
26
- */
27
- export declare class LibsqlLockAdapter implements IDatabaseLockAdapter, IDeinitizable, IInitizable {
28
- private databaseLockAdapter;
29
- /***
30
- * @example
31
- * ```ts
32
- * import { LibsqlLockAdapter } from "@daiso-tech/core/lock/adapters";
33
- * import { createClient } from "@libsql/client";
34
- *
35
- * const database = createClient({ url: "file:local.db" });
36
- * const lockAdapter = new LibsqlLockAdapter({
37
- * database,
38
- * });
39
- * // You need initialize the adapter once before using it.
40
- * await lockAdapter.init();
41
- * ```
42
- */
43
- constructor(settings: LibsqlLockAdapterSettings);
44
- removeExpiredKeys(): Promise<void>;
45
- /**
46
- * Removes the table where the lock keys are stored and removes the table indexes.
47
- * Note all lock data will be removed.
48
- */
49
- deInit(): Promise<void>;
50
- /**
51
- * Creates the table where the lock keys are stored and it's related indexes.
52
- * Note the `init` method needs to be called before using the adapter.
53
- */
54
- init(): Promise<void>;
55
- insert(key: string, owner: string, expiration: Date | null): Promise<void>;
56
- update(key: string, owner: string, expiration: Date | null): Promise<number>;
57
- remove(key: string, owner: string | null): Promise<void>;
58
- refresh(key: string, owner: string, expiration: Date): Promise<number>;
59
- find(key: string): Promise<ILockData | null>;
60
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * @module Lock
3
- */
4
- import { TimeSpan, } from "../../../../utilities/_module-exports.js";
5
- import { Kysely } from "kysely";
6
- import { KyselyTableNameTransformerPlugin } from "../../../../utilities/_module-exports.js";
7
- import { LibsqlDialect } from "@libsql/kysely-libsql";
8
- import { KyselyLockAdapter } from "../../../../lock/implementations/adapters/kysely-lock-adapter/_module.js";
9
- /**
10
- * To utilize the `LibsqlLockAdapter`, you must install the `"@libsql/client"` package.
11
- *
12
- * Note in order to use `LibsqlLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
13
- * This means you can't use libsql embedded replicas.
14
- *
15
- * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
16
- * @group Adapters
17
- */
18
- export class LibsqlLockAdapter {
19
- databaseLockAdapter;
20
- /***
21
- * @example
22
- * ```ts
23
- * import { LibsqlLockAdapter } from "@daiso-tech/core/lock/adapters";
24
- * import { createClient } from "@libsql/client";
25
- *
26
- * const database = createClient({ url: "file:local.db" });
27
- * const lockAdapter = new LibsqlLockAdapter({
28
- * database,
29
- * });
30
- * // You need initialize the adapter once before using it.
31
- * await lockAdapter.init();
32
- * ```
33
- */
34
- constructor(settings) {
35
- const { database, tableName = "lock", expiredKeysRemovalInterval = TimeSpan.fromMinutes(1), shouldRemoveExpiredKeys = true, } = settings;
36
- this.databaseLockAdapter = new KyselyLockAdapter({
37
- database: new Kysely({
38
- dialect: new LibsqlDialect({
39
- client: database,
40
- }),
41
- plugins: [
42
- new KyselyTableNameTransformerPlugin({
43
- lock: tableName,
44
- }),
45
- ],
46
- }),
47
- expiredKeysRemovalInterval,
48
- shouldRemoveExpiredKeys,
49
- });
50
- }
51
- async removeExpiredKeys() {
52
- await this.databaseLockAdapter.removeExpiredKeys();
53
- }
54
- /**
55
- * Removes the table where the lock keys are stored and removes the table indexes.
56
- * Note all lock data will be removed.
57
- */
58
- async deInit() {
59
- await this.databaseLockAdapter.deInit();
60
- }
61
- /**
62
- * Creates the table where the lock keys are stored and it's related indexes.
63
- * Note the `init` method needs to be called before using the adapter.
64
- */
65
- async init() {
66
- await this.databaseLockAdapter.init();
67
- }
68
- async insert(key, owner, expiration) {
69
- await this.databaseLockAdapter.insert(key, owner, expiration);
70
- }
71
- async update(key, owner, expiration) {
72
- return await this.databaseLockAdapter.update(key, owner, expiration);
73
- }
74
- async remove(key, owner) {
75
- await this.databaseLockAdapter.remove(key, owner);
76
- }
77
- async refresh(key, owner, expiration) {
78
- return await this.databaseLockAdapter.refresh(key, owner, expiration);
79
- }
80
- async find(key) {
81
- return await this.databaseLockAdapter.find(key);
82
- }
83
- }
84
- //# sourceMappingURL=libsql-lock-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libsql-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAGH,QAAQ,GACX,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AAenG;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAGlB,mBAAmB,CAAoB;IAE/C;;;;;;;;;;;;;OAaG;IACH,YAAY,QAAmC;QAC3C,MAAM,EACF,QAAQ,EACR,SAAS,GAAG,MAAM,EAClB,0BAA0B,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC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AO,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QAClB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;CACJ"}
@@ -1 +0,0 @@
1
- export * from "../../../../lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js";
@@ -1,2 +0,0 @@
1
- export * from "../../../../lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js";
2
- //# sourceMappingURL=_module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/sqlite-lock-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,4EAA4E,CAAC"}
@@ -1,59 +0,0 @@
1
- /**
2
- * @module Lock
3
- */
4
- import type { IDatabaseLockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js";
5
- import { type IDeinitizable, type IInitizable, type ISqliteDatabase, TimeSpan } from "../../../../utilities/_module-exports.js";
6
- /**
7
- *
8
- * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
9
- * @group Adapters
10
- */
11
- export type SqliteLockAdapterSettings = {
12
- database: ISqliteDatabase;
13
- tableName?: string;
14
- expiredKeysRemovalInterval?: TimeSpan;
15
- shouldRemoveExpiredKeys?: boolean;
16
- };
17
- /**
18
- * To utilize the `SqliteLockAdapter`, you must install the `"better-sqlite3"` and `"@types/better-sqlite3"` packages.
19
- *
20
- * Note the `SqliteLockAdapter` is limited to single server usage and cannot be shared across multiple servers but it can be shared between different processes.
21
- * To use it correctly, ensure all process instances access the same consistent, persisted database.
22
- *
23
- * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
24
- * @group Adapters
25
- */
26
- export declare class SqliteLockAdapter implements IDatabaseLockAdapter, IDeinitizable, IInitizable {
27
- private databaseLockAdapter;
28
- /**
29
- * @example
30
- * ```ts
31
- * import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
32
- * import Sqlite from "better-sqlite3";
33
- *
34
- * const database = new Sqlite("local.db");
35
- * const lockAdapter = new SqliteLockAdapter({
36
- * database,
37
- * });
38
- * // You need initialize the adapter once before using it.
39
- * await lockAdapter.init();
40
- * ```
41
- */
42
- constructor(settings: SqliteLockAdapterSettings);
43
- removeExpiredKeys(): Promise<void>;
44
- /**
45
- * Removes the table where the lock keys are stored and removes the table indexes.
46
- * Note all lock data will be removed.
47
- */
48
- deInit(): Promise<void>;
49
- /**
50
- * Creates the table where the lock keys are stored and it's related indexes.
51
- * Note the `init` method needs to be called before using the adapter.
52
- */
53
- init(): Promise<void>;
54
- insert(key: string, owner: string, expiration: Date | null): Promise<void>;
55
- update(key: string, owner: string, expiration: Date | null): Promise<number>;
56
- remove(key: string, owner: string | null): Promise<void>;
57
- refresh(key: string, owner: string, expiration: Date): Promise<number>;
58
- find(key: string): Promise<ILockData | null>;
59
- }