(stdout: string)
| 73 | } |
| 74 | |
| 75 | export function parseNoteList(stdout: string): ZenNote[] { |
| 76 | const parsed = JSON.parse(stdout) as unknown; |
| 77 | if (!Array.isArray(parsed)) { |
| 78 | throw new Error("Expected `zn list --json` to return an array of notes."); |
| 79 | } |
| 80 | return parsed.map(parseNote).filter((note): note is ZenNote => note !== null); |
| 81 | } |
| 82 | |
| 83 | export function parseNote(value: unknown): ZenNote | null { |
| 84 | if (!isRecord(value)) return null; |