@bridgebase/redis 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ Redis adapter for BridgeBase - Native Redis client with gateway integration.
12
12
  ## Installation
13
13
 
14
14
  ```bash
15
- npm install @bridgebase/redis redis
15
+ npm install @bridgebase/redis
16
16
  ```
17
17
 
18
18
  ## Quick Start
package/dist/index.d.mts CHANGED
@@ -59,6 +59,6 @@ declare function createRedisSession(jwtToken: string, options?: Partial<RedisSes
59
59
  /**
60
60
  * SDK version
61
61
  */
62
- declare const version = "0.2.0";
62
+ declare const version = "0.2.1";
63
63
 
64
64
  export { type RedisConnection, RedisSession, type RedisSessionConfig, connectRedis, createRedisSession, redis, version };
package/dist/index.d.ts CHANGED
@@ -59,6 +59,6 @@ declare function createRedisSession(jwtToken: string, options?: Partial<RedisSes
59
59
  /**
60
60
  * SDK version
61
61
  */
62
- declare const version = "0.2.0";
62
+ declare const version = "0.2.1";
63
63
 
64
64
  export { type RedisConnection, RedisSession, type RedisSessionConfig, connectRedis, createRedisSession, redis, version };
package/dist/index.js CHANGED
@@ -124,7 +124,7 @@ function createRedisSession(jwtToken, options) {
124
124
  ...options
125
125
  });
126
126
  }
127
- var version = "0.2.0";
127
+ var version = "0.2.1";
128
128
  // Annotate the CommonJS export names for ESM import in node:
