import { Collection, ObjectId } from "mongodb"; export declare class MongoLocksError extends Error { constructor(message?: string); } interface LockModel { _id: ObjectId; action: unknown; createdAt: Date; refreshedAt: Date; expiresAt: Date; } declare class Lock { _id: ObjectId; action: unknown; collection: Collection; constructor(_id: ObjectId, action: unknown, collection: Collection); locked: boolean; /** * Instead of calling `this.free` directly you can use the `using` syntax * * @returns true if the lock was successfully released. False if the lock was not found */ free(): Promise; /** * Refreshes the lock's TTL * * Automatically called every 10 seconds if the lock is still active, no * need to call this manually * * @returns true if the lock was successfully refreshed. False if the lock was not found */ refresh(): Promise; [Symbol.dispose](): void; [Symbol.asyncDispose](): Promise; } export declare class LockManager { collection: Collection; private readonly ready; MongoLocksError: typeof MongoLocksError; constructor(collection: Collection); /** * Creates a DB lock based on the key provided * * @returns a function that when called will release the lock */ lock(key: unknown): Promise; } export type { LockModel, Lock };