@enterprisestandard/ioredis 0.0.13 → 0.0.14-beta.20260331.2
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.md +33 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @enterprisestandard/ioredis
|
|
2
2
|
|
|
3
|
-
ioredis adapter and Redis stores for Enterprise Standard. Install this package and **ioredis**; import the adapter and
|
|
3
|
+
ioredis adapter and Redis stores for Enterprise Standard. Install this package and **ioredis**; import the adapter, stores, and **`esRedis(...)`** helper from here. You do not need to install `@enterprisestandard/redis-core` separately.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,6 +8,38 @@ ioredis adapter and Redis stores for Enterprise Standard. Install this package a
|
|
|
8
8
|
bun add @enterprisestandard/ioredis ioredis
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Secret-backed reactive Redis
|
|
12
|
+
|
|
13
|
+
Use **`esRedis(path, secrets?)`** when your ioredis connection details come from `es.secrets` and may change over time.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { enterpriseStandard, envConfig } from '@enterprisestandard/server';
|
|
17
|
+
import { createValidators } from '@enterprisestandard/zod';
|
|
18
|
+
import { esRedis, RedisSessionStore, RedisUserStore } from '@enterprisestandard/ioredis';
|
|
19
|
+
|
|
20
|
+
const redis = esRedis('examples:sso:redis');
|
|
21
|
+
|
|
22
|
+
export const es = enterpriseStandard(envConfig(), {
|
|
23
|
+
validators: createValidators(),
|
|
24
|
+
secrets: {
|
|
25
|
+
redis: {},
|
|
26
|
+
},
|
|
27
|
+
stores: {
|
|
28
|
+
sessionStore: new RedisSessionStore({ redis }),
|
|
29
|
+
userStore: new RedisUserStore({ redis }),
|
|
30
|
+
},
|
|
31
|
+
async afterChange(es) {
|
|
32
|
+
redis.configure(es.secrets);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Notes:
|
|
38
|
+
|
|
39
|
+
- The first argument is the **secret path**. The default named secrets source is **`redis`**; pass `{ sourceName }` if your source uses a different name.
|
|
40
|
+
- The secret payload may be either an ioredis options object or `{ redisUrl, ...options }`.
|
|
41
|
+
- Store operations wait for the first configured connection, and `ready()` remains available when you want an explicit startup or health-check barrier. Later secret version changes reconnect the adapter in place.
|
|
42
|
+
|
|
11
43
|
## Usage
|
|
12
44
|
|
|
13
45
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedisAdapter as RedisAdapter2 } from "@enterprisestandard/redis-core";
|
|
2
|
-
import { getKeyPrefix, getLogger, isRedisVersionSupported, prefixedKey, RedisGroupStore, RedisMagicLinkStore, RedisSessionStore, RedisStoreOptions, RedisTenantStore, RedisUserStore, RedisWorkloadTokenStore, supportsSortedSetList } from "@enterprisestandard/redis-core";
|
|
2
|
+
import { createReactiveRedis, getKeyPrefix, getLogger, isRedisVersionSupported, prefixedKey, ReactiveRedisAdapter as ReactiveRedisAdapter2, ReactiveRedisClient, ReactiveRedisOptions, RedisGroupStore, RedisMagicLinkStore, RedisSessionStore, RedisStoreOptions, RedisTenantStore, RedisUserStore, RedisWorkloadTokenStore, supportsSortedSetList } from "@enterprisestandard/redis-core";
|
|
3
3
|
import { RedisAdapter } from "@enterprisestandard/redis-core";
|
|
4
4
|
import { Redis } from "ioredis";
|
|
5
5
|
/**
|
|
@@ -7,4 +7,17 @@ import { Redis } from "ioredis";
|
|
|
7
7
|
* Implements the full interface including sorted-set list and getRedisVersion.
|
|
8
8
|
*/
|
|
9
9
|
declare function createIoredisAdapter(redis: Redis): RedisAdapter;
|
|
10
|
-
|
|
10
|
+
import { Logger, Secrets, SecretsOperationOptions } from "@enterprisestandard/core";
|
|
11
|
+
import { ReactiveRedisAdapter } from "@enterprisestandard/redis-core";
|
|
12
|
+
import { RedisOptions } from "ioredis";
|
|
13
|
+
type ESIoredisSecret = RedisOptions & {
|
|
14
|
+
redisUrl?: string;
|
|
15
|
+
clientOptions?: RedisOptions;
|
|
16
|
+
};
|
|
17
|
+
type ESIoredisOptions = {
|
|
18
|
+
sourceName?: string;
|
|
19
|
+
logger?: Logger;
|
|
20
|
+
secretOptions?: SecretsOperationOptions;
|
|
21
|
+
};
|
|
22
|
+
declare function esRedis(path: string, secrets?: Secrets, options?: ESIoredisOptions): ReactiveRedisAdapter;
|
|
23
|
+
export { supportsSortedSetList, prefixedKey, isRedisVersionSupported, getLogger, getKeyPrefix, esRedis, createReactiveRedis, createIoredisAdapter, RedisWorkloadTokenStore, RedisUserStore, RedisTenantStore, RedisStoreOptions, RedisSessionStore, RedisMagicLinkStore, RedisGroupStore, RedisAdapter2 as RedisAdapter, ReactiveRedisOptions, ReactiveRedisClient, ReactiveRedisAdapter2 as ReactiveRedisAdapter, ESIoredisSecret, ESIoredisOptions };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getKeyPrefix as
|
|
1
|
+
import{createReactiveRedis as I,getKeyPrefix as A,getLogger as E,isRedisVersionSupported as L,prefixedKey as N,RedisGroupStore as C,RedisMagicLinkStore as v,RedisSessionStore as K,RedisTenantStore as P,RedisUserStore as T,RedisWorkloadTokenStore as j,supportsSortedSetList as q}from"@enterprisestandard/redis-core";function p(e){return{async get(t){return e.get(t)},async set(t,o){await e.set(t,o)},async setex(t,o,i){await e.setex(t,o,i)},async del(t){await e.del(t)},async sadd(t,...o){if(o.length>0)await e.sadd(t,...o)},async srem(t,...o){if(o.length>0)await e.srem(t,...o)},async smembers(t){return e.smembers(t)},async mget(t){if(t.length===0)return[];return e.mget(...t)},async zadd(t,o,i){await e.zadd(t,o,i)},async zrem(t,...o){if(o.length>0)await e.zrem(t,...o)},async zrange(t,o,i,r){if(r)return e.zrevrange(t,o,i);return e.zrange(t,o,i)},async zcard(t){return e.zcard(t)},async getRedisVersion(){let t=await e.call("INFO","server");if(typeof t!=="string")return null;let o=/redis_version:([^\r\n]+)/.exec(t);return o?o[1].trim():null}}}import{createReactiveRedis as d}from"@enterprisestandard/redis-core";import c from"ioredis";function a(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function R(e){let t=a(e.clientOptions)?{...e.clientOptions}:{...e};return delete t.redisUrl,delete t.clientOptions,{redisUrl:(typeof e.redisUrl==="string"?e.redisUrl.trim():"")||void 0,clientOptions:t}}async function g(e){try{await e.quit()}catch{e.disconnect()}}function O(e,t,o={}){return d({path:e,secrets:t,sourceName:o.sourceName,logger:o.logger,secretOptions:o.secretOptions,async createClient(i){let r=R(i.data),n=r.redisUrl?new c(r.redisUrl,r.clientOptions):new c(r.clientOptions);return n.on("error",(s)=>{o.logger?.warn?.("Reactive ioredis client error",{path:e,sourceName:o.sourceName??"redis",error:s.message})}),{adapter:p(n),dispose:async()=>{await g(n)}}}})}export{q as supportsSortedSetList,N as prefixedKey,L as isRedisVersionSupported,E as getLogger,A as getKeyPrefix,O as esRedis,I as createReactiveRedis,p as createIoredisAdapter,j as RedisWorkloadTokenStore,T as RedisUserStore,P as RedisTenantStore,K as RedisSessionStore,v as RedisMagicLinkStore,C as RedisGroupStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enterprisestandard/ioredis",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14-beta.20260331.2",
|
|
4
4
|
"description": "ioredis adapter and Redis stores for Enterprise Standard. Single package: install this and ioredis; import adapter and stores from here.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "enterprisestandard",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@enterprisestandard/redis-core": "
|
|
24
|
+
"@enterprisestandard/redis-core": "0.0.14-beta.20260331.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"ioredis": "*"
|