129
129
  0 && (module.exports = {
130
130
  AuthError,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/sessions/RedisSession.ts"],"sourcesContent":["/**\n * @bridgebase/redis - Redis adapter with BridgeBase gateway integration\n */\n\nimport { RedisSession, RedisSessionConfig } from \"./sessions/RedisSession\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisConnection {\n client: RedisClientType;\n disconnect: () => Promise<void>;\n}\n\n/**\n * Convenience factory function for Redis\n * Creates and connects a session in one call\n */\nexport async function connectRedis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n const session = new RedisSession({\n jwtToken,\n ...options,\n });\n await session.connect();\n return {\n client: session.client,\n disconnect: () => session.disconnect(),\n };\n}\n\n/**\n * Alias for connectRedis\n */\nexport async function redis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n return connectRedis(jwtToken, options);\n}\n\n/**\n * Factory function to create a session without auto-connecting\n */\nexport function createRedisSession(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): RedisSession {\n return new RedisSession({\n jwtToken,\n ...options,\n });\n}\n\n// Session exports\nexport { RedisSession };\nexport type { RedisSessionConfig } from \"./sessions/RedisSession\";\n\n// Re-export commonly used Redis types for convenience\nexport type { RedisClientType } from \"redis\";\n\n// Re-export core types and exceptions\nexport {\n BridgeBaseError,\n AuthError,\n GatewayError,\n GatewayResolutionError,\n ConnectionError,\n CredentialError,\n ProxyError,\n} from \"@bridgebase/core\";\n\nexport type { SessionConfig, DatabaseCredentials } from \"@bridgebase/core\";\n\n/**\n * SDK version\n */\nexport const version = \"0.2.0\";\n","import { BaseSession, DatabaseCredentials, SessionConfig, ConnectionError } from \"@bridgebase/core\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisSessionConfig extends SessionConfig {\n db?: number;\n}\n\n/**\n * Session adapter for Redis database\n * Provides full access to node-redis client methods\n */\nexport class RedisSession extends BaseSession<RedisClientType> {\n private db: number;\n\n constructor(config: RedisSessionConfig) {\n super(config);\n this.db = config.db ?? 0;\n this.dbType = \"redis\";\n }\n\n /**\n * Access native Redis client\n * Must call connect() first\n * \n * All redis (node-redis) client methods are available:\n * - Basic commands: get, set, del, exists, etc.\n * - Hashes: hSet, hGet, hGetAll, hDel, etc.\n * - Lists: lPush, rPush, lPop, rPop, lRange, etc.\n * - Sets: sAdd, sRem, sMembers, etc.\n * - Sorted Sets: zAdd, zRem, zRange, zScore, etc.\n * - Pub/Sub: publish, subscribe, unsubscribe, etc.\n * - Transactions: multi, exec, etc.\n * - And many more...\n */\n get client(): RedisClientType {\n if (!this.nativeClient) {\n throw new ConnectionError(\n \"Session not connected. Call connect() first.\",\n \"SESSION_NOT_CONNECTED\"\n );\n }\n return this.nativeClient;\n }\n\n protected async connectNative(\n credentials: DatabaseCredentials | null,\n proxyPort: number,\n ): Promise<RedisClientType> {\n try {\n // Lazy import redis\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const redis = require(\"redis\");\n\n const client = redis.createClient({\n socket: {\n host: \"127.0.0.1\",\n port: proxyPort,\n },\n database: this.db,\n });\n\n await client.connect();\n return client;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new ConnectionError(\n `Failed to connect to Redis: ${message}`,\n \"REDIS_CONNECT_FAILED\",\n { originalError: error },\n );\n }\n }\n\n protected async closeNative(nativeClient: RedisClientType): Promise<void> {\n if (nativeClient && typeof nativeClient.quit === \"function\") {\n await nativeClient.quit();\n } else if (nativeClient && typeof nativeClient.disconnect === \"function\") {\n await nativeClient.disconnect();\n }\n }\n\n protected get requiresCredentials(): boolean {\n return false;\n }\n\n protected get dbLabel(): string {\n return \"Redis\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiF;AAW1E,IAAM,eAAN,cAA2B,wBAA6B;AAAA,EAG7D,YAAY,QAA4B;AACtC,UAAM,MAAM;AACZ,SAAK,KAAK,OAAO,MAAM;AACvB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,IAAI,SAA0B;AAC5B,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,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sources":["../src/index.ts","../src/sessions/RedisSession.ts"],"sourcesContent":["/**\n * @bridgebase/redis - Redis adapter with BridgeBase gateway integration\n */\n\nimport { RedisSession, RedisSessionConfig } from \"./sessions/RedisSession\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisConnection {\n client: RedisClientType;\n disconnect: () => Promise<void>;\n}\n\n/**\n * Convenience factory function for Redis\n * Creates and connects a session in one call\n */\nexport async function connectRedis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n const session = new RedisSession({\n jwtToken,\n ...options,\n });\n await session.connect();\n return {\n client: session.client,\n disconnect: () => session.disconnect(),\n };\n}\n\n/**\n * Alias for connectRedis\n */\nexport async function redis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n return connectRedis(jwtToken, options);\n}\n\n/**\n * Factory function to create a session without auto-connecting\n */\nexport function createRedisSession(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): RedisSession {\n return new RedisSession({\n jwtToken,\n ...options,\n });\n}\n\n// Session exports\nexport { RedisSession };\nexport type { RedisSessionConfig } from \"./sessions/RedisSession\";\n\n// Re-export commonly used Redis types for convenience\nexport type { RedisClientType } from \"redis\";\n\n// Re-export core types and exceptions\nexport {\n BridgeBaseError,\n AuthError,\n GatewayError,\n GatewayResolutionError,\n ConnectionError,\n CredentialError,\n ProxyError,\n} from \"@bridgebase/core\";\n\nexport type { SessionConfig, DatabaseCredentials } from \"@bridgebase/core\";\n\n/**\n * SDK version\n */\nexport const version = \"0.2.1\";\n","import { BaseSession, DatabaseCredentials, SessionConfig, ConnectionError } from \"@bridgebase/core\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisSessionConfig extends SessionConfig {\n db?: number;\n}\n\n/**\n * Session adapter for Redis database\n * Provides full access to node-redis client methods\n */\nexport class RedisSession extends BaseSession<RedisClientType> {\n private db: number;\n\n constructor(config: RedisSessionConfig) {\n super(config);\n this.db = config.db ?? 0;\n this.dbType = \"redis\";\n }\n\n /**\n * Access native Redis client\n * Must call connect() first\n * \n * All redis (node-redis) client methods are available:\n * - Basic commands: get, set, del, exists, etc.\n * - Hashes: hSet, hGet, hGetAll, hDel, etc.\n * - Lists: lPush, rPush, lPop, rPop, lRange, etc.\n * - Sets: sAdd, sRem, sMembers, etc.\n * - Sorted Sets: zAdd, zRem, zRange, zScore, etc.\n * - Pub/Sub: publish, subscribe, unsubscribe, etc.\n * - Transactions: multi, exec, etc.\n * - And many more...\n */\n get client(): RedisClientType {\n if (!this.nativeClient) {\n throw new ConnectionError(\n \"Session not connected. Call connect() first.\",\n \"SESSION_NOT_CONNECTED\"\n );\n }\n return this.nativeClient;\n }\n\n protected async connectNative(\n credentials: DatabaseCredentials | null,\n proxyPort: number,\n ): Promise<RedisClientType> {\n try {\n // Lazy import redis\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const redis = require(\"redis\");\n\n const client = redis.createClient({\n socket: {\n host: \"127.0.0.1\",\n port: proxyPort,\n },\n database: this.db,\n });\n\n await client.connect();\n return client;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new ConnectionError(\n `Failed to connect to Redis: ${message}`,\n \"REDIS_CONNECT_FAILED\",\n { originalError: error },\n );\n }\n }\n\n protected async closeNative(nativeClient: RedisClientType): Promise<void> {\n if (nativeClient && typeof nativeClient.quit === \"function\") {\n await nativeClient.quit();\n } else if (nativeClient && typeof nativeClient.disconnect === \"function\") {\n await nativeClient.disconnect();\n }\n }\n\n protected get requiresCredentials(): boolean {\n return false;\n }\n\n protected get dbLabel(): string {\n return \"Redis\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiF;AAW1E,IAAM,eAAN,cAA2B,wBAA6B;AAAA,EAG7D,YAAY,QAA4B;AACtC,UAAM,MAAM;AACZ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,QAAQ;AAAA,IAChB,YAAY,MAAM,QAAQ,WAAW;AAAA,EACvC;AACF;AAKA,eAAsB,MACpB,UACA,SAC0B;AAC1B,SAAO,aAAa,UAAU,OAAO;AACvC;AAKO,SAAS,mBACd,UACA,SACc;AACd,SAAO,IAAI,aAAa;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;AAyBO,IAAM,UAAU;","names":["redis","import_core"]}
package/dist/index.mjs CHANGED
@@ -102,7 +102,7 @@ function createRedisSession(jwtToken, options) {
102
102
  ...options
103
103
  });
104
104
  }
