aboutsummaryrefslogtreecommitdiffstats
path: root/packages/open-api/lib/pagination.ts
blob: 382f00efaf14b629d51bd007aef1a718ba8b7969 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
import { z } from "zod";

import { zBookmarkSchema } from "@karakeep/shared/types/bookmarks";

extendZodWithOpenApi(z);

export const BookmarkSchema = zBookmarkSchema.openapi("Bookmark");

export const PaginatedBookmarksSchema = z
  .object({
    bookmarks: z.array(BookmarkSchema),
    nextCursor: z.string().nullable(),
  })
  .openapi("PaginatedBookmarks");

export const CursorSchema = z.string().openapi("Cursor");

export const PaginationSchema = z
  .object({
    limit: z.number().optional(),
    cursor: 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.",
    ),
});