export type FieldDef = { kind: string; defaultValue?: unknown; }; export type TableDef = { kind: "table"; fields: Record; }; export type Schema = Record; export type Row = Record & { id: string; createdAt: string; updatedAt: string; }; type Rows = Map; type SortSpec = { field: string; direction: "asc" | "desc"; }; type Filter = { field: string; value: unknown; }; declare class QueryBuilder { table: string; rows: Rows; filters: Filter[]; sort: SortSpec | null; max: number | null; constructor(table: string, rows: Rows, filters?: Filter[], sort?: SortSpec | null, max?: number | null); where(field: string, value: unknown): QueryBuilder; orderBy(field: string, direction?: "asc" | "desc"): QueryBuilder; limit(count: number): QueryBuilder; all(): Row[]; } declare class TableApi extends QueryBuilder { stateCell: StateCell; name: string; definition: TableDef | undefined; constructor(stateCell: StateCell, name: string); validateInsert(value: Record): Record; validatePatch(patch: Record): Record; get(id: string): Row | null; insert(value: Record): Row; update(id: string, patch: Record): void; delete(id: string): void; } export type Db = Record; export declare class StateCell { schema: Schema | undefined; tables: Map; changedTables: Set; queue: Promise; constructor(schema: Schema | undefined); updateSchema(schema: Schema | undefined): void; createDb(): Db; listTables(): string[]; dump(): { tables: Record; }; transaction(handler: (db: Db) => T | Promise): Promise<{ result: T; changedTables: string[]; }>; } export type LogLevel = "info" | "warn" | "error"; export type LogEntry = { level: LogLevel; message: string; data?: unknown; at: string; }; export type Logger = { info: (message: string, data?: unknown) => void; warn: (message: string, data?: unknown) => void; error: (message: string, data?: unknown) => void; }; export declare class LogBuffer { entries: LogEntry[]; beforeConsoleWrite?: () => void; constructor({ beforeConsoleWrite }?: { beforeConsoleWrite?: () => void; }); append(level: LogLevel, message: string, data?: unknown): void; createLogger(): Logger; } export {}; //# sourceMappingURL=runtime.d.ts.map