@fluojs/redis 1.0.0-beta.2 → 1.0.0-beta.4

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.
package/README.ko.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><a href="./README.md"><kbd>English</kbd></a> <strong><kbd>한국어</kbd></strong></p>
4
4
 
5
- fluo를 위한 공유 Redis 연결 계층입니다. 애플리케이션 수명 주기에 따라 관리되는 단일 `ioredis` 클라이언트를 제공합니다.
5
+ fluo를 위한 공유 Redis 연결 계층입니다. 기본 app-scoped `ioredis` client와 선택적인 named client를 제공하며, 모두 애플리케이션 lifecycle로 관리됩니다.
6
6
 
7
7
  ## 목차
8
8
 
@@ -51,6 +51,8 @@ export class AppModule {}
51
51
 
52
52
  `RedisService`를 주입받아 고수준 작업을 수행하거나, `REDIS_CLIENT`를 통해 원시 `ioredis` 인스턴스를 직접 사용할 수 있습니다.
53
53
 
54
+ `RedisService.get()`은 JSON parse를 시도하고 실패하면 raw string을 반환합니다. 누락된 key는 `null`을 반환합니다. `RedisService.set()`은 값을 `JSON.stringify()`로 직렬화하고 양수 TTL에만 `EX`를 사용합니다.
55
+
54
56
  ```typescript
55
57
  import { Inject } from '@fluojs/core';
56
58
  import { RedisService } from '@fluojs/redis';
@@ -73,7 +75,7 @@ export class CacheRepository {
73
75
 
74
76
  ### 수명 주기 소유권
75
77
 
76
- `@fluojs/redis`는 `RedisModule.forRootNamed(...)`로 등록한 연결을 포함해, 자신이 생성한 모든 Redis 클라이언트의 수명 주기를 직접 관리합니다.
78
+ `@fluojs/redis`는 `RedisModule.forRoot({ name, ... })`로 등록한 이름 있는 연결을 포함해, 자신이 생성한 모든 Redis 클라이언트의 수명 주기를 직접 관리합니다.
77
79
 
78
80
  - 호출자가 옵션을 강제로 캐스팅하더라도 Fluo는 항상 `lazyConnect: true`를 강제하므로, 소켓은 import 시점이 아니라 애플리케이션 bootstrap 중에 열립니다.
79
81
  - bootstrap 단계에서는 클라이언트가 ioredis `wait` 상태일 때만 lifecycle service가 `connect()`를 호출합니다.
@@ -82,11 +84,12 @@ export class CacheRepository {
82
84
 
83
85
  ### 이름 있는 클라이언트
84
86
 
85
- 하나의 애플리케이션에서 여러 Redis 연결이 필요하면 `RedisModule.forRootNamed(name, options)`를 사용하세요. `RedisModule.forRoot(options)`는 기본 `REDIS_CLIENT`와 `RedisService` 별칭을 제공하고, 이름 있는 등록은 `getRedisClientToken(name)`과 `getRedisServiceToken(name)`으로 해석합니다.
87
+ 하나의 애플리케이션에서 여러 Redis 연결이 필요하면 `RedisModule.forRoot({ name, ...options })`를 사용하세요. `name` 없는 `RedisModule.forRoot(options)`는 기본 `REDIS_CLIENT`와 `RedisService` 별칭을 제공하고, 이름 있는 등록은 `getRedisClientToken(name)`과 `getRedisServiceToken(name)`으로 해석합니다.
86
88
 
87
89
  - `name`을 생략하면 기본 별칭인 `REDIS_CLIENT` / `RedisService`를 사용합니다.
88
90
  - `name`을 지정하면 `getRedisClientToken(name)` / `getRedisServiceToken(name)`으로 이름 있는 바인딩을 가져옵니다.
89
91
  - 이름 있는 클라이언트도 기본 클라이언트와 동일한 bootstrap/shutdown 계약을 따르며, `REDIS_CLIENT` / `RedisService` 별칭은 기본 등록에서만 export됩니다.
92
+ - 이름은 trim되며, blank 또는 whitespace-only name은 token/component helper에서 거부됩니다.
90
93
 
91
94
  ```typescript
92
95
  import { Module, Inject } from '@fluojs/core';
