import * as _poppinss_utils_exception from '@poppinss/utils/exception'; import { LockStore, ResolvedLockConfig, SerializedLock, LockAcquireOptions, Duration, LockFactoryOptions, StoreFactory } from './src/types/main.js'; import { Logger } from '@julr/utils/logger'; import './drivers-ClN4eGOp.js'; import 'knex'; import 'kysely'; import 'ioredis'; import '@aws-sdk/client-dynamodb'; /** * Thrown when user tries to update/release/extend a lock that is not acquired by them */ declare const E_LOCK_NOT_OWNED: new (args?: any, options?: ErrorOptions) => _poppinss_utils_exception.Exception; /** * Thrown when the underlying store throws an error while saving/deleting/reading a lock */ declare const E_LOCK_STORAGE_ERROR: new (args: [{ message: string; }], options?: ErrorOptions) => _poppinss_utils_exception.Exception; declare class Lock { #private; constructor(key: string, lockStore: LockStore, config: ResolvedLockConfig, owner?: string, ttl?: number | null, expirationTime?: number | null); /** * Returns the owner ID */ getOwner(): string; /** * Serialize the lock */ serialize(): SerializedLock; /** * Acquire the lock */ acquire(options?: LockAcquireOptions): Promise; /** * Try to acquire the lock immediately or throw an error */ acquireImmediately(): Promise; /** * Acquire the lock, run the callback and release the lock automatically * after the callback is done. * Also returns the callback return value */ run(callback: () => Promise): Promise<[true, T] | [false, null]>; /** * Same as `run` but try to acquire the lock immediately * Or throw an error if the lock is already acquired */ runImmediately(callback: () => Promise): Promise<[true, T] | [false, null]>; /** * Force release the lock */ forceRelease(): Promise; /** * Release the lock */ release(): Promise; /** * Returns true if the lock is expired */ isExpired(): boolean; /** * Get the remaining time before the lock expires */ getRemainingTime(): number | null; /** * Extends the lock TTL */ extend(ttl?: Duration): Promise; /** * Returns true if the lock is currently locked */ isLocked(): Promise; } declare class LockFactory { #private; constructor(store: LockStore, options?: LockFactoryOptions); /** * Create a new lock */ createLock(name: string, ttl?: Duration): Lock; /** * Restore a lock from a previous owner. This is particularly useful * if you want to release a lock from a different process than the one * that acquired it. */ restoreLock(lock: SerializedLock): Lock; } /** * Verrou provides a lock management for multiple stores. * It allows accessing and manipulating locks in different stores */ declare class Verrou> { #private; constructor(config: { default: keyof KnownStores; stores: KnownStores; logger?: Logger; }); /** * Access a store by its name */ use(store: T): LockFactory; /** * Create a new lock using the default store */ createLock(name: string, ttl?: Duration): Lock; /** * Restore a lock from a previous owner. This is particularly useful * if you want to release a lock from a different process than the one * that acquired it. */ restoreLock(lock: SerializedLock): Lock; } export { E_LOCK_NOT_OWNED, E_LOCK_STORAGE_ERROR, Lock, LockFactory, Verrou };