( files: ChatFile[], executionContext: ChatExecutionContext, requestId: string, userId?: string )
| 34 | * @returns Array of UserFile objects with upload results |
| 35 | */ |
| 36 | export async function processChatFiles( |
| 37 | files: ChatFile[], |
| 38 | executionContext: ChatExecutionContext, |
| 39 | requestId: string, |
| 40 | userId?: string |
| 41 | ): Promise<UserFile[]> { |
| 42 | logger.info( |
| 43 | `Processing ${files.length} chat files for execution ${executionContext.executionId}`, |
| 44 | { |
| 45 | requestId, |
| 46 | executionContext, |
| 47 | } |
| 48 | ) |
| 49 | |
| 50 | const transformedFiles = files.map((file) => { |
| 51 | const inlineData = file.dataUrl || file.data |
| 52 | |
| 53 | return { |
| 54 | type: inlineData ? ('file' as const) : ('url' as const), |
| 55 | data: inlineData || file.url || '', |
| 56 | name: file.name, |
| 57 | mime: file.type, |
| 58 | } |
| 59 | }) |
| 60 | |
| 61 | const userFiles = await processExecutionFiles( |
| 62 | transformedFiles, |
| 63 | executionContext, |
| 64 | requestId, |
| 65 | userId |
| 66 | ) |
| 67 | |
| 68 | logger.info(`Successfully processed ${userFiles.length} chat files`, { |
| 69 | requestId, |
| 70 | executionId: executionContext.executionId, |
| 71 | }) |
| 72 | |
| 73 | return userFiles |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Upload a single chat file to temporary execution storage |
no test coverage detected