(data: ExportData, options: ExportOptions)
| 44 | |
| 45 | // Export as JSON |
| 46 | export const exportAsJSON = (data: ExportData, options: ExportOptions): string => { |
| 47 | const exportObject = { |
| 48 | ...data, |
| 49 | exportOptions: { |
| 50 | format: options.format, |
| 51 | includeImages: options.includeImages, |
| 52 | exportTimestamp: new Date().toISOString() |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | // If images are excluded, strip base64 data but keep metadata |
| 57 | if (!options.includeImages) { |
| 58 | const processIterations = (iterations: IterationData[]) => { |
| 59 | return iterations.map(iteration => ({ |
| 60 | ...iteration, |
| 61 | modelImages: iteration.modelImages?.map(() => '[Image data excluded]'), |
| 62 | sensors: iteration.sensors.map(sensor => ({ |
| 63 | ...sensor, |
| 64 | content: (sensor.type === 'screenshot' || sensor.type === 'camera') |
| 65 | ? { size: sensor.content?.size, excluded: true } |
| 66 | : sensor.content |
| 67 | })) |
| 68 | })); |
| 69 | }; |
| 70 | |
| 71 | if (exportObject.currentSession) { |
| 72 | exportObject.currentSession = processIterations(exportObject.currentSession); |
| 73 | } |
| 74 | |
| 75 | if (exportObject.historicalSessions) { |
| 76 | exportObject.historicalSessions = exportObject.historicalSessions.map(session => ({ |
| 77 | ...session, |
| 78 | iterations: processIterations(session.iterations) |
| 79 | })); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | return JSON.stringify(exportObject, null, 2); |
| 84 | }; |
| 85 | |
| 86 | // Export as HTML |
| 87 | export const exportAsHTML = (data: ExportData, options: ExportOptions): string => { |
no test coverage detected