import type Database from 'better-sqlite3'; import type { AnnotatedSymbolInfo, CallGraphEdge, Module, ModuleTreeNode, ModuleWithMembers } from '../schema.js'; export interface ModuleSymbol { id: number; name: string; kind: string; filePath: string; line: number; isExported: boolean; } export interface ModuleMemberInfo { definitionId: number; name: string; kind: string; filePath: string; line: number; isExported: boolean; } export interface ModuleStats { moduleCount: number; assigned: number; unassigned: number; } export interface IncomingEdge { callerId: number; callerName: string; callerModuleId: number | null; weight: number; } /** * Repository for module tree operations. */ export declare class ModuleRepository { private db; constructor(db: Database.Database); /** * Ensure the root "project" module exists and return its ID. */ ensureRoot(): number; /** * Insert a new module in the tree. */ insert(parentId: number | null, slug: string, name: string, description?: string, isTest?: boolean): number; /** * Get a module by its full path. */ getByPath(fullPath: string): Module | null; /** * Get a module by ID. */ getById(id: number): Module | null; /** * Get direct children of a module. */ getChildren(moduleId: number): Module[]; /** * Get all modules as a flat list. */ getAll(): Module[]; /** * Get the module tree as a recursive structure. */ getTree(): ModuleTreeNode | null; /** * Delete all modules and their memberships. */ clear(): void; /** * Assign a symbol (definition) to a module. */ assignSymbol(definitionId: number, moduleId: number): void; /** * Get all symbols not yet assigned to any module. */ getUnassigned(): AnnotatedSymbolInfo[]; /** * Get symbols assigned to a specific module. */ getSymbols(moduleId: number): ModuleSymbol[]; /** * Get a module with all its members. */ getWithMembers(moduleId: number): ModuleWithMembers | null; /** * Get all modules with their members. */ getAllWithMembers(): ModuleWithMembers[]; /** * Get module statistics. */ getStats(): ModuleStats; /** * Get count of modules. */ getCount(): number; /** * Get module membership for a definition. */ getDefinitionModule(definitionId: number): { module: Module; } | null; /** * Get the symbol-level call graph. * This is needed by getModuleCallGraph and getIncomingEdgesFor. */ getCallGraph(): CallGraphEdge[]; /** * Get modules that exceed a member threshold. * Returns modules with member_count > threshold, including their member details. */ getModulesExceedingThreshold(threshold: number): ModuleWithMembers[]; /** * Get detailed member info for a module (used by deepen phase). */ getMemberInfo(moduleId: number): ModuleMemberInfo[]; /** * Assign color indices based on branch identity. * Each depth-1 module gets a sequential index; descendants inherit their ancestor's index. */ assignColorIndices(): void; /** * Get IDs of all test modules (is_test = 1). */ getTestModuleIds(): Set; /** * Prune empty leaf modules iteratively. * A leaf is a module with no children and no members. * Deleting a leaf may turn its parent into a new empty leaf, so we loop. */ pruneEmptyLeaves(): number; /** * Update a module's name and/or description. */ update(id: number, updates: { name?: string; description?: string; }): boolean; /** * Delete a module. * Throws an error if the module has members unless the caller handles that externally. */ delete(id: number): boolean; /** * Remove a symbol from its module assignment. */ unassignSymbol(definitionId: number): boolean; /** * Get leaf modules exceeding a member threshold. * Leaf = not a parent of any other module. Ordered by member count DESC (largest first). */ getLeafModulesExceedingThreshold(threshold: number): ModuleWithMembers[]; /** * Get branch modules (has children) with direct members exceeding a threshold. * These need rebalancing, not splitting. */ getBranchModulesWithDirectMembers(threshold: number): ModuleWithMembers[]; /** * Get all assigned symbols grouped by file path. * Returns definition_id, module_id, and file path for every module member. */ getAssignedSymbolsByFile(): Array<{ definitionId: number; moduleId: number; filePath: string; }>; /** * Get definitions that are base classes (extended by 2+ subclasses) with their current module assignment. * * Note: matches by simple class name (extends_name column). If two unrelated * classes share the same name, they will be conflated. This is an inherent * limitation of the extends_name schema. */ getBaseClassCandidates(): Array<{ definitionId: number; name: string; moduleId: number; extendedByCount: number; }>; /** * Get definitions that extend a given class name, with their module assignments. * * Note: matches by simple class name (extends_name column). If two unrelated * classes share the same name, they will be conflated. This is an inherent * limitation of the extends_name schema. */ getExtenderModules(className: string): Array<{ definitionId: number; moduleId: number; }>; /** * Get all extender definitions grouped by class name, in a single query. * Used to avoid N+1 queries when processing multiple base class candidates. */ getAllExtenderModulesByClass(): Map>; /** * Get all callers of a definition with their module assignments. */ getIncomingEdgesFor(definitionId: number): IncomingEdge[]; } //# sourceMappingURL=module-repository.d.ts.map