@daiso-tech/core 0.26.1 → 0.28.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 (289) hide show
  1. package/README.md +13 -3
  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 +143 -71
  6. package/dist/async/utilities/lazy-promise/lazy-promise.js +223 -142
  7. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  8. package/dist/async/utilities/retry/retry-or-fail.d.ts +2 -0
  9. package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
  10. package/dist/cache/contracts/_module-exports.d.ts +1 -0
  11. package/dist/cache/contracts/_module-exports.js +1 -0
  12. package/dist/cache/contracts/_module-exports.js.map +1 -1
  13. package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
  14. package/dist/cache/contracts/cache-adapter.contract.js +1 -4
  15. package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
  16. package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
  17. package/dist/cache/contracts/cache.contract.d.ts +144 -96
  18. package/dist/cache/contracts/cache.contract.js +1 -2
  19. package/dist/cache/contracts/cache.contract.js.map +1 -1
  20. package/dist/cache/contracts/cache.errors.js +2 -5
  21. package/dist/cache/contracts/cache.errors.js.map +1 -1
  22. package/dist/cache/contracts/cache.events.d.ts +10 -10
  23. package/dist/cache/contracts/cache.events.js +2 -5
  24. package/dist/cache/contracts/cache.events.js.map +1 -1
  25. package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
  26. package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
  27. package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
  28. package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
  29. package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
  30. package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
  31. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
  32. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
  33. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
  34. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
  35. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
  36. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
  37. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
  38. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
  39. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  40. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
  41. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
  42. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
  43. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
  44. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
  45. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  46. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +14 -13
  47. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +19 -17
  48. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
  49. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
  50. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
  51. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
  52. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
  53. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
  54. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  55. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
  56. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
  57. package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
  58. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -41
  59. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
  60. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
  61. package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
  62. package/dist/cache/implementations/derivables/_module-exports.js +1 -1
  63. package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
  64. package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
  65. package/dist/cache/implementations/derivables/cache/_module.js +1 -0
  66. package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
  67. package/dist/cache/implementations/derivables/cache/cache.d.ts +269 -507
  68. package/dist/cache/implementations/derivables/cache/cache.js +538 -822
  69. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  70. package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
  71. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
  72. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
  73. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
  74. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
  75. package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
  76. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +69 -105
  77. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +117 -87
  78. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  79. package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
  80. package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
  81. package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
  82. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
  83. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
  84. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
  85. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
  86. package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
  87. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  88. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
  89. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
  90. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
  91. package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
  92. package/dist/collection/contracts/async-collection.contract.js +1 -12
  93. package/dist/collection/contracts/async-collection.contract.js.map +1 -1
  94. package/dist/collection/contracts/collection.contract.d.ts +1 -1
  95. package/dist/collection/contracts/collection.errors.d.ts +1 -1
  96. package/dist/collection/contracts/collection.errors.js +3 -6
  97. package/dist/collection/contracts/collection.errors.js.map +1 -1
  98. package/dist/collection/implementations/_shared.d.ts +4 -4
  99. package/dist/collection/implementations/_shared.js +6 -9
  100. package/dist/collection/implementations/_shared.js.map +1 -1
  101. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
  102. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
  103. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +5 -21
  104. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +12 -8
  105. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  106. package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
  107. package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
  108. package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
  109. package/dist/collection/implementations/list-collection/list-collection.js +1 -1
  110. package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
  111. package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
  112. package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
  113. package/dist/event-bus/contracts/event-bus.errors.js +2 -5
  114. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  115. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
  116. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
  117. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
  118. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -4
  119. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -8
  120. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
  121. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
  122. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
  123. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
  124. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +85 -289
  125. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +128 -325
  126. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  127. package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
  128. package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
  129. package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
  130. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +103 -86
  131. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +135 -77
  132. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  133. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -48
  134. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
  135. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  136. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
  137. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
  138. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  139. package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
  140. package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
  141. package/dist/lock/contracts/lock-provider.contract.d.ts +20 -6
  142. package/dist/lock/contracts/lock.contract.d.ts +37 -8
  143. package/dist/lock/contracts/lock.errors.js +2 -5
  144. package/dist/lock/contracts/lock.errors.js.map +1 -1
  145. package/dist/lock/contracts/lock.events.js +2 -5
  146. package/dist/lock/contracts/lock.events.js.map +1 -1
  147. package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -0
  148. package/dist/lock/implementations/adapters/_module-exports.js +1 -0
  149. package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
  150. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
  151. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
  152. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
  153. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
  154. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
  155. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
  156. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
  157. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
  158. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
  159. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
  160. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
  161. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
  162. package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.d.ts +1 -0
  163. package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js +2 -0
  164. package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js.map +1 -0
  165. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +17 -0
  166. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +24 -0
  167. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -0
  168. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
  169. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
  170. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
  171. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +14 -20
  172. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
  173. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
  174. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
  175. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
  176. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
  177. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +1 -5
  178. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
  179. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +181 -369
  180. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +259 -407
  181. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  182. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +15 -17
  183. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
  184. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  185. package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
  186. package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
  187. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +194 -680
  188. package/dist/lock/implementations/derivables/lock-provider/lock.js +284 -744
  189. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  190. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +106 -143
  191. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +173 -101
  192. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  193. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
  194. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
  195. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
  196. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
  197. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
  198. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
  199. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
  200. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +295 -145
  201. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  202. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
  203. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
  204. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +3 -2
  205. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -1
  206. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js.map +1 -1
  207. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
  208. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
  209. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
  210. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
  211. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
  212. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
  213. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  214. package/dist/serde/implementations/derivables/serde.d.ts +14 -14
  215. package/dist/serde/implementations/derivables/serde.js +14 -15
  216. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  217. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
  218. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
  219. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
  220. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
  221. package/dist/utilities/_module-exports.d.ts +2 -3
  222. package/dist/utilities/_module-exports.js +2 -3
  223. package/dist/utilities/_module-exports.js.map +1 -1
  224. package/dist/utilities/classes/_module.d.ts +4 -0
  225. package/dist/utilities/classes/_module.js +5 -0
  226. package/dist/utilities/classes/_module.js.map +1 -0
  227. package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
  228. package/dist/utilities/classes/key-prefixer/_module.js +3 -0
  229. package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
  230. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
  231. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
  232. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
  233. package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
  234. package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
  235. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
  236. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
  237. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
  238. package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
  239. package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
  240. package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
  241. package/dist/utilities/classes/pipeline/_module.js +2 -0
  242. package/dist/utilities/classes/pipeline/_module.js.map +1 -0
  243. package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
  244. package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
  245. package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
  246. package/dist/utilities/classes/time-span/_module.d.ts +1 -0
  247. package/dist/utilities/classes/time-span/_module.js +2 -0
  248. package/dist/utilities/classes/time-span/_module.js.map +1 -0
  249. package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
  250. package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
  251. package/dist/utilities/classes/time-span/time-span.js.map +1 -0
  252. package/dist/utilities/{_constants.d.ts → constants.d.ts} +0 -3
  253. package/dist/utilities/constants.js +5 -0
  254. package/dist/utilities/constants.js.map +1 -0
  255. package/dist/utilities/contracts/_module.d.ts +3 -1
  256. package/dist/utilities/contracts/_module.js +3 -1
  257. package/dist/utilities/contracts/_module.js.map +1 -1
  258. package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
  259. package/dist/utilities/contracts/prunable.contract.js +5 -0
  260. package/dist/utilities/contracts/prunable.contract.js.map +1 -0
  261. package/dist/utilities/contracts/sqlite-database.contract.d.ts +26 -0
  262. package/dist/utilities/contracts/sqlite-database.contract.js +5 -0
  263. package/dist/utilities/contracts/sqlite-database.contract.js.map +1 -0
  264. package/dist/utilities/functions.d.ts +34 -2
  265. package/dist/utilities/functions.js +72 -4
  266. package/dist/utilities/functions.js.map +1 -1
  267. package/dist/utilities/types.d.ts +49 -16
  268. package/package.json +14 -13
  269. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
  270. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
  271. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
  272. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
  273. package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
  274. package/dist/utilities/_constants.js +0 -8
  275. package/dist/utilities/_constants.js.map +0 -1
  276. package/dist/utilities/kysely/_module.d.ts +0 -1
  277. package/dist/utilities/kysely/_module.js +0 -2
  278. package/dist/utilities/kysely/_module.js.map +0 -1
  279. package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
  280. package/dist/utilities/pipeline/_module.d.ts +0 -1
  281. package/dist/utilities/pipeline/_module.js +0 -2
  282. package/dist/utilities/pipeline/_module.js.map +0 -1
  283. package/dist/utilities/pipeline/pipeline.js.map +0 -1
  284. package/dist/utilities/time-span/_module.d.ts +0 -1
  285. package/dist/utilities/time-span/_module.js +0 -2
  286. package/dist/utilities/time-span/_module.js.map +0 -1
  287. package/dist/utilities/time-span/time-span.js.map +0 -1
  288. /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
  289. /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
