import type { Unsubscriber } from "../../../svelte.js"; import type { SqliteChange, SqliteDatabase, SqliteEngine } from "./engine.js"; export type { SqliteChange } from "./engine.js"; /** The engine methods a worker serves, by name, so nothing else on the engine can be called. */ export declare const SQLITE_ENGINE_METHODS: readonly ["query", "count", "countTags", "getEvent", "getDeletes", "write", "evict", "prune", "clear"]; export type SqliteMethods = Pick; /** Methods an app serves from the worker alongside the engine's, over the same database. */ export type SqliteExtension = Record unknown>; /** Builds an app's methods after the engine migrates, so its schema can refer to the engine's. */ export type ExtendSqlite = (db: SqliteDatabase, engine: SqliteEngine) => M; /** Methods answered beside the engine's, over the file the events are kept in. */ export type SqliteWorkerMethods = { /** Discard the database file, leaving an empty one in its place. */ wipe: () => void; /** Do nothing, so the answer says the database is open. */ ping: () => void; }; /** The engine's methods and an extension's, which can't shadow them. */ export type SqliteServed = SqliteWorkerMethods & SqliteMethods & Omit; /** Calls a method wherever the database lives, in the order calls are made. */ export type SqliteRpc> = & string>(method: K, ...args: Parameters[K]>) => Promise[K]>>; /** Calls the database in order, and hears other connections' changes in the order committed. */ export type SqliteConnection> = { call: SqliteRpc; subscribe: (listener: (change: SqliteChange) => void) => Unsubscriber; close: () => void; }; export type SqliteRequest = { id: string; method: string; args: unknown[]; }; export type SqliteResponse = { id: string; result: unknown; } | { id: string; error: string; }; /** A worker's answer to a request, with the change it committed, if any. */ export type SqliteReply = { response: SqliteResponse; change?: SqliteChange; }; /** Sent to a worker first, naming the database it serves. */ export type SqliteOpen = { type: "open"; name: string; }; /** Answers one request, with the change it committed if it made one. */ export type SqliteResponder = (request: SqliteRequest) => SqliteReply; /** Migrates the engine, then answers requests for its methods and the extension's. */ export declare const createSqliteHandler: (engine: SqliteEngine, extend?: ExtendSqlite) => SqliteResponder; //# sourceMappingURL=protocol.d.ts.map