( data: BatchInsertData, table: TableDefinition, requestId: string )
| 195 | * @throws Error if validation fails or capacity exceeded |
| 196 | */ |
| 197 | export async function batchInsertRows( |
| 198 | data: BatchInsertData, |
| 199 | table: TableDefinition, |
| 200 | requestId: string |
| 201 | ): Promise<TableRow[]> { |
| 202 | // Best-effort capacity check against the workspace's current plan limit. Import |
| 203 | // paths call `batchInsertRowsWithTx` directly and gate capacity up front instead. |
| 204 | const rowLimit = await assertRowCapacity({ |
| 205 | workspaceId: table.workspaceId, |
| 206 | currentRowCount: table.rowCount, |
| 207 | addedRows: data.rows.length, |
| 208 | }) |
| 209 | |
| 210 | const result = await db.transaction((trx) => batchInsertRowsWithTx(trx, data, table, requestId)) |
| 211 | notifyTableRowUsage({ |
| 212 | workspaceId: table.workspaceId, |
| 213 | currentRowCount: table.rowCount, |
| 214 | addedRows: result.length, |
| 215 | limit: rowLimit, |
| 216 | }) |
| 217 | dispatchAfterBatchInsert(table, result, requestId, data.userId) |
| 218 | return result |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Transaction-bound variant of `batchInsertRows`. Validates rows and unique |
no test coverage detected