@daiso-tech/core 0.26.0 → 0.27.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 (275) hide show
  1. package/README.md +10 -0
  2. package/dist/async/utilities/delay/delay.d.ts +1 -12
  3. package/dist/async/utilities/delay/delay.js +1 -12
  4. package/dist/async/utilities/delay/delay.js.map +1 -1
  5. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +99 -65
  6. package/dist/async/utilities/lazy-promise/lazy-promise.js +151 -111
  7. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  8. package/dist/cache/contracts/_module-exports.d.ts +1 -0
  9. package/dist/cache/contracts/_module-exports.js +1 -0
  10. package/dist/cache/contracts/_module-exports.js.map +1 -1
  11. package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
  12. package/dist/cache/contracts/cache-adapter.contract.js +1 -4
  13. package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
  14. package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
  15. package/dist/cache/contracts/cache.contract.d.ts +52 -88
  16. package/dist/cache/contracts/cache.contract.js +1 -2
  17. package/dist/cache/contracts/cache.contract.js.map +1 -1
  18. package/dist/cache/contracts/cache.errors.js +2 -5
  19. package/dist/cache/contracts/cache.errors.js.map +1 -1
  20. package/dist/cache/contracts/cache.events.d.ts +10 -10
  21. package/dist/cache/contracts/cache.events.js +2 -5
  22. package/dist/cache/contracts/cache.events.js.map +1 -1
  23. package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
  24. package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
  25. package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
  26. package/dist/cache/implementations/adapters/_module-exports.d.ts +0 -1
  27. package/dist/cache/implementations/adapters/_module-exports.js +0 -1
  28. package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
  29. package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
  30. package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
  31. package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
  32. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
  33. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
  34. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
  35. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
  36. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
  37. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
  38. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
  39. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
  40. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  41. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
  42. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
  43. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
  44. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
  45. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
  46. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  47. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
  48. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
  49. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
  50. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
  51. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
  52. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  53. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
  54. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
  55. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
  56. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -40
  57. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
  58. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
  59. package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
  60. package/dist/cache/implementations/derivables/_module-exports.js +1 -1
  61. package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
  62. package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
  63. package/dist/cache/implementations/derivables/cache/_module.js +1 -0
  64. package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
  65. package/dist/cache/implementations/derivables/cache/cache.d.ts +122 -565
  66. package/dist/cache/implementations/derivables/cache/cache.js +342 -854
  67. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  68. package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
  69. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
  70. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
  71. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
  72. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
  73. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
  74. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +65 -104
  75. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +101 -85
  76. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  77. package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
  78. package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
  79. package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
  80. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
  81. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
  82. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
  83. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
  84. package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
  85. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  86. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
  87. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
  88. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
  89. package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
  90. package/dist/collection/contracts/async-collection.contract.js +1 -12
  91. package/dist/collection/contracts/async-collection.contract.js.map +1 -1
  92. package/dist/collection/contracts/collection.contract.d.ts +1 -1
  93. package/dist/collection/contracts/collection.errors.d.ts +1 -1
  94. package/dist/collection/contracts/collection.errors.js +3 -6
  95. package/dist/collection/contracts/collection.errors.js.map +1 -1
  96. package/dist/collection/implementations/_shared.d.ts +4 -4
  97. package/dist/collection/implementations/_shared.js +6 -9
  98. package/dist/collection/implementations/_shared.js.map +1 -1
  99. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
  100. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
  101. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +1 -1
  102. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +6 -5
  103. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  104. package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
  105. package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
  106. package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
  107. package/dist/collection/implementations/list-collection/list-collection.js +1 -1
  108. package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
  109. package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
  110. package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
  111. package/dist/event-bus/contracts/event-bus.errors.js +2 -5
  112. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  113. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
  114. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
  115. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
  116. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +1 -3
  117. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +1 -7
  118. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
  119. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
  120. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
  121. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
  122. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +78 -267
  123. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +119 -323
  124. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  125. package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
  126. package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
  127. package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
  128. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +70 -96
  129. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +100 -90
  130. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  131. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -48
  132. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
  133. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  134. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
  135. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
  136. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  137. package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
  138. package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
  139. package/dist/lock/contracts/lock-provider.contract.d.ts +1 -1
  140. package/dist/lock/contracts/lock.errors.js +2 -5
  141. package/dist/lock/contracts/lock.errors.js.map +1 -1
  142. package/dist/lock/contracts/lock.events.js +2 -5
  143. package/dist/lock/contracts/lock.events.js.map +1 -1
  144. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
  145. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
  146. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
  147. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
  148. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
  149. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
  150. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
  151. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
  152. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
  153. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
  154. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
  155. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
  156. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
  157. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
  158. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
  159. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +12 -17
  160. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
  161. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
  162. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
  163. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
  164. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
  165. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.d.ts +9 -0
  166. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +17 -0
  167. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -0
  168. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +115 -372
  169. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +197 -455
  170. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  171. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +15 -17
  172. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
  173. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  174. package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
  175. package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
  176. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +30 -754
  177. package/dist/lock/implementations/derivables/lock-provider/lock.js +94 -812
  178. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  179. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +58 -161
  180. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +116 -122
  181. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  182. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
  183. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
  184. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
  185. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
  186. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
  187. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
  188. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
  189. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +133 -137
  190. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  191. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
  192. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
  193. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
  194. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +1 -1
  195. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
  196. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
  197. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
  198. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
  199. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
  200. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
  201. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  202. package/dist/serde/implementations/derivables/serde.d.ts +14 -14
  203. package/dist/serde/implementations/derivables/serde.js +14 -15
  204. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  205. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
  206. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
  207. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
  208. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
  209. package/dist/utilities/_module-exports.d.ts +1 -2
  210. package/dist/utilities/_module-exports.js +1 -2
  211. package/dist/utilities/_module-exports.js.map +1 -1
  212. package/dist/utilities/classes/_module.d.ts +4 -0
  213. package/dist/utilities/classes/_module.js +5 -0
  214. package/dist/utilities/classes/_module.js.map +1 -0
  215. package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
  216. package/dist/utilities/classes/key-prefixer/_module.js +3 -0
  217. package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
  218. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
  219. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
  220. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
  221. package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
  222. package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
  223. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
  224. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
  225. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
  226. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
  227. package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
  228. package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
  229. package/dist/utilities/classes/pipeline/_module.js +2 -0
  230. package/dist/utilities/classes/pipeline/_module.js.map +1 -0
  231. package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
  232. package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
  233. package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
  234. package/dist/utilities/classes/time-span/_module.d.ts +1 -0
  235. package/dist/utilities/classes/time-span/_module.js +2 -0
  236. package/dist/utilities/classes/time-span/_module.js.map +1 -0
  237. package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
  238. package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
  239. package/dist/utilities/classes/time-span/time-span.js.map +1 -0
  240. package/dist/utilities/contracts/_module.d.ts +2 -1
  241. package/dist/utilities/contracts/_module.js +2 -1
  242. package/dist/utilities/contracts/_module.js.map +1 -1
  243. package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
  244. package/dist/utilities/contracts/prunable.contract.js +5 -0
  245. package/dist/utilities/contracts/prunable.contract.js.map +1 -0
  246. package/dist/utilities/functions.d.ts +30 -2
  247. package/dist/utilities/functions.js +66 -4
  248. package/dist/utilities/functions.js.map +1 -1
  249. package/dist/utilities/types.d.ts +47 -14
  250. package/package.json +14 -13
  251. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
  252. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
  253. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
  254. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
  255. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
  256. package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.d.ts +0 -1
  257. package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js +0 -2
  258. package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js.map +0 -1
  259. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +0 -22
  260. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -39
  261. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +0 -1
  262. package/dist/utilities/kysely/_module.d.ts +0 -1
  263. package/dist/utilities/kysely/_module.js +0 -2
  264. package/dist/utilities/kysely/_module.js.map +0 -1
  265. package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
  266. package/dist/utilities/pipeline/_module.d.ts +0 -1
  267. package/dist/utilities/pipeline/_module.js +0 -2
  268. package/dist/utilities/pipeline/_module.js.map +0 -1
  269. package/dist/utilities/pipeline/pipeline.js.map +0 -1
  270. package/dist/utilities/time-span/_module.d.ts +0 -1
  271. package/dist/utilities/time-span/_module.js +0 -2
  272. package/dist/utilities/time-span/_module.js.map +0 -1
  273. package/dist/utilities/time-span/time-span.js.map +0 -1
  274. /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
  275. /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
