(connection, index)
| 92 | } |
| 93 | |
| 94 | function normalizeConnection(connection, index) { |
| 95 | if (!connection || typeof connection !== 'object' || !Array.isArray(connection.messages)) { |
| 96 | return null; |
| 97 | } |
| 98 | |
| 99 | const importedAt = Date.now(); |
| 100 | const originalId = connection.originalId || connection.id || `import-source-${index}`; |
| 101 | const createdAt = parseTimestamp(connection.createdAt, importedAt); |
| 102 | const id = generateImportedId(index); |
| 103 | |
| 104 | return { |
| 105 | id, |
| 106 | originalId, |
| 107 | importedAt, |
| 108 | url: connection.url || 'unknown', |
| 109 | frameUrl: connection.frameUrl || null, |
| 110 | isIframe: Boolean(connection.isIframe), |
| 111 | source: connection.source || connection.requestType || 'imported', |
| 112 | status: 'archived', |
| 113 | createdAt, |
| 114 | messages: connection.messages.map((message, messageIndex) => normalizeMessage(message, messageIndex)) |
| 115 | }; |
| 116 | } |
| 117 | |
| 118 | function normalizeMessage(message, index) { |
| 119 | const fallbackTimestamp = Date.now(); |
no test coverage detected