| 205 | } |
| 206 | |
| 207 | const resolveOutputPath = (filename: string | undefined, format: 'jsonl' | 'json'): string => { |
| 208 | const fallback = format === 'json' ? 'events.json' : 'events.jsonl' |
| 209 | const outputPath = path.resolve(filename || fallback) |
| 210 | const expectedExtension = format === 'json' ? '.json' : '.jsonl' |
| 211 | |
| 212 | if (extname(outputPath).toLowerCase() !== expectedExtension) { |
| 213 | throw new Error(`Output file extension must be ${expectedExtension} when using --format ${format}`) |
| 214 | } |
| 215 | |
| 216 | return outputPath |
| 217 | } |
| 218 | |
| 219 | const toEvent = (row: EventRow) => ({ |
| 220 | id: row.event_id.toString('hex'), |