import { DoOnceActionKey, DoOnceResponse, EpochMS } from '@paradoxical-io/types'; import { Logger, Monitoring } from '../../monitoring'; import { PartitionedKeyValueTable } from '../keys'; export declare class DoOnceManager { private readonly kv; private readonly time; readonly logger: Logger; constructor(kv: PartitionedKeyValueTable, time?: import("@paradoxical-io/common").TimeProvider, monitoring?: Monitoring); /** * The key format where each action is stored separately in the KV. * @param userId * @param actionKey * @private */ private static key; /** * Wraps an action with a check on whether, or not, the user has done the action already. * @param userId * @param key * @param action * @note We aren't currently locking the key so if two requests come through for the same user and action in parallel * there is a chance the action could be done more than once. */ doOnce(userId: Key, key: DoOnceActionKey, action: () => Promise): Promise>; /** * Returns whether of or not the user has already done the action * @param userId * @param key */ haveAlreadyDone(userId: Key, key: DoOnceActionKey): Promise; /** * Marks a particular action for a user done * @param userId * @param key */ markDone(userId: Key, key: DoOnceActionKey): Promise; /** * Clears a particular key for a user * @param userId * @param key */ clearKey(userId: Key, key: DoOnceActionKey): Promise; } export interface DoOnceResult { done: true; at?: EpochMS; } //# sourceMappingURL=doOnce.d.ts.map