Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat: add new article quality assessment (#2975)

Mohamed Bassem76b477c4c04e
diff --git a/apps/web/components/dashboard/preview/LinkContentSection.tsx b/apps/web/components/dashboard/preview/LinkContentSection.tsx
index 31b8c51c..84a9207b 100644
--- a/apps/web/components/dashboard/preview/LinkContentSection.tsx
+++ b/apps/web/components/dashboard/preview/LinkContentSection.tsx
@@ -26,6 +26,7 @@ import {
ExpandIcon,
FileText,
Info,
+ LayoutPanelTop,
Video,
} from "lucide-react";
import { useQueryState } from "nuqs";
@@ -41,6 +42,7 @@ import { READER_FONT_FAMILIES } from "@karakeep/shared/types/readers";
import { contentRendererRegistry } from "./content-renderers";
import ReaderSettingsPopover from "./ReaderSettingsPopover";
import ReaderView from "./ReaderView";
+import SavedPageOverview from "./SavedPageOverview";
function CustomRendererErrorFallback({ error }: { error: Error }) {
return (
@@ -123,8 +125,17 @@ export default function LinkContentSection({
const { t } = useTranslation();
const { settings } = useReaderSettings();
const availableRenderers = contentRendererRegistry.getRenderers(bookmark);
- const defaultSection =
- availableRenderers.length > 0 ? availableRenderers[0].id : "cached";
+ let defaultSection = availableRenderers[0]?.id ?? "cached";
+ if (
+ availableRenderers.length === 0 &&
+ bookmark.content.type === BookmarkTypes.LINK
+ ) {
+ if (bookmark.content.preferredPreview === "screenshot") {
+ defaultSection = "screenshot";
+ } else if (bookmark.content.preferredPreview === "overview") {
+ defaultSection = "overview";
+ }
+ }
const [section, setSection] = useQueryState("section", {
defaultValue: defaultSection,
});
@@ -167,8 +178,12 @@ export default function LinkContentSection({
content = <VideoSection link={bookmark.content} />;
} else if (section === "pdf") {
content = <PDFSection link={bookmark.content} />;
- } else {
+ } else if (section === "screenshot") {
content = <ScreenshotSection link={bookmark.content} />;
+ } else {
+ content = (
+ <SavedPageOverview link={bookmark.content} onSelectSection={setSection} />
+ );
}
return (
@@ -196,7 +211,16 @@ export default function LinkContentSection({
})}
{/* Default renderers */}
- <SelectItem value="cached">
+ <SelectItem value="overview">
+ <div className="flex items-center">
+ <LayoutPanelTop className="mr-2 h-4 w-4" />
+ {t("preview.page_overview")}
+ </div>
+ </SelectItem>
+ <SelectItem
+ value="cached"
+ disabled={bookmark.content.readerViewStatus === "unavailable"}
+ >
<div className="flex items-center">
<BookOpen className="mr-2 h-4 w-4" />
{t("preview.reader_view")}
@@ -226,7 +250,7 @@ export default function LinkContentSection({
>
<div className="flex items-center">
<Archive className="mr-2 h-4 w-4" />
- {t("common.archive")}
+ {t("preview.archived_page")}
</div>
</SelectItem>
<SelectItem
diff --git a/apps/web/components/dashboard/preview/SavedPageOverview.tsx b/apps/web/components/dashboard/preview/SavedPageOverview.tsx
new file mode 100644
index 00000000..c46e80fb
--- /dev/null
+++ b/apps/web/components/dashboard/preview/SavedPageOverview.tsx
@@ -0,0 +1,100 @@
+import Image from "next/image";
+import Link from "next/link";
+import { Button } from "@/components/ui/button";
+import { useTranslation } from "@/lib/i18n/client";
+import { BookOpen, ExternalLink, Globe2 } from "lucide-react";
+
+import type { ZBookmarkedLink } from "@karakeep/shared/types/bookmarks";
+import { getBookmarkLinkImageUrl } from "@karakeep/shared/utils/bookmarkUtils";
+
+function hostname(url: string) {
+ try {
+ return new URL(url).hostname.replace(/^www\./, "");
+ } catch {
+ return url;
+ }
+}
+
+export default function SavedPageOverview({
+ link,
+ onSelectSection,
+}: {
+ link: ZBookmarkedLink;
+ onSelectSection: (section: string) => void;
+}) {
+ const { t } = useTranslation();
+ const image = getBookmarkLinkImageUrl(link);
+ const readerAvailable = link.readerViewStatus !== "unavailable";
+
+ return (
+ <div className="h-full overflow-y-auto">
+ <div className="mx-auto w-full max-w-3xl px-4 pb-10 pt-16 sm:px-8 sm:pt-20">
+ <article className="w-full overflow-hidden rounded-xl border bg-card shadow-sm">
+ {image ? (
+ <div className="relative aspect-[16/7] max-h-72 w-full overflow-hidden border-b bg-muted/40">
+ <Image
+ src={image.url}
+ alt=""
+ fill
+ unoptimized
+ className="object-contain"
+ sizes="(max-width: 768px) 100vw, 768px"
+ />
+ </div>
+ ) : (
+ <div className="flex h-28 items-center justify-center border-b bg-muted/40">
+ <Globe2 className="size-8 text-muted-foreground/60" />
+ </div>
+ )}
+
+ <div className="space-y-6 p-5 sm:p-8">
+ <div className="space-y-3">
+ <div className="flex items-center gap-2 text-xs font-medium uppercase tracking-wider text-muted-foreground">
+ {link.favicon ? (
+ <Image
+ src={link.favicon}
+ alt=""
+ width={16}
+ height={16}
+ unoptimized
+ className="rounded-sm"
+ />
+ ) : (
+ <Globe2 className="size-4" />
+ )}
+ <span className="truncate">{hostname(link.url)}</span>
+ </div>
+ <h2 className="text-balance text-2xl font-semibold leading-tight text-foreground sm:text-3xl">
+ {link.title || hostname(link.url)}
+ </h2>
+ {link.description ? (
+ <p className="max-w-2xl text-pretty text-sm leading-6 text-muted-foreground sm:text-base">
+ {link.description}
+ </p>
+ ) : null}
+ </div>
+
+ <div className="flex flex-nowrap items-center gap-2">
+ <Button asChild size="sm">
+ <Link href={link.url} target="_blank" rel="noreferrer">
+ <ExternalLink className="mr-2 size-4" />
+ {t("preview.view_original")}
+ </Link>
+ </Button>
+ {readerAvailable ? (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => onSelectSection("cached")}
+ >
+ <BookOpen className="mr-2 size-4" />
+ {t("preview.try_reader_view")}
+ </Button>
+ ) : null}
+ </div>
+ </div>
+ </article>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json
index 0ac87235..a4410498 100644
--- a/apps/web/lib/i18n/locales/en/translation.json
+++ b/apps/web/lib/i18n/locales/en/translation.json
@@ -980,6 +980,9 @@
"view_original": "View Original",
"cached_content": "Cached Content",
"reader_view": "Reader View",
+ "page_overview": "Page Overview",
+ "try_reader_view": "Try Reader View",
+ "archived_page": "Archived Page",
"archive_info": "Archives may not render correctly inline if they require Javascript. For best results, <1>download it and open in your browser</1>.",
"fetch_error_title": "Content Unavailable",
"fetch_error_description": "We couldn't fetch the content for this link. The page may be protected, require authentication, or be temporarily unavailable.",
diff --git a/apps/web/lib/i18n/locales/en_US/translation.json b/apps/web/lib/i18n/locales/en_US/translation.json
index 25fe2629..31aeef2c 100644
--- a/apps/web/lib/i18n/locales/en_US/translation.json
+++ b/apps/web/lib/i18n/locales/en_US/translation.json
@@ -1069,6 +1069,9 @@
"view_original": "View Original",
"cached_content": "Cached Content",
"reader_view": "Reader View",
+ "page_overview": "Page Overview",
+ "try_reader_view": "Try Reader View",
+ "archived_page": "Archived Page",
"tabs": {
"content": "Content",
"details": "Details"
diff --git a/apps/workers/scripts/parseHtmlSubprocess.ts b/apps/workers/scripts/parseHtmlSubprocess.ts
index bc9c4a3d..273ec890 100644
--- a/apps/workers/scripts/parseHtmlSubprocess.ts
+++ b/apps/workers/scripts/parseHtmlSubprocess.ts
@@ -28,6 +28,11 @@ import {
parseSubprocessInputSchema,
parseSubprocessOutputSchema,
} from "../workers/utils/parseHtmlSubprocessIpc";
+import {
+ assessReaderView,
+ ReaderViewAssessment,
+ unavailableReaderViewAssessment,
+} from "../workers/utils/readerViewAssessment";
// Redirect all log output to stderr so it doesn't interfere with the JSON protocol on stdout.
logger.clear();
@@ -128,21 +133,40 @@ function normalizeLazyLoadImages(document: Document): void {
function extractReadableContent(
htmlContent: string,
url: string,
-): { content: string } | null {
+): {
+ readableContent: { content: string } | null;
+ readerViewAssessment: ReaderViewAssessment;
+} {
const virtualConsole = new VirtualConsole();
const dom = new JSDOM(htmlContent, { url, virtualConsole });
try {
normalizeLazyLoadImages(dom.window.document);
- const readableContent = new Readability(dom.window.document).parse();
+ const documentClone = dom.window.document.cloneNode(true) as Document;
+ const readableContent = new Readability(documentClone).parse();
if (!readableContent || typeof readableContent.content !== "string") {
- return null;
+ return {
+ readableContent: null,
+ readerViewAssessment: unavailableReaderViewAssessment(),
+ };
}
const purifyWindow = new JSDOM("").window;
try {
const purify = DOMPurify(purifyWindow);
const purifiedHTML = purify.sanitize(readableContent.content);
- return { content: purifiedHTML };
+ const extractedDom = new JSDOM(purifiedHTML, { url, virtualConsole });
+ try {
+ return {
+ readableContent: { content: purifiedHTML },
+ readerViewAssessment: assessReaderView(
+ dom.window.document,
+ extractedDom.window.document,
+ url,
+ ),
+ };
+ } finally {
+ extractedDom.window.close();
+ }
} finally {
purifyWindow.close();
}
@@ -177,6 +201,7 @@ async function main() {
// Conditionally run readability (skip if metascraper already provided readable content, e.g. Reddit plugin)
let readableContent: { content: string } | null = null;
+ let readerViewAssessment: ReaderViewAssessment | null = null;
if (!metadataOnly && meta.readableContentHtml) {
// Sanitize plugin-provided HTML through DOMPurify (the extractReadableContent
// path already does this, but the direct-content path was missing it).
@@ -185,6 +210,18 @@ async function main() {
const purify = DOMPurify(purifyWindow);
const purifiedHTML = purify.sanitize(meta.readableContentHtml);
readableContent = { content: purifiedHTML };
+ const sourceDom = new JSDOM(htmlContent, { url });
+ const extractedDom = new JSDOM(purifiedHTML, { url });
+ try {
+ readerViewAssessment = assessReaderView(
+ sourceDom.window.document,
+ extractedDom.window.document,
+ url,
+ );
+ } finally {
+ sourceDom.window.close();
+ extractedDom.window.close();
+ }
} finally {
purifyWindow.close();
}
@@ -194,16 +231,19 @@ async function main() {
logger.info(
`[Crawler][${jobId}] Will attempt to extract readable content ...`,
);
- readableContent = extractReadableContent(
+ const extractionResult = extractReadableContent(
meta.contentHtml ?? htmlContent,
url,
);
+ readableContent = extractionResult.readableContent;
+ readerViewAssessment = extractionResult.readerViewAssessment;
logger.info(`[Crawler][${jobId}] Done extracting readable content.`);
}
const output = parseSubprocessOutputSchema.parse({
metadata: meta,
readableContent,
+ readerViewAssessment,
});
// Write the result as JSON to stdout
diff --git a/apps/workers/workers/crawler/crawlAndParse.ts b/apps/workers/workers/crawler/crawlAndParse.ts
index 09e00b71..b6ef593a 100644
--- a/apps/workers/workers/crawler/crawlAndParse.ts
+++ b/apps/workers/workers/crawler/crawlAndParse.ts
@@ -34,6 +34,7 @@ import {
import serverConfig from "@karakeep/shared/config";
import logger from "@karakeep/shared/logger";
import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";
+import type { ZReaderViewReason } from "@karakeep/shared/types/bookmarks";
import type { ParseSubprocessOutput } from "../utils/parseHtmlSubprocessIpc";
import {
@@ -273,8 +274,11 @@ export async function crawlAndParseUrl(
);
}
- const { metadata: renderMeta, readableContent: parsedReadableContent } =
- await runParseSubprocess(htmlContent, browserUrl, jobId, abortSignal);
+ const {
+ metadata: renderMeta,
+ readableContent: parsedReadableContent,
+ readerViewAssessment,
+ } = await runParseSubprocess(htmlContent, browserUrl, jobId, abortSignal);
abortSignal.throwIfAborted();
// The probe metadata extraction has been running alongside the crawl;
@@ -287,9 +291,12 @@ export async function crawlAndParseUrl(
// code, and some bot walls serve their challenge page with a 200; in
// both cases don't let that page's metadata override clean values from
// the preflight probe.
+ const renderIsChallengePage = isLikelyChallengePage({
+ title: renderMeta.title,
+ htmlContent,
+ });
const renderBlocked =
- shouldRetryCrawlStatusCode(statusCode) ||
- isLikelyChallengePage({ title: renderMeta.title, htmlContent });
+ shouldRetryCrawlStatusCode(statusCode) || renderIsChallengePage;
addLogFields<"crawlerWorker.run">({
"crawler.render_blocked": renderBlocked,
});
@@ -299,6 +306,12 @@ export async function crawlAndParseUrl(
);
}
const meta = resolveMetadata(renderMeta, probeMetadata, renderBlocked);
+ const readerViewReasons: ZReaderViewReason[] | null = readerViewAssessment
+ ? renderIsChallengePage &&
+ !readerViewAssessment.reasons.includes("challenge_page")
+ ? [...readerViewAssessment.reasons, "challenge_page"]
+ : readerViewAssessment.reasons
+ : null;
const parseDate = (date: string | null | undefined) => {
if (!date) {
@@ -390,6 +403,11 @@ export async function crawlAndParseUrl(
htmlContentAssetInfo.result === "stored"
? htmlContentAssetInfo.assetId
: null,
+ readerViewStatus: readerViewAssessment?.status ?? null,
+ readerViewScore: readerViewAssessment?.score ?? null,
+ readerViewReasons,
+ readerViewClassifierVersion:
+ readerViewAssessment?.classifierVersion ?? null,
})
.where(eq(bookmarkLinks.id, bookmarkId));
diff --git a/apps/workers/workers/crawler/parseSubprocess.ts b/apps/workers/workers/crawler/parseSubprocess.ts
index 3bf4db84..ec24e45e 100644
--- a/apps/workers/workers/crawler/parseSubprocess.ts
+++ b/apps/workers/workers/crawler/parseSubprocess.ts
@@ -57,6 +57,7 @@ export async function runParseSubprocess(
): Promise<{
metadata: ParseSubprocessOutput["metadata"];
readableContent: { content: string } | null;
+ readerViewAssessment: ParseSubprocessOutput["readerViewAssessment"];
}> {
return await withSpan(
tracer,
@@ -143,6 +144,7 @@ export async function runParseSubprocess(
return {
metadata: output.metadata,
readableContent: output.readableContent,
+ readerViewAssessment: output.readerViewAssessment,
};
},
);
diff --git a/apps/workers/workers/utils/parseHtmlSubprocessIpc.ts b/apps/workers/workers/utils/parseHtmlSubprocessIpc.ts
index 304830f2..dbac019c 100644
--- a/apps/workers/workers/utils/parseHtmlSubprocessIpc.ts
+++ b/apps/workers/workers/utils/parseHtmlSubprocessIpc.ts
@@ -1,5 +1,10 @@
import { z } from "zod";
+import {
+ zReaderViewReasonSchema,
+ zReaderViewStatusSchema,
+} from "@karakeep/shared/types/bookmarks";
+
export const parseSubprocessInputSchema = z.object({
htmlContent: z.string(),
url: z.string(),
@@ -23,6 +28,14 @@ export const parseSubprocessMetadataSchema = z.looseObject({
export const parseSubprocessOutputSchema = z.object({
metadata: parseSubprocessMetadataSchema,
readableContent: z.object({ content: z.string() }).nullable(),
+ readerViewAssessment: z
+ .object({
+ status: zReaderViewStatusSchema,
+ score: z.number().int().min(0).max(100),
+ reasons: z.array(zReaderViewReasonSchema),
+ classifierVersion: z.number().int().positive(),
+ })
+ .nullable(),
});
export const parseSubprocessErrorSchema = z.object({
diff --git a/apps/workers/workers/utils/readerViewAssessment.test.ts b/apps/workers/workers/utils/readerViewAssessment.test.ts
new file mode 100644
index 00000000..6e23fce8
--- /dev/null
+++ b/apps/workers/workers/utils/readerViewAssessment.test.ts
@@ -0,0 +1,136 @@
+import { JSDOM } from "jsdom";
+import { describe, expect, test } from "vitest";
+
+import {
+ assessReaderView,
+ unavailableReaderViewAssessment,
+} from "./readerViewAssessment";
+
+function assess(sourceHtml: string, extractedHtml: string, url: string) {
+ const source = new JSDOM(sourceHtml, { url });
+ const extracted = new JSDOM(extractedHtml, { url });
+ try {
+ return assessReaderView(
+ source.window.document,
+ extracted.window.document,
+ url,
+ );
+ } finally {
+ source.window.close();
+ extracted.window.close();
+ }
+}
+
+const paragraph =
+ "A useful article paragraph contains connected prose, enough detail to make a point, and several complete sentences. It gives readers context. It is not merely a navigation label.";
+
+describe("reader view assessment", () => {
+ test("accepts a structured article with substantial prose", () => {
+ const html = `
+ <html>
+ <head><meta property="og:type" content="article"></head>
+ <body><article><h1>A considered essay</h1>${Array.from(
+ { length: 6 },
+ () => `<p>${paragraph}</p>`,
+ ).join("")}</article></body>
+ </html>`;
+
+ const result = assess(html, html, "https://example.com/essays/considered");
+
+ expect(result.status).toBe("readable");
+ expect(result.score).toBeGreaterThanOrEqual(70);
+ expect(result.reasons).toContain("article_metadata");
+ });
+
+ test("rejects a search homepage made of controls and navigation links", () => {
+ const links = [
+ "About",
+ "Store",
+ "Mail",
+ "Images",
+ "Advertising",
+ "Business",
+ "Privacy",
+ "Terms",
+ "Settings",
+ ]
+ .map((label) => `<a href="/${label.toLowerCase()}">${label}</a>`)
+ .join("");
+ const source = `<main><form><input name="q"><button>Search</button><button>Lucky</button></form>${links}</main>`;
+
+ const result = assess(
+ source,
+ `<div>${links}</div>`,
+ "https://www.google.com/",
+ );
+
+ expect(result.status).toBe("not_readable");
+ expect(result.reasons).toContain("very_high_link_density");
+ expect(result.reasons).toContain("root_page");
+ });
+
+ test("rejects a link-heavy search results extraction despite its length", () => {
+ const results = Array.from(
+ { length: 12 },
+ (_, index) =>
+ `<li><a href="https://example.com/${index}">Result ${index}: ${paragraph}</a></li>`,
+ ).join("");
+ const source = `<main><form><input name="q"><button>Search</button><button>Tools</button></form><ul>${results}</ul></main>`;
+
+ const result = assess(
+ source,
+ `<ul>${results}</ul>`,
+ "https://www.google.com/search?q=reader+mode",
+ );
+
+ expect(result.status).toBe("not_readable");
+ expect(result.reasons).toContain("search_url");
+ expect(result.reasons).toContain("link_collection");
+ });
+
+ test("keeps short but prose-like content uncertain", () => {
+ const html = `<main><p>${paragraph}</p><p>${paragraph}</p></main>`;
+
+ const result = assess(html, html, "https://example.com/note");
+
+ expect(result.status).toBe("uncertain");
+ });
+
+ test("does not auto-select reader view for a prose-heavy homepage", () => {
+ const html = `<main>${Array.from(
+ { length: 8 },
+ () => `<p>${paragraph}</p>`,
+ ).join(
+ "",
+ )}<form><input><button>Start now</button><button>Sign in</button></form></main>`;
+
+ const result = assess(html, html, "https://example.com/");
+
+ expect(result.status).toBe("uncertain");
+ expect(result.score).toBeLessThan(70);
+ expect(result.reasons).toContain("root_page");
+ });
+
+ test("accepts code-heavy documentation with a substantial preformatted block", () => {
+ const code = Array.from(
+ { length: 20 },
+ (_, index) => `const task${index} = queue.enqueue({ id: ${index} });`,
+ ).join("\n");
+ const source = `<article><h1>Queue documentation</h1><p>${paragraph}</p><pre>${code}</pre></article>`;
+ const extracted = `<article><p>${paragraph}</p><pre>${code}</pre></article>`;
+
+ const result = assess(source, extracted, "https://example.com/docs/queue");
+
+ expect(result.status).toBe("readable");
+ expect(result.reasons).toContain("long_preformatted_content");
+ });
+
+ test("represents a missing extraction separately", () => {
+ expect(unavailableReaderViewAssessment()).toEqual({
+ status: "unavailable",
+ score: 0,
+ reasons: ["no_extracted_content"],
+ classifierVersion: 3,
+ });
+ });
+});
diff --git a/apps/workers/workers/utils/readerViewAssessment.ts b/apps/workers/workers/utils/readerViewAssessment.ts
new file mode 100644
index 00000000..df3b949f
--- /dev/null
+++ b/apps/workers/workers/utils/readerViewAssessment.ts
@@ -0,0 +1,248 @@
+import { isProbablyReaderable } from "@mozilla/readability";
+
+import type {
+ ZReaderViewReason,
+ ZReaderViewStatus,
+} from "@karakeep/shared/types/bookmarks";
+
+export const READER_VIEW_CLASSIFIER_VERSION = 3;
+
+export interface ReaderViewAssessment {
+ status: ZReaderViewStatus;
+ score: number;
+ reasons: ZReaderViewReason[];
+ classifierVersion: number;
+}
+
+const ARTICLE_SCHEMA_PATTERN =
+ /"@type"\s*:\s*(?:\[[^\]]*)?"(?:Article|NewsArticle|BlogPosting|TechArticle|ScholarlyArticle|Report)"/i;
+const NON_ARTICLE_SCHEMA_PATTERN =
+ /"@type"\s*:\s*(?:\[[^\]]*)?"(?:Product|WebApplication|SearchResultsPage|ItemList)"/i;
+const SENTENCE_END_PATTERN = /(?:[.!?](?:\s|$)|[。!?])/gu;
+
+function normalizedText(document: Document): string {
+ return (document.body?.textContent ?? "").replace(/\s+/g, " ").trim();
+}
+
+function schemaText(document: Document): string {
+ return [...document.querySelectorAll('script[type="application/ld+json"]')]
+ .map((node) => node.textContent ?? "")
+ .join("\n");
+}
+
+function hasArticleMetadata(document: Document): boolean {
+ const ogType = document
+ .querySelector('meta[property="og:type"]')
+ ?.getAttribute("content")
+ ?.toLowerCase();
+ return (
+ ogType === "article" ||
+ !!document.querySelector(
+ '[itemtype*="schema.org/Article"], [itemtype*="schema.org/NewsArticle"], [itemtype*="schema.org/BlogPosting"]',
+ ) ||
+ ARTICLE_SCHEMA_PATTERN.test(schemaText(document))
+ );
+}
+
+function hasNonArticleMetadata(document: Document): boolean {
+ return (
+ !!document.querySelector(
+ '[itemtype*="schema.org/Product"], [itemtype*="schema.org/WebApplication"], [itemtype*="schema.org/SearchResultsPage"], [itemtype*="schema.org/ItemList"]',
+ ) || NON_ARTICLE_SCHEMA_PATTERN.test(schemaText(document))
+ );
+}
+
+function hasSearchUrlSignal(url: string): boolean {
+ try {
+ const parsed = new URL(url);
+ const pathLooksLikeSearch = /\/(?:search|results)(?:\/|$)/i.test(
+ parsed.pathname,
+ );
+ const params = new Set(
+ [...parsed.searchParams.keys()].map((key) => key.toLowerCase()),
+ );
+ return (
+ pathLooksLikeSearch ||
+ params.has("q") ||
+ params.has("query") ||
+ params.has("keyword") ||
+ params.has("search")
+ );
+ } catch {
+ return false;
+ }
+}
+
+function isRootUrl(url: string): boolean {
+ try {
+ const parsed = new URL(url);
+ return (
+ (parsed.pathname === "/" || parsed.pathname === "") && !parsed.search
+ );
+ } catch {
+ return false;
+ }
+}
+
+function statusForScore(score: number): ZReaderViewStatus {
+ if (score >= 70) {
+ return "readable";
+ }
+ if (score >= 35) {
+ return "uncertain";
+ }
+ return "not_readable";
+}
+
+export function unavailableReaderViewAssessment(): ReaderViewAssessment {
+ return {
+ status: "unavailable",
+ score: 0,
+ reasons: ["no_extracted_content"],
+ classifierVersion: READER_VIEW_CLASSIFIER_VERSION,
+ };
+}
+
+export function assessReaderView(
+ sourceDocument: Document,
+ extractedDocument: Document,
+ url: string,
+): ReaderViewAssessment {
+ let score = 50;
+ const reasons: ZReaderViewReason[] = [];
+ const extractedText = normalizedText(extractedDocument);
+ const textLength = extractedText.length;
+ const articleMetadata = hasArticleMetadata(sourceDocument);
+ const rootPage = isRootUrl(url) && !articleMetadata;
+
+ if (articleMetadata) {
+ score += 20;
+ reasons.push("article_metadata");
+ } else if (hasNonArticleMetadata(sourceDocument)) {
+ score -= 20;
+ reasons.push("non_article_metadata");
+ }
+
+ if (sourceDocument.querySelector("article")) {
+ score += 10;
+ reasons.push("article_element");
+ }
+
+ if (textLength < 80) {
+ score -= 30;
+ reasons.push("very_short_content");
+ } else if (textLength < 200) {
+ score -= 15;
+ reasons.push("short_content");
+ } else if (textLength >= 1_500) {
+ score += 25;
+ reasons.push("substantial_content_length");
+ } else if (textLength >= 500) {
+ score += 15;
+ reasons.push("useful_content_length");
+ }
+
+ const substantiveBlocks = [
+ ...extractedDocument.querySelectorAll("p, pre, blockquote"),
+ ].filter((node) => (node.textContent?.trim().length ?? 0) >= 80).length;
+ const hasLongPreformattedBlock = [
+ ...extractedDocument.querySelectorAll("pre"),
+ ].some((node) => (node.textContent?.trim().length ?? 0) >= 300);
+
+ if (substantiveBlocks === 0) {
+ score -= 25;
+ reasons.push("no_substantive_blocks");
+ } else if (substantiveBlocks === 1) {
+ score -= 10;
+ reasons.push("single_substantive_block");
+ } else if (substantiveBlocks >= 4) {
+ score += 15;
+ reasons.push("multiple_substantive_blocks");
+ } else {
+ score += 5;
+ reasons.push("some_substantive_blocks");
+ }
+
+ if (hasLongPreformattedBlock) {
+ score += 15;
+ reasons.push("long_preformatted_content");
+ }
+
+ const linkTextLength = [...extractedDocument.querySelectorAll("a")].reduce(
+ (total, link) => total + (link.textContent?.trim().length ?? 0),
+ 0,
+ );
+ const linkDensity = linkTextLength / Math.max(textLength, 1);
+ if (linkDensity > 0.65) {
+ score -= 35;
+ reasons.push("very_high_link_density");
+ } else if (linkDensity > 0.4) {
+ score -= 25;
+ reasons.push("high_link_density");
+ } else if (linkDensity > 0.25) {
+ score -= 10;
+ reasons.push("elevated_link_density");
+ } else if (linkDensity <= 0.12 && textLength >= 200) {
+ score += 10;
+ reasons.push("low_link_density");
+ }
+
+ const controls = sourceDocument.querySelectorAll(
+ "button, input, select, textarea",
+ ).length;
+ const sourceParagraphs =
+ sourceDocument.querySelectorAll("p, pre, blockquote").length;
+ if (controls >= 3 && controls > sourceParagraphs) {
+ score -= 15;
+ reasons.push("control_heavy_page");
+ }
+
+ const extractedLinks = extractedDocument.querySelectorAll("a").length;
+ if (extractedLinks >= 8 && substantiveBlocks <= 1) {
+ score -= 20;
+ reasons.push("link_collection");
+ }
+
+ if (hasSearchUrlSignal(url) && !articleMetadata) {
+ score -= 25;
+ reasons.push("search_url");
+ }
+
+ if (rootPage) {
+ score -= 10;
+ reasons.push("root_page");
+ }
+
+ const sentenceEndCount =
+ extractedText.match(SENTENCE_END_PATTERN)?.length ?? 0;
+ if (sentenceEndCount >= 3) {
+ score += 10;
+ reasons.push("sentence_like_text");
+ } else if (textLength >= 200) {
+ score -= 10;
+ reasons.push("low_sentence_density");
+ }
+
+ if (isProbablyReaderable(sourceDocument)) {
+ score += 10;
+ reasons.push("probably_readerable");
+ } else {
+ score -= 10;
+ reasons.push("probably_not_readerable");
+ }
+
+ // A homepage can contain a large amount of polished marketing copy while
+ // still lacking a coherent standalone document. Without explicit article
+ // metadata, require the user to opt into Reader View.
+ if (rootPage) {
+ score = Math.min(score, 60);
+ }
+
+ const normalizedScore = Math.max(0, Math.min(100, Math.round(score)));
+ return {
+ status: statusForScore(normalizedScore),
+ score: normalizedScore,
+ reasons,
+ classifierVersion: READER_VIEW_CLASSIFIER_VERSION,
+ };
+}
diff --git a/packages/db/drizzle/0093_reader_view_assessment.sql b/packages/db/drizzle/0093_reader_view_assessment.sql
new file mode 100644
index 00000000..42ff330c
--- /dev/null
+++ b/packages/db/drizzle/0093_reader_view_assessment.sql
@@ -0,0 +1,4 @@
+ALTER TABLE `bookmarkLinks` ADD `readerViewStatus` text;--> statement-breakpoint
+ALTER TABLE `bookmarkLinks` ADD `readerViewScore` integer;--> statement-breakpoint
+ALTER TABLE `bookmarkLinks` ADD `readerViewReasons` text;--> statement-breakpoint
+ALTER TABLE `bookmarkLinks` ADD `readerViewClassifierVersion` integer;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0093_snapshot.json b/packages/db/drizzle/meta/0093_snapshot.json
new file mode 100644
index 00000000..16d303b6
--- /dev/null
+++ b/packages/db/drizzle/meta/0093_snapshot.json
@@ -0,0 +1,3582 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "21170083-5dab-4bbf-803f-406ea6baeb30",
+ "prevId": "e00919aa-5d40-4c7a-b77c-4d6b131f36bf",
+ "tables": {
+ "account": {
+ "name": "account",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ],
+ "name": "account_provider_providerAccountId_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "apiKey": {
+ "name": "apiKey",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "lastUsedAt": {
+ "name": "lastUsedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "keyId": {
+ "name": "keyId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyHash": {
+ "name": "keyHash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "apiKey_keyId_unique": {
+ "name": "apiKey_keyId_unique",
+ "columns": [
+ "keyId"
+ ],
+ "isUnique": true
+ },
+ "apiKey_name_userId_unique": {
+ "name": "apiKey_name_userId_unique",
+ "columns": [
+ "name",
+ "userId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "apiKey_userId_user_id_fk": {
+ "name": "apiKey_userId_user_id_fk",
+ "tableFrom": "apiKey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "assets": {
+ "name": "assets",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "assetType": {
+ "name": "assetType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "contentType": {
+ "name": "contentType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileName": {
+ "name": "fileName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "assets_bookmarkId_idx": {
+ "name": "assets_bookmarkId_idx",
+ "columns": [
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "assets_assetType_idx": {
+ "name": "assets_assetType_idx",
+ "columns": [
+ "assetType"
+ ],
+ "isUnique": false
+ },
+ "assets_userId_idx": {
+ "name": "assets_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "assets_bookmarkId_bookmarks_id_fk": {
+ "name": "assets_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "assets_userId_user_id_fk": {
+ "name": "assets_userId_user_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "backups": {
+ "name": "backups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "assetId": {
+ "name": "assetId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bookmarkCount": {
+ "name": "bookmarkCount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "errorMessage": {
+ "name": "errorMessage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "backups_userId_idx": {
+ "name": "backups_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "backups_createdAt_idx": {
+ "name": "backups_createdAt_idx",
+ "columns": [
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "backups_userId_user_id_fk": {
+ "name": "backups_userId_user_id_fk",
+ "tableFrom": "backups",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "backups_assetId_assets_id_fk": {
+ "name": "backups_assetId_assets_id_fk",
+ "tableFrom": "backups",
+ "tableTo": "assets",
+ "columnsFrom": [
+ "assetId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarkAssets": {
+ "name": "bookmarkAssets",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "assetType": {
+ "name": "assetType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "assetId": {
+ "name": "assetId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileName": {
+ "name": "fileName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "sourceUrl": {
+ "name": "sourceUrl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bookmarkAssets_id_bookmarks_id_fk": {
+ "name": "bookmarkAssets_id_bookmarks_id_fk",
+ "tableFrom": "bookmarkAssets",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarkLinks": {
+ "name": "bookmarkLinks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "author": {
+ "name": "author",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "publisher": {
+ "name": "publisher",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "datePublished": {
+ "name": "datePublished",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "dateModified": {
+ "name": "dateModified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "imageUrl": {
+ "name": "imageUrl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "favicon": {
+ "name": "favicon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "htmlContent": {
+ "name": "htmlContent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "contentAssetId": {
+ "name": "contentAssetId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerViewStatus": {
+ "name": "readerViewStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerViewScore": {
+ "name": "readerViewScore",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerViewReasons": {
+ "name": "readerViewReasons",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerViewClassifierVersion": {
+ "name": "readerViewClassifierVersion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "crawledAt": {
+ "name": "crawledAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "crawlStatus": {
+ "name": "crawlStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "crawlStatusCode": {
+ "name": "crawlStatusCode",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 200
+ },
+ "probeMetadataAt": {
+ "name": "probeMetadataAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "bookmarkLinks_url_idx": {
+ "name": "bookmarkLinks_url_idx",
+ "columns": [
+ "url"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "bookmarkLinks_id_bookmarks_id_fk": {
+ "name": "bookmarkLinks_id_bookmarks_id_fk",
+ "tableFrom": "bookmarkLinks",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarkLists": {
+ "name": "bookmarkLists",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "query": {
+ "name": "query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "rssToken": {
+ "name": "rssToken",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "public": {
+ "name": "public",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "bookmarkLists_userId_idx": {
+ "name": "bookmarkLists_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "bookmarkLists_userId_id_idx": {
+ "name": "bookmarkLists_userId_id_idx",
+ "columns": [
+ "userId",
+ "id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "bookmarkLists_userId_user_id_fk": {
+ "name": "bookmarkLists_userId_user_id_fk",
+ "tableFrom": "bookmarkLists",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bookmarkLists_parentId_bookmarkLists_id_fk": {
+ "name": "bookmarkLists_parentId_bookmarkLists_id_fk",
+ "tableFrom": "bookmarkLists",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarkTags": {
+ "name": "bookmarkTags",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "normalizedName": {
+ "name": "normalizedName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "generated": {
+ "as": "(lower(replace(replace(replace(\"name\", ' ', ''), '-', ''), '_', '')))",
+ "type": "virtual"
+ }
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "bookmarkTags_name_idx": {
+ "name": "bookmarkTags_name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": false
+ },
+ "bookmarkTags_normalizedName_idx": {
+ "name": "bookmarkTags_normalizedName_idx",
+ "columns": [
+ "normalizedName"
+ ],
+ "isUnique": false
+ },
+ "bookmarkTags_userId_name_unique": {
+ "name": "bookmarkTags_userId_name_unique",
+ "columns": [
+ "userId",
+ "name"
+ ],
+ "isUnique": true
+ },
+ "bookmarkTags_userId_id_idx": {
+ "name": "bookmarkTags_userId_id_idx",
+ "columns": [
+ "userId",
+ "id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "bookmarkTags_userId_user_id_fk": {
+ "name": "bookmarkTags_userId_user_id_fk",
+ "tableFrom": "bookmarkTags",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarkTexts": {
+ "name": "bookmarkTexts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "sourceUrl": {
+ "name": "sourceUrl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bookmarkTexts_id_bookmarks_id_fk": {
+ "name": "bookmarkTexts_id_bookmarks_id_fk",
+ "tableFrom": "bookmarkTexts",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarks": {
+ "name": "bookmarks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "lastSavedAt": {
+ "name": "lastSavedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "archived": {
+ "name": "archived",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "favourited": {
+ "name": "favourited",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "taggingStatus": {
+ "name": "taggingStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "summarizationStatus": {
+ "name": "summarizationStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "embeddingStatus": {
+ "name": "embeddingStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "bookmarks_lastSavedAt_idx": {
+ "name": "bookmarks_lastSavedAt_idx",
+ "columns": [
+ "lastSavedAt"
+ ],
+ "isUnique": false
+ },
+ "bookmarks_userId_lastSavedAt_id_idx": {
+ "name": "bookmarks_userId_lastSavedAt_id_idx",
+ "columns": [
+ "userId",
+ "lastSavedAt",
+ "id"
+ ],
+ "isUnique": false
+ },
+ "bookmarks_userId_archived_lastSavedAt_id_idx": {
+ "name": "bookmarks_userId_archived_lastSavedAt_id_idx",
+ "columns": [
+ "userId",
+ "archived",
+ "lastSavedAt",
+ "id"
+ ],
+ "isUnique": false
+ },
+ "bookmarks_userId_favourited_lastSavedAt_id_idx": {
+ "name": "bookmarks_userId_favourited_lastSavedAt_id_idx",
+ "columns": [
+ "userId",
+ "favourited",
+ "lastSavedAt",
+ "id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "bookmarks_userId_user_id_fk": {
+ "name": "bookmarks_userId_user_id_fk",
+ "tableFrom": "bookmarks",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "bookmarksInLists": {
+ "name": "bookmarksInLists",
+ "columns": {
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "listId": {
+ "name": "listId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "addedAt": {
+ "name": "addedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "listMembershipId": {
+ "name": "listMembershipId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "bookmarksInLists_listId_bookmarkId_idx": {
+ "name": "bookmarksInLists_listId_bookmarkId_idx",
+ "columns": [
+ "listId",
+ "bookmarkId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "bookmarksInLists_bookmarkId_bookmarks_id_fk": {
+ "name": "bookmarksInLists_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "bookmarksInLists",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bookmarksInLists_listId_bookmarkLists_id_fk": {
+ "name": "bookmarksInLists_listId_bookmarkLists_id_fk",
+ "tableFrom": "bookmarksInLists",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "listId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bookmarksInLists_listMembershipId_listCollaborators_id_fk": {
+ "name": "bookmarksInLists_listMembershipId_listCollaborators_id_fk",
+ "tableFrom": "bookmarksInLists",
+ "tableTo": "listCollaborators",
+ "columnsFrom": [
+ "listMembershipId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "bookmarksInLists_bookmarkId_listId_pk": {
+ "columns": [
+ "bookmarkId",
+ "listId"
+ ],
+ "name": "bookmarksInLists_bookmarkId_listId_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "chatMessages": {
+ "name": "chatMessages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "chatId": {
+ "name": "chatId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "chatMessages_chatId_idx": {
+ "name": "chatMessages_chatId_idx",
+ "columns": [
+ "chatId"
+ ],
+ "isUnique": false
+ },
+ "chatMessages_chatId_createdAt_idx": {
+ "name": "chatMessages_chatId_createdAt_idx",
+ "columns": [
+ "chatId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "chatMessages_chatId_chatSessions_id_fk": {
+ "name": "chatMessages_chatId_chatSessions_id_fk",
+ "tableFrom": "chatMessages",
+ "tableTo": "chatSessions",
+ "columnsFrom": [
+ "chatId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "chatSessions": {
+ "name": "chatSessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "chatSessions_userId_idx": {
+ "name": "chatSessions_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "chatSessions_userId_modifiedAt_idx": {
+ "name": "chatSessions_userId_modifiedAt_idx",
+ "columns": [
+ "userId",
+ "modifiedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "chatSessions_userId_user_id_fk": {
+ "name": "chatSessions_userId_user_id_fk",
+ "tableFrom": "chatSessions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "config": {
+ "name": "config",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "customPrompts": {
+ "name": "customPrompts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appliesTo": {
+ "name": "appliesTo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "customPrompts_userId_idx": {
+ "name": "customPrompts_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "customPrompts_userId_user_id_fk": {
+ "name": "customPrompts_userId_user_id_fk",
+ "tableFrom": "customPrompts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "highlights": {
+ "name": "highlights",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "startOffset": {
+ "name": "startOffset",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "endOffset": {
+ "name": "endOffset",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'yellow'"
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "highlights_bookmarkId_idx": {
+ "name": "highlights_bookmarkId_idx",
+ "columns": [
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "highlights_userId_idx": {
+ "name": "highlights_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "highlights_bookmarkId_bookmarks_id_fk": {
+ "name": "highlights_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "highlights",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "highlights_userId_user_id_fk": {
+ "name": "highlights_userId_user_id_fk",
+ "tableFrom": "highlights",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "importSessionBookmarks": {
+ "name": "importSessionBookmarks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "importSessionId": {
+ "name": "importSessionId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "importSessionBookmarks_bookmarkId_idx": {
+ "name": "importSessionBookmarks_bookmarkId_idx",
+ "columns": [
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "importSessionBookmarks_importSessionId_bookmarkId_unique": {
+ "name": "importSessionBookmarks_importSessionId_bookmarkId_unique",
+ "columns": [
+ "importSessionId",
+ "bookmarkId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "importSessionBookmarks_importSessionId_importSessions_id_fk": {
+ "name": "importSessionBookmarks_importSessionId_importSessions_id_fk",
+ "tableFrom": "importSessionBookmarks",
+ "tableTo": "importSessions",
+ "columnsFrom": [
+ "importSessionId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "importSessionBookmarks_bookmarkId_bookmarks_id_fk": {
+ "name": "importSessionBookmarks_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "importSessionBookmarks",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "importSessions": {
+ "name": "importSessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "rootListId": {
+ "name": "rootListId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'staging'"
+ },
+ "lastProcessedAt": {
+ "name": "lastProcessedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "completedAt": {
+ "name": "completedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "totalBookmarks": {
+ "name": "totalBookmarks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "completedBookmarks": {
+ "name": "completedBookmarks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "failedBookmarks": {
+ "name": "failedBookmarks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "pendingBookmarks": {
+ "name": "pendingBookmarks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "processingBookmarks": {
+ "name": "processingBookmarks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "importSessions_userId_idx": {
+ "name": "importSessions_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "importSessions_status_idx": {
+ "name": "importSessions_status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ },
+ "importSessions_status_completedAt_idx": {
+ "name": "importSessions_status_completedAt_idx",
+ "columns": [
+ "status",
+ "completedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "importSessions_userId_user_id_fk": {
+ "name": "importSessions_userId_user_id_fk",
+ "tableFrom": "importSessions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "importSessions_rootListId_bookmarkLists_id_fk": {
+ "name": "importSessions_rootListId_bookmarkLists_id_fk",
+ "tableFrom": "importSessions",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "rootListId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "importStagingBookmarks": {
+ "name": "importStagingBookmarks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "importSessionId": {
+ "name": "importSessionId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "listIds": {
+ "name": "listIds",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "sourceAddedAt": {
+ "name": "sourceAddedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "archived": {
+ "name": "archived",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "processingStartedAt": {
+ "name": "processingStartedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resultReason": {
+ "name": "resultReason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resultBookmarkId": {
+ "name": "resultBookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "completedAt": {
+ "name": "completedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "importStaging_session_status_idx": {
+ "name": "importStaging_session_status_idx",
+ "columns": [
+ "importSessionId",
+ "status"
+ ],
+ "isUnique": false
+ },
+ "importStaging_completedAt_idx": {
+ "name": "importStaging_completedAt_idx",
+ "columns": [
+ "completedAt"
+ ],
+ "isUnique": false
+ },
+ "importStaging_resultBookmarkId_idx": {
+ "name": "importStaging_resultBookmarkId_idx",
+ "columns": [
+ "resultBookmarkId"
+ ],
+ "isUnique": false
+ },
+ "importStaging_status_idx": {
+ "name": "importStaging_status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ },
+ "importStaging_status_processingStartedAt_idx": {
+ "name": "importStaging_status_processingStartedAt_idx",
+ "columns": [
+ "status",
+ "processingStartedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "importStagingBookmarks_importSessionId_importSessions_id_fk": {
+ "name": "importStagingBookmarks_importSessionId_importSessions_id_fk",
+ "tableFrom": "importStagingBookmarks",
+ "tableTo": "importSessions",
+ "columnsFrom": [
+ "importSessionId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "importStagingBookmarks_resultBookmarkId_bookmarks_id_fk": {
+ "name": "importStagingBookmarks_resultBookmarkId_bookmarks_id_fk",
+ "tableFrom": "importStagingBookmarks",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "resultBookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "invites": {
+ "name": "invites",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "usedAt": {
+ "name": "usedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "invitedBy": {
+ "name": "invitedBy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "invites_token_unique": {
+ "name": "invites_token_unique",
+ "columns": [
+ "token"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "invites_invitedBy_user_id_fk": {
+ "name": "invites_invitedBy_user_id_fk",
+ "tableFrom": "invites",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invitedBy"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "listCollaborators": {
+ "name": "listCollaborators",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "listId": {
+ "name": "listId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "addedBy": {
+ "name": "addedBy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "listCollaborators_listId_idx": {
+ "name": "listCollaborators_listId_idx",
+ "columns": [
+ "listId"
+ ],
+ "isUnique": false
+ },
+ "listCollaborators_userId_idx": {
+ "name": "listCollaborators_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "listCollaborators_listId_userId_unique": {
+ "name": "listCollaborators_listId_userId_unique",
+ "columns": [
+ "listId",
+ "userId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "listCollaborators_listId_bookmarkLists_id_fk": {
+ "name": "listCollaborators_listId_bookmarkLists_id_fk",
+ "tableFrom": "listCollaborators",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "listId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "listCollaborators_userId_user_id_fk": {
+ "name": "listCollaborators_userId_user_id_fk",
+ "tableFrom": "listCollaborators",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "listCollaborators_addedBy_user_id_fk": {
+ "name": "listCollaborators_addedBy_user_id_fk",
+ "tableFrom": "listCollaborators",
+ "tableTo": "user",
+ "columnsFrom": [
+ "addedBy"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "listInvitations": {
+ "name": "listInvitations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "listId": {
+ "name": "listId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "invitedAt": {
+ "name": "invitedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "invitedEmail": {
+ "name": "invitedEmail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "invitedBy": {
+ "name": "invitedBy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "listInvitations_listId_idx": {
+ "name": "listInvitations_listId_idx",
+ "columns": [
+ "listId"
+ ],
+ "isUnique": false
+ },
+ "listInvitations_userId_idx": {
+ "name": "listInvitations_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "listInvitations_status_idx": {
+ "name": "listInvitations_status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ },
+ "listInvitations_listId_userId_unique": {
+ "name": "listInvitations_listId_userId_unique",
+ "columns": [
+ "listId",
+ "userId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "listInvitations_listId_bookmarkLists_id_fk": {
+ "name": "listInvitations_listId_bookmarkLists_id_fk",
+ "tableFrom": "listInvitations",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "listId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "listInvitations_userId_user_id_fk": {
+ "name": "listInvitations_userId_user_id_fk",
+ "tableFrom": "listInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "listInvitations_invitedBy_user_id_fk": {
+ "name": "listInvitations_invitedBy_user_id_fk",
+ "tableFrom": "listInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invitedBy"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "passwordResetToken": {
+ "name": "passwordResetToken",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "passwordResetToken_token_unique": {
+ "name": "passwordResetToken_token_unique",
+ "columns": [
+ "token"
+ ],
+ "isUnique": true
+ },
+ "passwordResetTokens_userId_idx": {
+ "name": "passwordResetTokens_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "passwordResetToken_userId_user_id_fk": {
+ "name": "passwordResetToken_userId_user_id_fk",
+ "tableFrom": "passwordResetToken",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rssFeedImports": {
+ "name": "rssFeedImports",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entryId": {
+ "name": "entryId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "rssFeedId": {
+ "name": "rssFeedId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "rssFeedImports_feedIdIdx_idx": {
+ "name": "rssFeedImports_feedIdIdx_idx",
+ "columns": [
+ "rssFeedId"
+ ],
+ "isUnique": false
+ },
+ "rssFeedImports_entryIdIdx_idx": {
+ "name": "rssFeedImports_entryIdIdx_idx",
+ "columns": [
+ "entryId"
+ ],
+ "isUnique": false
+ },
+ "rssFeedImports_bookmarkId_idx": {
+ "name": "rssFeedImports_bookmarkId_idx",
+ "columns": [
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "rssFeedImports_rssFeedId_bookmarkId_idx": {
+ "name": "rssFeedImports_rssFeedId_bookmarkId_idx",
+ "columns": [
+ "rssFeedId",
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "rssFeedImports_rssFeedId_entryId_unique": {
+ "name": "rssFeedImports_rssFeedId_entryId_unique",
+ "columns": [
+ "rssFeedId",
+ "entryId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "rssFeedImports_rssFeedId_rssFeeds_id_fk": {
+ "name": "rssFeedImports_rssFeedId_rssFeeds_id_fk",
+ "tableFrom": "rssFeedImports",
+ "tableTo": "rssFeeds",
+ "columnsFrom": [
+ "rssFeedId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rssFeedImports_bookmarkId_bookmarks_id_fk": {
+ "name": "rssFeedImports_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "rssFeedImports",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rssFeeds": {
+ "name": "rssFeeds",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "importTags": {
+ "name": "importTags",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "lastFetchedAt": {
+ "name": "lastFetchedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastSuccessfulFetchAt": {
+ "name": "lastSuccessfulFetchAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastFetchedStatus": {
+ "name": "lastFetchedStatus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "rssFeeds_userId_idx": {
+ "name": "rssFeeds_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "rssFeeds_userId_user_id_fk": {
+ "name": "rssFeeds_userId_user_id_fk",
+ "tableFrom": "rssFeeds",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ruleEngineActions": {
+ "name": "ruleEngineActions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ruleId": {
+ "name": "ruleId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "listId": {
+ "name": "listId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "tagId": {
+ "name": "tagId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ruleEngineActions_userId_idx": {
+ "name": "ruleEngineActions_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "ruleEngineActions_ruleId_idx": {
+ "name": "ruleEngineActions_ruleId_idx",
+ "columns": [
+ "ruleId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ruleEngineActions_userId_user_id_fk": {
+ "name": "ruleEngineActions_userId_user_id_fk",
+ "tableFrom": "ruleEngineActions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ruleEngineActions_ruleId_ruleEngineRules_id_fk": {
+ "name": "ruleEngineActions_ruleId_ruleEngineRules_id_fk",
+ "tableFrom": "ruleEngineActions",
+ "tableTo": "ruleEngineRules",
+ "columnsFrom": [
+ "ruleId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ruleEngineActions_userId_tagId_fk": {
+ "name": "ruleEngineActions_userId_tagId_fk",
+ "tableFrom": "ruleEngineActions",
+ "tableTo": "bookmarkTags",
+ "columnsFrom": [
+ "userId",
+ "tagId"
+ ],
+ "columnsTo": [
+ "userId",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ruleEngineActions_userId_listId_fk": {
+ "name": "ruleEngineActions_userId_listId_fk",
+ "tableFrom": "ruleEngineActions",
+ "tableTo": "bookmarkLists",
+ "columnsFrom": [
+ "userId",
+ "listId"
+ ],
+ "columnsTo": [
+ "userId",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ruleEngineRules": {
+ "name": "ruleEngineRules",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "event": {
+ "name": "event",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "condition": {
+ "name": "condition",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tagId": {
+ "name": "tagId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ruleEngine_userId_idx": {
+ "name": "ruleEngine_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ruleEngineRules_userId_user_id_fk": {
+ "name": "ruleEngineRules_userId_user_id_fk",
+ "tableFrom": "ruleEngineRules",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ruleEngineRules_userId_tagId_fk": {
+ "name": "ruleEngineRules_userId_tagId_fk",
+ "tableFrom": "ruleEngineRules",
+ "tableTo": "bookmarkTags",
+ "columnsFrom": [
+ "userId",
+ "tagId"
+ ],
+ "columnsTo": [
+ "userId",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "subscriptions": {
+ "name": "subscriptions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "stripeCustomerId": {
+ "name": "stripeCustomerId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "stripeSubscriptionId": {
+ "name": "stripeSubscriptionId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tier": {
+ "name": "tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'free'"
+ },
+ "priceId": {
+ "name": "priceId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cancelAtPeriodEnd": {
+ "name": "cancelAtPeriodEnd",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "startDate": {
+ "name": "startDate",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "endDate": {
+ "name": "endDate",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "subscriptions_userId_unique": {
+ "name": "subscriptions_userId_unique",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": true
+ },
+ "subscriptions_userId_idx": {
+ "name": "subscriptions_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "subscriptions_stripeCustomerId_idx": {
+ "name": "subscriptions_stripeCustomerId_idx",
+ "columns": [
+ "stripeCustomerId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "subscriptions_userId_user_id_fk": {
+ "name": "subscriptions_userId_user_id_fk",
+ "tableFrom": "subscriptions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tagsOnBookmarks": {
+ "name": "tagsOnBookmarks",
+ "columns": {
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tagId": {
+ "name": "tagId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "attachedAt": {
+ "name": "attachedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "attachedBy": {
+ "name": "attachedBy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "tagsOnBookmarks_tagId_bookmarkId_idx": {
+ "name": "tagsOnBookmarks_tagId_bookmarkId_idx",
+ "columns": [
+ "tagId",
+ "bookmarkId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "tagsOnBookmarks_bookmarkId_bookmarks_id_fk": {
+ "name": "tagsOnBookmarks_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "tagsOnBookmarks",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "tagsOnBookmarks_tagId_bookmarkTags_id_fk": {
+ "name": "tagsOnBookmarks_tagId_bookmarkTags_id_fk",
+ "tableFrom": "tagsOnBookmarks",
+ "tableTo": "bookmarkTags",
+ "columnsFrom": [
+ "tagId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "tagsOnBookmarks_bookmarkId_tagId_pk": {
+ "columns": [
+ "bookmarkId",
+ "tagId"
+ ],
+ "name": "tagsOnBookmarks_bookmarkId_tagId_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "userReadingProgress": {
+ "name": "userReadingProgress",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bookmarkId": {
+ "name": "bookmarkId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "readingProgressOffset": {
+ "name": "readingProgressOffset",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "readingProgressAnchor": {
+ "name": "readingProgressAnchor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readingProgressPercent": {
+ "name": "readingProgressPercent",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "userReadingProgress_bookmarkId_idx": {
+ "name": "userReadingProgress_bookmarkId_idx",
+ "columns": [
+ "bookmarkId"
+ ],
+ "isUnique": false
+ },
+ "userReadingProgress_userId_idx": {
+ "name": "userReadingProgress_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "userReadingProgress_bookmarkId_userId_unique": {
+ "name": "userReadingProgress_bookmarkId_userId_unique",
+ "columns": [
+ "bookmarkId",
+ "userId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "userReadingProgress_bookmarkId_bookmarks_id_fk": {
+ "name": "userReadingProgress_bookmarkId_bookmarks_id_fk",
+ "tableFrom": "userReadingProgress",
+ "tableTo": "bookmarks",
+ "columnsFrom": [
+ "bookmarkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "userReadingProgress_userId_user_id_fk": {
+ "name": "userReadingProgress_userId_user_id_fk",
+ "tableFrom": "userReadingProgress",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "salt": {
+ "name": "salt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'user'"
+ },
+ "bookmarkQuota": {
+ "name": "bookmarkQuota",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "browserCrawlingEnabled": {
+ "name": "browserCrawlingEnabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "manualTierName": {
+ "name": "manualTierName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "bookmarkClickAction": {
+ "name": "bookmarkClickAction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'open_original_link'"
+ },
+ "archiveDisplayBehaviour": {
+ "name": "archiveDisplayBehaviour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'show'"
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'UTC'"
+ },
+ "backupsEnabled": {
+ "name": "backupsEnabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "backupsFrequency": {
+ "name": "backupsFrequency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'weekly'"
+ },
+ "backupsRetentionDays": {
+ "name": "backupsRetentionDays",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 30
+ },
+ "readerFontSize": {
+ "name": "readerFontSize",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerLineHeight": {
+ "name": "readerLineHeight",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readerFontFamily": {
+ "name": "readerFontFamily",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "autoTaggingEnabled": {
+ "name": "autoTaggingEnabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "autoSummarizationEnabled": {
+ "name": "autoSummarizationEnabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "tagStyle": {
+ "name": "tagStyle",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'titlecase-spaces'"
+ },
+ "curatedTagIds": {
+ "name": "curatedTagIds",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "inferredTagLang": {
+ "name": "inferredTagLang",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "verificationToken": {
+ "name": "verificationToken",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "columns": [
+ "identifier",
+ "token"
+ ],
+ "name": "verificationToken_identifier_token_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "webhooks": {
+ "name": "webhooks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "events": {
+ "name": "events",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "webhooks_userId_idx": {
+ "name": "webhooks_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "webhooks_userId_user_id_fk": {
+ "name": "webhooks_userId_user_id_fk",
+ "tableFrom": "webhooks",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index f239840f..af46eb98 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -652,6 +652,13 @@
"when": 1785067924780,
"tag": "0092_add_last_saved_at",
"breakpoints": true
+ },
+ {
+ "idx": 93,
+ "version": "6",
+ "when": 1785586065846,
+ "tag": "0093_reader_view_assessment",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/schema.ts b/packages/db/schema.ts
index 54920134..9a304e1f 100644
--- a/packages/db/schema.ts
+++ b/packages/db/schema.ts
@@ -16,6 +16,7 @@ import {
import type { ZApiKeyScope } from "@karakeep/shared/types/apiKeys";
import { API_KEY_FULL_ACCESS_SCOPE } from "@karakeep/shared/types/apiKeys";
import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";
+import type { ZReaderViewReason } from "@karakeep/shared/types/bookmarks";
function createdAtField(colName = "createdAt") {
return integer(colName, { mode: "timestamp" })
@@ -298,6 +299,14 @@ export const bookmarkLinks = sqliteTable(
favicon: text("favicon"),
htmlContent: text("htmlContent"),
contentAssetId: text("contentAssetId"),
+ readerViewStatus: text("readerViewStatus", {
+ enum: ["readable", "not_readable", "uncertain", "unavailable"],
+ }),
+ readerViewScore: integer("readerViewScore"),
+ readerViewReasons: text("readerViewReasons", { mode: "json" }).$type<
+ ZReaderViewReason[]
+ >(),
+ readerViewClassifierVersion: integer("readerViewClassifierVersion"),
crawledAt: integer("crawledAt", { mode: "timestamp" }),
crawlStatus: text("crawlStatus", {
enum: ["pending", "failure", "success"],
diff --git a/packages/open-api/karakeep-openapi-spec.json b/packages/open-api/karakeep-openapi-spec.json
index 53dffe1b..66232820 100644
--- a/packages/open-api/karakeep-openapi-spec.json
+++ b/packages/open-api/karakeep-openapi-spec.json
@@ -291,6 +291,33 @@
"type": "string",
"nullable": true
},
+ "readerViewStatus": {
+ "type": "string",
+ "nullable": true,
+ "enum": [
+ "readable",
+ "not_readable",
+ "uncertain",
+ "unavailable",
+ null
+ ]
+ },
+ "readerViewScore": {
+ "type": "integer",
+ "nullable": true,
+ "minimum": 0,
+ "maximum": 100
+ },
+ "preferredPreview": {
+ "type": "string",
+ "nullable": true,
+ "enum": [
+ "reader_view",
+ "screenshot",
+ "overview",
+ null
+ ]
+ },
"crawledAt": {
"type": "string",
"nullable": true,
diff --git a/packages/shared/types/bookmarks.ts b/packages/shared/types/bookmarks.ts
index 4fe462e8..e8e85b2a 100644
--- a/packages/shared/types/bookmarks.ts
+++ b/packages/shared/types/bookmarks.ts
@@ -47,6 +47,51 @@ export type ZBookmarkReadableContent = z.infer<
typeof zBookmarkReadableContentSchema
>;
+export const zReaderViewStatusSchema = z.enum([
+ "readable",
+ "not_readable",
+ "uncertain",
+ "unavailable",
+]);
+export type ZReaderViewStatus = z.infer<typeof zReaderViewStatusSchema>;
+
+export const zReaderViewReasonSchema = z.enum([
+ "article_metadata",
+ "non_article_metadata",
+ "article_element",
+ "very_short_content",
+ "short_content",
+ "substantial_content_length",
+ "useful_content_length",
+ "no_substantive_blocks",
+ "single_substantive_block",
+ "multiple_substantive_blocks",
+ "some_substantive_blocks",
+ "long_preformatted_content",
+ "very_high_link_density",
+ "high_link_density",
+ "elevated_link_density",
+ "low_link_density",
+ "control_heavy_page",
+ "link_collection",
+ "search_url",
+ "root_page",
+ "challenge_page",
+ "sentence_like_text",
+ "low_sentence_density",
+ "probably_readerable",
+ "probably_not_readerable",
+ "no_extracted_content",
+]);
+export type ZReaderViewReason = z.infer<typeof zReaderViewReasonSchema>;
+
+export const zPreferredLinkPreviewSchema = z.enum([
+ "reader_view",
+ "screenshot",
+ "overview",
+]);
+export type ZPreferredLinkPreview = z.infer<typeof zPreferredLinkPreviewSchema>;
+
export const zSortOrder = z.enum(["asc", "desc", "relevance"]);
export type ZSortOrder = z.infer<typeof zSortOrder>;
@@ -87,6 +132,9 @@ export const zBookmarkedLinkSchema = z.object({
favicon: z.string().nullish(),
htmlContent: z.string().nullish(),
contentAssetId: z.string().nullish(),
+ readerViewStatus: zReaderViewStatusSchema.nullish(),
+ readerViewScore: z.number().int().min(0).max(100).nullish(),
+ preferredPreview: zPreferredLinkPreviewSchema.nullish(),
crawledAt: z.date().nullish(),
crawlStatus: z.enum(["success", "failure", "pending"]).nullish(),
author: z.string().nullish(),
diff --git a/packages/trpc/lib/linkPreview.ts b/packages/trpc/lib/linkPreview.ts
new file mode 100644
index 00000000..0c931427
--- /dev/null
+++ b/packages/trpc/lib/linkPreview.ts
@@ -0,0 +1,39 @@
+import type {
+ ZPreferredLinkPreview,
+ ZReaderViewReason,
+ ZReaderViewStatus,
+} from "@karakeep/shared/types/bookmarks";
+
+interface LinkPreviewSignals {
+ readerViewStatus: ZReaderViewStatus | null;
+ readerViewReasons: ZReaderViewReason[] | null;
+ crawlStatusCode: number | null;
+ hasScreenshot: boolean;
+}
+
+export function getPreferredLinkPreview({
+ readerViewStatus,
+ readerViewReasons,
+ crawlStatusCode,
+ hasScreenshot,
+}: LinkPreviewSignals): ZPreferredLinkPreview {
+ const capturedChallengePage =
+ readerViewReasons?.includes("challenge_page") ?? false;
+ if (capturedChallengePage) {
+ return "overview";
+ }
+
+ if (!readerViewStatus || readerViewStatus === "readable") {
+ return "reader_view";
+ }
+
+ const crawlSucceeded =
+ crawlStatusCode === null ||
+ (crawlStatusCode >= 200 && crawlStatusCode <= 299);
+
+ if (hasScreenshot && crawlSucceeded) {
+ return "screenshot";
+ }
+
+ return "overview";
+}
diff --git a/packages/trpc/models/bookmarks.ts b/packages/trpc/models/bookmarks.ts
index b209faa8..13fed6d0 100644
--- a/packages/trpc/models/bookmarks.ts
+++ b/packages/trpc/models/bookmarks.ts
@@ -59,6 +59,7 @@ import { htmlToPlainText } from "@karakeep/shared/utils/htmlUtils";
import { AuthedContext } from "..";
import { mapDBAssetTypeToUserType } from "../lib/attachments";
+import { getPreferredLinkPreview } from "../lib/linkPreview";
import { Asset } from "./assets";
import { List } from "./lists";
@@ -195,6 +196,16 @@ export class Bookmark extends BareBookmark {
htmlContent: includeContent
? await Bookmark.getBookmarkHtmlContent(link, bookmark.userId)
: null,
+ readerViewStatus: link.readerViewStatus,
+ readerViewScore: link.readerViewScore,
+ preferredPreview: getPreferredLinkPreview({
+ readerViewStatus: link.readerViewStatus,
+ readerViewReasons: link.readerViewReasons,
+ crawlStatusCode: link.crawlStatusCode,
+ hasScreenshot: assets.some(
+ (asset) => asset.assetType === AssetTypes.LINK_SCREENSHOT,
+ ),
+ }),
crawledAt: link.crawledAt,
crawlStatus: link.crawlStatus,
author: link.author,
@@ -606,6 +617,15 @@ export class Bookmark extends BareBookmark {
: row.bookmarkLinks.htmlContent
: null,
contentAssetId: row.bookmarkLinks.contentAssetId,
+ readerViewStatus: row.bookmarkLinks.readerViewStatus,
+ readerViewScore: row.bookmarkLinks.readerViewScore,
+ preferredPreview: getPreferredLinkPreview({
+ readerViewStatus: row.bookmarkLinks.readerViewStatus,
+ readerViewReasons: row.bookmarkLinks.readerViewReasons,
+ crawlStatusCode: row.bookmarkLinks.crawlStatusCode,
+ hasScreenshot:
+ row.assets?.assetType === AssetTypes.LINK_SCREENSHOT,
+ }),
crawlStatus: row.bookmarkLinks.crawlStatus,
crawledAt: row.bookmarkLinks.crawledAt,
author: row.bookmarkLinks.author,
@@ -667,8 +687,18 @@ export class Bookmark extends BareBookmark {
if (acc[bookmarkId].content.type == BookmarkTypes.LINK) {
const content = acc[bookmarkId].content;
invariant(content.type == BookmarkTypes.LINK);
+ invariant(
+ row.bookmarkLinks,
+ "a link bookmark must have a corresponding bookmarkLinks row",
+ );
if (row.assets.assetType == AssetTypes.LINK_SCREENSHOT) {
content.screenshotAssetId = row.assets.id;
+ content.preferredPreview = getPreferredLinkPreview({
+ readerViewStatus: row.bookmarkLinks.readerViewStatus,
+ readerViewReasons: row.bookmarkLinks.readerViewReasons,
+ crawlStatusCode: row.bookmarkLinks.crawlStatusCode,
+ hasScreenshot: true,
+ });
}
if (row.assets.assetType == AssetTypes.LINK_PDF) {
content.pdfAssetId = row.assets.id;