(
rows: Record<string, unknown>[],
state: ImportState,
currentRowCount: number
)
| 107 | } |
| 108 | |
| 109 | const insertRows = async ( |
| 110 | rows: Record<string, unknown>[], |
| 111 | state: ImportState, |
| 112 | currentRowCount: number |
| 113 | ) => { |
| 114 | if (rows.length === 0) return 0 |
| 115 | const coerced = coerceRowsForTable(rows, state.schema, state.headerToColumn) |
| 116 | const result = await batchInsertRows( |
| 117 | { tableId: state.table.id, rows: coerced, workspaceId, userId }, |
| 118 | // The created table's rowCount is frozen at 0; pass the running total so the |
| 119 | // per-batch capacity check sees cumulative rows, not an always-empty table. |
| 120 | { ...state.table, rowCount: currentRowCount }, |
| 121 | generateId().slice(0, 8) |
| 122 | ) |
| 123 | return result.length |
| 124 | } |
| 125 | |
| 126 | /** Infer the schema from the buffered sample and create the (empty) table. */ |
| 127 | const buildTable = async (sampleRows: Record<string, unknown>[]): Promise<ImportState> => { |
no test coverage detected