/** * Scoped Redis Plugin * * Wraps the standard redis() plugin to provide per-project * key isolation. Each project's keys are prefixed with {projectId}: * so project A can't see project B's data. * * If ioredis is available, uses its built-in keyPrefix option. * Otherwise, wraps the built-in RESP client with a PrefixedRedisClient. * * If ctx._projectId is null (shared services like auth), * returns the unprefixed client. */ import type { HealthCheckResult, IoRedisLikeClient, RedisOptions, ScopedPluginContext } from "./types.js"; type RespValue = string | number | Buffer | null | Error | RespValue[]; interface RedisClient { status: string; get(key: string): Promise; set(...args: string[]): Promise; del(...keys: string[]): Promise; hget(key: string, field: string): Promise; hset(key: string, field: string, value: string): Promise; hgetall(key: string): Promise>; keys(pattern: string): Promise; expire(key: string, seconds: string): Promise; ttl(key: string): Promise; ping(): Promise; incr(key: string): Promise; decr(key: string): Promise; lpush(key: string, ...values: string[]): Promise; rpush(key: string, ...values: string[]): Promise; lrange(key: string, start: string | number, end: string | number): Promise; sadd(key: string, ...members: string[]): Promise; smembers(key: string): Promise; publish(channel: string, message: string): Promise; disconnect(): void; quit(): Promise; } interface ScopedRedisPlugin { name: "redis"; version: string; inject: "redis"; validate(): void; env(): Record; connect(ctx: ScopedPluginContext): Promise; healthCheck(c: RedisClient | PrefixedRedisClient | IoRedisLikeClient): Promise; disconnect(c: RedisClient | PrefixedRedisClient | IoRedisLikeClient): Promise; metrics(c: RedisClient | PrefixedRedisClient | IoRedisLikeClient): Record; } /** * Wraps the built-in RESP client to prefix all key operations. */ declare class PrefixedRedisClient { _client: RedisClient; _prefix: string; constructor(client: RedisClient, prefix: string); _pk(key: string): string; get status(): string; get(k: string): Promise; set(...a: string[]): Promise; del(...keys: string[]): Promise; incr(k: string): Promise; decr(k: string): Promise; expire(k: string, s: string): Promise; ttl(k: string): Promise; hget(k: string, f: string): Promise; hset(k: string, f: string, v: string): Promise; hgetall(k: string): Promise>; lpush(k: string, ...v: string[]): Promise; rpush(k: string, ...v: string[]): Promise; lrange(k: string, s: string | number, e: string | number): Promise; sadd(k: string, ...m: string[]): Promise; smembers(k: string): Promise; keys(p: string): Promise; publish(ch: string, m: string): Promise; ping(): Promise; quit(): Promise; disconnect(): void; } /** * Create a scoped Redis plugin. * * @param {Object} [options] - Same options as redis() plugin * @returns {Object} Plugin descriptor */ export declare function scopedRedis(options?: RedisOptions): ScopedRedisPlugin; export {}; //# sourceMappingURL=ScopedRedis.d.ts.map