/** * SMI-2180: Database Factory with Auto-Detection * * Creates database connections with automatic driver selection: * 1. Try native better-sqlite3 first (fastest, requires native module) * 2. Fall back to sql.js WASM (cross-platform, no native compilation) * * This enables the MCP server to work on any platform without Docker. * * @example * ```typescript * // Auto-detect best driver * const db = await createDatabaseAsync('~/.skillsmith/skills.db') * * // Force specific driver * const db = createDatabaseSync(path) // better-sqlite3 only * ``` */ import type { Database, DatabaseOptions } from './database-interface.js'; /** * Driver type used for database connections */ export type DriverType = 'better-sqlite3' | 'sql.js'; /** * Result of driver detection */ export interface DriverInfo { type: DriverType; available: boolean; reason?: string; } /** * Detect which database drivers are available * @returns Array of driver info objects */ export declare function detectAvailableDrivers(): DriverInfo[]; /** * Get the best available driver type * @returns The driver type to use, or null if none available */ export declare function getBestDriver(): DriverType | null; /** * Create a database connection synchronously using better-sqlite3 * * Use this when you know native modules are available (e.g., in Docker). * For cross-platform code, use createDatabaseAsync instead. * * @param path - Path to database file, or ':memory:' for in-memory * @param options - Database connection options * @returns Database instance * @throws Error if better-sqlite3 is not available */ export declare function createDatabaseSync(path?: string, options?: DatabaseOptions): Database; /** * Create a database connection with automatic driver selection * * This is the recommended way to create database connections for * cross-platform compatibility. It will: * 1. Try better-sqlite3 native module first (fastest) * 2. Fall back to sql.js WASM if native is unavailable * * @param path - Path to database file, or ':memory:' for in-memory * @param options - Database connection options * @returns Promise resolving to Database instance (bare connection — caller must call initializeSchema) * @throws Error if no database driver is available * * @important This factory returns a **bare connection with no schema tables**. Unlike the * sync path, no schema initialization happens automatically. Always call `initializeSchema(db)` * immediately after for new/application databases: * ```typescript * const db = await createDatabaseAsync(path) * initializeSchema(db) // required — creates tables if they don't exist * ``` */ export declare function createDatabaseAsync(path?: string, options?: DatabaseOptions): Promise; /** * @deprecated Use createDatabaseAsync() instead for cross-platform support. * * createDatabase() only works with native better-sqlite3 and will fail on * platforms where native modules aren't available (e.g., macOS without Docker). * * Migration: * ```typescript * // Before (synchronous, native only) * const db = createDatabase(path) * * // After (async, with automatic WASM fallback) * const db = await createDatabaseAsync(path) * ``` * * This alias is maintained for backward compatibility with existing code. */ export declare const createDatabase: typeof createDatabaseSync; //# sourceMappingURL=createDatabase.d.ts.map