import type { CallbackUserFunction, QueryKey, RawResultData, Sqlite3Method, ScalarUserFunction, Statement, DatabaseInfo, ClientConfig, StatementInput, Transaction, DatabasePath, AggregateUserFunction, ReactiveQuery, SqlTag, TransactionHandle, WindowUserFunction, UserFunction } from './types.js'; import type { BatchMessage, BroadcastMessage, DeleteMessage, DestroyMessage, ExportMessage, FunctionMessage, GetInfoMessage, ImportMessage, OmitQueryKey, OutputMessage, QueryMessage, TransactionMessage, WorkerProxy } from './messages.js'; import { SQLocalProcessor } from './processor.js'; /** * This class is your entry point for connecting to and * interacting with an on-device SQLite database in the browser. * @see {@link https://sqlocal.dev/guide/setup} */ export declare class SQLocal { protected config: ClientConfig; protected clientKey: QueryKey; protected processor: SQLocalProcessor | Worker; protected isDestroyed: boolean; protected bypassMutationLock: boolean; protected transactionQueryKeyQueue: QueryKey[]; protected userCallbacks: Map; protected queriesInProgress: Map void, reject: (error: unknown) => void ]>; protected proxy: WorkerProxy; protected reinitChannel: BroadcastChannel; protected effectsChannel?: BroadcastChannel; constructor(databasePath: DatabasePath); constructor(config: ClientConfig); protected processMessageEvent: (event: OutputMessage | MessageEvent) => void; protected createQuery: (message: OmitQueryKey) => Promise; protected broadcast: (message: BroadcastMessage) => void; /** @internal */ exec: (sql: string, params: unknown[], method?: Sqlite3Method, transactionKey?: QueryKey) => Promise; protected execBatch: (statements: Statement[], transactionKey?: QueryKey) => Promise; /** * Execute SQL queries against the database. * @see {@link https://sqlocal.dev/api/sql} */ sql: >(queryTemplate: TemplateStringsArray | string, ...params: unknown[]) => Promise; /** * Execute a batch of SQL queries against the database in an atomic way. * @see {@link https://sqlocal.dev/api/batch} */ batch: >(passStatements: (sql: SqlTag) => Statement[]) => Promise; /** @internal */ beginTransaction: () => Promise; /** * Execute SQL transactions against the database. * @see {@link https://sqlocal.dev/api/transaction} */ transaction: (transaction: (tx: TransactionHandle) => Promise) => Promise; /** * Subscribe to a SQL query and receive the latest results * whenever the read tables change. * @see {@link https://sqlocal.dev/api/reactivequery} */ reactiveQuery: >(passStatement: StatementInput) => ReactiveQuery; protected createFunction: (fn: UserFunction) => Promise; /** * Create a SQL function that can be called from queries to * trigger a JavaScript callback. * @see {@link https://sqlocal.dev/api/createcallbackfunction} */ createCallbackFunction: (funcName: string, func: CallbackUserFunction["func"]) => Promise; /** * Create a SQL function that can be called from queries to * transform column values or to filter rows. * @see {@link https://sqlocal.dev/api/createscalarfunction} */ createScalarFunction: (funcName: string, func: ScalarUserFunction["func"]) => Promise; /** * Create a SQL function that can be called from queries to * combine multiple rows into a single result row. * @see {@link https://sqlocal.dev/api/createaggregatefunction} */ createAggregateFunction: (funcName: string, func: AggregateUserFunction["func"]) => Promise; /** * Create a SQL function that can be called from queries to * perform calculations for rows using data from related rows. * @see {@link https://sqlocal.dev/api/createwindowfunction} */ createWindowFunction: (funcName: string, func: WindowUserFunction["func"]) => Promise; /** * Retrieve information about the SQLite database file. * @see {@link https://sqlocal.dev/api/getdatabaseinfo} */ getDatabaseInfo: () => Promise; /** * Access the SQLite database file so that it can be uploaded * to the server or allowed to be downloaded by the user. * @see {@link https://sqlocal.dev/api/getdatabasefile} */ getDatabaseFile: () => Promise; /** * Replace the contents of the SQLite database file. * @see {@link https://sqlocal.dev/api/overwritedatabasefile} */ overwriteDatabaseFile: (databaseFile: File | Blob | ArrayBuffer | Uint8Array | ReadableStream>, beforeUnlock?: () => void | Promise) => Promise; /** * Delete the SQLite database file. * @see {@link https://sqlocal.dev/api/deletedatabasefile} */ deleteDatabaseFile: (beforeUnlock?: () => void | Promise, destroy?: boolean) => Promise; /** * Disconnect this SQLocal client from the database and terminate * its worker thread. * @see {@link https://sqlocal.dev/api/destroy} */ destroy: (skipOptimize?: boolean) => Promise; /** * Handles cleaning up the SQLocal client with JavaScript * Explicit Resource Management (`using`). * @internal */ [Symbol.dispose]: () => void; /** * Handles cleaning up the SQLocal client with JavaScript * Explicit Resource Management (`await using`). * @internal */ [Symbol.asyncDispose]: () => Promise; }