@@ -2,137 +2,154 @@
2
2
  * @module EventBus
3
3
  */
4
4
  import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module-exports.js";
5
- import { type IEventBusAdapter, type IGroupableEventBus, type IEventBusFactory, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
6
- import type { OneOrMore, TimeSpan } from "../../../../utilities/_module-exports.js";
7
- import type { IFlexibleSerde } from "../../../../serde/contracts/_module-exports.js";
5
+ import { type IGroupableEventBus, type IEventBusFactory, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
6
+ import { type EventBusAdapterFactoryable, type EventBusSettingsBase } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
7
+ import type { KeyPrefixer, TimeSpan } from "../../../../utilities/_module-exports.js";
8
8
  /**
9
9
  *
10
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/derivables"```
10
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
11
11
  * @group Derivables
12
12
  */
13
- export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, IEventBusAdapter>>;
13
+ export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, EventBusAdapterFactoryable>>;
14
14
  /**
15
15
  *
16
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/derivables"```
16
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
17
17
  * @group Derivables
18
18
  */
19
- export type EventBusFactorySettings<TAdapters extends string = string> = {
20
- /**
21
- * You can pass one or more <i>{@link IFlexibleSerde}</i> that will be used to register all <i>{@link IGroupableEventBus}</i> related errors.
22
- * @default {true}
23
- */
24
- serde: OneOrMore<IFlexibleSerde>;
25
- /**
26
- * If set to true, all <i>{@link IGroupableEventBus}</i> related errors will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
27
- * This ensures that all <i>{@link IGroupableEventBus}</i> related errors will be serialized correctly.
28
- * @default {true}
29
- */
30
- shouldRegisterErrors?: boolean;
19
+ export type EventBusFactorySettings<TAdapters extends string = string> = EventBusSettingsBase & {
31
20
  adapters: EventBusAdapters<TAdapters>;
32
21
  defaultAdapter?: NoInfer<TAdapters>;
33
- /**
34
- * In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
35
- */
36
- eventBus?: IGroupableEventBus<any>;
37
- /**
38
- * The default retry attempt to use in the returned <i>LazyPromise</i>.
39
- * @default {null}
40
- */
41
- retryAttempts?: number | null;
42
- /**
43
- * The default backof policy to use in the returned <i>LazyPromise</i>.
44
- * @default {null}
45
- */
46
- backoffPolicy?: BackoffPolicy | null;
47
- /**
48
- * The default retry policy to use in the returned <i>LazyPromise</i>.
49
- * @default {null}
50
- */
51
- retryPolicy?: RetryPolicy | null;
52
- /**
53
- * The default timeout to use in the returned <i>LazyPromise</i>.
54
- * @default {null}
55
- */
56
- timeout?: TimeSpan | null;
57
22
  };
58
23
  /**
59
24
  *
60
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/derivables"```
25
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
61
26
  * @group Derivables
62
27
  */
63
28
  export declare class EventBusFactory<TAdapters extends string = string> implements IEventBusFactory<TAdapters> {
64
- private readonly eventBusRecord;
65
- private readonly serde;
66
- private readonly defaultAdapter?;
67
- private readonly retryAttempts?;
68
- private readonly backoffPolicy?;
69
- private readonly retryPolicy?;
70
- private readonly timeout?;
71
- private readonly shouldRegisterErrors?;
29
+ private readonly settings;
72
30
  /**
73
31
  * @example
74
32
  * ```ts
75
- * import { EventBusFactory } from "@daiso-tech/core/event-bus/implementations/derivables";
76
- * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
77
- * import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
78
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
33
+ * import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
34
+ * import { EventBusFactory } from "@daiso-tech/core/event-bus";
35
+ * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
36
+ * import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
37
+ * import { Serde } from "@daiso-tech/core/serde";
38
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
79
39
  * import Redis from "ioredis";
80
40
  *
41
+ * type Store = Partial<Record<string, IEventBusAdapter>> = {};
42
+ *
43
+ * async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
44
+ * return (prefix) => {
45
+ * let adapter = store[prefix];
46
+ * if (adapter === undefined) {
47
+ * adapter = new MemoryEventBusAdapter();
48
+ * store[prefix] = adapter;
49
+ * }
50
+ * return adapter;
51
+ * }
52
+ * }
53
+ *
81
54
  * const serde = new Serde(new SuperJsonSerdeAdapter());
82
- * const cacheFactory = new EventBusFactory({
83
- * serde,
55
+ * const store: Store = {};
56
+ * const eventBusFactory = new EventBusFactory({
57
+ * keyPrefixer: new KeyPrefixer("event-bus"),
84
58
  * adapters: {
85
- * memory:new MemoryEventBusAdapter({
86
- * rootGroup: "@global"
87
- * }),
59
+ * memory: new MemoryEventBusAdapter(),
60
+ * memoryFactory: cahceAdapterFactory(store),
88
61
  * redis: new RedisPubSubEventBusAdapter({
89
- * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
90
- * listenerClient: new Redis("YOUR_REDIS_CONNECTION")
91
62
  * serde,
92
- * rootGroup: "@global"
63
+ * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
64
+ * listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
93
65
  * }),
94
- * defaultAdapter: "memory"
95
- * }
66
+ * },
67
+ * defaultAdapter: "memory"
96
68
  * });
97
69
  * ```
98
70
  */
99
71
  constructor(settings: EventBusFactorySettings<TAdapters>);
100
- private init;
72
+ setKeyPrefixer(keyPrefixer: KeyPrefixer): EventBusFactory<TAdapters>;
73
+ setRetryAttempts(attempts: number): EventBusFactory<TAdapters>;
74
+ setBackoffPolicy(policy: BackoffPolicy): EventBusFactory<TAdapters>;
75
+ setRetryPolicy(policy: RetryPolicy): EventBusFactory<TAdapters>;
76
+ setRetryTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
77
+ setTotalTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
101
78
  /**
102
79
  * @example
103
80
  * ```ts
104
- * import { BaseEvent } from "@daiso-tech/core/event-bus/contracts";
105
- * import { EventBusFactory } from "@daiso-tech/core/event-bus/implementations/derivables";
106
- * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
107
- * import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
108
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
81
+ * import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
82
+ * import { EventBusFactory } from "@daiso-tech/core/event-bus";
83
+ * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
84
+ * import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
85
+ * import { Serde } from "@daiso-tech/core/serde";
86
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
109
87
  * import Redis from "ioredis";
110
88
  *
89
+ * type Store = Partial<Record<string, IEventBusAdapter>> = {};
90
+ *
91
+ * async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
92
+ * return (prefix) => {
93
+ * let adapter = store[prefix];
94
+ * if (adapter === undefined) {
95
+ * adapter = new MemoryEventBusAdapter();
96
+ * store[prefix] = adapter;
97
+ * }
98
+ * return adapter;
99
+ * }
100
+ * }
101
+ *
102
+ * const dispatcherClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
103
+ * const listenerClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
111
104
  * const serde = new Serde(new SuperJsonSerdeAdapter());
112
- * const cacheFactory = new EventBusFactory({
113
- * serde,
105
+ * const store: Store = {};
106
+ * const eventBusFactory = new EventBusFactory({
107
+ * keyPrefixer: new KeyPrefixer("event-bus"),
114
108
  * adapters: {
115
- * memory:new MemoryEventBusAdapter({
116
- * rootGroup: "@global"
117
- * }),
109
+ * memory: new MemoryEventBusAdapter(),
110
+ * memoryFactory: cahceAdapterFactory(store),
118
111
  * redis: new RedisPubSubEventBusAdapter({
119
- * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
120
- * listenerClient: new Redis("YOUR_REDIS_CONNECTION")
121
112
  * serde,
122
- * rootGroup: "@global"
113
+ * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
114
+ * listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
123
115
  * }),
124
- * defaultAdapter: "memory"
125
- * }
116
+ * },
117
+ * defaultAdapter: "memory"
126
118
  * });
127
119
  *
128
120
  * class AddEvent extends BaseEvent<{ a: number, b: number }> {}
129
- * serde.registerEvent(AddEvent);
130
121
  *
131
- * // Will use the default adapter which is MemoryEventBusAdapter
132
- * await cacheFactory.use().dispatch(new AddEvent({ a: 1, b: 2 }));
122
+ * // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
123
+ * await eventBusFactory
124
+ * .use()
125
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
126
+ *
127
+ * // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
128
+ * await eventBusFactory
129
+ * .use("redis")
130
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
131
+ *
132
+ * // You can change the default settings of the returned EventBus instance.
133
+ * await eventBusFactory
134
+ * .setRetryAttempts(4)
135
+ * .use("memoryFactory")
136
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
137
+ *
138
+ * // You can reuse the settings
139
+ * const retryableEventBusFactory = eventBusFactory
140
+ * .setRetryAttempts(4);
141
+ *
142
+ * await retryableEventBusFactory
143
+ * .use()
144
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
145
+ *
146
+ * // You can extend the settings
147
+ * const extendedEventBusFactory = retryableEventBusFactory
148
+ * .setRetryTimeout(TimeSpan.fromSeconds(1));
133
149
  *
134
- * // Will use the redis dapter which is RedisPubSubEventBusAdapter
135
- * await cacheFactory.use("redis").dispatch(new AddEvent({ a: 1, b: 2 }));
150
+ * await extendedEventBusFactory
151
+ * .use()
152
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
136
153
  * ```
137
154
  */
138
155
  use<TEvents extends BaseEvent = BaseEvent>(adapterName?: TAdapters | undefined): IGroupableEventBus<TEvents>;
@@ -1,127 +1,185 @@
1
1
  /**
2
2
  * @module EventBus
3
3
  */
4
- import { registerEventBusErrorsToSerde, } from "../../../../event-bus/contracts/_module-exports.js";
5
- import { EventBus } from "../../../../event-bus/implementations/derivables/event-bus/event-bus.js";
4
+ import {} from "../../../../event-bus/contracts/_module-exports.js";
5
+ import { EventBus, } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
6
6
  import { DefaultAdapterNotDefinedError, UnregisteredAdapterError, } from "../../../../utilities/_module-exports.js";
7
7
  /**
8
8
  *
9
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/derivables"```
9
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
10
10
  * @group Derivables
11
11
  */
12
12
  export class EventBusFactory {
13
- eventBusRecord = {};
14
- serde;
15
- defaultAdapter;
16
- retryAttempts;
17
- backoffPolicy;
18
- retryPolicy;
19
- timeout;
20
- shouldRegisterErrors;
13
+ settings;
21
14
  /**
22
15
  * @example
23
16
  * ```ts
24
- * import { EventBusFactory } from "@daiso-tech/core/event-bus/implementations/derivables";
25
- * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
26
- * import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
27
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
17
+ * import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
18
+ * import { EventBusFactory } from "@daiso-tech/core/event-bus";
19
+ * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
20
+ * import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
21
+ * import { Serde } from "@daiso-tech/core/serde";
22
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
28
23
  * import Redis from "ioredis";
29
24
  *
25
+ * type Store = Partial<Record<string, IEventBusAdapter>> = {};
26
+ *
27
+ * async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
28
+ * return (prefix) => {
29
+ * let adapter = store[prefix];
30
+ * if (adapter === undefined) {
31
+ * adapter = new MemoryEventBusAdapter();
32
+ * store[prefix] = adapter;
33
+ * }
34
+ * return adapter;
35
+ * }
36
+ * }
37
+ *
30
38
  * const serde = new Serde(new SuperJsonSerdeAdapter());
31
- * const cacheFactory = new EventBusFactory({
32
- * serde,
39
+ * const store: Store = {};
40
+ * const eventBusFactory = new EventBusFactory({
41
+ * keyPrefixer: new KeyPrefixer("event-bus"),
33
42
  * adapters: {
34
- * memory:new MemoryEventBusAdapter({
35
- * rootGroup: "@global"
36
- * }),
43
+ * memory: new MemoryEventBusAdapter(),
44
+ * memoryFactory: cahceAdapterFactory(store),
37
45
  * redis: new RedisPubSubEventBusAdapter({
38
- * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
39
- * listenerClient: new Redis("YOUR_REDIS_CONNECTION")
40
46
  * serde,
41
- * rootGroup: "@global"
47
+ * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
48
+ * listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
42
49
  * }),
43
- * defaultAdapter: "memory"
44
- * }
50
+ * },
51
+ * defaultAdapter: "memory"
45
52
  * });
46
53
  * ```
47
54
  */
48
55
  constructor(settings) {
49
- const { adapters, shouldRegisterErrors = true, serde, defaultAdapter, retryAttempts, backoffPolicy, retryPolicy, timeout, } = settings;
50
- this.shouldRegisterErrors = shouldRegisterErrors;
51
- this.serde = serde;
52
- this.retryAttempts = retryAttempts;
53
- this.backoffPolicy = backoffPolicy;
54
- this.retryPolicy = retryPolicy;
55
- this.timeout = timeout;
56
- this.defaultAdapter = defaultAdapter;
57
- this.eventBusRecord = this.init(adapters);
56
+ this.settings = settings;
58
57
  }
59
- init(adapters) {
60
- if (this.shouldRegisterErrors) {
61
- registerEventBusErrorsToSerde(this.serde);
62
- }
63
- const eventBusRecord = {};
64
- for (const key in adapters) {
65
- const { [key]: adapter } = adapters;
66
- if (adapter === undefined) {
67
- continue;
68
- }
69
- eventBusRecord[key] = new EventBus({
70
- adapter,
71
- retryAttempts: this.retryAttempts,
72
- backoffPolicy: this.backoffPolicy,
73
- retryPolicy: this.retryPolicy,
74
- timeout: this.timeout,
75
- });
76
- }
77
- return eventBusRecord;
58
+ setKeyPrefixer(keyPrefixer) {
59
+ return new EventBusFactory({
60
+ ...this.settings,
61
+ keyPrefixer,
62
+ });
63
+ }
64
+ setRetryAttempts(attempts) {
65
+ return new EventBusFactory({
66
+ ...this.settings,
67
+ retryAttempts: attempts,
68
+ });
69
+ }
70
+ setBackoffPolicy(policy) {
71
+ return new EventBusFactory({
72
+ ...this.settings,
73
+ backoffPolicy: policy,
74
+ });
75
+ }
76
+ setRetryPolicy(policy) {
77
+ return new EventBusFactory({
78
+ ...this.settings,
79
+ retryPolicy: policy,
80
+ });
81
+ }
82
+ setRetryTimeout(timeout) {
83
+ return new EventBusFactory({
84
+ ...this.settings,
85
+ retryTimeout: timeout,
86
+ });
87
+ }
88
+ setTotalTimeout(timeout) {
89
+ return new EventBusFactory({
90
+ ...this.settings,
91
+ totalTimeout: timeout,
92
+ });
78
93
  }
79
94
  /**
80
95
  * @example
81
96
  * ```ts
82
- * import { BaseEvent } from "@daiso-tech/core/event-bus/contracts";
83
- * import { EventBusFactory } from "@daiso-tech/core/event-bus/implementations/derivables";
84
- * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
85
- * import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
86
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
97
+ * import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
98
+ * import { EventBusFactory } from "@daiso-tech/core/event-bus";
99
+ * import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
100
+ * import { KeyPrefixer, type IFactoryObject, type Promiseable, type FactoryFn } from "@daiso-tech/utilities";
101
+ * import { Serde } from "@daiso-tech/core/serde";
102
+ * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
87
103
  * import Redis from "ioredis";
88
104
  *
105
+ * type Store = Partial<Record<string, IEventBusAdapter>> = {};
106
+ *
107
+ * async function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
108
+ * return (prefix) => {
109
+ * let adapter = store[prefix];
110
+ * if (adapter === undefined) {
111
+ * adapter = new MemoryEventBusAdapter();
112
+ * store[prefix] = adapter;
113
+ * }
114
+ * return adapter;
115
+ * }
116
+ * }
117
+ *
118
+ * const dispatcherClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
119
+ * const listenerClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
89
120
  * const serde = new Serde(new SuperJsonSerdeAdapter());
90
- * const cacheFactory = new EventBusFactory({
91
- * serde,
121
+ * const store: Store = {};
122
+ * const eventBusFactory = new EventBusFactory({
123
+ * keyPrefixer: new KeyPrefixer("event-bus"),
92
124
  * adapters: {
93
- * memory:new MemoryEventBusAdapter({
94
- * rootGroup: "@global"
95
- * }),
125
+ * memory: new MemoryEventBusAdapter(),
126
+ * memoryFactory: cahceAdapterFactory(store),
96
127
  * redis: new RedisPubSubEventBusAdapter({
97
- * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION"),
98
- * listenerClient: new Redis("YOUR_REDIS_CONNECTION")
99
128
  * serde,
100
- * rootGroup: "@global"
129
+ * dispatcherClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
130
+ * listenerClient: new Redis("YOUR_REDIS_CONNECTION_STRING"),
101
131
  * }),
102
- * defaultAdapter: "memory"
103
- * }
132
+ * },
133
+ * defaultAdapter: "memory"
104
134
  * });
105
135
  *
106
136
  * class AddEvent extends BaseEvent<{ a: number, b: number }> {}
107
- * serde.registerEvent(AddEvent);
108
137
  *
109
- * // Will use the default adapter which is MemoryEventBusAdapter
110
- * await cacheFactory.use().dispatch(new AddEvent({ a: 1, b: 2 }));
138
+ * // Will dispatch AddEvent using the default adapter which is MemoryEventBusAdapter
139
+ * await eventBusFactory
140
+ * .use()
141
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
142
+ *
143
+ * // Will dispatch AddEvent using the redis adapter which is RedisPubSubEventBusAdapter
144
+ * await eventBusFactory
145
+ * .use("redis")
146
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
147
+ *
148
+ * // You can change the default settings of the returned EventBus instance.
149
+ * await eventBusFactory
150
+ * .setRetryAttempts(4)
151
+ * .use("memoryFactory")
152
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
153
+ *
154
+ * // You can reuse the settings
155
+ * const retryableEventBusFactory = eventBusFactory
156
+ * .setRetryAttempts(4);
157
+ *
158
+ * await retryableEventBusFactory
159
+ * .use()
160
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
161
+ *
162
+ * // You can extend the settings
163
+ * const extendedEventBusFactory = retryableEventBusFactory
164
+ * .setRetryTimeout(TimeSpan.fromSeconds(1));
111
165
  *
112
- * // Will use the redis dapter which is RedisPubSubEventBusAdapter
113
- * await cacheFactory.use("redis").dispatch(new AddEvent({ a: 1, b: 2 }));
166
+ * await extendedEventBusFactory
167
+ * .use()
168
+ * .dispatch(new AddEvent({ a: 1, b: 2 }));
114
169
  * ```
115
170
  */
116
- use(adapterName = this.defaultAdapter) {
171
+ use(adapterName = this.settings.defaultAdapter) {
117
172
  if (adapterName === undefined) {
118
173
  throw new DefaultAdapterNotDefinedError(EventBusFactory.name);
119
174
  }
120
- const eventBus = this.eventBusRecord[adapterName];
121
- if (eventBus === undefined) {
175
+ const adapter = this.settings.adapters[adapterName];
176
+ if (adapter === undefined) {
122
177
  throw new UnregisteredAdapterError(adapterName);
123
178
  }
124
- return eventBus;
179
+ return new EventBus({
180
+ adapter,
181
+ ...this.settings,
182
+ });
125
183
  }
126
184
  }
127
185
  //# sourceMappingURL=event-bus-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAKH,6BAA6B,GAChC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,+DAA+D,CAAC;AAEzF,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAwExC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAGP,cAAc,GAAG,EAA+B,CAAC;IACjD,KAAK,CAA4B;IACjC,cAAc,CAAa;IAC3B,aAAa,CAAiB;IAC9B,aAAa,CAAwB;IACrC,WAAW,CAAsB;IACjC,OAAO,CAAmB;IAC1B,oBAAoB,CAAW;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,YAAY,QAA4C;QACpD,MAAM,EACF,QAAQ,EACR,oBAAoB,GAAG,IAAI,EAC3B,KAAK,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,GACV,GAAG,QAAQ,CAAC;QACb,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAEO,IAAI,CACR,QAAqC;QAErC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,cAAc,GAA8B,EAAE,CAAC;QACrD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YACzB,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;YACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBACxB,SAAS;YACb,CAAC;YACD,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,QAAQ,CAAC;gBAC/B,OAAO;gBACP,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAC;QACP,CAAC;QACD,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,cAAc;QAExD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
1
+ {"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAGX,MAAM,6DAA6D,CAAC;AAErE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA6CH;IA1CrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,YACqB,QAA4C;QAA5C,aAAQ,GAAR,QAAQ,CAAoC;IAC9D,CAAC;IAEJ,cAAc,CAAC,WAAwB;QACnC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW;SACd,CAAC,CAAC;IACP,CAAC;IAED,gBAAgB,CAAC,QAAgB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,aAAa,EAAE,QAAQ;SAC1B,CAAC,CAAC;IACP,CAAC;IAED,gBAAgB,CAAC,MAAqB;QAClC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,aAAa,EAAE,MAAM;SACxB,CAAC,CAAC;IACP,CAAC;IAED,cAAc,CAAC,MAAmB;QAC9B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW,EAAE,MAAM;SACtB,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,OAAiB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,YAAY,EAAE,OAAO;SACxB,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,OAAiB;QAC7B,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,YAAY,EAAE,OAAO;SACxB,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4EG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAEjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC;YAChB,OAAO;YACP,GAAG,IAAI,CAAC,QAAQ;SACnB,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -7,7 +7,7 @@ import { type Promisable } from "../../../utilities/_module-exports.js";
7
7
  import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js";
8
8
  /**
9
9
  *
10
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/test-utilities"```
10
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
11
11
  * @group Test utilities
12
12
  */
13
13
  export type EventBusAdapterTestSuiteSettings = {
@@ -21,53 +21,7 @@ export type EventBusAdapterTestSuiteSettings = {
21
21
  /**
22
22
  * The <i>eventBusAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBusAdapter}</i> with vitest.
23
23
  *
24
- * IMPORT_PATH: ```"@daiso-tech/core/event-bus/implementations/test-utilities"```
24
+ * IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
25
25
  * @group Test utilities
26
- * @example
27
- * ```ts
28
- * import { describe, test, beforeEach, expect, afterEach } from "vitest";
29
- * import type { StartedRedisContainer } from "@testcontainers/redis";
30
- * import { RedisContainer } from "@testcontainers/redis";
31
- * import Redis from "ioredis";
32
- * import { RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
33
- * import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
34
- * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
35
- * import { eventBusAdapterTestSuite } from "@daiso-tech/core/event-bus/implementations/test-utilities";
36
- *
37
- * const TIMEOUT = TimeSpan.fromMinutes(2);
38
- * describe("class: RedisPubSubEventBusAdapter", () => {
39
- * let dispatcherClient: Redis;
40
- * let listenerClient: Redis;
41
- * let startedContainer: StartedRedisContainer;
42
- * const serde = new Serde(new SuperJsonSerdeAdapter());
43
- *
44
- * beforeEach(async () => {
45
- * startedContainer = await new RedisContainer().start();
46
- * dispatcherClient = new Redis(startedContainer.getConnectionUrl());
47
- * listenerClient = new Redis(startedContainer.getConnectionUrl());
48
- * }, TIMEOUT.toMilliseconds());
49
- *
50
- * afterEach(async () => {
51
- * await dispatcherClient.quit();
52
- * await listenerClient.quit();
53
- * await startedContainer.stop();
54
- * }, TIMEOUT.toMilliseconds());
55
- *
56
- * eventBusAdapterTestSuite({
57
- * createAdapter: () =>
58
- * new RedisPubSubEventBusAdapter({
59
- * dispatcherClient,
60
- * listenerClient,
61
- * serde,
62
- * rootGroup: "@global"
63
- * }),
64
- * serde,
65
- * test,
66
- * beforeEach,
67
- * expect,
68
- * describe,
69
- * });
70
- * });
71
- * ```
72
26
  */
73
27
  export declare function eventBusAdapterTestSuite(settings: EventBusAdapterTestSuiteSettings): void;