@venizia/ignis-helpers 0.4.7 → 0.4.8-1

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 (678) hide show
  1. package/README.md +2 -2
  2. package/dist/esm/common/constants/app.d.ts +15 -0
  3. package/dist/esm/common/constants/app.js +14 -0
  4. package/dist/esm/common/constants/app.js.map +1 -1
  5. package/dist/esm/common/constants/duration.d.ts +2 -0
  6. package/dist/esm/common/constants/duration.js.map +1 -1
  7. package/dist/esm/common/constants/grpc.d.ts +3 -0
  8. package/dist/esm/common/constants/grpc.js +1 -0
  9. package/dist/esm/common/constants/grpc.js.map +1 -1
  10. package/dist/esm/common/constants/http.d.ts +4 -0
  11. package/dist/esm/common/constants/http.js +1 -0
  12. package/dist/esm/common/constants/http.js.map +1 -1
  13. package/dist/esm/common/constants/mime.d.ts +4 -0
  14. package/dist/esm/common/constants/mime.js +1 -0
  15. package/dist/esm/common/constants/mime.js.map +1 -1
  16. package/dist/esm/common/redact.d.ts +2 -0
  17. package/dist/esm/common/redact.js +2 -0
  18. package/dist/esm/common/redact.js.map +1 -1
  19. package/dist/esm/common/resolvers.d.ts +1 -0
  20. package/dist/esm/common/resolvers.js +1 -0
  21. package/dist/esm/common/resolvers.js.map +1 -1
  22. package/dist/esm/common/types/class.d.ts +6 -0
  23. package/dist/esm/common/types/class.js.map +1 -1
  24. package/dist/esm/common/types/const-value.d.ts +3 -0
  25. package/dist/esm/common/types/const-value.js.map +1 -1
  26. package/dist/esm/common/types/field-mapping.d.ts +3 -0
  27. package/dist/esm/common/types/field-mapping.js.map +1 -1
  28. package/dist/esm/common/types/injection.d.ts +2 -0
  29. package/dist/esm/common/types/injection.js.map +1 -1
  30. package/dist/esm/common/types/utility.d.ts +9 -0
  31. package/dist/esm/common/types/utility.js.map +1 -1
  32. package/dist/esm/modules/base.d.ts +1 -0
  33. package/dist/esm/modules/base.js +1 -0
  34. package/dist/esm/modules/base.js.map +1 -1
  35. package/dist/esm/modules/cron/helper.d.ts +7 -0
  36. package/dist/esm/modules/cron/helper.js +1 -0
  37. package/dist/esm/modules/cron/helper.js.map +1 -1
  38. package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts +2 -0
  39. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  40. package/dist/esm/modules/crypto/algorithms/aes.engine.js.map +1 -1
  41. package/dist/esm/modules/crypto/algorithms/base.algorithm.d.ts +1 -0
  42. package/dist/esm/modules/crypto/algorithms/base.algorithm.js +1 -0
  43. package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
  44. package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts +12 -4
  45. package/dist/esm/modules/crypto/algorithms/credential.algorithm.js +4 -4
  46. package/dist/esm/modules/crypto/algorithms/credential.algorithm.js.map +1 -1
  47. package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.d.ts +3 -0
  48. package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.js.map +1 -1
  49. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js.map +1 -1
  50. package/dist/esm/modules/crypto/algorithms/rsa.algorithm.d.ts +1 -0
  51. package/dist/esm/modules/crypto/algorithms/rsa.algorithm.js.map +1 -1
  52. package/dist/esm/modules/crypto/common/constants.d.ts +12 -1
  53. package/dist/esm/modules/crypto/common/constants.js +9 -1
  54. package/dist/esm/modules/crypto/common/constants.js.map +1 -1
  55. package/dist/esm/modules/crypto/common/types.d.ts +1 -0
  56. package/dist/esm/modules/crypto/common/types.js.map +1 -1
  57. package/dist/esm/modules/env/app-env.d.ts +3 -0
  58. package/dist/esm/modules/env/app-env.js +3 -0
  59. package/dist/esm/modules/env/app-env.js.map +1 -1
  60. package/dist/esm/modules/env/common/types.d.ts +1 -0
  61. package/dist/esm/modules/env/common/types.js.map +1 -1
  62. package/dist/esm/modules/logger/base/base.js.map +1 -1
  63. package/dist/esm/modules/logger/base/console.js.map +1 -1
  64. package/dist/esm/modules/logger/common/constants.d.ts +3 -0
  65. package/dist/esm/modules/logger/common/constants.js +2 -0
  66. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  67. package/dist/esm/modules/logger/common/debug-gate.js.map +1 -1
  68. package/dist/esm/modules/logger/common/types.d.ts +2 -0
  69. package/dist/esm/modules/logger/common/types.js +1 -0
  70. package/dist/esm/modules/logger/common/types.js.map +1 -1
  71. package/dist/esm/modules/logger/factory.js.map +1 -1
  72. package/dist/esm/modules/logger/formatting/deep-splat.d.ts +1 -0
  73. package/dist/esm/modules/logger/formatting/deep-splat.js +1 -0
  74. package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
  75. package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
  76. package/dist/esm/modules/logger/hf/common/types.d.ts +7 -2
  77. package/dist/esm/modules/logger/hf/common/types.js.map +1 -1
  78. package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
  79. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  80. package/dist/esm/modules/logger/hf/ring.js.map +1 -1
  81. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  82. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  83. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  84. package/dist/esm/modules/logger/winston/common/types.d.ts +31 -3
  85. package/dist/esm/modules/logger/winston/common/types.js.map +1 -1
  86. package/dist/esm/modules/logger/winston/define.d.ts +1 -0
  87. package/dist/esm/modules/logger/winston/define.js +1 -0
  88. package/dist/esm/modules/logger/winston/define.js.map +1 -1
  89. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  90. package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
  91. package/dist/esm/modules/logger/winston/logger.d.ts +1 -0
  92. package/dist/esm/modules/logger/winston/logger.js +1 -0
  93. package/dist/esm/modules/logger/winston/logger.js.map +1 -1
  94. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -0
  95. package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -0
  96. package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
  97. package/dist/esm/modules/network/http-request/base-network-request.helper.d.ts +1 -0
  98. package/dist/esm/modules/network/http-request/base-network-request.helper.js +1 -0
  99. package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
  100. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +8 -8
  101. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +2 -0
  102. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  103. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +2 -0
  104. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
  105. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +5 -1
  106. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +2 -0
  107. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  108. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts +11 -0
  109. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +1 -0
  110. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  111. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +3 -0
  112. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +1 -0
  113. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  114. package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.d.ts +1 -0
  115. package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.js +1 -0
  116. package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.js.map +1 -1
  117. package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.d.ts +1 -0
  118. package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.js +1 -0
  119. package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.js.map +1 -1
  120. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.d.ts +1 -0
  121. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.js +1 -0
  122. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.js.map +1 -1
  123. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.d.ts +1 -0
  124. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.js +1 -0
  125. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.js.map +1 -1
  126. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.d.ts +4 -0
  127. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +4 -0
  128. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
  129. package/dist/esm/modules/network/utilities/query-string.d.ts +13 -2
  130. package/dist/esm/modules/network/utilities/query-string.js +2 -1
  131. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  132. package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts +2 -1
  133. package/dist/esm/modules/network/utilities/url-safety/common/constants.js +1 -1
  134. package/dist/esm/modules/network/utilities/url-safety/common/constants.js.map +1 -1
  135. package/dist/esm/modules/network/utilities/url-safety/common/types.d.ts +18 -5
  136. package/dist/esm/modules/network/utilities/url-safety/common/types.js.map +1 -1
  137. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  138. package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
  139. package/dist/esm/modules/pool/abstract.js.map +1 -1
  140. package/dist/esm/modules/pool/common/types.d.ts +5 -1
  141. package/dist/esm/modules/pool/common/types.js.map +1 -1
  142. package/dist/esm/modules/queue/bullmq/helper.d.ts +13 -0
  143. package/dist/esm/modules/queue/bullmq/helper.js +4 -0
  144. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  145. package/dist/esm/modules/queue/common/hook.d.ts +1 -0
  146. package/dist/esm/modules/queue/common/hook.js +1 -0
  147. package/dist/esm/modules/queue/common/hook.js.map +1 -1
  148. package/dist/esm/modules/queue/internal/hf/helper.js.map +1 -1
  149. package/dist/esm/modules/queue/internal/sequential/common/types.d.ts +8 -0
  150. package/dist/esm/modules/queue/internal/sequential/common/types.js +1 -0
  151. package/dist/esm/modules/queue/internal/sequential/common/types.js.map +1 -1
  152. package/dist/esm/modules/queue/internal/sequential/helper.d.ts +4 -0
  153. package/dist/esm/modules/queue/internal/sequential/helper.js +4 -0
  154. package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
  155. package/dist/esm/modules/queue/kafka/base.d.ts +5 -0
  156. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  157. package/dist/esm/modules/queue/kafka/bundler/common/constants.d.ts +3 -0
  158. package/dist/esm/modules/queue/kafka/bundler/common/constants.js +3 -0
  159. package/dist/esm/modules/queue/kafka/bundler/common/constants.js.map +1 -1
  160. package/dist/esm/modules/queue/kafka/common/constants.d.ts +8 -0
  161. package/dist/esm/modules/queue/kafka/common/constants.js +5 -0
  162. package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
  163. package/dist/esm/modules/queue/kafka/common/types/admin.d.ts +1 -0
  164. package/dist/esm/modules/queue/kafka/common/types/admin.js.map +1 -1
  165. package/dist/esm/modules/queue/kafka/common/types/callbacks.d.ts +12 -0
  166. package/dist/esm/modules/queue/kafka/common/types/callbacks.js.map +1 -1
  167. package/dist/esm/modules/queue/kafka/common/types/connection.d.ts +2 -0
  168. package/dist/esm/modules/queue/kafka/common/types/connection.js.map +1 -1
  169. package/dist/esm/modules/queue/kafka/common/types/consumer.d.ts +62 -0
  170. package/dist/esm/modules/queue/kafka/common/types/consumer.js.map +1 -1
  171. package/dist/esm/modules/queue/kafka/common/types/producer.d.ts +1 -0
  172. package/dist/esm/modules/queue/kafka/common/types/producer.js.map +1 -1
  173. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  174. package/dist/esm/modules/queue/mqtt/helper.d.ts +2 -0
  175. package/dist/esm/modules/queue/mqtt/helper.js +1 -0
  176. package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
  177. package/dist/esm/modules/redis/base/abstract.helper.d.ts +2 -0
  178. package/dist/esm/modules/redis/base/abstract.helper.js +2 -0
  179. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  180. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -0
  181. package/dist/esm/modules/redis/cluster/cluster.helper.js +1 -0
  182. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  183. package/dist/esm/modules/redis/common/constants.d.ts +4 -0
  184. package/dist/esm/modules/redis/common/constants.js +2 -0
  185. package/dist/esm/modules/redis/common/constants.js.map +1 -1
  186. package/dist/esm/modules/redis/common/interfaces.d.ts +12 -0
  187. package/dist/esm/modules/redis/common/interfaces.js.map +1 -1
  188. package/dist/esm/modules/redis/common/types.d.ts +21 -1
  189. package/dist/esm/modules/redis/common/types.js.map +1 -1
  190. package/dist/esm/modules/redis/factory.d.ts +2 -0
  191. package/dist/esm/modules/redis/factory.js +1 -0
  192. package/dist/esm/modules/redis/factory.js.map +1 -1
  193. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -0
  194. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +1 -0
  195. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  196. package/dist/esm/modules/redis/single/single.helper.d.ts +1 -0
  197. package/dist/esm/modules/redis/single/single.helper.js +1 -0
  198. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  199. package/dist/esm/modules/redis/utility.d.ts +1 -0
  200. package/dist/esm/modules/redis/utility.js +1 -0
  201. package/dist/esm/modules/redis/utility.js.map +1 -1
  202. package/dist/esm/modules/retry/common/constants.d.ts +4 -0
  203. package/dist/esm/modules/retry/common/constants.js +2 -0
  204. package/dist/esm/modules/retry/common/constants.js.map +1 -1
  205. package/dist/esm/modules/retry/common/types.d.ts +19 -5
  206. package/dist/esm/modules/retry/common/types.js.map +1 -1
  207. package/dist/esm/modules/retry/helper.d.ts +4 -4
  208. package/dist/esm/modules/retry/helper.js.map +1 -1
  209. package/dist/esm/modules/secrets/base/abstract.helper.d.ts +1 -0
  210. package/dist/esm/modules/secrets/base/abstract.helper.js +1 -0
  211. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  212. package/dist/esm/modules/secrets/common/constants.d.ts +4 -0
  213. package/dist/esm/modules/secrets/common/constants.js +2 -0
  214. package/dist/esm/modules/secrets/common/constants.js.map +1 -1
  215. package/dist/esm/modules/secrets/common/types/helper.d.ts +13 -0
  216. package/dist/esm/modules/secrets/common/types/helper.js.map +1 -1
  217. package/dist/esm/modules/secrets/common/types/lease.d.ts +2 -0
  218. package/dist/esm/modules/secrets/common/types/lease.js.map +1 -1
  219. package/dist/esm/modules/secrets/common/types/registration.d.ts +13 -2
  220. package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
  221. package/dist/esm/modules/secrets/common/types/timer.d.ts +1 -0
  222. package/dist/esm/modules/secrets/common/types/timer.js.map +1 -1
  223. package/dist/esm/modules/secrets/dotenv/dotenv.helper.d.ts +8 -0
  224. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -0
  225. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
  226. package/dist/esm/modules/secrets/factory.d.ts +1 -0
  227. package/dist/esm/modules/secrets/factory.js +1 -0
  228. package/dist/esm/modules/secrets/factory.js.map +1 -1
  229. package/dist/esm/modules/secrets/hashicorp/auth.d.ts +2 -0
  230. package/dist/esm/modules/secrets/hashicorp/auth.js +1 -0
  231. package/dist/esm/modules/secrets/hashicorp/auth.js.map +1 -1
  232. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +2 -0
  233. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +1 -0
  234. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  235. package/dist/esm/modules/secrets/system-envs/system-envs.helper.d.ts +1 -0
  236. package/dist/esm/modules/secrets/system-envs/system-envs.helper.js +1 -0
  237. package/dist/esm/modules/secrets/system-envs/system-envs.helper.js.map +1 -1
  238. package/dist/esm/modules/slug/common/constants.d.ts +1 -0
  239. package/dist/esm/modules/slug/common/constants.js +1 -0
  240. package/dist/esm/modules/slug/common/constants.js.map +1 -1
  241. package/dist/esm/modules/socket/socket-io/client/browser-helper.js.map +1 -1
  242. package/dist/esm/modules/socket/socket-io/common/constants.d.ts +2 -0
  243. package/dist/esm/modules/socket/socket-io/common/constants.js +2 -0
  244. package/dist/esm/modules/socket/socket-io/common/constants.js.map +1 -1
  245. package/dist/esm/modules/socket/socket-io/common/types/client.d.ts +5 -0
  246. package/dist/esm/modules/socket/socket-io/common/types/client.js.map +1 -1
  247. package/dist/esm/modules/socket/socket-io/common/types/hooks.d.ts +4 -0
  248. package/dist/esm/modules/socket/socket-io/common/types/hooks.js.map +1 -1
  249. package/dist/esm/modules/socket/socket-io/common/types/server.d.ts +6 -0
  250. package/dist/esm/modules/socket/socket-io/common/types/server.js.map +1 -1
  251. package/dist/esm/modules/socket/socket-io/server/helper.d.ts +1 -0
  252. package/dist/esm/modules/socket/socket-io/server/helper.js +1 -0
  253. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  254. package/dist/esm/modules/socket/websocket/common/constants.d.ts +7 -0
  255. package/dist/esm/modules/socket/websocket/common/constants.js +5 -0
  256. package/dist/esm/modules/socket/websocket/common/constants.js.map +1 -1
  257. package/dist/esm/modules/socket/websocket/common/types/client.d.ts +4 -0
  258. package/dist/esm/modules/socket/websocket/common/types/client.js.map +1 -1
  259. package/dist/esm/modules/socket/websocket/common/types/hooks.d.ts +7 -0
  260. package/dist/esm/modules/socket/websocket/common/types/hooks.js.map +1 -1
  261. package/dist/esm/modules/socket/websocket/common/types/server.d.ts +30 -0
  262. package/dist/esm/modules/socket/websocket/common/types/server.js.map +1 -1
  263. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts +1 -0
  264. package/dist/esm/modules/socket/websocket/emitter/helper.js +1 -0
  265. package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
  266. package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
  267. package/dist/esm/modules/socket/websocket/server/helper.d.ts +1 -0
  268. package/dist/esm/modules/socket/websocket/server/helper.js +1 -0
  269. package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
  270. package/dist/esm/modules/storage/base.d.ts +6 -1
  271. package/dist/esm/modules/storage/base.js +1 -0
  272. package/dist/esm/modules/storage/base.js.map +1 -1
  273. package/dist/esm/modules/storage/bun-s3/helper.d.ts +9 -1
  274. package/dist/esm/modules/storage/bun-s3/helper.js +2 -1
  275. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  276. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  277. package/dist/esm/modules/storage/common/constants.d.ts +1 -0
  278. package/dist/esm/modules/storage/common/constants.js.map +1 -1
  279. package/dist/esm/modules/storage/common/types.d.ts +17 -1
  280. package/dist/esm/modules/storage/common/types.js.map +1 -1
  281. package/dist/esm/modules/storage/common/utility.d.ts +1 -0
  282. package/dist/esm/modules/storage/common/utility.js +1 -0
  283. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  284. package/dist/esm/modules/storage/disk/helper.d.ts +2 -0
  285. package/dist/esm/modules/storage/disk/helper.js +1 -0
  286. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  287. package/dist/esm/modules/temporal/abstract.d.ts +5 -0
  288. package/dist/esm/modules/temporal/abstract.js +2 -1
  289. package/dist/esm/modules/temporal/abstract.js.map +1 -1
  290. package/dist/esm/modules/temporal/adapters/dayjs.js.map +1 -1
  291. package/dist/esm/modules/temporal/adapters/intl.js.map +1 -1
  292. package/dist/esm/modules/temporal/adapters/luxon.js.map +1 -1
  293. package/dist/esm/modules/temporal/adapters/native.js.map +1 -1
  294. package/dist/esm/modules/temporal/calendar/calendar.js.map +1 -1
  295. package/dist/esm/modules/temporal/common/constants.d.ts +3 -0
  296. package/dist/esm/modules/temporal/common/constants.js.map +1 -1
  297. package/dist/esm/modules/temporal/common/types.js.map +1 -1
  298. package/dist/esm/modules/temporal/duration/duration.js.map +1 -1
  299. package/dist/esm/modules/temporal/helper.js.map +1 -1
  300. package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
  301. package/dist/esm/modules/temporal/pattern/pattern.js.map +1 -1
  302. package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
  303. package/dist/esm/modules/tree/builder.js.map +1 -1
  304. package/dist/esm/modules/tree/common/types.d.ts +6 -0
  305. package/dist/esm/modules/tree/common/types.js.map +1 -1
  306. package/dist/esm/modules/uid/common/constants.d.ts +1 -0
  307. package/dist/esm/modules/uid/common/constants.js.map +1 -1
  308. package/dist/esm/modules/uid/common/types.d.ts +28 -7
  309. package/dist/esm/modules/uid/common/types.js.map +1 -1
  310. package/dist/esm/modules/uid/helper.d.ts +12 -0
  311. package/dist/esm/modules/uid/helper.js.map +1 -1
  312. package/dist/esm/modules/uid/opaque.js.map +1 -1
  313. package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
  314. package/dist/esm/modules/uid/uuid/sha1.js.map +1 -1
  315. package/dist/esm/modules/uid/uuid/v4.d.ts +1 -0
  316. package/dist/esm/modules/uid/uuid/v4.js +1 -0
  317. package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
  318. package/dist/esm/modules/uid/uuid/v5.d.ts +1 -0
  319. package/dist/esm/modules/uid/uuid/v5.js +1 -0
  320. package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
  321. package/dist/esm/modules/uid/uuid/v7.d.ts +1 -0
  322. package/dist/esm/modules/uid/uuid/v7.js +1 -0
  323. package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
  324. package/dist/esm/modules/worker-thread/bus/abstract.d.ts +1 -0
  325. package/dist/esm/modules/worker-thread/bus/abstract.js +1 -0
  326. package/dist/esm/modules/worker-thread/bus/abstract.js.map +1 -1
  327. package/dist/esm/modules/worker-thread/bus/base.d.ts +1 -0
  328. package/dist/esm/modules/worker-thread/bus/base.js +1 -0
  329. package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
  330. package/dist/esm/modules/worker-thread/bus/handler/abstract.d.ts +1 -0
  331. package/dist/esm/modules/worker-thread/bus/handler/abstract.js +1 -0
  332. package/dist/esm/modules/worker-thread/bus/handler/abstract.js.map +1 -1
  333. package/dist/esm/modules/worker-thread/bus/handler/base.d.ts +1 -0
  334. package/dist/esm/modules/worker-thread/bus/handler/base.js +1 -0
  335. package/dist/esm/modules/worker-thread/bus/handler/base.js.map +1 -1
  336. package/dist/esm/modules/worker-thread/common/types.d.ts +4 -0
  337. package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
  338. package/dist/esm/modules/worker-thread/thread/abstract.d.ts +1 -0
  339. package/dist/esm/modules/worker-thread/thread/abstract.js +1 -0
  340. package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
  341. package/dist/esm/modules/worker-thread/thread/base.d.ts +1 -0
  342. package/dist/esm/modules/worker-thread/thread/base.js +1 -0
  343. package/dist/esm/modules/worker-thread/thread/base.js.map +1 -1
  344. package/dist/esm/modules/worker-thread/worker/abstract.d.ts +1 -0
  345. package/dist/esm/modules/worker-thread/worker/abstract.js +1 -0
  346. package/dist/esm/modules/worker-thread/worker/abstract.js.map +1 -1
  347. package/dist/esm/modules/worker-thread/worker/base.d.ts +1 -0
  348. package/dist/esm/modules/worker-thread/worker/base.js +1 -0
  349. package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
  350. package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -0
  351. package/dist/esm/modules/worker-thread/worker-pool.js +1 -0
  352. package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
  353. package/dist/esm/utilities/error.utility.d.ts +1 -0
  354. package/dist/esm/utilities/error.utility.js +1 -0
  355. package/dist/esm/utilities/error.utility.js.map +1 -1
  356. package/dist/esm/utilities/form-body.utility.d.ts +1 -0
  357. package/dist/esm/utilities/form-body.utility.js +1 -0
  358. package/dist/esm/utilities/form-body.utility.js.map +1 -1
  359. package/dist/esm/utilities/hr-time.utility.d.ts +1 -0
  360. package/dist/esm/utilities/hr-time.utility.js +1 -0
  361. package/dist/esm/utilities/hr-time.utility.js.map +1 -1
  362. package/dist/esm/utilities/module.utility.js.map +1 -1
  363. package/dist/esm/utilities/parse.utility.js.map +1 -1
  364. package/dist/esm/utilities/performance.utility.d.ts +1 -0
  365. package/dist/esm/utilities/performance.utility.js +1 -0
  366. package/dist/esm/utilities/performance.utility.js.map +1 -1
  367. package/dist/esm/utilities/promise.utility.d.ts +1 -0
  368. package/dist/esm/utilities/promise.utility.js.map +1 -1
  369. package/dist/esm/utilities/request.utility.d.ts +2 -0
  370. package/dist/esm/utilities/request.utility.js +1 -0
  371. package/dist/esm/utilities/request.utility.js.map +1 -1
  372. package/package.json +4 -4
  373. package/dist/esm/common/constants/app.d.ts.map +0 -1
  374. package/dist/esm/common/constants/duration.d.ts.map +0 -1
  375. package/dist/esm/common/constants/grpc.d.ts.map +0 -1
  376. package/dist/esm/common/constants/http.d.ts.map +0 -1
  377. package/dist/esm/common/constants/index.d.ts.map +0 -1
  378. package/dist/esm/common/constants/mime.d.ts.map +0 -1
  379. package/dist/esm/common/index.d.ts.map +0 -1
  380. package/dist/esm/common/jsx.d.ts.map +0 -1
  381. package/dist/esm/common/redact.d.ts.map +0 -1
  382. package/dist/esm/common/resolvers.d.ts.map +0 -1
  383. package/dist/esm/common/types/class.d.ts.map +0 -1
  384. package/dist/esm/common/types/const-value.d.ts.map +0 -1
  385. package/dist/esm/common/types/field-mapping.d.ts.map +0 -1
  386. package/dist/esm/common/types/index.d.ts.map +0 -1
  387. package/dist/esm/common/types/injection.d.ts.map +0 -1
  388. package/dist/esm/common/types/resolver.d.ts.map +0 -1
  389. package/dist/esm/common/types/utility.d.ts.map +0 -1
  390. package/dist/esm/core.d.ts.map +0 -1
  391. package/dist/esm/index.d.ts.map +0 -1
  392. package/dist/esm/modules/base.d.ts.map +0 -1
  393. package/dist/esm/modules/cron/helper.d.ts.map +0 -1
  394. package/dist/esm/modules/cron/index.d.ts.map +0 -1
  395. package/dist/esm/modules/crypto/algorithms/abstract.algorithm.d.ts.map +0 -1
  396. package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +0 -1
  397. package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +0 -1
  398. package/dist/esm/modules/crypto/algorithms/aes.engine.d.ts.map +0 -1
  399. package/dist/esm/modules/crypto/algorithms/base.algorithm.d.ts.map +0 -1
  400. package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts.map +0 -1
  401. package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.d.ts.map +0 -1
  402. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +0 -1
  403. package/dist/esm/modules/crypto/algorithms/index.d.ts.map +0 -1
  404. package/dist/esm/modules/crypto/algorithms/rsa.algorithm.d.ts.map +0 -1
  405. package/dist/esm/modules/crypto/common/constants.d.ts.map +0 -1
  406. package/dist/esm/modules/crypto/common/index.d.ts.map +0 -1
  407. package/dist/esm/modules/crypto/common/types.d.ts.map +0 -1
  408. package/dist/esm/modules/crypto/index.d.ts.map +0 -1
  409. package/dist/esm/modules/env/app-env.d.ts.map +0 -1
  410. package/dist/esm/modules/env/common/index.d.ts.map +0 -1
  411. package/dist/esm/modules/env/common/types.d.ts.map +0 -1
  412. package/dist/esm/modules/env/index.d.ts.map +0 -1
  413. package/dist/esm/modules/env/names.d.ts.map +0 -1
  414. package/dist/esm/modules/error/index.d.ts.map +0 -1
  415. package/dist/esm/modules/index.d.ts.map +0 -1
  416. package/dist/esm/modules/logger/base/abstract.d.ts.map +0 -1
  417. package/dist/esm/modules/logger/base/base.d.ts.map +0 -1
  418. package/dist/esm/modules/logger/base/console.d.ts.map +0 -1
  419. package/dist/esm/modules/logger/base/index.d.ts.map +0 -1
  420. package/dist/esm/modules/logger/common/constants.d.ts.map +0 -1
  421. package/dist/esm/modules/logger/common/debug-gate.d.ts.map +0 -1
  422. package/dist/esm/modules/logger/common/index.d.ts.map +0 -1
  423. package/dist/esm/modules/logger/common/types.d.ts.map +0 -1
  424. package/dist/esm/modules/logger/factory.d.ts.map +0 -1
  425. package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +0 -1
  426. package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +0 -1
  427. package/dist/esm/modules/logger/formatting/index.d.ts.map +0 -1
  428. package/dist/esm/modules/logger/hf/common/constants.d.ts.map +0 -1
  429. package/dist/esm/modules/logger/hf/common/index.d.ts.map +0 -1
  430. package/dist/esm/modules/logger/hf/common/types.d.ts.map +0 -1
  431. package/dist/esm/modules/logger/hf/flusher.d.ts.map +0 -1
  432. package/dist/esm/modules/logger/hf/index.d.ts.map +0 -1
  433. package/dist/esm/modules/logger/hf/logger.d.ts.map +0 -1
  434. package/dist/esm/modules/logger/hf/ring.d.ts.map +0 -1
  435. package/dist/esm/modules/logger/index.d.ts.map +0 -1
  436. package/dist/esm/modules/logger/pino/backing.d.ts.map +0 -1
  437. package/dist/esm/modules/logger/pino/common/constants.d.ts.map +0 -1
  438. package/dist/esm/modules/logger/pino/common/index.d.ts.map +0 -1
  439. package/dist/esm/modules/logger/pino/common/types.d.ts.map +0 -1
  440. package/dist/esm/modules/logger/pino/destination.d.ts.map +0 -1
  441. package/dist/esm/modules/logger/pino/index.d.ts.map +0 -1
  442. package/dist/esm/modules/logger/pino/logger.d.ts.map +0 -1
  443. package/dist/esm/modules/logger/winston/common/constants.d.ts.map +0 -1
  444. package/dist/esm/modules/logger/winston/common/index.d.ts.map +0 -1
  445. package/dist/esm/modules/logger/winston/common/types.d.ts.map +0 -1
  446. package/dist/esm/modules/logger/winston/define.d.ts.map +0 -1
  447. package/dist/esm/modules/logger/winston/formats.d.ts.map +0 -1
  448. package/dist/esm/modules/logger/winston/index.d.ts.map +0 -1
  449. package/dist/esm/modules/logger/winston/logger-factory.d.ts.map +0 -1
  450. package/dist/esm/modules/logger/winston/logger.d.ts.map +0 -1
  451. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts.map +0 -1
  452. package/dist/esm/modules/logger/winston/transports/index.d.ts.map +0 -1
  453. package/dist/esm/modules/network/http-request/base-network-request.helper.d.ts.map +0 -1
  454. package/dist/esm/modules/network/http-request/common/constants.d.ts.map +0 -1
  455. package/dist/esm/modules/network/http-request/common/index.d.ts.map +0 -1
  456. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +0 -1
  457. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts.map +0 -1
  458. package/dist/esm/modules/network/http-request/fetcher/common/index.d.ts.map +0 -1
  459. package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts.map +0 -1
  460. package/dist/esm/modules/network/http-request/fetcher/index.d.ts.map +0 -1
  461. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +0 -1
  462. package/dist/esm/modules/network/http-request/index.d.ts.map +0 -1
  463. package/dist/esm/modules/network/index.d.ts.map +0 -1
  464. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts.map +0 -1
  465. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +0 -1
  466. package/dist/esm/modules/network/tcp-socket/index.d.ts.map +0 -1
  467. package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.d.ts.map +0 -1
  468. package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.d.ts.map +0 -1
  469. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.d.ts.map +0 -1
  470. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.d.ts.map +0 -1
  471. package/dist/esm/modules/network/udp-socket/index.d.ts.map +0 -1
  472. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.d.ts.map +0 -1
  473. package/dist/esm/modules/network/utilities/index.d.ts.map +0 -1
  474. package/dist/esm/modules/network/utilities/query-string.d.ts.map +0 -1
  475. package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts.map +0 -1
  476. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +0 -1
  477. package/dist/esm/modules/network/utilities/url-safety/common/index.d.ts.map +0 -1
  478. package/dist/esm/modules/network/utilities/url-safety/common/types.d.ts.map +0 -1
  479. package/dist/esm/modules/network/utilities/url-safety/index.d.ts.map +0 -1
  480. package/dist/esm/modules/network/utilities/url-safety/ingest.d.ts.map +0 -1
  481. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +0 -1
  482. package/dist/esm/modules/pool/abstract.d.ts.map +0 -1
  483. package/dist/esm/modules/pool/base.d.ts.map +0 -1
  484. package/dist/esm/modules/pool/common/index.d.ts.map +0 -1
  485. package/dist/esm/modules/pool/common/types.d.ts.map +0 -1
  486. package/dist/esm/modules/pool/index.d.ts.map +0 -1
  487. package/dist/esm/modules/queue/bullmq/helper.d.ts.map +0 -1
  488. package/dist/esm/modules/queue/bullmq/index.d.ts.map +0 -1
  489. package/dist/esm/modules/queue/common/constants.d.ts.map +0 -1
  490. package/dist/esm/modules/queue/common/hook.d.ts.map +0 -1
  491. package/dist/esm/modules/queue/common/index.d.ts.map +0 -1
  492. package/dist/esm/modules/queue/index.d.ts.map +0 -1
  493. package/dist/esm/modules/queue/internal/hf/common/index.d.ts.map +0 -1
  494. package/dist/esm/modules/queue/internal/hf/common/types.d.ts.map +0 -1
  495. package/dist/esm/modules/queue/internal/hf/helper.d.ts.map +0 -1
  496. package/dist/esm/modules/queue/internal/hf/index.d.ts.map +0 -1
  497. package/dist/esm/modules/queue/internal/index.d.ts.map +0 -1
  498. package/dist/esm/modules/queue/internal/sequential/common/index.d.ts.map +0 -1
  499. package/dist/esm/modules/queue/internal/sequential/common/types.d.ts.map +0 -1
  500. package/dist/esm/modules/queue/internal/sequential/helper.d.ts.map +0 -1
  501. package/dist/esm/modules/queue/internal/sequential/index.d.ts.map +0 -1
  502. package/dist/esm/modules/queue/kafka/admin.d.ts.map +0 -1
  503. package/dist/esm/modules/queue/kafka/base.d.ts.map +0 -1
  504. package/dist/esm/modules/queue/kafka/bundler/common/constants.d.ts.map +0 -1
  505. package/dist/esm/modules/queue/kafka/bundler/common/index.d.ts.map +0 -1
  506. package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +0 -1
  507. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +0 -1
  508. package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +0 -1
  509. package/dist/esm/modules/queue/kafka/common/index.d.ts.map +0 -1
  510. package/dist/esm/modules/queue/kafka/common/types/admin.d.ts.map +0 -1
  511. package/dist/esm/modules/queue/kafka/common/types/callbacks.d.ts.map +0 -1
  512. package/dist/esm/modules/queue/kafka/common/types/connection.d.ts.map +0 -1
  513. package/dist/esm/modules/queue/kafka/common/types/consumer.d.ts.map +0 -1
  514. package/dist/esm/modules/queue/kafka/common/types/index.d.ts.map +0 -1
  515. package/dist/esm/modules/queue/kafka/common/types/producer.d.ts.map +0 -1
  516. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +0 -1
  517. package/dist/esm/modules/queue/kafka/index.d.ts.map +0 -1
  518. package/dist/esm/modules/queue/kafka/producer.d.ts.map +0 -1
  519. package/dist/esm/modules/queue/kafka/schema/index.d.ts.map +0 -1
  520. package/dist/esm/modules/queue/kafka/schema/registry.d.ts.map +0 -1
  521. package/dist/esm/modules/queue/mqtt/helper.d.ts.map +0 -1
  522. package/dist/esm/modules/queue/mqtt/index.d.ts.map +0 -1
  523. package/dist/esm/modules/redis/base/abstract.helper.d.ts.map +0 -1
  524. package/dist/esm/modules/redis/base/index.d.ts.map +0 -1
  525. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts.map +0 -1
  526. package/dist/esm/modules/redis/cluster/index.d.ts.map +0 -1
  527. package/dist/esm/modules/redis/common/constants.d.ts.map +0 -1
  528. package/dist/esm/modules/redis/common/index.d.ts.map +0 -1
  529. package/dist/esm/modules/redis/common/interfaces.d.ts.map +0 -1
  530. package/dist/esm/modules/redis/common/types.d.ts.map +0 -1
  531. package/dist/esm/modules/redis/factory.d.ts.map +0 -1
  532. package/dist/esm/modules/redis/index.d.ts.map +0 -1
  533. package/dist/esm/modules/redis/sentinel/index.d.ts.map +0 -1
  534. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts.map +0 -1
  535. package/dist/esm/modules/redis/single/index.d.ts.map +0 -1
  536. package/dist/esm/modules/redis/single/single.helper.d.ts.map +0 -1
  537. package/dist/esm/modules/redis/utility.d.ts.map +0 -1
  538. package/dist/esm/modules/retry/common/constants.d.ts.map +0 -1
  539. package/dist/esm/modules/retry/common/index.d.ts.map +0 -1
  540. package/dist/esm/modules/retry/common/types.d.ts.map +0 -1
  541. package/dist/esm/modules/retry/helper.d.ts.map +0 -1
  542. package/dist/esm/modules/retry/index.d.ts.map +0 -1
  543. package/dist/esm/modules/secrets/base/abstract.helper.d.ts.map +0 -1
  544. package/dist/esm/modules/secrets/base/index.d.ts.map +0 -1
  545. package/dist/esm/modules/secrets/common/constants.d.ts.map +0 -1
  546. package/dist/esm/modules/secrets/common/index.d.ts.map +0 -1
  547. package/dist/esm/modules/secrets/common/types/helper.d.ts.map +0 -1
  548. package/dist/esm/modules/secrets/common/types/index.d.ts.map +0 -1
  549. package/dist/esm/modules/secrets/common/types/lease.d.ts.map +0 -1
  550. package/dist/esm/modules/secrets/common/types/registration.d.ts.map +0 -1
  551. package/dist/esm/modules/secrets/common/types/timer.d.ts.map +0 -1
  552. package/dist/esm/modules/secrets/dotenv/dotenv.helper.d.ts.map +0 -1
  553. package/dist/esm/modules/secrets/dotenv/index.d.ts.map +0 -1
  554. package/dist/esm/modules/secrets/factory.d.ts.map +0 -1
  555. package/dist/esm/modules/secrets/hashicorp/auth.d.ts.map +0 -1
  556. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts.map +0 -1
  557. package/dist/esm/modules/secrets/hashicorp/index.d.ts.map +0 -1
  558. package/dist/esm/modules/secrets/index.d.ts.map +0 -1
  559. package/dist/esm/modules/secrets/system-envs/index.d.ts.map +0 -1
  560. package/dist/esm/modules/secrets/system-envs/system-envs.helper.d.ts.map +0 -1
  561. package/dist/esm/modules/slug/common/constants.d.ts.map +0 -1
  562. package/dist/esm/modules/slug/common/index.d.ts.map +0 -1
  563. package/dist/esm/modules/slug/helper.d.ts.map +0 -1
  564. package/dist/esm/modules/slug/index.d.ts.map +0 -1
  565. package/dist/esm/modules/socket/index.d.ts.map +0 -1
  566. package/dist/esm/modules/socket/socket-io/browser.d.ts.map +0 -1
  567. package/dist/esm/modules/socket/socket-io/client/browser-helper.d.ts.map +0 -1
  568. package/dist/esm/modules/socket/socket-io/client/helper.d.ts.map +0 -1
  569. package/dist/esm/modules/socket/socket-io/client/index.d.ts.map +0 -1
  570. package/dist/esm/modules/socket/socket-io/common/constants.d.ts.map +0 -1
  571. package/dist/esm/modules/socket/socket-io/common/index.d.ts.map +0 -1
  572. package/dist/esm/modules/socket/socket-io/common/types/client.d.ts.map +0 -1
  573. package/dist/esm/modules/socket/socket-io/common/types/hooks.d.ts.map +0 -1
  574. package/dist/esm/modules/socket/socket-io/common/types/index.d.ts.map +0 -1
  575. package/dist/esm/modules/socket/socket-io/common/types/server.d.ts.map +0 -1
  576. package/dist/esm/modules/socket/socket-io/index.d.ts.map +0 -1
  577. package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +0 -1
  578. package/dist/esm/modules/socket/socket-io/server/index.d.ts.map +0 -1
  579. package/dist/esm/modules/socket/websocket/common/constants.d.ts.map +0 -1
  580. package/dist/esm/modules/socket/websocket/common/index.d.ts.map +0 -1
  581. package/dist/esm/modules/socket/websocket/common/types/client.d.ts.map +0 -1
  582. package/dist/esm/modules/socket/websocket/common/types/hooks.d.ts.map +0 -1
  583. package/dist/esm/modules/socket/websocket/common/types/index.d.ts.map +0 -1
  584. package/dist/esm/modules/socket/websocket/common/types/message.d.ts.map +0 -1
  585. package/dist/esm/modules/socket/websocket/common/types/server.d.ts.map +0 -1
  586. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +0 -1
  587. package/dist/esm/modules/socket/websocket/emitter/index.d.ts.map +0 -1
  588. package/dist/esm/modules/socket/websocket/index.d.ts.map +0 -1
  589. package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +0 -1
  590. package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +0 -1
  591. package/dist/esm/modules/socket/websocket/server/index.d.ts.map +0 -1
  592. package/dist/esm/modules/storage/base.d.ts.map +0 -1
  593. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +0 -1
  594. package/dist/esm/modules/storage/bun-s3/index.d.ts.map +0 -1
  595. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +0 -1
  596. package/dist/esm/modules/storage/common/constants.d.ts.map +0 -1
  597. package/dist/esm/modules/storage/common/errors.d.ts.map +0 -1
  598. package/dist/esm/modules/storage/common/index.d.ts.map +0 -1
  599. package/dist/esm/modules/storage/common/types.d.ts.map +0 -1
  600. package/dist/esm/modules/storage/common/utility.d.ts.map +0 -1
  601. package/dist/esm/modules/storage/disk/helper.d.ts.map +0 -1
  602. package/dist/esm/modules/storage/disk/index.d.ts.map +0 -1
  603. package/dist/esm/modules/storage/in-memory/helper.d.ts.map +0 -1
  604. package/dist/esm/modules/storage/in-memory/index.d.ts.map +0 -1
  605. package/dist/esm/modules/storage/index.d.ts.map +0 -1
  606. package/dist/esm/modules/temporal/abstract.d.ts.map +0 -1
  607. package/dist/esm/modules/temporal/adapters/dayjs.d.ts.map +0 -1
  608. package/dist/esm/modules/temporal/adapters/index.d.ts.map +0 -1
  609. package/dist/esm/modules/temporal/adapters/intl.d.ts.map +0 -1
  610. package/dist/esm/modules/temporal/adapters/luxon.d.ts.map +0 -1
  611. package/dist/esm/modules/temporal/adapters/native.d.ts.map +0 -1
  612. package/dist/esm/modules/temporal/calendar/calendar.d.ts.map +0 -1
  613. package/dist/esm/modules/temporal/calendar/index.d.ts.map +0 -1
  614. package/dist/esm/modules/temporal/common/constants.d.ts.map +0 -1
  615. package/dist/esm/modules/temporal/common/index.d.ts.map +0 -1
  616. package/dist/esm/modules/temporal/common/types.d.ts.map +0 -1
  617. package/dist/esm/modules/temporal/duration/duration.d.ts.map +0 -1
  618. package/dist/esm/modules/temporal/duration/index.d.ts.map +0 -1
  619. package/dist/esm/modules/temporal/helper.d.ts.map +0 -1
  620. package/dist/esm/modules/temporal/index.d.ts.map +0 -1
  621. package/dist/esm/modules/temporal/locale/index.d.ts.map +0 -1
  622. package/dist/esm/modules/temporal/locale/locale.d.ts.map +0 -1
  623. package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +0 -1
  624. package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +0 -1
  625. package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +0 -1
  626. package/dist/esm/modules/temporal/pattern/index.d.ts.map +0 -1
  627. package/dist/esm/modules/temporal/pattern/pattern.d.ts.map +0 -1
  628. package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +0 -1
  629. package/dist/esm/modules/tree/builder.d.ts.map +0 -1
  630. package/dist/esm/modules/tree/common/index.d.ts.map +0 -1
  631. package/dist/esm/modules/tree/common/types.d.ts.map +0 -1
  632. package/dist/esm/modules/tree/index.d.ts.map +0 -1
  633. package/dist/esm/modules/tree/walk.d.ts.map +0 -1
  634. package/dist/esm/modules/uid/common/constants.d.ts.map +0 -1
  635. package/dist/esm/modules/uid/common/index.d.ts.map +0 -1
  636. package/dist/esm/modules/uid/common/types.d.ts.map +0 -1
  637. package/dist/esm/modules/uid/helper.d.ts.map +0 -1
  638. package/dist/esm/modules/uid/index.d.ts.map +0 -1
  639. package/dist/esm/modules/uid/opaque.d.ts.map +0 -1
  640. package/dist/esm/modules/uid/request-id.d.ts.map +0 -1
  641. package/dist/esm/modules/uid/uuid/common/constants.d.ts.map +0 -1
  642. package/dist/esm/modules/uid/uuid/common/index.d.ts.map +0 -1
  643. package/dist/esm/modules/uid/uuid/common/types.d.ts.map +0 -1
  644. package/dist/esm/modules/uid/uuid/helper.d.ts.map +0 -1
  645. package/dist/esm/modules/uid/uuid/index.d.ts.map +0 -1
  646. package/dist/esm/modules/uid/uuid/sha1.d.ts.map +0 -1
  647. package/dist/esm/modules/uid/uuid/v4.d.ts.map +0 -1
  648. package/dist/esm/modules/uid/uuid/v5.d.ts.map +0 -1
  649. package/dist/esm/modules/uid/uuid/v7.d.ts.map +0 -1
  650. package/dist/esm/modules/worker-thread/bus/abstract.d.ts.map +0 -1
  651. package/dist/esm/modules/worker-thread/bus/base.d.ts.map +0 -1
  652. package/dist/esm/modules/worker-thread/bus/handler/abstract.d.ts.map +0 -1
  653. package/dist/esm/modules/worker-thread/bus/handler/base.d.ts.map +0 -1
  654. package/dist/esm/modules/worker-thread/bus/handler/index.d.ts.map +0 -1
  655. package/dist/esm/modules/worker-thread/bus/index.d.ts.map +0 -1
  656. package/dist/esm/modules/worker-thread/common/index.d.ts.map +0 -1
  657. package/dist/esm/modules/worker-thread/common/types.d.ts.map +0 -1
  658. package/dist/esm/modules/worker-thread/index.d.ts.map +0 -1
  659. package/dist/esm/modules/worker-thread/thread/abstract.d.ts.map +0 -1
  660. package/dist/esm/modules/worker-thread/thread/base.d.ts.map +0 -1
  661. package/dist/esm/modules/worker-thread/thread/index.d.ts.map +0 -1
  662. package/dist/esm/modules/worker-thread/worker/abstract.d.ts.map +0 -1
  663. package/dist/esm/modules/worker-thread/worker/base.d.ts.map +0 -1
  664. package/dist/esm/modules/worker-thread/worker/index.d.ts.map +0 -1
  665. package/dist/esm/modules/worker-thread/worker-pool.d.ts.map +0 -1
  666. package/dist/esm/temporal.d.ts.map +0 -1
  667. package/dist/esm/utilities/build-info.utility.d.ts.map +0 -1
  668. package/dist/esm/utilities/error.utility.d.ts.map +0 -1
  669. package/dist/esm/utilities/form-body.utility.d.ts.map +0 -1
  670. package/dist/esm/utilities/hr-time.utility.d.ts.map +0 -1
  671. package/dist/esm/utilities/index.d.ts.map +0 -1
  672. package/dist/esm/utilities/module.utility.d.ts.map +0 -1
  673. package/dist/esm/utilities/parse.utility.d.ts.map +0 -1
  674. package/dist/esm/utilities/performance.utility.d.ts.map +0 -1
  675. package/dist/esm/utilities/project-root.utility.d.ts.map +0 -1
  676. package/dist/esm/utilities/promise.utility.d.ts.map +0 -1
  677. package/dist/esm/utilities/request.utility.d.ts.map +0 -1
  678. package/dist/esm/uuid.d.ts.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import type { TRedisClient } from './types.js';
