import { type ILogger, BaseObserver, DBAdapterListener, DBLockOptions, LockContext, QueryResult, Transaction } from '@powersync/common'; import { AsyncDatabaseConnection } from './AsyncDatabaseConnection'; import { SharedConnectionWorker, WebDBAdapter } from './WebDBAdapter'; import { ResolvedWebSQLOpenOptions } from './web-sql-flags'; /** * @internal */ export interface LockedAsyncDatabaseAdapterOptions { name: string; openConnection: () => Promise; debugMode?: boolean; logger?: ILogger; } export type LockedAsyncDatabaseAdapterListener = DBAdapterListener & { initialized?: () => void; }; /** * @internal * Wraps a {@link AsyncDatabaseConnection} and provides exclusive locking functions in * order to implement {@link DBAdapter}. */ export declare class LockedAsyncDatabaseAdapter extends BaseObserver implements WebDBAdapter { protected options: LockedAsyncDatabaseAdapterOptions; private logger; private dbGetHelpers; private debugMode; private _dbIdentifier; protected initPromise: Promise; private _db; protected _disposeTableChangeListener: (() => void) | null; private _config; protected pendingAbortControllers: Set; closing: boolean; closed: boolean; constructor(options: LockedAsyncDatabaseAdapterOptions); protected get baseDB(): AsyncDatabaseConnection; get name(): string; /** * Init is automatic, this helps catch errors or explicitly await initialization */ init(): Promise; protected _init(): Promise; getConfiguration(): ResolvedWebSQLOpenOptions; protected waitForInitialized(): Promise; shareConnection(): Promise; /** * Registers a table change notification callback with the base database. * This can be extended by custom implementations in order to handle proxy events. */ protected registerOnChangeListener(db: AsyncDatabaseConnection): Promise; /** * This is currently a no-op on web */ refreshSchema(): Promise; execute(query: string, params?: any[] | undefined): Promise; executeRaw(query: string, params?: any[] | undefined): Promise; executeBatch(query: string, params?: any[][]): Promise; /** * Attempts to close the connection. * Shared workers might not actually close the connection if other * tabs are still using it. */ close(): Promise; getAll(sql: string, parameters?: any[] | undefined): Promise; getOptional(sql: string, parameters?: any[] | undefined): Promise; get(sql: string, parameters?: any[] | undefined): Promise; readLock(fn: (tx: LockContext) => Promise, options?: DBLockOptions | undefined): Promise; writeLock(fn: (tx: LockContext) => Promise, options?: DBLockOptions | undefined): Promise; protected acquireLock(callback: () => Promise, options?: { timeoutMs?: number; }): Promise; readTransaction(fn: (tx: Transaction) => Promise, options?: DBLockOptions | undefined): Promise; writeTransaction(fn: (tx: Transaction) => Promise, options?: DBLockOptions | undefined): Promise; private generateDBHelpers; /** * Wraps a lock context into a transaction context */ private wrapTransaction; /** * Wraps the worker execute function, awaiting for it to be available */ private _execute; /** * Wraps the worker executeRaw function, awaiting for it to be available */ private _executeRaw; /** * Wraps the worker executeBatch function, awaiting for it to be available */ private _executeBatch; }