@venizia/ignis-helpers 0.4.8-8 → 0.4.8

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 (199) hide show
  1. package/README.md +2 -3
  2. package/dist/esm/common/constants/app.d.ts +1 -3
  3. package/dist/esm/common/constants/app.js +1 -11
  4. package/dist/esm/common/constants/app.js.map +1 -1
  5. package/dist/esm/common/constants/http.d.ts +4 -0
  6. package/dist/esm/common/constants/http.js +5 -0
  7. package/dist/esm/common/constants/http.js.map +1 -1
  8. package/dist/esm/common/constants/mime.d.ts +0 -2
  9. package/dist/esm/common/constants/mime.js +0 -4
  10. package/dist/esm/common/constants/mime.js.map +1 -1
  11. package/dist/esm/common/redact.js.map +1 -1
  12. package/dist/esm/common/types/class.d.ts +14 -12
  13. package/dist/esm/common/types/class.js.map +1 -1
  14. package/dist/esm/common/types/const-value.d.ts +3 -3
  15. package/dist/esm/common/types/const-value.js.map +1 -1
  16. package/dist/esm/common/types/field-mapping.d.ts +6 -8
  17. package/dist/esm/common/types/field-mapping.js +0 -10
  18. package/dist/esm/common/types/field-mapping.js.map +1 -1
  19. package/dist/esm/common/types/index.d.ts +1 -0
  20. package/dist/esm/common/types/index.js +1 -0
  21. package/dist/esm/common/types/index.js.map +1 -1
  22. package/dist/esm/common/types/injection.d.ts +1 -1
  23. package/dist/esm/common/types/injection.js.map +1 -1
  24. package/dist/esm/common/types/json.d.ts +14 -0
  25. package/dist/esm/common/types/json.js +2 -0
  26. package/dist/esm/common/types/json.js.map +1 -0
  27. package/dist/esm/common/types/utility.d.ts +0 -4
  28. package/dist/esm/common/types/utility.js.map +1 -1
  29. package/dist/esm/modules/env/app-env.d.ts +17 -8
  30. package/dist/esm/modules/env/app-env.js +18 -15
  31. package/dist/esm/modules/env/app-env.js.map +1 -1
  32. package/dist/esm/modules/env/common/types.d.ts +22 -6
  33. package/dist/esm/modules/env/common/types.js.map +1 -1
  34. package/dist/esm/modules/logger/base/abstract.d.ts +6 -7
  35. package/dist/esm/modules/logger/base/abstract.js.map +1 -1
  36. package/dist/esm/modules/logger/base/base.d.ts +7 -8
  37. package/dist/esm/modules/logger/base/base.js.map +1 -1
  38. package/dist/esm/modules/logger/base/console.d.ts +6 -7
  39. package/dist/esm/modules/logger/base/console.js.map +1 -1
  40. package/dist/esm/modules/logger/common/types.d.ts +7 -7
  41. package/dist/esm/modules/logger/common/types.js.map +1 -1
  42. package/dist/esm/modules/logger/factory.js.map +1 -1
  43. package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
  44. package/dist/esm/modules/logger/hf/logger.d.ts +6 -7
  45. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  46. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  47. package/dist/esm/modules/logger/pino/destination.d.ts +1 -1
  48. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  49. package/dist/esm/modules/logger/pino/logger.d.ts +1 -2
  50. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  51. package/dist/esm/modules/logger/winston/formats.js +2 -2
  52. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  53. package/dist/esm/modules/logger/winston/logger.d.ts +1 -2
  54. package/dist/esm/modules/logger/winston/logger.js.map +1 -1
  55. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -1
  56. package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -1
  57. package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
  58. package/dist/esm/modules/network/http-request/common/constants.d.ts +0 -2
  59. package/dist/esm/modules/network/http-request/common/constants.js +0 -4
  60. package/dist/esm/modules/network/http-request/common/constants.js.map +1 -1
  61. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +6 -6
  62. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  63. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +2 -3
  64. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
  65. package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts +1 -1
  66. package/dist/esm/modules/network/http-request/fetcher/common/types.js.map +1 -1
  67. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +1 -2
  68. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +5 -6
  69. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  70. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts +4 -4
  71. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +1 -1
  72. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  73. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +3 -5
  74. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +0 -8
  75. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  76. package/dist/esm/modules/network/utilities/query-string.d.ts +2 -2
  77. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  78. package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts +0 -2
  79. package/dist/esm/modules/network/utilities/url-safety/common/constants.js +0 -4
  80. package/dist/esm/modules/network/utilities/url-safety/common/constants.js.map +1 -1
  81. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  82. package/dist/esm/modules/queue/bullmq/helper.d.ts +23 -10
  83. package/dist/esm/modules/queue/bullmq/helper.js +57 -10
  84. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  85. package/dist/esm/modules/queue/common/constants.d.ts +6 -2
  86. package/dist/esm/modules/queue/common/constants.js +6 -4
  87. package/dist/esm/modules/queue/common/constants.js.map +1 -1
  88. package/dist/esm/modules/queue/internal/sequential/common/types.d.ts +2 -4
  89. package/dist/esm/modules/queue/internal/sequential/common/types.js +0 -4
  90. package/dist/esm/modules/queue/internal/sequential/common/types.js.map +1 -1
  91. package/dist/esm/modules/queue/kafka/base.d.ts +1 -1
  92. package/dist/esm/modules/queue/kafka/base.js +13 -2
  93. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  94. package/dist/esm/modules/queue/kafka/common/constants.d.ts +0 -4
  95. package/dist/esm/modules/queue/kafka/common/constants.js +0 -8
  96. package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
  97. package/dist/esm/modules/redis/base/abstract.helper.d.ts +13 -2
  98. package/dist/esm/modules/redis/base/abstract.helper.js +53 -45
  99. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  100. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -2
  101. package/dist/esm/modules/redis/cluster/cluster.helper.js +21 -9
  102. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  103. package/dist/esm/modules/redis/cluster/index.d.ts +1 -0
  104. package/dist/esm/modules/redis/cluster/index.js +1 -0
  105. package/dist/esm/modules/redis/cluster/index.js.map +1 -1
  106. package/dist/esm/modules/redis/cluster/types.d.ts +20 -0
  107. package/dist/esm/modules/redis/cluster/types.js +2 -0
  108. package/dist/esm/modules/redis/cluster/types.js.map +1 -0
  109. package/dist/esm/modules/redis/common/constants.d.ts +15 -19
  110. package/dist/esm/modules/redis/common/constants.js +16 -18
  111. package/dist/esm/modules/redis/common/constants.js.map +1 -1
  112. package/dist/esm/modules/redis/common/types.d.ts +10 -60
  113. package/dist/esm/modules/redis/common/types.js.map +1 -1
  114. package/dist/esm/modules/redis/factory.d.ts +7 -25
  115. package/dist/esm/modules/redis/factory.js +9 -18
  116. package/dist/esm/modules/redis/factory.js.map +1 -1
  117. package/dist/esm/modules/redis/sentinel/constants.d.ts +14 -0
  118. package/dist/esm/modules/redis/sentinel/constants.js +11 -0
  119. package/dist/esm/modules/redis/sentinel/constants.js.map +1 -0
  120. package/dist/esm/modules/redis/sentinel/index.d.ts +2 -0
  121. package/dist/esm/modules/redis/sentinel/index.js +2 -0
  122. package/dist/esm/modules/redis/sentinel/index.js.map +1 -1
  123. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -2
  124. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +25 -15
  125. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  126. package/dist/esm/modules/redis/sentinel/types.d.ts +26 -0
  127. package/dist/esm/modules/redis/sentinel/types.js +2 -0
  128. package/dist/esm/modules/redis/sentinel/types.js.map +1 -0
  129. package/dist/esm/modules/redis/single/index.d.ts +1 -0
  130. package/dist/esm/modules/redis/single/index.js +1 -0
  131. package/dist/esm/modules/redis/single/index.js.map +1 -1
  132. package/dist/esm/modules/redis/single/single.helper.d.ts +1 -2
  133. package/dist/esm/modules/redis/single/single.helper.js +5 -6
  134. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  135. package/dist/esm/modules/redis/single/types.d.ts +15 -0
  136. package/dist/esm/modules/redis/single/types.js +2 -0
  137. package/dist/esm/modules/redis/single/types.js.map +1 -0
  138. package/dist/esm/modules/secrets/base/abstract.helper.js +6 -1
  139. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  140. package/dist/esm/modules/secrets/common/types/registration.d.ts +25 -6
  141. package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
  142. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -1
  143. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
  144. package/dist/esm/modules/secrets/factory.js +7 -6
  145. package/dist/esm/modules/secrets/factory.js.map +1 -1
  146. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +12 -10
  147. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +50 -25
  148. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  149. package/dist/esm/modules/socket/socket-io/client/browser-helper.js.map +1 -1
  150. package/dist/esm/modules/socket/socket-io/common/types/client.d.ts +2 -2
  151. package/dist/esm/modules/socket/socket-io/common/types/client.js.map +1 -1
  152. package/dist/esm/modules/socket/socket-io/common/types/server.d.ts +3 -1
  153. package/dist/esm/modules/socket/socket-io/common/types/server.js.map +1 -1
  154. package/dist/esm/modules/socket/socket-io/server/helper.d.ts +2 -2
  155. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  156. package/dist/esm/modules/storage/base.d.ts +26 -57
  157. package/dist/esm/modules/storage/base.js +76 -127
  158. package/dist/esm/modules/storage/base.js.map +1 -1
  159. package/dist/esm/modules/storage/bun-s3/helper.d.ts +22 -37
  160. package/dist/esm/modules/storage/bun-s3/helper.js +131 -132
  161. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  162. package/dist/esm/modules/storage/bun-s3/utility.d.ts +15 -8
  163. package/dist/esm/modules/storage/bun-s3/utility.js +66 -47
  164. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  165. package/dist/esm/modules/storage/common/constants.d.ts +36 -2
  166. package/dist/esm/modules/storage/common/constants.js +34 -4
  167. package/dist/esm/modules/storage/common/constants.js.map +1 -1
  168. package/dist/esm/modules/storage/common/errors.d.ts +26 -0
  169. package/dist/esm/modules/storage/common/errors.js +23 -0
  170. package/dist/esm/modules/storage/common/errors.js.map +1 -1
  171. package/dist/esm/modules/storage/common/types.d.ts +99 -57
  172. package/dist/esm/modules/storage/common/types.js.map +1 -1
  173. package/dist/esm/modules/storage/common/utility.d.ts +8 -0
  174. package/dist/esm/modules/storage/common/utility.js +14 -2
  175. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  176. package/dist/esm/modules/storage/disk/helper.d.ts +4 -8
  177. package/dist/esm/modules/storage/disk/helper.js +3 -1
  178. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  179. package/dist/esm/modules/storage/in-memory/helper.d.ts +2 -3
  180. package/dist/esm/modules/storage/in-memory/helper.js.map +1 -1
  181. package/dist/esm/modules/worker-thread/common/types.d.ts +2 -2
  182. package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
  183. package/dist/esm/modules/worker-thread/thread/abstract.d.ts +2 -2
  184. package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
  185. package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -1
  186. package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
  187. package/dist/esm/utilities/module.utility.d.ts +8 -5
  188. package/dist/esm/utilities/module.utility.js +5 -1
  189. package/dist/esm/utilities/module.utility.js.map +1 -1
  190. package/dist/esm/utilities/parse.utility.d.ts +34 -6
  191. package/dist/esm/utilities/parse.utility.js +82 -15
  192. package/dist/esm/utilities/parse.utility.js.map +1 -1
  193. package/dist/esm/utilities/performance.utility.d.ts +3 -3
  194. package/dist/esm/utilities/performance.utility.js.map +1 -1
  195. package/dist/esm/utilities/promise.utility.d.ts +1 -1
  196. package/dist/esm/utilities/promise.utility.js.map +1 -1
  197. package/dist/esm/utilities/request.utility.d.ts +9 -11
  198. package/dist/esm/utilities/request.utility.js.map +1 -1
  199. package/package.json +3 -3
