import { Alepha, Static } from "alepha";
import { RedisClientType, createClient } from "@redis/client";
//#region ../../src/redis/providers/RedisProvider.d.ts
/**
 * Abstract Redis provider interface.
 *
 * This abstract class defines the common interface for Redis operations.
 * Implementations include:
 * - {@link NodeRedisProvider} - Uses `@redis/client` for Node.js runtime
 * - {@link BunRedisProvider} - Uses Bun's native `RedisClient` for Bun runtime
 *
 * @example
 * ```ts
 * // Inject the abstract provider - runtime selects the implementation
 * const redis = alepha.inject(RedisProvider);
 *
 * // Use common operations
 * await redis.set("key", "value");
 * const value = await redis.get("key");
 * ```
 */
declare abstract class RedisProvider {
  /**
   * Whether the Redis client is ready to accept commands.
   */
  abstract readonly isReady: boolean;
  /**
   * Connect to the Redis server.
   */
  abstract connect(): Promise<void>;
  /**
   * Close the connection to the Redis server.
   */
  abstract close(): Promise<void>;
  /**
   * Get the value of a key.
   *
   * @param key The key to get.
   * @returns The value as a Buffer, or undefined if the key does not exist.
   */
  abstract get(key: string): Promise<Buffer | undefined>;
  /**
   * Set the value of a key.
   *
   * @param key The key to set.
   * @param value The value to set (Buffer or string).
   * @param options Optional set options (EX, PX, NX, XX, etc.).
   * @returns The value as a Buffer.
   */
  abstract set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
  /**
   * Check if a key exists.
   *
   * @param key The key to check.
   * @returns True if the key exists.
   */
  abstract has(key: string): Promise<boolean>;
  /**
   * Get all keys matching a pattern.
   *
   * @param pattern The glob-style pattern to match.
   * @returns Array of matching key names.
   */
  abstract keys(pattern: string): Promise<string[]>;
  /**
   * Delete one or more keys.
   *
   * @param keys The keys to delete.
   */
  abstract del(keys: string[]): Promise<void>;
  /**
   * Push a value to the left (head) of a list.
   *
   * @param key The list key.
   * @param value The value to push.
   */
  abstract lpush(key: string, value: string): Promise<void>;
  /**
   * Pop a value from the right (tail) of a list.
   *
   * @param key The list key.
   * @returns The value, or undefined if the list is empty.
   */
  abstract rpop(key: string): Promise<string | undefined>;
  /**
   * Publish a message to a channel.
   *
   * @param channel The channel name.
   * @param message The message to publish.
   */
  abstract publish(channel: string, message: string): Promise<void>;
  /**
   * Increment the integer value of a key by the given amount.
   *
   * If the key does not exist, it is set to 0 before performing the operation.
   * This operation is atomic.
   *
   * @param key The key to increment.
   * @param amount The amount to increment by.
   * @returns The new value after incrementing.
   */
  abstract incr(key: string, amount: number): Promise<number>;
}
/**
 * Common Redis SET command options.
 * Compatible with @redis/client SetOptions format.
 */
interface RedisSetOptions {
  /**
   * Set the specified expire time, in seconds.
   */
  EX?: number;
  /**
   * Set the specified expire time, in milliseconds.
   */
  PX?: number;
  /**
   * Set the specified Unix time at which the key will expire, in seconds.
   */
  EXAT?: number;
  /**
   * Set the specified Unix time at which the key will expire, in milliseconds.
   */
  PXAT?: number;
  /**
   * Only set the key if it does not already exist.
   */
  NX?: boolean;
  /**
   * Only set the key if it already exists.
   */
  XX?: boolean;
  /**
   * Retain the time to live associated with the key.
   */
  KEEPTTL?: boolean;
  /**
   * Return the old string stored at key, or nil if key did not exist.
   */
  GET?: boolean;
  /**
   * Alternative expiration format (compatible with @redis/client).
   */
  expiration?: {
    type: "EX" | "PX" | "EXAT" | "PXAT" | "KEEPTTL";
    value: number;
  };
  /**
   * Alternative condition format (compatible with @redis/client).
   */
  condition?: "NX" | "XX";
}
//#endregion
//#region ../../src/redis/providers/BunRedisProvider.d.ts
declare const envSchema$1: import("zod").ZodObject<{
  REDIS_URL: import("zod").ZodString;
}, import("zod/v4/core").$strip>;
declare module "alepha" {
  interface Env extends Partial<Static<typeof envSchema$1>> {}
}
/**
 * Bun Redis client provider using Bun's native Redis client.
 *
 * This provider uses Bun's built-in `RedisClient` class for Redis connections,
 * which provides excellent performance (7.9x faster than ioredis) on the Bun runtime.
 *
 * @example
 * ```ts
 * // Set REDIS_URL environment variable (default: redis://localhost:6379)
 * // REDIS_URL=redis://:password@myredis.example.com:6379
 *
 * // Or configure programmatically
 * alepha.with({
 *   provide: RedisProvider,
 *   use: BunRedisProvider,
 * });
 * ```
 */
