import { ResumableStreamAcquireOptions, ResumableStreamEntry, ResumableStreamRole, ResumableStreamStatus, ResumableStreamStore } from "../types.js";

//#region src/resumable/stores/redis-impl.d.ts
type PipelineCommand = {
  readonly type: "xAdd";
  readonly key: string;
  readonly fields: Record<string, string | Uint8Array>;
} | {
  readonly type: "expire";
  readonly key: string;
  readonly ttlSec: number;
} | {
  readonly type: "set";
  readonly key: string;
  readonly value: string;
  readonly ttlSec: number;
};
/**
 * Structural Redis-client interface. The bundled `redis` and `ioredis`
 * adapters wrap their respective clients to satisfy it; custom or proxied
 * clients can implement it directly.
 */
interface RedisLikeClient {
  setNX(key: string, value: string, ttlSec: number): Promise<boolean>;
  set(key: string, value: string, ttlSec: number): Promise<void>;
  get(key: string): Promise<string | null>;
  expire(key: string, ttlSec: number): Promise<void>;
  exists(key: string): Promise<boolean>;
  del(keys: string[]): Promise<void>;
  xAdd(key: string, fields: Record<string, string | Uint8Array>): Promise<string>;
  xRange(key: string, start: string, end: string): Promise<Array<{
    id: string;
    fields: Record<string, string | Uint8Array>;
  }>>;
  /** Executes the commands as a single pipeline batch (one round trip). */
  pipeline(commands: readonly PipelineCommand[]): Promise<void>;
}
type RedisResumableStreamStoreOptions = {
  readonly keyPrefix?: string;
  readonly defaultTtlMs?: number; /** Defaults to 100ms. Lower values reduce read latency, raise traffic. */
  readonly pollIntervalMs?: number;
  readonly maxChunkBytes?: number;
};
declare class RedisResumableStreamStore implements ResumableStreamStore {
  private readonly client;
  private readonly keyPrefix;
  private readonly defaultTtlMs;
  private readonly pollIntervalMs;
  private readonly maxChunkBytes;
  constructor(client: RedisLikeClient, options?: RedisResumableStreamStoreOptions);
  acquire(streamId: string, options?: ResumableStreamAcquireOptions): Promise<ResumableStreamRole>;
  append(streamId: string, chunk: Uint8Array): Promise<void>;
  finalize(streamId: string, status: "done" | "error", error?: string): Promise<void>;
  read(streamId: string, cursor: string, signal: AbortSignal): AsyncIterable<ResumableStreamEntry>;
  status(streamId: string): Promise<ResumableStreamStatus>;
  delete(streamId: string): Promise<void>;
  private readMeta;
  private metaKey;
  private dataKey;
}
//#endregion
export { PipelineCommand, RedisLikeClient, RedisResumableStreamStore, RedisResumableStreamStoreOptions };
//# sourceMappingURL=redis-impl.d.ts.map