A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
Revert "fix: Fix the types of the bookmark types in the db query"
Mohamed Bassem0addc7bc3296
diff --git a/apps/workers/workers/assetPreprocessingWorker.ts b/apps/workers/workers/assetPreprocessingWorker.tsindex f36908cc..c3ecd1e0 100644--- a/apps/workers/workers/assetPreprocessingWorker.ts+++ b/apps/workers/workers/assetPreprocessingWorker.ts@@ -189,11 +189,6 @@ async function extractAndSaveImageText(bookmark: NonNullable<Awaited<ReturnType<typeof getBookmark>>>,isFixMode: boolean,): Promise<boolean> {- if (!bookmark.asset) {- throw new Error(- `[assetPreprocessing][${jobId}] Bookmark ${bookmark.id} has no asset attached`,- );- }{const alreadyHasText = !!bookmark.asset.content;if (alreadyHasText && isFixMode) {@@ -237,11 +232,6 @@ async function extractAndSavePDFText(bookmark: NonNullable<Awaited<ReturnType<typeof getBookmark>>>,isFixMode: boolean,): Promise<boolean> {- if (!bookmark.asset) {- throw new Error(- `[assetPreprocessing][${jobId}] Bookmark ${bookmark.id} has no asset attached`,- );- }{const alreadyHasText = !!bookmark.asset.content;if (alreadyHasText && isFixMode) {diff --git a/apps/workers/workers/inference/tagging.ts b/apps/workers/workers/inference/tagging.tsindex 47419a1f..3c7b5adb 100644--- a/apps/workers/workers/inference/tagging.ts+++ b/apps/workers/workers/inference/tagging.ts@@ -118,11 +118,6 @@ async function inferTagsFromImage(inferenceClient: InferenceClient,abortSignal: AbortSignal,) {- if (!bookmark.asset) {- throw new Error(- `[inference][${jobId}] Bookmark ${bookmark.id} has no asset attached`,- );- }const { asset, metadata } = await readAsset({userId: bookmark.userId,assetId: bookmark.asset.assetId,@@ -204,16 +199,11 @@ function containsTagsPlaceholder(prompts: { text: string }[]): boolean {}async function inferTagsFromPDF(- jobId: string,+ _jobId: string,bookmark: NonNullable<Awaited<ReturnType<typeof fetchBookmark>>>,inferenceClient: InferenceClient,abortSignal: AbortSignal,) {- if (!bookmark.asset) {- throw new Error(- `[inference][${jobId}] Bookmark ${bookmark.id} has no asset attached`,- );- }const prompt = buildTextPrompt(serverConfig.inference.inferredTagLang,await fetchCustomPrompts(bookmark.userId, "text"),diff --git a/packages/db/schema.ts b/packages/db/schema.tsindex 540c4c82..6dacdec6 100644--- a/packages/db/schema.ts+++ b/packages/db/schema.ts@@ -649,9 +649,18 @@ export const bookmarkRelations = relations(bookmarks, ({ many, one }) => ({fields: [bookmarks.userId],references: [users.id],}),- link: one(bookmarkLinks),- text: one(bookmarkTexts),- asset: one(bookmarkAssets),+ link: one(bookmarkLinks, {+ fields: [bookmarks.id],+ references: [bookmarkLinks.id],+ }),+ text: one(bookmarkTexts, {+ fields: [bookmarks.id],+ references: [bookmarkTexts.id],+ }),+ asset: one(bookmarkAssets, {+ fields: [bookmarks.id],+ references: [bookmarkAssets.id],+ }),tagsOnBookmarks: many(tagsOnBookmarks),bookmarksInLists: many(bookmarksInLists),assets: many(assets),diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.tsindex ef6ce396..9aa9ec1e 100644--- a/packages/trpc/routers/bookmarks.ts+++ b/packages/trpc/routers/bookmarks.ts@@ -187,7 +187,7 @@ async function toZodSchema(let content: ZBookmarkContent = {type: BookmarkTypes.UNKNOWN,};- if (link) {+ if (bookmark.link) {content = {type: BookmarkTypes.LINK,screenshotAssetId: assets.find(@@ -219,7 +219,7 @@ async function toZodSchema(dateModified: link.dateModified,};}- if (text) {+ if (bookmark.text) {content = {type: BookmarkTypes.TEXT,// It's ok to include the text content as it's usually not big and is used to render the text bookmark card.@@ -227,7 +227,7 @@ async function toZodSchema(sourceUrl: text.sourceUrl,};}- if (asset) {+ if (bookmark.asset) {content = {type: BookmarkTypes.ASSET,assetType: asset.assetType,