import * as React from 'react'; import { NormalisableError, NormalisedError } from '@batoanng/types'; /** * Return a slugified copy of a string. * * @param {string} str The string to be slugified * @return {string} The slugified string. */ declare function toSlug(str: string): string; /** * On the server, React emits a warning when calling `useLayoutEffect`. * This is because neither `useLayoutEffect` nor `useEffect` run on the server. * We use this safe version which suppresses the warning by replacing it with a noop on the server. * * See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect */ declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect; declare function usePrevious(value: T): T; declare enum Operator { EQ = "EQ", GT = "GT", GTE = "GTE", LT = "LT", LTE = "LTE" } declare class SearchSpecBuilder { private readonly ownerType?; private _clauses; private _childClauses; constructor(ownerType?: any | undefined); get count(): number; where(propertyName: string, value: string | null | undefined, includeIfNullOrEmpty?: boolean, caseSensitive?: boolean): this; and(propertyName: string, value: string | null | undefined, includeIfNullOrEmpty?: boolean, caseSensitive?: boolean): this; or(propertyName: string, value: string | null | undefined, includeIfNullOrEmpty?: boolean, caseSensitive?: boolean): this; private includeString; private caseInsensitiveOperator; andDate(propertyName: string, op: Operator, value: Date | null | undefined, includeIfNull?: boolean): this; orDate(propertyName: string, op: Operator, value: Date | null | undefined, includeIfNull?: boolean): this; private includeDate; andValue(propertyName: string, op: Operator, value: any, includeIfNull?: boolean): this; orValue(propertyName: string, op: Operator, value: any, includeIfNull?: boolean): this; private include; private mapOperator; andChild(child: SearchSpecBuilder): this; orChild(child: SearchSpecBuilder): this; private addChildClause; toString(): string; } declare function sleep(ms?: number): Promise; declare const generateShortId: () => string; declare const getNormalisedError: (...errors: (NormalisableError | unknown)[]) => NormalisedError | null; type RateLimitCheckResult = { key: string; allowed: boolean; limit: number; used: number; remaining: number; retryAfterMs: number; }; type LeakyBucketRateLimiterOptions = { capacity: number; leakRatePerSecond: number; now?: () => number; }; type FixedWindowRateLimiterOptions = { limit: number; windowMs: number; now?: () => number; }; type SlidingWindowRateLimiterOptions = { limit: number; windowMs: number; now?: () => number; }; declare class LeakyBucketRateLimiter { private readonly capacity; private readonly leakRatePerSecond; private readonly now; private readonly buckets; constructor({ capacity, leakRatePerSecond, now }: LeakyBucketRateLimiterOptions); check(key?: string): RateLimitCheckResult; getSnapshot(key?: string): RateLimitCheckResult; reset(key?: string): void; clear(): void; getTrackedKeyCount(): number; private getOrCreateState; private getLeakedLevel; private createResult; private buildResult; private getRetryAfterMs; } declare class FixedWindowRateLimiter { private readonly limit; private readonly windowMs; private readonly now; private readonly windows; constructor({ limit, windowMs, now }: FixedWindowRateLimiterOptions); check(key?: string): RateLimitCheckResult; getSnapshot(key?: string): RateLimitCheckResult; reset(key?: string): void; clear(): void; getTrackedKeyCount(): number; private getOrCreateState; private isExpired; private getWindowStart; private getRetryAfterMs; private buildResult; } declare class SlidingWindowRateLimiter { private readonly limit; private readonly windowMs; private readonly now; private readonly windows; constructor({ limit, windowMs, now }: SlidingWindowRateLimiterOptions); check(key?: string): RateLimitCheckResult; getSnapshot(key?: string): RateLimitCheckResult; reset(key?: string): void; clear(): void; getTrackedKeyCount(): number; private getOrCreateState; private evictExpiredTimestamps; private buildResult; private createEmptyResult; private getRetryAfterMs; } export { FixedWindowRateLimiter, type FixedWindowRateLimiterOptions, LeakyBucketRateLimiter, type LeakyBucketRateLimiterOptions, Operator, type RateLimitCheckResult, SearchSpecBuilder, SlidingWindowRateLimiter, type SlidingWindowRateLimiterOptions, generateShortId, getNormalisedError, sleep, toSlug, useIsomorphicLayoutEffect, usePrevious };