105
- var version = "0.2.0";
105
+ var version = "0.2.1";
106
106
  export {
107
107
  AuthError,
108
108
  BridgeBaseError,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sessions/RedisSession.ts","../src/index.ts"],"sourcesContent":["import { BaseSession, DatabaseCredentials, SessionConfig, ConnectionError } from \"@bridgebase/core\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisSessionConfig extends SessionConfig {\n db?: number;\n}\n\n/**\n * Session adapter for Redis database\n * Provides full access to node-redis client methods\n */\nexport class RedisSession extends BaseSession<RedisClientType> {\n private db: number;\n\n constructor(config: RedisSessionConfig) {\n super(config);\n this.db = config.db ?? 0;\n this.dbType = \"redis\";\n }\n\n /**\n * Access native Redis client\n * Must call connect() first\n * \n * All redis (node-redis) client methods are available:\n * - Basic commands: get, set, del, exists, etc.\n * - Hashes: hSet, hGet, hGetAll, hDel, etc.\n * - Lists: lPush, rPush, lPop, rPop, lRange, etc.\n * - Sets: sAdd, sRem, sMembers, etc.\n * - Sorted Sets: zAdd, zRem, zRange, zScore, etc.\n * - Pub/Sub: publish, subscribe, unsubscribe, etc.\n * - Transactions: multi, exec, etc.\n * - And many more...\n */\n get client(): RedisClientType {\n if (!this.nativeClient) {\n throw new ConnectionError(\n \"Session not connected. Call connect() first.\",\n \"SESSION_NOT_CONNECTED\"\n );\n }\n return this.nativeClient;\n }\n\n protected async connectNative(\n credentials: DatabaseCredentials | null,\n proxyPort: number,\n ): Promise<RedisClientType> {\n try {\n // Lazy import redis\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const redis = require(\"redis\");\n\n const client = redis.createClient({\n socket: {\n host: \"127.0.0.1\",\n port: proxyPort,\n },\n database: this.db,\n });\n\n await client.connect();\n return client;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new ConnectionError(\n `Failed to connect to Redis: ${message}`,\n \"REDIS_CONNECT_FAILED\",\n { originalError: error },\n );\n }\n }\n\n protected async closeNative(nativeClient: RedisClientType): Promise<void> {\n if (nativeClient && typeof nativeClient.quit === \"function\") {\n await nativeClient.quit();\n } else if (nativeClient && typeof nativeClient.disconnect === \"function\") {\n await nativeClient.disconnect();\n }\n }\n\n protected get requiresCredentials(): boolean {\n return false;\n }\n\n protected get dbLabel(): string {\n return \"Redis\";\n }\n}\n","/**\n * @bridgebase/redis - Redis adapter with BridgeBase gateway integration\n */\n\nimport { RedisSession, RedisSessionConfig } from \"./sessions/RedisSession\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisConnection {\n client: RedisClientType;\n disconnect: () => Promise<void>;\n}\n\n/**\n * Convenience factory function for Redis\n * Creates and connects a session in one call\n */\nexport async function connectRedis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n const session = new RedisSession({\n jwtToken,\n ...options,\n });\n await session.connect();\n return {\n client: session.client,\n disconnect: () => session.disconnect(),\n };\n}\n\n/**\n * Alias for connectRedis\n */\nexport async function redis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n return connectRedis(jwtToken, options);\n}\n\n/**\n * Factory function to create a session without auto-connecting\n */\nexport function createRedisSession(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): RedisSession {\n return new RedisSession({\n jwtToken,\n ...options,\n });\n}\n\n// Session exports\nexport { RedisSession };\nexport type { RedisSessionConfig } from \"./sessions/RedisSession\";\n\n// Re-export commonly used Redis types for convenience\nexport type { RedisClientType } from \"redis\";\n\n// Re-export core types and exceptions\nexport {\n BridgeBaseError,\n AuthError,\n GatewayError,\n GatewayResolutionError,\n ConnectionError,\n CredentialError,\n ProxyError,\n} from \"@bridgebase/core\";\n\nexport type { SessionConfig, DatabaseCredentials } from \"@bridgebase/core\";\n\n/**\n * SDK version\n */\nexport const version = \"0.2.0\";\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAiD,uBAAuB;AAW1E,IAAM,eAAN,cAA2B,YAA6B;AAAA,EAG7D,YAAY,QAA4B;AACtC,UAAM,MAAM;AACZ,SAAK,KAAK,OAAO,MAAM;AACvB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,IAAI,SAA0B;AAC5B,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAgB,cACd,aACA,WAC0B;AAC1B,QAAI;AAGF,YAAMA,SAAQ,UAAQ,OAAO;AAE7B,YAAM,SAASA,OAAM,aAAa;AAAA,QAChC,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,QACA,UAAU,KAAK;AAAA,MACjB,CAAC;AAED,YAAM,OAAO,QAAQ;AACrB,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,YAAM,IAAI;AAAA,QACR,+BAA+B,OAAO;AAAA,QACtC;AAAA,QACA,EAAE,eAAe,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAgB,YAAY,cAA8C;AACxE,QAAI,gBAAgB,OAAO,aAAa,SAAS,YAAY;AAC3D,YAAM,aAAa,KAAK;AAAA,IAC1B,WAAW,gBAAgB,OAAO,aAAa,eAAe,YAAY;AACxE,YAAM,aAAa,WAAW;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,IAAc,sBAA+B;AAC3C,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,UAAkB;AAC9B,WAAO;AAAA,EACT;AACF;;;AC1BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAtDP,eAAsB,aACpB,UACA,SAC0B;AAC1B,QAAM,UAAU,IAAI,aAAa;AAAA,IAC/B;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACD,QAAM,QAAQ,QAAQ;AACtB,SAAO;AAAA,IACL,QAAQ,QAAQ;AAAA,IAChB,YAAY,MAAM,QAAQ,WAAW;AAAA,EACvC;AACF;AAKA,eAAsB,MACpB,UACA,SAC0B;AAC1B,SAAO,aAAa,UAAU,OAAO;AACvC;AAKO,SAAS,mBACd,UACA,SACc;AACd,SAAO,IAAI,aAAa;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;AAyBO,IAAM,UAAU;","names":["redis","ConnectionError"]}
