import { BaseAdapter } from '../sync-adapter.js'; import type { AdapterConfig, SyncQuery, PushOptions, SyncResult, TableSchema, ColumnDef } from '../sync-adapter.js'; export interface SQLiteClient { prepare(sql: string): { run(...args: unknown[]): { changes: number; lastInsertRowid: number; }; all(...args: unknown[]): unknown[]; get(...args: unknown[]): unknown | undefined; }; close(): void; } export interface SQLiteAdapterConfig extends AdapterConfig { /** * A connected node:sqlite DatabaseSync instance. * If not provided, the adapter runs in HTTP mode and expects `url` to be set. */ client?: SQLiteClient; /** * Base URL for HTTP mode (e.g., 'http://localhost:3001'). * If provided, the adapter makes HTTP requests instead of using a direct client. */ url?: string; /** * Endpoint pattern for HTTP mode (e.g., '/{table}'). * Replaces '{table}' with the actual table name. */ endpointPattern?: string; /** Default owner_id when a record doesn't carry one (defaults to 'demo'). */ defaultOwnerId?: string; } /** * SQLite (node:sqlite) sync adapter. * * Supports two modes: * - Direct client mode (server-side): Pass a DatabaseSync instance * - HTTP mode (browser-side): Pass url/endpointPattern to talk to SyncServer * * ```ts * import { DatabaseSync } from 'node:sqlite'; * import { SQLiteAdapter } from 'idb-activerecord'; * * // Direct client mode (server) * const db = new DatabaseSync('app.db'); * const adapter = new SQLiteAdapter(); * await adapter.connect({ client: db }); * * // HTTP mode (browser) * const adapter = new SQLiteAdapter(); * await adapter.connect({ * url: 'http://localhost:3001', * endpointPattern: '/{table}' * }); * ``` */ export declare class SQLiteAdapter extends BaseAdapter { private client?; private httpUrl?; private httpEndpointPattern?; private useHttp; config: SQLiteAdapterConfig; connect(config: SQLiteAdapterConfig): Promise; disconnect(): Promise; applyMigration(migration: { version: number; name: string; sql?: string; }): Promise; private exec; private queryAll; private buildUrl; private httpGet; private httpPost; /** * Create the table if missing, or ALTER TABLE ADD COLUMN for any newly * declared columns. SQLite's ALTER TABLE is limited (no drop/rename), * so existing columns are never modified. */ ensureTable(table: string, columns?: ColumnDef[]): Promise; pull(query: SyncQuery): Promise; push(records: T[], options?: PushOptions): Promise; getRemoteSchema(table: string): Promise; private requireConnected; private identifier; private columnSql; private toSqlType; private fromSqliteType; private toSqlValue; } //# sourceMappingURL=sqlite-adapter.d.ts.map