ioredis-toolkit 0.0.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +1 -1
  3. package/README.md +68 -1058
  4. package/dist/cache/cache.d.ts +30 -0
  5. package/dist/cache/cache.d.ts.map +1 -0
  6. package/dist/cache/cache.js +59 -0
  7. package/dist/cache/cache.js.map +1 -0
  8. package/dist/cache/config.d.ts +12 -0
  9. package/dist/cache/config.d.ts.map +1 -0
  10. package/dist/cache/config.js +13 -0
  11. package/dist/cache/config.js.map +1 -0
  12. package/dist/cache/types.d.ts +32 -0
  13. package/dist/cache/types.d.ts.map +1 -0
  14. package/dist/cache/types.js +5 -0
  15. package/dist/cache/types.js.map +1 -0
  16. package/dist/index.d.ts +43 -51
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +32 -44
  19. package/dist/index.js.map +1 -0
  20. package/dist/lock/config.d.ts +12 -0
  21. package/dist/lock/config.d.ts.map +1 -0
  22. package/dist/lock/config.js +8 -0
  23. package/dist/lock/config.js.map +1 -0
  24. package/dist/lock/lock.d.ts +20 -0
  25. package/dist/lock/lock.d.ts.map +1 -0
  26. package/dist/lock/lock.js +44 -0
  27. package/dist/lock/lock.js.map +1 -0
  28. package/dist/lock/types.d.ts +19 -0
  29. package/dist/lock/types.d.ts.map +1 -0
  30. package/dist/lock/types.js +2 -0
  31. package/dist/lock/types.js.map +1 -0
  32. package/dist/modules-config.d.ts +3 -0
  33. package/dist/modules-config.d.ts.map +1 -0
  34. package/dist/modules-config.js +2 -0
  35. package/dist/modules-config.js.map +1 -0
  36. package/dist/pubsub/config.d.ts +11 -0
  37. package/dist/pubsub/config.d.ts.map +1 -0
  38. package/dist/pubsub/config.js +6 -0
  39. package/dist/pubsub/config.js.map +1 -0
  40. package/dist/pubsub/pubsub.d.ts +20 -0
  41. package/dist/pubsub/pubsub.d.ts.map +1 -0
  42. package/dist/pubsub/pubsub.js +54 -0
  43. package/dist/pubsub/pubsub.js.map +1 -0
  44. package/dist/pubsub/types.d.ts +24 -0
  45. package/dist/pubsub/types.d.ts.map +1 -0
  46. package/dist/pubsub/types.js +2 -0
  47. package/dist/pubsub/types.js.map +1 -0
  48. package/dist/rate-limit/config.d.ts +12 -0
  49. package/dist/rate-limit/config.d.ts.map +1 -0
  50. package/dist/rate-limit/config.js +6 -0
  51. package/dist/rate-limit/config.js.map +1 -0
  52. package/dist/rate-limit/rate-limiter.d.ts +18 -0
  53. package/dist/rate-limit/rate-limiter.d.ts.map +1 -0
  54. package/dist/rate-limit/rate-limiter.js +37 -0
  55. package/dist/rate-limit/rate-limiter.js.map +1 -0
  56. package/dist/rate-limit/types.d.ts +27 -0
  57. package/dist/rate-limit/types.d.ts.map +1 -0
  58. package/dist/rate-limit/types.js +2 -0
  59. package/dist/rate-limit/types.js.map +1 -0
  60. package/dist/redis/client-facade.d.ts +77 -0
  61. package/dist/redis/client-facade.d.ts.map +1 -0
  62. package/dist/redis/client-facade.js +102 -0
  63. package/dist/redis/client-facade.js.map +1 -0
  64. package/dist/redis/client.d.ts +10 -0
  65. package/dist/redis/client.d.ts.map +1 -0
  66. package/dist/redis/client.js +29 -0
  67. package/dist/redis/client.js.map +1 -0
  68. package/dist/redis/cluster.d.ts +7 -0
  69. package/dist/redis/cluster.d.ts.map +1 -0
  70. package/dist/redis/cluster.js +47 -0
  71. package/dist/redis/cluster.js.map +1 -0
  72. package/dist/redis/config.d.ts +39 -0
  73. package/dist/redis/config.d.ts.map +1 -0
  74. package/dist/redis/config.js +52 -0
  75. package/dist/redis/config.js.map +1 -0
  76. package/dist/redis/errors.d.ts +5 -0
  77. package/dist/redis/errors.d.ts.map +1 -0
  78. package/dist/redis/errors.js +5 -0
  79. package/dist/redis/errors.js.map +1 -0
  80. package/dist/redis/types.d.ts +135 -0
  81. package/dist/redis/types.d.ts.map +1 -0
  82. package/dist/redis/types.js +2 -0
  83. package/dist/redis/types.js.map +1 -0
  84. package/dist/redis/wrapper.d.ts +88 -0
  85. package/dist/redis/wrapper.d.ts.map +1 -0
  86. package/dist/redis/wrapper.js +206 -0
  87. package/dist/redis/wrapper.js.map +1 -0
  88. package/dist/session/config.d.ts +47 -0
  89. package/dist/session/config.d.ts.map +1 -0
  90. package/dist/session/config.js +101 -0
  91. package/dist/session/config.js.map +1 -0
  92. package/dist/session/cookie.d.ts +16 -0
  93. package/dist/session/cookie.d.ts.map +1 -0
  94. package/dist/session/cookie.js +28 -0
  95. package/dist/session/cookie.js.map +1 -0
  96. package/dist/session/errors.d.ts +56 -0
  97. package/dist/session/errors.d.ts.map +1 -0
  98. package/dist/session/errors.js +58 -0
  99. package/dist/session/errors.js.map +1 -0
  100. package/dist/session/factory.d.ts +21 -0
  101. package/dist/session/factory.d.ts.map +1 -0
  102. package/dist/session/factory.js +30 -0
  103. package/dist/session/factory.js.map +1 -0
  104. package/dist/session/health.d.ts +12 -0
  105. package/dist/session/health.d.ts.map +1 -0
  106. package/dist/session/health.js +23 -0
  107. package/dist/session/health.js.map +1 -0
  108. package/dist/session/keys.d.ts +23 -0
  109. package/dist/session/keys.d.ts.map +1 -0
  110. package/dist/session/keys.js +27 -0
  111. package/dist/session/keys.js.map +1 -0
  112. package/dist/session/manager.d.ts +34 -0
  113. package/dist/session/manager.d.ts.map +1 -0
  114. package/dist/session/manager.js +31 -0
  115. package/dist/session/manager.js.map +1 -0
  116. package/dist/session/metrics.d.ts +11 -0
  117. package/dist/session/metrics.d.ts.map +1 -0
  118. package/dist/session/metrics.js +10 -0
  119. package/dist/session/metrics.js.map +1 -0
  120. package/dist/session/repository.d.ts +49 -0
  121. package/dist/session/repository.d.ts.map +1 -0
  122. package/dist/session/repository.js +203 -0
  123. package/dist/session/repository.js.map +1 -0
  124. package/dist/session/revocation.d.ts +22 -0
  125. package/dist/session/revocation.d.ts.map +1 -0
  126. package/dist/session/revocation.js +41 -0
  127. package/dist/session/revocation.js.map +1 -0
  128. package/dist/session/script-sources.d.ts +11 -0
  129. package/dist/session/script-sources.d.ts.map +1 -0
  130. package/dist/session/script-sources.js +140 -0
  131. package/dist/session/script-sources.js.map +1 -0
  132. package/dist/session/scripts.d.ts +15 -0
  133. package/dist/session/scripts.d.ts.map +1 -0
  134. package/dist/session/scripts.js +41 -0
  135. package/dist/session/scripts.js.map +1 -0
  136. package/dist/session/serializer.d.ts +12 -0
  137. package/dist/session/serializer.d.ts.map +1 -0
  138. package/dist/session/serializer.js +77 -0
  139. package/dist/session/serializer.js.map +1 -0
  140. package/dist/session/service.d.ts +48 -0
  141. package/dist/session/service.d.ts.map +1 -0
  142. package/dist/session/service.js +235 -0
  143. package/dist/session/service.js.map +1 -0
  144. package/dist/session/token.d.ts +16 -0
  145. package/dist/session/token.d.ts.map +1 -0
  146. package/dist/session/token.js +32 -0
  147. package/dist/session/token.js.map +1 -0
  148. package/dist/session/types.d.ts +134 -0
  149. package/dist/session/types.d.ts.map +1 -0
  150. package/dist/session/types.js +2 -0
  151. package/dist/session/types.js.map +1 -0
  152. package/dist/streams/config.d.ts +12 -0
  153. package/dist/streams/config.d.ts.map +1 -0
  154. package/dist/streams/config.js +6 -0
  155. package/dist/streams/config.js.map +1 -0
  156. package/dist/streams/streams.d.ts +24 -0
  157. package/dist/streams/streams.d.ts.map +1 -0
  158. package/dist/streams/streams.js +55 -0
  159. package/dist/streams/streams.js.map +1 -0
  160. package/dist/streams/types.d.ts +32 -0
  161. package/dist/streams/types.d.ts.map +1 -0
  162. package/dist/streams/types.js +2 -0
  163. package/dist/streams/types.js.map +1 -0
  164. package/docs/ACCEPTANCE-REPORT.md +70 -0
  165. package/docs/ARCHITECTURE.md +61 -0
  166. package/docs/CAPACITY.md +33 -0
  167. package/docs/DEPLOYMENT.md +22 -0
  168. package/docs/README-API.md +15 -0
  169. package/docs/STATE-MACHINE.md +38 -0
  170. package/docs/TESTING.md +37 -0
  171. package/docs/THREAT-MODEL.md +23 -0
  172. package/docs/TYPE-SAFETY.md +34 -0
  173. package/docs/modules/cache/README.md +7 -0
  174. package/docs/modules/cache/usage.md +156 -0
  175. package/docs/modules/lock/README.md +7 -0
  176. package/docs/modules/lock/usage.md +105 -0
  177. package/docs/modules/pubsub/README.md +7 -0
  178. package/docs/modules/pubsub/usage.md +106 -0
  179. package/docs/modules/rate-limit/README.md +7 -0
  180. package/docs/modules/rate-limit/usage.md +100 -0
  181. package/docs/modules/sessions/README.md +7 -0
  182. package/docs/modules/sessions/usage.md +262 -0
  183. package/docs/modules/streams/README.md +7 -0
  184. package/docs/modules/streams/usage.md +141 -0
  185. package/package.json +50 -60
  186. package/src/scripts/cleanup-index.lua +4 -0
  187. package/src/scripts/conditional-update.lua +21 -0
  188. package/src/scripts/consume-session.lua +21 -0
  189. package/src/scripts/create-session.lua +28 -0
  190. package/src/scripts/delete.lua +2 -0
  191. package/src/scripts/destroy-user.lua +13 -0
  192. package/src/scripts/enforce-limit.lua +17 -0
  193. package/src/scripts/revoke-session.lua +13 -0
  194. package/src/scripts/rotate.lua +24 -0
  195. package/src/scripts/touch-session.lua +28 -0
  196. package/src/scripts/update-session.lua +18 -0
  197. package/dist/cache.d.ts +0 -796
  198. package/dist/cache.js +0 -1120
  199. package/dist/client.d.ts +0 -284
  200. package/dist/client.js +0 -1114
  201. package/dist/cluster-slot.d.ts +0 -4
  202. package/dist/cluster-slot.js +0 -31
  203. package/dist/cluster.d.ts +0 -79
  204. package/dist/cluster.js +0 -156
  205. package/dist/errors.d.ts +0 -30
  206. package/dist/errors.js +0 -63
  207. package/dist/health.d.ts +0 -180
  208. package/dist/health.js +0 -239
  209. package/dist/lock.d.ts +0 -248
  210. package/dist/lock.js +0 -397
  211. package/dist/logger.d.ts +0 -12
  212. package/dist/logger.js +0 -40
  213. package/dist/pubsub.d.ts +0 -423
  214. package/dist/pubsub.js +0 -537
  215. package/dist/ratelimiter.d.ts +0 -441
  216. package/dist/ratelimiter.js +0 -539
  217. package/dist/session/index.d.ts +0 -23
  218. package/dist/session/index.js +0 -16
  219. package/dist/session/revocation-store.d.ts +0 -176
  220. package/dist/session/revocation-store.js +0 -318
  221. package/dist/session/scripts/cleanup-index.lua +0 -21
  222. package/dist/session/scripts/conditional-update-encrypted.lua +0 -60
  223. package/dist/session/scripts/conditional-update.lua +0 -63
  224. package/dist/session/scripts/create.lua +0 -83
  225. package/dist/session/scripts/delete-by-user.lua +0 -29
  226. package/dist/session/scripts/delete.lua +0 -15
  227. package/dist/session/scripts/enforce-limit.lua +0 -38
  228. package/dist/session/scripts/revoke.lua +0 -61
  229. package/dist/session/scripts/rotate-encrypted.lua +0 -110
  230. package/dist/session/scripts/rotate.lua +0 -122
  231. package/dist/session/scripts/touch-encrypted.lua +0 -89
  232. package/dist/session/scripts/touch.lua +0 -72
  233. package/dist/session/scripts/validate.lua +0 -90
  234. package/dist/session/session-circuit-breaker.d.ts +0 -42
  235. package/dist/session/session-circuit-breaker.js +0 -129
  236. package/dist/session/session-config.d.ts +0 -335
  237. package/dist/session/session-config.js +0 -162
  238. package/dist/session/session-cookie.d.ts +0 -72
  239. package/dist/session/session-cookie.js +0 -101
  240. package/dist/session/session-encryption.d.ts +0 -87
  241. package/dist/session/session-encryption.js +0 -139
  242. package/dist/session/session-errors.d.ts +0 -85
  243. package/dist/session/session-errors.js +0 -145
  244. package/dist/session/session-health.d.ts +0 -38
  245. package/dist/session/session-health.js +0 -60
  246. package/dist/session/session-keys.d.ts +0 -51
  247. package/dist/session/session-keys.js +0 -113
  248. package/dist/session/session-manager.d.ts +0 -73
  249. package/dist/session/session-manager.js +0 -94
  250. package/dist/session/session-metrics.d.ts +0 -33
  251. package/dist/session/session-metrics.js +0 -112
  252. package/dist/session/session-repository.d.ts +0 -161
  253. package/dist/session/session-repository.js +0 -683
  254. package/dist/session/session-scripts.d.ts +0 -36
  255. package/dist/session/session-scripts.js +0 -130
  256. package/dist/session/session-serializer.d.ts +0 -42
  257. package/dist/session/session-serializer.js +0 -248
  258. package/dist/session/session-service.d.ts +0 -104
  259. package/dist/session/session-service.js +0 -611
  260. package/dist/session/session-token.d.ts +0 -38
  261. package/dist/session/session-token.js +0 -86
  262. package/dist/session/session-types.d.ts +0 -253
  263. package/dist/session/session-types.js +0 -16
  264. package/dist/types.d.ts +0 -924
  265. package/dist/types.js +0 -151
  266. package/dist/utils/deepmerge.d.ts +0 -9
  267. package/dist/utils/deepmerge.js +0 -61
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { RedisConfigurationError } from './errors.js';
3
+ const endpoint = z.object({
4
+ host: z.string().min(1),
5
+ port: z.number().int().min(1).max(65535),
6
+ });
7
+ /** Runtime schema for the standalone Redis connection subset accepted by this package. */
8
+ export const RedisConnectionConfigSchema = z.preprocess((input) => {
9
+ if (input && typeof input === 'object' && !('mode' in input)) {
10
+ return { ...input, mode: 'standalone' };
11
+ }
12
+ return input;
13
+ }, z.discriminatedUnion('mode', [
14
+ z.object({
15
+ mode: z.literal('standalone'),
16
+ host: z.string().default('127.0.0.1'),
17
+ port: z.number().int().min(1).max(65535).default(6379),
18
+ password: z.string().optional(),
19
+ username: z.string().optional(),
20
+ db: z.number().int().nonnegative().default(0),
21
+ tls: z.unknown().optional(),
22
+ }).passthrough(),
23
+ z.object({
24
+ mode: z.literal('sentinel'),
25
+ sentinels: z.array(endpoint).min(1),
26
+ name: z.string().min(1),
27
+ username: z.string().optional(),
28
+ password: z.string().optional(),
29
+ db: z.number().int().nonnegative().default(0),
30
+ tls: z.unknown().optional(),
31
+ }).passthrough(),
32
+ z.object({
33
+ mode: z.literal('cluster'),
34
+ nodes: z.array(endpoint).min(1),
35
+ redisOptions: z.record(z.string(), z.unknown()).optional(),
36
+ }).passthrough(),
37
+ ]));
38
+ /**
39
+ * Validates the public Redis connection configuration and returns it in the
40
+ * package's topology-independent shape. Unsupported extra ioredis options are
41
+ * preserved so advanced users can still configure retries, TLS, timeouts, and
42
+ * other supported client features. `mode` may be omitted for standalone Redis,
43
+ * matching {@link StandaloneRedisConfig}'s optional `mode` field.
44
+ */
45
+ export function parseRedisConnectionConfig(input) {
46
+ const result = RedisConnectionConfigSchema.safeParse(input ?? {});
47
+ if (!result.success) {
48
+ throw new RedisConfigurationError(result.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; '));
49
+ }
50
+ return result.data;
51
+ }
52
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/redis/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;CACzC,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,UAAU,CACrD,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAK,KAAiC,CAAC,EAAE,CAAC;QAC1F,OAAO,EAAE,GAAI,KAAiC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACvE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,EACD,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC3B,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;QAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;QACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,G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,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC3D,CAAC,CAAC,WAAW,EAAE;CACjB,CAAC,CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,MAAM,MAAM,GAAG,2BAA2B,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAA+C,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1K,CAAC;IACD,OAAO,MAAM,CAAC,IAAmB,CAAC;AACpC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** Thrown when Redis connection configuration is invalid, or a module is used while disabled. */
2
+ export declare class RedisConfigurationError extends Error {
3
+ constructor(message: string, options?: ErrorOptions);
4
+ }
5
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/redis/errors.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CACpD"}
@@ -0,0 +1,5 @@
1
+ /** Thrown when Redis connection configuration is invalid, or a module is used while disabled. */
2
+ export class RedisConfigurationError extends Error {
3
+ constructor(message, options) { super(message, options); this.name = 'RedisConfigurationError'; }
4
+ }
5
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/redis/errors.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe,EAAE,OAAsB,IAAI,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,CAAC,CAAC;CACzH"}
@@ -0,0 +1,135 @@
1
+ import type { Cluster, ClusterNode, ClusterOptions, Redis, RedisOptions } from 'ioredis';
2
+ /** Supported Redis deployment topologies. */
3
+ export type RedisMode = 'standalone' | 'sentinel' | 'cluster';
4
+ /** Connection options for a single Redis server. */
5
+ export interface StandaloneRedisConfig extends RedisOptions {
6
+ /** Selects standalone Redis. Optional for backwards-compatible single-node configuration. */
7
+ mode?: 'standalone';
8
+ }
9
+ /** Connection options for Redis Sentinel. */
10
+ export interface SentinelRedisConfig extends RedisOptions {
11
+ /** Selects Sentinel mode. */
12
+ mode: 'sentinel';
13
+ /** Sentinel endpoints used to discover the current master. */
14
+ sentinels: Array<{
15
+ host: string;
16
+ port: number;
17
+ }>;
18
+ /** Sentinel master service name. */
19
+ name: string;
20
+ }
21
+ /** Connection options for Redis Cluster. */
22
+ export interface ClusterRedisConfig extends ClusterOptions {
23
+ /** Selects Cluster mode. */
24
+ mode: 'cluster';
25
+ /** Initial cluster startup nodes. */
26
+ nodes: ClusterNode[];
27
+ }
28
+ /** Union of supported Redis topology configurations. */
29
+ export type RedisConfig = StandaloneRedisConfig | SentinelRedisConfig | ClusterRedisConfig;
30
+ /** Runtime connection type created by this package. */
31
+ export type RedisConnection = Redis | Cluster;
32
+ /** Options controlling bounded fan-out against Redis Cluster nodes/slots. */
33
+ export interface ClusterFanoutOptions {
34
+ /** Maximum number of concurrent node/slot operations. Defaults to a conservative value. */
35
+ concurrency?: number;
36
+ }
37
+ /** Minimal Redis command surface consumed by the package modules. */
38
+ export interface RedisCommandClient {
39
+ /** Reads a string value. */
40
+ get(key: string): Promise<string | null>;
41
+ /** Writes a string value with raw Redis option arguments. */
42
+ set(key: string, value: string, ...args: string[]): Promise<string | null>;
43
+ /** Performs legacy SETNX. */
44
+ setnx(key: string, value: string): Promise<number>;
45
+ /** Deletes one or more keys. */
46
+ del(...keys: string[]): Promise<number>;
47
+ /** Returns the number of existing keys. */
48
+ exists(...keys: string[]): Promise<number>;
49
+ /** Sets a TTL in seconds. */
50
+ expire(key: string, seconds: number): Promise<number>;
51
+ /** Sets a TTL in milliseconds. */
52
+ pexpire(key: string, milliseconds: number): Promise<number>;
53
+ /** Reads TTL in seconds. */
54
+ ttl(key: string): Promise<number>;
55
+ /** Adds one sorted-set member. */
56
+ zadd(key: string, score: number, member: string): Promise<number>;
57
+ /** Removes sorted-set members. */
58
+ zrem(key: string, ...members: string[]): Promise<number>;
59
+ /** Returns sorted-set cardinality. */
60
+ zcard(key: string): Promise<number>;
61
+ /** Reads one sorted-set member score. */
62
+ zscore(key: string, member: string): Promise<string | null>;
63
+ /** Reads sorted-set members by rank. */
64
+ zrange(key: string, start: number, stop: number, ...args: string[]): Promise<string[]>;
65
+ /** Reads sorted-set members by score. */
66
+ zrangebyscore(key: string, min: string | number, max: string | number, ...args: string[]): Promise<string[]>;
67
+ /** Pops the lowest-score sorted-set members. */
68
+ zpopmin(key: string, count?: number): Promise<string[]>;
69
+ /** Atomically increments an integer value. */
70
+ incrby(key: string, increment: number): Promise<number>;
71
+ /** Atomically decrements an integer value. */
72
+ decrby(key: string, decrement: number): Promise<number>;
73
+ /** Executes a cached Lua script by SHA. */
74
+ evalsha(sha: string, numKeys: number, ...args: string[]): Promise<unknown>;
75
+ /** Executes Lua source directly. */
76
+ eval(script: string, numKeys: number, ...args: string[]): Promise<unknown>;
77
+ /** Loads Lua source and returns its SHA-1. */
78
+ script(command: 'LOAD', script: string): Promise<string>;
79
+ /** Reads Redis server time. */
80
+ time(): Promise<[string, string]>;
81
+ /** Pings Redis. */
82
+ ping(): Promise<string>;
83
+ /** Scans keys from one Redis node. */
84
+ scan(cursor: string, ...args: string[]): Promise<[string, string[]]>;
85
+ /** Publishes a string message. */
86
+ publish(channel: string, message: string): Promise<number>;
87
+ /** Appends a Redis Stream entry. */
88
+ xadd(key: string, ...args: string[]): Promise<string>;
89
+ /** Executes an XGROUP CREATE operation. */
90
+ xgroup(command: 'CREATE', key: string, group: string, id: string, ...args: string[]): Promise<string>;
91
+ /** Reads a Redis Stream. */
92
+ xread(...args: string[]): Promise<unknown>;
93
+ /** Reads a Redis Stream through a consumer group. */
94
+ xreadgroup(...args: string[]): Promise<unknown>;
95
+ /** Acknowledges consumer-group entries. */
96
+ xack(key: string, group: string, ...ids: string[]): Promise<number>;
97
+ /** Deletes Stream entries. */
98
+ xdel(key: string, ...ids: string[]): Promise<number>;
99
+ /** Returns Stream length. */
100
+ xlen(key: string): Promise<number>;
101
+ /** Creates a Redis pipeline. */
102
+ pipeline(): RedisPipeline;
103
+ /** Reads multiple values in input-key order. */
104
+ mget(...keys: string[]): Promise<Array<string | null>>;
105
+ /** Creates a dedicated duplicate connection, e.g. for Pub/Sub consumers. */
106
+ duplicateConnection(): RedisConnection;
107
+ /** Reads multiple keys while preserving input order and grouping Cluster requests by slot. */
108
+ mgetClusterAware(keys: string[], options?: ClusterFanoutOptions): Promise<Array<string | null>>;
109
+ /** Scans all master nodes in Cluster mode or the standalone server otherwise. */
110
+ scanCluster(pattern: string, count?: number, options?: ClusterFanoutOptions): Promise<string[]>;
111
+ /** Scans and deletes matching keys without using `KEYS`, `FLUSHDB`, or cross-slot multi-key commands. */
112
+ deletePatternClusterAware(pattern: string, options?: ClusterFanoutOptions): Promise<number>;
113
+ }
114
+ /** Minimal pipeline surface needed by this package. */
115
+ export interface RedisPipeline {
116
+ /** Queues GET. */
117
+ get(key: string): RedisPipeline;
118
+ /** Queues EXISTS. */
119
+ exists(key: string): RedisPipeline;
120
+ /** Queues DEL. */
121
+ del(...keys: string[]): RedisPipeline;
122
+ /** Queues ZRANGE. */
123
+ zrange(key: string, start: number, stop: number, ...args: string[]): RedisPipeline;
124
+ /** Queues ZREM. */
125
+ zrem(key: string, ...members: string[]): RedisPipeline;
126
+ /** Queues ZSCORE. */
127
+ zscore(key: string, member: string): RedisPipeline;
128
+ /** Queues SET. */
129
+ set(key: string, value: string, ...args: string[]): RedisPipeline;
130
+ /** Queues EXPIRE. */
131
+ expire(key: string, seconds: number): RedisPipeline;
132
+ /** Executes the pipeline. Each tuple contains a command-level error and result. */
133
+ exec(): Promise<Array<[Error | null, unknown]> | null>;
134
+ }
135
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/redis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzF,6CAA6C;AAC7C,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAE9D,oDAAoD;AACpD,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,6FAA6F;IAC7F,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,6BAA6B;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,4BAA4B;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,qCAAqC;IACrC,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAE3F,uDAAuD;AACvD,MAAM,MAAM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AAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;IACnF,mBAAmB;IACnB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;IACvD,qBAAqB;IACrB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IACnD,kBAAkB;IAClB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;IAClE,qBAAqB;IACrB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IACpD,mFAAmF;IACnF,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CACxD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/redis/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
1
+ import type { ClusterFanoutOptions, RedisCommandClient, RedisConnection, RedisPipeline } from './types.js';
2
+ export type { ClusterFanoutOptions } from './types.js';
3
+ /**
4
+ * Topology-independent Redis command adapter.
5
+ *
6
+ * The wrapper deliberately exposes only the commands required by this package and
7
+ * centralizes Cluster-aware multi-key behavior so higher-level modules remain topology agnostic.
8
+ */
9
+ export declare class RedisClientWrapper implements RedisCommandClient {
10
+ private readonly client;
11
+ /** Creates a wrapper around an existing ioredis Redis or Cluster connection. */
12
+ constructor(client: RedisConnection);
13
+ /** Reads a string value. */
14
+ get(key: string): Promise<string | null>;
15
+ /** Writes a string value using raw Redis option arguments. */
16
+ set(key: string, value: string, ...args: string[]): Promise<string | null>;
17
+ /** Reads multiple values in input-key order. */
18
+ mget(...keys: string[]): Promise<Array<string | null>>;
19
+ /** Performs SETNX. */
20
+ setnx(key: string, value: string): Promise<number>;
21
+ /** Deletes keys, splitting cross-slot deletions into safe groups in Cluster mode. */
22
+ del(...keys: string[]): Promise<number>;
23
+ /** Returns the number of existing keys. */
24
+ exists(...keys: string[]): Promise<number>;
25
+ /** Sets an expiration in seconds. */
26
+ expire(key: string, seconds: number): Promise<number>;
27
+ /** Sets an expiration in milliseconds. */
28
+ pexpire(key: string, milliseconds: number): Promise<number>;
29
+ /** Reads remaining TTL in seconds. */
30
+ ttl(key: string): Promise<number>;
31
+ /** Adds one sorted-set member. */
32
+ zadd(key: string, score: number, member: string): Promise<number>;
33
+ /** Removes sorted-set members. */
34
+ zrem(key: string, ...members: string[]): Promise<number>;
35
+ /** Returns sorted-set cardinality. */
36
+ zcard(key: string): Promise<number>;
37
+ /** Reads a sorted-set member score. */
38
+ zscore(key: string, member: string): Promise<string | null>;
39
+ /** Reads sorted-set members by rank. */
40
+ zrange(key: string, start: number, stop: number, ...args: string[]): Promise<string[]>;
41
+ /** Reads sorted-set members by score. */
42
+ zrangebyscore(key: string, min: string | number, max: string | number, ...args: string[]): Promise<string[]>;
43
+ /** Pops the lowest sorted-set members. */
44
+ zpopmin(key: string, count?: number): Promise<string[]>;
45
+ /** Atomically increments an integer. */
46
+ incrby(key: string, increment: number): Promise<number>;
47
+ /** Atomically decrements an integer. */
48
+ decrby(key: string, decrement: number): Promise<number>;
49
+ /** Executes a cached Lua script. */
50
+ evalsha(sha: string, numKeys: number, ...args: string[]): Promise<unknown>;
51
+ /** Executes Lua source. */
52
+ eval(script: string, numKeys: number, ...args: string[]): Promise<unknown>;
53
+ /** Loads a Lua script. */
54
+ script(command: 'LOAD', script: string): Promise<string>;
55
+ /** Reads server time. */
56
+ time(): Promise<[string, string]>;
57
+ /** Pings Redis. */
58
+ ping(): Promise<string>;
59
+ /** Scans one Redis node or the standalone server. */
60
+ scan(cursor: string, ...args: string[]): Promise<[string, string[]]>;
61
+ /** Publishes a string message. */
62
+ publish(channel: string, message: string): Promise<number>;
63
+ /** Appends a Stream entry. */
64
+ xadd(key: string, ...args: string[]): Promise<string>;
65
+ /** Creates a consumer group. */
66
+ xgroup(command: 'CREATE', key: string, group: string, id: string, ...args: string[]): Promise<string>;
67
+ /** Reads Stream entries. */
68
+ xread(...args: string[]): Promise<unknown>;
69
+ /** Reads Stream entries through a consumer group. */
70
+ xreadgroup(...args: string[]): Promise<unknown>;
71
+ /** Acknowledges Stream entries. */
72
+ xack(key: string, group: string, ...ids: string[]): Promise<number>;
73
+ /** Deletes Stream entries. */
74
+ xdel(key: string, ...ids: string[]): Promise<number>;
75
+ /** Returns Stream length. */
76
+ xlen(key: string): Promise<number>;
77
+ /** Creates a pipeline. Command-level errors must be inspected in the returned tuples. */
78
+ pipeline(): RedisPipeline;
79
+ /** Creates a dedicated duplicate connection for Pub/Sub consumers. */
80
+ duplicateConnection(): RedisConnection;
81
+ /** Reads multiple keys while preserving input order and grouping Cluster requests by slot. */
82
+ mgetClusterAware(keys: string[], options?: ClusterFanoutOptions): Promise<Array<string | null>>;
83
+ /** Scans all master nodes in Cluster mode or the standalone server otherwise. */
84
+ scanCluster(pattern: string, count?: number, options?: ClusterFanoutOptions): Promise<string[]>;
85
+ /** Scans and deletes matching keys without using `KEYS`, `FLUSHDB`, or cross-slot multi-key commands. */
86
+ deletePatternClusterAware(pattern: string, options?: ClusterFanoutOptions): Promise<number>;
87
+ }
88
+ //# sourceMappingURL=wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/redis/wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3G,YAAY,EAAE,oBAAoB,EAAE,MAAM,YA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C,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IACpD,6BAA6B;IAC7B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAClC,yFAAyF;IACzF,QAAQ,IAAI,aAAa;IACzB,sEAAsE;IACtE,mBAAmB,IAAI,eAAe;IAEtC,8FAA8F;IACxF,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAkBzG,iFAAiF;IAC3E,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwBtG,yGAAyG;IACnG,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBtG"}
@@ -0,0 +1,206 @@
1
+ import { Cluster } from 'ioredis';
2
+ import { redisHashSlot } from './cluster.js';
3
+ /**
4
+ * Topology-independent Redis command adapter.
5
+ *
6
+ * The wrapper deliberately exposes only the commands required by this package and
7
+ * centralizes Cluster-aware multi-key behavior so higher-level modules remain topology agnostic.
8
+ */
9
+ export class RedisClientWrapper {
10
+ client;
11
+ /** Creates a wrapper around an existing ioredis Redis or Cluster connection. */
12
+ constructor(client) {
13
+ this.client = client;
14
+ }
15
+ /** Reads a string value. */
16
+ get(key) { return this.client.get(key); }
17
+ /** Writes a string value using raw Redis option arguments. */
18
+ set(key, value, ...args) {
19
+ return this.client.set(key, value, ...args);
20
+ }
21
+ /** Reads multiple values in input-key order. */
22
+ mget(...keys) {
23
+ return this.client.mget(...keys);
24
+ }
25
+ /** Performs SETNX. */
26
+ setnx(key, value) { return this.client.setnx(key, value); }
27
+ /** Deletes keys, splitting cross-slot deletions into safe groups in Cluster mode. */
28
+ async del(...keys) {
29
+ if (keys.length <= 1 || !(this.client instanceof Cluster))
30
+ return this.client.del(...keys);
31
+ const groups = new Map();
32
+ for (const key of keys) {
33
+ const slot = redisHashSlot(key);
34
+ const group = groups.get(slot) ?? [];
35
+ group.push(key);
36
+ groups.set(slot, group);
37
+ }
38
+ let deleted = 0;
39
+ await boundedMap([...groups.values()], 4, async (group) => {
40
+ for (const batch of chunk(group, 200))
41
+ deleted += await this.client.del(...batch);
42
+ });
43
+ return deleted;
44
+ }
45
+ /** Returns the number of existing keys. */
46
+ exists(...keys) { return this.client.exists(...keys); }
47
+ /** Sets an expiration in seconds. */
48
+ expire(key, seconds) { return this.client.expire(key, seconds); }
49
+ /** Sets an expiration in milliseconds. */
50
+ pexpire(key, milliseconds) { return this.client.pexpire(key, milliseconds); }
51
+ /** Reads remaining TTL in seconds. */
52
+ ttl(key) { return this.client.ttl(key); }
53
+ /** Adds one sorted-set member. */
54
+ zadd(key, score, member) { return this.client.zadd(key, score, member); }
55
+ /** Removes sorted-set members. */
56
+ zrem(key, ...members) { return this.client.zrem(key, ...members); }
57
+ /** Returns sorted-set cardinality. */
58
+ zcard(key) { return this.client.zcard(key); }
59
+ /** Reads a sorted-set member score. */
60
+ zscore(key, member) { return this.client.zscore(key, member); }
61
+ /** Reads sorted-set members by rank. */
62
+ zrange(key, start, stop, ...args) {
63
+ return this.client.zrange(key, String(start), String(stop), ...args);
64
+ }
65
+ /** Reads sorted-set members by score. */
66
+ zrangebyscore(key, min, max, ...args) {
67
+ return this.client.zrangebyscore(key, String(min), String(max), ...args);
68
+ }
69
+ /** Pops the lowest sorted-set members. */
70
+ zpopmin(key, count) { return count === undefined ? this.client.zpopmin(key) : this.client.zpopmin(key, count); }
71
+ /** Atomically increments an integer. */
72
+ incrby(key, increment) { return this.client.incrby(key, increment); }
73
+ /** Atomically decrements an integer. */
74
+ decrby(key, decrement) { return this.client.decrby(key, decrement); }
75
+ /** Executes a cached Lua script. */
76
+ evalsha(sha, numKeys, ...args) { return this.client.evalsha(sha, numKeys, ...args); }
77
+ /** Executes Lua source. */
78
+ eval(script, numKeys, ...args) { return this.client.eval(script, numKeys, ...args); }
79
+ /** Loads a Lua script. */
80
+ script(command, script) {
81
+ return this.client.script(command, script);
82
+ }
83
+ /** Reads server time. */
84
+ time() {
85
+ return this.client.time().then(([seconds, microseconds]) => [String(seconds), String(microseconds)]);
86
+ }
87
+ /** Pings Redis. */
88
+ ping() { return this.client.ping(); }
89
+ /** Scans one Redis node or the standalone server. */
90
+ scan(cursor, ...args) {
91
+ return this.client.scan(cursor, ...args);
92
+ }
93
+ /** Publishes a string message. */
94
+ publish(channel, message) { return this.client.publish(channel, message); }
95
+ /** Appends a Stream entry. */
96
+ xadd(key, ...args) {
97
+ return this.client.xadd(key, ...args);
98
+ }
99
+ /** Creates a consumer group. */
100
+ xgroup(command, key, group, id, ...args) {
101
+ return this.client.xgroup(command, key, group, id, ...args);
102
+ }
103
+ /** Reads Stream entries. */
104
+ xread(...args) {
105
+ return this.client.xread(...args);
106
+ }
107
+ /** Reads Stream entries through a consumer group. */
108
+ xreadgroup(...args) {
109
+ return this.client.xreadgroup(...args);
110
+ }
111
+ /** Acknowledges Stream entries. */
112
+ xack(key, group, ...ids) { return this.client.xack(key, group, ...ids); }
113
+ /** Deletes Stream entries. */
114
+ xdel(key, ...ids) { return this.client.xdel(key, ...ids); }
115
+ /** Returns Stream length. */
116
+ xlen(key) { return this.client.xlen(key); }
117
+ /** Creates a pipeline. Command-level errors must be inspected in the returned tuples. */
118
+ pipeline() { return this.client.pipeline(); }
119
+ /** Creates a dedicated duplicate connection for Pub/Sub consumers. */
120
+ duplicateConnection() { return this.client.duplicate(); }
121
+ /** Reads multiple keys while preserving input order and grouping Cluster requests by slot. */
122
+ async mgetClusterAware(keys, options = {}) {
123
+ if (keys.length === 0)
124
+ return [];
125
+ if (!(this.client instanceof Cluster))
126
+ return this.client.mget(...keys);
127
+ const grouped = new Map();
128
+ keys.forEach((key, index) => {
129
+ const slot = redisHashSlot(key);
130
+ const group = grouped.get(slot) ?? [];
131
+ group.push({ key, index });
132
+ grouped.set(slot, group);
133
+ });
134
+ const result = Array.from({ length: keys.length }, () => null);
135
+ await boundedMap([...grouped.values()], options.concurrency ?? 4, async (group) => {
136
+ const values = await this.client.mget(...group.map(item => item.key));
137
+ values.forEach((value, index) => { result[group[index].index] = value; });
138
+ });
139
+ return result;
140
+ }
141
+ /** Scans all master nodes in Cluster mode or the standalone server otherwise. */
142
+ async scanCluster(pattern, count = 500, options = {}) {
143
+ if (!(this.client instanceof Cluster)) {
144
+ const out = [];
145
+ let cursor = '0';
146
+ do {
147
+ const [next, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', String(count));
148
+ out.push(...keys);
149
+ cursor = next;
150
+ } while (cursor !== '0');
151
+ return out;
152
+ }
153
+ const nodes = this.client.nodes('master');
154
+ const out = [];
155
+ await boundedMap(nodes, options.concurrency ?? 2, async (node) => {
156
+ let cursor = '0';
157
+ do {
158
+ const [next, keys] = await node.scan(cursor, 'MATCH', pattern, 'COUNT', String(count));
159
+ out.push(...keys);
160
+ cursor = next;
161
+ } while (cursor !== '0');
162
+ });
163
+ return out;
164
+ }
165
+ /** Scans and deletes matching keys without using `KEYS`, `FLUSHDB`, or cross-slot multi-key commands. */
166
+ async deletePatternClusterAware(pattern, options = {}) {
167
+ const keys = await this.scanCluster(pattern, 500, options);
168
+ if (keys.length === 0)
169
+ return 0;
170
+ if (!(this.client instanceof Cluster))
171
+ return this.del(...keys);
172
+ const groups = new Map();
173
+ for (const key of keys) {
174
+ const slot = redisHashSlot(key);
175
+ const group = groups.get(slot) ?? [];
176
+ group.push(key);
177
+ groups.set(slot, group);
178
+ }
179
+ let deleted = 0;
180
+ await boundedMap([...groups.values()], options.concurrency ?? 4, async (group) => {
181
+ for (const batch of chunk(group, 200))
182
+ deleted += await this.del(...batch);
183
+ });
184
+ return deleted;
185
+ }
186
+ }
187
+ /** Runs bounded concurrent asynchronous work over an array. */
188
+ async function boundedMap(items, concurrency, fn) {
189
+ const width = Math.max(1, Math.min(Math.floor(concurrency), items.length || 1));
190
+ let cursor = 0;
191
+ const worker = async () => {
192
+ while (cursor < items.length) {
193
+ const index = cursor++;
194
+ await fn(items[index]);
195
+ }
196
+ };
197
+ await Promise.all(Array.from({ length: width }, () => worker()));
198
+ }
199
+ /** Splits an array into bounded chunks. */
200
+ function chunk(items, size) {
201
+ const out = [];
202
+ for (let i = 0; i < items.length; i += size)
203
+ out.push(items.slice(i, i + size));
204
+ return out;
205
+ }
206
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/redis/wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAEA;IAD7B,gFAAgF;IAChF,YAA6B,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;IAAG,CAAC;IACxD,4BAA4B;IAC5B,GAAG,CAAC,GAAW,IAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzE,8DAA8D;IAC9D,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAG,IAAc;QAC/C,OAAQ,IAAI,CAAC,MAAM,CAAC,GAA6D,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACzG,CAAC;IACD,gDAAgD;IAChD,IAAI,CAAC,GAAG,IAAc;QACpB,OAAQ,IAAI,CAAC,MAAM,CAAC,IAAqE,CAAC,GAAG,IAAI,CAAC,CAAC;IACrG,CAAC;IACD,sBAAsB;IACtB,KAAK,CAAC,GAAW,EAAE,KAAa,IAAqB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,G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,2CAA2C;AAC3C,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI;QAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ /** Runtime schema for session configuration and security invariants. */
3
+ export declare const SessionConfigSchema: z.ZodObject<{
4
+ enabled: z.ZodDefault<z.ZodBoolean>;
5
+ namespace: z.ZodDefault<z.ZodString>;
6
+ tokenBytes: z.ZodDefault<z.ZodNumber>;
7
+ ttl: z.ZodDefault<z.ZodNumber>;
8
+ idleTimeout: z.ZodOptional<z.ZodNumber>;
9
+ absoluteTimeout: z.ZodOptional<z.ZodNumber>;
10
+ touchInterval: z.ZodDefault<z.ZodNumber>;
11
+ rolling: z.ZodDefault<z.ZodBoolean>;
12
+ securityVersionEnabled: z.ZodDefault<z.ZodBoolean>;
13
+ maxSessionsPerUser: z.ZodDefault<z.ZodNumber>;
14
+ maxMetadataBytes: z.ZodDefault<z.ZodNumber>;
15
+ maxBatchSize: z.ZodDefault<z.ZodNumber>;
16
+ maxConcurrency: z.ZodDefault<z.ZodNumber>;
17
+ storeIpAddress: z.ZodDefault<z.ZodBoolean>;
18
+ storeUserAgent: z.ZodDefault<z.ZodBoolean>;
19
+ storeDeviceId: z.ZodDefault<z.ZodBoolean>;
20
+ encryption: z.ZodDefault<z.ZodObject<{
21
+ enabled: z.ZodDefault<z.ZodBoolean>;
22
+ }, z.core.$strip>>;
23
+ circuitBreaker: z.ZodDefault<z.ZodObject<{
24
+ enabled: z.ZodDefault<z.ZodBoolean>;
25
+ failureThreshold: z.ZodDefault<z.ZodNumber>;
26
+ resetTimeoutMs: z.ZodDefault<z.ZodNumber>;
27
+ halfOpenMaxRequests: z.ZodDefault<z.ZodNumber>;
28
+ }, z.core.$strip>>;
29
+ cookie: z.ZodDefault<z.ZodObject<{
30
+ name: z.ZodDefault<z.ZodString>;
31
+ httpOnly: z.ZodDefault<z.ZodBoolean>;
32
+ secure: z.ZodDefault<z.ZodBoolean>;
33
+ sameSite: z.ZodDefault<z.ZodEnum<{
34
+ strict: "strict";
35
+ lax: "lax";
36
+ none: "none";
37
+ }>>;
38
+ domain: z.ZodOptional<z.ZodString>;
39
+ path: z.ZodDefault<z.ZodString>;
40
+ maxAge: z.ZodOptional<z.ZodNumber>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ /** Fully normalized session configuration returned by {@link parseSessionConfig}. */
44
+ export type SessionConfig = z.infer<typeof SessionConfigSchema>;
45
+ /** Validates and applies secure defaults to session configuration. */
46
+ export declare function parseSessionConfig(input: unknown): SessionConfig;
47
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/session/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wEAAwE;AACxE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyF5B,CAAC;AACL,qFAAqF;AACrF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAShE"}