(rawLine: string)
| 85 | } |
| 86 | |
| 87 | function parseCodexLine(rawLine: string): CodexLine | null { |
| 88 | try { |
| 89 | const parsed: unknown = JSON.parse(rawLine); |
| 90 | if (!isRecord(parsed) || typeof parsed.type !== 'string') return null; |
| 91 | let timestamp: string | undefined; |
| 92 | if (typeof parsed.timestamp === 'string') { |
| 93 | timestamp = parsed.timestamp; |
| 94 | } else if (typeof parsed.timestamp === 'number') { |
| 95 | timestamp = new Date(parsed.timestamp).toISOString(); |
| 96 | } |
| 97 | return { |
| 98 | type: parsed.type, |
| 99 | timestamp, |
| 100 | payload: recordValue(parsed.payload), |
| 101 | }; |
| 102 | } catch { |
| 103 | return null; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | function parseJsonRecord(raw: string): Record<string, unknown> | null { |
| 108 | try { |
no test coverage detected