/** * A single label / value pair. Tuple form is supported as a shorthand — * `['Login', 'user@example.com']` is equivalent to `{label: 'Login', value: 'user@example.com'}`. * * Values that are `null` or `undefined` are skipped entirely (the row is not * rendered). This matches the common shape of optional fields in OpenAPI * responses where missing data is `null`. */ export type DetailField = [label: string, value: DetailValue] | DetailFieldObject; /** * Allowed scalar values for a detail field. */ export type DetailValue = string | number | boolean | null | undefined; /** * Object form of a {@link DetailField} entry. */ export interface DetailFieldObject { label: string; value: DetailValue; } /** * Section under a sub-heading. Renders a blank line, the heading, a separator, * and then either label/value `fields` or a flat list of `lines`. */ export interface DetailSection { /** Section heading shown above the body */ title: string; /** Label/value rows. Mutually exclusive with `lines`. */ fields?: DetailField[]; /** Flat list of single-column rows (e.g. role names). Mutually exclusive with `fields`. */ lines?: string[]; } /** * Options for {@link printFieldsBlock}. */ export interface PrintFieldsBlockOptions { /** Width of the label column (default 25) */ labelWidth?: number; /** Width of the separator dashes (default 50) */ separatorWidth?: number; /** Total terminal width (default `process.stdout.columns || 80`) */ termWidth?: number; /** Optional sections rendered after the primary fields */ sections?: DetailSection[]; } /** * Renders a "details" block to stdout: a title, a separator, then a column * of `label: value` rows. Optional named sections can be rendered after the * primary block. * * @param title - Heading rendered above the fields. * @param fields - Primary list of label / value rows. Rows whose value is * `undefined` are skipped. * @param options - Rendering options including optional sub-sections. * * @example * ```typescript * printFieldsBlock('User Details', [ * ['Login', user.login], * ['Email', user.email], * ['Disabled', user.disabled?.toString()], * ], { * sections: user.roles?.length * ? [{title: 'Roles', fields: user.roles.map((r) => [r, ''] as DetailField)}] * : [], * }); * ``` */ export declare function printFieldsBlock(title: string, fields: DetailField[], options?: PrintFieldsBlockOptions): void;