@@ -1,147 +1,111 @@
1
1
  /**
2
2
  * @module Cache
3
3
  */
4
- import type { IEventListenable } from "../../event-bus/contracts/_module-exports.js";
5
- import type { OneOrMore } from "../../utilities/_module-exports.js";
6
- import { type AsyncLazyable, type GetOrAddValue } from "../../utilities/_module-exports.js";
7
- import type { CacheEvents } from "../../cache/contracts/_module-exports.js";
8
- import type { TimeSpan } from "../../utilities/_module-exports.js";
9
4
  import type { LazyPromise } from "../../async/_module-exports.js";
5
+ import type { TimeSpan } from "../../utilities/_module-exports.js";
6
+ import type { AsyncLazyable, NoneFunction, OneOrMore } from "../../utilities/types.js";
7
+ import type { CacheEvents } from "../../cache/contracts/cache.events.js";
8
+ import type { IEventListenable } from "../../event-bus/contracts/_module-exports.js";
10
9
  /**
11
- * The <i>ICacheListenable</i> contract defines a way for listening <i>{@link ICache}</i> operations.
10
+ * The <i>ICacheListenable</i> contract defines a way for listening <i>{@link ICache}</i> operation events.
12
11
  *
13
12
  * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
14
13
  * @group Contracts
15
14
  */
