MCPcopy Create free account
hub / github.com/Roy3838/Observer / exportAsJSON

Function exportAsJSON

app/src/utils/exportUtils.ts:46–84  ·  view source on GitHub ↗
(data: ExportData, options: ExportOptions)

Source from the content-addressed store, hash-verified

44
45// Export as JSON
46export 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
87export const exportAsHTML = (data: ExportData, options: ExportOptions): string => {

Callers 1

exportDataFunction · 0.85

Calls 1

processIterationsFunction · 0.85

Tested by

no test coverage detected