@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,28 +1,32 @@
1
1
  /**
2
2
  * @module Cache
3
3
  */
4
- import type { CacheEvents, WithTtlValue } from "../../../../cache/contracts/_module-exports.js";
4
+ import type { CacheEvents, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
5
5
  import { type ICache, type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
6
6
  import { type IGroupableCache } from "../../../../cache/contracts/_module-exports.js";
7
- import type { AsyncLazyable, GetOrAddValue, Invokable, OneOrMore } from "../../../../utilities/_module-exports.js";
8
- import type { TimeSpan } from "../../../../utilities/_module-exports.js";
7
+ import { type AsyncLazyable, type Invokable, type OneOrMore } from "../../../../utilities/_module-exports.js";
8
+ import { type NoneFunction, type TimeSpan, type Factoryable } from "../../../../utilities/_module-exports.js";
9
9
  import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module-exports.js";
10
10
  import { LazyPromise } from "../../../../async/_module-exports.js";
11
11
  import type { IGroupableEventBus, Unsubscribe, EventClass, EventInstance } from "../../../../event-bus/contracts/_module-exports.js";
12
+ import type { IKeyPrefixer, Items } from "../../../../utilities/_module-exports.js";
12
13
  /**
13
14
  *
14
- * IMPORT_PATH: ```"@daiso-tech/core/cache/implementations/derivables"```
15
+ * IMPORT_PATH: ```"@daiso-tech/core/cache"```
15
16
  * @group Derivables
16
17
  */
17
- export type CacheSettings = {
18
- adapter: ICacheAdapter<any>;
18
+ export type CacheSettingsBase = {
19
+ keyPrefixer: IKeyPrefixer;
19
20
  /**
20
21
  * @default
21
22
  * ```ts
23
+ * import { EventBus } from "@daiso-tech/core/event-bus";
24
+ * import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
25
+ * import { KeyPrefixer } from "@daiso-tech/core/utilities";
26
+ *
22
27
  * new EventBus({
23
- * adapter: new MemoryEventBusAdapter({
24
- * rootGroup: "@global"
25
- * })
28
+ * keyPrefixer: new KeyPrefixer("event-bus"),
29
+ * adapter: new MemoryEventBusAdapter()
26
30
  * })
27
31
  * ```
28
32
  */
@@ -54,597 +58,150 @@ export type CacheSettings = {
54
58
  timeout?: TimeSpan | null;
55
59
  };
56
60
  /**
57
- * <i>Cache</i> class can be derived from any <i>{@link ICacheAdapter}</i>.
58
61
  *
59
- * IMPORT_PATH: ```"@daiso-tech/core/cache/implementations/derivables"```
62
+ * IMPORT_PATH: ```"@daiso-tech/core/cache"```
63
+ * @group Derivables
64
+ */
65
+ export type CacheAdapterFactoryable<TType> = Factoryable<string, ICacheAdapter<TType> | IDatabaseCacheAdapter<TType>>;
66
+ /**
67
+ *
68
+ * IMPORT_PATH: ```"@daiso-tech/core/cache"```
69
+ * @group Derivables
70
+ */
71
+ export type CacheSettings = CacheSettingsBase & {
72
+ adapter: CacheAdapterFactoryable<any>;
73
+ };
74
+ /**
75
+ *
76
+ * IMPORT_PATH: ```"@daiso-tech/core/cache"```
60
77
  * @group Derivables
61
78
  */
62
79
  export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
80
+ private static resolveCacheAdapter;
81
+ private static resolveCacheAdapterFactoryable;
63
82
  private static defaultRetryPolicy;
64
83
  private readonly groupdEventBus;
65
84
  private readonly eventBus;
66
- private readonly adapter;
85
+ private readonly adapterFactoryable;
86
+ private readonly adapterPromise;
67
87
  private readonly defaultTtl;
68
88
  private readonly retryAttempts;
69
89
  private readonly backoffPolicy;
70
90
  private readonly retryPolicy;
71
91
  private readonly timeout;
92
+ private readonly keyPrefixer;
72
93
  /**
73
- * @example
74
- * ```ts
75
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
76
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
77
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
78
94
  *
79
- * const cache: IGroupableCache = new Cache({
80
- * adapter: new MemoryCacheAdapter({
81
- * rootGroup: "@global"
82
- * }),
83
- * });
84
- * ```
85
- */
86
- constructor(settings: CacheSettings);
87
- private createLayPromise;
88
- /**
89
- * You can listen to different events of <i>Cache</i> class instance.
90
- *
91
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
92
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
93
95
  * @example
94
96
  * ```ts
95
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
96
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
97
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
98
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
99
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
100
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
97
+ * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
98
+ * import { Serde } from "@daiso-tech/core/serde";
99
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
100
+ * import Sqlite from "better-sqlite3";
101
+ * import { Cache } from "@daiso-tech/core/cache";
102
+ * import { KeyPrefixer } from "@daiso-tech/core/utilities";
101
103
  *
102
- * const cache: IGroupableCache = new Cache({
103
- * adapter: new MemoryCacheAdapter({
104
- * rootGroup: "@global"
105
- * }),
104
+ * const database = new Sqlite("local.db");
105
+ * const serde = new Serde(new SuperJsonSerdeAdapter());
106
+ * const cacheAdapter = new SqliteCacheAdapter({
107
+ * database,
108
+ * serde,
106
109
  * });
110
+ * // You need initialize the adapter once before using it.
111
+ * await cacheAdapter.init();
107
112
  *
108
- * const listener: Invokable<CacheEvents> = event => {
109
- * console.log(event);
110
- * };
111
- * await cache.addListener(KeyAddedCacheEvent, listener);
112
- * await cache.add("a", 1);
113
- * ```
114
- */
115
- addListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
116
- /**
117
- * You can listen to different events of <i>Cache</i> class instance.
118
- *
119
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
120
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
121
- * @example
122
- * ```ts
123
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
124
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
125
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
126
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
127
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
128
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
129
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
130
- *
131
- * const cache: IGroupableCache = new Cache({
132
- * adapter: new MemoryCacheAdapter({
133
- * rootGroup: "@global"
134
- * }),
113
+ * const cache = new Cache({
114
+ * keyPrefixer: new KeyPrefixer("cache"),
115
+ * adapter: cacheAdapter,
135
116
  * });
136
- *
137
- * const listener: Invokable<CacheEvents> = event => {
138
- * console.log(event);
139
- * };
140
- * await cache.addListenerMany([KeyAddedCacheEvent], listener);
141
- * await cache.add("a", 1);
142
- * ```
143
- */
144
- addListenerMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
145
- /**
146
- * You can listen to different events of <i>Cache</i> class instance.
147
- *
148
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
149
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
150
- * @example
151
- * ```ts
152
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
153
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
154
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
155
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
156
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
157
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
158
- *
159
- * const cache: IGroupableCache = new Cache({
160
- * adapter: new MemoryCacheAdapter({
161
- * rootGroup: "@global"
162
- * }),
163
- * });
164
- *
165
- * const listener: Invokable<CacheEvents> = event => {
166
- * console.log(event);
167
- * };
168
- * await cache.addListener(KeyAddedCacheEvent, listener);
169
- * await cache.removeListener(KeyAddedCacheEvent, listener);
170
- * await cache.add("a", 1);
171
117
  * ```
172
- */
173
- removeListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
174
- /**
175
- * You can listen to different events of <i>Cache</i> class instance.
176
118
  *
177
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
178
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
119
+ * You can pass factory function that will create an adapter for every group.
179
120
  * @example
180
121
  * ```ts
181
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
182
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
183
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
184
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
185
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
186
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
122
+ * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
123
+ * import type { ICacheAdapter } from "@daiso-tech/core/cache/contracts";
124
+ * import { Serde } from "@daiso-tech/core/serde";
125
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
126
+ * import Sqlite from "better-sqlite3";
127
+ * import { Cache } from "@daiso-tech/core/cache";
128
+ * import { KeyPrefixer, type Promiseable } from "@daiso-tech/core/utilities";
187
129
  *
188
- * const cache: IGroupableCache = new Cache({
189
- * adapter: new MemoryCacheAdapter({
190
- * rootGroup: "@global"
191
- * }),
192
- * });
193
- *
194
- * const listener: Invokable<CacheEvents> = event => {
195
- * console.log(event);
196
- * };
197
- * await cache.addListenerMany([KeyAddedCacheEvent], listener);
198
- * await cache.removeListenerMany(KeyAddedCacheEvent, listener);
199
- * await cache.add("a", 1);
200
- * ```
201
- */
202
- removeListenerMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
203
- /**
204
- * You can listen to different events of <i>Cache</i> class instance.
205
130
  *
206
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
207
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
208
- * @example
209
- * ```ts
210
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
211
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
212
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
213
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
214
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
215
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
131
+ * async function cahceAdapterFactory(prefix: string): Promiseable<ICacheAdapter> {
132
+ * const database = new Sqlite("local.db");
133
+ * const serde = new Serde(new SuperJsonSerdeAdapter());
134
+ * const cacheAdapter = new SqliteCacheAdapter({
135
+ * database,
136
+ * serde,
137
+ * tableName: `cache_${prefix}`
138
+ * });
139
+ * await cacheAdapter.init();
140
+ * return cacheAdapter;
141
+ * }
216
142
  *
217
- * const cache: IGroupableCache = new Cache({
218
- * adapter: new MemoryCacheAdapter({
219
- * rootGroup: "@global"
220
- * }),
143
+ * const cache = new Cache({
144
+ * keyPrefixer: new KeyPrefixer("cache"),
145
+ * adapter: cahceAdapterFactory,
221
146
  * });
222
- *
223
- * const listener: Invokable<CacheEvents> = event => {
224
- * console.log(event);
225
- * };
226
- * await cache.listenOnce(KeyAddedCacheEvent, listener);
227
- * await cache.add("a", 1);
228
147
  * ```
229
- */
230
- listenOnce<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
231
- asPromise<TEventClass extends EventClass<CacheEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
232
- /**
233
- * You can listen to different events of <i>Cache</i> class instance.
234
148
  *
235
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
236
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
149
+ * You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
237
150
  * @example
238
151
  * ```ts
239
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
240
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
241
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
242
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
243
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
244
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
152
+ * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
153
+ * import type { ICacheAdapter } from "@daiso-tech/core/cache/contracts";
154
+ * import { Serde } from "@daiso-tech/core/serde";
155
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
156
+ * import Sqlite from "better-sqlite3";
157
+ * import { Cache } from "@daiso-tech/core/cache";
158
+ * import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
245
159
  *
246
- * const cache: IGroupableCache = new Cache({
247
- * adapter: new MemoryCacheAdapter({
248
- * rootGroup: "@global"
249
- * }),
160
+ * class CahceAdapterFactory implements IFactoryObject<string, ICacheAdapter> {
161
+ * async use(prefix: string): Promiseable<ICacheAdapter> {
162
+ * const database = new Sqlite("local.db");
163
+ * const serde = new Serde(new SuperJsonSerdeAdapter());
164
+ * const cacheAdapter = new SqliteCacheAdapter({
165
+ * database,
166
+ * serde,
167
+ * tableName: `cache_${prefix}`
168
+ * });
169
+ * await cacheAdapter.init();
170
+ * return cacheAdapter;
171
+ * }
172
+ * }
173
+ * const cahceAdapterFactory = new CahceAdapterFactory();
174
+ * const cache = new Cache({
175
+ * keyPrefixer: new KeyPrefixer("cache"),
176
+ * adapter: cahceAdapterFactory,
250
177
  * });
251
- *
252
- * const listener: Invokable<CacheEvents> = event => {
253
- * console.log(event);
254
- * };
255
- * const unsubscribe = await cache.subscribe(KeyAddedCacheEvent, listener);
256
- * await cache.add("a", 1);
257
- * await unsubscribe();
258
178
  * ```
259
179
  */
260
- subscribe<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
261
- /**
262
- * You can listen to different events of <i>Cache</i> class instance.
263
- *
264
- * Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
265
- * Refer to <i>{@link IEventListenable}</i> for details on how the method works.
266
- * @example
267
- * ```ts
268
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
269
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
270
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
271
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
272
- * import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
273
- * import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
274
- *
275
- * const cache: IGroupableCache = new Cache({
276
- * adapter: new MemoryCacheAdapter({
277
- * rootGroup: "@global"
278
- * }),
279
- * });
280
- *
281
- * const listener: Invokable<CacheEvents> = event => {
282
- * console.log(event);
283
- * };
284
- * const unsubscribe = await cache.subscribeMany([KeyAddedCacheEvent], listener);
285
- * await cache.add("a", 1);
286
- * await unsubscribe();
287
- * ```
288
- */
289
- subscribeMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
290
- /**
291
- * @example
292
- * ```ts
293
- * import type { IGroupableCache, ICache } from "@daiso-tech/core/cache/contracts";
294
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
295
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
296
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
297
- *
298
- * const cache: IGroupableCache = new Cache({
299
- * adapter: new MemoryCacheAdapter({
300
- * rootGroup: "@global"
301
- * }),
302
- * });
303
- *
304
- * // Will print "@global"
305
- * console.log(cache.getGroup());
306
- *
307
- * const groupedCache: ICache = cache.withGroup("company-1");
308
- *
309
- * // Will print "@global/company-1"
310
- * console.log(groupedCache.getGroup());
311
- * ```
312
- */
313
- withGroup(group: OneOrMore<string>): ICache<TType>;
314
- /**
315
- * @example
316
- * ```ts
317
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
318
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
319
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
320
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
321
- *
322
- * const cache: IGroupableCache = new Cache({
323
- * adapter: new MemoryCacheAdapter({
324
- * rootGroup: "@global"
325
- * }),
326
- * });
327
- *
328
- * // Will print "@global"
329
- * console.log(cache.getGroup());
330
- * ```
331
- */
332
- getGroup(): string;
333
- get(key: string): LazyPromise<TType | null>;
334
- add(key: string, value: TType,
335
- /**
336
- * @default null
337
- */
338
- ttl?: TimeSpan | null): LazyPromise<boolean>;
339
- update(key: string, value: TType): LazyPromise<boolean>;
340
- put(key: string, value: TType,
341
- /**
342
- * @default null
343
- */
344
- ttl?: TimeSpan | null): LazyPromise<boolean>;
345
- remove(key: string): LazyPromise<boolean>;
346
- increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
180
+ constructor(settings: CacheSettings);
181
+ addListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
182
+ addListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
183
+ removeListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
184
+ removeListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
185
+ listenOnce<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
186
+ asPromise<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
187
+ subscribe<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
188
+ subscribeMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
189
+ private createLazyPromise;
190
+ exists(key: OneOrMore<string>): LazyPromise<boolean>;
191
+ missing(key: OneOrMore<string>): LazyPromise<boolean>;
192
+ get(key: OneOrMore<string>): LazyPromise<TType | null>;
193
+ getOrFail(key: OneOrMore<string>): LazyPromise<TType>;
194
+ getAndRemove(key: OneOrMore<string>): LazyPromise<TType | null>;
195
+ getOr(key: OneOrMore<string>, defaultValue: AsyncLazyable<NoneFunction<TType>>): LazyPromise<TType>;
196
+ getOrAdd(key: OneOrMore<string>, valueToAdd: AsyncLazyable<NoneFunction<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
197
+ add(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
198
+ put(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
199
+ update(key: OneOrMore<string>, value: TType): LazyPromise<boolean>;
200
+ increment(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
201
+ decrement(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
202
+ remove(key: OneOrMore<string>): LazyPromise<boolean>;
203
+ removeMany(keys: OneOrMore<string>[]): LazyPromise<boolean>;
347
204
  clear(): LazyPromise<void>;
348
- exists(key: string): LazyPromise<boolean>;
349
- existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
350
- missing(key: string): LazyPromise<boolean>;
351
- missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
352
- getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
353
- /**
354
- * @example
355
- * ```ts
356
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
357
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
358
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
359
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
360
- *
361
- * const cache: IGroupableCache = new Cache({
362
- * adapter: new MemoryCacheAdapter({
363
- * rootGroup: "@global"
364
- * }),
365
- * });
366
- *
367
- * const result = await cache.getOr("a", -1);
368
- * // -1
369
- * console.log(result);
370
- * ```
371
- *
372
- * You can pass function as default value.
373
- * @example
374
- * ```ts
375
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
376
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
377
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
378
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
379
- *
380
- * const cache: IGroupableCache = new Cache({
381
- * adapter: new MemoryCacheAdapter({
382
- * rootGroup: "@global"
383
- * }),
384
- * });
385
- *
386
- * const result = await cache.getOr("a", () => -1);
387
- * // -1
388
- * console.log(result);
389
- * ```
390
- *
391
- * You can pass async function as default value.
392
- * @example
393
- * ```ts
394
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
395
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
396
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
397
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
398
- *
399
- * const cache: IGroupableCache = new Cache({
400
- * adapter: new MemoryCacheAdapter({
401
- * rootGroup: "@global"
402
- * }),
403
- * });
404
- *
405
- * const result = await cache.getOr("a", async () => -1);
406
- * // -1
407
- * console.log(result);
408
- * ```
409
- *
410
- * You can pass <i>{@link LazyPromise}</i> as default value.
411
- * @example
412
- * ```ts
413
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
414
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
415
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
416
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
417
- *
418
- * const cache: IGroupableCache = new Cache({
419
- * adapter: new MemoryCacheAdapter({
420
- * rootGroup: "@global"
421
- * }),
422
- * });
423
- *
424
- * const result = await cache.getOr("a", new LazyPromise(async () => -1));
425
- * // -1
426
- * console.log(result);
427
- * ```
428
- */
429
- getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
430
- /**
431
- * @example
432
- * ```ts
433
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
434
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
435
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
436
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
437
- *
438
- * const cache: IGroupableCache = new Cache({
439
- * adapter: new MemoryCacheAdapter({
440
- * rootGroup: "@global"
441
- * }),
442
- * });
443
- *
444
- * const result = await cache.getOrMany({ a: -1 });
445
- * // { a: -1 }
446
- * console.log(result);
447
- * ```
448
- *
449
- * You can pass function as default value.
450
- * @example
451
- * ```ts
452
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
453
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
454
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
455
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
456
- *
457
- * const cache: IGroupableCache = new Cache({
458
- * adapter: new MemoryCacheAdapter({
459
- * rootGroup: "@global"
460
- * }),
461
- * });
462
- *
463
- * const result = await cache.getOrMany({ a: () => -1 });
464
- * // { a: -1 }
465
- * console.log(result);
466
- * ```
467
- *
468
- * You can pass async function as default value.
469
- * @example
470
- * ```ts
471
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
472
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
473
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
474
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
475
- *
476
- * const cache: IGroupableCache = new Cache({
477
- * adapter: new MemoryCacheAdapter({
478
- * rootGroup: "@global"
479
- * }),
480
- * });
481
- *
482
- * const result = await cache.getOrMany({ a: async () => -1 });
483
- * // { a: -1 }
484
- * console.log(result);
485
- * ```
486
- *
487
- * You can pass <i>{@link LazyPromise}</i> as default value.
488
- * @example
489
- * ```ts
490
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
491
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
492
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
493
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
494
- *
495
- * const cache: IGroupableCache = new Cache({
496
- * adapter: new MemoryCacheAdapter({
497
- * rootGroup: "@global"
498
- * }),
499
- * });
500
- *
501
- * const result = await cache.getOrMany({ a: new LazyPromise(async () => - 1) });
502
- * // { a: -1 }
503
- * console.log(result);
504
- * ```
505
- */
506
- getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
507
- /**
508
- * @example
509
- * ```ts
510
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
511
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
512
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
513
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
514
- *
515
- * const cache: IGroupableCache = new Cache({
516
- * adapter: new MemoryCacheAdapter({
517
- * rootGroup: "@global"
518
- * }),
519
- * });
520
- *
521
- * await cache.add("a", 1);
522
- *
523
- * const result1 = await cache.getOrFail("a");
524
- * // Will print 1
525
- * console.log(result1);
526
- *
527
- * await cache.remove("a");
528
- *
529
- * // Will throw an error
530
- * await cache.getOrFail("a");
531
- * ```
532
- */
533
- getOrFail(key: string): LazyPromise<TType>;
534
- addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
535
- updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
536
- putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
537
- removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
538
- /**
539
- * @example
540
- * ```ts
541
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
542
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
543
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
544
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
545
- *
546
- * const cache: IGroupableCache = new Cache({
547
- * adapter: new MemoryCacheAdapter({
548
- * rootGroup: "@global"
549
- * }),
550
- * });
551
- *
552
- * const result1 = await cache.getAndRemove("a");
553
- * // Will print null
554
- * console.log(result1);
555
- *
556
- * await cache.add("a", 2)
557
- *
558
- * const result2 = await cache.getAndRemove("a");
559
- * // Will print 2
560
- * console.log(result2);
561
- *
562
- * const result3 = await cache.get("a");
563
- * // Will print null
564
- * console.log(result3);
565
- * ```
566
- */
567
- getAndRemove(key: string): LazyPromise<TType | null>;
568
- /**
569
- * @example
570
- * ```ts
571
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
572
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
573
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
574
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
575
- *
576
- * const cache: IGroupableCache = new Cache({
577
- * adapter: new MemoryCacheAdapter({
578
- * rootGroup: "@global"
579
- * }),
580
- * });
581
- *
582
- * const result = await cache.getOrAdd("a", -1);
583
- * // -1
584
- * console.log(result);
585
- * ```
586
- *
587
- * You can pass function as default value.
588
- * @example
589
- * ```ts
590
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
591
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
592
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
593
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
594
- *
595
- * const cache: IGroupableCache = new Cache({
596
- * adapter: new MemoryCacheAdapter({
597
- * rootGroup: "@global"
598
- * }),
599
- * });
600
- *
601
- * const result = await cache.getOrAdd("a", () => -1);
602
- * // -1
603
- * console.log(result);
604
- * ```
605
- *
606
- * You can pass async function as default value.
607
- * @example
608
- * ```ts
609
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
610
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
611
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
612
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
613
- *
614
- * const cache: IGroupableCache = new Cache({
615
- * adapter: new MemoryCacheAdapter({
616
- * rootGroup: "@global"
617
- * }),
618
- * });
619
- *
620
- * const result = await cache.getOrAdd("a", async () => -1);
621
- * // -1
622
- * console.log(result);
623
- * ```
624
- *
625
- * You can pass <i>{@link LazyPromise}</i> as default value.
626
- * @example
627
- * ```ts
628
- * import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
629
- * import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
630
- * import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
631
- * import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
632
- *
633
- * const cache: IGroupableCache = new Cache({
634
- * adapter: new MemoryCacheAdapter({
635
- * rootGroup: "@global"
636
- * }),
637
- * });
638
- *
639
- * const result = await cache.getOrAdd("a", new LazyPromise(async () => -1));
640
- * // -1
641
- * console.log(result);
642
- * ```
643
- */
644
- getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>,
645
- /**
646
- * @default {null}
647
- */
648
- ttl?: TimeSpan): LazyPromise<TType>;
649
- decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
205
+ getGroup(): string | null;
206
+ withGroup(group: OneOrMore<string>): ICache<TType>;
650
207
  }