import * as fs from 'fs'; import type { AppContext } from '../types/context.js'; import { WriteBatcher } from './writeBatcher.js'; /** * Initialize the global write batcher */ export declare function initWriteBatcher(batchSize?: number, batchDelay?: number): void; /** * Get the global write batcher */ export declare function getWriteBatcher(): WriteBatcher | null; /** * Get the number of pending writes in the batcher */ export declare function getWriteBatcherQueueLength(): number; /** * Get write batcher queue statistics for visualization */ export declare function getWriteBatcherQueueStats(): { queueLength: number; batchSize: number; isFlushing: boolean; } | null; /** * Wait for all batched writes to complete */ export declare function flushWriteBatcher(): Promise; /** * Reset the global write batcher (primarily for testing) */ export declare function resetWriteBatcher(): void; export interface FileInfo { dirname: string; basename: string; filename: string; extname: string; exists: boolean; stats: fs.Stats | undefined; } export declare function checkDepth(obj: unknown, maxDepth: number, currentDepth?: number): void; export declare function estimateObjectSize(obj: unknown): number; export declare function safeJSONParse(jsonString: string): unknown; export { sanitizeErrorPath } from './errorUtils.js'; export { clearPathSanitizationCache, replaceSpecialChars } from './pathUtils.js'; export declare function validatePath(userPath: string, workspaceRoot?: string): string; /** * SEC-011: Validate symlink and ensure it doesn't point outside workspace * @param filePath - Path to check * @param workspaceRoot - Workspace root directory * @param fsTmp - File system module (for testing) * @returns Resolved path if symlink is safe, throws error if unsafe */ export declare function validateSymlink(filePath: string, workspaceRoot: string | undefined, fsTmp?: typeof fs): Promise; export declare function directoryExists({ dirPath, fs: fsTmp, workspaceRoot, }: { dirPath: string; fs: typeof fs; workspaceRoot?: string; }): Promise; export declare function fileExists({ filePath, fs: fsTmp, workspaceRoot, }: { filePath: string; fs: typeof fs; workspaceRoot?: string; }): Promise; /** * Clear the verified directories cache (primarily for testing) */ export declare function clearVerifiedDirectoriesCache(): void; export declare function createDirectory(dirPath: string, fsTmp?: typeof fs): Promise; export declare function deleteDirectory(dirPath: string, recursive?: boolean, fsTmp?: typeof fs): Promise; export declare function getFiles(dirPath: string, filter?: string, fsTmp?: typeof fs): Promise; export declare function getDirectories(dirPath: string, fsTmp?: typeof fs): Promise; export declare function deleteFile(filePath: string, fsTmp?: typeof fs): Promise; export declare function fileInfo(filePath: string, fsTmp?: typeof fs, workspaceRoot?: string): Promise; export declare function saveFile(ctx: AppContext, json: unknown, fileName: string, format?: string, fsTmp?: typeof fs, useBatching?: boolean): Promise; /** * Read and parse a file (YAML, JSON, or XML) * * @param filePath - Path to the file * @param convert - Whether to parse the file (default: true) * @param fsTmp - File system module (for testing) * @returns Parsed file content or undefined if file doesn't exist * * @security Uses yaml.JSON_SCHEMA to prevent prototype pollution attacks. * This schema only allows JSON-compatible types and rejects dangerous * keys like __proto__ and constructor. See SECURITY.md for details. */ export declare function readFile(ctx: AppContext, filePath: string, convert?: boolean, fsTmp?: typeof fs): Promise; export declare function writeFile(ctx: AppContext, fileName: string, data: string, atime?: Date, mtime?: Date, fsTmp?: typeof fs): Promise; export declare function find(filename: string, root?: string, fsTmp?: typeof fs): Promise; //# sourceMappingURL=fileUtils.d.ts.map