@@ -104,7 +107,7 @@ const ANALYTICS_REDIS_CLIENT = getRedisClientToken('analytics');
104
107
  @Module({
105
108
  imports: [
106
109
  RedisModule.forRoot({ host: 'localhost', port: 6379 }),
107
- RedisModule.forRootNamed('analytics', { host: 'localhost', port: 6380 }),
110
+ RedisModule.forRoot({ name: 'analytics', host: 'localhost', port: 6380 }),
108
111
  ],
109
112
  })
110
113
  export class AppModule {}
@@ -123,6 +126,8 @@ export class AnalyticsStore {
123
126
 
124
127
  파이프라인, Lua 스크립트, Pub/Sub 등 복잡한 Redis 명령이 필요한 경우 원시 클라이언트를 직접 주입받아 사용합니다.
125
128
 
129
+ 이미 `RedisService`를 주입받았다면 `redis.getRawClient()`로 같은 underlying `ioredis` instance에 접근할 수 있습니다.
130
+
126
131
  ```typescript
127
132
  import { Inject } from '@fluojs/core';
128
133
  import { REDIS_CLIENT } from '@fluojs/redis';
@@ -141,11 +146,11 @@ export class AdvancedService {
141
146
  ## 공개 API 개요
142
147
 
143
148
  ### 핵심 구성 요소
144
- - `RedisModule`: 전역 Redis 클라이언트 등록 및 수명 주기 훅을 관리합니다.
145
- - `RedisModule.forRoot(options)`: `lazyConnect` 수명 주기 제어를 Fluo 내부에서 유지하면서 기본 Redis 클라이언트와 `RedisService` 파사드를 등록하는 지원되는 root entrypoint입니다.
146
- - `RedisModule.forRootNamed(name, options)`: 동일한 수명 주기 계약을 유지한 채 기본 별칭을 건드리지 않고 추가 Redis 클라이언트를 등록합니다.
149
+ - `RedisModule`: Redis 클라이언트 등록 및 수명 주기 훅을 관리합니다.
150
+ - `RedisModule.forRoot(options)`: `name`을 생략하면 기본 Redis 클라이언트와 `RedisService` 파사드를 등록하고, `name`을 제공하면 추가 이름 있는 Redis 클라이언트를 등록합니다. 기본 등록은 기본적으로 global이고, 이름 있는 등록은 scoped입니다.
147
151
  - `RedisService`: JSON 코덱 지원 및 `get`/`set`/`del` 메서드를 제공하는 파사드입니다.
148
152
  - `REDIS_CLIENT`: 내부 `ioredis` 인스턴스에 접근하기 위한 DI 토큰입니다.
153
+ - `DEFAULT_REDIS_CLIENT_NAME`: 안정적인 기본 Redis client name입니다.
149
154
  - `getRedisClientToken(name)`: 이름 있는 raw client 토큰 헬퍼입니다. `name`을 생략하면 기본 `REDIS_CLIENT` 토큰을 돌려줍니다.
150
155
  - `getRedisServiceToken(name)`: 이름 있는 `RedisService` 토큰 헬퍼입니다. `name`을 생략하면 기본 `RedisService` 토큰을 돌려줍니다.
151
156
  - `getRedisComponentId(name)`: Redis 소비 패키지들이 사용하는 상태/의존성 식별자 헬퍼입니다 (`redis.default`, `redis.cache` 등).
@@ -153,6 +158,7 @@ export class AdvancedService {
153
158
 
154
159
  ### 타입
155
160
  - `RedisModuleOptions`: `ioredis` 생성자에 전달되는 설정 옵션입니다.
161
+ - `PersistencePlatformStatusSnapshot`, `RedisStatusAdapterInput`: status snapshot input/output type입니다.
156
162
 
157
163
  ## 관련 패키지
158
164
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><strong><kbd>English</kbd></strong> <a href="./README.ko.md"><kbd>한국어</kbd></a></p>
4
4
 
5
- Shared Redis connection layer for fluo. It provides a singleton `ioredis` client managed by the application lifecycle.
5
+ Shared Redis connection layer for fluo. It provides a default app-scoped `ioredis` client plus optional named clients, all managed by the application lifecycle.
6
6
 
7
7
  ## Table of Contents
8
8
 
@@ -51,6 +51,8 @@ export class AppModule {}
51
51
 
52
52
  Inject `RedisService` for high-level operations or `REDIS_CLIENT` for the raw `ioredis` instance.
53
53
 
54
+ `RedisService.get()` attempts JSON parsing and falls back to the raw string; missing keys return `null`. `RedisService.set()` serializes values with `JSON.stringify()` and uses `EX` only for positive TTL values.
55
+
54
56
  ```typescript
55
57
  import { Inject } from '@fluojs/core';
56
58
  import { RedisService } from '@fluojs/redis';
@@ -73,7 +75,7 @@ export class CacheRepository {
73
75
 
74
76
  ### Lifecycle Ownership
75
77
 
76
- `@fluojs/redis` owns the lifecycle of every client it creates, including clients registered through `RedisModule.forRootNamed(...)`.
78
+ `@fluojs/redis` owns the lifecycle of every client it creates, including named clients registered through `RedisModule.forRoot({ name, ... })`.
77
79
 
78
80
  - Fluo always forces `lazyConnect: true`, even if callers cast options manually, so sockets open during application bootstrap instead of import time.
79
81
  - During bootstrap, the lifecycle service only calls `connect()` while the client is still in ioredis `wait` state.
@@ -82,11 +84,12 @@ export class CacheRepository {
82
84
 
83
85
  ### Named Clients
84
86
 
85
- Use `RedisModule.forRootNamed(name, options)` when one application needs more than one Redis connection. `RedisModule.forRoot(options)` provides the default `REDIS_CLIENT` and `RedisService` aliases, and named registrations are resolved with `getRedisClientToken(name)` and `getRedisServiceToken(name)`.
87
+ Use `RedisModule.forRoot({ name, ...options })` when one application needs more than one Redis connection. `RedisModule.forRoot(options)` without `name` provides the default `REDIS_CLIENT` and `RedisService` aliases, and named registrations are resolved with `getRedisClientToken(name)` and `getRedisServiceToken(name)`.
86
88
 
87
89
  - Omit `name` when you want the default aliases: `REDIS_CLIENT` / `RedisService`.
88
90
  - Pass `name` when you want the named helpers: `getRedisClientToken(name)` / `getRedisServiceToken(name)`.
89
91
  - Named clients follow the same bootstrap/shutdown contract as the default client; only the default registration exports the `REDIS_CLIENT` / `RedisService` aliases.
92
+ - Names are trimmed, and blank or whitespace-only names are rejected by token/component helpers.
90
93
 
91
94
  ```typescript
92
95
  import { Module, Inject } from '@fluojs/core';
@@ -104,7 +107,7 @@ const ANALYTICS_REDIS_CLIENT = getRedisClientToken('analytics');
104
107
  @Module({
105
108
  imports: [
106
109
  RedisModule.forRoot({ host: 'localhost', port: 6379 }),
107
- RedisModule.forRootNamed('analytics', { host: 'localhost', port: 6380 }),
110
+ RedisModule.forRoot({ name: 'analytics', host: 'localhost', port: 6380 }),
108
111
  ],
109
112
  })
110
113
  export class AppModule {}
@@ -123,6 +126,8 @@ export class AnalyticsStore {
123
126
 
124
127
  If you need advanced Redis commands (pipelines, lua scripts, pub/sub), inject the raw client directly.
125
128
 
129
+ If you already injected `RedisService`, call `redis.getRawClient()` to access the same underlying `ioredis` instance.
130
+
126
131
  ```typescript
127
132
  import { Inject } from '@fluojs/core';
128
133
  import { REDIS_CLIENT } from '@fluojs/redis';
@@ -141,11 +146,11 @@ export class AdvancedService {
141
146
  ## Public API Overview
142
147
 
143
148
  ### Core
144
- - `RedisModule`: Registers the global Redis client and lifecycle hooks.
145
- - `RedisModule.forRoot(options)`: Registers the default Redis client plus `RedisService` facade, with `lazyConnect` lifecycle ownership kept inside Fluo.
146
- - `RedisModule.forRootNamed(name, options)`: Registers an additional named Redis client without replacing the default aliases, using the same lifecycle contract.
149
+ - `RedisModule`: Registers Redis clients and lifecycle hooks.
150
+ - `RedisModule.forRoot(options)`: Registers the default Redis client plus `RedisService` facade when `name` is omitted, or an additional named Redis client when `name` is provided. The default registration is global by default; named registrations are scoped.
147
151
  - `RedisService`: Facade with JSON codec support and `get`/`set`/`del` methods.
148
152
  - `REDIS_CLIENT`: DI token for the underlying `ioredis` instance.
153
+ - `DEFAULT_REDIS_CLIENT_NAME`: Stable default Redis client name.
149
154
  - `getRedisClientToken(name)`: DI token helper for a named raw client. Omitting `name` returns the default `REDIS_CLIENT` token.
150
155
  - `getRedisServiceToken(name)`: DI token helper for a named `RedisService` facade. Omitting `name` returns the default `RedisService` token.
151
156
  - `getRedisComponentId(name)`: Status/dependency id helper used by Redis-consuming packages (`redis.default`, `redis.cache`, etc.).
@@ -153,6 +158,7 @@ export class AdvancedService {
153
158
 
154
159
  ### Types
155
160
  - `RedisModuleOptions`: Configuration options passed directly to the `ioredis` constructor.
161
+ - `PersistencePlatformStatusSnapshot`, `RedisStatusAdapterInput`: Status snapshot input/output types.
156
162
 
157
163
  ## Related Packages
158
164
 
package/dist/module.d.ts CHANGED
@@ -3,12 +3,11 @@ import type { RedisModuleOptions } from './types.js';
3
3
  /** Runtime module entrypoint for the shared Redis client integration. */
4
4
  export declare class RedisModule {
5
5
  /**
6
- * Registers a global Redis client and exports the facade used across Fluo packages.
6
+ * Registers the default Redis client or an additional named Redis client.
7
7
  *
8
- * @param options Redis client options used to construct the shared connection.
9
- * @returns A module definition that exports {@link REDIS_CLIENT} and {@link RedisService}.
8
+ * @param options Redis client options. Pass `name` to derive named client and service tokens.
9
+ * @returns A module definition that exports the matching Redis client and facade tokens.
10
10
  *
11
- * @see RedisModule.forRootNamed
12
11
  * @see getRedisClientToken
13
12
  * @see getRedisServiceToken
14
13
  *
@@ -18,54 +17,14 @@ export declare class RedisModule {
18
17
  * import { RedisModule } from '@fluojs/redis';
19
18
  *
20
19
  * @Module({
21
- * imports: [RedisModule.forRoot({ host: 'localhost', port: 6379 })],
22
- * })
23
- * export class AppModule {}
24
- * ```
25
- */
26
- static forRoot(options: RedisModuleOptions): ModuleType;
27
- /**
28
- * Registers one additional named Redis client without changing the default aliases.
29
- *
30
- * @param name Stable Redis client name used to derive named raw-client and facade tokens.
31
- * @param options Redis client options used to construct the named connection.
32
- * @returns A module definition that exports the named raw-client token and named `RedisService` token.
33
- *
34
- * @see getRedisClientToken
35
- * @see getRedisServiceToken
36
- *
37
- * @example
38
- * ```ts
39
- * import { Module, Inject } from '@fluojs/core';
40
- * import type Redis from 'ioredis';
41
- * import {
42
- * getRedisClientToken,
43
- * getRedisServiceToken,
44
- * RedisModule,
45
- * RedisService,
46
- * } from '@fluojs/redis';
47
- *
48
- * const ANALYTICS_REDIS = getRedisServiceToken('analytics');
49
- * const ANALYTICS_REDIS_CLIENT = getRedisClientToken('analytics');
50
- *
51
- * @Module({
52
20
  * imports: [
53
21
  * RedisModule.forRoot({ host: 'localhost', port: 6379 }),
54
- * RedisModule.forRootNamed('analytics', { host: 'localhost', port: 6380 }),
22
+ * RedisModule.forRoot({ name: 'analytics', host: 'localhost', port: 6380 }),
55
23
  * ],
56
24
  * })
57
25
  * export class AppModule {}
58
- *
59
- * @Inject(RedisService, ANALYTICS_REDIS, ANALYTICS_REDIS_CLIENT)
60
- * export class AnalyticsStore {
61
- * constructor(
62
- * private readonly defaultRedis: RedisService,
63
- * private readonly analyticsRedis: RedisService,
64
- * private readonly analyticsClient: Redis,
65
- * ) {}
66
- * }
67
26
  * ```
68
27
  */
69
- static forRootNamed(name: string, options: RedisModuleOptions): ModuleType;
28
+ static forRoot(options: RedisModuleOptions): ModuleType;
70
29
  }
71
30
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA6ErD,yEAAyE;AACzE,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU;IAUvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,UAAU;CAW3E"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMhE,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAoGzE,yEAAyE;AACzE,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU;CAYxD"}
package/dist/module.js CHANGED
@@ -21,6 +21,25 @@ function getRedisLifecycleToken(name) {
21
21
  * @param name Optional Redis client name for additional named registrations.
22
22
  * @returns Providers for the raw client token, the JSON-aware facade, and lifecycle hooks.
23
23
  */
24
+ function normalizeRedisModuleOptions(options) {
25
+ const {
26
+ global,
27
+ name,
28
+ ...clientOptions
29
+ } = options;
30
+ const normalizedName = name?.trim();
31
+ if (normalizedName !== undefined && normalizedName.length === 0) {
32
+ throw new Error('Redis client name must be a non-empty string when provided.');
33
+ }
34
+ if (normalizedName !== undefined && global === true) {
35
+ throw new Error('Named Redis registrations are scoped and cannot be registered globally.');
36
+ }
37
+ return {
38
+ clientOptions,
39
+ global: normalizedName === undefined ? global ?? true : false,
40
+ name: normalizedName
41
+ };
42
+ }
24
43
  function createRedisProviders(options, name) {
25
44
  const clientToken = getRedisClientToken(name);
26
45
  if (clientToken === REDIS_CLIENT) {
@@ -66,12 +85,11 @@ function createRedisProviders(options, name) {
66
85
  /** Runtime module entrypoint for the shared Redis client integration. */
67
86
  export class RedisModule {
68
87
  /**
69
- * Registers a global Redis client and exports the facade used across Fluo packages.
88
+ * Registers the default Redis client or an additional named Redis client.
70
89
  *
71
- * @param options Redis client options used to construct the shared connection.
72
- * @returns A module definition that exports {@link REDIS_CLIENT} and {@link RedisService}.
90
+ * @param options Redis client options. Pass `name` to derive named client and service tokens.
91
+ * @returns A module definition that exports the matching Redis client and facade tokens.
73
92
  *
74
- * @see RedisModule.forRootNamed
75
93
  * @see getRedisClientToken
76
94
  * @see getRedisServiceToken
77
95
  *
@@ -81,70 +99,23 @@ export class RedisModule {
81
99
  * import { RedisModule } from '@fluojs/redis';
82
100
  *
83
101
  * @Module({
84
- * imports: [RedisModule.forRoot({ host: 'localhost', port: 6379 })],
85
- * })
86
- * export class AppModule {}
87
- * ```
88
- */
89
- static forRoot(options) {
90
- class RedisModuleDefinition {}
91
- return defineModule(RedisModuleDefinition, {
92
- global: true,
93
- exports: [REDIS_CLIENT, RedisService],
94
- providers: createRedisProviders(options)
95
- });
96
- }
97
-
98
- /**
99
- * Registers one additional named Redis client without changing the default aliases.
100
- *
101
- * @param name Stable Redis client name used to derive named raw-client and facade tokens.
102
- * @param options Redis client options used to construct the named connection.
103
- * @returns A module definition that exports the named raw-client token and named `RedisService` token.
104
- *
105
- * @see getRedisClientToken
106
- * @see getRedisServiceToken
107
- *
108
- * @example
109
- * ```ts
110
- * import { Module, Inject } from '@fluojs/core';
111
- * import type Redis from 'ioredis';
112
- * import {
113
- * getRedisClientToken,
114
- * getRedisServiceToken,
115
- * RedisModule,
116
- * RedisService,
117
- * } from '@fluojs/redis';
118
- *
119
- * const ANALYTICS_REDIS = getRedisServiceToken('analytics');
120
- * const ANALYTICS_REDIS_CLIENT = getRedisClientToken('analytics');
121
- *
122
- * @Module({
123
102
  * imports: [
124
103
  * RedisModule.forRoot({ host: 'localhost', port: 6379 }),
125
- * RedisModule.forRootNamed('analytics', { host: 'localhost', port: 6380 }),
104
+ * RedisModule.forRoot({ name: 'analytics', host: 'localhost', port: 6380 }),
126
105
  * ],
127
106
  * })
128
107
  * export class AppModule {}
129
- *
130
- * @Inject(RedisService, ANALYTICS_REDIS, ANALYTICS_REDIS_CLIENT)
131
- * export class AnalyticsStore {
132
- * constructor(
133
- * private readonly defaultRedis: RedisService,
134
- * private readonly analyticsRedis: RedisService,
135
- * private readonly analyticsClient: Redis,
136
- * ) {}
137
- * }
138
108
  * ```
139
109
  */
140
- static forRootNamed(name, options) {
141
- const clientToken = getRedisClientToken(name);
142
- const serviceToken = getRedisServiceToken(name);
143
- class NamedRedisModuleDefinition {}
144
- return defineModule(NamedRedisModuleDefinition, {
145
- global: true,
146
- exports: [clientToken, serviceToken],
147
- providers: createRedisProviders(options, name)
110
+ static forRoot(options) {
111
+ const normalized = normalizeRedisModuleOptions(options);
112
+ const clientToken = getRedisClientToken(normalized.name);
113
+ const serviceToken = getRedisServiceToken(normalized.name);
114
+ class RedisModuleDefinition {}
115
+ return defineModule(RedisModuleDefinition, {
116
+ global: normalized.global,
117
+ exports: normalized.name === undefined ? [REDIS_CLIENT, RedisService] : [clientToken, serviceToken],
118
+ providers: createRedisProviders(normalized.clientOptions, normalized.name)
148
119
  });
149
120
  }
150
121
  }
@@ -59,7 +59,7 @@ export declare class RedisService {
59
59
  /**
60
60
  * Resolves the facade token for the default or a named `RedisService` binding.
61
61
  *
62
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
62
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
63
63
  * @returns `RedisService` for the default client path, otherwise a stable named service token.
64
64
  *
65
65
  * @example
@@ -72,7 +72,7 @@ export declare class RedisService {
72
72
  * }
73
73
  * ```
74
74
  *
75
- * @see RedisModule.forRootNamed
75
+ * @see RedisModule.forRoot
76
76
  * @see getRedisClientToken
77
77
  */
78
78
  export declare function getRedisServiceToken(name?: string): Token<RedisService>;
@@ -113,7 +113,7 @@ class RedisService {
113
113
  /**
114
114
  * Resolves the facade token for the default or a named `RedisService` binding.
115
115
  *
116
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
116
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
117
117
  * @returns `RedisService` for the default client path, otherwise a stable named service token.
118
118
  *
119
119
  * @example
@@ -126,7 +126,7 @@ class RedisService {
126
126
  * }
127
127
  * ```
128
128
  *
129
- * @see RedisModule.forRootNamed
129
+ * @see RedisModule.forRoot
130
130
  * @see getRedisClientToken
131
131
  */
132
132
  export { _RedisService as RedisService };
package/dist/tokens.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare const DEFAULT_REDIS_CLIENT_NAME = "default";
9
9
  /**
10
10
  * Resolves the DI token for the default or a named Redis client.
11
11
  *
12
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
12
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
13
13
  * @returns The default `REDIS_CLIENT` token when `name` is omitted, otherwise a stable named token.
14
14
  *
15
15
  * @example
@@ -22,14 +22,14 @@ export declare const DEFAULT_REDIS_CLIENT_NAME = "default";
22
22
  * }
23
23
  * ```
24
24
  *
25
- * @see RedisModule.forRootNamed
25
+ * @see RedisModule.forRoot
26
26
  * @see getRedisServiceToken
27
27
  */
28
28
  export declare function getRedisClientToken(name?: string): symbol;
29
29
  /**
30
30
  * Builds the stable component/dependency id used by platform status snapshots.
31
31
  *
32
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
32
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
33
33
  * @returns A stable component id such as `redis.default` or `redis.jobs`.
34
34
  *
35
35
  * @see getRedisClientToken
package/dist/tokens.js CHANGED
@@ -31,7 +31,7 @@ function getOrCreateNamedRedisClientToken(name) {
31
31
  /**
32
32
  * Resolves the DI token for the default or a named Redis client.
33
33
  *
34
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
34
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
35
35
  * @returns The default `REDIS_CLIENT` token when `name` is omitted, otherwise a stable named token.
36
36
  *
37
37
  * @example
@@ -44,7 +44,7 @@ function getOrCreateNamedRedisClientToken(name) {
44
44
  * }
45
45
  * ```
46
46
  *
47
- * @see RedisModule.forRootNamed
47
+ * @see RedisModule.forRoot
48
48
  * @see getRedisServiceToken
49
49
  */
50
50
  export function getRedisClientToken(name) {
@@ -58,7 +58,7 @@ export function getRedisClientToken(name) {
58
58
  /**
59
59
  * Builds the stable component/dependency id used by platform status snapshots.
60
60
  *
61
- * @param name Optional Redis client name registered through `RedisModule.forRootNamed(...)`.
61
+ * @param name Optional Redis client name registered through `RedisModule.forRoot({ name, ... })`.
62
62
  * @returns A stable component id such as `redis.default` or `redis.jobs`.
63
63
  *
64
64
  * @see getRedisClientToken
package/dist/types.d.ts CHANGED
@@ -1,9 +1,26 @@
1
1
  import type { RedisOptions } from 'ioredis';
2
+ type RedisConnectionOptions = Omit<RedisOptions, 'lazyConnect'>;
3
+ /** Options accepted by the default unnamed Redis registration. */
4
+ export type DefaultRedisModuleOptions = RedisConnectionOptions & {
5
+ /** Whether the default Redis aliases should be visible globally. Defaults to `true`. */
6
+ global?: boolean;
7
+ name?: undefined;
8
+ };
9
+ /** Options accepted by an additional named Redis registration. */
10
+ export type NamedRedisModuleOptions = RedisConnectionOptions & {
11
+ /** Registration name used to derive named raw-client and facade tokens. */
12
+ name: string;
13
+ /** Named Redis registrations remain scoped to their importing module. */
14
+ global?: false;
15
+ };
2
16
  /**
3
17
  * Options accepted by {@link RedisModule.forRoot}.
4
18
  *
5
19
  * Fluo always enables `lazyConnect` internally so the client connects during
6
20
  * application bootstrap instead of import time.
7
21
  */
8
- export type RedisModuleOptions = Omit<RedisOptions, 'lazyConnect'>;
22
+ export type RedisModuleOptions = DefaultRedisModuleOptions | NamedRedisModuleOptions;
23
+ /** Redis constructor options after Fluo module-only fields are removed. */
24
+ export type RedisClientOptions = RedisConnectionOptions;
25
+ export {};
9
26
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,sBAAsB,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEhE,kEAAkE;AAClE,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,GAAG;IAC/D,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,GAAG;IAC7D,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG,uBAAuB,CAAC;AAErF,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "connection",
10
10
  "lifecycle"
11
11
  ],
12
- "version": "1.0.0-beta.2",
12
+ "version": "1.0.0-beta.4",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -36,12 +36,15 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "ioredis": "^5.10.0",
40
- "@fluojs/di": "^1.0.0-beta.2",
41
- "@fluojs/runtime": "^1.0.0-beta.2",
42
- "@fluojs/core": "^1.0.0-beta.1"
39
+ "@fluojs/core": "^1.0.0-beta.5",
40
+ "@fluojs/di": "^1.0.0-beta.7",
41
+ "@fluojs/runtime": "^1.0.0-beta.12"
42
+ },
43
+ "peerDependencies": {
44
+ "ioredis": "^5.10.0"
43
45
  },
44
46
  "devDependencies": {
47
+ "ioredis": "^5.10.0",
45
48
  "vitest": "^3.2.4"
46
49
  },
47
50
  "scripts": {