A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: Add includeContent to search endpoint and document it in the docs
Mohamed Bassemba89a864bb45
diff --git a/apps/mcp/src/bookmarks.ts b/apps/mcp/src/bookmarks.tsindex 14043489..57b6959b 100644--- a/apps/mcp/src/bookmarks.ts+++ b/apps/mcp/src/bookmarks.ts@@ -36,6 +36,7 @@ machine learning is:fav`),query: {q: query,limit: 10,+ includeContent: false,},},});@@ -63,6 +64,9 @@ mcpServer.tool(path: {bookmarkId,},+ query: {+ includeContent: false,+ },},});if (res.error) {@@ -149,6 +153,9 @@ mcpServer.tool(path: {bookmarkId,},+ query: {+ includeContent: true,+ },},});if (res.error) {diff --git a/apps/mcp/src/lists.ts b/apps/mcp/src/lists.tsindex 1e0f3a8a..eee1cc96 100644--- a/apps/mcp/src/lists.ts+++ b/apps/mcp/src/lists.ts@@ -33,6 +33,9 @@ mcpServer.tool(path: {listId,},+ query: {+ includeContent: false,+ },},});if (res.error) {diff --git a/apps/web/app/api/v1/bookmarks/search/route.ts b/apps/web/app/api/v1/bookmarks/search/route.tsindex f0c5417a..52081c7f 100644--- a/apps/web/app/api/v1/bookmarks/search/route.ts+++ b/apps/web/app/api/v1/bookmarks/search/route.ts@@ -2,29 +2,33 @@ import { NextRequest } from "next/server";import { z } from "zod";import { buildHandler } from "../../utils/handler";+import { zGetBookmarkSearchParamsSchema } from "../../utils/types";export const dynamic = "force-dynamic";export const GET = (req: NextRequest) =>buildHandler({req,- searchParamsSchema: z.object({- q: z.string(),- limit: z.coerce.number().optional(),- cursor: z- .string()- // Search cursor V1 is just a number- .pipe(z.coerce.number())- .transform((val) => {- return { ver: 1 as const, offset: val };- })- .optional(),- }),+ searchParamsSchema: z+ .object({+ q: z.string(),+ limit: z.coerce.number().optional(),+ cursor: z+ .string()+ // Search cursor V1 is just a number+ .pipe(z.coerce.number())+ .transform((val) => {+ return { ver: 1 as const, offset: val };+ })+ .optional(),+ })+ .and(zGetBookmarkSearchParamsSchema),handler: async ({ api, searchParams }) => {const bookmarks = await api.bookmarks.searchBookmarks({text: searchParams.q,cursor: searchParams.cursor,limit: searchParams.limit,+ includeContent: searchParams.includeContent,});return {status: 200,diff --git a/packages/open-api/hoarder-openapi-spec.json b/packages/open-api/hoarder-openapi-spec.jsonindex dfe7c761..9a1d8634 100644--- a/packages/open-api/hoarder-openapi-spec.json+++ b/packages/open-api/hoarder-openapi-spec.json@@ -564,6 +564,17 @@"required": false,"name": "cursor","in": "query"+ },+ {+ "schema": {+ "type": "boolean",+ "default": true,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks."+ },+ "required": false,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ "name": "includeContent",+ "in": "query"}],"responses": {@@ -778,6 +789,17 @@"required": false,"name": "cursor","in": "query"+ },+ {+ "schema": {+ "type": "boolean",+ "default": true,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks."+ },+ "required": false,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ "name": "includeContent",+ "in": "query"}],"responses": {@@ -809,6 +831,17 @@"parameters": [{"$ref": "#/components/parameters/BookmarkId"+ },+ {+ "schema": {+ "type": "boolean",+ "default": true,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks."+ },+ "required": false,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ "name": "includeContent",+ "in": "query"}],"responses": {@@ -1965,6 +1998,17 @@"required": false,"name": "cursor","in": "query"+ },+ {+ "schema": {+ "type": "boolean",+ "default": true,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks."+ },+ "required": false,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ "name": "includeContent",+ "in": "query"}],"responses": {@@ -2374,6 +2418,17 @@"required": false,"name": "cursor","in": "query"+ },+ {+ "schema": {+ "type": "boolean",+ "default": true,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks."+ },+ "required": false,+ "description": "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ "name": "includeContent",+ "in": "query"}],"responses": {diff --git a/packages/open-api/lib/bookmarks.ts b/packages/open-api/lib/bookmarks.tsindex 51c67369..e344d656 100644--- a/packages/open-api/lib/bookmarks.ts+++ b/packages/open-api/lib/bookmarks.ts@@ -17,6 +17,7 @@ import { ErrorSchema } from "./errors";import { HighlightSchema } from "./highlights";import {BookmarkSchema,+ IncludeContentSearchParamSchema,PaginatedBookmarksSchema,PaginationSchema,} from "./pagination";@@ -60,7 +61,8 @@ registry.registerPath({archived: z.boolean().optional(),favourited: z.boolean().optional(),})- .merge(PaginationSchema),+ .merge(PaginationSchema)+ .merge(IncludeContentSearchParamSchema),},responses: {200: {@@ -86,7 +88,8 @@ registry.registerPath({.object({q: z.string(),})- .merge(PaginationSchema),+ .merge(PaginationSchema)+ .merge(IncludeContentSearchParamSchema),},responses: {200: {@@ -145,6 +148,7 @@ registry.registerPath({security: [{ [BearerAuth.name]: [] }],request: {params: z.object({ bookmarkId: BookmarkIdSchema }),+ query: IncludeContentSearchParamSchema,},responses: {200: {diff --git a/packages/open-api/lib/lists.ts b/packages/open-api/lib/lists.tsindex f2c0d954..2273d33b 100644--- a/packages/open-api/lib/lists.ts+++ b/packages/open-api/lib/lists.ts@@ -13,7 +13,11 @@ import {import { BookmarkIdSchema } from "./bookmarks";import { BearerAuth } from "./common";import { ErrorSchema } from "./errors";-import { PaginatedBookmarksSchema, PaginationSchema } from "./pagination";+import {+ IncludeContentSearchParamSchema,+ PaginatedBookmarksSchema,+ PaginationSchema,+} from "./pagination";export const registry = new OpenAPIRegistry();extendZodWithOpenApi(z);@@ -192,7 +196,7 @@ registry.registerPath({security: [{ [BearerAuth.name]: [] }],request: {params: z.object({ listId: ListIdSchema }),- query: PaginationSchema,+ query: PaginationSchema.merge(IncludeContentSearchParamSchema),},responses: {200: {diff --git a/packages/open-api/lib/pagination.ts b/packages/open-api/lib/pagination.tsindex dfe835e2..382f00ef 100644--- a/packages/open-api/lib/pagination.ts+++ b/packages/open-api/lib/pagination.ts@@ -22,3 +22,12 @@ export const PaginationSchema = zcursor: CursorSchema.optional(),}).openapi("Pagination");++export const IncludeContentSearchParamSchema = z.object({+ includeContent: z+ .boolean()+ .default(true)+ .describe(+ "If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks.",+ ),+});diff --git a/packages/open-api/lib/tags.ts b/packages/open-api/lib/tags.tsindex 86353924..c51e3b84 100644--- a/packages/open-api/lib/tags.ts+++ b/packages/open-api/lib/tags.ts@@ -11,7 +11,11 @@ import {import { BearerAuth } from "./common";import { ErrorSchema } from "./errors";-import { PaginatedBookmarksSchema, PaginationSchema } from "./pagination";+import {+ IncludeContentSearchParamSchema,+ PaginatedBookmarksSchema,+ PaginationSchema,+} from "./pagination";export const registry = new OpenAPIRegistry();extendZodWithOpenApi(z);@@ -154,7 +158,7 @@ registry.registerPath({security: [{ [BearerAuth.name]: [] }],request: {params: z.object({ tagId: TagIdSchema }),- query: PaginationSchema,+ query: PaginationSchema.merge(IncludeContentSearchParamSchema),},responses: {200: {diff --git a/packages/sdk/src/hoarder-api.d.ts b/packages/sdk/src/hoarder-api.d.tsindex 2b9986d3..0b434b3d 100644--- a/packages/sdk/src/hoarder-api.d.ts+++ b/packages/sdk/src/hoarder-api.d.ts@@ -22,6 +22,8 @@ export interface paths {favourited?: boolean;limit?: number;cursor?: components["schemas"]["Cursor"];+ /** @description If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks. */+ includeContent?: boolean;};header?: never;path?: never;@@ -135,6 +137,8 @@ export interface paths {q: string;limit?: number;cursor?: components["schemas"]["Cursor"];+ /** @description If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks. */+ includeContent?: boolean;};header?: never;path?: never;@@ -174,7 +178,10 @@ export interface paths {*/get: {parameters: {- query?: never;+ query?: {+ /** @description If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks. */+ includeContent?: boolean;+ };header?: never;path: {bookmarkId: components["parameters"]["BookmarkId"];@@ -972,6 +979,8 @@ export interface paths {query?: {limit?: number;cursor?: components["schemas"]["Cursor"];+ /** @description If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks. */+ includeContent?: boolean;};header?: never;path: {@@ -1313,6 +1322,8 @@ export interface paths {query?: {limit?: number;cursor?: components["schemas"]["Cursor"];+ /** @description If set to true, bookmark's content will be included in the response. Note, this content can be large for some bookmarks. */+ includeContent?: boolean;};header?: never;path: {diff --git a/packages/shared/types/bookmarks.ts b/packages/shared/types/bookmarks.tsindex 8df0e375..3cac2845 100644--- a/packages/shared/types/bookmarks.ts+++ b/packages/shared/types/bookmarks.ts@@ -239,4 +239,5 @@ export const zSearchBookmarksRequestSchema = z.object({limit: z.number().max(MAX_NUM_BOOKMARKS_PER_PAGE).optional(),cursor: zSearchBookmarksCursor.nullish(),sortOrder: zSortOrder.optional().default("desc"),+ includeContent: z.boolean().optional().default(false),});diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.tsindex a02fb691..9a1b6b0b 100644--- a/packages/trpc/routers/bookmarks.ts+++ b/packages/trpc/routers/bookmarks.ts@@ -761,9 +761,7 @@ export const bookmarksAppRouter = router({results.sort((a, b) => idToRank[b.id] - idToRank[a.id]);return {- bookmarks: results.map((b) =>- toZodSchema(b, /* includeContent: */ false),- ),+ bookmarks: results.map((b) => toZodSchema(b, input.includeContent)),nextCursor:resp.hits.length + resp.offset >= resp.estimatedTotalHits? null