@@ -1,60 +1,19 @@
1
- import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';
2
- import type { TRedisSentinelRole } from './constants.js';
1
+ import type { Cluster, Redis } from 'ioredis';
3
2
  import type { IRedisHelper } from './interfaces.js';
4
3
  /** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */
5
4
  export type TRedisClient = Redis | Cluster;
6
- /** Connection settings for a single Redis node. */
7
- export interface IRedisSingleHelperProps {
8
- name: string;
5
+ /** The address of one Redis node. A node has no credentials of its own: ioredis reads only the host and port of a Sentinel endpoint, and applies a cluster node's credentials to the startup nodes only. */
6
+ export interface IRedisNode {
9
7
  host: string;
10
- port: string | number;
11
- user?: string;
12
- /** Omit it for a Redis with no password. */
13
- password?: string;
14
- /** @default 0 */
15
- database?: number;
16
- /** @default true */
17
- autoConnect?: boolean;
18
- /** @default 0 */
19
- maxRetry?: number;
8
+ /** @default RedisDefaults.PORT (6379), or RedisSentinelDefaults.PORT (26379) for a Sentinel node */
9
+ port?: string | number;
20
10
  }
21
- /** Connection settings for a Redis Cluster: the startup `nodes`, plus raw ioredis `clusterOptions` that override the helper defaults. */
22
- export interface IRedisClusterHelperProps {
23
- name: string;
24
- nodes: Array<{
25
- host: string;
26
- port: string | number;
27
- password?: string;
28
- }>;
29
- /**
30
- * Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`.
31
- *
32
- * @default true
33
- */
34
- autoConnect?: boolean;
35
- clusterOptions?: ClusterOptions;
36
- }
37
- /** Connection settings for Redis behind Sentinel. `redisOptions` overrides the helper defaults. */
38
- export interface IRedisSentinelHelperProps {
39
- name: string;
40
- sentinels: Array<{
41
- host: string;
42
- /** @default 26379 */
43
- port?: string | number;
44
- }>;
45
- masterName: string;
46
- /** @default RedisSentinelRoles.MASTER */
47
- role?: TRedisSentinelRole;
11
+ /** An ACL user and its password. Omit both to authenticate as the `default` user with no password. */
12
+ export interface IRedisCredentials {
13
+ /** The Redis ACL user, with `password`. Omit it to authenticate as the `default` user. */
14
+ username?: string;
15
+ /** Omit it for a Redis with no password. */
48
16
  password?: string;
49
- sentinelPassword?: string;
50
- sentinelUsername?: string;
51
- /** @default 0 */
52
- database?: number;
53
- /** @default true */
54
- autoConnect?: boolean;
55
- /** @default 0 */
56
- maxRetry?: number;
57
- redisOptions?: Partial<RedisOptions>;
58
17
  }
59
18
  /** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */
60
19
  export interface IRedisHelperCallbacks {
@@ -84,13 +43,4 @@ export interface IRedisHelperCallbacks {
84
43
  export interface IRedisModuleOption {
85
44
  module?: typeof import('ioredis');
86
45
  }
87
- /** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
88
- export interface IRedisSingleHelperOptions extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
89
- }
90
- /** Options for `RedisClusterHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
91
- export interface IRedisClusterHelperOptions extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
92
- }
93
- /** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
94
- export interface IRedisSentinelHelperOptions extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
95
- }
96
46
  //# 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\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"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Cluster, Redis } from 'ioredis';\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/** The address of one Redis node. A node has no credentials of its own: ioredis reads only the host and port of a Sentinel endpoint, and applies a cluster node's credentials to the startup nodes only. */\nexport interface IRedisNode {\n host: string;\n /** @default RedisDefaults.PORT (6379), or RedisSentinelDefaults.PORT (26379) for a Sentinel node */\n port?: string | number;\n}\n\n/** An ACL user and its password. Omit both to authenticate as the `default` user with no password. */\nexport interface IRedisCredentials {\n /** The Redis ACL user, with `password`. Omit it to authenticate as the `default` user. */\n username?: string;\n /** Omit it for a Redis with no password. */\n password?: string;\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"]}
@@ -1,28 +1,10 @@
1
- import { type AbstractRedisHelper } from './base/index.js';
2
- import { RedisClusterHelper } from './cluster/index.js';
3
- import { RedisModes } from './common/index.js';
4
- import type { IRedisClusterHelperOptions, IRedisSentinelHelperOptions, IRedisSingleHelperOptions } from './common/index.js';
5
- import { RedisSentinelHelper } from './sentinel/index.js';
6
- import { RedisSingleHelper } from './single/index.js';
7
- /** Options for `RedisHelperFactory.create`: the helper options of one mode, discriminated by `mode`. */
8
- export type TCreateRedisHelperOptions = ({
9
- mode: typeof RedisModes.SINGLE;
10
- } & IRedisSingleHelperOptions) | ({
11
- mode: typeof RedisModes.CLUSTER;
12
- } & IRedisClusterHelperOptions) | ({
13
- mode: typeof RedisModes.SENTINEL;
14
- } & IRedisSentinelHelperOptions);
15
- /** Creates the Redis helper for a `mode`; the overloads return the concrete helper type. Throws on an unsupported mode. */
1
+ import { RedisClusterHelper, type IRedisClusterHelperOptions } from './cluster/index.js';
2
+ import { RedisSentinelHelper, type IRedisSentinelHelperOptions } from './sentinel/index.js';
3
+ import { RedisSingleHelper, type IRedisSingleHelperOptions } from './single/index.js';
4
+ /** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */
16
5
  export declare class RedisHelperFactory {
17
- static create(opts: {
18
- mode: typeof RedisModes.SINGLE;
19
- } & IRedisSingleHelperOptions): RedisSingleHelper;
20
- static create(opts: {
21
- mode: typeof RedisModes.CLUSTER;
22
- } & IRedisClusterHelperOptions): RedisClusterHelper;
23
- static create(opts: {
24
- mode: typeof RedisModes.SENTINEL;
25
- } & IRedisSentinelHelperOptions): RedisSentinelHelper;
26
- static create(opts: TCreateRedisHelperOptions): AbstractRedisHelper;
6
+ static single(opts: IRedisSingleHelperOptions): RedisSingleHelper;
7
+ static cluster(opts: IRedisClusterHelperOptions): RedisClusterHelper;
8
+ static sentinel(opts: IRedisSentinelHelperOptions): RedisSentinelHelper;
27
9
  }
28
10
  //# sourceMappingURL=factory.d.ts.map
@@ -1,25 +1,16 @@
1
- import { getError } from '../error/index.js';
2
1
  import { RedisClusterHelper } from './cluster/index.js';
3
- import { RedisModes } from './common/index.js';
4
2
  import { RedisSentinelHelper } from './sentinel/index.js';
5
3
  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. */
4
+ /** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */
7
5
  export class RedisHelperFactory {
8
- static create(opts) {
9
- switch (opts.mode) {
10
- case RedisModes.SINGLE: {
11
- return new RedisSingleHelper(opts);
12
- }
13
- case RedisModes.CLUSTER: {
14
- return new RedisClusterHelper(opts);
15
- }
16
- case RedisModes.SENTINEL: {
17
- return new RedisSentinelHelper(opts);
18
- }
19
- default: {
20
- throw getError({ message: '[RedisHelperFactory.create] Unsupported redis mode!' });
21
- }
22
- }
6
+ static single(opts) {
7
+ return new RedisSingleHelper(opts);
8
+ }
9
+ static cluster(opts) {
10
+ return new RedisClusterHelper(opts);
11
+ }
12
+ static sentinel(opts) {
13
+ return new RedisSentinelHelper(opts);
23
14
  }
24
15
  }
25
16
  //# sourceMappingURL=factory.js.map
@@ -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;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
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/redis/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmC,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAoC,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAkC,MAAM,UAAU,CAAC;AAE7E,0HAA0H;AAC1H,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAC3C,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAgC;QAC7C,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAiC;QAC/C,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { RedisClusterHelper, type IRedisClusterHelperOptions } from './cluster';\nimport { RedisSentinelHelper, type IRedisSentinelHelperOptions } from './sentinel';\nimport { RedisSingleHelper, type IRedisSingleHelperOptions } from './single';\n\n/** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */\nexport class RedisHelperFactory {\n static single(opts: IRedisSingleHelperOptions) {\n return new RedisSingleHelper(opts);\n }\n\n static cluster(opts: IRedisClusterHelperOptions) {\n return new RedisClusterHelper(opts);\n }\n\n static sentinel(opts: IRedisSentinelHelperOptions) {\n return new RedisSentinelHelper(opts);\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { TConstValue } from '../../../common/types/index.js';
2
+ /** Role of the node a Sentinel-backed client connects to. */
3
+ export declare class RedisSentinelRoles {
4
+ static readonly MASTER = "master";
5
+ static readonly SLAVE = "slave";
6
+ }
7
+ /** Union of the `RedisSentinelRoles` values. */
8
+ export type TRedisSentinelRole = TConstValue<typeof RedisSentinelRoles>;
9
+ /** Defaults of the Sentinel helper. */
10
+ export declare class RedisSentinelDefaults {
11
+ /** The port of a Sentinel process when none is given. */
12
+ static readonly PORT = 26379;
13
+ }
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Role of the node a Sentinel-backed client connects to. */
2
+ export class RedisSentinelRoles {
3
+ static { this.MASTER = 'master'; }
4
+ static { this.SLAVE = 'slave'; }
5
+ }
6
+ /** Defaults of the Sentinel helper. */
7
+ export class RedisSentinelDefaults {
8
+ /** The port of a Sentinel process when none is given. */
9
+ static { this.PORT = 26379; }
10
+ }
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/constants.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,OAAO,kBAAkB;aACb,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;;AAMlC,uCAAuC;AACvC,MAAM,OAAO,qBAAqB;IAChC,yDAAyD;aACzC,SAAI,GAAG,KAAK,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Role of the node a Sentinel-backed client connects to. */\nexport class RedisSentinelRoles {\n static readonly MASTER = 'master';\n static readonly SLAVE = 'slave';\n}\n\n/** Union of the `RedisSentinelRoles` values. */\nexport type TRedisSentinelRole = TConstValue<typeof RedisSentinelRoles>;\n\n/** Defaults of the Sentinel helper. */\nexport class RedisSentinelDefaults {\n /** The port of a Sentinel process when none is given. */\n static readonly PORT = 26379;\n}\n"]}
@@ -1,2 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
1
3
  export * from './sentinel.helper.js';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
1
3
  export * from './sentinel.helper.js';
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './sentinel.helper';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './constants';\nexport * from './types';\nexport * from './sentinel.helper';\n"]}
@@ -1,9 +1,8 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
- import { type IRedisSentinelHelperOptions } from './../common/index.js';
3
+ import type { IRedisSentinelHelperOptions } from './types.js';
4
4
  /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
5
5
  export declare class RedisSentinelHelper extends AbstractRedisHelper<Redis> {
6
6
  constructor(opts: IRedisSentinelHelperOptions);
7
- getClient(): Redis;
8
7
  }
9
8
  //# sourceMappingURL=sentinel.helper.d.ts.map
@@ -1,37 +1,47 @@
1
+ import { getError } from '../../error/index.js';
1
2
  import { ModuleUtility } from '../../../utilities/module.utility.js';
2
3
  import { ParseUtility } from '../../../utilities/parse.utility.js';
3
4
  import { AbstractRedisHelper } from './../base/index.js';
4
- import { RedisSentinelRoles } from './../common/index.js';
5
+ import { RedisDefaults } from './../common/index.js';
6
+ import { RedisSentinelDefaults, RedisSentinelRoles } from './constants.js';
5
7
  /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
6
8
  export class RedisSentinelHelper extends AbstractRedisHelper {
7
9
  constructor(opts) {
8
- const { name, sentinels, masterName, role = RedisSentinelRoles.MASTER, password, sentinelPassword, sentinelUsername, database = 0, autoConnect = true, maxRetry = 0, redisOptions = {}, } = opts;
9
- const normalizedSentinels = sentinels.map((sentinel) => ({
10
- host: sentinel.host,
11
- port: ParseUtility.toInt({ input: sentinel.port ?? 26379 }),
10
+ const { name, sentinel, username, password, database = 0, autoConnect = true, maxRetry = RedisDefaults.MAX_RETRY, redisOptions = {}, } = opts;
11
+ // A JavaScript caller (or a config read from a file) may still pass the old shape, `masterName` and `sentinels` at the top level.
12
+ if (!Array.isArray(sentinel?.nodes) || sentinel.nodes.length === 0) {
13
+ throw getError({
14
+ message: `[${RedisSentinelHelper.name}] sentinel.nodes is required | pass sentinel: { masterName, nodes }`,
15
+ });
16
+ }
17
+ const normalizedSentinels = sentinel.nodes.map((node) => ({
18
+ host: node.host,
19
+ port: ParseUtility.toInt({ input: node.port ?? RedisSentinelDefaults.PORT }),
12
20
  }));
13
21
  const ioredis = opts.module ?? ModuleUtility.loadSync({ module: 'ioredis' });
14
22
  super({
15
23
  ...opts,
16
24
  scope: RedisSentinelHelper.name,
17
25
  identifier: name,
18
- // 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.
26
+ // Precedence (low -> high): framework defaults, the redisOptions escape hatch, then first-class fields. An auth field left unset falls back to `redisOptions`, so an undefined first-class field never clobbers it.
19
27
  client: new ioredis.Redis({
20
- ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),
28
+ ...AbstractRedisHelper.buildDefaultOpts({
29
+ scope: RedisSentinelHelper.name,
30
+ name,
31
+ maxRetry,
32
+ }),
21
33
  ...redisOptions,
22
34
  sentinels: normalizedSentinels,
23
- name: masterName,
24
- role,
35
+ name: sentinel.masterName,
36
+ role: sentinel.role ?? RedisSentinelRoles.MASTER,
25
37
  db: database,
26
38
  lazyConnect: !autoConnect,
27
- ...(password === undefined ? {} : { password }),
28
- ...(sentinelPassword === undefined ? {} : { sentinelPassword }),
29
- ...(sentinelUsername === undefined ? {} : { sentinelUsername }),
39
+ username: username ?? redisOptions.username,
40
+ password: password ?? redisOptions.password,
41
+ sentinelUsername: sentinel.username ?? redisOptions.sentinelUsername,
42
+ sentinelPassword: sentinel.password ?? redisOptions.sentinelPassword,
30
43
  }),
31
44
  });
32
45
  }
33
- getClient() {
34
- return this.client;
35
- }
36
46
  }
37
47
  //# sourceMappingURL=sentinel.helper.js.map
@@ -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,4JAA4J;AAC5J,MAAM,OAAO,mBAAoB,SAAQ,mBAA0B;IACjE,YAAY,IAAiC;QAC3C,MAAM,EACJ,IAAI,EACJ,SAAS,EACT,UAAU,EACV,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAChC,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,CAAC,EACZ,YAAY,GAAG,EAAE,GAClB,GAAG,IAAI,CAAC;QAET,MAAM,mBAAmB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACvD,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;SAC5D,CAAC,CAAC,CAAC;QAEJ,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,mBAAmB,CAAC,IAAI;YAC/B,UAAU,EAAE,IAAI;YAChB,gPAAgP;YAChP,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;gBACrD,GAAG,YAAY;gBACf,SAAS,EAAE,mBAAmB;gBAC9B,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,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
+ {"version":3,"file":"sentinel.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/sentinel.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,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,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGxE,4JAA4J;AAC5J,MAAM,OAAO,mBAAoB,SAAQ,mBAA0B;IACjE,YAAY,IAAiC;QAC3C,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,EAClC,YAAY,GAAG,EAAE,GAClB,GAAG,IAAI,CAAC;QAET,kIAAkI;QAClI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnE,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,mBAAmB,CAAC,IAAI,qEAAqE;aAC3G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,mBAAmB,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,EAAE,CAAC;SAC7E,CAAC,CAAC,CAAC;QAEJ,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,mBAAmB,CAAC,IAAI;YAC/B,UAAU,EAAE,IAAI;YAChB,oNAAoN;YACpN,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;oBACtC,KAAK,EAAE,mBAAmB,CAAC,IAAI;oBAC/B,IAAI;oBACJ,QAAQ;iBACT,CAAC;gBACF,GAAG,YAAY;gBACf,SAAS,EAAE,mBAAmB;gBAC9B,IAAI,EAAE,QAAQ,CAAC,UAAU;gBACzB,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,kBAAkB,CAAC,MAAM;gBAChD,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,QAAQ,EAAE,QAAQ,IAAI,YAAY,CAAC,QAAQ;gBAC3C,QAAQ,EAAE,QAAQ,IAAI,YAAY,CAAC,QAAQ;gBAC3C,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,YAAY,CAAC,gBAAgB;gBACpE,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,YAAY,CAAC,gBAAgB;aACrE,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { RedisDefaults } from './../common';\nimport { RedisSentinelDefaults, RedisSentinelRoles } from './constants';\nimport type { IRedisSentinelHelperOptions } from './types';\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 sentinel,\n username,\n password,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n redisOptions = {},\n } = opts;\n\n // A JavaScript caller (or a config read from a file) may still pass the old shape, `masterName` and `sentinels` at the top level.\n if (!Array.isArray(sentinel?.nodes) || sentinel.nodes.length === 0) {\n throw getError({\n message: `[${RedisSentinelHelper.name}] sentinel.nodes is required | pass sentinel: { masterName, nodes }`,\n });\n }\n\n const normalizedSentinels = sentinel.nodes.map((node) => ({\n host: node.host,\n port: ParseUtility.toInt({ input: node.port ?? RedisSentinelDefaults.PORT }),\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. An auth field left unset falls back to `redisOptions`, so an undefined first-class field never clobbers it.\n client: new ioredis.Redis({\n ...AbstractRedisHelper.buildDefaultOpts({\n scope: RedisSentinelHelper.name,\n name,\n maxRetry,\n }),\n ...redisOptions,\n sentinels: normalizedSentinels,\n name: sentinel.masterName,\n role: sentinel.role ?? RedisSentinelRoles.MASTER,\n db: database,\n lazyConnect: !autoConnect,\n username: username ?? redisOptions.username,\n password: password ?? redisOptions.password,\n sentinelUsername: sentinel.username ?? redisOptions.sentinelUsername,\n sentinelPassword: sentinel.password ?? redisOptions.sentinelPassword,\n }),\n });\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { RedisOptions } from 'ioredis';
2
+ import type { IRedisCredentials, IRedisHelperCallbacks, IRedisModuleOption, IRedisNode } from './../common/index.js';
3
+ import type { TRedisSentinelRole } from './constants.js';
4
+ /** Connection settings for Redis behind Sentinel. Top-level `username` and `password` are the data nodes' (master and replica) credentials; everything Sentinel-specific is in `sentinel`. Precedence (low -> high): the helper defaults, `redisOptions`, then the first-class fields; an auth field left unset falls back to `redisOptions`. */
5
+ export interface IRedisSentinelHelperProps extends IRedisCredentials {
6
+ name: string;
7
+ /** The monitored group, which side to read, the Sentinel processes' own credentials and their addresses. `username` and `password` here are the Sentinel processes' (ioredis `sentinelUsername`, `sentinelPassword`), never the data nodes'. */
8
+ sentinel: IRedisCredentials & {
9
+ /** The group name in sentinel.conf (`sentinel monitor <masterName> ...`). Maps to ioredis `name`. */
10
+ masterName: string;
11
+ /** Connect to the master or to a replica. @default RedisSentinelRoles.MASTER */
12
+ role?: TRedisSentinelRole;
13
+ nodes: IRedisNode[];
14
+ };
15
+ /** @default 0 */
16
+ database?: number;
17
+ /** @default true */
18
+ autoConnect?: boolean;
19
+ /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
20
+ maxRetry?: number;
21
+ redisOptions?: Partial<RedisOptions>;
22
+ }
23
+ /** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
24
+ export interface IRedisSentinelHelperOptions extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RedisOptions } from 'ioredis';\nimport type {\n IRedisCredentials,\n IRedisHelperCallbacks,\n IRedisModuleOption,\n IRedisNode,\n} from './../common';\nimport type { TRedisSentinelRole } from './constants';\n\n/** Connection settings for Redis behind Sentinel. Top-level `username` and `password` are the data nodes' (master and replica) credentials; everything Sentinel-specific is in `sentinel`. Precedence (low -> high): the helper defaults, `redisOptions`, then the first-class fields; an auth field left unset falls back to `redisOptions`. */\nexport interface IRedisSentinelHelperProps extends IRedisCredentials {\n name: string;\n /** The monitored group, which side to read, the Sentinel processes' own credentials and their addresses. `username` and `password` here are the Sentinel processes' (ioredis `sentinelUsername`, `sentinelPassword`), never the data nodes'. */\n sentinel: IRedisCredentials & {\n /** The group name in sentinel.conf (`sentinel monitor <masterName> ...`). Maps to ioredis `name`. */\n masterName: string;\n /** Connect to the master or to a replica. @default RedisSentinelRoles.MASTER */\n role?: TRedisSentinelRole;\n nodes: IRedisNode[];\n };\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n redisOptions?: Partial<RedisOptions>;\n}\n\n/** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSentinelHelperOptions\n extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
@@ -1,2 +1,3 @@
1
+ export * from './types.js';
1
2
  export * from './single.helper.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
+ export * from './types.js';
1
2
  export * from './single.helper.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './single.helper';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './types';\nexport * from './single.helper';\n"]}
@@ -1,9 +1,8 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
- import { type IRedisSingleHelperOptions } from './../common/index.js';
3
+ import type { IRedisSingleHelperOptions } from './types.js';
4
4
  /** Redis helper over one ioredis `Redis` client connected to a single node. */
5
5
  export declare class RedisSingleHelper extends AbstractRedisHelper<Redis> {
6
6
  constructor(opts: IRedisSingleHelperOptions);
7
- getClient(): Redis;
8
7
  }
9
8
  //# sourceMappingURL=single.helper.d.ts.map
@@ -1,10 +1,11 @@
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
+ import { RedisDefaults } from './../common/index.js';
4
5
  /** Redis helper over one ioredis `Redis` client connected to a single node. */
5
6
  export class RedisSingleHelper extends AbstractRedisHelper {
6
7
  constructor(opts) {
7
- const { name, host, port, password, database = 0, autoConnect = true, maxRetry = 0 } = opts;
8
+ const { name, host, port, username, password, database = 0, autoConnect = true, maxRetry = RedisDefaults.MAX_RETRY, } = opts;
8
9
  // Optional peer, loaded when a client is built: an app with no Redis installs no ioredis.
9
10
  const ioredis = opts.module ?? ModuleUtility.loadSync({ module: 'ioredis' });
10
11
  super({
@@ -14,16 +15,14 @@ export class RedisSingleHelper extends AbstractRedisHelper {
14
15
  client: new ioredis.Redis({
15
16
  name,
16
17
  host,
17
- port: ParseUtility.toInt({ input: port }),
18
+ port: ParseUtility.toInt({ input: port ?? RedisDefaults.PORT }),
19
+ username,
18
20
  password,
19
21
  db: database,
20
22
  lazyConnect: !autoConnect,
21
- ...AbstractRedisHelper.buildDefaultOpts({ maxRetry }),
23
+ ...AbstractRedisHelper.buildDefaultOpts({ scope: RedisSingleHelper.name, name, maxRetry }),
22
24
  }),
23
25
  });
24
26
  }
25
- getClient() {
26
- return this.client;
27
- }
28
27
  }
29
28
  //# sourceMappingURL=single.helper.js.map
@@ -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,+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
+ {"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;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,+EAA+E;AAC/E,MAAM,OAAO,iBAAkB,SAAQ,mBAA0B;IAC/D,YAAY,IAA+B;QACzC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,GACnC,GAAG,IAAI,CAAC;QAET,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,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBAC/D,QAAQ;gBACR,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC3F,CAAC;SACH,CAAC,CAAC;IACL,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 { RedisDefaults } from './../common';\nimport type { IRedisSingleHelperOptions } from './types';\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 {\n name,\n host,\n port,\n username,\n password,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n } = 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 ?? RedisDefaults.PORT }),\n username,\n password,\n db: database,\n lazyConnect: !autoConnect,\n ...AbstractRedisHelper.buildDefaultOpts({ scope: RedisSingleHelper.name, name, maxRetry }),\n }),\n });\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { IRedisCredentials, IRedisHelperCallbacks, IRedisModuleOption, IRedisNode } from './../common/index.js';
2
+ /** Connection settings for a single Redis node. */
3
+ export interface IRedisSingleHelperProps extends IRedisNode, IRedisCredentials {
4
+ name: string;
5
+ /** @default 0 */
6
+ database?: number;
7
+ /** @default true */
8
+ autoConnect?: boolean;
9
+ /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
10
+ maxRetry?: number;
11
+ }
12
+ /** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
13
+ export interface IRedisSingleHelperOptions extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IRedisCredentials,\n IRedisHelperCallbacks,\n IRedisModuleOption,\n IRedisNode,\n} from './../common';\n\n/** Connection settings for a single Redis node. */\nexport interface IRedisSingleHelperProps extends IRedisNode, IRedisCredentials {\n name: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n}\n\n/** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSingleHelperOptions\n extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
@@ -3,7 +3,12 @@ import { getError } from '../../error/index.js';
3
3
  const DEFAULT_CLOCK = { now: () => Date.now() };
4
4
  const DEFAULT_TIMERS = {
5
5
  set: (handler, ms) => setTimeout(handler, ms),
6
- clear: (handle) => clearTimeout(handle),
6
+ clear: (handle) => {
7
+ // Only a real timer handle can be cleared: a number, or an object that carries `unref` (Node and Bun timers); an opaque fake from a test adapter has nothing to clear.
8
+ if (typeof handle === 'number' || (typeof handle === 'object' && 'unref' in handle)) {
9
+ clearTimeout(handle);
10
+ }
11
+ },
7
12
  };
8
13
  const DEFAULT_CACHE_TTL_SECONDS = 300;
9
14
  const DEFAULT_RENEW_BEFORE_RATIO = 0.66;