@daiso-tech/core 0.40.0 → 0.41.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 (671) hide show
  1. package/dist/backoff-policies/_module-exports.d.ts +5 -0
  2. package/dist/backoff-policies/_module-exports.js +6 -0
  3. package/dist/backoff-policies/_module-exports.js.map +1 -0
  4. package/dist/{async/backof-policies → backoff-policies}/_shared.d.ts +6 -7
  5. package/dist/{async/backof-policies → backoff-policies}/_shared.js +1 -1
  6. package/dist/backoff-policies/_shared.js.map +1 -0
  7. package/dist/backoff-policies/constant-backoff-policy/_module.d.ts +1 -0
  8. package/dist/backoff-policies/constant-backoff-policy/_module.js +2 -0
  9. package/dist/backoff-policies/constant-backoff-policy/_module.js.map +1 -0
  10. package/dist/{async/backof-policies → backoff-policies}/constant-backoff-policy/constant-backoff-policy.d.ts +6 -8
  11. package/dist/{async/backof-policies → backoff-policies}/constant-backoff-policy/constant-backoff-policy.js +8 -10
  12. package/dist/backoff-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
  13. package/dist/backoff-policies/exponential-backoff-policy/_module.d.ts +1 -0
  14. package/dist/backoff-policies/exponential-backoff-policy/_module.js +2 -0
  15. package/dist/backoff-policies/exponential-backoff-policy/_module.js.map +1 -0
  16. package/dist/{async/backof-policies → backoff-policies}/exponential-backoff-policy/exponential-backoff-policy.d.ts +7 -9
  17. package/dist/backoff-policies/exponential-backoff-policy/exponential-backoff-policy.js +30 -0
  18. package/dist/backoff-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
  19. package/dist/backoff-policies/linear-backoff-policy/_module.d.ts +1 -0
  20. package/dist/backoff-policies/linear-backoff-policy/_module.js +2 -0
  21. package/dist/backoff-policies/linear-backoff-policy/_module.js.map +1 -0
  22. package/dist/{async/backof-policies → backoff-policies}/linear-backoff-policy/linear-backoff-policy.d.ts +7 -9
  23. package/dist/backoff-policies/linear-backoff-policy/linear-backoff-policy.js +30 -0
  24. package/dist/backoff-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
  25. package/dist/backoff-policies/polynomial-backoff-policy/_module.d.ts +1 -0
  26. package/dist/backoff-policies/polynomial-backoff-policy/_module.js +2 -0
  27. package/dist/backoff-policies/polynomial-backoff-policy/_module.js.map +1 -0
  28. package/dist/{async/backof-policies → backoff-policies}/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +7 -9
  29. package/dist/backoff-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +30 -0
  30. package/dist/backoff-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
  31. package/dist/cache/contracts/cache-adapter.contract.d.ts +3 -3
  32. package/dist/cache/contracts/cache.contract.d.ts +22 -22
  33. package/dist/cache/contracts/cache.errors.d.ts +7 -14
  34. package/dist/cache/contracts/cache.errors.js +12 -24
  35. package/dist/cache/contracts/cache.errors.js.map +1 -1
  36. package/dist/cache/contracts/cache.events.d.ts +1 -1
  37. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +1 -1
  38. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +4 -4
  39. package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -1
  40. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +1 -1
  41. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +2 -2
  42. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  43. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +3 -2
  44. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +3 -3
  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 +1 -1
  47. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +1 -1
  48. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +2 -2
  49. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  50. package/dist/cache/implementations/derivables/cache/cache.d.ts +38 -43
  51. package/dist/cache/implementations/derivables/cache/cache.js +106 -101
  52. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  53. package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +1 -1
  54. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +3 -3
  55. package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -1
  56. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +6 -8
  57. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +5 -15
  58. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  59. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +1 -1
  60. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +48 -48
  61. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
  62. package/dist/cache/implementations/test-utilities/cache.test-suite.js +107 -107
  63. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  64. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +2 -1
  65. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -1
  66. package/dist/collection/contracts/async-collection.contract.d.ts +43 -43
  67. package/dist/collection/contracts/collection.contract.d.ts +15 -1
  68. package/dist/collection/contracts/collection.contract.js +1 -3
  69. package/dist/collection/contracts/collection.contract.js.map +1 -1
  70. package/dist/collection/contracts/collection.errors.d.ts +4 -13
  71. package/dist/collection/contracts/collection.errors.js +4 -16
  72. package/dist/collection/contracts/collection.errors.js.map +1 -1
  73. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.d.ts +6 -0
  74. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js +3 -0
  75. package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js.map +1 -1
  76. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +40 -51
  77. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +31 -37
  78. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  79. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.d.ts +3 -0
  80. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js +6 -0
  81. package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js.map +1 -1
  82. package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +3 -3
  83. package/dist/collection/implementations/iterable-collection/iterable-collection.js +5 -2
  84. package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  85. package/dist/collection/implementations/list-collection/list-collection.d.ts +3 -3
  86. package/dist/collection/implementations/list-collection/list-collection.js +5 -2
  87. package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
  88. package/dist/event-bus/contracts/event-bus.contract.d.ts +10 -10
  89. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +3 -6
  90. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +7 -9
  91. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
  92. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +17 -24
  93. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +32 -32
  94. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  95. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +1 -3
  96. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +4 -8
  97. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  98. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +34 -32
  99. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  100. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +195 -190
  101. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  102. package/dist/hooks/_module-exports.d.ts +3 -0
  103. package/dist/hooks/_module-exports.js +4 -0
  104. package/dist/hooks/_module-exports.js.map +1 -0
  105. package/dist/{utilities/classes/hooks → hooks}/async-hooks.d.ts +15 -26
  106. package/dist/{utilities/classes/hooks → hooks}/async-hooks.js +4 -6
  107. package/dist/hooks/async-hooks.js.map +1 -0
  108. package/dist/{utilities/classes/hooks → hooks}/hooks.d.ts +11 -18
  109. package/dist/{utilities/classes/hooks → hooks}/hooks.js +4 -5
  110. package/dist/hooks/hooks.js.map +1 -0
  111. package/dist/{utilities/classes/hooks → hooks}/types.d.ts +2 -3
  112. package/dist/hooks/types.js +5 -0
  113. package/dist/hooks/types.js.map +1 -0
  114. package/dist/lock/contracts/_module-exports.d.ts +4 -2
  115. package/dist/lock/contracts/_module-exports.js +4 -2
  116. package/dist/lock/contracts/_module-exports.js.map +1 -1
  117. package/dist/lock/contracts/database-lock-adapter.contract.d.ts +24 -17
  118. package/dist/lock/contracts/lock-adapter.contract.d.ts +15 -24
  119. package/dist/lock/contracts/lock-adapter.contract.js +1 -10
  120. package/dist/lock/contracts/lock-adapter.contract.js.map +1 -1
  121. package/dist/lock/contracts/lock-provider.contract.d.ts +5 -5
  122. package/dist/lock/contracts/lock-state.contract.d.ts +52 -0
  123. package/dist/lock/contracts/lock-state.contract.js +14 -0
  124. package/dist/lock/contracts/lock-state.contract.js.map +1 -0
  125. package/dist/lock/contracts/lock.contract.d.ts +64 -55
  126. package/dist/lock/contracts/lock.errors.d.ts +13 -20
  127. package/dist/lock/contracts/lock.errors.js +19 -26
  128. package/dist/lock/contracts/lock.errors.js.map +1 -1
  129. package/dist/lock/contracts/lock.events.d.ts +21 -49
  130. package/dist/lock/contracts/lock.events.js +2 -3
  131. package/dist/lock/contracts/lock.events.js.map +1 -1
  132. package/dist/lock/contracts/types.d.ts +11 -0
  133. package/dist/lock/contracts/types.js +5 -0
  134. package/dist/lock/contracts/types.js.map +1 -0
  135. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +21 -19
  136. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +92 -61
  137. package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
  138. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +8 -5
  139. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +33 -13
  140. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
  141. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +7 -8
  142. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +33 -20
  143. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
  144. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +6 -5
  145. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +7 -5
  146. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -1
  147. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +26 -8
  148. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +61 -28
  149. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
  150. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +6 -5
  151. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +33 -33
  152. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
  153. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.d.ts +2 -2
  154. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +4 -6
  155. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
  156. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +29 -39
  157. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +31 -35
  158. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  159. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +5 -8
  160. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +27 -23
  161. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  162. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +38 -34
  163. package/dist/lock/implementations/derivables/lock-provider/lock.js +182 -257
  164. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  165. package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.d.ts +9 -0
  166. package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.js +12 -0
  167. package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.js.map +1 -0
  168. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +12 -13
  169. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +7 -16
  170. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  171. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +310 -207
  172. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
  173. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +1 -1
  174. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +376 -292
  175. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
  176. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -5
  177. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +3285 -2976
  178. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  179. package/dist/namespace/_module-exports.d.ts +1 -0
  180. package/dist/namespace/_module-exports.js +2 -0
  181. package/dist/namespace/_module-exports.js.map +1 -0
  182. package/dist/namespace/namespace.d.ts +87 -0
  183. package/dist/namespace/namespace.js +117 -0
  184. package/dist/namespace/namespace.js.map +1 -0
  185. package/dist/resilience/_module-exports.d.ts +2 -0
  186. package/dist/resilience/_module-exports.js +3 -0
  187. package/dist/resilience/_module-exports.js.map +1 -0
  188. package/dist/resilience/middlewares/_module.d.ts +5 -0
  189. package/dist/resilience/middlewares/_module.js +6 -0
  190. package/dist/resilience/middlewares/_module.js.map +1 -0
  191. package/dist/resilience/middlewares/dynamic/_module.d.ts +1 -0
  192. package/dist/resilience/middlewares/dynamic/_module.js +2 -0
  193. package/dist/resilience/middlewares/dynamic/_module.js.map +1 -0
  194. package/dist/{async → resilience}/middlewares/dynamic/dynamic.middleware.d.ts +6 -6
  195. package/dist/{async → resilience}/middlewares/dynamic/dynamic.middleware.js +5 -5
  196. package/dist/resilience/middlewares/dynamic/dynamic.middleware.js.map +1 -0
  197. package/dist/resilience/middlewares/fallback/_module.d.ts +2 -0
  198. package/dist/resilience/middlewares/fallback/_module.js +3 -0
  199. package/dist/resilience/middlewares/fallback/_module.js.map +1 -0
  200. package/dist/{async → resilience}/middlewares/fallback/fallback.middleware.d.ts +9 -9
  201. package/dist/{async → resilience}/middlewares/fallback/fallback.middleware.js +7 -6
  202. package/dist/resilience/middlewares/fallback/fallback.middleware.js.map +1 -0
  203. package/dist/{async → resilience}/middlewares/fallback/fallback.types.d.ts +7 -6
  204. package/dist/{async → resilience}/middlewares/fallback/fallback.types.js +1 -1
  205. package/dist/resilience/middlewares/fallback/fallback.types.js.map +1 -0
  206. package/dist/resilience/middlewares/observe/_module.d.ts +2 -0
  207. package/dist/resilience/middlewares/observe/_module.js +3 -0
  208. package/dist/resilience/middlewares/observe/_module.js.map +1 -0
  209. package/dist/{async → resilience}/middlewares/observe/observe.middleware.d.ts +13 -11
  210. package/dist/{async → resilience}/middlewares/observe/observe.middleware.js +14 -10
  211. package/dist/resilience/middlewares/observe/observe.middleware.js.map +1 -0
  212. package/dist/{async → resilience}/middlewares/observe/observe.types.d.ts +13 -12
  213. package/dist/resilience/middlewares/observe/observe.types.js +5 -0
  214. package/dist/resilience/middlewares/observe/observe.types.js.map +1 -0
  215. package/dist/resilience/middlewares/retry/_module.d.ts +2 -0
  216. package/dist/resilience/middlewares/retry/_module.js +3 -0
  217. package/dist/resilience/middlewares/retry/_module.js.map +1 -0
  218. package/dist/{async → resilience}/middlewares/retry/retry.middleware.d.ts +12 -9
  219. package/dist/{async → resilience}/middlewares/retry/retry.middleware.js +19 -15
  220. package/dist/resilience/middlewares/retry/retry.middleware.js.map +1 -0
  221. package/dist/{async → resilience}/middlewares/retry/retry.types.d.ts +14 -12
  222. package/dist/resilience/middlewares/retry/retry.types.js +7 -0
  223. package/dist/resilience/middlewares/retry/retry.types.js.map +1 -0
  224. package/dist/resilience/middlewares/timeout/_module.d.ts +2 -0
  225. package/dist/resilience/middlewares/timeout/_module.js +3 -0
  226. package/dist/resilience/middlewares/timeout/_module.js.map +1 -0
  227. package/dist/{async → resilience}/middlewares/timeout/timeout.middleware.d.ts +9 -7
  228. package/dist/{async → resilience}/middlewares/timeout/timeout.middleware.js +12 -11
  229. package/dist/resilience/middlewares/timeout/timeout.middleware.js.map +1 -0
  230. package/dist/{async → resilience}/middlewares/timeout/timeout.type.d.ts +10 -9
  231. package/dist/resilience/middlewares/timeout/timeout.type.js +5 -0
  232. package/dist/resilience/middlewares/timeout/timeout.type.js.map +1 -0
  233. package/dist/resilience/resilience.errors.d.ts +40 -0
  234. package/dist/resilience/resilience.errors.js +48 -0
  235. package/dist/resilience/resilience.errors.js.map +1 -0
  236. package/dist/resilience/utilities/_module.d.ts +2 -0
  237. package/dist/resilience/utilities/_module.js +3 -0
  238. package/dist/resilience/utilities/_module.js.map +1 -0
  239. package/dist/resilience/utilities/abort-and-fail/_module.d.ts +1 -0
  240. package/dist/resilience/utilities/abort-and-fail/_module.js +2 -0
  241. package/dist/resilience/utilities/abort-and-fail/_module.js.map +1 -0
  242. package/dist/resilience/utilities/abort-and-fail/abort-and-fail.d.ts +7 -0
  243. package/dist/resilience/utilities/abort-and-fail/abort-and-fail.js +51 -0
  244. package/dist/resilience/utilities/abort-and-fail/abort-and-fail.js.map +1 -0
  245. package/dist/resilience/utilities/timeout-and-fail/_module.d.ts +1 -0
  246. package/dist/resilience/utilities/timeout-and-fail/_module.js +2 -0
  247. package/dist/resilience/utilities/timeout-and-fail/_module.js.map +1 -0
  248. package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
  249. package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.js +23 -0
  250. package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
  251. package/dist/semaphore/contracts/_module-exports.d.ts +9 -0
  252. package/dist/semaphore/contracts/_module-exports.js +10 -0
  253. package/dist/semaphore/contracts/_module-exports.js.map +1 -0
  254. package/dist/semaphore/contracts/database-semaphore-adapter.contract.d.ts +90 -0
  255. package/dist/semaphore/contracts/database-semaphore-adapter.contract.js +5 -0
  256. package/dist/semaphore/contracts/database-semaphore-adapter.contract.js.map +1 -0
  257. package/dist/semaphore/contracts/semaphore-adapter.contract.d.ts +61 -0
  258. package/dist/semaphore/contracts/semaphore-adapter.contract.js +5 -0
  259. package/dist/semaphore/contracts/semaphore-adapter.contract.js.map +1 -0
  260. package/dist/semaphore/contracts/semaphore-provider-factory.contract.d.ts +19 -0
  261. package/dist/semaphore/contracts/semaphore-provider-factory.contract.js +9 -0
  262. package/dist/semaphore/contracts/semaphore-provider-factory.contract.js.map +1 -0
  263. package/dist/semaphore/contracts/semaphore-provider.contract.d.ts +50 -0
  264. package/dist/semaphore/contracts/semaphore-provider.contract.js +5 -0
  265. package/dist/semaphore/contracts/semaphore-provider.contract.js.map +1 -0
  266. package/dist/semaphore/contracts/semaphore-state.contract.d.ts +70 -0
  267. package/dist/semaphore/contracts/semaphore-state.contract.js +15 -0
  268. package/dist/semaphore/contracts/semaphore-state.contract.js.map +1 -0
  269. package/dist/semaphore/contracts/semaphore.contract.d.ts +127 -0
  270. package/dist/semaphore/contracts/semaphore.contract.js +5 -0
  271. package/dist/semaphore/contracts/semaphore.contract.js.map +1 -0
  272. package/dist/semaphore/contracts/semaphore.errors.d.ts +52 -0
  273. package/dist/semaphore/contracts/semaphore.errors.js +63 -0
  274. package/dist/semaphore/contracts/semaphore.errors.js.map +1 -0
  275. package/dist/semaphore/contracts/semaphore.events.d.ts +101 -0
  276. package/dist/semaphore/contracts/semaphore.events.js +19 -0
  277. package/dist/semaphore/contracts/semaphore.events.js.map +1 -0
  278. package/dist/semaphore/contracts/types.d.ts +11 -0
  279. package/dist/semaphore/contracts/types.js +5 -0
  280. package/dist/semaphore/contracts/types.js.map +1 -0
  281. package/dist/semaphore/implementations/adapters/_module-exports.d.ts +5 -0
  282. package/dist/semaphore/implementations/adapters/_module-exports.js +6 -0
  283. package/dist/semaphore/implementations/adapters/_module-exports.js.map +1 -0
  284. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.d.ts +1 -0
  285. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.js +2 -0
  286. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.js.map +1 -0
  287. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.d.ts +97 -0
  288. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.js +313 -0
  289. package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.js.map +1 -0
  290. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.d.ts +1 -0
  291. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.js +2 -0
  292. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.js.map +1 -0
  293. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.d.ts +49 -0
  294. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.js +141 -0
  295. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.js.map +1 -0
  296. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.d.ts +1 -0
  297. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.js +2 -0
  298. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.js.map +1 -0
  299. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.d.ts +80 -0
  300. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.js +390 -0
  301. package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.js.map +1 -0
  302. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.d.ts +1 -0
  303. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.js +2 -0
  304. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.js.map +1 -0
  305. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.d.ts +18 -0
  306. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.js +30 -0
  307. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.js.map +1 -0
  308. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.d.ts +1 -0
  309. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.js +2 -0
  310. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.js.map +1 -0
  311. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.d.ts +48 -0
  312. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.js +338 -0
  313. package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.js.map +1 -0
  314. package/dist/semaphore/implementations/derivables/_module-exports.d.ts +2 -0
  315. package/dist/semaphore/implementations/derivables/_module-exports.js +3 -0
  316. package/dist/semaphore/implementations/derivables/_module-exports.js.map +1 -0
  317. package/dist/semaphore/implementations/derivables/semaphore-provider/_module.d.ts +1 -0
  318. package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js +2 -0
  319. package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js.map +1 -0
  320. package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.d.ts +17 -0
  321. package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.js +74 -0
  322. package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.js.map +1 -0
  323. package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.d.ts +8 -0
  324. package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.js +15 -0
  325. package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.js.map +1 -0
  326. package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.d.ts +8 -0
  327. package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.js +15 -0
  328. package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.js.map +1 -0
  329. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.d.ts +149 -0
  330. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.js +135 -0
  331. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.js.map +1 -0
  332. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.d.ts +41 -0
  333. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.js +77 -0
  334. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.js.map +1 -0
  335. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.d.ts +83 -0
  336. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.js +336 -0
  337. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.js.map +1 -0
  338. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.d.ts +1 -0
  339. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.js +2 -0
  340. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.js.map +1 -0
  341. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.d.ts +40 -0
  342. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.js +67 -0
  343. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.js.map +1 -0
  344. package/dist/semaphore/implementations/test-utilities/_module-exports.d.ts +3 -0
  345. package/dist/semaphore/implementations/test-utilities/_module-exports.js +4 -0
  346. package/dist/semaphore/implementations/test-utilities/_module-exports.js.map +1 -0
  347. package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.d.ts +59 -0
  348. package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.js +536 -0
  349. package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.js.map +1 -0
  350. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.d.ts +59 -0
  351. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js +961 -0
  352. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js.map +1 -0
  353. package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.d.ts +67 -0
  354. package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.js +4981 -0
  355. package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.js.map +1 -0
  356. package/dist/serde/contracts/_module-exports.d.ts +0 -1
  357. package/dist/serde/contracts/_module-exports.js +0 -1
  358. package/dist/serde/contracts/_module-exports.js.map +1 -1
  359. package/dist/serde/contracts/flexible-serde.contract.d.ts +21 -5
  360. package/dist/serde/contracts/serde.errors.d.ts +14 -11
  361. package/dist/serde/contracts/serde.errors.js +15 -14
  362. package/dist/serde/contracts/serde.errors.js.map +1 -1
  363. package/dist/serde/implementations/adapters/_module-exports.d.ts +0 -3
  364. package/dist/serde/implementations/adapters/_module-exports.js +0 -3
  365. package/dist/serde/implementations/adapters/_module-exports.js.map +1 -1
  366. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +6 -0
  367. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  368. package/dist/serde/implementations/derivables/serde-transformers.d.ts +38 -30
  369. package/dist/serde/implementations/derivables/serde-transformers.js +62 -20
  370. package/dist/serde/implementations/derivables/serde-transformers.js.map +1 -1
  371. package/dist/serde/implementations/derivables/serde.d.ts +12 -3
  372. package/dist/serde/implementations/derivables/serde.js +5 -2
  373. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  374. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +85 -1
  375. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js.map +1 -1
  376. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +85 -1
  377. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js.map +1 -1
  378. package/dist/shared-lock/contracts/_module-exports.d.ts +10 -0
  379. package/dist/shared-lock/contracts/_module-exports.js +11 -0
  380. package/dist/shared-lock/contracts/_module-exports.js.map +1 -0
  381. package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.d.ts +145 -0
  382. package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.js +5 -0
  383. package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.js.map +1 -0
  384. package/dist/shared-lock/contracts/shared-lock-adapter.contract.d.ts +96 -0
  385. package/dist/shared-lock/contracts/shared-lock-adapter.contract.js +5 -0
  386. package/dist/shared-lock/contracts/shared-lock-adapter.contract.js.map +1 -0
  387. package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.d.ts +19 -0
  388. package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.js +9 -0
  389. package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.js.map +1 -0
  390. package/dist/shared-lock/contracts/shared-lock-provider.contract.d.ts +53 -0
  391. package/dist/shared-lock/contracts/shared-lock-provider.contract.js +5 -0
  392. package/dist/shared-lock/contracts/shared-lock-provider.contract.js.map +1 -0
  393. package/dist/shared-lock/contracts/shared-lock-state.contract.d.ts +133 -0
  394. package/dist/shared-lock/contracts/shared-lock-state.contract.js +33 -0
  395. package/dist/shared-lock/contracts/shared-lock-state.contract.js.map +1 -0
  396. package/dist/shared-lock/contracts/shared-lock.contract.d.ts +222 -0
  397. package/dist/shared-lock/contracts/shared-lock.contract.js +13 -0
  398. package/dist/shared-lock/contracts/shared-lock.contract.js.map +1 -0
  399. package/dist/shared-lock/contracts/shared-lock.errors.d.ts +124 -0
  400. package/dist/shared-lock/contracts/shared-lock.errors.js +136 -0
  401. package/dist/shared-lock/contracts/shared-lock.errors.js.map +1 -0
  402. package/dist/shared-lock/contracts/shared-lock.events.d.ts +205 -0
  403. package/dist/shared-lock/contracts/shared-lock.events.js +43 -0
  404. package/dist/shared-lock/contracts/shared-lock.events.js.map +1 -0
  405. package/dist/shared-lock/contracts/types.d.ts +10 -0
  406. package/dist/shared-lock/contracts/types.js +5 -0
  407. package/dist/shared-lock/contracts/types.js.map +1 -0
  408. package/dist/shared-lock/implementations/adapters/_module-exports.d.ts +5 -0
  409. package/dist/shared-lock/implementations/adapters/_module-exports.js +6 -0
  410. package/dist/shared-lock/implementations/adapters/_module-exports.js.map +1 -0
  411. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.d.ts +1 -0
  412. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.js +2 -0
  413. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.js.map +1 -0
  414. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.d.ts +114 -0
  415. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.js +496 -0
  416. package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.js.map +1 -0
  417. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.d.ts +1 -0
  418. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.js +2 -0
  419. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.js.map +1 -0
  420. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.d.ts +79 -0
  421. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js +347 -0
  422. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js.map +1 -0
  423. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.d.ts +1 -0
  424. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.js +2 -0
  425. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.js.map +1 -0
  426. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.d.ts +112 -0
  427. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.js +805 -0
  428. package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.js.map +1 -0
  429. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.d.ts +1 -0
  430. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.js +2 -0
  431. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.js.map +1 -0
  432. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.d.ts +23 -0
  433. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.js +42 -0
  434. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.js.map +1 -0
  435. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.d.ts +1 -0
  436. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.js +2 -0
  437. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.js.map +1 -0
  438. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.d.ts +79 -0
  439. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.js +630 -0
  440. package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.js.map +1 -0
  441. package/dist/shared-lock/implementations/derivables/_module-exports.d.ts +2 -0
  442. package/dist/shared-lock/implementations/derivables/_module-exports.js +3 -0
  443. package/dist/shared-lock/implementations/derivables/_module-exports.js.map +1 -0
  444. package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.d.ts +1 -0
  445. package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.js +2 -0
  446. package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.js.map +1 -0
  447. package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.d.ts +27 -0
  448. package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.js +208 -0
  449. package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.js.map +1 -0
  450. package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.d.ts +8 -0
  451. package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.js +12 -0
  452. package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.js.map +1 -0
  453. package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.d.ts +8 -0
  454. package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.js +15 -0
  455. package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.js.map +1 -0
  456. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.d.ts +190 -0
  457. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.js +177 -0
  458. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.js.map +1 -0
  459. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.d.ts +41 -0
  460. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.js +77 -0
  461. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.js.map +1 -0
  462. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.d.ts +95 -0
  463. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.js +542 -0
  464. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.js.map +1 -0
  465. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.d.ts +1 -0
  466. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.js +2 -0
  467. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.js.map +1 -0
  468. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.d.ts +97 -0
  469. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.js +128 -0
  470. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.js.map +1 -0
  471. package/dist/shared-lock/implementations/test-utilities/_module-exports.d.ts +3 -0
  472. package/dist/shared-lock/implementations/test-utilities/_module-exports.js +4 -0
  473. package/dist/shared-lock/implementations/test-utilities/_module-exports.js.map +1 -0
  474. package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.d.ts +59 -0
  475. package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.js +944 -0
  476. package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.js.map +1 -0
  477. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.d.ts +59 -0
  478. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js +1921 -0
  479. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js.map +1 -0
  480. package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.d.ts +67 -0
  481. package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.js +9833 -0
  482. package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.js.map +1 -0
  483. package/dist/task/_module-exports.d.ts +1 -0
  484. package/dist/task/_module-exports.js +2 -0
  485. package/dist/task/_module-exports.js.map +1 -0
  486. package/dist/{async/utilities/abort-and-fail → task}/abort-and-fail.d.ts +1 -1
  487. package/dist/{async/utilities/abort-and-fail → task}/abort-and-fail.js +1 -1
  488. package/dist/task/abort-and-fail.js.map +1 -0
  489. package/dist/task/task.d.ts +194 -0
  490. package/dist/task/task.js +212 -0
  491. package/dist/task/task.js.map +1 -0
  492. package/dist/time-span/contracts/_module-exports.d.ts +1 -0
  493. package/dist/time-span/contracts/_module-exports.js +2 -0
  494. package/dist/time-span/contracts/_module-exports.js.map +1 -0
  495. package/dist/time-span/contracts/time-span.contract.d.ts +19 -0
  496. package/dist/time-span/contracts/time-span.contract.js +10 -0
  497. package/dist/time-span/contracts/time-span.contract.js.map +1 -0
  498. package/dist/time-span/implementations/_module-exports.d.ts +1 -0
  499. package/dist/time-span/implementations/_module-exports.js +2 -0
  500. package/dist/time-span/implementations/_module-exports.js.map +1 -0
  501. package/dist/{utilities/classes/time-span → time-span/implementations}/time-span.d.ts +49 -11
  502. package/dist/{utilities/classes/time-span → time-span/implementations}/time-span.js +33 -11
  503. package/dist/time-span/implementations/time-span.js.map +1 -0
  504. package/dist/utilities/classes/_module.d.ts +0 -3
  505. package/dist/utilities/classes/_module.js +0 -3
  506. package/dist/utilities/classes/_module.js.map +1 -1
  507. package/dist/utilities/contracts/_module.d.ts +1 -1
  508. package/dist/utilities/contracts/_module.js +1 -1
  509. package/dist/utilities/contracts/_module.js.map +1 -1
  510. package/dist/utilities/contracts/comparable.contract.d.ts +49 -0
  511. package/dist/utilities/contracts/comparable.contract.js +5 -0
  512. package/dist/utilities/contracts/comparable.contract.js.map +1 -0
  513. package/dist/utilities/functions/is-standard-schema.d.ts +6 -0
  514. package/dist/utilities/functions/is-standard-schema.js +6 -0
  515. package/dist/utilities/functions/is-standard-schema.js.map +1 -1
  516. package/dist/utilities/functions/lazy.d.ts +3 -3
  517. package/dist/utilities/functions/lazy.js +3 -3
  518. package/dist/utilities/functions/lazy.js.map +1 -1
  519. package/dist/utilities/functions/option.d.ts +3 -0
  520. package/dist/utilities/functions/option.js +3 -0
  521. package/dist/utilities/functions/option.js.map +1 -1
  522. package/dist/utilities/functions/validate.d.ts +5 -0
  523. package/dist/utilities/functions/validate.js +5 -0
  524. package/dist/utilities/functions/validate.js.map +1 -1
  525. package/dist/utilities/types/any-class.type.d.ts +6 -0
  526. package/dist/utilities/types/any-class.type.js +3 -0
  527. package/dist/utilities/types/any-class.type.js.map +1 -1
  528. package/package.json +67 -5
  529. package/dist/async/_module-exports.d.ts +0 -4
  530. package/dist/async/_module-exports.js +0 -5
  531. package/dist/async/_module-exports.js.map +0 -1
  532. package/dist/async/async.errors.d.ts +0 -47
  533. package/dist/async/async.errors.js +0 -61
  534. package/dist/async/async.errors.js.map +0 -1
  535. package/dist/async/backof-policies/_module.d.ts +0 -5
  536. package/dist/async/backof-policies/_module.js +0 -6
  537. package/dist/async/backof-policies/_module.js.map +0 -1
  538. package/dist/async/backof-policies/_shared.js.map +0 -1
  539. package/dist/async/backof-policies/constant-backoff-policy/_module.d.ts +0 -1
  540. package/dist/async/backof-policies/constant-backoff-policy/_module.js +0 -2
  541. package/dist/async/backof-policies/constant-backoff-policy/_module.js.map +0 -1
  542. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +0 -1
  543. package/dist/async/backof-policies/exponential-backoff-policy/_module.d.ts +0 -1
  544. package/dist/async/backof-policies/exponential-backoff-policy/_module.js +0 -2
  545. package/dist/async/backof-policies/exponential-backoff-policy/_module.js.map +0 -1
  546. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +0 -35
  547. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +0 -1
  548. package/dist/async/backof-policies/linear-backoff-policy/_module.d.ts +0 -1
  549. package/dist/async/backof-policies/linear-backoff-policy/_module.js +0 -2
  550. package/dist/async/backof-policies/linear-backoff-policy/_module.js.map +0 -1
  551. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +0 -35
  552. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +0 -1
  553. package/dist/async/backof-policies/polynomial-backoff-policy/_module.d.ts +0 -1
  554. package/dist/async/backof-policies/polynomial-backoff-policy/_module.js +0 -2
  555. package/dist/async/backof-policies/polynomial-backoff-policy/_module.js.map +0 -1
  556. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +0 -35
  557. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +0 -1
  558. package/dist/async/middlewares/_module.d.ts +0 -7
  559. package/dist/async/middlewares/_module.js +0 -8
  560. package/dist/async/middlewares/_module.js.map +0 -1
  561. package/dist/async/middlewares/bulkhead/_module.d.ts +0 -1
  562. package/dist/async/middlewares/bulkhead/_module.js +0 -2
  563. package/dist/async/middlewares/bulkhead/_module.js.map +0 -1
  564. package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +0 -80
  565. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +0 -46
  566. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +0 -1
  567. package/dist/async/middlewares/dynamic/_module.d.ts +0 -1
  568. package/dist/async/middlewares/dynamic/_module.js +0 -2
  569. package/dist/async/middlewares/dynamic/_module.js.map +0 -1
  570. package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +0 -1
  571. package/dist/async/middlewares/fallback/_module.d.ts +0 -2
  572. package/dist/async/middlewares/fallback/_module.js +0 -3
  573. package/dist/async/middlewares/fallback/_module.js.map +0 -1
  574. package/dist/async/middlewares/fallback/fallback.middleware.js.map +0 -1
  575. package/dist/async/middlewares/fallback/fallback.types.js.map +0 -1
  576. package/dist/async/middlewares/hedging/_module.d.ts +0 -2
  577. package/dist/async/middlewares/hedging/_module.js +0 -3
  578. package/dist/async/middlewares/hedging/_module.js.map +0 -1
  579. package/dist/async/middlewares/hedging/hedging.types.d.ts +0 -121
  580. package/dist/async/middlewares/hedging/hedging.types.js +0 -6
  581. package/dist/async/middlewares/hedging/hedging.types.js.map +0 -1
  582. package/dist/async/middlewares/hedging/sequential-hedging.middleware.d.ts +0 -51
  583. package/dist/async/middlewares/hedging/sequential-hedging.middleware.js +0 -133
  584. package/dist/async/middlewares/hedging/sequential-hedging.middleware.js.map +0 -1
  585. package/dist/async/middlewares/observe/_module.d.ts +0 -2
  586. package/dist/async/middlewares/observe/_module.js +0 -3
  587. package/dist/async/middlewares/observe/_module.js.map +0 -1
  588. package/dist/async/middlewares/observe/observe.middleware.js.map +0 -1
  589. package/dist/async/middlewares/observe/observe.types.js +0 -6
  590. package/dist/async/middlewares/observe/observe.types.js.map +0 -1
  591. package/dist/async/middlewares/retry/_module.d.ts +0 -2
  592. package/dist/async/middlewares/retry/_module.js +0 -3
  593. package/dist/async/middlewares/retry/_module.js.map +0 -1
  594. package/dist/async/middlewares/retry/retry.middleware.js.map +0 -1
  595. package/dist/async/middlewares/retry/retry.types.js +0 -7
  596. package/dist/async/middlewares/retry/retry.types.js.map +0 -1
  597. package/dist/async/middlewares/timeout/_module.d.ts +0 -2
  598. package/dist/async/middlewares/timeout/_module.js +0 -3
  599. package/dist/async/middlewares/timeout/_module.js.map +0 -1
  600. package/dist/async/middlewares/timeout/timeout.middleware.js.map +0 -1
  601. package/dist/async/middlewares/timeout/timeout.type.js +0 -6
  602. package/dist/async/middlewares/timeout/timeout.type.js.map +0 -1
  603. package/dist/async/utilities/_module.d.ts +0 -4
  604. package/dist/async/utilities/_module.js +0 -5
  605. package/dist/async/utilities/_module.js.map +0 -1
  606. package/dist/async/utilities/abort-and-fail/_module.d.ts +0 -1
  607. package/dist/async/utilities/abort-and-fail/_module.js +0 -2
  608. package/dist/async/utilities/abort-and-fail/_module.js.map +0 -1
  609. package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +0 -1
  610. package/dist/async/utilities/lazy-promise/_module.d.ts +0 -1
  611. package/dist/async/utilities/lazy-promise/_module.js +0 -2
  612. package/dist/async/utilities/lazy-promise/_module.js.map +0 -1
  613. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +0 -153
  614. package/dist/async/utilities/lazy-promise/lazy-promise.js +0 -176
  615. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +0 -1
  616. package/dist/async/utilities/promise-queue/_module.d.ts +0 -1
  617. package/dist/async/utilities/promise-queue/_module.js +0 -2
  618. package/dist/async/utilities/promise-queue/_module.js.map +0 -1
  619. package/dist/async/utilities/promise-queue/promise-queue.d.ts +0 -32
  620. package/dist/async/utilities/promise-queue/promise-queue.js +0 -118
  621. package/dist/async/utilities/promise-queue/promise-queue.js.map +0 -1
  622. package/dist/async/utilities/timeout-and-fail/_module.d.ts +0 -1
  623. package/dist/async/utilities/timeout-and-fail/_module.js +0 -2
  624. package/dist/async/utilities/timeout-and-fail/_module.js.map +0 -1
  625. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +0 -7
  626. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +0 -22
  627. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +0 -1
  628. package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +0 -40
  629. package/dist/lock/implementations/derivables/lock-provider/lock-state.js +0 -60
  630. package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +0 -1
  631. package/dist/serde/contracts/serializable.contract.d.ts +0 -12
  632. package/dist/serde/contracts/serializable.contract.js +0 -5
  633. package/dist/serde/contracts/serializable.contract.js.map +0 -1
  634. package/dist/serde/implementations/adapters/mongodb-serde/_module.d.ts +0 -1
  635. package/dist/serde/implementations/adapters/mongodb-serde/_module.js +0 -2
  636. package/dist/serde/implementations/adapters/mongodb-serde/_module.js.map +0 -1
  637. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.d.ts +0 -13
  638. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +0 -38
  639. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +0 -1
  640. package/dist/serde/implementations/adapters/redis-serde/_module.d.ts +0 -1
  641. package/dist/serde/implementations/adapters/redis-serde/_module.js +0 -2
  642. package/dist/serde/implementations/adapters/redis-serde/_module.js.map +0 -1
  643. package/dist/serde/implementations/adapters/redis-serde/redis-serde.d.ts +0 -13
  644. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +0 -39
  645. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +0 -1
  646. package/dist/serde/implementations/adapters/sql-serde/_module.d.ts +0 -1
  647. package/dist/serde/implementations/adapters/sql-serde/_module.js +0 -2
  648. package/dist/serde/implementations/adapters/sql-serde/_module.js.map +0 -1
  649. package/dist/serde/implementations/adapters/sql-serde/sql-serde.d.ts +0 -13
  650. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +0 -39
  651. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +0 -1
  652. package/dist/utilities/classes/hooks/_module.d.ts +0 -3
  653. package/dist/utilities/classes/hooks/_module.js +0 -4
  654. package/dist/utilities/classes/hooks/_module.js.map +0 -1
  655. package/dist/utilities/classes/hooks/async-hooks.js.map +0 -1
  656. package/dist/utilities/classes/hooks/hooks.js.map +0 -1
  657. package/dist/utilities/classes/hooks/types.js +0 -5
  658. package/dist/utilities/classes/hooks/types.js.map +0 -1
  659. package/dist/utilities/classes/namespace/_module.d.ts +0 -1
  660. package/dist/utilities/classes/namespace/_module.js +0 -2
  661. package/dist/utilities/classes/namespace/_module.js.map +0 -1
  662. package/dist/utilities/classes/namespace/namespace.d.ts +0 -85
  663. package/dist/utilities/classes/namespace/namespace.js +0 -125
  664. package/dist/utilities/classes/namespace/namespace.js.map +0 -1
  665. package/dist/utilities/classes/time-span/_module.d.ts +0 -1
  666. package/dist/utilities/classes/time-span/_module.js +0 -2
  667. package/dist/utilities/classes/time-span/_module.js.map +0 -1
  668. package/dist/utilities/classes/time-span/time-span.js.map +0 -1
  669. package/dist/utilities/contracts/serialized-error.contract.d.ts +0 -13
  670. package/dist/utilities/contracts/serialized-error.contract.js +0 -5
  671. package/dist/utilities/contracts/serialized-error.contract.js.map +0 -1
