aboutsummaryrefslogtreecommitdiffstats
path: root/packages/open-api/lib/types.ts
blob: 3aae48fcb6f8943fa6318dd063a69adb918c6a1c (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
import { z } from "zod";

import { zBookmarkSchema } from "@karakeep/shared/types/bookmarks";
import { zHighlightSchema } from "@karakeep/shared/types/highlights";
import { zBookmarkListSchema } from "@karakeep/shared/types/lists";
import { zGetTagResponseSchema } from "@karakeep/shared/types/tags";

extendZodWithOpenApi(z);

export const ListSchema = zBookmarkListSchema.openapi("List");

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.",
    ),
});

export const HighlightSchema = zHighlightSchema.openapi("Highlight");

export const PaginatedHighlightsSchema = z
  .object({
    highlights: z.array(HighlightSchema),
    nextCursor: z.string().nullable(),
  })
  .openapi("PaginatedHighlights");

export const TagSchema = zGetTagResponseSchema.openapi("Tag");