import { DatabaseSync } from "node:sqlite"; /** 按运行时约定解析数据库文件:相对路径以 data 目录为根,绝对路径保持不变。 */ export declare function resolveDatabaseFilePath(dataDirectory: string, database: string): string; /** * SQLite-based database implementation to replace JsonDB * Uses Node.js built-in SQLite support (node:sqlite) */ export declare class SqliteDB { private filePath; private db; static getType(data: unknown): string; constructor(filePath: string); create(tableName: string, schema: SqliteDB.Schema): void; select(...fieds: string[]): Selection; insert(table: string): Insertion; update(table: string): Updation; delete(table: string): Deletion; /** * 执行原始 SQL(如复合主键建表),调用方需保证语句幂等(常用 IF NOT EXISTS) */ execSQL(sql: string): void; /** * Close database connection */ close(): void; } export declare namespace SqliteDB { type ColumnType = "TEXT" | "INTEGER" | "REAL" | "BLOB"; type Column = { type: ColumnType; primaryKey?: boolean; autoIncrement?: boolean; index?: boolean; notNull?: boolean; unique?: boolean; default?: () => string | number | boolean; }; type Schema = { [columnName: string]: Column; }; function Column(type: ColumnType, options?: Omit): Column; function Column(column: Column): Column; /** 将值格式化为 SQL 字面量(字符串加单引号并转义,数字等直接返回,null/undefined 返回 NULL) */ function formatValue(value: unknown): string; type QueryCondition = T & { $and?: QueryCondition; $or?: QueryCondition; $like?: string; $not?: QueryCondition; $regexp?: string; $gt?: number; $gte?: number; $lt?: number; $lte?: number; $between?: [number, number]; }; function generateWhereClause(conditions: QueryCondition[], logic?: string): string; } export declare class Selection { private db; private fields; private tableName; private whereClauses; private groupByClauses; private orderByClauses; constructor(db: DatabaseSync, fields: string[]); from(tableName: string): this; where>(condition: SqliteDB.QueryCondition): this; groupBy(field: string): this; orderBy(field: string, order?: "ASC" | "DESC"): this; get sql(): string; run(): Record[]; } export declare class Insertion { #private; private db; private tableName; private columns; constructor(db: DatabaseSync, tableName: string); values>(first: T, ...rest: T[]): this; get sql(): string; run(): import("node:sqlite").StatementResultingChanges; } export declare class Updation { private db; private tableName; private setClauses; private whereClauses; constructor(db: DatabaseSync, tableName: string); set>(value: T): this; where>(condition: SqliteDB.QueryCondition): this; get sql(): string; run(): import("node:sqlite").StatementResultingChanges; } export declare class Deletion { private db; private tableName; private whereClauses; constructor(db: DatabaseSync, tableName: string); where>(condition: SqliteDB.QueryCondition): this; get sql(): string; run(): import("node:sqlite").StatementResultingChanges; }