/** * Rendering the caller's own data: table formats and plain-text charts. * * WHY THIS IS SHARED: five of the six tools being rewritten here publish an * `export` operation and three publish a `visualize`. Written once per tool * those would be six renderers that disagree about quoting and about what to do * with a payload that is not a table -- and disagreement between copies is * exactly what the deleted hand-written validation layer was. * * Nothing here invents a value. A payload that cannot be rendered in the * requested format is refused, never reshaped into one that can: a silent * flatten is how a caller ends up quoting a figure the tool made up. */ /** The table formats every `export` operation offers. */ export declare const EXPORT_FORMATS: readonly ["markdown", "json", "csv"]; export type ExportFormat = (typeof EXPORT_FORMATS)[number]; export declare const isExportFormat: (value: unknown) => value is ExportFormat; /** * Escapes a cell so a value containing a pipe cannot forge a column. * * The backslash is escaped FIRST, and that order is the whole point. * Escaping only the pipe turned the two-character input `\|` into * `\\|`, which a Markdown reader parses as an escaped backslash * followed by a LIVE pipe -- so the cell could still forge a column, which * is the one thing this function exists to prevent. Escaping the backslash * first makes that input `\\\|`: a literal backslash followed by a * literal pipe. */ export declare const markdownCell: (value: unknown) => string; /** Escapes a field per RFC 4180. */ export declare const csvField: (value: unknown) => string; /** The union of keys across an array of records, in first-seen order. */ export declare const columnsOf: (rows: ReadonlyArray>) => string[]; /** A payload read as table rows, or undefined when it is not a table. */ export declare const asRows: (payload: unknown) => Array> | undefined; export interface RenderedPayload { format: ExportFormat; content: string; rows: number; } /** * Renders a payload in the requested format. `json` takes anything; `csv` and * `markdown` need a table and refuse anything else, naming the format that * could not be produced. */ export declare const renderPayload: (tool: string, payload: unknown, format: ExportFormat) => RenderedPayload; /** Eight levels: the resolution the glyphs give, so the scale maps onto eight. */ export declare const SPARK_LEVEL_COUNT = 8; export declare const SPARK_LEVELS: string; /** * A sparkline over the series, scaled between its own minimum and maximum. * * A flat series renders at the LOWEST level rather than the middle: there is no * way to place a constant on a scale derived from itself, and the middle would * read as "about average" for data that has no average to be about. */ export declare const sparkline: (values: readonly number[]) => string; export interface BarRow { label: string; value: number; } /** Default bar width, in characters, for the longest bar in a chart. */ export declare const BAR_CHART_WIDTH = 40; /** * A horizontal bar chart in plain text. Bars are scaled against the largest * ABSOLUTE value so a series containing negatives still shares one scale, and * every row is labelled with its own value so the chart never has to be read * off the glyphs. */ export declare const barChart: (rows: readonly BarRow[], width?: number) => string; //# sourceMappingURL=render-core.d.ts.map