A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
feat: add support for resaving already existing bookmarks (#2962)
Mohamed Bassemf2f6431db2da
diff --git a/apps/mobile/app/dashboard/bookmarks/new.tsx b/apps/mobile/app/dashboard/bookmarks/new.tsxindex f7be22e1..076ad4e4 100644--- a/apps/mobile/app/dashboard/bookmarks/new.tsx+++ b/apps/mobile/app/dashboard/bookmarks/new.tsx@@ -22,7 +22,7 @@ const NoteEditorPage = () => {onSuccess: (resp) => {if (resp.alreadyExists) {toast({- message: "Bookmark already exists",+ message: "Bookmark saved again",});}setText("");diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsxindex 82b321d5..ffa52694 100644--- a/apps/mobile/app/sharing.tsx+++ b/apps/mobile/app/sharing.tsx@@ -150,19 +150,17 @@ export default function Sharing() {entering={FadeIn.duration(200)}className="items-center gap-6">- <SuccessAnimation isAlreadyExists={mode.type === "alreadyExists"} />+ <SuccessAnimation /><Animated.Viewentering={FadeIn.delay(400).duration(300)}className="items-center gap-2"><Text variant="title1" className="font-semibold text-foreground">- {mode.type === "alreadyExists" ? "Already Hoarded!" : "Hoarded!"}+ {mode.type === "alreadyExists" ? "Hoarded again!" : "Hoarded!"}</Text><Text variant="body" className="text-muted-foreground">- {mode.type === "alreadyExists"- ? "This item was saved before"- : "Saved to your collection"}+ Saved to your collection</Text></Animated.View>diff --git a/apps/mobile/components/sharing/SuccessAnimation.tsx b/apps/mobile/components/sharing/SuccessAnimation.tsxindex fa0aaf3a..9b20b1a1 100644--- a/apps/mobile/components/sharing/SuccessAnimation.tsx+++ b/apps/mobile/components/sharing/SuccessAnimation.tsx@@ -56,28 +56,16 @@ function Particle({ angle, delay, color }: ParticleProps) {return <Animated.View style={particleStyle} />;}-interface SuccessAnimationProps {- isAlreadyExists: boolean;-}--export default function SuccessAnimation({- isAlreadyExists,-}: SuccessAnimationProps) {+export default function SuccessAnimation() {const checkScale = useSharedValue(0);const checkOpacity = useSharedValue(0);const ringScale = useSharedValue(0.8);const ringOpacity = useSharedValue(0);- const particleColor = isAlreadyExists- ? "rgb(255, 180, 0)"- : "rgb(0, 200, 100)";+ const particleColor = "rgb(0, 200, 100)";useEffect(() => {- Haptics.notificationAsync(- isAlreadyExists- ? Haptics.NotificationFeedbackType.Warning- : Haptics.NotificationFeedbackType.Success,- );+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);ringScale.value = withSequence(withTiming(1.2, { duration: 400, easing: Easing.out(Easing.ease) }),@@ -97,7 +85,7 @@ export default function SuccessAnimation({}),);checkOpacity.value = withDelay(150, withTiming(1, { duration: 200 }));- }, [isAlreadyExists]);+ }, []);const ringStyle = useAnimatedStyle(() => ({transform: [{ scale: ringScale.value }],@@ -122,16 +110,12 @@ export default function SuccessAnimation({<Animated.Viewstyle={ringStyle}- className={`absolute h-28 w-28 rounded-full ${- isAlreadyExists ? "bg-yellow-500/20" : "bg-green-500/20"- }`}+ className="absolute h-28 w-28 rounded-full bg-green-500/20"/><Animated.Viewstyle={checkStyle}- className={`h-24 w-24 items-center justify-center rounded-full ${- isAlreadyExists ? "bg-yellow-500" : "bg-green-500"- }`}+ className="h-24 w-24 items-center justify-center rounded-full bg-green-500"><Check size={48} color="white" strokeWidth={3} /></Animated.View>diff --git a/apps/web/components/dashboard/UploadDropzone.tsx b/apps/web/components/dashboard/UploadDropzone.tsxindex c76da523..006b99b3 100644--- a/apps/web/components/dashboard/UploadDropzone.tsx+++ b/apps/web/components/dashboard/UploadDropzone.tsx@@ -12,14 +12,14 @@ import { useCreateBookmarkWithPostHook } from "@karakeep/shared-react/hooks/bookimport { BookmarkTypes } from "@karakeep/shared/types/bookmarks";import LoadingSpinner from "../ui/spinner";-import BookmarkAlreadyExistsToast from "../utils/BookmarkAlreadyExistsToast";+import BookmarkSavedToast from "../utils/BookmarkSavedToast";export function useUploadAsset() {const { mutateAsync: createBookmark } = useCreateBookmarkWithPostHook({onSuccess: (resp) => {if (resp.alreadyExists) {toast({- description: <BookmarkAlreadyExistsToast bookmarkId={resp.id} />,+ description: <BookmarkSavedToast bookmarkId={resp.id} />,variant: "default",});} else {diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsxindex 4636bcb9..76424a38 100644--- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx+++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx@@ -7,7 +7,7 @@ import MultipleChoiceDialog from "@/components/ui/multiple-choice-dialog";import { Separator } from "@/components/ui/separator";import { toast } from "@/components/ui/sonner";import { Textarea } from "@/components/ui/textarea";-import BookmarkAlreadyExistsToast from "@/components/utils/BookmarkAlreadyExistsToast";+import BookmarkSavedToast from "@/components/utils/BookmarkSavedToast";import { useClientConfig } from "@/lib/clientConfig";import { useTranslation } from "@/lib/i18n/client";import {@@ -58,7 +58,7 @@ export default function EditorCard({ className }: { className?: string }) {onSuccess: (resp) => {if (resp.alreadyExists) {toast({- description: <BookmarkAlreadyExistsToast bookmarkId={resp.id} />,+ description: <BookmarkSavedToast bookmarkId={resp.id} />,variant: "default",});}diff --git a/apps/web/components/utils/BookmarkAlreadyExistsToast.tsx b/apps/web/components/utils/BookmarkSavedToast.tsxsimilarity index 82%rename from apps/web/components/utils/BookmarkAlreadyExistsToast.tsxrename to apps/web/components/utils/BookmarkSavedToast.tsxindex 66bdb17a..e07a094e 100644--- a/apps/web/components/utils/BookmarkAlreadyExistsToast.tsx+++ b/apps/web/components/utils/BookmarkSavedToast.tsx@@ -1,14 +1,14 @@import Link from "next/link";import { ExternalLink } from "lucide-react";-export default function BookmarkAlreadyExistsToast({+export default function BookmarkSavedToast({bookmarkId,}: {bookmarkId: string;}) {return (<div className="flex items-center gap-1">- Bookmark already exists.+ Bookmark saved again.<LinkclassName="flex underline-offset-4 hover:underline"href={`/dashboard/preview/${bookmarkId}`}diff --git a/packages/db/drizzle/0092_add_last_saved_at.sql b/packages/db/drizzle/0092_add_last_saved_at.sqlnew file mode 100644index 00000000..a88f0acb--- /dev/null+++ b/packages/db/drizzle/0092_add_last_saved_at.sql@@ -0,0 +1,10 @@+DROP INDEX `bookmarks_userId_createdAt_id_idx`;--> statement-breakpoint+DROP INDEX `bookmarks_userId_archived_createdAt_id_idx`;--> statement-breakpoint+DROP INDEX `bookmarks_userId_favourited_createdAt_id_idx`;--> statement-breakpoint+DROP INDEX `bookmarks_createdAt_idx`;--> statement-breakpoint+ALTER TABLE `bookmarks` ADD `lastSavedAt` integer NOT NULL DEFAULT 0;--> statement-breakpoint+UPDATE `bookmarks` SET `lastSavedAt` = `createdAt`;--> statement-breakpoint+CREATE INDEX `bookmarks_userId_lastSavedAt_id_idx` ON `bookmarks` (`userId`,`lastSavedAt`,`id`);--> statement-breakpoint+CREATE INDEX `bookmarks_userId_archived_lastSavedAt_id_idx` ON `bookmarks` (`userId`,`archived`,`lastSavedAt`,`id`);--> statement-breakpoint+CREATE INDEX `bookmarks_userId_favourited_lastSavedAt_id_idx` ON `bookmarks` (`userId`,`favourited`,`lastSavedAt`,`id`);--> statement-breakpoint+CREATE INDEX `bookmarks_lastSavedAt_idx` ON `bookmarks` (`lastSavedAt`);diff --git a/packages/db/drizzle/meta/0092_snapshot.json b/packages/db/drizzle/meta/0092_snapshot.jsonnew file mode 100644index 00000000..39d06d81--- /dev/null+++ b/packages/db/drizzle/meta/0092_snapshot.json@@ -0,0 +1,3554 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "e00919aa-5d40-4c7a-b77c-4d6b131f36bf",+ "prevId": "17fb3a4a-6b6d-4ef9-acf4-a679f2732f0f",+ "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+ },+ "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 filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex a6146387..f239840f 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -645,6 +645,13 @@"when": 1784396536240,"tag": "0091_remove_redundant_indicies","breakpoints": true+ },+ {+ "idx": 92,+ "version": "6",+ "when": 1785067924780,+ "tag": "0092_add_last_saved_at",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/schema.ts b/packages/db/schema.tsindex 0be62583..54920134 100644--- a/packages/db/schema.ts+++ b/packages/db/schema.ts@@ -17,8 +17,8 @@ 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";-function createdAtField() {- return integer("createdAt", { mode: "timestamp" })+function createdAtField(colName = "createdAt") {+ return integer(colName, { mode: "timestamp" }).notNull().$defaultFn(() => new Date());}@@ -208,7 +208,16 @@ export const bookmarks = sqliteTable(.notNull().primaryKey().$defaultFn(() => createId()),- createdAt: createdAtField(),+ // The `createdAt` field and the `createdAt` column intentionally don't+ // match. Re-saving an existing bookmark bumps it back to the top of the+ // list, so the timestamp everything sorts and filters on is now "when was+ // this last saved" and lives in the `lastSavedAt` column. It keeps the+ // `createdAt` field name because that's what the API has always exposed and+ // what every query already orders by. The immutable "when did this row+ // first appear" timestamp stays in the original `createdAt` column, and is+ // exposed to clients as `firstCreatedAt`.+ dbCreatedAt: createdAtField(),+ createdAt: createdAtField("lastSavedAt"),modifiedAt: modifiedAtField(),title: text("title"),archived: integer("archived", { mode: "boolean" }).notNull().default(false),@@ -246,16 +255,20 @@ export const bookmarks = sqliteTable(}),},(b) => [- index("bookmarks_createdAt_idx").on(b.createdAt),+ index("bookmarks_lastSavedAt_idx").on(b.createdAt),// Composite indexes for optimized pagination queries- index("bookmarks_userId_createdAt_id_idx").on(b.userId, b.createdAt, b.id),- index("bookmarks_userId_archived_createdAt_id_idx").on(+ index("bookmarks_userId_lastSavedAt_id_idx").on(+ b.userId,+ b.createdAt,+ b.id,+ ),+ index("bookmarks_userId_archived_lastSavedAt_id_idx").on(b.userId,b.archived,b.createdAt,b.id,),- index("bookmarks_userId_favourited_createdAt_id_idx").on(+ index("bookmarks_userId_favourited_lastSavedAt_id_idx").on(b.userId,b.favourited,b.createdAt,diff --git a/packages/open-api/karakeep-openapi-spec.json b/packages/open-api/karakeep-openapi-spec.jsonindex acfc9b4b..53dffe1b 100644--- a/packages/open-api/karakeep-openapi-spec.json+++ b/packages/open-api/karakeep-openapi-spec.json@@ -124,6 +124,10 @@"id": {"type": "string"},+ "firstCreatedAt": {+ "type": "string",+ "format": "date-time"+ },"createdAt": {"type": "string","format": "date-time"@@ -1560,6 +1564,10 @@"id": {"type": "string"},+ "firstCreatedAt": {+ "type": "string",+ "format": "date-time"+ },"createdAt": {"type": "string","format": "date-time"@@ -1814,6 +1822,10 @@"id": {"type": "string"},+ "firstCreatedAt": {+ "type": "string",+ "format": "date-time"+ },"createdAt": {"type": "string","format": "date-time"diff --git a/packages/shared/import-export/exporters.ts b/packages/shared/import-export/exporters.tsindex 3962c1fd..f121157a 100644--- a/packages/shared/import-export/exporters.ts+++ b/packages/shared/import-export/exporters.ts@@ -64,6 +64,8 @@ export function toExportFormat(// Exclude asset types for now}return {+ // Deliberately the last saved date rather than `firstCreatedAt`, so that+ // re-importing an export preserves the ordering the user sees in the app.createdAt: Math.floor(bookmark.createdAt.getTime() / 1000),title:bookmark.title ??diff --git a/packages/shared/types/bookmarks.ts b/packages/shared/types/bookmarks.tsindex 215d49b0..4fe462e8 100644--- a/packages/shared/types/bookmarks.ts+++ b/packages/shared/types/bookmarks.ts@@ -136,6 +136,8 @@ export type ZBookmarkSource = z.infer<typeof zBookmarkSourceSchema>;export const zBareBookmarkSchema = z.object({id: z.string(),+ // This is optional for backwards compatibility+ firstCreatedAt: z.date().optional(),createdAt: z.date(),modifiedAt: z.date().nullable(),title: z.string().nullish(),diff --git a/packages/trpc/models/bookmarks.ts b/packages/trpc/models/bookmarks.tsindex 797910dd..b209faa8 100644--- a/packages/trpc/models/bookmarks.ts+++ b/packages/trpc/models/bookmarks.ts@@ -238,6 +238,7 @@ export class Bookmark extends BareBookmark {assetType: mapDBAssetTypeToUserType(a.assetType),fileName: a.fileName,})),+ firstCreatedAt: bookmark.dbCreatedAt,...rest,};}@@ -394,6 +395,7 @@ export class Bookmark extends BareBookmark {id: bookmark.id,type: bookmark.type,source: bookmark.source,+ firstCreatedAt: bookmark.dbCreatedAt,createdAt: bookmark.createdAt,modifiedAt: bookmark.modifiedAt,title: bookmark.title,@@ -554,7 +556,7 @@ export class Bookmark extends BareBookmark {);} else {// PATH: No list/tag/rssFeed filter - query bookmarks directly- // Uses composite index: bookmarks_userId_createdAt_id_idx (or archived/favourited variants)+ // Uses composite index: bookmarks_userId_lastSavedAt_id_idx (or archived/favourited variants)sq = ctx.db.$with("bookmarksSq").as(ctx.db.select()@@ -636,6 +638,7 @@ export class Bookmark extends BareBookmark {}acc[bookmarkId] = {...row.bookmarksSq,+ firstCreatedAt: row.bookmarksSq.dbCreatedAt,content,tags: [],assets: [],diff --git a/packages/trpc/routers/bookmarks.test.ts b/packages/trpc/routers/bookmarks.test.tsindex f54768d4..04b249fd 100644--- a/packages/trpc/routers/bookmarks.test.ts+++ b/packages/trpc/routers/bookmarks.test.ts@@ -11,8 +11,13 @@ import {import * as sharedServer from "@karakeep/shared-server";import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";+import { WebhooksService } from "../models/webhooks.service";import type { APICallerType, CustomTestContext } from "../testUtils";-import { defaultBeforeEach, getApiKeyCallerForPlainKey } from "../testUtils";+import {+ defaultBeforeEach,+ getApiKeyCallerForPlainKey,+ getTestQueueMocks,+} from "../testUtils";vi.mock("@karakeep/shared-server", async (original) => {const mod = (await original()) as typeof import("@karakeep/shared-server");@@ -807,6 +812,196 @@ describe("Bookmark Routes", () => {expect(bookmark3User1.alreadyExists).toEqual(false);});+ test<CustomTestContext>("re-saving a link restores and refreshes the existing bookmark", async ({+ apiCallers,+ db,+ }) => {+ const api = apiCallers[0].bookmarks;+ const user = await apiCallers[0].users.whoami();+ const triggerSearchReindexMock = getTestQueueMocks().triggerSearchReindex;+ const triggerWebhookSpy = vi+ .spyOn(WebhooksService.prototype, "triggerWebhook")+ .mockResolvedValue();+ const originallySavedAt = new Date("2026-01-01T00:00:00.000Z");+ const resavedAt = new Date("2026-01-02T00:00:00.000Z");++ vi.useFakeTimers();+ try {+ vi.setSystemTime(originallySavedAt);+ const original = await api.createBookmark({+ url: "https://example.com/resave",+ type: BookmarkTypes.LINK,+ });+ await api.updateBookmark({+ bookmarkId: original.id,+ archived: true,+ });++ const [beforeResave] = await db+ .select({+ dbCreatedAt: bookmarks.dbCreatedAt,+ createdAt: bookmarks.createdAt,+ })+ .from(bookmarks)+ .where(eq(bookmarks.id, original.id));+ assert(beforeResave);++ triggerSearchReindexMock.mockClear();+ triggerWebhookSpy.mockClear();+ vi.setSystemTime(resavedAt);++ const duplicate = await api.createBookmark({+ url: "https://example.com/resave",+ type: BookmarkTypes.LINK,+ });++ expect(duplicate).toMatchObject({+ id: original.id,+ alreadyExists: true,+ archived: false,+ createdAt: resavedAt,+ modifiedAt: resavedAt,+ });++ const [afterResave] = await db+ .select({+ dbCreatedAt: bookmarks.dbCreatedAt,+ createdAt: bookmarks.createdAt,+ modifiedAt: bookmarks.modifiedAt,+ archived: bookmarks.archived,+ })+ .from(bookmarks)+ .where(eq(bookmarks.id, original.id));+ assert(afterResave);++ expect(afterResave).toMatchObject({+ archived: false,+ createdAt: resavedAt,+ modifiedAt: resavedAt,+ });+ expect(afterResave.dbCreatedAt).toEqual(beforeResave.dbCreatedAt);+ expect(triggerSearchReindexMock).toHaveBeenCalledWith(original.id, {+ groupId: user.id,+ });+ expect(triggerWebhookSpy).toHaveBeenCalledWith(+ original.id,+ "edited",+ user.id,+ {+ groupId: user.id,+ },+ );+ } finally {+ triggerWebhookSpy.mockRestore();+ vi.useRealTimers();+ }+ });++ test<CustomTestContext>("re-saving a link only overwrites the metadata it was given", async ({+ apiCallers,+ }) => {+ const api = apiCallers[0].bookmarks;++ const original = await api.createBookmark({+ url: "https://example.com/resave-metadata",+ type: BookmarkTypes.LINK,+ title: "Original title",+ note: "Original note",+ favourited: true,+ });++ const bareResave = await api.createBookmark({+ url: "https://example.com/resave-metadata",+ type: BookmarkTypes.LINK,+ });+ expect(bareResave).toMatchObject({+ id: original.id,+ alreadyExists: true,+ title: "Original title",+ note: "Original note",+ favourited: true,+ });++ const resaveWithMetadata = await api.createBookmark({+ url: "https://example.com/resave-metadata",+ type: BookmarkTypes.LINK,+ title: "New title",+ favourited: false,+ });+ expect(resaveWithMetadata).toMatchObject({+ id: original.id,+ alreadyExists: true,+ title: "New title",+ note: "Original note",+ favourited: false,+ });++ const persisted = await api.getBookmark({ bookmarkId: original.id });+ expect(persisted).toMatchObject({+ title: "New title",+ note: "Original note",+ favourited: false,+ });+ });++ test<CustomTestContext>("re-saving a link from an exempt source stays a no-op", async ({+ apiCallers,+ db,+ }) => {+ const api = apiCallers[0].bookmarks;+ const triggerWebhookSpy = vi+ .spyOn(WebhooksService.prototype, "triggerWebhook")+ .mockResolvedValue();+ const originallySavedAt = new Date("2026-01-01T00:00:00.000Z");+ const resavedAt = new Date("2026-01-02T00:00:00.000Z");++ vi.useFakeTimers();+ try {+ vi.setSystemTime(originallySavedAt);+ const original = await api.createBookmark({+ url: "https://example.com/resave-exempt",+ type: BookmarkTypes.LINK,+ source: "rss",+ });+ await api.updateBookmark({+ bookmarkId: original.id,+ archived: true,+ });++ triggerWebhookSpy.mockClear();+ vi.setSystemTime(resavedAt);++ const duplicate = await api.createBookmark({+ url: "https://example.com/resave-exempt",+ type: BookmarkTypes.LINK,+ source: "rss",+ });+ expect(duplicate).toMatchObject({+ id: original.id,+ alreadyExists: true,+ archived: true,+ createdAt: originallySavedAt,+ });++ const [afterResave] = await db+ .select({+ createdAt: bookmarks.createdAt,+ archived: bookmarks.archived,+ })+ .from(bookmarks)+ .where(eq(bookmarks.id, original.id));+ assert(afterResave);+ expect(afterResave).toMatchObject({+ archived: true,+ createdAt: originallySavedAt,+ });+ expect(triggerWebhookSpy).not.toHaveBeenCalled();+ } finally {+ triggerWebhookSpy.mockRestore();+ vi.useRealTimers();+ }+ });+// Ensure that the pagination returns all the resultstest<CustomTestContext>("pagination", async ({ apiCallers, db }) => {const user = await apiCallers[0].users.whoami();diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.tsindex fc3f5dab..e010569a 100644--- a/packages/trpc/routers/bookmarks.ts+++ b/packages/trpc/routers/bookmarks.ts@@ -37,7 +37,10 @@ import { EnqueueOptions } from "@karakeep/shared/queueing";import { getRateLimitClient } from "@karakeep/shared/ratelimiting";import { FilterQuery, getSearchClient } from "@karakeep/shared/search";import { parseSearchQuery } from "@karakeep/shared/searchQueryParser";-import type { ZBookmarkContent } from "@karakeep/shared/types/bookmarks";+import type {+ ZBookmarkContent,+ ZBookmarkSource,+} from "@karakeep/shared/types/bookmarks";import {BookmarkTypes,DEFAULT_NUM_BOOKMARKS_PER_PAGE,@@ -199,6 +202,14 @@ const highBookmarkCreationRateLimitConfig = {maxRequests: 30,} as const;+// Automated bulk flows rely on the dedup path for idempotency, so hitting an+// existing bookmark from them must stay a no-op instead of unarchiving it and+// bumping it to the top of the list.+const RESAVE_EXEMPT_SOURCES: ReadonlySet<ZBookmarkSource> = new Set([+ "rss",+ "import",+]);+async function shouldUseLowPriorityQueues(ctx: AuthedContext,): Promise<boolean> {@@ -265,7 +276,53 @@ export const bookmarksAppRouter = router({"bookmark.id": alreadyExists.id,"bookmark.already_existed": true,});- return { ...alreadyExists, alreadyExists: true };+ if (input.source && RESAVE_EXEMPT_SOURCES.has(input.source)) {+ return { ...alreadyExists, alreadyExists: true };+ }+ const now = new Date();+ // Re-saving always restores the bookmark and bumps it back to the top+ // of the list. The rest of the metadata is only overwritten when the+ // caller actually supplied it, so a bare re-save doesn't wipe the+ // title or the note that are already on the existing bookmark.+ const resaved = {+ createdAt: input.createdAt ?? now,+ archived: input.archived ?? false,+ ...(input.title !== undefined ? { title: input.title } : {}),+ ...(input.favourited !== undefined+ ? { favourited: input.favourited }+ : {}),+ ...(input.note !== undefined ? { note: input.note } : {}),+ ...(input.summary !== undefined ? { summary: input.summary } : {}),+ };+ await ctx.db+ .update(bookmarks)+ .set({ ...resaved, modifiedAt: now })+ .where(+ and(+ eq(bookmarks.userId, ctx.user.id),+ eq(bookmarks.id, alreadyExists.id),+ ),+ );+ await Promise.all([+ triggerSearchReindex(alreadyExists.id, {+ groupId: ctx.user.id,+ }),+ new WebhooksService(ctx.db).triggerWebhook(+ alreadyExists.id,+ "edited",+ ctx.user.id,+ {+ groupId: ctx.user.id,+ },+ ),+ ]);++ return {+ ...alreadyExists,+ ...resaved,+ modifiedAt: now,+ alreadyExists: true,+ };}}