/** * Global AiDex Database * * Meta-DB at ~/.aidex/global.db that references all project databases. * Uses ATTACH DATABASE for cross-project queries. */ import Database from 'better-sqlite3'; export interface GuidelineRow { key: string; value: string; created_at: number; updated_at: number; } export interface GlobalProject { id: number; path: string; name: string; languages: string | null; files_count: number; items_count: number; methods_count: number; types_count: number; db_size_bytes: number; last_indexed: number | null; last_synced: number | null; tags: string | null; registered_at: number; } export interface ScheduledTaskRow { id: number; project_path: string; task_id: number; due: number; interval: string | null; auto_go: number; } export interface ProjectStats { files: number; items: number; methods: number; types: number; sizeBytes: number; languages: string[]; lastIndexed: number | null; } export declare class GlobalDatabase { private db; private dbPath; constructor(); /** * Register or update a project in the global registry */ registerProject(path: string, name: string, stats: ProjectStats, tags?: string): void; /** * Remove a project from the registry. Tries the path exactly as given, * then falls back to the normalised form — covers legacy entries that * were stored with raw backslashes before path normalisation was applied * at insert time. */ unregisterProject(path: string): boolean; /** * Get all registered projects, optionally filtered */ getProjects(filter?: { tag?: string; namePattern?: string; }): GlobalProject[]; /** * Get a single project by path */ getProjectByPath(path: string): GlobalProject | null; /** * Update tags for a project */ updateProjectTags(path: string, tags: string): void; /** * Get total counts across all projects */ getTotals(): { projects: number; files: number; items: number; methods: number; types: number; }; /** * Execute a query function across multiple project databases in batches. * Opens each project DB via ATTACH, runs the query, collects results. */ queryAcrossProjects(projects: GlobalProject[], queryFn: (db: Database.Database, alias: string, project: GlobalProject) => T[], limitTotal?: number): Array<{ project: GlobalProject; results: T[]; }>; setMetadata(key: string, value: string | null): void; getMetadata(key: string): string | null; setGuideline(key: string, value: string): void; getGuideline(key: string): GuidelineRow | null; listGuidelines(filter?: string): GuidelineRow[]; deleteGuideline(key: string): boolean; /** * Upsert a scheduled task into the global mirror table. */ upsertScheduledTask(projectPath: string, taskId: number, due: number, interval: string | null, autoGo: number): void; /** * Remove a scheduled task from the global mirror. */ removeScheduledTask(projectPath: string, taskId: number): void; /** * Remove all scheduled tasks for a project. */ removeScheduledTasksByProject(projectPath: string): void; /** * Get all scheduled tasks that are due (due <= now). */ getDueScheduledTasks(now?: number): ScheduledTaskRow[]; /** * Get all scheduled tasks (for status display). */ getAllScheduledTasks(): ScheduledTaskRow[]; /** * Update the due timestamp for a scheduled task (after interval advancement). */ updateScheduledTaskDue(projectPath: string, taskId: number, newDue: number): void; getDb(): Database.Database; getPath(): string; close(): void; } /** * Check if global.db exists */ export declare function globalDbExists(): boolean; /** * Get the global DB path */ export declare function getGlobalDbPath(): string; /** * Get the global directory path */ export declare function getGlobalDir(): string; /** * Open the global database (creates if not exists) */ export declare function openGlobalDatabase(): GlobalDatabase; /** * Read project stats from a project's index.db */ export declare function readProjectStats(projectPath: string): ProjectStats | null; //# sourceMappingURL=global-database.d.ts.map