declare class BunRedisProvider extends RedisProvider {
  protected readonly log: import("alepha/logger").Logger;
  protected readonly alepha: Alepha;
  protected readonly env: {
    REDIS_URL: string;
  };
  protected client?: Bun.RedisClient;
  get publisher(): Bun.RedisClient;
  get isReady(): boolean;
  protected readonly start: import("alepha").HookPrimitive<"start">;
  protected readonly stop: import("alepha").HookPrimitive<"stop">;
  /**
   * Connect to the Redis server.
   */
  connect(): Promise<void>;
  /**
   * Close the connection to the Redis server.
   */
  close(): Promise<void>;
  /**
   * Create a duplicate connection for pub/sub or other isolated operations.
   */
  duplicate(): Promise<Bun.RedisClient>;
  get(key: string): Promise<Buffer | undefined>;
  set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
  has(key: string): Promise<boolean>;
  keys(pattern: string): Promise<string[]>;
  del(keys: string[]): Promise<void>;
  lpush(key: string, value: string): Promise<void>;
  rpop(key: string): Promise<string | undefined>;
  publish(channel: string, message: string): Promise<void>;
  incr(key: string, amount: number): Promise<number>;
  /**
   * Get the Redis connection URL.
   */
  protected getUrl(): string;
}
//#endregion
//#region ../../src/redis/providers/RedisSubscriberProvider.d.ts
/**
 * Abstract Redis subscriber provider interface.
 *
 * This abstract class defines the common interface for Redis pub/sub subscriptions.
 * Implementations include:
 * - {@link NodeRedisSubscriberProvider} - Uses `@redis/client` for Node.js runtime
 * - {@link BunRedisSubscriberProvider} - Uses Bun's native `RedisClient` for Bun runtime
 *
 * Redis requires separate connections for pub/sub operations, so this provider
 * creates a dedicated connection for subscriptions.
 *
 * @example
 * ```ts
 * // Inject the abstract provider - runtime selects the implementation
 * const subscriber = alepha.inject(RedisSubscriberProvider);
 *
 * // Subscribe to a channel
 * await subscriber.subscribe("my-channel", (message, channel) => {
 *   console.log(`Received: ${message} on ${channel}`);
 * });
 * ```
 */
declare abstract class RedisSubscriberProvider {
  /**
   * Whether the Redis subscriber client is ready to accept commands.
   */
  abstract readonly isReady: boolean;
  /**
   * Connect to the Redis server for subscriptions.
   */
  abstract connect(): Promise<void>;
  /**
   * Close the subscriber connection.
   */
  abstract close(): Promise<void>;
  /**
   * Subscribe to a channel.
   *
   * @param channel The channel name.
   * @param callback The callback to invoke when a message is received.
   */
  abstract subscribe(channel: string, callback: SubscribeCallback): Promise<void>;
  /**
   * Unsubscribe from a channel.
   *
   * @param channel The channel name.
   * @param callback Optional specific callback to remove.
   */
  abstract unsubscribe(channel: string, callback?: SubscribeCallback): Promise<void>;
}
/**
 * Callback for subscription messages.
 */
type SubscribeCallback = (message: string, channel: string) => void;
//#endregion
//#region ../../src/redis/providers/BunRedisSubscriberProvider.d.ts
/**
 * Bun Redis subscriber provider for pub/sub operations.
 *
 * This provider creates a dedicated Redis connection for subscriptions,
 * as Redis requires separate connections for pub/sub operations.
 *
 * @example
 * ```ts
 * const subscriber = alepha.inject(RedisSubscriberProvider);
 * await subscriber.subscribe("channel", (message, channel) => {
 *   console.log(`Received: ${message} on ${channel}`);
 * });
 * ```
 */
