@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
@@ -0,0 +1,698 @@
1
+ /**
2
+ * @module Cache
3
+ */
4
+ import {} from "vitest";
5
+ import {} from "../../../cache/contracts/_module-exports.js";
6
+ import { TimeSpan } from "../../../utilities/_module-exports.js";
7
+ /**
8
+ * The <i>databaseCacheAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IDatabaseCacheAdapter}</i> with <i>vitest</i>.
9
+ *
10
+ * IMPORT_PATH: ```"@daiso-tech/core/cache/test-utilities"```
11
+ * @group Test utilities
12
+ * @example
13
+ * ```ts
14
+ * import { afterEach, beforeEach, describe, expect, test } from "vitest";
15
+ * import Sqlite, { type Database } from "better-sqlite3";
16
+ * import { databaseCacheAdapterTestSuite } from "@daiso-tech/core/cache/test-utilities";
17
+ * import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
18
+ * import { Serde } from "@daiso-tech/core/serde";
19
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
20
+ *
21
+ * describe("class: SqliteCacheAdapter", () => {
22
+ * let database: Database;
23
+ * beforeEach(() => {
24
+ * database = new Sqlite(":memory:");
25
+ * });
26
+ * afterEach(() => {
27
+ * database.close();
28
+ * });
29
+ * databaseCacheAdapterTestSuite({
30
+ * createAdapter: async () => {
31
+ * const adapter = new SqliteCacheAdapter({
32
+ * database: database,
33
+ * tableName: "custom_table",
34
+ * shouldRemoveExpiredKeys: false,
35
+ * serde: new Serde(new SuperJsonSerdeAdapter()),
36
+ * });
37
+ * await adapter.init();
38
+ * return adapter;
39
+ * },
40
+ * test,
41
+ * beforeEach,
42
+ * expect,
43
+ * describe,
44
+ * });
45
+ * });
46
+ * ```
47
+ */
48
+ export function databaseCacheAdapterTestSuite(settings) {
49
+ const { expect, test, createAdapter, describe, beforeEach } = settings;
50
+ let adapter;
51
+ beforeEach(async () => {
52
+ adapter = await createAdapter();
53
+ });
54
+ describe("method: find", () => {
55
+ test("Should return null when key doesnt exists", async () => {
56
+ const findData = await adapter.find("a");
57
+ expect(findData).toBeNull();
58
+ });
59
+ test("Should return the value when key exists", async () => {
60
+ const insertData = {
61
+ key: "a",
62
+ value: 1,
63
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
64
+ };
65
+ await adapter.insert(insertData);
66
+ const findData = await adapter.find(insertData.key);
67
+ const result = {
68
+ expiration: insertData.expiration,
69
+ value: insertData.value,
70
+ };
71
+ expect(findData).toStrictEqual(result);
72
+ });
73
+ });
74
+ describe("method: insert", () => {
75
+ test("Should throw an error when key exists", async () => {
76
+ const insertData = {
77
+ key: "a",
78
+ value: 1,
79
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
80
+ };
81
+ await adapter.insert(insertData);
82
+ const promise = adapter.insert(insertData);
83
+ await expect(promise).rejects.toBeDefined();
84
+ });
85
+ });
86
+ describe("method: upsert", () => {
87
+ test("Should return null when key doesnt exist", async () => {
88
+ const upsertData = {
89
+ key: "a",
90
+ value: 1,
91
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
92
+ };
93
+ const prevData = await adapter.upsert(upsertData);
94
+ expect(prevData).toBeNull();
95
+ });
96
+ test("Should return previous key expiration when key exist", async () => {
97
+ const upsertData1 = {
98
+ key: "a",
99
+ value: 1,
100
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
101
+ };
102
+ await adapter.upsert(upsertData1);
103
+ const upsertData2 = {
104
+ key: "a",
105
+ value: 2,
106
+ expiration: TimeSpan.fromMilliseconds(50).toEndDate(),
107
+ };
108
+ const prevData = await adapter.upsert(upsertData2);
109
+ const result = {
110
+ expiration: upsertData1.expiration,
111
+ };
112
+ expect({ expiration: prevData?.expiration }).toStrictEqual(result);
113
+ });
114
+ test("Should persist insertion when key doesnt exist", async () => {
115
+ const upsertData = {
116
+ key: "a",
117
+ value: 1,
118
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
119
+ };
120
+ await adapter.upsert(upsertData);
121
+ const findData = await adapter.find(upsertData.key);
122
+ const result = {
123
+ value: upsertData.value,
124
+ expiration: upsertData.expiration,
125
+ };
126
+ expect(findData).toStrictEqual(result);
127
+ });
128
+ test("Should persist update when key exist", async () => {
129
+ const upsertData1 = {
130
+ key: "a",
131
+ value: 1,
132
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
133
+ };
134
+ await adapter.upsert(upsertData1);
135
+ const upsertData2 = {
136
+ key: "a",
137
+ value: 2,
138
+ expiration: TimeSpan.fromMilliseconds(50).toEndDate(),
139
+ };
140
+ await adapter.upsert(upsertData2);
141
+ const findData = await adapter.find(upsertData2.key);
142
+ const result = {
143
+ value: upsertData2.value,
144
+ expiration: upsertData2.expiration,
145
+ };
146
+ expect(findData).toStrictEqual(result);
147
+ });
148
+ });
149
+ describe("method: updateExpired", () => {
150
+ test("Should not persist update when key has no expiration", async () => {
151
+ const insertData = {
152
+ key: "a",
153
+ value: 1,
154
+ expiration: null,
155
+ };
156
+ await adapter.insert(insertData);
157
+ const updateData = {
158
+ key: "a",
159
+ value: 2,
160
+ expiration: null,
161
+ };
162
+ await adapter.updateExpired(updateData);
163
+ const findData = await adapter.find(updateData.key);
164
+ const result = {
165
+ value: insertData.value,
166
+ expiration: insertData.expiration,
167
+ };
168
+ expect(findData).toStrictEqual(result);
169
+ });
170
+ test("Should return 0 when key has no expiration", async () => {
171
+ const insertData = {
172
+ key: "a",
173
+ value: 1,
174
+ expiration: null,
175
+ };
176
+ await adapter.insert(insertData);
177
+ const updateData = {
178
+ key: "a",
179
+ value: 2,
180
+ expiration: null,
181
+ };
182
+ const result = await adapter.updateExpired(updateData);
183
+ expect(result).toBe(0);
184
+ });
185
+ test("Should not persist update when key has expiration but not expired", async () => {
186
+ const insertData = {
187
+ key: "a",
188
+ value: 1,
189
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
190
+ };
191
+ await adapter.insert(insertData);
192
+ const updateData = {
193
+ key: "a",
194
+ value: 2,
195
+ expiration: null,
196
+ };
197
+ await adapter.updateExpired(updateData);
198
+ const findData = await adapter.find(updateData.key);
199
+ const result = {
200
+ value: insertData.value,
201
+ expiration: insertData.expiration,
202
+ };
203
+ expect(findData).toStrictEqual(result);
204
+ });
205
+ test("Should return 0 update when key has expiration but not expired", async () => {
206
+ const insertData = {
207
+ key: "a",
208
+ value: 1,
209
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
210
+ };
211
+ await adapter.insert(insertData);
212
+ const updateData = {
213
+ key: "a",
214
+ value: 2,
215
+ expiration: null,
216
+ };
217
+ const result = await adapter.updateExpired(updateData);
218
+ expect(result).toBe(0);
219
+ });
220
+ test("Should persist update when key has expiration and expired", async () => {
221
+ const insertData = {
222
+ key: "a",
223
+ value: 1,
224
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
225
+ };
226
+ await adapter.insert(insertData);
227
+ const updateData = {
228
+ key: "a",
229
+ value: 2,
230
+ expiration: null,
231
+ };
232
+ await adapter.updateExpired(updateData);
233
+ const findData = await adapter.find(updateData.key);
234
+ const result = {
235
+ value: updateData.value,
236
+ expiration: updateData.expiration,
237
+ };
238
+ expect(findData).toStrictEqual(result);
239
+ });
240
+ test("Should return 1 update when key has expiration and expired", async () => {
241
+ const insertData = {
242
+ key: "a",
243
+ value: 1,
244
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
245
+ };
246
+ await adapter.insert(insertData);
247
+ const updateData = {
248
+ key: "a",
249
+ value: 2,
250
+ expiration: null,
251
+ };
252
+ const result = await adapter.updateExpired(updateData);
253
+ expect(result).toBe(1);
254
+ });
255
+ });
256
+ describe("method: updateUnexpired", () => {
257
+ test("Should persist update when key has no expiration", async () => {
258
+ const insertData = {
259
+ key: "a",
260
+ value: 1,
261
+ expiration: null,
262
+ };
263
+ await adapter.insert(insertData);
264
+ const updateData = {
265
+ key: "a",
266
+ value: 2,
267
+ };
268
+ await adapter.updateUnexpired(updateData);
269
+ const findData = await adapter.find(updateData.key);
270
+ const result = {
271
+ value: updateData.value,
272
+ expiration: insertData.expiration,
273
+ };
274
+ expect(findData).toStrictEqual(result);
275
+ });
276
+ test("Should return 1 when key has no expiration", async () => {
277
+ const insertData = {
278
+ key: "a",
279
+ value: 1,
280
+ expiration: null,
281
+ };
282
+ await adapter.insert(insertData);
283
+ const updateData = {
284
+ key: "a",
285
+ value: 2,
286
+ };
287
+ const result = await adapter.updateUnexpired(updateData);
288
+ expect(result).toBe(1);
289
+ });
290
+ test("Should persist update when key has expiration but not expired", async () => {
291
+ const insertData = {
292
+ key: "a",
293
+ value: 1,
294
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
295
+ };
296
+ await adapter.insert(insertData);
297
+ const updateData = {
298
+ key: "a",
299
+ value: 2,
300
+ };
301
+ await adapter.updateUnexpired(updateData);
302
+ const findData = await adapter.find(updateData.key);
303
+ const result = {
304
+ value: updateData.value,
305
+ expiration: insertData.expiration,
306
+ };
307
+ expect(findData).toStrictEqual(result);
308
+ });
309
+ test("Should return 1 update when key has expiration but not expired", async () => {
310
+ const insertData = {
311
+ key: "a",
312
+ value: 1,
313
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
314
+ };
315
+ await adapter.insert(insertData);
316
+ const updateData = {
317
+ key: "a",
318
+ value: 2,
319
+ };
320
+ const result = await adapter.updateUnexpired(updateData);
321
+ expect(result).toBe(1);
322
+ });
323
+ test("Should not persist update when key has expiration and expired", async () => {
324
+ const insertData = {
325
+ key: "a",
326
+ value: 1,
327
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
328
+ };
329
+ await adapter.insert(insertData);
330
+ const updateData = {
331
+ key: "a",
332
+ value: 2,
333
+ };
334
+ await adapter.updateUnexpired(updateData);
335
+ const findData = await adapter.find(updateData.key);
336
+ const result = {
337
+ value: insertData.value,
338
+ expiration: insertData.expiration,
339
+ };
340
+ expect(findData).toStrictEqual(result);
341
+ });
342
+ test("Should return 0 update when key has expiration and expired", async () => {
343
+ const insertData = {
344
+ key: "a",
345
+ value: 1,
346
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
347
+ };
348
+ await adapter.insert(insertData);
349
+ const updateData = {
350
+ key: "a",
351
+ value: 2,
352
+ };
353
+ const result = await adapter.updateUnexpired(updateData);
354
+ expect(result).toBe(0);
355
+ });
356
+ });
357
+ describe("method: incrementUnexpired", () => {
358
+ test("Should persist update when key has no expiration", async () => {
359
+ const insertData = {
360
+ key: "a",
361
+ value: 1,
362
+ expiration: null,
363
+ };
364
+ await adapter.insert(insertData);
365
+ const updateData = {
366
+ key: "a",
367
+ value: 2,
368
+ };
369
+ await adapter.incrementUnexpired(updateData);
370
+ const findData = await adapter.find(updateData.key);
371
+ const result = {
372
+ value: insertData.value + updateData.value,
373
+ expiration: insertData.expiration,
374
+ };
375
+ expect(findData).toStrictEqual(result);
376
+ });
377
+ test("Should return 1 when key has no expiration", async () => {
378
+ const insertData = {
379
+ key: "a",
380
+ value: 1,
381
+ expiration: null,
382
+ };
383
+ await adapter.insert(insertData);
384
+ const updateData = {
385
+ key: "a",
386
+ value: 2,
387
+ };
388
+ const result = await adapter.incrementUnexpired(updateData);
389
+ expect(result).toBe(1);
390
+ });
391
+ test("Should persist update when key has expiration but not expired", async () => {
392
+ const insertData = {
393
+ key: "a",
394
+ value: 1,
395
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
396
+ };
397
+ await adapter.insert(insertData);
398
+ const updateData = {
399
+ key: "a",
400
+ value: 2,
401
+ };
402
+ await adapter.incrementUnexpired(updateData);
403
+ const findData = await adapter.find(updateData.key);
404
+ const result = {
405
+ value: insertData.value + updateData.value,
406
+ expiration: insertData.expiration,
407
+ };
408
+ expect(findData).toStrictEqual(result);
409
+ });
410
+ test("Should return 1 update when key has expiration but not expired", async () => {
411
+ const insertData = {
412
+ key: "a",
413
+ value: 1,
414
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
415
+ };
416
+ await adapter.insert(insertData);
417
+ const updateData = {
418
+ key: "a",
419
+ value: 2,
420
+ };
421
+ const result = await adapter.incrementUnexpired(updateData);
422
+ expect(result).toBe(1);
423
+ });
424
+ test("Should not persist update when key has expiration and expired", async () => {
425
+ const insertData = {
426
+ key: "a",
427
+ value: 1,
428
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
429
+ };
430
+ await adapter.insert(insertData);
431
+ const updateData = {
432
+ key: "a",
433
+ value: 2,
434
+ };
435
+ await adapter.incrementUnexpired(updateData);
436
+ const findData = await adapter.find(updateData.key);
437
+ const result = {
438
+ value: insertData.value,
439
+ expiration: insertData.expiration,
440
+ };
441
+ expect(findData).toStrictEqual(result);
442
+ });
443
+ test("Should return 0 update when key has expiration and expired", async () => {
444
+ const insertData = {
445
+ key: "a",
446
+ value: 1,
447
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
448
+ };
449
+ await adapter.insert(insertData);
450
+ const updateData = {
451
+ key: "a",
452
+ value: 2,
453
+ };
454
+ const result = await adapter.incrementUnexpired(updateData);
455
+ expect(result).toBe(0);
456
+ });
457
+ test("Should throw an error when incrementing a number error", async () => {
458
+ await adapter.insert({
459
+ key: "a",
460
+ value: "A",
461
+ expiration: null,
462
+ });
463
+ const promise = adapter.incrementUnexpired({
464
+ key: "a",
465
+ value: 2,
466
+ });
467
+ await expect(promise).rejects.toBeDefined();
468
+ });
469
+ });
470
+ describe("method: removeExpiredMany", () => {
471
+ test("Should not persist removal when key has no expiration", async () => {
472
+ const insertData = {
473
+ key: "a",
474
+ value: 1,
475
+ expiration: null,
476
+ };
477
+ await adapter.insert(insertData);
478
+ await adapter.removeExpiredMany([insertData.key]);
479
+ const findData = await adapter.find(insertData.key);
480
+ const result = {
481
+ value: insertData.value,
482
+ expiration: insertData.expiration,
483
+ };
484
+ expect(findData).toStrictEqual(result);
485
+ });
486
+ test("Should return 0 when key has no expiration", async () => {
487
+ const insertData = {
488
+ key: "a",
489
+ value: 1,
490
+ expiration: null,
491
+ };
492
+ await adapter.insert(insertData);
493
+ const result = await adapter.removeExpiredMany([insertData.key]);
494
+ expect(result).toBe(0);
495
+ });
496
+ test("Should not persist removal when key has expiration but not expired", async () => {
497
+ const insertData = {
498
+ key: "a",
499
+ value: 1,
500
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
501
+ };
502
+ await adapter.insert(insertData);
503
+ await adapter.removeExpiredMany([insertData.key]);
504
+ const findData = await adapter.find(insertData.key);
505
+ const result = {
506
+ value: insertData.value,
507
+ expiration: insertData.expiration,
508
+ };
509
+ expect(findData).toStrictEqual(result);
510
+ });
511
+ test("Should return 0 removal when key has expiration but not expired", async () => {
512
+ const insertData = {
513
+ key: "a",
514
+ value: 1,
515
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
516
+ };
517
+ await adapter.insert(insertData);
518
+ const result = await adapter.removeExpiredMany([insertData.key]);
519
+ expect(result).toBe(0);
520
+ });
521
+ test("Should persist removal when key has expiration and expired", async () => {
522
+ const insertData = {
523
+ key: "a",
524
+ value: 1,
525
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
526
+ };
527
+ await adapter.insert(insertData);
528
+ await adapter.removeExpiredMany([insertData.key]);
529
+ const findData = await adapter.find(insertData.key);
530
+ expect(findData).toBeNull();
531
+ });
532
+ test("Should return number of removed keys when all keys has expiration and are expired", async () => {
533
+ const insertData1 = {
534
+ key: "a",
535
+ value: 1,
536
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
537
+ };
538
+ const insertData2 = {
539
+ key: "b",
540
+ value: 1,
541
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
542
+ };
543
+ await adapter.insert(insertData1);
544
+ await adapter.insert(insertData2);
545
+ const result = await adapter.removeExpiredMany([
546
+ insertData1.key,
547
+ insertData2.key,
548
+ ]);
549
+ expect(result).toBe(2);
550
+ });
551
+ });
552
+ describe("method: removeUnexpiredMany", () => {
553
+ test("Should persist removal when key has no expiration", async () => {
554
+ const insertData = {
555
+ key: "a",
556
+ value: 1,
557
+ expiration: null,
558
+ };
559
+ await adapter.insert(insertData);
560
+ await adapter.removeUnexpiredMany([insertData.key]);
561
+ const findData = await adapter.find(insertData.key);
562
+ expect(findData).toBeNull();
563
+ });
564
+ test("Should return number of removed keys when all keys has no expiration", async () => {
565
+ const insertData1 = {
566
+ key: "a",
567
+ value: 1,
568
+ expiration: null,
569
+ };
570
+ const insertData2 = {
571
+ key: "b",
572
+ value: 1,
573
+ expiration: null,
574
+ };
575
+ await adapter.insert(insertData1);
576
+ await adapter.insert(insertData2);
577
+ const result = await adapter.removeUnexpiredMany([
578
+ insertData1.key,
579
+ insertData2.key,
580
+ ]);
581
+ expect(result).toBe(2);
582
+ });
583
+ test("Should persist removal when key has expiration but not expired", async () => {
584
+ const insertData = {
585
+ key: "a",
586
+ value: 1,
587
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
588
+ };
589
+ await adapter.insert(insertData);
590
+ await adapter.removeUnexpiredMany([insertData.key]);
591
+ const findData = await adapter.find(insertData.key);
592
+ expect(findData).toBeNull();
593
+ });
594
+ test("Should return number of removed keys when all key has expiration but not expired", async () => {
595
+ const insertData1 = {
596
+ key: "a",
597
+ value: 1,
598
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
599
+ };
600
+ const insertData2 = {
601
+ key: "b",
602
+ value: 1,
603
+ expiration: TimeSpan.fromMilliseconds(25).toEndDate(),
604
+ };
605
+ await adapter.insert(insertData1);
606
+ await adapter.insert(insertData2);
607
+ const result = await adapter.removeUnexpiredMany([
608
+ insertData1.key,
609
+ insertData2.key,
610
+ ]);
611
+ expect(result).toBe(2);
612
+ });
613
+ test("Should not persist removal when key has expiration and expired", async () => {
614
+ const insertData = {
615
+ key: "a",
616
+ value: 1,
617
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
618
+ };
619
+ await adapter.insert(insertData);
620
+ await adapter.removeUnexpiredMany([insertData.key]);
621
+ const findData = await adapter.find(insertData.key);
622
+ const result = {
623
+ expiration: insertData.expiration,
624
+ value: insertData.value,
625
+ };
626
+ expect(findData).toStrictEqual(result);
627
+ });
628
+ test("Should return 0 removal when key has expiration and expired", async () => {
629
+ const insertData = {
630
+ key: "a",
631
+ value: 1,
632
+ expiration: TimeSpan.fromMilliseconds(25).toStartDate(),
633
+ };
634
+ await adapter.insert(insertData);
635
+ const result = await adapter.removeUnexpiredMany([insertData.key]);
636
+ expect(result).toBe(0);
637
+ });
638
+ });
639
+ describe("method: removeAll", () => {
640
+ test("Should remove all keys", async () => {
641
+ await adapter.insert({
642
+ key: "cache/a",
643
+ value: 1,
644
+ expiration: null,
645
+ });
646
+ await adapter.insert({
647
+ key: "cache/b",
648
+ value: 2,
649
+ expiration: null,
650
+ });
651
+ await adapter.insert({
652
+ key: "c",
653
+ value: 3,
654
+ expiration: null,
655
+ });
656
+ await adapter.removeAll();
657
+ expect([
658
+ await adapter.find("cache/a"),
659
+ await adapter.find("cache/b"),
660
+ await adapter.find("c"),
661
+ ]).toEqual([null, null, null]);
662
+ });
663
+ });
664
+ describe("method: removeByKeyPrefix", () => {
665
+ test("Should remove the keys that mathc the prefix", async () => {
666
+ await adapter.insert({
667
+ key: "cache/a",
668
+ value: 1,
669
+ expiration: null,
670
+ });
671
+ await adapter.insert({
672
+ key: "cache/b",
673
+ value: 2,
674
+ expiration: null,
675
+ });
676
+ await adapter.insert({
677
+ key: "c",
678
+ value: 3,
679
+ expiration: null,
680
+ });
681
+ await adapter.removeByKeyPrefix("cache");
682
+ const result = [
683
+ await adapter.find("cache/a"),
684
+ await adapter.find("cache/b"),
685
+ await adapter.find("c"),
686
+ ];
687
+ expect(result).toStrictEqual([
688
+ null,
689
+ null,
690
+ {
691
+ value: 3,
692
+ expiration: null,
693
+ },
694
+ ]);
695
+ });
696
+ });
697
+ }
698
+ //# sourceMappingURL=database-cache-dapter.test-suite.js.map