import IODefinitions from '../core/definitions.js'; import IOObject from '../core/internet-object.js'; import IOSchema from '../schema/schema.js'; import '../schema/types/memberdef.js'; import '../schema/schema-types.js'; /** * IO Formatter - Smart formatting for Internet Object output * * Formatting Rules: * 1. Simple objects (primitives only) stay inline: { a, b, c } * 2. Arrays of primitives stay inline: [ a, b, c ] * 3. Arrays of objects expand with one item per line * 4. Complex objects (with nested arrays of objects) may expand * 5. Line breaks happen BEFORE opening [ when array expands, NOT after closing } * * Key insight: After closing }, the next value continues on same line. * Line breaks only occur BEFORE [ when it needs to expand. * * @module io-formatter */ /** * Formatting context passed through recursive calls */ interface FormatContext { /** Indentation string (e.g., ' ' for 2 spaces) */ indentStr: string; /** Current indentation level */ level: number; /** Definitions for variable/schema resolution */ defs?: IODefinitions; /** Whether we're inside a nested structure (affects expansion decisions) */ isNested: boolean; } /** * Create indent string from options */ declare function createIndentString(indent: number | string | undefined): string; /** * Format a top-level record (row of data) * This is the main entry point for formatting a single record. * * The formatting logic follows these rules: * - Simple values and inline objects stay on the same line * - Line breaks happen BEFORE [ when an array of objects expands * - After } closes, the next value continues on the same line (no line break after }) * - Complex objects (containing arrays of objects) expand with content indented */ declare function formatRecord(obj: IOObject | any, schema: IOSchema | undefined, ctx: FormatContext): string; /** * Format a collection of records */ declare function formatCollection(items: any[], schema: IOSchema | undefined, ctx: FormatContext, asTopLevel?: boolean): string; export { type FormatContext, createIndentString, formatCollection, formatRecord };