@@ -0,0 +1,944 @@
1
+ import { TimeSpan } from "../../../time-span/implementations/_module-exports.js";
2
+ /**
3
+ * The `databaseSharedLockAdapterTestSuite` function simplifies the process of testing your custom implementation of {@link IDatabaseSharedLockAdapter | `IDatabaseSharedLockAdapter`} with `vitest`.
4
+ *
5
+ * IMPORT_PATH: `"@daiso-tech/core/shared-lock/test-utilities"`
6
+ * @group Utilities
7
+ * @example
8
+ * ```ts
9
+ * import { afterEach, beforeEach, describe, expect, test } from "vitest";
10
+ * import { databaseSharedLockAdapterTestSuite } from "@daiso-tech/core/shared-lock/test-utilities";
11
+ * import { LibsqlSharedLockAdapter } from "@daiso-tech/core/shared-lock/adapters";
12
+ * import { type Client, createClient } from "@libsql/client";
13
+ *
14
+ * describe("class: LibsqlSharedLockAdapter", () => {
15
+ * let client: Client;
16
+ * beforeEach(() => {
17
+ * client = createClient({
18
+ * url: ":memory:",
19
+ * });
20
+ * });
21
+ * afterEach(() => {
22
+ * client.close();
23
+ * });
24
+ * databaseSharedLockAdapterTestSuite({
25
+ * createAdapter: async () => {
26
+ * const lockAdapter = new LibsqlSharedLockAdapter({
27
+ * database: client,
28
+ * tableName: "custom_table",
29
+ * shouldRemoveExpiredKeys: false,
30
+ * });
31
+ * await lockAdapter.init();
32
+ * return lockAdapter;
33
+ * },
34
+ * test,
35
+ * beforeEach,
36
+ * expect,
37
+ * describe,
38
+ * });
39
+ * });
40
+ * ```
41
+ */
42
+ export function databaseSharedLockAdapterTestSuite(settings) {
43
+ const { expect, test, createAdapter, describe, beforeEach } = settings;
44
+ describe("Reusable tests:", () => {
45
+ let adapter;
46
+ beforeEach(async () => {
47
+ adapter = await createAdapter();
48
+ });
49
+ describe("method: transaction writer.find", () => {
50
+ test("Should return null when key doesnt exists", async () => {
51
+ const key = "a";
52
+ const owner = "1";
53
+ const expiration = null;
54
+ await adapter.transaction(async (trx) => {
55
+ await trx.writer.upsert(key, owner, expiration);
56
+ });
57
+ const noneExistingKey = "b";
58
+ const result = await adapter.transaction(async (trx) => {
59
+ return await trx.writer.find(noneExistingKey);
60
+ });
61
+ expect(result).toBeNull();
62
+ });
63
+ test("Should return IWriterLockData when key exists", async () => {
64
+ const key = "a";
65
+ const owner = "1";
66
+ const expiration = TimeSpan.fromMinutes(2).toEndDate();
67
+ await adapter.transaction(async (trx) => {
68
+ await trx.writer.upsert(key, owner, expiration);
69
+ });
70
+ const result = await adapter.transaction(async (trx) => {
71
+ return await trx.writer.find(key);
72
+ });
73
+ expect(result).toEqual({
74
+ owner,
75
+ expiration,
76
+ });
77
+ });
78
+ });
79
+ describe("method: transaction writer.upsert", () => {
80
+ test("Should insert when key doesnt exists exists", async () => {
81
+ const key = "a";
82
+ const owner = "b";
83
+ const expiration = null;
84
+ await adapter.transaction(async (trx) => {
85
+ await trx.writer.upsert(key, owner, expiration);
86
+ });
87
+ const lockData = await adapter.transaction(async (trx) => {
88
+ return await trx.writer.find(key);
89
+ });
90
+ expect(lockData).toEqual({
91
+ expiration,
92
+ owner,
93
+ });
94
+ });
95
+ test("Should update when key exists exists", async () => {
96
+ const key = "a";
97
+ const owner1 = "1";
98
+ const expiration1 = null;
99
+ await adapter.transaction(async (trx) => {
100
+ await trx.writer.upsert(key, owner1, expiration1);
101
+ });
102
+ const owner2 = "2";
103
+ const expiration2 = TimeSpan.fromMilliseconds(100).toEndDate();
104
+ await adapter.transaction(async (trx) => {
105
+ await trx.writer.upsert(key, owner2, expiration2);
106
+ });
107
+ const lockData = await adapter.transaction(async (trx) => {
108
+ return await trx.writer.find(key);
109
+ });
110
+ expect(lockData).toEqual({
111
+ expiration: expiration2,
112
+ owner: owner2,
113
+ });
114
+ });
115
+ });
116
+ describe("method: transaction writer.remove", () => {
117
+ test("Should return null when key doesnt exists", async () => {
118
+ const key = "a";
119
+ const owner = "b";
120
+ const expiration = null;
121
+ await adapter.transaction(async (trx) => {
122
+ await trx.writer.upsert(key, owner, expiration);
123
+ });
124
+ const noneExistingKey = "c";
125
+ const lockExpirationData = await adapter.transaction(async (trx) => {
126
+ return await trx.writer.remove(noneExistingKey);
127
+ });
128
+ expect(lockExpirationData).toBeNull();
129
+ });
130
+ test("Should return expiration as null when key exists", async () => {
131
+ const key = "a";
132
+ const owner = "b";
133
+ const expiration = null;
134
+ await adapter.transaction(async (trx) => {
135
+ await trx.writer.upsert(key, owner, expiration);
136
+ });
137
+ const lockExpirationData = await adapter.transaction(async (trx) => {
138
+ return await trx.writer.remove(key);
139
+ });
140
+ expect(lockExpirationData).toEqual({
141
+ expiration,
142
+ });
143
+ });
144
+ test("Should return expiration as date when key exists", async () => {
145
+ const key = "a";
146
+ const owner = "b";
147
+ const expiration = TimeSpan.fromMinutes(5).toEndDate();
148
+ await adapter.transaction(async (trx) => {
149
+ await trx.writer.upsert(key, owner, expiration);
150
+ });
151
+ const lockExpirationData = await adapter.transaction(async (trx) => {
152
+ return await trx.writer.remove(key);
153
+ });
154
+ expect(lockExpirationData).toEqual({
155
+ expiration,
156
+ });
157
+ });
158
+ test("Should remove lock when key exists", async () => {
159
+ const key = "a";
160
+ const owner = "b";
161
+ const expiration = TimeSpan.fromMinutes(5).toEndDate();
162
+ await adapter.transaction(async (trx) => {
163
+ await trx.writer.upsert(key, owner, expiration);
164
+ });
165
+ await adapter.transaction(async (trx) => {
166
+ return await trx.writer.remove(key);
167
+ });
168
+ const lockExpirationData = await adapter.transaction(async (trx) => {
169
+ return await trx.writer.find(key);
170
+ });
171
+ expect(lockExpirationData).toBeNull();
172
+ });
173
+ });
174
+ describe("method: transaction writer.removeIfOwner", () => {
175
+ test("Should return null when key doesnt exists", async () => {
176
+ const key = "a";
177
+ const owner = "b";
178
+ const expiration = null;
179
+ await adapter.transaction(async (trx) => {
180
+ await trx.writer.upsert(key, owner, expiration);
181
+ });
182
+ const noneExistingKey = "c";
183
+ const lockData = await adapter.transaction(async (trx) => {
184
+ return await trx.writer.removeIfOwner(noneExistingKey, owner);
185
+ });
186
+ expect(lockData).toBeNull();
187
+ });
188
+ test("Should return null when owner doesnt exists", async () => {
189
+ const key = "a";
190
+ const owner = "b";
191
+ const expiration = null;
192
+ await adapter.transaction(async (trx) => {
193
+ await trx.writer.upsert(key, owner, expiration);
194
+ });
195
+ const noneExistingOwner = "c";
196
+ const lockData = await adapter.transaction(async (trx) => {
197
+ return await trx.writer.removeIfOwner(key, noneExistingOwner);
198
+ });
199
+ expect(lockData).toBeNull();
200
+ });
201
+ test("Should return expiration as null when key and owner exists and is unexpireable", async () => {
202
+ const key = "a";
203
+ const owner = "b";
204
+ const expiration = null;
205
+ await adapter.transaction(async (trx) => {
206
+ await trx.writer.upsert(key, owner, expiration);
207
+ });
208
+ const lockData = await adapter.transaction(async (trx) => {
209
+ return await trx.writer.removeIfOwner(key, owner);
210
+ });
211
+ expect(lockData).toEqual({
212
+ expiration,
213
+ owner,
214
+ });
215
+ });
216
+ test("Should return expiration as date when key and owner exists and is unexpireable", async () => {
217
+ const key = "a";
218
+ const owner = "b";
219
+ const expiration = TimeSpan.fromMinutes(10).toEndDate();
220
+ await adapter.transaction(async (trx) => {
221
+ await trx.writer.upsert(key, owner, expiration);
222
+ });
223
+ const lockData = await adapter.transaction(async (trx) => {
224
+ return await trx.writer.removeIfOwner(key, owner);
225
+ });
226
+ expect(lockData).toEqual({
227
+ expiration,
228
+ owner,
229
+ });
230
+ });
231
+ test("Should remove lock when key and owner exists", async () => {
232
+ const key = "a";
233
+ const owner = "b";
234
+ const expiration = TimeSpan.fromMinutes(10).toEndDate();
235
+ await adapter.transaction(async (trx) => {
236
+ await trx.writer.upsert(key, owner, expiration);
237
+ });
238
+ await adapter.transaction(async (trx) => {
239
+ await trx.writer.removeIfOwner(key, owner);
240
+ });
241
+ const lockData = await adapter.transaction(async (trx) => {
242
+ return await trx.writer.find(key);
243
+ });
244
+ expect(lockData).toBeNull();
245
+ });
246
+ test("Should not remove lock when key exists and owner does not exists", async () => {
247
+ const key = "a";
248
+ const owner = "b";
249
+ const expiration = TimeSpan.fromMinutes(10).toEndDate();
250
+ await adapter.transaction(async (trx) => {
251
+ await trx.writer.upsert(key, owner, expiration);
252
+ });
253
+ const noneExsitingOwner = "c";
254
+ await adapter.transaction(async (trx) => {
255
+ await trx.writer.removeIfOwner(key, noneExsitingOwner);
256
+ });
257
+ const lockData = await adapter.transaction(async (trx) => {
258
+ return await trx.writer.find(key);
259
+ });
260
+ expect(lockData).toEqual({
261
+ expiration,
262
+ owner,
263
+ });
264
+ });
265
+ });
266
+ describe("method: transaction writer.updateExpiration", () => {
267
+ test("Should return 0 when semaphore key doesnt exists", async () => {
268
+ const key = "a";
269
+ const owner = "1";
270
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
271
+ await adapter.transaction(async (trx) => {
272
+ await trx.writer.upsert(key, owner, expiration);
273
+ });
274
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
275
+ const noneExistingKey = "b";
276
+ const result1 = await adapter.transaction(async (trx) => {
277
+ return await trx.writer.updateExpiration(noneExistingKey, owner, newExpiration);
278
+ });
279
+ expect(result1).toBe(0);
280
+ });
281
+ test("Should return 0 when owner doesnt exists", async () => {
282
+ const key = "a";
283
+ const owner = "1";
284
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
285
+ await adapter.transaction(async (trx) => {
286
+ await trx.writer.upsert(key, owner, expiration);
287
+ });
288
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
289
+ const noneExistingOwner = "b";
290
+ const result1 = await adapter.transaction(async (trx) => {
291
+ return await trx.writer.updateExpiration(key, noneExistingOwner, newExpiration);
292
+ });
293
+ expect(result1).toBe(0);
294
+ });
295
+ test("Should return 0 when lock is expired", async () => {
296
+ const key = "a";
297
+ const owner = "1";
298
+ const expiration = TimeSpan.fromMilliseconds(50).toStartDate();
299
+ await adapter.transaction(async (trx) => {
300
+ await trx.writer.upsert(key, owner, expiration);
301
+ });
302
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
303
+ const result1 = await adapter.transaction(async (trx) => {
304
+ return await trx.writer.updateExpiration(key, owner, newExpiration);
305
+ });
306
+ expect(result1).toBe(0);
307
+ });
308
+ test("Should return 0 when lock is unexpireable", async () => {
309
+ const key = "a";
310
+ const owner = "1";
311
+ const expiration = null;
312
+ await adapter.transaction(async (trx) => {
313
+ await trx.writer.upsert(key, owner, expiration);
314
+ });
315
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
316
+ const result1 = await adapter.transaction(async (trx) => {
317
+ return await trx.writer.updateExpiration(key, owner, newExpiration);
318
+ });
319
+ expect(result1).toBe(0);
320
+ });
321
+ test("Should return number greater than 0 when lock is unexpired", async () => {
322
+ const key = "a";
323
+ const owner = "1";
324
+ const expiration = TimeSpan.fromMilliseconds(50);
325
+ await adapter.transaction(async (trx) => {
326
+ await trx.writer.upsert(key, owner, expiration.toEndDate());
327
+ });
328
+ const newExpiration = TimeSpan.fromMilliseconds(100);
329
+ const result1 = await adapter.transaction(async (trx) => {
330
+ return await trx.writer.updateExpiration(key, owner, newExpiration.toEndDate());
331
+ });
332
+ expect(result1).toBeGreaterThan(0);
333
+ });
334
+ test("Should not update expiration when lock is expired", async () => {
335
+ const key = "a";
336
+ const owner = "1";
337
+ const expiration = TimeSpan.fromMilliseconds(50).toStartDate();
338
+ await adapter.transaction(async (trx) => {
339
+ await trx.writer.upsert(key, owner, expiration);
340
+ });
341
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
342
+ await adapter.transaction(async (trx) => {
343
+ await trx.writer.updateExpiration(key, owner, newExpiration);
344
+ });
345
+ const lockData = await adapter.transaction(async (trx) => {
346
+ return await trx.writer.find(key);
347
+ });
348
+ expect(lockData).toEqual({
349
+ owner,
350
+ expiration,
351
+ });
352
+ });
353
+ test("Should not update expiration when lock is unexpireable", async () => {
354
+ const key = "a";
355
+ const owner = "1";
356
+ const expiration = null;
357
+ await adapter.transaction(async (trx) => {
358
+ await trx.writer.upsert(key, owner, expiration);
359
+ });
360
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
361
+ await adapter.transaction(async (trx) => {
362
+ await trx.writer.updateExpiration(key, owner, newExpiration);
363
+ });
364
+ const lockData = await adapter.transaction(async (trx) => {
365
+ return await trx.writer.find(key);
366
+ });
367
+ expect(lockData).toEqual({
368
+ owner,
369
+ expiration,
370
+ });
371
+ });
372
+ test("Should update expiration when lock is unexpired", async () => {
373
+ const key = "a";
374
+ const owner = "1";
375
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
376
+ await adapter.transaction(async (trx) => {
377
+ await trx.writer.upsert(key, owner, expiration);
378
+ });
379
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
380
+ await adapter.transaction(async (trx) => {
381
+ await trx.writer.updateExpiration(key, owner, newExpiration);
382
+ });
383
+ const lockData = await adapter.transaction(async (trx) => {
384
+ return await trx.writer.find(key);
385
+ });
386
+ expect(lockData).toEqual({
387
+ owner,
388
+ expiration: newExpiration,
389
+ });
390
+ });
391
+ });
392
+ describe("method: transaction writer.find", () => {
393
+ test("Should return null when key doesnt exists", async () => {
394
+ const key = "a";
395
+ const owner = "1";
396
+ const expiration = null;
397
+ await adapter.transaction(async (trx) => {
398
+ await trx.writer.upsert(key, owner, expiration);
399
+ });
400
+ const noneExistingKey = "b";
401
+ const result = await adapter.transaction(async (trx) => {
402
+ return await trx.writer.find(noneExistingKey);
403
+ });
404
+ expect(result).toBeNull();
405
+ });
406
+ test("Should return IWriterLockData when key exists", async () => {
407
+ const key = "a";
408
+ const owner = "1";
409
+ const expiration = TimeSpan.fromMinutes(2).toEndDate();
410
+ await adapter.transaction(async (trx) => {
411
+ await trx.writer.upsert(key, owner, expiration);
412
+ });
413
+ const result = await adapter.transaction(async (trx) => {
414
+ return await trx.writer.find(key);
415
+ });
416
+ expect(result).toEqual({
417
+ owner,
418
+ expiration,
419
+ });
420
+ });
421
+ });
422
+ describe("method: transaction reader.findSemaphore", () => {
423
+ test("Should return null when key doesnt exists", async () => {
424
+ const key = "a";
425
+ const limit = 2;
426
+ await adapter.transaction(async (trx) => {
427
+ await trx.reader.upsertSemaphore(key, limit);
428
+ });
429
+ const noneExistingKey = "b";
430
+ const result = await adapter.transaction(async (trx) => {
431
+ return await trx.reader.findSemaphore(noneExistingKey);
432
+ });
433
+ expect(result).toBeNull();
434
+ });
435
+ test("Should return ISemaphoreData when key exists", async () => {
436
+ const key = "a";
437
+ const limit = 2;
438
+ await adapter.transaction(async (trx) => {
439
+ await trx.reader.upsertSemaphore(key, limit);
440
+ });
441
+ const result = await adapter.transaction(async (trx) => {
442
+ return await trx.reader.findSemaphore(key);
443
+ });
444
+ expect(result).toEqual({
445
+ limit,
446
+ });
447
+ });
448
+ });
449
+ describe("method: transaction reader.findSlots", () => {
450
+ test("Should return empty array when key doesnt exists", async () => {
451
+ const key = "a";
452
+ const limit = 2;
453
+ await adapter.transaction(async (trx) => {
454
+ await trx.reader.upsertSemaphore(key, limit);
455
+ });
456
+ const noneExistingKey = "b";
457
+ const result = await adapter.transaction(async (trx) => {
458
+ return await trx.reader.findSlots(noneExistingKey);
459
+ });
460
+ expect(result).toEqual([]);
461
+ });
462
+ test("Should return empty array when key exists and has no slots", async () => {
463
+ const key = "a";
464
+ const limit = 2;
465
+ await adapter.transaction(async (trx) => {
466
+ await trx.reader.upsertSemaphore(key, limit);
467
+ });
468
+ const result = await adapter.transaction(async (trx) => {
469
+ return await trx.reader.findSlots(key);
470
+ });
471
+ expect(result).toEqual([]);
472
+ });
473
+ test("Should not return empty array when key exists and has no slots", async () => {
474
+ const key = "a";
475
+ const limit = 2;
476
+ await adapter.transaction(async (trx) => {
477
+ await trx.reader.upsertSemaphore(key, limit);
478
+ });
479
+ const slotId1 = "1";
480
+ const expiration1 = null;
481
+ await adapter.transaction(async (trx) => {
482
+ await trx.reader.upsertSlot(key, slotId1, expiration1);
483
+ });
484
+ const slotId2 = "2";
485
+ const expiration2 = null;
486
+ await adapter.transaction(async (trx) => {
487
+ await trx.reader.upsertSlot(key, slotId2, expiration2);
488
+ });
489
+ const result = await adapter.transaction(async (trx) => {
490
+ return await trx.reader.findSlots(key);
491
+ });
492
+ expect(result).toEqual([
493
+ {
494
+ id: slotId1,
495
+ expiration: expiration1,
496
+ },
497
+ {
498
+ id: slotId2,
499
+ expiration: expiration2,
500
+ },
501
+ ]);
502
+ });
503
+ });
504
+ describe("method: transaction reader.upsertSemaphore", () => {
505
+ test("Should insert when key doesnt exists exists", async () => {
506
+ const key = "a";
507
+ const limit = 2;
508
+ await adapter.transaction(async (trx) => {
509
+ await trx.reader.upsertSemaphore(key, limit);
510
+ });
511
+ const result = await adapter.transaction(async (trx) => {
512
+ return await trx.reader.findSemaphore(key);
513
+ });
514
+ expect(result).toEqual({
515
+ limit,
516
+ });
517
+ });
518
+ test("Should update when key exists exists", async () => {
519
+ const key = "a";
520
+ const limit = 2;
521
+ await adapter.transaction(async (trx) => {
522
+ await trx.reader.upsertSemaphore(key, limit);
523
+ });
524
+ const newLimit = 4;
525
+ await adapter.transaction(async (trx) => {
526
+ await trx.reader.upsertSemaphore(key, newLimit);
527
+ });
528
+ const result = await adapter.transaction(async (trx) => {
529
+ return await trx.reader.findSemaphore(key);
530
+ });
531
+ expect(result).toEqual({
532
+ limit: newLimit,
533
+ });
534
+ });
535
+ });
536
+ describe("method: transaction reader.upsertSlot", () => {
537
+ test("Should insert when key doesnt exists exists", async () => {
538
+ const key = "a";
539
+ const limit = 2;
540
+ await adapter.transaction(async (trx) => {
541
+ await trx.reader.upsertSemaphore(key, limit);
542
+ });
543
+ const slotId = "a";
544
+ const expiration = null;
545
+ await adapter.transaction(async (trx) => {
546
+ await trx.reader.upsertSlot(key, slotId, expiration);
547
+ });
548
+ const slot = await adapter.transaction(async (trx) => {
549
+ const slots = await trx.reader.findSlots(key);
550
+ return slots.find((slot) => slot.id === slotId);
551
+ });
552
+ expect(slot).toEqual({
553
+ expiration,
554
+ id: slotId,
555
+ });
556
+ });
557
+ test("Should update when key exists exists", async () => {
558
+ const key = "a";
559
+ const limit = 2;
560
+ await adapter.transaction(async (trx) => {
561
+ await trx.reader.upsertSemaphore(key, limit);
562
+ });
563
+ const slotId1 = "1";
564
+ const expiration1 = null;
565
+ await adapter.transaction(async (trx) => {
566
+ await trx.reader.upsertSlot(key, slotId1, expiration1);
567
+ });
568
+ const slotId2 = "2";
569
+ const expiration2 = TimeSpan.fromMilliseconds(100).toEndDate();
570
+ await adapter.transaction(async (trx) => {
571
+ await trx.reader.upsertSlot(key, slotId2, expiration2);
572
+ });
573
+ const slot = await adapter.transaction(async (trx) => {
574
+ const slots = await trx.reader.findSlots(key);
575
+ return slots.find((slot) => slot.id === slotId2);
576
+ });
577
+ expect(slot).toEqual({
578
+ expiration: expiration2,
579
+ id: slotId2,
580
+ });
581
+ });
582
+ });
583
+ describe("method: removeSlot", () => {
584
+ test("Should return null when key doesnt exists", async () => {
585
+ const key = "a";
586
+ const slotId = "b";
587
+ const limit = 2;
588
+ const expiration = null;
589
+ await adapter.transaction(async (trx) => {
590
+ await trx.reader.upsertSemaphore(key, limit);
591
+ });
592
+ await adapter.transaction(async (trx) => {
593
+ await trx.reader.upsertSlot(key, slotId, expiration);
594
+ });
595
+ const noneExistingKey = "c";
596
+ const result = await adapter.transaction(async (trx) => {
597
+ return await trx.reader.removeSlot(noneExistingKey, slotId);
598
+ });
599
+ expect(result).toBeNull();
600
+ });
601
+ test("Should return null when slotId doesnt exists", async () => {
602
+ const key = "a";
603
+ const slotId = "b";
604
+ const limit = 2;
605
+ const expiration = null;
606
+ await adapter.transaction(async (trx) => {
607
+ await trx.reader.upsertSemaphore(key, limit);
608
+ });
609
+ await adapter.transaction(async (trx) => {
610
+ await trx.reader.upsertSlot(key, slotId, expiration);
611
+ });
612
+ const noneExistingSlotId = "c";
613
+ const result = await adapter.transaction(async (trx) => {
614
+ return await trx.reader.removeSlot(key, noneExistingSlotId);
615
+ });
616
+ expect(result).toBeNull();
617
+ });
618
+ test("Should return expiration as null when key and slotId exists", async () => {
619
+ const key = "a";
620
+ const slotId = "b";
621
+ const limit = 2;
622
+ const expiration = null;
623
+ await adapter.transaction(async (trx) => {
624
+ await trx.reader.upsertSemaphore(key, limit);
625
+ });
626
+ await adapter.transaction(async (trx) => {
627
+ await trx.reader.upsertSlot(key, slotId, expiration);
628
+ });
629
+ const result = await adapter.transaction(async (trx) => {
630
+ return await trx.reader.removeSlot(key, slotId);
631
+ });
632
+ expect(result).toEqual({
633
+ expiration,
634
+ });
635
+ });
636
+ test("Should return expiration as date when key and slotId exists", async () => {
637
+ const key = "a";
638
+ const slotId = "b";
639
+ const limit = 2;
640
+ const expiration = TimeSpan.fromMilliseconds(100).toEndDate();
641
+ await adapter.transaction(async (trx) => {
642
+ await trx.reader.upsertSemaphore(key, limit);
643
+ });
644
+ await adapter.transaction(async (trx) => {
645
+ await trx.reader.upsertSlot(key, slotId, expiration);
646
+ });
647
+ const result = await adapter.transaction(async (trx) => {
648
+ return await trx.reader.removeSlot(key, slotId);
649
+ });
650
+ expect(result).toEqual({
651
+ expiration,
652
+ });
653
+ });
654
+ test("Should remove slot when key and slotId exists", async () => {
655
+ const key = "a";
656
+ const slotId = "b";
657
+ const limit = 2;
658
+ const expiration = null;
659
+ await adapter.transaction(async (trx) => {
660
+ await trx.reader.upsertSemaphore(key, limit);
661
+ });
662
+ await adapter.transaction(async (trx) => {
663
+ await trx.reader.upsertSlot(key, slotId, expiration);
664
+ });
665
+ await adapter.transaction(async (trx) => {
666
+ return await trx.reader.removeSlot(key, slotId);
667
+ });
668
+ const slot = await adapter.transaction(async (trx) => {
669
+ const slots = await trx.reader.findSlots(key);
670
+ return slots.find((slot) => slot.id === slotId);
671
+ });
672
+ expect(slot).toBeUndefined();
673
+ });
674
+ test("Should not remove slot when key exists and slotId does not exists", async () => {
675
+ const key = "a";
676
+ const slotId = "b";
677
+ const limit = 2;
678
+ const expiration = null;
679
+ await adapter.transaction(async (trx) => {
680
+ await trx.reader.upsertSemaphore(key, limit);
681
+ });
682
+ await adapter.transaction(async (trx) => {
683
+ await trx.reader.upsertSlot(key, slotId, expiration);
684
+ });
685
+ const noneExistingSlotId = "c";
686
+ await adapter.transaction(async (trx) => {
687
+ return await trx.reader.removeSlot(key, noneExistingSlotId);
688
+ });
689
+ const slot = await adapter.transaction(async (trx) => {
690
+ const slots = await trx.reader.findSlots(key);
691
+ return slots.find((slot) => slot.id === slotId);
692
+ });
693
+ expect(slot).toEqual({
694
+ id: slotId,
695
+ expiration,
696
+ });
697
+ });
698
+ });
699
+ describe("method: removeAllSlots", () => {
700
+ test("Should return empty array when key doesnt exists", async () => {
701
+ const key = "a";
702
+ const slotId = "b";
703
+ const limit = 2;
704
+ const expiration = null;
705
+ await adapter.transaction(async (trx) => {
706
+ await trx.reader.upsertSemaphore(key, limit);
707
+ });
708
+ await adapter.transaction(async (trx) => {
709
+ await trx.reader.upsertSlot(key, slotId, expiration);
710
+ });
711
+ const noneExistingKey = "c";
712
+ const result = await adapter.transaction(async (trx) => {
713
+ return trx.reader.removeAllSlots(noneExistingKey);
714
+ });
715
+ expect(result).toEqual([]);
716
+ });
717
+ test("Should return empty array when key exists and has no slots", async () => {
718
+ const key = "a";
719
+ const limit = 2;
720
+ await adapter.transaction(async (trx) => {
721
+ await trx.reader.upsertSemaphore(key, limit);
722
+ });
723
+ const result = await adapter.transaction(async (trx) => {
724
+ return trx.reader.removeAllSlots(key);
725
+ });
726
+ expect(result).toEqual([]);
727
+ });
728
+ test("Should return array with 2 items when key exists and has slots", async () => {
729
+ const key = "a";
730
+ const limit = 2;
731
+ await adapter.transaction(async (trx) => {
732
+ await trx.reader.upsertSemaphore(key, limit);
733
+ });
734
+ const slotId1 = "b";
735
+ const expiration1 = null;
736
+ await adapter.transaction(async (trx) => {
737
+ await trx.reader.upsertSlot(key, slotId1, expiration1);
738
+ });
739
+ const slotId2 = "c";
740
+ const expiration2 = TimeSpan.fromMilliseconds(10).toEndDate();
741
+ await adapter.transaction(async (trx) => {
742
+ await trx.reader.upsertSlot(key, slotId2, expiration2);
743
+ });
744
+ const result = await adapter.transaction(async (trx) => {
745
+ return trx.reader.removeAllSlots(key);
746
+ });
747
+ expect(result).toEqual([
748
+ {
749
+ expiration: expiration1,
750
+ },
751
+ {
752
+ expiration: expiration2,
753
+ },
754
+ ]);
755
+ });
756
+ test("Should remove all items when key exists and has slots", async () => {
757
+ const key = "a";
758
+ const limit = 2;
759
+ await adapter.transaction(async (trx) => {
760
+ await trx.reader.upsertSemaphore(key, limit);
761
+ });
762
+ const slotId1 = "b";
763
+ const expiration1 = null;
764
+ await adapter.transaction(async (trx) => {
765
+ await trx.reader.upsertSlot(key, slotId1, expiration1);
766
+ });
767
+ const slotId2 = "c";
768
+ const expiration2 = TimeSpan.fromMilliseconds(10).toEndDate();
769
+ await adapter.transaction(async (trx) => {
770
+ await trx.reader.upsertSlot(key, slotId2, expiration2);
771
+ });
772
+ await adapter.transaction(async (trx) => {
773
+ return trx.reader.removeAllSlots(key);
774
+ });
775
+ const slots = await adapter.transaction(async (trx) => {
776
+ return await trx.reader.findSlots(key);
777
+ });
778
+ expect(slots).toEqual([]);
779
+ });
780
+ });
781
+ describe("method: updateExpiration", () => {
782
+ test("Should return 0 when semaphore key doesnt exists", async () => {
783
+ const key = "a";
784
+ const limit = 2;
785
+ await adapter.transaction(async (trx) => {
786
+ await trx.reader.upsertSemaphore(key, limit);
787
+ });
788
+ const slotId1 = "1";
789
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
790
+ await adapter.transaction(async (trx) => {
791
+ await trx.reader.upsertSlot(key, slotId1, expiration);
792
+ });
793
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
794
+ const noneExistingKey = "b";
795
+ const result1 = await adapter.transaction(async (trx) => {
796
+ return trx.reader.updateExpiration(noneExistingKey, slotId1, newExpiration);
797
+ });
798
+ expect(result1).toBe(0);
799
+ });
800
+ test("Should return 0 when slot doesnt exists", async () => {
801
+ const key = "a";
802
+ const limit = 2;
803
+ await adapter.transaction(async (trx) => {
804
+ await trx.reader.upsertSemaphore(key, limit);
805
+ });
806
+ const slotId1 = "1";
807
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
808
+ await adapter.transaction(async (trx) => {
809
+ await trx.reader.upsertSlot(key, slotId1, expiration);
810
+ });
811
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
812
+ const noneExistingSlotId = "b";
813
+ const result1 = await adapter.transaction(async (trx) => {
814
+ return trx.reader.updateExpiration(key, noneExistingSlotId, newExpiration);
815
+ });
816
+ expect(result1).toBe(0);
817
+ });
818
+ test("Should return 0 when slot is expired", async () => {
819
+ const key = "a";
820
+ const limit = 2;
821
+ await adapter.transaction(async (trx) => {
822
+ await trx.reader.upsertSemaphore(key, limit);
823
+ });
824
+ const slotId1 = "1";
825
+ const expiration = TimeSpan.fromMilliseconds(50).toStartDate();
826
+ await adapter.transaction(async (trx) => {
827
+ await trx.reader.upsertSlot(key, slotId1, expiration);
828
+ });
829
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
830
+ const result1 = await adapter.transaction(async (trx) => {
831
+ return trx.reader.updateExpiration(key, slotId1, newExpiration);
832
+ });
833
+ expect(result1).toBe(0);
834
+ });
835
+ test("Should return 0 when slot is unexpireable", async () => {
836
+ const key = "a";
837
+ const limit = 2;
838
+ await adapter.transaction(async (trx) => {
839
+ await trx.reader.upsertSemaphore(key, limit);
840
+ });
841
+ const slotId1 = "1";
842
+ const expiration = null;
843
+ await adapter.transaction(async (trx) => {
844
+ await trx.reader.upsertSlot(key, slotId1, expiration);
845
+ });
846
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
847
+ const result1 = await adapter.transaction(async (trx) => {
848
+ return trx.reader.updateExpiration(key, slotId1, newExpiration);
849
+ });
850
+ expect(result1).toBe(0);
851
+ });
852
+ test("Should return number greater than 0 when slot is unexpired", async () => {
853
+ const key = "a";
854
+ const limit = 2;
855
+ await adapter.transaction(async (trx) => {
856
+ await trx.reader.upsertSemaphore(key, limit);
857
+ });
858
+ const slotId1 = "1";
859
+ const expiration = TimeSpan.fromMilliseconds(50);
860
+ await adapter.transaction(async (trx) => {
861
+ await trx.reader.upsertSlot(key, slotId1, expiration.toEndDate());
862
+ });
863
+ const newExpiration = TimeSpan.fromMilliseconds(100);
864
+ const result1 = await adapter.transaction(async (trx) => {
865
+ return trx.reader.updateExpiration(key, slotId1, newExpiration.toEndDate());
866
+ });
867
+ expect(result1).toBeGreaterThan(0);
868
+ });
869
+ test("Should not update expiration when slot is expired", async () => {
870
+ const key = "a";
871
+ const limit = 2;
872
+ await adapter.transaction(async (trx) => {
873
+ await trx.reader.upsertSemaphore(key, limit);
874
+ });
875
+ const slotId1 = "1";
876
+ const expiration = TimeSpan.fromMilliseconds(50).toStartDate();
877
+ await adapter.transaction(async (trx) => {
878
+ await trx.reader.upsertSlot(key, slotId1, expiration);
879
+ });
880
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
881
+ await adapter.transaction(async (trx) => {
882
+ return await trx.reader.updateExpiration(key, slotId1, newExpiration);
883
+ });
884
+ const slot = await adapter.transaction(async (trx) => {
885
+ const slots = await trx.reader.findSlots(key);
886
+ return slots.find((slot) => slot.id === slotId1);
887
+ });
888
+ expect(slot).toEqual({
889
+ id: slotId1,
890
+ expiration,
891
+ });
892
+ });
893
+ test("Should not update expiration when slot is unexpireable", async () => {
894
+ const key = "a";
895
+ const limit = 2;
896
+ await adapter.transaction(async (trx) => {
897
+ await trx.reader.upsertSemaphore(key, limit);
898
+ });
899
+ const slotId1 = "1";
900
+ const expiration = null;
901
+ await adapter.transaction(async (trx) => {
902
+ await trx.reader.upsertSlot(key, slotId1, expiration);
903
+ });
904
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
905
+ await adapter.transaction(async (trx) => {
906
+ return await trx.reader.updateExpiration(key, slotId1, newExpiration);
907
+ });
908
+ const slot = await adapter.transaction(async (trx) => {
909
+ const slots = await trx.reader.findSlots(key);
910
+ return slots.find((slot) => slot.id === slotId1);
911
+ });
912
+ expect(slot).toEqual({
913
+ id: slotId1,
914
+ expiration,
915
+ });
916
+ });
917
+ test("Should update expiration when slot is unexpired", async () => {
918
+ const key = "a";
919
+ const limit = 2;
920
+ await adapter.transaction(async (trx) => {
921
+ await trx.reader.upsertSemaphore(key, limit);
922
+ });
923
+ const slotId1 = "1";
924
+ const expiration = TimeSpan.fromMilliseconds(50).toEndDate();
925
+ await adapter.transaction(async (trx) => {
926
+ await trx.reader.upsertSlot(key, slotId1, expiration);
927
+ });
928
+ const newExpiration = TimeSpan.fromMilliseconds(100).toEndDate();
929
+ await adapter.transaction(async (trx) => {
930
+ return await trx.reader.updateExpiration(key, slotId1, newExpiration);
931
+ });
932
+ const slot = await adapter.transaction(async (trx) => {
933
+ const slots = await trx.reader.findSlots(key);
934
+ return slots.find((slot) => slot.id === slotId1);
935
+ });
936
+ expect(slot).toEqual({
937
+ id: slotId1,
938
+ expiration: newExpiration,
939
+ });
940
+ });
941
+ });
942
+ });
943
+ }
944
+ //# sourceMappingURL=database-shared-lock-adapter.test-suite.js.map