import { CompoundKey, EpochMS, Milliseconds } from '@paradoxical-io/types'; import { PartitionedKeyValueTable } from './partitionedKeyTable'; export interface ResetState { created: EpochMS; data: T | undefined; attempts: number; } export declare class AttemptsError extends Error { readonly reason: 'attempts'; constructor(reason: 'attempts'); } export interface SuccessfulAttempt { clear(): Promise; context?: T; } interface AttemptsConfig { attemptsMax: number; validityTime: Milliseconds; } /** * A way to handle time/value based attempts */ export declare class LimitedAttempt { private reader; private timeProvider; constructor(reader: PartitionedKeyValueTable, timeProvider?: import("@paradoxical-io/common").TimeProvider); /** * Attempts a time expire-able, amount limited action. If the attempt is expired * resets the attempts and allows you to start over. If its not expired and not at the attempt max * then returns the context of the attempt. * * If it is expired or reached the attempt max, then throws an error. * @param key The key to store things by * @param attemptsConfig * @param contextToStore */ attempt(key: CompoundKey>, attemptsConfig: AttemptsConfig, contextToStore?: T): Promise | undefined>; private checkValidity; } export {}; //# sourceMappingURL=attempter.d.ts.map