import { JsonMapType } from './codec.js'; /** * An error on a TOML file — missing or malformed. * Extends Error so it can be thrown. Carries path and a clean message suitable for JSON output. */ export declare class TomlFileError extends Error { readonly path: string; constructor(path: string, message: string); } /** * General-purpose TOML file abstraction. * * Provides a unified interface for reading, patching, removing keys from, and replacing * the content of TOML files on disk. * * - `read` populates content from disk * - `patch` does surgical WASM-based edits (preserves comments and formatting) * - `remove` deletes a key by dotted path (preserves comments and formatting) * - `replace` does a full re-serialization (comments and formatting are NOT preserved). * - `transformRaw` applies a function to the raw TOML string on disk. */ export declare class TomlFile { /** * Read and parse a TOML file from disk. Throws {@link TomlFileError} if the file * doesn't exist or contains invalid TOML. * * @param path - Absolute path to the TOML file. * @returns A TomlFile instance with parsed content. */ static read(path: string): Promise; readonly path: string; content: JsonMapType; readonly errors: TomlFileError[]; constructor(path: string, content: JsonMapType); /** * Surgically patch values in the TOML file, preserving comments and formatting. * * Accepts a nested object whose leaf values are set in the TOML. Intermediate tables are * created automatically. Setting a leaf to `undefined` removes it (use `remove()` for a * clearer API when deleting keys). * * @example * ```ts * await file.patch({build: {dev_store_url: 'my-store.myshopify.com'}}) * await file.patch({application_url: 'https://example.com', auth: {redirect_urls: ['...']}}) * ``` */ patch(changes: { [key: string]: unknown; }): Promise; /** * Remove a key from the TOML file by dotted path, preserving comments and formatting. * * @param keyPath - Dotted key path to remove (e.g. 'build.include_config_on_deploy'). * @example * ```ts * await file.remove('build.include_config_on_deploy') * ``` */ remove(keyPath: string): Promise; /** * Replace the entire file content. The file is fully re-serialized — comments and formatting * are NOT preserved. * * @param content - The new content to write. * @example * ```ts * await file.replace({client_id: 'abc', name: 'My App'}) * ``` */ replace(content: JsonMapType): Promise; /** * Transform the raw TOML string on disk. Reads the file, applies the transform function * to the raw text, writes back, and re-parses to keep `content` in sync. * * Use this for text-level operations that can't be expressed as structured edits — * e.g. Injecting comments or positional insertion of keys in arrays-of-tables. * Subsequent `patch()` calls will preserve any comments added this way. * * @param transform - A function that receives the raw TOML string and returns the modified string. * @example * ```ts * await file.transformRaw((raw) => `# Header comment\n${raw}`) * ``` */ transformRaw(transform: (raw: string) => string): Promise; private decode; }