import type { Redis } from "ioredis";

declare module "rate-limiter-flexible" {
  export interface RateLimiterOptions {
    storeClient: Redis;
    points: number;
    duration: number;
    blockDuration?: number;
    keyPrefix?: string;
    inmemoryBlockOnConsumed?: number;
    insuranceLimiter?: RateLimiterMemory;
  }

  export class RateLimiterRes {
    remainingPoints: number;
    consumedPoints: number;
    msBeforeNext: number;
    constructor(data: { remainingPoints: number; consumedPoints: number; msBeforeNext: number });
  }

  export class RateLimiterRedis {
    readonly points: number;
    constructor(options: RateLimiterOptions);
    consume(key: string, points?: number): Promise<RateLimiterRes>;
    delete(key: string): Promise<void>;
    penalty(key: string, points?: number): Promise<RateLimiterRes>;
    reward(key: string, points?: number): Promise<RateLimiterRes>;
  }

  export class RateLimiterMemory {
    readonly points: number;
    constructor(options: RateLimiterOptions);
    consume(key: string, points?: number): Promise<RateLimiterRes>;
    delete(key: string): Promise<void>;
  }
}