1
+ {"version":3,"sources":["../src/sessions/RedisSession.ts","../src/index.ts"],"sourcesContent":["import { BaseSession, DatabaseCredentials, SessionConfig, ConnectionError } from \"@bridgebase/core\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisSessionConfig extends SessionConfig {\n db?: number;\n}\n\n/**\n * Session adapter for Redis database\n * Provides full access to node-redis client methods\n */\nexport class RedisSession extends BaseSession<RedisClientType> {\n private db: number;\n\n constructor(config: RedisSessionConfig) {\n super(config);\n this.db = config.db ?? 0;\n this.dbType = \"redis\";\n }\n\n /**\n * Access native Redis client\n * Must call connect() first\n * \n * All redis (node-redis) client methods are available:\n * - Basic commands: get, set, del, exists, etc.\n * - Hashes: hSet, hGet, hGetAll, hDel, etc.\n * - Lists: lPush, rPush, lPop, rPop, lRange, etc.\n * - Sets: sAdd, sRem, sMembers, etc.\n * - Sorted Sets: zAdd, zRem, zRange, zScore, etc.\n * - Pub/Sub: publish, subscribe, unsubscribe, etc.\n * - Transactions: multi, exec, etc.\n * - And many more...\n */\n get client(): RedisClientType {\n if (!this.nativeClient) {\n throw new ConnectionError(\n \"Session not connected. Call connect() first.\",\n \"SESSION_NOT_CONNECTED\"\n );\n }\n return this.nativeClient;\n }\n\n protected async connectNative(\n credentials: DatabaseCredentials | null,\n proxyPort: number,\n ): Promise<RedisClientType> {\n try {\n // Lazy import redis\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const redis = require(\"redis\");\n\n const client = redis.createClient({\n socket: {\n host: \"127.0.0.1\",\n port: proxyPort,\n },\n database: this.db,\n });\n\n await client.connect();\n return client;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new ConnectionError(\n `Failed to connect to Redis: ${message}`,\n \"REDIS_CONNECT_FAILED\",\n { originalError: error },\n );\n }\n }\n\n protected async closeNative(nativeClient: RedisClientType): Promise<void> {\n if (nativeClient && typeof nativeClient.quit === \"function\") {\n await nativeClient.quit();\n } else if (nativeClient && typeof nativeClient.disconnect === \"function\") {\n await nativeClient.disconnect();\n }\n }\n\n protected get requiresCredentials(): boolean {\n return false;\n }\n\n protected get dbLabel(): string {\n return \"Redis\";\n }\n}\n","/**\n * @bridgebase/redis - Redis adapter with BridgeBase gateway integration\n */\n\nimport { RedisSession, RedisSessionConfig } from \"./sessions/RedisSession\";\nimport type { RedisClientType } from \"redis\";\n\nexport interface RedisConnection {\n client: RedisClientType;\n disconnect: () => Promise<void>;\n}\n\n/**\n * Convenience factory function for Redis\n * Creates and connects a session in one call\n */\nexport async function connectRedis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n const session = new RedisSession({\n jwtToken,\n ...options,\n });\n await session.connect();\n return {\n client: session.client,\n disconnect: () => session.disconnect(),\n };\n}\n\n/**\n * Alias for connectRedis\n */\nexport async function redis(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): Promise<RedisConnection> {\n return connectRedis(jwtToken, options);\n}\n\n/**\n * Factory function to create a session without auto-connecting\n */\nexport function createRedisSession(\n jwtToken: string,\n options?: Partial<RedisSessionConfig>\n): RedisSession {\n return new RedisSession({\n jwtToken,\n ...options,\n });\n}\n\n// Session exports\nexport { RedisSession };\nexport type { RedisSessionConfig } from \"./sessions/RedisSession\";\n\n// Re-export commonly used Redis types for convenience\nexport type { RedisClientType } from \"redis\";\n\n// Re-export core types and exceptions\nexport {\n BridgeBaseError,\n AuthError,\n GatewayError,\n GatewayResolutionError,\n ConnectionError,\n CredentialError,\n ProxyError,\n} from \"@bridgebase/core\";\n\nexport type { SessionConfig, DatabaseCredentials } from \"@bridgebase/core\";\n\n/**\n * SDK version\n */\nexport const version = \"0.2.1\";\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAiD,uBAAuB;AAW1E,IAAM,eAAN,cAA2B,YAA6B;AAAA,EAG7D,YAAY,QAA4B;AACtC,UAAM,MAAM;AACZ,SAAK,KAAK,OAAO,MAAM;AACvB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,IAAI,SAA0B;AAC5B,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAgB,cACd,aACA,WAC0B;AAC1B,QAAI;AAGF,YAAMA,SAAQ,UAAQ,OAAO;AAE7B,YAAM,SAASA,OAAM,aAAa;AAAA,QAChC,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,QACA,UAAU,KAAK;AAAA,MACjB,CAAC;AAED,YAAM,OAAO,QAAQ;AACrB,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,YAAM,IAAI;AAAA,QACR,+BAA+B,OAAO;AAAA,QACtC;AAAA,QACA,EAAE,eAAe,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAgB,YAAY,cAA8C;AACxE,QAAI,gBAAgB,OAAO,aAAa,SAAS,YAAY;AAC3D,YAAM,aAAa,KAAK;AAAA,IAC1B,WAAW,gBAAgB,OAAO,aAAa,eAAe,YAAY;AACxE,YAAM,aAAa,WAAW;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,IAAc,sBAA+B;AAC3C,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,UAAkB;AAC9B,WAAO;AAAA,EACT;AACF;;;AC1BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAtDP,eAAsB,aACpB,UACA,SAC0B;AAC1B,QAAM,UAAU,IAAI,aAAa;AAAA,IAC/B;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACD,QAAM,QAAQ,QAAQ;AACtB,SAAO;AAAA,IACL,QAAQ,QAAQ;AAAA,IAChB,YAAY,MAAM,QAAQ,WAAW;AAAA,EACvC;AACF;AAKA,eAAsB,MACpB,UACA,SAC0B;AAC1B,SAAO,aAAa,UAAU,OAAO;AACvC;AAKO,SAAS,mBACd,UACA,SACc;AACd,SAAO,IAAI,aAAa;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;AAyBO,IAAM,UAAU;","names":["redis","ConnectionError"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridgebase/redis",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "BridgeBase Redis Adapter - Native Redis client wrapper with BridgeBase gateway integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,16 +44,9 @@
44
44
  "directory": "packages/redis"
45
45
  },
46
46
  "dependencies": {
47
- "@bridgebase/core": "^0.2.0"
48
- },
49
- "peerDependencies": {
47
+ "@bridgebase/core": "^0.2.0",
50
48
  "redis": "^5.0.0"
51
49
  },
52
- "peerDependenciesMeta": {
53
- "redis": {
54
- "optional": true
55
- }
56
- },
57
50
  "devDependencies": {
58
51
  "@bridgebase/core": "^0.2.0",
59
52
  "@types/node": "^20.0.0",