/** * Idempotency Pattern - Ensure operations can be safely retried */ import { AsyncFunction, Logger } from "../types/common"; import { ConcurrentBehavior, IdempotencyRecord, IdempotencyStore, IdempotencyOptions } from "../types/idempotency"; /** * Internal options (without execute, key, keyGenerator) */ interface IdempotencyInternalOptions { keyGenerator?: (...args: any[]) => string; ttl?: number; store?: IdempotencyStore; logger?: Logger; concurrentBehavior?: ConcurrentBehavior; waitTimeout?: number; onCacheHit?: (key: string) => void; onCacheMiss?: (key: string) => void; } /** * Idempotency - Guarantees operation idempotence */ export declare class Idempotency { private readonly fn; private store; private keyGenerator; private ttl; private logger; private concurrentBehavior; private waitTimeout; private pendingRequests; constructor(fn: AsyncFunction, options?: IdempotencyInternalOptions); /** * Execute function with idempotency */ execute(...args: TArgs): Promise; /** * Handle concurrent requests with same key */ private handleInProgress; /** * Execute function and cache result */ private executeAndCache; /** * Invalidate cache for key */ invalidate(...args: TArgs): Promise; /** * Clear all cache */ clear(): Promise; /** * Get cached record */ getRecord(...args: TArgs): Promise | null>; } /** * Reset the global idempotency store (useful for testing) */ export declare function resetGlobalIdempotencyStore(): void; /** * Stop the global idempotency store cleanup (useful for testing or when shutting down) */ export declare function stopGlobalIdempotencyCleanup(): void; /** * Manually start the global idempotency store cleanup */ export declare function startGlobalIdempotencyCleanup(): void; /** * Create idempotent function with single parameter API */ export declare function idempotent(options: IdempotencyOptions): Promise; /** * Decorator to make a method idempotent */ export declare function Idempotent(options?: IdempotencyOptions): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; export {}; //# sourceMappingURL=idempotency.d.ts.map