import type { ActorAlarmState, ActorAlarmStorage } from "../actor/alarm.js"; import type { ActorQueryResult, RuntimeActorDatabase, SqliteValue } from "../actor/database.js"; import type { JsonObject, JsonValue } from "../json.js"; import type { JsonText } from "../payload/json-text.js"; type DatabaseCall = { readonly op: "exec"; readonly sql: string; readonly bindings: readonly SqliteValue[]; readonly immediate: boolean; } | { readonly op: "fields"; readonly names?: readonly string[]; } | { readonly op: "initialize_fields"; readonly fields: ReadonlyMap; } | { readonly op: "persist_field"; readonly name: string; readonly value: JsonText; readonly immediate: boolean; } | { readonly op: "delete_field"; readonly name: string; readonly immediate: boolean; } | { readonly op: "alarm"; } | { readonly op: "set_alarm"; readonly timestamp_ms: number; readonly immediate: boolean; } | { readonly op: "delete_alarm"; readonly immediate: boolean; } | { readonly op: "commit"; } | { readonly op: "rollback"; }; type DatabaseResult = { readonly type: "rows"; readonly columns: string[]; readonly rows: SqliteValue[][]; } | { readonly type: "fields"; readonly fields: JsonObject; } | { readonly type: "alarm"; readonly timestamp_ms: number | null; } | { readonly type: "done"; }; /** Holds the thread until the Rust host has answered. */ type DatabaseTransport = (call: DatabaseCall) => DatabaseResult; declare class DatabaseCommitError extends Error { } type FieldRestore = (value: JsonValue | undefined) => void; declare class DatabaseProxy implements RuntimeActorDatabase, ActorAlarmStorage { private readonly transport; private readonly transactionDepth; private depth; private transactionsUnavailable; private readonly fieldRestores; constructor(transport: DatabaseTransport); exec(sql: string, ...bindings: SqliteValue[]): Row[]; query(sql: string, ...bindings: SqliteValue[]): ActorQueryResult; transaction(operation: () => Promise): Promise; rejectTransactions(reason: string): void; onFieldRestore(name: string, restore: FieldRestore): void; fields(names?: readonly string[]): JsonObject; getAlarmState(): ActorAlarmState; setAlarm(timestampMs: number): void; deleteAlarm(): void; /** Stores the fields the database does not hold yet. A value JSON leaves out stores nothing. */ initializeFields(fields: Readonly>): void; /** Stores the field as the JSON of `value`, and deletes it when JSON leaves the value out. */ persistField(name: string, value: unknown): void; commit(): void; rollback(): void; private assertAccess; private rollbackTo; private control; private restoreFields; } export { DatabaseCommitError, DatabaseProxy }; export type { DatabaseCall, DatabaseResult, DatabaseTransport }; //# sourceMappingURL=database.d.ts.map