MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / normalizeConnection

Function normalizeConnection

devtools/modules/importManager.js:94–116  ·  view source on GitHub ↗
(connection, index)

Source from the content-addressed store, hash-verified

92}
93
94function 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
118function normalizeMessage(message, index) {
119 const fallbackTimestamp = Date.now();

Callers 1

normalizeImportDataFunction · 0.70

Calls 3

parseTimestampFunction · 0.70
generateImportedIdFunction · 0.70
normalizeMessageFunction · 0.70

Tested by

no test coverage detected