import type { Database as DatabaseType } from 'better-sqlite3'; export interface TopicRow { id: number; name: string; language: string | null; parent_topic_id: number | null; sort_order: number; archived: number; archived_at: string | null; } export declare function createTopic(db: DatabaseType, name: string, parentTopicId?: number | null): number; export declare function getTopic(db: DatabaseType, id: number): TopicRow | undefined; /** * Return non-archived topics in hierarchy order (parent before children, siblings by sort_order). * Uses a recursive CTE to produce a depth-first traversal. */ export declare function listTopics(db: DatabaseType): TopicRow[]; export declare function setTopicLanguage(db: DatabaseType, topicId: number, language: string): void; export declare function archiveTopic(db: DatabaseType, topicId: number): void; export declare function listArchivedTopics(db: DatabaseType): TopicRow[]; export declare function restoreTopic(db: DatabaseType, topicId: number): void; export declare function renameTopic(db: DatabaseType, topicId: number, name: string): void; /** Return [topicId, parentId, grandparentId, ..., rootId]. */ export declare function getTopicLineage(db: DatabaseType, topicId: number): number[]; /** Check if `ancestorId` is an ancestor of `topicId` (or equal to it). */ export declare function isAncestorOf(db: DatabaseType, ancestorId: number, topicId: number): boolean; /** Move topic to root level, placed last. */ export declare function moveTopicToRoot(db: DatabaseType, topicId: number): void; /** Move topic inside targetId as last child. */ export declare function moveTopicInto(db: DatabaseType, topicId: number, targetId: number): void; /** Move topic to be a sibling of targetId, placed immediately before it. */ export declare function moveTopicBefore(db: DatabaseType, topicId: number, targetId: number): void; /** List direct children (non-archived) of a parent topic. Null parent = root topics. */ export declare function listTopicChildren(db: DatabaseType, parentId: number | null): TopicRow[]; /** * Walk a path of topic names to find the leaf topic. * E.g. ["Backend", "API Design"] finds the "API Design" topic whose parent is "Backend" at root. */ export declare function findTopicByPath(db: DatabaseType, pathSegments: string[]): TopicRow | undefined; /** Move topic to be a sibling of targetId, placed immediately after it. */ export declare function moveTopicAfter(db: DatabaseType, topicId: number, targetId: number): void; //# sourceMappingURL=topics.d.ts.map