/** * Vault filesystem operations — safe, validated access to the Obsidian vault. * * Key robustness features: * - Path traversal prevention (no escaping vault root, symlink-aware) * - Atomic writes via write-to-temp-then-rename * - File size limits * - Hidden file/folder exclusion (.obsidian, .trash, etc.) * - Auto-creation of parent directories * - Safe trash deletion (no silent permanent delete on rename failure) */ import { Config } from "./config.js"; export interface ListEntry { name: string; path: string; type: "file" | "directory"; extension?: string; size?: number; modifiedAt?: string; } export interface SearchResult { path: string; matches: { line: number; content: string; }[]; score: number; } export declare class Vault { private readonly config; /** Optional callback invoked after successful write or delete operations */ onWrite: ((path: string) => void) | null; constructor(config: Config); /** * Resolve a user-supplied relative path to an absolute path inside the vault. * Throws on any path traversal attempt. */ resolvePath(relativePath: string): string; /** * SEC-1: Resolve path and validate the real path (after symlink resolution) * is still inside the vault. For files that don't exist yet (write operations), * validate the parent directory's real path instead. */ private resolveAndValidateRealPath; private validateRealPathInVault; /** * Convert absolute path back to vault-relative path for display. */ relativePath(absolutePath: string): string; /** * Ensure a path has a valid note extension; add .md if missing. */ ensureNoteExtension(filePath: string): string; /** * Read a note's raw content as a UTF-8 string. * Validates existence and file size in a single stat call. */ readNote(relativePath: string): Promise; /** * Check if a file exists at the given vault-relative path. */ exists(relativePath: string): Promise; /** * Get file stats for a vault-relative path. */ stat(relativePath: string): Promise<{ size: number; createdAt: string; modifiedAt: string; isDirectory: boolean; }>; /** * Write content to a note using atomic write (temp file + rename). * Auto-creates parent directories. */ writeNote(relativePath: string, content: string, options?: { overwrite?: boolean; }): Promise; /** * Append content to an existing note. */ appendNote(relativePath: string, content: string): Promise; /** * Delete a note. If trashOnDelete is enabled (and permanent is not true), * moves to .trash/ instead. Uses collision-safe trash filenames. * Never silently falls through to permanent delete on rename failure. */ deleteNote(relativePath: string, options?: { permanent?: boolean; }): Promise<{ trashed: boolean; path: string; }>; /** * List files and directories at a vault-relative path. * Excludes hidden directories by default. */ list(relativePath?: string, options?: { recursive?: boolean; maxDepth?: number; includeHidden?: boolean; extensionFilter?: string[]; }): Promise; private walkDir; /** * Full-text search across all notes in the vault. * Supports plain text and regex patterns. * Has timeout protection and result limits. */ search(query: string, options?: { regex?: boolean; caseSensitive?: boolean; maxResults?: number; folder?: string; extensionFilter?: string[]; }): Promise; private searchDir; private assertFileExists; private fileExists; } //# sourceMappingURL=vault.d.ts.map