@boundless-oss/atlas
Version:
Atlas - MCP Server for comprehensive startup project management
149 lines • 4.18 kB
TypeScript
export interface QueryResult<T = any> {
success: boolean;
data?: T;
error?: string;
rowsAffected?: number;
}
export interface TransactionContext {
query<T = any>(sql: string, params?: any[]): Promise<T[]>;
run(sql: string, params?: any[]): Promise<{
changes: number;
lastID: number;
}>;
get<T = any>(sql: string, params?: any[]): Promise<T | undefined>;
}
/**
* SQLite Database Manager for Atlas
* Provides a clean interface for database operations with proper error handling
*/
export declare class SQLiteManager {
private db;
private isInitialized;
private isInitializing;
private dbPath;
constructor(dbPath?: string);
/**
* Initialize the database connection and schema
*/
initialize(): Promise<void>;
/**
* Open database connection
*/
private openDatabase;
/**
* Set database pragmas
*/
private runPragmas;
/**
* Load and execute the database schema
*/
private initializeSchema;
/**
* Check if migration is needed and perform one-time migration from JSON files
*/
private checkAndPerformMigration;
/**
* Check if schema migration is needed and perform schema updates
*/
private checkAndPerformSchemaMigration;
/**
* Execute multiple SQL statements
*/
private execMultiple;
/**
* Internal get method for use during initialization
*/
private getInternal;
/**
* Internal run method for use during initialization
*/
private runInternal;
/**
* Execute a single SQL statement
*/
private runQuery;
/**
* Execute a SELECT query and return all rows
*/
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T[]>>;
/**
* Execute a query and return the first row
*/
get<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
/**
* Execute a SELECT query and return all rows (alias for query)
*/
all<T = any>(sql: string, params?: any[]): Promise<QueryResult<T[]>>;
/**
* Execute an INSERT, UPDATE, or DELETE query
*/
run(sql: string, params?: any[]): Promise<QueryResult<{
changes: number;
lastInsertRowid: number;
}>>;
/**
* Execute multiple operations in a transaction
*/
transaction<T>(fn: (ctx: TransactionContext) => Promise<T>): Promise<QueryResult<T>>;
/**
* Check if a table exists
*/
tableExists(tableName: string): Promise<boolean>;
/**
* Get database statistics
*/
getStats(): Promise<QueryResult<{
tables: Array<{
name: string;
rowCount: number;
}>;
dbSize: number;
pageCount: number;
pageSize: number;
}>>;
/**
* Close the database connection
*/
close(): Promise<void>;
/**
* Check if the database is initialized
*/
private ensureInitialized;
/**
* Get the database path
*/
getDbPath(): string;
/**
* Internal get method for use during initialization (exposed for DataMigration)
*/
getForMigration<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
/**
* Internal run method for use during initialization (exposed for DataMigration)
*/
runForMigration(sql: string, params?: any[]): Promise<QueryResult<{
changes: number;
lastInsertRowid: number;
}>>;
/**
* Get database connection info
*/
getConnectionInfo(): {
isInitialized: boolean;
dbPath: string;
};
/**
* Check if database is ready for operations
*/
isReady(): boolean;
/**
* Wait for database to be ready with timeout
*/
waitForReady(timeoutMs?: number): Promise<boolean>;
}
export declare function getSQLiteManager(): SQLiteManager;
export declare function createSQLiteManager(dbPath?: string): SQLiteManager;
/**
* Utility function for dashboard APIs to ensure database is ready
*/
export declare function ensureDatabaseReady(retries?: number, delayMs?: number): Promise<SQLiteManager>;
//# sourceMappingURL=sqlite-manager.d.ts.map