( columns: Column[], rows: string[][], )
| 51 | ), |
| 52 | }); |
| 53 | |
| 54 | type Column = z.infer<typeof schema>["columns"][number]; |
| 55 | |
| 56 | // Cap the native Table block at 100 rows (header included) and 20 cols. |
| 57 | const MAX_COLUMNS = 20; |
| 58 | const MAX_DATA_ROWS = 99; |
| 59 | |
| 60 | /** Clamp to platform limits, recording what was dropped. */ |
| 61 | export function clamp( |
| 62 | columns: Column[], |
| 63 | rows: string[][], |
| 64 | ): { cols: Column[]; dataRows: string[][]; notes: string[] } { |
| 65 | const cols = columns.slice(0, MAX_COLUMNS); |
| 66 | const dataRows = rows.slice(0, MAX_DATA_ROWS); |
| 67 | const notes: string[] = []; |
| 68 | if (columns.length > MAX_COLUMNS) { |
| 69 | notes.push( |
| 70 | `only the first ${MAX_COLUMNS} of ${columns.length} columns shown`, |
| 71 | ); |
| 72 | } |
no outgoing calls
no test coverage detected