@pgxsinkit/pgwasm
Version:
53 lines • 2.96 kB
TypeScript
import type { BuildIdentity, DataDirEntry, DebugLevel, PostgresBuild, ServerExtension, StorageRequest } from "../build/seam";
import type { DumpCompression, Extension, ParserOptions, Pgwasm, QueryOptions, Results, SerializerOptions, StorageDescription, Transaction } from "../interface";
/** Everything `createPgwasm` resolved and validated before booting. */
export interface BootPlan {
readonly build: PostgresBuild;
readonly storage: StorageRequest;
readonly serverExtensions: readonly ServerExtension[];
readonly clientExtensions: readonly (readonly [key: string, extension: Extension])[];
/** A Store backup's entries to create the data directory from, marker included. */
readonly restore: readonly DataDirEntry[] | undefined;
readonly settings: Readonly<Record<string, string>>;
readonly user: string;
readonly database: string;
readonly username: string | undefined;
readonly debug: DebugLevel;
readonly relaxedDurability: boolean;
readonly parsers: ParserOptions | undefined;
readonly serializers: SerializerOptions | undefined;
}
/**
* A running database over a Postgres build. Everything above the wire protocol lives here, once for
* every build: queries and transactions, the persist scheduler and its latch, the failure latch,
* notifications, array types, backups and the build marker.
*/
export declare class PgwasmInstance implements Pgwasm {
#private;
readonly build: BuildIdentity;
readonly storage: StorageDescription;
readonly debug: DebugLevel;
readonly waitReady: Promise<void>;
constructor(plan: BootPlan);
/** Boot the build, check the build marker, create or restore the data directory, and start. */
boot(plan: BootPlan): Promise<void>;
get ready(): boolean;
get closed(): boolean;
query<T = Record<string, unknown>>(sql: string, params?: readonly unknown[], options?: QueryOptions): Promise<Results<T>>;
sql<T = Record<string, unknown>>(sqlStrings: TemplateStringsArray, ...params: unknown[]): Promise<Results<T>>;
exec(sql: string, options?: QueryOptions): Promise<Results[]>;
transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
refreshArrayTypes(): Promise<void>;
listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>;
unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>;
onNotification(callback: (channel: string, payload: string) => void): () => void;
/**
* A Store backup. It reads the data directory under the query lock, so no statement runs during the
* read; do not call it from inside `runExclusive`.
*/
dumpDataDir(compression?: DumpCompression): Promise<File>;
close(): Promise<void>;
[Symbol.asyncDispose](): Promise<void>;
}
//# sourceMappingURL=pgwasm.d.ts.map