/** * Idempotency Store for safe retries * * Features: * - Unique key generation * - Operation deduplication * - Result caching * - TTL-based expiration * - Multiple storage backends */ import type { IdempotencyStore, IdempotencyRecord } from '@cogitator-ai/types'; /** * Idempotency check result */ export interface IdempotencyCheckResult { isDuplicate: boolean; record?: IdempotencyRecord; } /** * Generate idempotency key from inputs */ export declare function generateIdempotencyKey(workflowId: string, nodeId: string, input?: unknown): string; /** * Generate idempotency key with custom components */ export declare function generateCustomKey(...components: unknown[]): string; /** * Abstract idempotency store */ export declare abstract class BaseIdempotencyStore implements IdempotencyStore { abstract check(key: string): Promise; abstract store(key: string, result: unknown, error?: Error): Promise; abstract get(key: string): Promise; abstract delete(key: string): Promise; abstract clear(): Promise; } /** * In-memory idempotency store */ export declare class InMemoryIdempotencyStore extends BaseIdempotencyStore { private records; private ttl; private cleanupInterval?; constructor(options?: { ttl?: number; cleanupIntervalMs?: number; }); check(key: string): Promise; store(key: string, result: unknown, error?: Error): Promise; get(key: string): Promise; delete(key: string): Promise; clear(): Promise; private cleanup; destroy(): void; } /** * File-based idempotency store */ export declare class FileIdempotencyStore extends BaseIdempotencyStore { private directory; private ttl; private initialized; constructor(directory: string, options?: { ttl?: number; }); private ensureInitialized; private getFilePath; check(key: string): Promise; store(key: string, result: unknown, error?: Error): Promise; get(key: string): Promise; delete(key: string): Promise; clear(): Promise; } /** * Idempotent operation wrapper with concurrency guard */ export declare function idempotent(store: IdempotencyStore, key: string, fn: () => Promise): Promise; /** * Decorator for idempotent methods */ export declare function Idempotent(store: IdempotencyStore, keyGenerator: (...args: unknown[]) => string): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Create an in-memory idempotency store */ export declare function createInMemoryIdempotencyStore(options?: { ttl?: number; cleanupIntervalMs?: number; }): InMemoryIdempotencyStore; /** * Create a file-based idempotency store */ export declare function createFileIdempotencyStore(directory: string, options?: { ttl?: number; }): FileIdempotencyStore; //# sourceMappingURL=idempotency.d.ts.map