MCPcopy Create free account
hub / github.com/simstudioai/sim / parseStreamSnapshot

Function parseStreamSnapshot

apps/sim/hooks/queries/mothership-chats.ts:84–112  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

82}
83
84function 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
114function normalizeMessages(value: unknown): PersistedMessage[] {
115 if (!Array.isArray(value)) {

Callers 1

Calls 4

isRecordLikeFunction · 0.90
isStreamBatchEventFunction · 0.90
isFilePreviewSessionFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected