changemaker.lite/api/dist/modules/docs/docs-files.service.d.ts

54 lines
2.1 KiB
TypeScript

export interface FileNode {
name: string;
path: string;
isDirectory: boolean;
children?: FileNode[];
}
/**
* Resolve and validate a relative path within MKDOCS_DOCS_PATH.
* Throws if the resolved path escapes the docs root.
*/
declare function safeResolve(relativePath: string): string;
export declare class PathTraversalError extends Error {
constructor();
}
export declare class FileNotFoundError extends Error {
constructor(filePath: string);
}
/**
* Recursively list the file tree under MKDOCS_DOCS_PATH.
* Cached in Redis with 1-hour TTL for root calls.
*/
declare function listTree(dir?: string, relBase?: string): Promise<FileNode[]>;
declare function readFileContent(relativePath: string): Promise<string>;
declare function writeFileContent(relativePath: string, content: string): Promise<void>;
declare function createFile(relativePath: string, content?: string, isDirectory?: boolean): Promise<void>;
declare function deleteFile(relativePath: string): Promise<void>;
declare function renameFile(fromPath: string, toPath: string): Promise<void>;
declare function isEditableFile(relativePath: string): boolean;
declare function uploadFile(relativePath: string, sourcePath: string): Promise<void>;
declare function invalidateTreeCache(): Promise<void>;
/**
* Flatten a FileNode tree into file-only entries, then filter by
* case-insensitive query match on name or path. Name matches score
* higher so they sort first.
*/
declare function searchFiles(query: string, limit?: number): Promise<{
name: string;
path: string;
}[]>;
export declare const docsFilesService: {
listTree: typeof listTree;
readFileContent: typeof readFileContent;
writeFileContent: typeof writeFileContent;
createFile: typeof createFile;
deleteFile: typeof deleteFile;
renameFile: typeof renameFile;
uploadFile: typeof uploadFile;
safeResolve: typeof safeResolve;
isEditableFile: typeof isEditableFile;
invalidateTreeCache: typeof invalidateTreeCache;
searchFiles: typeof searchFiles;
};
export {};
//# sourceMappingURL=docs-files.service.d.ts.map