(value: unknown)
| 82 | } |
| 83 | |
| 84 | function parseStreamSnapshot(value: unknown): MothershipChatHistory['streamSnapshot'] { |
| 85 | if (!isRecordLike(value)) { |
| 86 | return null |
| 87 | } |
| 88 | |
| 89 | const rawEvents = Array.isArray(value.events) ? value.events : [] |
| 90 | const events: StreamBatchEvent[] = [] |
| 91 | for (const entry of rawEvents) { |
| 92 | if (!isStreamBatchEvent(entry)) { |
| 93 | return null |
| 94 | } |
| 95 | events.push(entry) |
| 96 | } |
| 97 | |
| 98 | const rawPreviewSessions = Array.isArray(value.previewSessions) ? value.previewSessions : [] |
| 99 | const previewSessions: FilePreviewSession[] = [] |
| 100 | for (const session of rawPreviewSessions) { |
| 101 | if (!isFilePreviewSession(session)) { |
| 102 | return null |
| 103 | } |
| 104 | previewSessions.push(session) |
| 105 | } |
| 106 | |
| 107 | return { |
| 108 | events, |
| 109 | previewSessions, |
| 110 | status: typeof value.status === 'string' ? value.status : 'unknown', |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | function normalizeMessages(value: unknown): PersistedMessage[] { |
| 115 | if (!Array.isArray(value)) { |
no test coverage detected