UNPKG

staticql

Version:

Type-safe query engine for static content including Markdown, YAML, JSON, and more.

60 lines (59 loc) 2.08 kB
import { StorageRepository } from "./StorageRepository.js"; /** * FsRepository: StorageRepository implementation for the local file system. */ export declare class FsRepository implements StorageRepository { baseDir: string; constructor(baseDir?: string); /** * Checks whether a file or directory exists. * * @param filePath - Relative path from baseDir. * @returns `true` if the file exists, otherwise `false`. */ exists(filePath: string): Promise<boolean>; /** * Reads the content of a file as UTF-8 text. * * @param filePath - Relative path to the file. * @returns File content as a string. */ readFile(filePath: string): Promise<string>; openFileStream(path: string): Promise<ReadableStream>; /** * Writes data to a file (string or binary). Creates parent directories if needed. * * @param filePath - Relative file path. * @param content - File content as string or Uint8Array. */ writeFile(filePath: string, content: string | Uint8Array): Promise<void>; /** * Lists all files under a given path or glob pattern. * * If the path points to a file, it returns an array with a single entry. * Otherwise, recursively walks the directory and returns all file paths. * * @param pathString - Path or glob pattern (e.g. "data/*.json"). * @returns List of relative file paths. */ listFiles(pathString: string): Promise<string[]>; /** * Recursively walks through a directory and yields all file paths. * * @param pathString - Absolute path to start from. * @yields Relative file paths from baseDir. */ walk(pathString: string): AsyncGenerator<string, void, unknown>; /** * Deletes the specified file. * * @param filePath - Relative path to the file. */ removeFile(filePath: string): Promise<void>; /** * Deletes the directory recursive. * * @param filePath - Relative path to the file. */ removeDir(filePath: string): Promise<void>; }