16
15
  export type ICacheListenable<TType = unknown> = IEventListenable<CacheEvents<TType>>;
17
16
  /**
17
+ * The <i>ICacheBase</i> contract defines a way for as key-value pairs independent of data storage.
18
18
  *
19
19
  * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
20
20
  * @group Contracts
21
21
  */
22
- export type WithTtlValue<TType> = {
23
- value: TType;
24
- /**
25
- * You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
26
- */
27
- ttl?: TimeSpan | null;
28
- };
29
- /**
30
- * The <i>ICache</i> contract defines a way for storing data as key-value pairs independent of data storage.
31
- * It commes with more convient methods compared to <i>ICacheAdapter</i>.
32
- *
33
- * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
34
- * @group Contracts
35
- */
36
- export type ICache<TType = unknown> = ICacheListenable & {
22
+ export type ICacheBase<TType = unknown> = {
37
23
  /**
38
24
  * The <i>exists</i> method returns true when <i>key</i> is found otherwise false will be returned.
39
25
  */
40
- exists(key: string): LazyPromise<boolean>;
41
- /**
42
- * The <i>existsMany</i> method returns true for the <i>keys</i> that are found otherwise false will be returned.
43
- */
44
- existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
26
+ exists(key: OneOrMore<string>): LazyPromise<boolean>;
45
27
  /**
46
28
  * The <i>missing</i> method returns true when <i>key</i> is not found otherwise false will be returned.
47
29
  */
48
- missing(key: string): LazyPromise<boolean>;
49
- /**
50
- * The <i>missingMany</i> method returns true for the <i>keys</i> that are not found otherwise false will be returned.
51
- */
52
- missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
30
+ missing(key: OneOrMore<string>): LazyPromise<boolean>;
53
31
  /**
54
32
  * The <i>get</i> method returns the value when <i>key</i> is found otherwise null will be returned.
55
33
  */
56
- get(key: string): LazyPromise<TType | null>;
57
- /**
58
- * The <i>getMany</i> returns the value for the <i>keys</i> that are found otherwise null will be returned.
59
- */
60
- getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
61
- /**
62
- * The <i>getOr</i> method returns the value when <i>key</i> is found otherwise <i>defaultValue</i> will be returned.
63
- */
64
- getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
65
- /**
66
- * The <i>getOrMany</i> method returns the value for the keys that are found otherwise defaultValue will be returned.
67
- */
68
- getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
34
+ get(key: OneOrMore<string>): LazyPromise<TType | null>;
69
35
  /**
70
36
  * The <i>getOrFail</i> method returns the value when <i>key</i> is found otherwise an error will be thrown.
71
37
  * @throws {KeyNotFoundCacheError} {@link KeyNotFoundCacheError}
72
38
  */
73
- getOrFail(key: string): LazyPromise<TType>;
39
+ getOrFail(key: OneOrMore<string>): LazyPromise<TType>;
74
40
  /**
75
- * 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.
76
- * You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
41
+ * The <i>getAndRemove</i> method returns the value when <i>key</i> is found otherwise null will be returned.
42
+ * The key will be removed after it is returned.
77
43
  */
78
- add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
44
+ getAndRemove(key: OneOrMore<string>): LazyPromise<TType | null>;
79
45
  /**
80
- * The <i>addMany</i> method adds new keys. Returns true for the keys that where added otherwise false will be returned.
46
+ * The <i>getOr</i> method will retrieve the given <i>key</i> if found otherwise <i>defaultValue</i> will be returned.
47
+ * The <i>defaultValue<i> can be async or sync function.
81
48
  */
82
- addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
49
+ getOr(key: OneOrMore<string>, defaultValue: AsyncLazyable<NoneFunction<TType>>): LazyPromise<TType>;
83
50
  /**
84
- * 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.
51
+ * The <i>getOrAdd</i> method will retrieve the given <i>key</i> if found otherwise <i>valueToAdd</i> will be added and returned.
52
+ * The <i>valueToAdd<i> can be async, sync function and <i>{@link LazyPromise}</i>.
85
53
  */
86
- update(key: string, value: TType): LazyPromise<boolean>;
54
+ getOrAdd(key: OneOrMore<string>, valueToAdd: AsyncLazyable<NoneFunction<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
87
55
  /**
88
- * The <i>updateMany</i> method updates the given keys. Returns true for the keys that where updated otherwise false will be returned.
56
+ * 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.
57
+ * You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
89
58
  */
90
- updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
59
+ add(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
91
60
  /**
92
- * The <i>put</i> method replaces a <i>key</i> if the <i>key</i> exists including the ttl value or adds <i>key</i> that do not exists with a given <i>ttl</i>.
61
+ * The <i>put</i> method replaces th given <i>key</i> with the given <i>value</i> and <i>ttl</i> if the <i>key</i> exists othwerwise it will add the given <i>value</i> and <i>ttl</i>.
93
62
  * Returns true if the <i>key</i> where replaced otherwise false is returned.
94
- * You can provide a <i>ttl</i> value for the replaced key. If <i>null</i> is passed, the item will not expires and <i>null</i> is the default value.
95
- */
96
- put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
97
- /**
98
- * The <i>putMany</i> method replaces the keys that exists including their ttl values or adds keys that do not exists.
99
- * Returns true for all the keys that where replaced otherwise false is returned.
100
- */
101
- putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
102
- /**
103
- * The <i>remove</i> method removes the given <i>key</i> when found. Returns true if the key is found otherwise false is returned.
104
63
  */
105
- remove(key: string): LazyPromise<boolean>;
64
+ put(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
106
65
  /**
107
- * The <i>removeMany</i> method removes keys. Returns true for the keys that are removed otherwise false is returned.
66
+ * The <i>update</i> method updates the given <i>key</i> with given <i>value</i>. Returns true if the <i>key</i> where updated otherwise false will be returned.
108
67
  */
109
- removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
68
+ update(key: OneOrMore<string>, value: TType): LazyPromise<boolean>;
110
69
  /**
111
- * The <i>getAndRemove</i> method removes the given <i>key</i> and returns it when found otherwise null will be returned.
112
- */
113
- getAndRemove(key: string): LazyPromise<TType | null>;
114
- /**
115
- * The <i>getOrAdd</i> method will retrieve the given <i>key</i> if found otherwise <i>valueToAdd</i> will be added and returned.
116
- * The <i>valueToAdd<i> can be async or sync function.
117
- */
118
- getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
119
- /**
120
- * The <i>increment</i> method will increment the given <i>key</i> if found otherwise nonthing will occur.
121
- * Returns true if key is incremented otherwise false will be returned.
70
+ * The <i>increment</i> method increments the given <i>key</i> with given <i>value</i>. Returns true if the <i>key</i> where incremented otherwise false will be returned.
71
+ * If <i>values</i> is not defined then it will increment the key with 1.
122
72
  * An error will thrown if the key is not a number.
123
73
  * @throws {TypeCacheError} {@link TypeCacheError}
124
74
  */
125
- increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
75
+ increment(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
126
76
  /**
127
- * The <i>decrement</i> method will decrement the given <i>key</i> if found otherwise nonthing will occur.
128
- * Returns true if key exists otherwise false will be returned.
77
+ * The <i>decrement</i> method decrements the given <i>key</i> with given <i>value</i>. Returns true if the <i>key</i> where decremented otherwise false will be returned.
78
+ * If <i>values</i> is not defined then it will decrement the key with 1.
129
79
  * An error will thrown if the key is not a number.
130
80
  * @throws {TypeCacheError} {@link TypeCacheError}
131
81
  */
132
- decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
82
+ decrement(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
83
+ /**
84
+ * The <i>remove</i> method removes the given <i>key</i>. Returns true if the key is found otherwise false is returned.
85
+ */
86
+ remove(key: OneOrMore<string>): LazyPromise<boolean>;
87
+ /**
88
+ * The <i>removeMany</i> method removes many keys. Returns true if one of the keys where deleted otherwise false is returned.
89
+ */
90
+ removeMany(keys: OneOrMore<string>[]): PromiseLike<boolean>;
133
91
  /**
134
- * The <i>clear</i> method removes all the keys in the cache.
92
+ * The <i>clear</i> method removes all the keys in the cache. If a cache is in a group then only the keys part of the group will be removed.
135
93
  */
136
94
  clear(): LazyPromise<void>;
137
95
  /**
138
- * The <i>getGroup</i> method returns the group name.
96
+ * The <i>getGroup</i> method returns the group name of the cache. If the cache is not part of a group then null is returned.
139
97
  */
140
- getGroup(): string;
98
+ getGroup(): string | null;
141
99
  };
142
100
  /**
143
- * The <i>IGroupableCache</i> contract defines a way for storing data as key-value pairs independent of data storage.
144
- * It commes with one extra method which is useful for multitennat applications compared to <i>{@link ICache}</i>.
101
+ * The <i>ICache</i> contract defines a way for as key-value pairs independent of data storage and listening to operation events.
102
+ *
103
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
104
+ * @group Contracts
105
+ */
106
+ export type ICache<TType = unknown> = ICacheListenable<TType> & ICacheBase<TType>;
107
+ /**
108
+ * The <i>IGroupableCache</i> contract defines a way for storing and grouping data as key-value pairs independent of data storage.
145
109
  *
146
110
  * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
147
111
  * @group Contracts
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * @module Cache
3
3
  */
4
- import {} from "../../utilities/_module-exports.js";
5
- import {} from "../../cache/contracts/_module-exports.js";
4
+ export {};
6
5
  //# sourceMappingURL=cache.contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.contract.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAGN,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAON,MAAM,sCAAsC,CAAC"}
1
+ {"version":3,"file":"cache.contract.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.contract.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Cache
3
3
  */
4
- import { CORE, } from "../../utilities/_module-exports.js";
4
+ import { CORE, resolveOneOrMore, } from "../../utilities/_module-exports.js";
5
5
  /**
6
6
  *
7
7
  * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
@@ -72,10 +72,7 @@ export class KeyNotFoundCacheError extends CacheError {
72
72
  * @group Errors
73
73
  */
74
74
  export function registerCacheErrorsToSerde(serde) {
75
- if (!Array.isArray(serde)) {
76
- serde = [serde];
77
- }
78
- for (const serde_ of serde) {
75
+ for (const serde_ of resolveOneOrMore(serde)) {
79
76
  serde_
80
77
  .registerClass(CacheError, CORE)
81
78
  .registerClass(UnexpectedCacheError, CORE)
@@ -1 +1 @@
1
- {"version":3,"file":"cache.errors.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EACH,IAAI,GAGP,MAAM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AC;QAC1B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;IAC3C,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACtC,KAAgC;IAEhC,KAAK,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM;aACD,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC;aAC/B,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC;aACnC,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;AACL,CAAC"}
@@ -10,7 +10,7 @@ import { type OneOrMore, type TimeSpan } from "../../utilities/_module-exports.j
10
10
  * @group Events
11
11
  */
12
12
  export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
13
- group: string;
13
+ group: string | null;
14
14
  key: string;
15
15
  value: TType;
16
16
  }> {
@@ -21,7 +21,7 @@ export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
21
21
  * @group Events
22
22
  */
23
23
  export declare class KeyNotFoundCacheEvent extends BaseEvent<{
24
- group: string;
24
+ group: string | null;
25
25
  key: string;
26
26
  }> {
27
27
  }
@@ -31,7 +31,7 @@ export declare class KeyNotFoundCacheEvent extends BaseEvent<{
31
31
  * @group Events
32
32
  */
33
33
  export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
34
- group: string;
34
+ group: string | null;
35
35
  key: string;
36
36
  value: TType;
37
37
  ttl: TimeSpan | null;
@@ -43,7 +43,7 @@ export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
43
43
  * @group Events
44
44
  */
45
45
  export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
46
- group: string;
46
+ group: string | null;
47
47
  key: string;
48
48
  value: TType;
49
49
  }> {
@@ -54,7 +54,7 @@ export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
54
54
  * @group Events
55
55
  */
56
56
  export declare class KeyRemovedCacheEvent extends BaseEvent<{
57
- group: string;
57
+ group: string | null;
58
58
  key: string;
59
59
  }> {
60
60
  }
@@ -64,7 +64,7 @@ export declare class KeyRemovedCacheEvent extends BaseEvent<{
64
64
  * @group Events
65
65
  */
66
66
  export declare class KeyIncrementedCacheEvent extends BaseEvent<{
67
- group: string;
67
+ group: string | null;
68
68
  key: string;
69
69
  value: number;
70
70
  }> {
@@ -75,7 +75,7 @@ export declare class KeyIncrementedCacheEvent extends BaseEvent<{
75
75
  * @group Events
76
76
  */
77
77
  export declare class KeyDecrementedCacheEvent extends BaseEvent<{
78
- group: string;
78
+ group: string | null;
79
79
  key: string;
80
80
  value: number;
81
81
  }> {
@@ -86,7 +86,7 @@ export declare class KeyDecrementedCacheEvent extends BaseEvent<{
86
86
  * @group Events
87
87
  */
88
88
  export declare class KeysClearedCacheEvent extends BaseEvent<{
89
- group: string;
89
+ group: string | null;
90
90
  }> {
91
91
  }
92
92
  /**
@@ -95,8 +95,8 @@ export declare class KeysClearedCacheEvent extends BaseEvent<{
95
95
  * @group Events
96
96
  */
97
97
  export declare class UnexpectedCacheErrorEvent extends BaseEvent<{
98
- group: string;
99
- key?: string;
98
+ group: string | null;
99
+ keys?: string[];
100
100
  value?: unknown;
101
101
  method: string;
102
102
  error: unknown;
@@ -2,7 +2,7 @@
2
2
  * @module Cache
3
3
  */
4
4
  import { BaseEvent } from "../../event-bus/contracts/_module-exports.js";
5
- import { CORE, } from "../../utilities/_module-exports.js";
5
+ import { CORE, resolveOneOrMore, } from "../../utilities/_module-exports.js";
6
6
  /**
7
7
  *
8
8
  * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
@@ -73,10 +73,7 @@ export class UnexpectedCacheErrorEvent extends BaseEvent {
73
73
  * @group Events
74
74
  */
75
75
  export function registerCacheEventsToSerde(serde) {
76
- if (!Array.isArray(serde)) {
77
- serde = [serde];
78
- }
79
- for (const serde_ of serde) {
76
+ for (const serde_ of resolveOneOrMore(serde)) {
80
77
  serde_
81
78
  .registerEvent(KeyFoundCacheEvent, CORE)
82
79
  .registerEvent(KeyNotFoundCacheEvent, CORE)
@@ -1 +1 @@
1
- {"version":3,"file":"cache.events.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EACH,IAAI,GAGP,MAAM,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAIvD;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAGzC;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAKvD;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,oBAAsC,SAAQ,SAIzD;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAGxC;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAI5C;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAI5C;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAEzC;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAM7C;CAAG;AAkBL;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACtC,KAAgC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM;aACD,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,kBAAkB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CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;AACL,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @module Cache
3
+ */
4
+ /**
5
+ *
6
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
7
+ * @group Contracts
8
+ */
9
+ export type ICacheData<TType = unknown> = {
10
+ value: TType;
11
+ expiration: Date | null;
12
+ };
13
+ /**
14
+ *
15
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
16
+ * @group Contracts
17
+ */
18
+ export type ICacheDataExpiration = {
19
+ expiration: Date | null;
20
+ };
21
+ /**
22
+ *
23
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
24
+ * @group Contracts
25
+ */
26
+ export type ICacheInsert<TType = unknown> = {
27
+ key: string;
28
+ value: TType;
29
+ expiration: Date | null;
30
+ };
31
+ /**
32
+ *
33
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
34
+ * @group Contracts
35
+ */
36
+ export type ICacheUpdate<TType = unknown> = {
37
+ key: string;
38
+ value: TType;
39
+ };
40
+ /**
41
+ * The <i>IDatabaseCacheAdapter</i> contract defines a way for as key-value pairs independent of data storage.
42
+ * This contract simplifies the implementation of cache adapters with CRUD-based databases, such as SQL databases and ORMs like TypeOrm and MikroOrm.
43
+ *
44
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
45
+ * @group Contracts
46
+ */
47
+ export type IDatabaseCacheAdapter<TType = unknown> = {
48
+ /**
49
+ * The <i>find</i> method returns the the <i>key</i> data which includs <i>{@link ICacheData}.value</i> and <i>{@link ICacheData}.expiration</i>.
50
+ */
51
+ find(key: string): PromiseLike<ICacheData<TType> | null>;
52
+ /**
53
+ * The <i>insert</i> method inserts the given cache <i>data</i>.
54
+ */
55
+ insert(data: ICacheInsert<TType>): PromiseLike<void>;
56
+ /**
57
+ * The <i>upsert</i> method inserts a key and if the key already exists then key will be updated with new <i>data.value</i> and <i>data.expiration</i>.
58
+ * The method always returns the old cache data if it exists otherwise null will be returned.
59
+ */
60
+ upsert(data: ICacheInsert<TType>): PromiseLike<ICacheDataExpiration | null>;
61
+ /**
62
+ * The <i>removeExpiredMany</i> method updates a expired <i>key</i>.
63
+ */
64
+ updateExpired(data: ICacheInsert<TType>): PromiseLike<number>;
65
+ /**
66
+ * The <i>removeExpiredMany</i> method updates a unexpired <i>key</i>.
67
+ */
68
+ updateUnexpired(data: ICacheUpdate<TType>): PromiseLike<number>;
69
+ /**
70
+ * The <i>incrementUnexpired</i> should always throw an error if the existing item is not a number type.
71
+ */
72
+ incrementUnexpired(data: ICacheUpdate<number>): PromiseLike<number>;
73
+ /**
74
+ * The <i>removeExpiredMany</i> method removes multiple expired <i>keys</i>.
75
+ */
76
+ removeExpiredMany(keys: string[]): PromiseLike<number>;
77
+ /**
78
+ * The <i>removeExpiredMany</i> method removes multiple unexpired <i>keys</i>.
79
+ */
80
+ removeUnexpiredMany(keys: string[]): PromiseLike<number>;
81
+ /**
82
+ * The <i>removeAll</i> method removes all keys from the cache.
83
+ */
84
+ removeAll(): PromiseLike<void>;
85
+ /**
86
+ * The <i>removeByKeyPrefix</i> method removes all the keys in the cache that starts with the given <i>prefix</i>.
87
+ */
88
+ removeByKeyPrefix(prefix: string): PromiseLike<void>;
89
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module Cache
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=database-cache-adapter.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-cache-adapter.contract.js","sourceRoot":"","sources":["../../../src/cache/contracts/database-cache-adapter.contract.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,6 +1,5 @@
1
1
  export * from "../../../cache/implementations/adapters/libsql-cache-adapter/_module.js";
2
2
  export * from "../../../cache/implementations/adapters/memory-cache-adapter/_module.js";
3
3
  export * from "../../../cache/implementations/adapters/mongodb-cache-adapter/_module.js";
4
- export * from "../../../cache/implementations/adapters/no-op-cache-adapter/_module.js";
5
4
  export * from "../../../cache/implementations/adapters/redis-cache-adapter/_module.js";
6
5
  export * from "../../../cache/implementations/adapters/sqlite-cache-adapter/_module.js";
@@ -1,7 +1,6 @@
1
1
  export * from "../../../cache/implementations/adapters/libsql-cache-adapter/_module.js";
2
2
  export * from "../../../cache/implementations/adapters/memory-cache-adapter/_module.js";
3
3
  export * from "../../../cache/implementations/adapters/mongodb-cache-adapter/_module.js";
4
- export * from "../../../cache/implementations/adapters/no-op-cache-adapter/_module.js";
5
4
  export * from "../../../cache/implementations/adapters/redis-cache-adapter/_module.js";
6
5
  export * from "../../../cache/implementations/adapters/sqlite-cache-adapter/_module.js";
7
6
  //# sourceMappingURL=_module-exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../../../src/cache/implementations/adapters/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,kEAAkE,CAAC;AACjF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,iEAAiE,CAAC;AAChF,cAAc,iEAAiE,CAAC;AAChF,cAAc,kEAAkE,CAAC"}
1
+ {"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../../../src/cache/implementations/adapters/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,kEAAkE,CAAC;AACjF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,iEAAiE,CAAC;AAChF,cAAc,kEAAkE,CAAC"}
@@ -1 +1 @@
1
- export * from "../../../../cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js";
1
+ export * from "../../../../cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js";
@@ -0,0 +1,2 @@
1
+ export * from "../../../../cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js";
2
+ //# sourceMappingURL=_module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/kysely-cache-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+EAA+E,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @module Cache
3
+ */
4
+ import { type ICacheData, type ICacheInsert, type ICacheUpdate, type IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
5
+ import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
6
+ import type { IDeinitizable, IInitizable, IPrunable } from "../../../../utilities/_module-exports.js";
7
+ import { TimeSpan } from "../../../../utilities/_module-exports.js";
8
+ import type { Kysely } from "kysely";
9
+ /**
10
+ * @internal
11
+ */
12
+ type KyselyCacheTable = {
13
+ key: string;
14
+ value: string;
15
+ expiration: number | null;
16
+ };
17
+ /**
18
+ * @internal
19
+ */
20
+ type KyselyTables = {
21
+ cache: KyselyCacheTable;
22
+ };
23
+ /**
24
+ * @internal
25
+ */
26
+ type KyselySettings = {
27
+ database: Kysely<KyselyTables>;
28
+ serde: ISerde<string>;
29
+ /**
30
+ * @default {false}
31
+ */
32
+ disableTransaction?: boolean;
33
+ /**
34
+ * @default
35
+ * ```ts
36
+ * TimeSpan.fromMinutes(1)
37
+ * ```
38
+ */
39
+ expiredKeysRemovalInterval?: TimeSpan;
40
+ /**
41
+ * @default {true}
42
+ */
43
+ shouldRemoveExpiredKeys?: boolean;
44
+ };
45
+ /**
46
+ * @internal
47
+ */
48
+ export declare class KyselyCacheAdapter<TType = unknown> implements IDatabaseCacheAdapter<TType>, IInitizable, IDeinitizable, IPrunable {
49
+ private static filterUnexpiredKeys;
50
+ private static filterExpiredKeys;
51
+ private readonly serde;
52
+ private readonly database;
53
+ private readonly shouldRemoveExpiredKeys;
54
+ private readonly expiredKeysRemovalInterval;
55
+ private timeoutId;
56
+ private readonly disableTransaction;
57
+ constructor(settings: KyselySettings);
58
+ removeAllExpired(): Promise<void>;
59
+ init(): Promise<void>;
60
+ deInit(): Promise<void>;
61
+ find(key: string): Promise<ICacheData<TType> | null>;
62
+ insert(data: ICacheInsert<TType>): Promise<void>;
63
+ private transaction;
64
+ upsert(data: ICacheInsert<TType>): Promise<ICacheData<TType> | null>;
65
+ updateExpired(data: ICacheInsert<TType>): Promise<number>;
66
+ updateUnexpired(data: ICacheUpdate<TType>): Promise<number>;
67
+ incrementUnexpired(data: ICacheUpdate<number>): Promise<number>;
68
+ removeExpiredMany(keys: string[]): Promise<number>;
69
+ removeUnexpiredMany(keys: string[]): Promise<number>;
70
+ removeAll(): Promise<void>;
71
+ removeByKeyPrefix(prefix: string): Promise<void>;
72
+ }
73
+ export {};