import { LeasedItem } from './types.js'; interface DBOperation { operation: string; payload?: { payload: unknown; }; uptoSeq?: number; resolve?: (value: unknown) => void; reject?: (reason?: unknown) => void; } declare class Queue { private db; private dbOperationQueue; private nextDBOperationPromise; private nextItemPromise; private nextLeasePromise; private leasedThrough; private queueName; private dbOperationDispatch; nextDBOperation: () => AsyncGenerator; constructor(queueName: string); /** * Determine which environment we are in to set * the appropriate indexeddb information. */ initialize(): Promise; /** * Perform transaction to add item into indexeddb * If we are waiting for an item to available to dequeue, * we resolve the item immediately and don't add it to * the indexeddb. */ addItemToDB(op: DBOperation): Promise; /** * Perform transaction to fetch next item in indexeddb */ nextItemFromDB(op: DBOperation): Promise; /** * Lease the next item WITHOUT deleting it: the lowest-id record with * id > leasedThrough. Advances leasedThrough so the next lease moves * forward. If none is available, park until a matching enqueue (or a * rewind) hands one over. The item stays in the DB until confirm(). */ leaseFromDB(op: DBOperation): Promise; /** * Cumulative ack: delete every stored record with id <= uptoSeq. A single * ranged delete covers the whole confirmed prefix in one transaction. */ confirmInDB(op: DBOperation): Promise; /** Count stored (unconfirmed) records. */ countInDB(op: DBOperation): Promise; /** * The processing loop continually waits for the next * dbOperation to come using the following generator. */ private _nextDBOperation; /** * This method processes incoming dbOperations */ startProcessing(): Promise; addItemToDBOperationQueue(payload: DBOperation): void; /** * This functions will append an enqueue message to the * current operation stream. */ enqueue(item: unknown): void; /** * This function appends a dequeue message to the operation * stream and returns the result. */ dequeue(): Promise; /** Lease the next unconfirmed item (non-destructive). See leaseFromDB. */ leaseNext(): Promise; /** Cumulative ack — delete everything with seq <= uptoSeq. Fire-and-forget. */ confirm(uptoSeq: number): void; /** * Reset the lease cursor so the next lease re-hands unconfirmed items from * the lowest stored id (resend on reconnect). If a lease consumer is parked * (nothing was left to lease), re-issue a LEASE so it re-hands the earliest * still-stored item instead of waiting for a fresh enqueue. */ rewind(): void; /** Count of stored (unconfirmed) items. */ unconfirmedCount(): Promise; } export { Queue };