Spaces:
Sleeping
Sleeping
File size: 866 Bytes
a4836dc ad2afbf a4836dc ad2afbf a4836dc ad2afbf a4836dc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import type { ReadyResponse } from "@oloka/contracts";
import type { DatabaseSync } from "node:sqlite";
export type DatabaseReadiness = ReadyResponse["checks"]["database"];
export type TransactionMode = "read" | "deferred" | "immediate";
export interface TransactionContext {
readonly database: DatabaseSync;
}
export class PersistenceBusyError extends Error {
readonly code = "PERSISTENCE_BUSY";
constructor(options?: ErrorOptions) {
super("Persistence is temporarily busy", options);
this.name = "PersistenceBusyError";
}
}
export interface TransactionRunner {
run<T>(
mode: TransactionMode,
operation: (context: TransactionContext) => T,
): T;
}
export interface SystemDatabase {
readonly transactions: TransactionRunner;
migrate(): Promise<void>;
checkReadiness(): Promise<DatabaseReadiness>;
close(): Promise<void>;
}
|