import IOHeader from './header.js'; import IOSectionCollection from './section-collection.js'; import '../schema/schema.js'; import '../schema/types/memberdef.js'; import '../schema/schema-types.js'; import './definitions.js'; import './section.js'; import './collection.js'; import './internet-object.js'; /** * IODocument represents a complete Internet Object document. * * A document consists of: * - A header containing schema definitions, variables, and metadata * - Zero or more data sections, each optionally named and schema-bound * - Accumulated parsing and validation errors * * Features: * - Aggregates errors from all sections for single-pass diagnostics * - JSON serialization with optional header output * - Schema-aware section management * * @example * ```typescript * const doc = parse(` * ~ $person: {name: string, age: int} * --- * ~ Alice, 30 * ~ Bob, 25 * `); * * console.log(doc.toJSON()); * // [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }] * * if (doc.errors.length > 0) { * console.error('Parsing errors:', doc.errors); * } * ``` */ declare class IODocument { private _header; private _sections; private _ownErrors; constructor(header: IOHeader, sections: IOSectionCollection | null, errors?: Error[]); get header(): IOHeader; get sections(): IOSectionCollection | null; /** * Returns all errors accumulated during parsing and validation. * This enables IDEs and tools to show all diagnostics in one pass. * * @returns A defensive copy of the errors array to prevent external mutation */ get errors(): Error[]; /** * Returns all errors accumulated during parsing and validation. * This enables IDEs and tools to show all diagnostics in one pass. * * @returns A defensive copy of the errors array to prevent external mutation */ getErrors(): ReadonlyArray; /** * Adds validation errors to the document. * This method is package-private and should only be called by the parser. * * @internal * @param errors - Array of validation errors to append */ addErrors(errors: Error[]): void; /** * Converts the data sections into a JavaScript object. * @param options Optional configuration for object conversion * @param options.skipErrors If true, excludes error objects from collections (default: false) */ toObject(options?: { skipErrors?: boolean; }): any; /** * Alias for toObject() method for JSON compatibility * @param options Optional configuration for JSON conversion */ toJSON(options?: { skipErrors?: boolean; }): any; } export { IODocument as default };