import { ElectricNamespace } from '../../electric/namespace.js'; import { DbSchema, TableSchema } from './schema.js'; import { Table } from './table.js'; import { Row, Statement } from '../../util/index.js'; import { LiveResultContext } from './model.js'; import { Notifier } from '../../notifiers/index.js'; import { DatabaseAdapter } from '../../electric/adapter.js'; import { GlobalRegistry, Registry, Satellite } from '../../satellite/index.js'; import { Dialect } from '../../migrators/query-builder/builder.js'; import { IShapeManager } from './shapes.js'; export type ClientTables> = { [Tbl in keyof DB['tables']]: DB['tables'][Tbl] extends TableSchema ? Table : never; }; interface RawQueries { /** * Executes a raw SQL query without protecting against modifications * to the store that are incompatible with the replication mechanism * * [WARNING]: might break data replication, use with care! * @param sql - A raw SQL query and its bind parameters. * @returns The rows that result from the query. */ unsafeExec(sql: Statement): Promise; /** * Executes a read-only raw SQL query. * @param sql - A raw SQL query and its bind parameters. * @returns The rows that result from the query. */ rawQuery(sql: Statement): Promise; /** * A read-only raw SQL query that can be used with {@link useLiveQuery}. * Same as {@link RawQueries#raw} but wraps the result in a {@link LiveResult} object. * @param sql - A raw SQL query and its bind parameters. */ liveRawQuery(sql: Statement): LiveResultContext; /** * @deprecated * For safe, read-only SQL queries, use the `rawQuery` API * For unsafe, store-modifying queries, use the `unsafeExec` API * * Executes a raw SQL query. * @param sql - A raw SQL query and its bind parameters. * @returns The rows that result from the query. */ raw(sql: Statement): Promise; /** * @deprecated * Use `liveRawQuery` instead for reactive read-only SQL queries. * * A read-only raw SQL query that can be used with {@link useLiveQuery}. * Same as {@link RawQueries#raw} but wraps the result in a {@link LiveResult} object. * @param sql - A raw SQL query and its bind parameters. */ liveRaw(sql: Statement): LiveResultContext; } /** * Electric client. * Extends the {@link ElectricNamespace} with a `db` property * providing raw query capabilities as well as a data access library for each DB table. */ export declare class ElectricClient> extends ElectricNamespace { db: ClientTables & RawQueries; readonly satellite: Satellite; sync: Omit; private constructor(); /** * Connects to the Electric sync service. * This method is idempotent, it is safe to call it multiple times. * @param token - The JWT token to use to connect to the Electric sync service. * This token is required on first connection but can be left out when reconnecting * in which case the last seen token is reused. */ connect(token?: string): Promise; disconnect(): void; static create>(dbName: string, dbDescription: DB, adapter: DatabaseAdapter, notifier: Notifier, satellite: Satellite, registry: Registry | GlobalRegistry, dialect: Dialect): ElectricClient; } export {};