feat(bookmarks): client plumbing — saver capture + bookmark api

This commit is contained in:
2026-09-08 01:04:44 +08:00
parent 0fe3bc3057
commit b2c5c4a445
5 changed files with 31 additions and 4 deletions
+8 -1
View File
@@ -1,4 +1,4 @@
import type { Book, Library, Me, ProgressRow, User } from "./types";
import type { Book, Bookmark, Library, Me, ProgressRow, User } from "./types";
export const TOKEN_KEY = "booklib.token";
export const LOGOUT_EVENT = "booklib:logout";
@@ -177,5 +177,12 @@ export const api = {
putProgress: (id: number, locator: Record<string, unknown>, percent: number, keepalive = false) =>
apiFetch<void>(`/books/${id}/progress`, { method: "PUT", body: { locator, percent }, keepalive }),
listBookmarks: (id: number) => apiFetch<Bookmark[]>(`/books/${id}/bookmarks`),
createBookmark: (id: number, locator: Record<string, unknown>, percent: number, note: string) =>
apiFetch<Bookmark>(`/books/${id}/bookmarks`, { method: "POST", body: { locator, percent, note } }),
patchBookmark: (id: number, note: string) =>
apiFetch<void>(`/bookmarks/${id}`, { method: "PATCH", body: { note } }),
deleteBookmark: (id: number) => apiFetch<void>(`/bookmarks/${id}`, { method: "DELETE" }),
listProgress: () => apiFetch<ProgressRow[]>("/progress"),
};