import type { LibraryNodeType, LibraryParseOptions, TraverseOptions, TraverseCallback, FilterCallback, TreeStringOptions } from './types.js'; /** * A node in the content library tree. * * Represents a library, page, content asset, component, or static asset reference. */ export declare class LibraryNode { id: string; type: LibraryNodeType; typeId: string | null; data: Record | null; parent: LibraryNode | null; children: LibraryNode[]; hidden: boolean; /** @internal Raw xml2js content object */ xml: Record | null; constructor(values: { id: string; type: LibraryNodeType; typeId: string | null; data: Record | null; parent: LibraryNode | null; children: LibraryNode[]; hidden: boolean; xml: Record | null; }); toJSON(): Record; } /** * Provides an interface for manipulating B2C Commerce content libraries. * * Use the static `Library.parse()` factory to create instances from library XML. * The library tree supports filtering, traversal, mutation, and serialization * back to importable XML. * * @example * ```typescript * const library = await Library.parse(xmlString); * * // Filter to specific pages * library.filter(node => node.id === 'homepage'); * * // Traverse visible nodes * library.traverse(node => { * console.log(node.id, node.type); * }); * * // Serialize back to XML * const xml = await library.toXMLString({ traverseHidden: false }); * ``` */ export declare class Library { assetQuery: string[]; tree: LibraryNode; /** @internal Raw xml2js parsed object */ xml: Record; /** @internal */ constructor(guard: symbol); /** * Parse library XML into a Library tree. * * @param libraryXML - Raw XML string of a content library * @param options - Parse options * @returns Parsed Library instance */ static parse(libraryXML: string, { assetQuery, keepOrphans }?: LibraryParseOptions): Promise; /** * Depth-first traversal of the library tree. * * @param callback - Function called for each visited node * @param options - Traversal options * @returns this (for chaining) */ traverse(callback: TraverseCallback, { traverseHidden, callbackHidden }?: TraverseOptions): this; /** * Generator-based depth-first iteration of the library tree. * * @param options - Traversal options * @yields LibraryNode for each visited node * * @example * ```typescript * for (const node of library.nodes()) { * console.log(node.id, node.type); * } * ``` */ nodes({ traverseHidden, callbackHidden }?: TraverseOptions): Generator; /** * Filter the library tree by setting hidden flags on root children. * * @param predicate - Return true to keep the node visible * @param options - Filter options * @returns this (for chaining) */ filter(predicate: FilterCallback, { recursive }?: { recursive?: boolean | undefined; }): this; /** * Move a node from its current parent to the root of the library tree. * * Useful for exporting individual components that are normally nested under pages. * The node is removed from its original parent's children and added as a root child. * * @param node - The node to promote * @returns this (for chaining) */ promoteToRoot(node: LibraryNode): this; /** * Reset all hidden flags, making every node visible again. * * @returns this (for chaining) */ reset(): this; /** * Serialize the library back to importable XML. * * Only includes visible content unless `traverseHidden` is true. * * @param options - Serialization options * @returns XML string */ toXMLString({ traverseHidden }?: { traverseHidden?: boolean; }): Promise; /** * Returns a text tree visualization of the library structure. * * @param options - Tree string options (traversal and optional colorize function) * @returns Multi-line tree string */ getTreeString({ traverseHidden, colorize }?: TreeStringOptions): string; /** * Returns a JSON-safe representation of the library tree. */ toJSON(): Record; }