@orbitinghail/sqlsync-worker
Version:
SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.
23 lines (22 loc) • 1.15 kB
TypeScript
import { ConnectionStatus, DocId, SqlValue } from "../sqlsync-wasm/pkg/sqlsync_wasm";
import { ParameterizedQuery } from "./sql";
import { Row } from "./types";
export interface DocType<Mutation> {
readonly reducerUrl: string | URL;
readonly serializeMutation: (mutation: Mutation) => Uint8Array;
}
export interface QuerySubscription {
handleRows: (rows: Row[]) => void;
handleErr: (err: string) => void;
}
export declare class SQLSync {
#private;
constructor(workerUrl: string | URL, wasmUrl: string | URL, coordinatorUrl?: string | URL);
close(): void;
query<M, T extends Row = Row>(docId: DocId, docType: DocType<M>, sql: string, params: SqlValue[]): Promise<T[]>;
subscribe<M>(docId: DocId, docType: DocType<M>, query: ParameterizedQuery, subscription: QuerySubscription): Promise<() => void>;
mutate<M>(docId: DocId, docType: DocType<M>, mutation: M): Promise<void>;
get connectionStatus(): ConnectionStatus;
addConnectionStatusListener(listener: (status: ConnectionStatus) => void): () => void;
setConnectionEnabled<M>(docId: DocId, docType: DocType<M>, enabled: boolean): Promise<void>;
}