/** * @file Surface-preserving YAML editor, the sibling of `json/edit`. * WHY THIS EXISTS. A YAML config is normally edited by regex or by filtering * lines. Both break the document as soon as a key owns an indented block. * Dropping the line `catalogShadowIgnore:` leaves its `- 'nock'` entries * behind at the same indent, and the next parse fails with "did not find * expected key". That happened across three fleet repos in one sweep. * `yaml`'s Document is a CST: it round-trips comments, key order and * blank-line spacing, and removing a key takes its whole value node with it. * This wraps that with the load / mutate / save shape `json/edit` already * established, so the two read the same at a call site. * THE PARSER IS INJECTED. socket-lib ships zero runtime dependencies; * importing `yaml` here would make it the first. Callers pass the module they * already have: * import * as yaml from 'yaml' * const doc = await EditableYaml.load(path, { parser: yaml }) * doc.delete('catalogShadowIgnore') * await doc.save() */ import type { EditableYamlInstance, EditableYamlOptions, EditableYamlSaveOptions, YamlDocumentLike, YamlParserLike } from './types.js'; /** * A loaded YAML file, edited through its Document and written back intact. */ export declare class EditableYaml implements EditableYamlInstance { #private; private constructor(); get document(): YamlDocumentLike; get path(): string | undefined; /** * Parse YAML text with no file behind it. `save` rejects on the result, * because there is nowhere to write. */ static fromString(source: string, options: EditableYamlOptions): EditableYaml; /** * Read and parse a YAML file. */ static load(path: string, options: EditableYamlOptions): Promise; /** * Remove a top-level key and everything nested under it. False when absent. */ delete(key: string): boolean; get(key: string): unknown; has(key: string): boolean; /** * Write the file back. Returns false when nothing changed. * * The no-change case is a skip rather than a write so an unchanged file keeps * its mtime, which the cascade's staleness checks read. */ save(options?: EditableYamlSaveOptions | undefined): Promise; set(key: string, value: unknown): this; toString(): string; } export type { EditableYamlInstance, EditableYamlOptions, EditableYamlSaveOptions, YamlDocumentLike, YamlParserLike, };