declare class BunRedisSubscriberProvider extends RedisSubscriberProvider {
  protected readonly log: import("alepha/logger").Logger;
  protected readonly alepha: Alepha;
  protected readonly redisProvider: BunRedisProvider;
  protected client?: Bun.RedisClient;
  get subscriber(): Bun.RedisClient;
  get isReady(): boolean;
  protected readonly start: import("alepha").HookPrimitive<"start">;
  protected readonly stop: import("alepha").HookPrimitive<"stop">;
  /**
   * Connect to the Redis server for subscriptions.
   */
  connect(): Promise<void>;
  /**
   * Close the subscriber connection.
   */
  close(): Promise<void>;
  subscribe(channel: string, callback: SubscribeCallback): Promise<void>;
  unsubscribe(channel: string, _callback?: SubscribeCallback): Promise<void>;
}
//#endregion
//#region ../../src/redis/providers/NodeRedisProvider.d.ts
declare const envSchema: import("zod").ZodObject<{
  REDIS_URL: import("zod").ZodString;
}, import("zod/v4/core").$strip>;
declare module "alepha" {
  interface Env extends Partial<Static<typeof envSchema>> {}
}
type NodeRedisClient = RedisClientType<{}, {}, {}, 3, {
  36: BufferConstructor;
}>;
type NodeRedisClientOptions = Parameters<typeof createClient>[0];
/**
 * Node.js Redis client provider using `@redis/client`.
 *
 * This provider uses the official Redis client for Node.js runtime.
 *
 * @example
 * ```ts
 * // Set REDIS_URL environment variable (default: redis://localhost:6379)
 * // REDIS_URL=redis://:password@myredis.example.com:6379
 *
 * // Or configure programmatically
 * alepha.with({
 *   provide: RedisProvider,
 *   use: NodeRedisProvider,
 * });
 * ```
 */
declare class NodeRedisProvider extends RedisProvider {
  protected readonly log: import("alepha/logger").Logger;
  protected readonly alepha: Alepha;
  protected readonly env: {
    REDIS_URL: string;
  };
  protected readonly client: NodeRedisClient;
  get publisher(): NodeRedisClient;
  get isReady(): boolean;
  protected readonly start: import("alepha").HookPrimitive<"start">;
  protected readonly stop: import("alepha").HookPrimitive<"stop">;
  /**
   * Connect to the Redis server.
   */
  connect(): Promise<void>;
  /**
   * Close the connection to the Redis server.
   */
  close(): Promise<void>;
  duplicate(options?: Partial<NodeRedisClientOptions>): NodeRedisClient;
  get(key: string): Promise<Buffer | undefined>;
  set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
  has(key: string): Promise<boolean>;
  keys(pattern: string): Promise<string[]>;
  del(keys: string[]): Promise<void>;
  lpush(key: string, value: string): Promise<void>;
  rpop(key: string): Promise<string | undefined>;
  publish(channel: string, message: string): Promise<void>;
  incr(key: string, amount: number): Promise<number>;
  /**
   * Get the Redis connection URL.
   */
  protected getUrl(): string;
  /**
   * Redis client factory method.
   */
  protected createClient(): NodeRedisClient;
}
//#endregion
//#region ../../src/redis/providers/NodeRedisSubscriberProvider.d.ts
/**
 * Node.js Redis subscriber provider using `@redis/client`.
 *
 * This provider creates a dedicated Redis connection for subscriptions,
 * as Redis requires separate connections for pub/sub operations.
 *
 * @example
 * ```ts
 * const subscriber = alepha.inject(RedisSubscriberProvider);
 * await subscriber.subscribe("channel", (message, channel) => {
 *   console.log(`Received: ${message} on ${channel}`);
 * });
 * ```
 */
declare class NodeRedisSubscriberProvider extends RedisSubscriberProvider {
  protected readonly log: import("alepha/logger").Logger;
  protected readonly alepha: Alepha;
  protected readonly redisProvider: NodeRedisProvider;
  protected readonly client: NodeRedisClient;
  get subscriber(): NodeRedisClient;
  get isReady(): boolean;
  protected readonly start: import("alepha").HookPrimitive<"start">;
  protected readonly stop: import("alepha").HookPrimitive<"stop">;
  connect(): Promise<void>;
  close(): Promise<void>;
  subscribe(channel: string, callback: SubscribeCallback): Promise<void>;
  unsubscribe(channel: string, callback?: SubscribeCallback): Promise<void>;
  /**
   * Redis subscriber client factory method.
   */
  protected createClient(): NodeRedisClient;
}
//#endregion
//#region ../../src/redis/index.d.ts
/**
 * Redis client wrapper.
 *
 * **Features:**
 * - Connection pooling
 * - Automatic reconnection
 * - Command pipelining
 * - Pub/sub support
 *
 * @module alepha.redis
 */
declare const AlephaRedis: import("alepha").Service<import("alepha").Module>;
//#endregion
export { AlephaRedis, BunRedisProvider, BunRedisSubscriberProvider, NodeRedisClient, NodeRedisClientOptions, NodeRedisProvider, NodeRedisSubscriberProvider, RedisProvider, RedisSetOptions, RedisSubscriberProvider, SubscribeCallback };
//# sourceMappingURL=index.d.ts.map