2
+ /** Client access and connection lifecycle of a Redis helper. `connect` and `disconnect` resolve `false` when the client status makes the call a no-op. */
2
3
  export interface IRedisConnection {
3
4
  getClient(): TRedisClient;
4
5
  duplicateClient(): TRedisClient;
@@ -6,6 +7,7 @@ export interface IRedisConnection {
6
7
  connect(): Promise<boolean>;
7
8
  disconnect(): Promise<boolean>;
8
9
  }
10
+ /** Key-level commands: existence, expiry, TTL and counters. */
9
11
  export interface IRedisKey {
10
12
  exists(opts: {
11
13
  keys: Array<string>;
@@ -39,6 +41,7 @@ export interface IRedisKey {
39
41
  value: number;
40
42
  }): Promise<number>;
41
43
  }
44
+ /** String value commands, including JSON-serialised object reads and batch get and set. `set` `expiresIn` is in milliseconds. */
42
45
  export interface IRedisKeyValue {
43
46
  set<T>(opts: {
44
47
  key: string;
@@ -84,6 +87,7 @@ export interface IRedisKeyValue {
84
87
  transform?: (input: string) => T;
85
88
  }): Promise<(T | null)[]>;
86
89
  }
90
+ /** Hash commands (`HSET`, `HGET`, ...) on one key. */
87
91
  export interface IRedisHash {
88
92
  hSet<T extends Record<string, unknown>>(opts: {
89
93
  key: string;
@@ -123,6 +127,7 @@ export interface IRedisHash {
123
127
  key: string;
124
128
  }): Promise<number>;
125
129
  }
130
+ /** Set commands (`SADD`, `SMEMBERS`, ...) on one key. */
126
131
  export interface IRedisSet {
127
132
  sAdd(opts: {
128
133
  key: string;
@@ -143,6 +148,7 @@ export interface IRedisSet {
143
148
  key: string;
144
149
  }): Promise<number>;
145
150
  }
151
+ /** List commands (`LPUSH`, `LRANGE`, ...) on one key. */
146
152
  export interface IRedisList {
147
153
  lPush(opts: {
148
154
  key: string;
@@ -167,6 +173,7 @@ export interface IRedisList {
167
173
  key: string;
168
174
  }): Promise<number>;
169
175
  }
176
+ /** Publish to many topics and subscribe on the helper client. `publish` serialises the payload as JSON and deflates it when `useCompress` is set. */
170
177
  export interface IRedisPubSub {
171
178
  publish<T>(opts: {
172
179
  topics: Array<string>;
@@ -180,6 +187,7 @@ export interface IRedisPubSub {
180
187
  topic: string;
181
188
  }): void;
182
189
  }
190
+ /** RedisJSON commands (`JSON.SET`, `JSON.GET`, ...); the Redis server needs the JSON module. */
183
191
  export interface IRedisJson {
184
192
  jSet<T>(opts: {
185
193
  key: string;
@@ -188,10 +196,12 @@ export interface IRedisJson {
188
196
  }): Promise<string | null>;
189
197
  jGet<T>(opts: {
190
198
  key: string;
199
+ /** @default '$' */
191
200
  path?: string;
192
201
  }): Promise<T | null>;
193
202
  jDelete(opts: {
194
203
  key: string;
204
+ /** @default '$' */
195
205
  path?: string;
196
206
  }): Promise<number>;
197
207
  jNumberIncreaseBy(opts: {
@@ -214,9 +224,11 @@ export interface IRedisJson {
214
224
  path: string;
215
225
  }): Promise<T | null>;
216
226
  }
227
+ /** Escape hatch to run any Redis command by name. */
217
228
  export interface IRedisCommand {
218
229
  execute<R>(command: string, parameters?: Array<string | number | Buffer>): Promise<R>;
219
230
  }
231
+ /** Full surface of a Redis helper, composed from the command-group interfaces; `name` is the identifier it was created with. */
220
232
  export interface IRedisHelper extends IRedisConnection, IRedisKey, IRedisKeyValue, IRedisHash, IRedisSet, IRedisList, IRedisPubSub, IRedisJson, IRedisCommand {
221
233
  readonly name: string;
222
234
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { TRedisClient } from './types';\n\nexport interface IRedisConnection {\n getClient(): TRedisClient;\n duplicateClient(): TRedisClient;\n ping(): Promise<string>;\n connect(): Promise<boolean>;\n disconnect(): Promise<boolean>;\n}\n\nexport interface IRedisKey {\n exists(opts: { keys: Array<string> }): Promise<number>;\n expire(opts: { key: string; seconds: number }): Promise<boolean>;\n expireAt(opts: { key: string; atEpochSeconds: number }): Promise<boolean>;\n ttl(opts: { key: string }): Promise<number>;\n persist(opts: { key: string }): Promise<boolean>;\n incr(opts: { key: string }): Promise<number>;\n decr(opts: { key: string }): Promise<number>;\n incrBy(opts: { key: string; value: number }): Promise<number>;\n decrBy(opts: { key: string; value: number }): Promise<number>;\n}\n\nexport interface IRedisKeyValue {\n set<T>(opts: {\n key: string;\n value: T;\n options?: { log?: boolean; expiresIn?: number };\n }): Promise<void>;\n get<T = string>(opts: { key: string; transform?: (input: string) => T }): Promise<T | null>;\n\n del(opts: { keys: Array<string> }): Promise<number>;\n\n keys(opts: { key: string }): Promise<Array<string>>;\n\n getString(opts: { key: string }): Promise<string | null>;\n getStrings(opts: { keys: Array<string> }): Promise<(string | null)[]>;\n\n getObject<T>(opts: { key: string }): Promise<T | null>;\n getObjects(opts: { keys: Array<string> }): Promise<(unknown | null)[]>;\n\n mSet<T>(opts: {\n payload: Array<{ key: string; value: T }>;\n options?: { log?: boolean };\n }): Promise<void>;\n\n mGet<T = string>(opts: {\n keys: Array<string>;\n transform?: (input: string) => T;\n }): Promise<(T | null)[]>;\n}\n\nexport interface IRedisHash {\n hSet<T extends Record<string, unknown>>(opts: {\n key: string;\n value: T;\n options?: { log?: boolean };\n }): Promise<number>;\n hGetAll(opts: { key: string; transform?: <T, R>(input: T) => R }): Promise<unknown>;\n hGet(opts: { key: string; field: string }): Promise<string | null>;\n hDel(opts: { key: string; fields: Array<string> }): Promise<number>;\n hExists(opts: { key: string; field: string }): Promise<boolean>;\n hKeys(opts: { key: string }): Promise<string[]>;\n hVals(opts: { key: string }): Promise<string[]>;\n hIncrBy(opts: { key: string; field: string; value: number }): Promise<number>;\n hLen(opts: { key: string }): Promise<number>;\n}\n\nexport interface IRedisSet {\n sAdd(opts: { key: string; members: Array<string | number> }): Promise<number>;\n sRem(opts: { key: string; members: Array<string | number> }): Promise<number>;\n sMembers(opts: { key: string }): Promise<string[]>;\n sIsMember(opts: { key: string; member: string | number }): Promise<boolean>;\n sCard(opts: { key: string }): Promise<number>;\n}\n\nexport interface IRedisList {\n lPush(opts: { key: string; values: Array<string | number> }): Promise<number>;\n rPush(opts: { key: string; values: Array<string | number> }): Promise<number>;\n lPop(opts: { key: string }): Promise<string | null>;\n rPop(opts: { key: string }): Promise<string | null>;\n lRange(opts: { key: string; start: number; stop: number }): Promise<string[]>;\n lLen(opts: { key: string }): Promise<number>;\n}\n\nexport interface IRedisPubSub {\n publish<T>(opts: { topics: Array<string>; payload: T; useCompress?: boolean }): Promise<void>;\n subscribe(opts: { topic: string }): void;\n unsubscribe(opts: { topic: string }): void;\n}\n\nexport interface IRedisJson {\n jSet<T>(opts: { key: string; path: string; value: T }): Promise<string | null>;\n jGet<T>(opts: { key: string; path?: string }): Promise<T | null>;\n jDelete(opts: { key: string; path?: string }): Promise<number>;\n jNumberIncreaseBy(opts: { key: string; path: string; value: number }): Promise<string | null>;\n jStringAppend(opts: { key: string; path: string; value: string }): Promise<number[] | null>;\n jPush<T>(opts: { key: string; path: string; value: T }): Promise<number[] | null>;\n jPop<T>(opts: { key: string; path: string }): Promise<T | null>;\n}\n\nexport interface IRedisCommand {\n execute<R>(command: string, parameters?: Array<string | number | Buffer>): Promise<R>;\n}\n\nexport interface IRedisHelper\n extends\n IRedisConnection,\n IRedisKey,\n IRedisKeyValue,\n IRedisHash,\n IRedisSet,\n IRedisList,\n IRedisPubSub,\n IRedisJson,\n IRedisCommand {\n readonly name: string;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { TRedisClient } from './types';\n\n/** Client access and connection lifecycle of a Redis helper. `connect` and `disconnect` resolve `false` when the client status makes the call a no-op. */\nexport interface IRedisConnection {\n getClient(): TRedisClient;\n duplicateClient(): TRedisClient;\n ping(): Promise<string>;\n connect(): Promise<boolean>;\n disconnect(): Promise<boolean>;\n}\n\n/** Key-level commands: existence, expiry, TTL and counters. */\nexport interface IRedisKey {\n exists(opts: { keys: Array<string> }): Promise<number>;\n expire(opts: { key: string; seconds: number }): Promise<boolean>;\n expireAt(opts: { key: string; atEpochSeconds: number }): Promise<boolean>;\n ttl(opts: { key: string }): Promise<number>;\n persist(opts: { key: string }): Promise<boolean>;\n incr(opts: { key: string }): Promise<number>;\n decr(opts: { key: string }): Promise<number>;\n incrBy(opts: { key: string; value: number }): Promise<number>;\n decrBy(opts: { key: string; value: number }): Promise<number>;\n}\n\n/** String value commands, including JSON-serialised object reads and batch get and set. `set` `expiresIn` is in milliseconds. */\nexport interface IRedisKeyValue {\n set<T>(opts: {\n key: string;\n value: T;\n options?: { log?: boolean; expiresIn?: number };\n }): Promise<void>;\n get<T = string>(opts: { key: string; transform?: (input: string) => T }): Promise<T | null>;\n\n del(opts: { keys: Array<string> }): Promise<number>;\n\n keys(opts: { key: string }): Promise<Array<string>>;\n\n getString(opts: { key: string }): Promise<string | null>;\n getStrings(opts: { keys: Array<string> }): Promise<(string | null)[]>;\n\n getObject<T>(opts: { key: string }): Promise<T | null>;\n getObjects(opts: { keys: Array<string> }): Promise<(unknown | null)[]>;\n\n mSet<T>(opts: {\n payload: Array<{ key: string; value: T }>;\n options?: { log?: boolean };\n }): Promise<void>;\n\n mGet<T = string>(opts: {\n keys: Array<string>;\n transform?: (input: string) => T;\n }): Promise<(T | null)[]>;\n}\n\n/** Hash commands (`HSET`, `HGET`, ...) on one key. */\nexport interface IRedisHash {\n hSet<T extends Record<string, unknown>>(opts: {\n key: string;\n value: T;\n options?: { log?: boolean };\n }): Promise<number>;\n hGetAll(opts: { key: string; transform?: <T, R>(input: T) => R }): Promise<unknown>;\n hGet(opts: { key: string; field: string }): Promise<string | null>;\n hDel(opts: { key: string; fields: Array<string> }): Promise<number>;\n hExists(opts: { key: string; field: string }): Promise<boolean>;\n hKeys(opts: { key: string }): Promise<string[]>;\n hVals(opts: { key: string }): Promise<string[]>;\n hIncrBy(opts: { key: string; field: string; value: number }): Promise<number>;\n hLen(opts: { key: string }): Promise<number>;\n}\n\n/** Set commands (`SADD`, `SMEMBERS`, ...) on one key. */\nexport interface IRedisSet {\n sAdd(opts: { key: string; members: Array<string | number> }): Promise<number>;\n sRem(opts: { key: string; members: Array<string | number> }): Promise<number>;\n sMembers(opts: { key: string }): Promise<string[]>;\n sIsMember(opts: { key: string; member: string | number }): Promise<boolean>;\n sCard(opts: { key: string }): Promise<number>;\n}\n\n/** List commands (`LPUSH`, `LRANGE`, ...) on one key. */\nexport interface IRedisList {\n lPush(opts: { key: string; values: Array<string | number> }): Promise<number>;\n rPush(opts: { key: string; values: Array<string | number> }): Promise<number>;\n lPop(opts: { key: string }): Promise<string | null>;\n rPop(opts: { key: string }): Promise<string | null>;\n lRange(opts: { key: string; start: number; stop: number }): Promise<string[]>;\n lLen(opts: { key: string }): Promise<number>;\n}\n\n/** Publish to many topics and subscribe on the helper client. `publish` serialises the payload as JSON and deflates it when `useCompress` is set. */\nexport interface IRedisPubSub {\n publish<T>(opts: { topics: Array<string>; payload: T; useCompress?: boolean }): Promise<void>;\n subscribe(opts: { topic: string }): void;\n unsubscribe(opts: { topic: string }): void;\n}\n\n/** RedisJSON commands (`JSON.SET`, `JSON.GET`, ...); the Redis server needs the JSON module. */\nexport interface IRedisJson {\n jSet<T>(opts: { key: string; path: string; value: T }): Promise<string | null>;\n jGet<T>(opts: {\n key: string;\n /** @default '$' */\n path?: string;\n }): Promise<T | null>;\n jDelete(opts: {\n key: string;\n /** @default '$' */\n path?: string;\n }): Promise<number>;\n jNumberIncreaseBy(opts: { key: string; path: string; value: number }): Promise<string | null>;\n jStringAppend(opts: { key: string; path: string; value: string }): Promise<number[] | null>;\n jPush<T>(opts: { key: string; path: string; value: T }): Promise<number[] | null>;\n jPop<T>(opts: { key: string; path: string }): Promise<T | null>;\n}\n\n/** Escape hatch to run any Redis command by name. */\nexport interface IRedisCommand {\n execute<R>(command: string, parameters?: Array<string | number | Buffer>): Promise<R>;\n}\n\n/** Full surface of a Redis helper, composed from the command-group interfaces; `name` is the identifier it was created with. */\nexport interface IRedisHelper\n extends\n IRedisConnection,\n IRedisKey,\n IRedisKeyValue,\n IRedisHash,\n IRedisSet,\n IRedisList,\n IRedisPubSub,\n IRedisJson,\n IRedisCommand {\n readonly name: string;\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';
2
2
  import type { TRedisSentinelRole } from './constants.js';
3
3
  import type { IRedisHelper } from './interfaces.js';
4
+ /** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */
4
5
  export type TRedisClient = Redis | Cluster;
6
+ /** Connection settings for a single Redis node. */
5
7
  export interface IRedisSingleHelperProps {
6
8
  name: string;
7
9
  host: string;
@@ -9,10 +11,14 @@ export interface IRedisSingleHelperProps {
9
11
  user?: string;
10
12
  /** Omit it for a Redis with no password. */
11
13
  password?: string;
14
+ /** @default 0 */
12
15
  database?: number;
16
+ /** @default true */
13
17
  autoConnect?: boolean;
18
+ /** @default 0 */
14
19
  maxRetry?: number;
15
20
  }
21
+ /** Connection settings for a Redis Cluster: the startup `nodes`, plus raw ioredis `clusterOptions` that override the helper defaults. */
16
22
  export interface IRedisClusterHelperProps {
17
23
  name: string;
18
24
  nodes: Array<{
@@ -20,26 +26,37 @@ export interface IRedisClusterHelperProps {
20
26
  port: string | number;
21
27
  password?: string;
22
28
  }>;
23
- /** Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`. */
29
+ /**
30
+ * Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`.
31
+ *
32
+ * @default true
33
+ */
24
34
  autoConnect?: boolean;
25
35
  clusterOptions?: ClusterOptions;
26
36
  }
37
+ /** Connection settings for Redis behind Sentinel. `redisOptions` overrides the helper defaults. */
27
38
  export interface IRedisSentinelHelperProps {
28
39
  name: string;
29
40
  sentinels: Array<{
30
41
  host: string;
42
+ /** @default 26379 */
31
43
  port?: string | number;
32
44
  }>;
33
45
  masterName: string;
46
+ /** @default RedisSentinelRoles.MASTER */
34
47
  role?: TRedisSentinelRole;
35
48
  password?: string;
36
49
  sentinelPassword?: string;
37
50
  sentinelUsername?: string;
51
+ /** @default 0 */
38
52
  database?: number;
53
+ /** @default true */
39
54
  autoConnect?: boolean;
55
+ /** @default 0 */
40
56
  maxRetry?: number;
41
57
  redisOptions?: Partial<RedisOptions>;
42
58
  }
59
+ /** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */
43
60
  export interface IRedisHelperCallbacks {
44
61
  onInitialized?: (opts: {
45
62
  name: string;
@@ -67,10 +84,13 @@ export interface IRedisHelperCallbacks {
67
84
  export interface IRedisModuleOption {
68
85
  module?: typeof import('ioredis');
69
86
  }
87
+ /** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
70
88
  export interface IRedisSingleHelperOptions extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
71
89
  }
90
+ /** Options for `RedisClusterHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
72
91
  export interface IRedisClusterHelperOptions extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
73
92
  }
93
+ /** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
74
94
  export interface IRedisSentinelHelperOptions extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
75
95
  }
76
96
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';\nimport type { TRedisSentinelRole } from './constants';\nimport type { IRedisHelper } from './interfaces';\n\nexport type TRedisClient = Redis | Cluster;\n\nexport interface IRedisSingleHelperProps {\n name: string;\n host: string;\n port: string | number;\n user?: string;\n /** Omit it for a Redis with no password. */\n password?: string;\n database?: number;\n autoConnect?: boolean;\n maxRetry?: number;\n}\n\nexport interface IRedisClusterHelperProps {\n name: string;\n nodes: Array<{ host: string; port: string | number; password?: string }>;\n /** Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`. */\n autoConnect?: boolean;\n clusterOptions?: ClusterOptions;\n}\n\nexport interface IRedisSentinelHelperProps {\n name: string;\n sentinels: Array<{ host: string; port?: string | number }>;\n masterName: string;\n role?: TRedisSentinelRole;\n password?: string;\n sentinelPassword?: string;\n sentinelUsername?: string;\n database?: number;\n autoConnect?: boolean;\n maxRetry?: number;\n redisOptions?: Partial<RedisOptions>;\n}\n\nexport interface IRedisHelperCallbacks {\n onInitialized?: (opts: { name: string; helper: IRedisHelper }) => void;\n onConnected?: (opts: { name: string; helper: IRedisHelper }) => void;\n onReady?: (opts: { name: string; helper: IRedisHelper }) => void;\n onError?: (opts: { name: string; helper: IRedisHelper; error: unknown }) => void;\n}\n\n/**\n * `ioredis` is an optional peer, loaded when a client is built. A `bun build --compile` binary\n * carries no `node_modules` to load it from: pass the module here, or register it once with\n * `ModuleUtility.register({ modules: { ioredis } })` at the entry.\n */\nexport interface IRedisModuleOption {\n module?: typeof import('ioredis');\n}\n\nexport interface IRedisSingleHelperOptions\n extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\nexport interface IRedisClusterHelperOptions\n extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\nexport interface IRedisSentinelHelperOptions\n extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';\nimport type { TRedisSentinelRole } from './constants';\nimport type { IRedisHelper } from './interfaces';\n\n/** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */\nexport type TRedisClient = Redis | Cluster;\n\n/** Connection settings for a single Redis node. */\nexport interface IRedisSingleHelperProps {\n name: string;\n host: string;\n port: string | number;\n user?: string;\n /** Omit it for a Redis with no password. */\n password?: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** @default 0 */\n maxRetry?: number;\n}\n\n/** Connection settings for a Redis Cluster: the startup `nodes`, plus raw ioredis `clusterOptions` that override the helper defaults. */\nexport interface IRedisClusterHelperProps {\n name: string;\n nodes: Array<{ host: string; port: string | number; password?: string }>;\n /**\n * Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`.\n *\n * @default true\n */\n autoConnect?: boolean;\n clusterOptions?: ClusterOptions;\n}\n\n/** Connection settings for Redis behind Sentinel. `redisOptions` overrides the helper defaults. */\nexport interface IRedisSentinelHelperProps {\n name: string;\n sentinels: Array<{\n host: string;\n /** @default 26379 */\n port?: string | number;\n }>;\n masterName: string;\n /** @default RedisSentinelRoles.MASTER */\n role?: TRedisSentinelRole;\n password?: string;\n sentinelPassword?: string;\n sentinelUsername?: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** @default 0 */\n maxRetry?: number;\n redisOptions?: Partial<RedisOptions>;\n}\n\n/** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */\nexport interface IRedisHelperCallbacks {\n onInitialized?: (opts: { name: string; helper: IRedisHelper }) => void;\n onConnected?: (opts: { name: string; helper: IRedisHelper }) => void;\n onReady?: (opts: { name: string; helper: IRedisHelper }) => void;\n onError?: (opts: { name: string; helper: IRedisHelper; error: unknown }) => void;\n}\n\n/**\n * `ioredis` is an optional peer, loaded when a client is built. A `bun build --compile` binary\n * carries no `node_modules` to load it from: pass the module here, or register it once with\n * `ModuleUtility.register({ modules: { ioredis } })` at the entry.\n */\nexport interface IRedisModuleOption {\n module?: typeof import('ioredis');\n}\n\n/** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSingleHelperOptions\n extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\n/** Options for `RedisClusterHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisClusterHelperOptions\n extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\n/** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSentinelHelperOptions\n extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
@@ -4,6 +4,7 @@ import { RedisModes } from './common/index.js';
4
4
  import type { IRedisClusterHelperOptions, IRedisSentinelHelperOptions, IRedisSingleHelperOptions } from './common/index.js';
5
5
  import { RedisSentinelHelper } from './sentinel/index.js';
6
6
  import { RedisSingleHelper } from './single/index.js';
7
+ /** Options for `RedisHelperFactory.create`: the helper options of one mode, discriminated by `mode`. */
7
8
  export type TCreateRedisHelperOptions = ({
8
9
  mode: typeof RedisModes.SINGLE;
9
10
  } & IRedisSingleHelperOptions) | ({
@@ -11,6 +12,7 @@ export type TCreateRedisHelperOptions = ({
11
12
  } & IRedisClusterHelperOptions) | ({
12
13
  mode: typeof RedisModes.SENTINEL;
13
14
  } & IRedisSentinelHelperOptions);
15
+ /** Creates the Redis helper for a `mode`; the overloads return the concrete helper type. Throws on an unsupported mode. */
14
16
  export declare class RedisHelperFactory {
15
17
  static create(opts: {
16
18
  mode: typeof RedisModes.SINGLE;
@@ -3,6 +3,7 @@ import { RedisClusterHelper } from './cluster/index.js';
3
3
  import { RedisModes } from './common/index.js';
4
4
  import { RedisSentinelHelper } from './sentinel/index.js';
5
5
  import { RedisSingleHelper } from './single/index.js';
6
+ /** Creates the Redis helper for a `mode`; the overloads return the concrete helper type. Throws on an unsupported mode. */
6
7
  export class RedisHelperFactory {
7
8
  static create(opts) {
8
9
  switch (opts.mode) {
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/redis/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAO7C,MAAM,OAAO,kBAAkB;IAe7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAC3C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvB,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;YACD,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,qDAAqD,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { type AbstractRedisHelper } from './base';\nimport { RedisClusterHelper } from './cluster';\nimport { RedisModes } from './common';\nimport type {\n IRedisClusterHelperOptions,\n IRedisSentinelHelperOptions,\n IRedisSingleHelperOptions,\n} from './common';\nimport { RedisSentinelHelper } from './sentinel';\nimport { RedisSingleHelper } from './single';\n\nexport type TCreateRedisHelperOptions =\n | ({ mode: typeof RedisModes.SINGLE } & IRedisSingleHelperOptions)\n | ({ mode: typeof RedisModes.CLUSTER } & IRedisClusterHelperOptions)\n | ({ mode: typeof RedisModes.SENTINEL } & IRedisSentinelHelperOptions);\n\nexport class RedisHelperFactory {\n static create(\n opts: { mode: typeof RedisModes.SINGLE } & IRedisSingleHelperOptions,\n ): RedisSingleHelper;\n\n static create(\n opts: { mode: typeof RedisModes.CLUSTER } & IRedisClusterHelperOptions,\n ): RedisClusterHelper;\n\n static create(\n opts: { mode: typeof RedisModes.SENTINEL } & IRedisSentinelHelperOptions,\n ): RedisSentinelHelper;\n\n static create(opts: TCreateRedisHelperOptions): AbstractRedisHelper;\n\n static create(opts: TCreateRedisHelperOptions): AbstractRedisHelper {\n switch (opts.mode) {\n case RedisModes.SINGLE: {\n return new RedisSingleHelper(opts);\n }\n case RedisModes.CLUSTER: {\n return new RedisClusterHelper(opts);\n }\n case RedisModes.SENTINEL: {\n return new RedisSentinelHelper(opts);\n }\n default: {\n throw getError({ message: '[RedisHelperFactory.create] Unsupported redis mode!' });\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/redis/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAQ7C,2HAA2H;AAC3H,MAAM,OAAO,kBAAkB;IAe7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAC3C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvB,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;YACD,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,qDAAqD,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { type AbstractRedisHelper } from './base';\nimport { RedisClusterHelper } from './cluster';\nimport { RedisModes } from './common';\nimport type {\n IRedisClusterHelperOptions,\n IRedisSentinelHelperOptions,\n IRedisSingleHelperOptions,\n} from './common';\nimport { RedisSentinelHelper } from './sentinel';\nimport { RedisSingleHelper } from './single';\n\n/** Options for `RedisHelperFactory.create`: the helper options of one mode, discriminated by `mode`. */\nexport type TCreateRedisHelperOptions =\n | ({ mode: typeof RedisModes.SINGLE } & IRedisSingleHelperOptions)\n | ({ mode: typeof RedisModes.CLUSTER } & IRedisClusterHelperOptions)\n | ({ mode: typeof RedisModes.SENTINEL } & IRedisSentinelHelperOptions);\n\n/** Creates the Redis helper for a `mode`; the overloads return the concrete helper type. Throws on an unsupported mode. */\nexport class RedisHelperFactory {\n static create(\n opts: { mode: typeof RedisModes.SINGLE } & IRedisSingleHelperOptions,\n ): RedisSingleHelper;\n\n static create(\n opts: { mode: typeof RedisModes.CLUSTER } & IRedisClusterHelperOptions,\n ): RedisClusterHelper;\n\n static create(\n opts: { mode: typeof RedisModes.SENTINEL } & IRedisSentinelHelperOptions,\n ): RedisSentinelHelper;\n\n static create(opts: TCreateRedisHelperOptions): AbstractRedisHelper;\n\n static create(opts: TCreateRedisHelperOptions): AbstractRedisHelper {\n switch (opts.mode) {\n case RedisModes.SINGLE: {\n return new RedisSingleHelper(opts);\n }\n case RedisModes.CLUSTER: {\n return new RedisClusterHelper(opts);\n }\n case RedisModes.SENTINEL: {\n return new RedisSentinelHelper(opts);\n }\n default: {\n throw getError({ message: '[RedisHelperFactory.create] Unsupported redis mode!' });\n }\n }\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
3
  import { type IRedisSentinelHelperOptions } from './../common/index.js';
4
+ /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
4
5
  export declare class RedisSentinelHelper extends AbstractRedisHelper<Redis> {
5
6
  constructor(opts: IRedisSentinelHelperOptions);
6
7
  getClient(): Redis;
@@ -2,6 +2,7 @@ import { ModuleUtility } from '../../../utilities/module.utility.js';
2
2
  import { ParseUtility } from '../../../utilities/parse.utility.js';
3
3
  import { AbstractRedisHelper } from './../base/index.js';
4
4
  import { RedisSentinelRoles } from './../common/index.js';
5
+ /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
5
6
  export class RedisSentinelHelper extends AbstractRedisHelper {
6
7
  constructor(opts) {
7
8
  const { name, sentinels, masterName, role = RedisSentinelRoles.MASTER, password, sentinelPassword, sentinelUsername, database = 0, autoConnect = true, maxRetry = 0, redisOptions = {}, } = opts;
@@ -1 +1 @@
1
- {"version":3,"file":"sentinel.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/sentinel.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAoC,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,OAAO,mBAAoB,SAAQ,mBAA0B;IACjE,YAAY,IAAiC;QAC3C,MAAM,EACJ,IAAI,EACJ,SAAS,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E,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;aAChE,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAe,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { type IRedisSentinelHelperOptions, RedisSentinelRoles } from './../common';\n\nexport class RedisSentinelHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSentinelHelperOptions) {\n const {\n name,\n sentinels,\n masterName,\n role = RedisSentinelRoles.MASTER,\n password,\n sentinelPassword,\n sentinelUsername,\n database = 0,\n autoConnect = true,\n maxRetry = 0,\n redisOptions = {},\n } = opts;\n\n const normalizedSentinels = sentinels.map((sentinel) => ({\n host: sentinel.host,\n port: ParseUtility.toInt({ input: sentinel.port ?? 26379 }),\n }));\n\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSentinelHelper.name,\n identifier: name,\n // Precedence (low -> high): framework defaults, the redisOptions escape hatch, then first-class fields. Optional auth fields are spread ONLY when provided, so a value set via redisOptions is not clobbered by an undefined first-class field.\n client: new ioredis.Redis({\n ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),\n ...redisOptions,\n sentinels: normalizedSentinels,\n name: masterName,\n role,\n db: database,\n lazyConnect: !autoConnect,\n ...(password === undefined ? {} : { password }),\n ...(sentinelPassword === undefined ? {} : { sentinelPassword }),\n ...(sentinelUsername === undefined ? {} : { sentinelUsername }),\n }),\n });\n }\n\n override getClient() {\n return this.client as Redis;\n }\n}\n"]}
1
+ {"version":3,"file":"sentinel.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/sentinel.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4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WAAW;gBACzB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;gBAC/C,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;gBAC/D,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;aAChE,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAe,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { type IRedisSentinelHelperOptions, RedisSentinelRoles } from './../common';\n\n/** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */\nexport class RedisSentinelHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSentinelHelperOptions) {\n const {\n name,\n sentinels,\n masterName,\n role = RedisSentinelRoles.MASTER,\n password,\n sentinelPassword,\n sentinelUsername,\n database = 0,\n autoConnect = true,\n maxRetry = 0,\n redisOptions = {},\n } = opts;\n\n const normalizedSentinels = sentinels.map((sentinel) => ({\n host: sentinel.host,\n port: ParseUtility.toInt({ input: sentinel.port ?? 26379 }),\n }));\n\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSentinelHelper.name,\n identifier: name,\n // Precedence (low -> high): framework defaults, the redisOptions escape hatch, then first-class fields. Optional auth fields are spread ONLY when provided, so a value set via redisOptions is not clobbered by an undefined first-class field.\n client: new ioredis.Redis({\n ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),\n ...redisOptions,\n sentinels: normalizedSentinels,\n name: masterName,\n role,\n db: database,\n lazyConnect: !autoConnect,\n ...(password === undefined ? {} : { password }),\n ...(sentinelPassword === undefined ? {} : { sentinelPassword }),\n ...(sentinelUsername === undefined ? {} : { sentinelUsername }),\n }),\n });\n }\n\n override getClient() {\n return this.client as Redis;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
3
  import { type IRedisSingleHelperOptions } from './../common/index.js';
4
+ /** Redis helper over one ioredis `Redis` client connected to a single node. */
4
5
  export declare class RedisSingleHelper extends AbstractRedisHelper<Redis> {
5
6
  constructor(opts: IRedisSingleHelperOptions);
6
7
  getClient(): Redis;
@@ -1,6 +1,7 @@
1
1
  import { ModuleUtility } from '../../../utilities/module.utility.js';
2
2
  import { ParseUtility } from '../../../utilities/parse.utility.js';
3
3
  import { AbstractRedisHelper } from './../base/index.js';
4
+ /** Redis helper over one ioredis `Redis` client connected to a single node. */
4
5
  export class RedisSingleHelper extends AbstractRedisHelper {
5
6
  constructor(opts) {
6
7
  const { name, host, port, password, database = 0, autoConnect = true, maxRetry = 0 } = opts;
@@ -1 +1 @@
1
- {"version":3,"file":"single.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/single.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD,MAAM,OAAO,iBAAkB,SAAQ,mBAA0B;IAC/D,YAAY,IAA+B;QACzC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;QAE5F,0FAA0F;QAC1F,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAA2B,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAEzF,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBACzC,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;aACtD,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAe,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { type IRedisSingleHelperOptions } from './../common';\n\nexport class RedisSingleHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSingleHelperOptions) {\n const { name, host, port, password, database = 0, autoConnect = true, maxRetry = 0 } = opts;\n\n // Optional peer, loaded when a client is built: an app with no Redis installs no ioredis.\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSingleHelper.name,\n identifier: name,\n client: new ioredis.Redis({\n name,\n host,\n port: ParseUtility.toInt({ input: port }),\n password,\n db: database,\n lazyConnect: !autoConnect,\n ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),\n }),\n });\n }\n\n override getClient() {\n return this.client as Redis;\n }\n}\n"]}
1
+ {"version":3,"file":"single.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/single.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD,+EAA+E;AAC/E,MAAM,OAAO,iBAAkB,SAAQ,mBAA0B;IAC/D,YAAY,IAA+B;QACzC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;QAE5F,0FAA0F;QAC1F,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAA2B,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAEzF,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBACzC,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;aACtD,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAe,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { type IRedisSingleHelperOptions } from './../common';\n\n/** Redis helper over one ioredis `Redis` client connected to a single node. */\nexport class RedisSingleHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSingleHelperOptions) {\n const { name, host, port, password, database = 0, autoConnect = true, maxRetry = 0 } = opts;\n\n // Optional peer, loaded when a client is built: an app with no Redis installs no ioredis.\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSingleHelper.name,\n identifier: name,\n client: new ioredis.Redis({\n name,\n host,\n port: ParseUtility.toInt({ input: port }),\n password,\n db: database,\n lazyConnect: !autoConnect,\n ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),\n }),\n });\n }\n\n override getClient() {\n return this.client as Redis;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { ILogger } from '../logger/index.js';
2
2
  import type { TRedisClient } from './common/index.js';
3
+ /** Static helpers for working with ioredis clients. */
3
4
  export declare class RedisUtility {
4
5
  /** Resolves once the client reaches `ready`; rejects on the first client error or when `timeoutMs` elapses. */
5
6
  static waitForReady(opts: {
@@ -2,6 +2,7 @@ import { HTTP } from '../../common/index.js';
2
2
  import { getError } from '../error/index.js';
3
3
  import { PromiseUtility } from '../../utilities/promise.utility.js';
4
4
  const REDIS_READY_TIMEOUT = 30_000;
5
+ /** Static helpers for working with ioredis clients. */
5
6
  export class RedisUtility {
6
7
  /** Resolves once the client reaches `ready`; rejects on the first client error or when `timeoutMs` elapses. */
7
8
  static waitForReady(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/modules/redis/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,MAAM,OAAO,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C,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAC/C,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,wJAAwJ;IACxJ,MAAM,CAAC,gBAAgB,CAAC,IAIvB;QACC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAExC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC7B,SAAS;YACX,CAAC;YAED,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common';\nimport { getError } from '@/modules/error';\nimport type { ILogger } from '@/modules/logger';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { type EventEmitter } from 'node:events';\nimport type { TRedisClient } from './common';\n\nconst REDIS_READY_TIMEOUT = 30_000;\n\nexport class RedisUtility {\n /** Resolves once the client reaches `ready`; rejects on the first client error or when `timeoutMs` elapses. */\n static waitForReady(opts: { client: TRedisClient; timeoutMs?: number }): Promise<void> {\n const { client, timeoutMs = REDIS_READY_TIMEOUT } = opts;\n\n return new Promise<void>((resolve, reject) => {\n if (client.status === 'ready') {\n resolve();\n return;\n }\n\n const emitter = client as EventEmitter;\n\n /** Run by every terminal branch: clients are long-lived and re-`configure()`d, so an unbound listener leaks (EventEmitter warns) and could fire on an already-settled promise. */\n const cleanups: Array<() => void> = [];\n const detach = () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n };\n\n const onReady = () => {\n detach();\n resolve();\n };\n\n const onError = (error: Error) => {\n detach();\n reject(error);\n };\n\n const timer = setTimeout(() => {\n detach();\n reject(\n getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `Redis client did not become ready within ${timeoutMs}ms (status: ${client.status})`,\n }),\n );\n }, timeoutMs);\n\n cleanups.push(\n () => clearTimeout(timer),\n () => emitter.removeListener('ready', onReady),\n () => emitter.removeListener('error', onError),\n );\n\n emitter.once('ready', onReady);\n emitter.once('error', onError);\n });\n }\n\n /** Kicks off connection for clients still parked in `wait` - duplicated clients inherit `lazyConnect` from their parent and never dial on their own. */\n static ensureConnecting(opts: {\n clients: TRedisClient[];\n logger?: ILogger;\n scope: string;\n }): void {\n const { clients, logger, scope } = opts;\n\n for (const client of clients) {\n if (client.status !== 'wait') {\n continue;\n }\n\n PromiseUtility.voidExecution({ logger, scope, execution: client.connect() });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/modules/redis/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,uDAAuD;AACvD,MAAM,OAAO,YAAY;IACvB,+GAA+G;IAC/G,MAAM,CAAC,YAAY,CAAC,IAAkD;QACpE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,mBAAmB,EAAE,GAAG,IAAI,CAAC;QAEzD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC9B,OAAO,EAAE,CAAC;gBAEV,OAAO;YACT,CAAC;YAED,MAAM,OAAO,GAAG,MAAsB,CAAC;YAEvC,kLAAkL;YAClL,MAAM,QAAQ,GAAsB,EAAE,CAAC;Y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AC7B,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC7B,SAAS;YACX,CAAC;YAED,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common';\nimport { getError } from '@/modules/error';\nimport type { ILogger } from '@/modules/logger';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { type EventEmitter } from 'node:events';\nimport type { TRedisClient } from './common';\n\nconst REDIS_READY_TIMEOUT = 30_000;\n\n/** Static helpers for working with ioredis clients. */\nexport class RedisUtility {\n /** Resolves once the client reaches `ready`; rejects on the first client error or when `timeoutMs` elapses. */\n static waitForReady(opts: { client: TRedisClient; timeoutMs?: number }): Promise<void> {\n const { client, timeoutMs = REDIS_READY_TIMEOUT } = opts;\n\n return new Promise<void>((resolve, reject) => {\n if (client.status === 'ready') {\n resolve();\n\n return;\n }\n\n const emitter = client as EventEmitter;\n\n /** Run by every terminal branch: clients are long-lived and re-`configure()`d, so an unbound listener leaks (EventEmitter warns) and could fire on an already-settled promise. */\n const cleanups: Array<() => void> = [];\n\n const detach = () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n };\n\n const onReady = () => {\n detach();\n resolve();\n };\n\n const onError = (error: Error) => {\n detach();\n reject(error);\n };\n\n const timer = setTimeout(() => {\n detach();\n reject(\n getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `Redis client did not become ready within ${timeoutMs}ms (status: ${client.status})`,\n }),\n );\n }, timeoutMs);\n\n cleanups.push(\n () => clearTimeout(timer),\n () => emitter.removeListener('ready', onReady),\n () => emitter.removeListener('error', onError),\n );\n\n emitter.once('ready', onReady);\n emitter.once('error', onError);\n });\n }\n\n /** Kicks off connection for clients still parked in `wait` - duplicated clients inherit `lazyConnect` from their parent and never dial on their own. */\n static ensureConnecting(opts: {\n clients: TRedisClient[];\n logger?: ILogger;\n scope: string;\n }): void {\n const { clients, logger, scope } = opts;\n\n for (const client of clients) {\n if (client.status !== 'wait') {\n continue;\n }\n\n PromiseUtility.voidExecution({ logger, scope, execution: client.connect() });\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { TConstValue } from '../../../common/index.js';
2
+ /** How the retry delay grows between attempts. */
2
3
  export declare class RetryBackoffStrategies {
3
4
  static readonly FIXED = "fixed";
4
5
  static readonly LINEAR = "linear";
@@ -8,7 +9,9 @@ export declare class RetryBackoffStrategies {
8
9
  static readonly SCHEME_SET: Set<string>;
9
10
  static isValid(value: string): value is TRetryBackoffStrategy;
10
11
  }
12
+ /** Union of the `RetryBackoffStrategies` values. */
11
13
  export type TRetryBackoffStrategy = TConstValue<typeof RetryBackoffStrategies>;
14
+ /** How randomness is applied to a computed retry delay. */
12
15
  export declare class RetryJitterModes {
13
16
  /** The computed delay is used as-is. */
14
17
  static readonly NONE = "none";
@@ -19,5 +22,6 @@ export declare class RetryJitterModes {
19
22
  static readonly SCHEME_SET: Set<string>;
20
23
  static isValid(value: string): value is TRetryJitterMode;
21
24
  }
25
+ /** Union of the `RetryJitterModes` values. */
22
26
  export type TRetryJitterMode = TConstValue<typeof RetryJitterModes>;
23
27
  //# sourceMappingURL=constants.d.ts.map
@@ -1,3 +1,4 @@
1
+ /** How the retry delay grows between attempts. */
1
2
  export class RetryBackoffStrategies {
2
3
  static { this.FIXED = 'fixed'; }
3
4
  static { this.LINEAR = 'linear'; }
@@ -14,6 +15,7 @@ export class RetryBackoffStrategies {
14
15
  return this.SCHEME_SET.has(value);
15
16
  }
16
17
  }
18
+ /** How randomness is applied to a computed retry delay. */
17
19
  export class RetryJitterModes {
18
20
  /** The computed delay is used as-is. */
19
21
  static { this.NONE = 'none'; }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/retry/common/constants.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,sBAAsB;aACjB,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,gBAAW,GAAG,aAAa,CAAC;IAE5C,4FAA4F;aAC5E,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,MAAM,OAAO,gBAAgB;IAC3B,wCAAwC;aACxB,SAAI,GAAG,MAAM,CAAC;IAE9B,6EAA6E;aAC7D,SAAI,GAAG,MAAM,CAAC;IAE9B,8FAA8F;aAC9E,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common';\n\nexport class RetryBackoffStrategies {\n static readonly FIXED = 'fixed';\n static readonly LINEAR = 'linear';\n static readonly EXPONENTIAL = 'exponential';\n\n /** An explicit per-attempt cap schedule, e.g. [250, 1000, 4000]; the last entry repeats. */\n static readonly SCHEDULE = 'schedule';\n\n static readonly SCHEME_SET = new Set<string>([\n this.FIXED,\n this.LINEAR,\n this.EXPONENTIAL,\n this.SCHEDULE,\n ]);\n\n static isValid(value: string): value is TRetryBackoffStrategy {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport type TRetryBackoffStrategy = TConstValue<typeof RetryBackoffStrategies>;\n\nexport class RetryJitterModes {\n /** The computed delay is used as-is. */\n static readonly NONE = 'none';\n\n /** Uniform random in [0, delay) - decorrelates a thundering herd hardest. */\n static readonly FULL = 'full';\n\n /** delay/2 + uniform random in [0, delay/2) - jittered but never less than half the delay. */\n static readonly EQUAL = 'equal';\n\n static readonly SCHEME_SET = new Set<string>([this.NONE, this.FULL, this.EQUAL]);\n\n static isValid(value: string): value is TRetryJitterMode {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport type TRetryJitterMode = TConstValue<typeof RetryJitterModes>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/retry/common/constants.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,MAAM,OAAO,sBAAsB;aACjB,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,gBAAW,GAAG,aAAa,CAAC;IAE5C,4FAA4F;aAC5E,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,2DAA2D;AAC3D,MAAM,OAAO,gBAAgB;IAC3B,wCAAwC;aACxB,SAAI,GAAG,MAAM,CAAC;IAE9B,6EAA6E;aAC7D,SAAI,GAAG,MAAM,CAAC;IAE9B,8FAA8F;aAC9E,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common';\n\n/** How the retry delay grows between attempts. */\nexport class RetryBackoffStrategies {\n static readonly FIXED = 'fixed';\n static readonly LINEAR = 'linear';\n static readonly EXPONENTIAL = 'exponential';\n\n /** An explicit per-attempt cap schedule, e.g. [250, 1000, 4000]; the last entry repeats. */\n static readonly SCHEDULE = 'schedule';\n\n static readonly SCHEME_SET = new Set<string>([\n this.FIXED,\n this.LINEAR,\n this.EXPONENTIAL,\n this.SCHEDULE,\n ]);\n\n static isValid(value: string): value is TRetryBackoffStrategy {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Union of the `RetryBackoffStrategies` values. */\nexport type TRetryBackoffStrategy = TConstValue<typeof RetryBackoffStrategies>;\n\n/** How randomness is applied to a computed retry delay. */\nexport class RetryJitterModes {\n /** The computed delay is used as-is. */\n static readonly NONE = 'none';\n\n /** Uniform random in [0, delay) - decorrelates a thundering herd hardest. */\n static readonly FULL = 'full';\n\n /** delay/2 + uniform random in [0, delay/2) - jittered but never less than half the delay. */\n static readonly EQUAL = 'equal';\n\n static readonly SCHEME_SET = new Set<string>([this.NONE, this.FULL, this.EQUAL]);\n\n static isValid(value: string): value is TRetryJitterMode {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Union of the `RetryJitterModes` values. */\nexport type TRetryJitterMode = TConstValue<typeof RetryJitterModes>;\n"]}
@@ -1,18 +1,32 @@
1
1
  import type { TRetryBackoffStrategy, TRetryJitterMode } from './constants.js';
2
+ /** Retry delay settings; every field is optional. */
2
3
  export interface IRetryBackoffOptions {
3
- /** Default EXPONENTIAL. */
4
+ /** @default RetryBackoffStrategies.EXPONENTIAL */
4
5
  strategy?: TRetryBackoffStrategy;
5
- /** First delay, default 250ms. LINEAR adds it per attempt; EXPONENTIAL multiplies from it. */
6
+ /**
7
+ * First delay in milliseconds. LINEAR adds it per attempt; EXPONENTIAL multiplies from it.
8
+ *
9
+ * @default 250
10
+ */
6
11
  initialDelayMs?: number;
7
- /** EXPONENTIAL growth factor, default 2. Ignored by other strategies. */
12
+ /**
13
+ * EXPONENTIAL growth factor. Ignored by other strategies.
14
+ *
15
+ * @default 2
16
+ */
8
17
  multiplier?: number;
9
- /** Upper cap applied BEFORE jitter, default 30000ms. */
18
+ /**
19
+ * Upper cap in milliseconds, applied BEFORE jitter.
20
+ *
21
+ * @default 30_000
22
+ */
10
23
  maxDelayMs?: number;
11
24
  /** Required when strategy is SCHEDULE; the last entry repeats for later attempts. */
12
25
  scheduleMs?: readonly number[];
13
- /** Default FULL. */
26
+ /** @default RetryJitterModes.FULL */
14
27
  jitter?: TRetryJitterMode;
15
28
  }
29
+ /** State passed to retry callbacks: the attempt number, the error that triggered the retry and the elapsed time in milliseconds. */
16
30
  export interface IRetryContext {
17
31
  attempt: number;
18
32
  error: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/retry/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TRetryBackoffStrategy, TRetryJitterMode } from './constants';\n\nexport interface IRetryBackoffOptions {\n /** Default EXPONENTIAL. */\n strategy?: TRetryBackoffStrategy;\n\n /** First delay, default 250ms. LINEAR adds it per attempt; EXPONENTIAL multiplies from it. */\n initialDelayMs?: number;\n\n /** EXPONENTIAL growth factor, default 2. Ignored by other strategies. */\n multiplier?: number;\n\n /** Upper cap applied BEFORE jitter, default 30000ms. */\n maxDelayMs?: number;\n\n /** Required when strategy is SCHEDULE; the last entry repeats for later attempts. */\n scheduleMs?: readonly number[];\n\n /** Default FULL. */\n jitter?: TRetryJitterMode;\n}\n\nexport interface IRetryContext {\n attempt: number;\n error: unknown;\n elapsedMs: number;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/retry/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TRetryBackoffStrategy, TRetryJitterMode } from './constants';\n\n/** Retry delay settings; every field is optional. */\nexport interface IRetryBackoffOptions {\n /** @default RetryBackoffStrategies.EXPONENTIAL */\n strategy?: TRetryBackoffStrategy;\n\n /**\n * First delay in milliseconds. LINEAR adds it per attempt; EXPONENTIAL multiplies from it.\n *\n * @default 250\n */\n initialDelayMs?: number;\n\n /**\n * EXPONENTIAL growth factor. Ignored by other strategies.\n *\n * @default 2\n */\n multiplier?: number;\n\n /**\n * Upper cap in milliseconds, applied BEFORE jitter.\n *\n * @default 30_000\n */\n maxDelayMs?: number;\n\n /** Required when strategy is SCHEDULE; the last entry repeats for later attempts. */\n scheduleMs?: readonly number[];\n\n /** @default RetryJitterModes.FULL */\n jitter?: TRetryJitterMode;\n}\n\n/** State passed to retry callbacks: the attempt number, the error that triggered the retry and the elapsed time in milliseconds. */\nexport interface IRetryContext {\n attempt: number;\n error: unknown;\n elapsedMs: number;\n}\n"]}
@@ -32,11 +32,11 @@ export declare class RetryHelper extends BaseHelper {
32
32
  signal?: AbortSignal;
33
33
  logger?: ILogger;
34
34
  operation: string;
35
- /** Default 3. */
35
+ /** @default 3 */
36
36
  maxAttempts?: number;
37
- /** Total budget across attempts AND sleeps. Default: unlimited. */
37
+ /** Total budget across attempts AND sleeps. Unlimited when omitted. */
38
38
  maxTotalMs?: number;
39
- /** Per-attempt race. Default: no per-attempt timeout. */
39
+ /** Per-attempt race. No per-attempt timeout when omitted. */
40
40
  perAttemptTimeoutMs?: number;
41
41
  backoff?: IRetryBackoffOptions;
42
42
  execution: (context: {
@@ -55,7 +55,7 @@ export declare class RetryHelper extends BaseHelper {
55
55
  signal?: AbortSignal;
56
56
  logger?: ILogger;
57
57
  operation: string;
58
- /** Default 3. */
58
+ /** @default 3 */
59
59
  maxAttempts?: number;
60
60
  /** Bounds when a NEW attempt may start; it never interrupts an attempt already in flight, so the first execution always runs to completion - a budget of 0 just means "no retries". */
61
61
  maxTotalMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../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S,CAAC;YACzC,IAAI,OAAO,IAAI,WAAW,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC;gBACpF,MAAM;YACR,CAAC;YAED,MAAM;gBACJ,EAAE,GAAG,CAAC,uBAAuB,CAAC;iBAC7B,KAAK,CAAC,4CAA4C,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAE3E,MAAM,WAAW,GAAG,WAAW,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YAC5E,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,WAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,MAAM;YACJ,EAAE,GAAG,CAAC,uBAAuB,CAAC;aAC7B,IAAI,CAAC,wDAAwD,EAAE,SAAS,CAAC,CAAC;QAC7E,OAAO,UAAe,CAAC;IACzB,CAAC","sourcesContent":["import type { ValueOrPromise } from '@/common';\nimport { getError } from '@/modules/error';\nimport type { ILogger } from '@/modules/logger';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { RetryBackoffStrategies, RetryJitterModes } from './common/constants';\nimport type { IRetryBackoffOptions, IRetryContext } from './common/types';\nimport { BaseHelper } from '@/modules/base';\n\ntype TRetryAttemptOutcome<T> =\n | { isResolved: true; value: T }\n | { isResolved: false; error: unknown; isRetryAllowed: boolean };\n\n/**\n * Static members call each other through the class name (`RetryHelper.xxx`), never `this` - a\n * detached static method loses its `this` binding.\n */\nexport class RetryHelper extends BaseHelper {\n private static readonly RETRY_TIMEOUT_MARKER = Symbol.for('@venizia/ignis-helpers:retry-timeout');\n\n /** True when `error` is a per-attempt timeout raised by `runWithTimeout`/`executeWithRetry`. */\n static isRetryTimeoutError(error: unknown): boolean {\n return typeof error === 'object' && error !== null && RetryHelper.RETRY_TIMEOUT_MARKER in error;\n }\n\n private static buildTimeoutError(opts: { operation: string; timeoutMs: number }) {\n const error = getError({\n message: `[runWithTimeout][${opts.operation}] Timed out after ${opts.timeoutMs}ms`,\n });\n Object.defineProperty(error, RetryHelper.RETRY_TIMEOUT_MARKER, { value: true });\n return error;\n }\n\n private static throwIfAborted(opts: { operation: string; signal?: AbortSignal }) {\n if (opts.signal?.aborted) {\n throw getError({\n message: `[executeWithRetry][${opts.operation}] Aborted | Reason: ${String(opts.signal.reason ?? 'unknown')}`,\n });\n }\n }\n\n /** `sleep` that wakes up early (and rejects) when `signal` aborts mid-wait. */\n private static async sleepWithSignal(opts: {\n ms: number;\n operation: string;\n signal?: AbortSignal;\n }) {\n const { ms, operation, signal } = opts;\n\n if (!signal) {\n await PromiseUtility.sleep({ ms });\n return;\n }\n\n RetryHelper.throwIfAborted({ operation, signal });\n\n // The listener is removed in `finally` rather than by the timer callback - the two would otherwise have to reference each other, and a leaked listener on a long-lived signal accumulates across retries.\n let removeAbortListener = () => {};\n\n try {\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n\n const onAbort = () => {\n clearTimeout(timer);\n reject(\n getError({\n message: `[executeWithRetry][${operation}] Aborted during backoff | Reason: ${String(signal.reason ?? 'unknown')}`,\n }),\n );\n };\n\n removeAbortListener = () => signal.removeEventListener('abort', onAbort);\n signal.addEventListener('abort', onAbort, { once: true });\n });\n } finally {\n removeAbortListener();\n }\n }\n\n /** Races `execution` against `timeoutMs` (`<= 0`/omitted = no timeout). The losing execution keeps running - JS promises cannot be cancelled - so pass `signal` through for cooperative cancellation. */\n static async runWithTimeout<T>(opts: {\n operation: string;\n timeoutMs?: number;\n execution: () => ValueOrPromise<T>;\n }): Promise<T> {\n const { operation, timeoutMs, execution } = opts;\n\n if (!timeoutMs || timeoutMs <= 0) {\n return execution();\n }\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => {\n reject(RetryHelper.buildTimeoutError({ operation, timeoutMs }));\n }, timeoutMs);\n });\n\n try {\n const result = await Promise.race([Promise.resolve().then(execution), timeoutPromise]);\n return result;\n } finally {\n clearTimeout(timer);\n }\n }\n\n /** The pre-jitter delay for `attempt` (1-based, i.e. the delay AFTER attempt N failed). */\n static computeBackoffDelayMs(opts: { attempt: number; backoff?: IRetryBackoffOptions }): number {\n const { attempt } = opts;\n const {\n strategy = RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs = 250,\n multiplier = 2,\n maxDelayMs = 30_000,\n scheduleMs,\n jitter = RetryJitterModes.FULL,\n } = opts.backoff ?? {};\n\n let delayMs: number;\n switch (strategy) {\n case RetryBackoffStrategies.FIXED: {\n delayMs = initialDelayMs;\n break;\n }\n case RetryBackoffStrategies.LINEAR: {\n delayMs = initialDelayMs * attempt;\n break;\n }\n case RetryBackoffStrategies.EXPONENTIAL: {\n delayMs = initialDelayMs * Math.pow(multiplier, attempt - 1);\n break;\n }\n case RetryBackoffStrategies.SCHEDULE: {\n if (!scheduleMs?.length) {\n throw getError({\n message:\n '[computeBackoffDelayMs] strategy SCHEDULE requires a non-empty backoff.scheduleMs',\n });\n }\n delayMs = scheduleMs[Math.min(attempt - 1, scheduleMs.length - 1)];\n break;\n }\n default: {\n throw getError({\n message: `[computeBackoffDelayMs] Unknown backoff strategy '${strategy}' | Expected one of: ${[...RetryBackoffStrategies.SCHEME_SET].join(', ')}`,\n });\n }\n }\n\n delayMs = Math.min(delayMs, maxDelayMs);\n\n if (delayMs <= 0) {\n return 0;\n }\n\n switch (jitter) {\n case RetryJitterModes.NONE: {\n return delayMs;\n }\n case RetryJitterModes.FULL: {\n return Math.floor(Math.random() * delayMs);\n }\n case RetryJitterModes.EQUAL: {\n const half = delayMs / 2;\n return Math.floor(half + Math.random() * half);\n }\n default: {\n throw getError({\n message: `[computeBackoffDelayMs] Unknown jitter mode '${jitter}' | Expected one of: ${[...RetryJitterModes.SCHEME_SET].join(', ')}`,\n });\n }\n }\n }\n\n /** One `executeWithRetry` attempt and everything that follows a failure: `shouldRetry` refusing rethrows, otherwise the bounds are checked and - when another attempt is allowed - the retry is logged, `onRetry` awaited and the backoff slept, all before returning. */\n private static async runRetryAttempt<T>(opts: {\n attempt: number;\n attemptTimeoutMs?: number;\n startedAt: number;\n deadline?: number;\n maxAttempts: number;\n operation: string;\n signal?: AbortSignal;\n logger?: ILogger;\n backoff?: IRetryBackoffOptions;\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n shouldRetry?: (context: IRetryContext) => boolean;\n onRetry?: (context: IRetryContext & { nextDelayMs: number }) => ValueOrPromise<void>;\n }): Promise<TRetryAttemptOutcome<T>> {\n const {\n attempt,\n attemptTimeoutMs,\n startedAt,\n deadline,\n maxAttempts,\n operation,\n signal,\n logger,\n backoff,\n execution,\n shouldRetry,\n onRetry,\n } = opts;\n\n try {\n const value = await RetryHelper.runWithTimeout({\n operation,\n timeoutMs: attemptTimeoutMs,\n execution: () => execution({ attempt, signal }),\n });\n return { isResolved: true, value };\n } catch (error) {\n const elapsedMs = Date.now() - startedAt;\n\n if (shouldRetry && !shouldRetry({ attempt, error, elapsedMs })) {\n throw error;\n }\n\n if (attempt >= maxAttempts) {\n return { isResolved: false, error, isRetryAllowed: false };\n }\n\n const nextDelayMs = RetryHelper.computeBackoffDelayMs({ attempt, backoff });\n if (deadline && Date.now() + nextDelayMs >= deadline) {\n return { isResolved: false, error, isRetryAllowed: false };\n }\n\n logger\n ?.for('executeWithRetry')\n .debug(\n '[%s] Attempt %d/%d failed - retrying in %dms | Error: %s',\n operation,\n attempt,\n maxAttempts,\n nextDelayMs,\n error,\n );\n\n await onRetry?.({ attempt, error, elapsedMs, nextDelayMs });\n\n if (nextDelayMs > 0) {\n await RetryHelper.sleepWithSignal({ ms: nextDelayMs, operation, signal });\n }\n\n return { isResolved: false, error, isRetryAllowed: true };\n }\n }\n\n /** Retries `execution` with backoff, bounded by `maxAttempts`/`maxTotalMs`. JS cannot cancel a running promise - `signal` only stops between attempts/sleeps, so a timed-out execution keeps running unless it honors the signal itself. */\n static async executeWithRetry<T>(opts: {\n signal?: AbortSignal;\n logger?: ILogger;\n operation: string;\n\n /** Default 3. */\n maxAttempts?: number;\n\n /** Total budget across attempts AND sleeps. Default: unlimited. */\n maxTotalMs?: number;\n\n /** Per-attempt race. Default: no per-attempt timeout. */\n perAttemptTimeoutMs?: number;\n\n backoff?: IRetryBackoffOptions;\n\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n\n /** Return `false` to stop retrying and rethrow `context.error` immediately. */\n shouldRetry?: (context: IRetryContext) => boolean;\n\n /** Observability hook, awaited before the backoff sleep. */\n onRetry?: (context: IRetryContext & { nextDelayMs: number }) => ValueOrPromise<void>;\n }): Promise<T> {\n const {\n operation,\n execution,\n maxAttempts = 3,\n maxTotalMs,\n perAttemptTimeoutMs,\n backoff,\n shouldRetry,\n onRetry,\n signal,\n logger,\n } = opts;\n\n if (maxAttempts < 1) {\n throw getError({\n message: `[executeWithRetry][${operation}] maxAttempts must be >= 1 | Got: ${maxAttempts}`,\n });\n }\n\n const startedAt = Date.now();\n // `!== undefined`, never truthiness: a budget of 0 - or a negative one, which is what `deadline - Date.now()` yields under load - means NO time left, not unlimited time.\n const deadline = maxTotalMs !== undefined ? startedAt + maxTotalMs : undefined;\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n RetryHelper.throwIfAborted({ operation, signal });\n\n const remainingMs = deadline ? deadline - Date.now() : undefined;\n if (remainingMs !== undefined && remainingMs <= 0) {\n break;\n }\n\n let attemptTimeoutMs = perAttemptTimeoutMs;\n if (remainingMs !== undefined) {\n attemptTimeoutMs = attemptTimeoutMs ? Math.min(attemptTimeoutMs, remainingMs) : remainingMs;\n }\n\n const outcome = await RetryHelper.runRetryAttempt({\n attempt,\n attemptTimeoutMs,\n startedAt,\n deadline,\n maxAttempts,\n operation,\n signal,\n logger,\n backoff,\n execution,\n shouldRetry,\n onRetry,\n });\n\n if (outcome.isResolved) {\n return outcome.value;\n }\n\n lastError = outcome.error;\n if (!outcome.isRetryAllowed) {\n break;\n }\n }\n\n const elapsedMs = Date.now() - startedAt;\n\n // The budget can run out BEFORE the first attempt (an expired `maxTotalMs`), leaving no error to rethrow; `throw undefined` would detonate inside the caller's own handler on `error.message`.\n if (lastError === undefined) {\n throw getError({\n message: `[executeWithRetry][${operation}] Time budget exhausted before any attempt ran | maxTotalMs: ${maxTotalMs}`,\n });\n }\n\n logger\n ?.for('executeWithRetry')\n .warn('[%s] Exhausted retries | Elapsed: %dms | Error: %s', operation, elapsedMs, lastError);\n\n throw lastError;\n }\n\n /** Retries `execution` while `until(result)` returns false - for read-after-write staleness behind a replicated pool. Never worse than a single un-retried call: on exhaustion the LAST result is returned rather than an error, and a thrown error propagates immediately instead of being retried. Only wrap idempotent operations. */\n static async executeWithRetryUntil<T>(opts: {\n signal?: AbortSignal;\n logger?: ILogger;\n operation: string;\n\n /** Default 3. */\n maxAttempts?: number;\n\n /** Bounds when a NEW attempt may start; it never interrupts an attempt already in flight, so the first execution always runs to completion - a budget of 0 just means \"no retries\". */\n maxTotalMs?: number;\n\n backoff?: IRetryBackoffOptions;\n\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n\n /** Retry while this returns false. */\n until: (result: T) => boolean;\n }): Promise<T> {\n const {\n signal,\n logger,\n operation,\n maxAttempts = 3,\n maxTotalMs,\n backoff,\n execution,\n until,\n } = opts;\n\n if (maxAttempts < 1) {\n throw getError({\n message: `[executeWithRetryUntil][${operation}] maxAttempts must be >= 1 | Got: ${maxAttempts}`,\n });\n }\n\n // Surfaced before the first execution - a misconfigured backoff discovered mid-loop would discard an already-fetched result.\n RetryHelper.computeBackoffDelayMs({ attempt: 1, backoff });\n\n const startedAt = Date.now();\n let lastResult: T | undefined;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n RetryHelper.throwIfAborted({ operation, signal });\n\n const result2 = await execution({ attempt, signal });\n lastResult = result2;\n if (until(lastResult)) {\n return lastResult;\n }\n\n const elapsedMs = Date.now() - startedAt;\n if (attempt >= maxAttempts || (maxTotalMs !== undefined && elapsedMs >= maxTotalMs)) {\n break;\n }\n\n logger\n ?.for('executeWithRetryUntil')\n .debug('[%s] until condition not met | Attempt: %d', operation, attempt);\n\n const nextDelayMs = RetryHelper.computeBackoffDelayMs({ attempt, backoff });\n if (nextDelayMs > 0) {\n await RetryHelper.sleepWithSignal({ ms: nextDelayMs, operation, signal });\n }\n }\n\n logger\n ?.for('executeWithRetryUntil')\n .warn('[%s] Exhausted retries - returning last (stale) result', operation);\n return lastResult as T;\n }\n}\n"]}
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/modules/retry/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAM5C;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;aACjB,yBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAElG,gGAAgG;IAChG,MAAM,CAAC,mBAAmB,CAAC,KAAc;QACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,CAAC,oBAAoB,IAAI,KAAK,CAAC;IAClG,CAAC;IAEO,MAAM,CAAC,iBAAiB,CAAC,IAA8C;QAC7E,MAAM,KAAK,GAAG,QAAQ,CAAC;YACrB,OAAO,EAAE,oBAAoB,IAAI,CAAC,SAAS,qBAAqB,IAAI,CAAC,SAAS,IAAI;SACnF,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,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IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,UAAyB,CAAC;QAE9B,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;YACxD,WAAW,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;YAElD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YACrD,UAAU,GAAG,OAAO,CAAC;YAErB,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;gBACtB,OAAO,UAAU,CAAC;YACpB,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YAEzC,IAAI,OAAO,IAAI,WAAW,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC;gBACpF,MAAM;YACR,CAAC;YAED,MAAM;gBACJ,EAAE,GAAG,CAAC,uBAAuB,CAAC;iBAC7B,KAAK,CAAC,4CAA4C,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAE3E,MAAM,WAAW,GAAG,WAAW,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YAE5E,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,WAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,MAAM;YACJ,EAAE,GAAG,CAAC,uBAAuB,CAAC;aAC7B,IAAI,CAAC,wDAAwD,EAAE,SAAS,CAAC,CAAC;QAE7E,OAAO,UAAe,CAAC;IACzB,CAAC","sourcesContent":["import type { ValueOrPromise } from '@/common';\nimport { getError } from '@/modules/error';\nimport type { ILogger } from '@/modules/logger';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { RetryBackoffStrategies, RetryJitterModes } from './common/constants';\nimport type { IRetryBackoffOptions, IRetryContext } from './common/types';\nimport { BaseHelper } from '@/modules/base';\n\ntype TRetryAttemptOutcome<T> =\n | { isResolved: true; value: T }\n | { isResolved: false; error: unknown; isRetryAllowed: boolean };\n\n/**\n * Static members call each other through the class name (`RetryHelper.xxx`), never `this` - a\n * detached static method loses its `this` binding.\n */\nexport class RetryHelper extends BaseHelper {\n private static readonly RETRY_TIMEOUT_MARKER = Symbol.for('@venizia/ignis-helpers:retry-timeout');\n\n /** True when `error` is a per-attempt timeout raised by `runWithTimeout`/`executeWithRetry`. */\n static isRetryTimeoutError(error: unknown): boolean {\n return typeof error === 'object' && error !== null && RetryHelper.RETRY_TIMEOUT_MARKER in error;\n }\n\n private static buildTimeoutError(opts: { operation: string; timeoutMs: number }) {\n const error = getError({\n message: `[runWithTimeout][${opts.operation}] Timed out after ${opts.timeoutMs}ms`,\n });\n Object.defineProperty(error, RetryHelper.RETRY_TIMEOUT_MARKER, { value: true });\n\n return error;\n }\n\n private static throwIfAborted(opts: { operation: string; signal?: AbortSignal }) {\n if (opts.signal?.aborted) {\n throw getError({\n message: `[executeWithRetry][${opts.operation}] Aborted | Reason: ${String(opts.signal.reason ?? 'unknown')}`,\n });\n }\n }\n\n /** `sleep` that wakes up early (and rejects) when `signal` aborts mid-wait. */\n private static async sleepWithSignal(opts: {\n ms: number;\n operation: string;\n signal?: AbortSignal;\n }) {\n const { ms, operation, signal } = opts;\n\n if (!signal) {\n await PromiseUtility.sleep({ ms });\n\n return;\n }\n\n RetryHelper.throwIfAborted({ operation, signal });\n\n // The listener is removed in `finally` rather than by the timer callback - the two would otherwise have to reference each other, and a leaked listener on a long-lived signal accumulates across retries.\n let removeAbortListener = () => {};\n\n try {\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n\n const onAbort = () => {\n clearTimeout(timer);\n reject(\n getError({\n message: `[executeWithRetry][${operation}] Aborted during backoff | Reason: ${String(signal.reason ?? 'unknown')}`,\n }),\n );\n };\n\n removeAbortListener = () => signal.removeEventListener('abort', onAbort);\n signal.addEventListener('abort', onAbort, { once: true });\n });\n } finally {\n removeAbortListener();\n }\n }\n\n /** Races `execution` against `timeoutMs` (`<= 0`/omitted = no timeout). The losing execution keeps running - JS promises cannot be cancelled - so pass `signal` through for cooperative cancellation. */\n static async runWithTimeout<T>(opts: {\n operation: string;\n timeoutMs?: number;\n execution: () => ValueOrPromise<T>;\n }): Promise<T> {\n const { operation, timeoutMs, execution } = opts;\n\n if (!timeoutMs || timeoutMs <= 0) {\n return execution();\n }\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => {\n reject(RetryHelper.buildTimeoutError({ operation, timeoutMs }));\n }, timeoutMs);\n });\n\n try {\n const result = await Promise.race([Promise.resolve().then(execution), timeoutPromise]);\n\n return result;\n } finally {\n clearTimeout(timer);\n }\n }\n\n /** The pre-jitter delay for `attempt` (1-based, i.e. the delay AFTER attempt N failed). */\n static computeBackoffDelayMs(opts: { attempt: number; backoff?: IRetryBackoffOptions }): number {\n const { attempt } = opts;\n const {\n strategy = RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs = 250,\n multiplier = 2,\n maxDelayMs = 30_000,\n scheduleMs,\n jitter = RetryJitterModes.FULL,\n } = opts.backoff ?? {};\n\n let delayMs: number;\n\n switch (strategy) {\n case RetryBackoffStrategies.FIXED: {\n delayMs = initialDelayMs;\n break;\n }\n case RetryBackoffStrategies.LINEAR: {\n delayMs = initialDelayMs * attempt;\n break;\n }\n case RetryBackoffStrategies.EXPONENTIAL: {\n delayMs = initialDelayMs * Math.pow(multiplier, attempt - 1);\n break;\n }\n case RetryBackoffStrategies.SCHEDULE: {\n if (!scheduleMs?.length) {\n throw getError({\n message:\n '[computeBackoffDelayMs] strategy SCHEDULE requires a non-empty backoff.scheduleMs',\n });\n }\n\n delayMs = scheduleMs[Math.min(attempt - 1, scheduleMs.length - 1)];\n break;\n }\n default: {\n throw getError({\n message: `[computeBackoffDelayMs] Unknown backoff strategy '${strategy}' | Expected one of: ${[...RetryBackoffStrategies.SCHEME_SET].join(', ')}`,\n });\n }\n }\n\n delayMs = Math.min(delayMs, maxDelayMs);\n\n if (delayMs <= 0) {\n return 0;\n }\n\n switch (jitter) {\n case RetryJitterModes.NONE: {\n return delayMs;\n }\n case RetryJitterModes.FULL: {\n return Math.floor(Math.random() * delayMs);\n }\n case RetryJitterModes.EQUAL: {\n const half = delayMs / 2;\n\n return Math.floor(half + Math.random() * half);\n }\n default: {\n throw getError({\n message: `[computeBackoffDelayMs] Unknown jitter mode '${jitter}' | Expected one of: ${[...RetryJitterModes.SCHEME_SET].join(', ')}`,\n });\n }\n }\n }\n\n /** One `executeWithRetry` attempt and everything that follows a failure: `shouldRetry` refusing rethrows, otherwise the bounds are checked and - when another attempt is allowed - the retry is logged, `onRetry` awaited and the backoff slept, all before returning. */\n private static async runRetryAttempt<T>(opts: {\n attempt: number;\n attemptTimeoutMs?: number;\n startedAt: number;\n deadline?: number;\n maxAttempts: number;\n operation: string;\n signal?: AbortSignal;\n logger?: ILogger;\n backoff?: IRetryBackoffOptions;\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n shouldRetry?: (context: IRetryContext) => boolean;\n onRetry?: (context: IRetryContext & { nextDelayMs: number }) => ValueOrPromise<void>;\n }): Promise<TRetryAttemptOutcome<T>> {\n const {\n attempt,\n attemptTimeoutMs,\n startedAt,\n deadline,\n maxAttempts,\n operation,\n signal,\n logger,\n backoff,\n execution,\n shouldRetry,\n onRetry,\n } = opts;\n\n try {\n const value = await RetryHelper.runWithTimeout({\n operation,\n timeoutMs: attemptTimeoutMs,\n execution: () => execution({ attempt, signal }),\n });\n\n return { isResolved: true, value };\n } catch (error) {\n const elapsedMs = Date.now() - startedAt;\n\n if (shouldRetry && !shouldRetry({ attempt, error, elapsedMs })) {\n throw error;\n }\n\n if (attempt >= maxAttempts) {\n return { isResolved: false, error, isRetryAllowed: false };\n }\n\n const nextDelayMs = RetryHelper.computeBackoffDelayMs({ attempt, backoff });\n\n if (deadline && Date.now() + nextDelayMs >= deadline) {\n return { isResolved: false, error, isRetryAllowed: false };\n }\n\n logger\n ?.for('executeWithRetry')\n .debug(\n '[%s] Attempt %d/%d failed - retrying in %dms | Error: %s',\n operation,\n attempt,\n maxAttempts,\n nextDelayMs,\n error,\n );\n\n await onRetry?.({ attempt, error, elapsedMs, nextDelayMs });\n\n if (nextDelayMs > 0) {\n await RetryHelper.sleepWithSignal({ ms: nextDelayMs, operation, signal });\n }\n\n return { isResolved: false, error, isRetryAllowed: true };\n }\n }\n\n /** Retries `execution` with backoff, bounded by `maxAttempts`/`maxTotalMs`. JS cannot cancel a running promise - `signal` only stops between attempts/sleeps, so a timed-out execution keeps running unless it honors the signal itself. */\n static async executeWithRetry<T>(opts: {\n signal?: AbortSignal;\n logger?: ILogger;\n operation: string;\n\n /** @default 3 */\n maxAttempts?: number;\n\n /** Total budget across attempts AND sleeps. Unlimited when omitted. */\n maxTotalMs?: number;\n\n /** Per-attempt race. No per-attempt timeout when omitted. */\n perAttemptTimeoutMs?: number;\n\n backoff?: IRetryBackoffOptions;\n\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n\n /** Return `false` to stop retrying and rethrow `context.error` immediately. */\n shouldRetry?: (context: IRetryContext) => boolean;\n\n /** Observability hook, awaited before the backoff sleep. */\n onRetry?: (context: IRetryContext & { nextDelayMs: number }) => ValueOrPromise<void>;\n }): Promise<T> {\n const {\n operation,\n execution,\n maxAttempts = 3,\n maxTotalMs,\n perAttemptTimeoutMs,\n backoff,\n shouldRetry,\n onRetry,\n signal,\n logger,\n } = opts;\n\n if (maxAttempts < 1) {\n throw getError({\n message: `[executeWithRetry][${operation}] maxAttempts must be >= 1 | Got: ${maxAttempts}`,\n });\n }\n\n const startedAt = Date.now();\n // `!== undefined`, never truthiness: a budget of 0 - or a negative one, which is what `deadline - Date.now()` yields under load - means NO time left, not unlimited time.\n const deadline = maxTotalMs !== undefined ? startedAt + maxTotalMs : undefined;\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n RetryHelper.throwIfAborted({ operation, signal });\n\n const remainingMs = deadline ? deadline - Date.now() : undefined;\n\n if (remainingMs !== undefined && remainingMs <= 0) {\n break;\n }\n\n let attemptTimeoutMs = perAttemptTimeoutMs;\n\n if (remainingMs !== undefined) {\n attemptTimeoutMs = attemptTimeoutMs ? Math.min(attemptTimeoutMs, remainingMs) : remainingMs;\n }\n\n const outcome = await RetryHelper.runRetryAttempt({\n attempt,\n attemptTimeoutMs,\n startedAt,\n deadline,\n maxAttempts,\n operation,\n signal,\n logger,\n backoff,\n execution,\n shouldRetry,\n onRetry,\n });\n\n if (outcome.isResolved) {\n return outcome.value;\n }\n\n lastError = outcome.error;\n\n if (!outcome.isRetryAllowed) {\n break;\n }\n }\n\n const elapsedMs = Date.now() - startedAt;\n\n // The budget can run out BEFORE the first attempt (an expired `maxTotalMs`), leaving no error to rethrow; `throw undefined` would detonate inside the caller's own handler on `error.message`.\n if (lastError === undefined) {\n throw getError({\n message: `[executeWithRetry][${operation}] Time budget exhausted before any attempt ran | maxTotalMs: ${maxTotalMs}`,\n });\n }\n\n logger\n ?.for('executeWithRetry')\n .warn('[%s] Exhausted retries | Elapsed: %dms | Error: %s', operation, elapsedMs, lastError);\n\n throw lastError;\n }\n\n /** Retries `execution` while `until(result)` returns false - for read-after-write staleness behind a replicated pool. Never worse than a single un-retried call: on exhaustion the LAST result is returned rather than an error, and a thrown error propagates immediately instead of being retried. Only wrap idempotent operations. */\n static async executeWithRetryUntil<T>(opts: {\n signal?: AbortSignal;\n logger?: ILogger;\n operation: string;\n\n /** @default 3 */\n maxAttempts?: number;\n\n /** Bounds when a NEW attempt may start; it never interrupts an attempt already in flight, so the first execution always runs to completion - a budget of 0 just means \"no retries\". */\n maxTotalMs?: number;\n\n backoff?: IRetryBackoffOptions;\n\n execution: (context: { attempt: number; signal?: AbortSignal }) => ValueOrPromise<T>;\n\n /** Retry while this returns false. */\n until: (result: T) => boolean;\n }): Promise<T> {\n const {\n signal,\n logger,\n operation,\n maxAttempts = 3,\n maxTotalMs,\n backoff,\n execution,\n until,\n } = opts;\n\n if (maxAttempts < 1) {\n throw getError({\n message: `[executeWithRetryUntil][${operation}] maxAttempts must be >= 1 | Got: ${maxAttempts}`,\n });\n }\n\n // Surfaced before the first execution - a misconfigured backoff discovered mid-loop would discard an already-fetched result.\n RetryHelper.computeBackoffDelayMs({ attempt: 1, backoff });\n\n const startedAt = Date.now();\n let lastResult: T | undefined;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n RetryHelper.throwIfAborted({ operation, signal });\n\n const result2 = await execution({ attempt, signal });\n lastResult = result2;\n\n if (until(lastResult)) {\n return lastResult;\n }\n\n const elapsedMs = Date.now() - startedAt;\n\n if (attempt >= maxAttempts || (maxTotalMs !== undefined && elapsedMs >= maxTotalMs)) {\n break;\n }\n\n logger\n ?.for('executeWithRetryUntil')\n .debug('[%s] until condition not met | Attempt: %d', operation, attempt);\n\n const nextDelayMs = RetryHelper.computeBackoffDelayMs({ attempt, backoff });\n\n if (nextDelayMs > 0) {\n await RetryHelper.sleepWithSignal({ ms: nextDelayMs, operation, signal });\n }\n }\n\n logger\n ?.for('executeWithRetryUntil')\n .warn('[%s] Exhausted retries - returning last (stale) result', operation);\n\n return lastResult as T;\n }\n}\n"]}