| 112 | |
| 113 | /** Maps a {@link MultipartError} from the streaming CSV parser to its HTTP response. */ |
| 114 | export function multipartErrorResponse(error: MultipartError): NextResponse { |
| 115 | if (error.code === 'FILE_TOO_LARGE') { |
| 116 | return NextResponse.json({ error: 'CSV import file exceeds maximum size' }, { status: 413 }) |
| 117 | } |
| 118 | const message = |
| 119 | error.code === 'NO_FILE' ? 'CSV file is required' : `Invalid CSV upload: ${error.message}` |
| 120 | return NextResponse.json({ error: message }, { status: 400 }) |
| 121 | } |
| 122 | |
| 123 | interface TableAccessResult { |
| 124 | hasAccess: true |