(bookId: string)
| 10 | } from "./db-core"; |
| 11 | |
| 12 | export async function getNotes(bookId: string): Promise<Note[]> { |
| 13 | const database = await getDB(); |
| 14 | const rows = await database.select<{ |
| 15 | id: string; |
| 16 | book_id: string; |
| 17 | highlight_id: string | null; |
| 18 | cfi: string | null; |
| 19 | title: string; |
| 20 | content: string; |
| 21 | chapter_title: string | null; |
| 22 | tags: string; |
| 23 | created_at: number; |
| 24 | updated_at: number; |
| 25 | }>("SELECT * FROM notes WHERE book_id = ? ORDER BY created_at DESC", [bookId]); |
| 26 | return sortAnnotationsByPosition( |
| 27 | rows.map((r) => ({ |
| 28 | id: r.id, |
| 29 | bookId: r.book_id, |
| 30 | highlightId: r.highlight_id || undefined, |
| 31 | cfi: r.cfi || undefined, |
| 32 | title: r.title, |
| 33 | content: r.content, |
| 34 | chapterTitle: r.chapter_title || undefined, |
| 35 | tags: parseJSON(r.tags, []), |
| 36 | createdAt: r.created_at, |
| 37 | updatedAt: r.updated_at, |
| 38 | })), |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | /** Get all notes across all books (for general chat without bookId) */ |
| 43 | export async function getAllNotes(limit = 50): Promise<Note[]> { |
no test coverage detected