aboutsummaryrefslogtreecommitdiffstats
path: root/packages/open-api
diff options
context:
space:
mode:
Diffstat (limited to 'packages/open-api')
-rw-r--r--packages/open-api/karakeep-openapi-spec.json195
-rw-r--r--packages/open-api/lib/bookmarks.ts6
-rw-r--r--packages/open-api/lib/lists.ts23
-rw-r--r--packages/open-api/lib/tags.ts48
-rw-r--r--packages/open-api/package.json1
-rw-r--r--packages/open-api/tsconfig.json2
6 files changed, 229 insertions, 46 deletions
diff --git a/packages/open-api/karakeep-openapi-spec.json b/packages/open-api/karakeep-openapi-spec.json
index 0f8074d4..a8eb2ac2 100644
--- a/packages/open-api/karakeep-openapi-spec.json
+++ b/packages/open-api/karakeep-openapi-spec.json
@@ -77,6 +77,15 @@
"pending"
]
},
+ "summarizationStatus": {
+ "type": "string",
+ "nullable": true,
+ "enum": [
+ "success",
+ "failure",
+ "pending"
+ ]
+ },
"note": {
"type": "string",
"nullable": true
@@ -307,6 +316,7 @@
"archived",
"favourited",
"taggingStatus",
+ "summarizationStatus",
"tags",
"content",
"assets"
@@ -416,13 +426,17 @@
"query": {
"type": "string",
"nullable": true
+ },
+ "public": {
+ "type": "boolean"
}
},
"required": [
"id",
"name",
"icon",
- "parentId"
+ "parentId",
+ "public"
]
},
"Tag": {
@@ -551,6 +565,19 @@
},
{
"schema": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc"
+ ],
+ "default": "desc"
+ },
+ "required": false,
+ "name": "sortOrder",
+ "in": "query"
+ },
+ {
+ "schema": {
"type": "number"
},
"required": false,
@@ -776,6 +803,20 @@
},
{
"schema": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc",
+ "relevance"
+ ],
+ "default": "relevance"
+ },
+ "required": false,
+ "name": "sortOrder",
+ "in": "query"
+ },
+ {
+ "schema": {
"type": "number"
},
"required": false,
@@ -1042,6 +1083,15 @@
"pending"
]
},
+ "summarizationStatus": {
+ "type": "string",
+ "nullable": true,
+ "enum": [
+ "success",
+ "failure",
+ "pending"
+ ]
+ },
"note": {
"type": "string",
"nullable": true
@@ -1057,7 +1107,8 @@
"modifiedAt",
"archived",
"favourited",
- "taggingStatus"
+ "taggingStatus",
+ "summarizationStatus"
]
}
}
@@ -1142,6 +1193,15 @@
"pending"
]
},
+ "summarizationStatus": {
+ "type": "string",
+ "nullable": true,
+ "enum": [
+ "success",
+ "failure",
+ "pending"
+ ]
+ },
"note": {
"type": "string",
"nullable": true
@@ -1157,7 +1217,8 @@
"modifiedAt",
"archived",
"favourited",
- "taggingStatus"
+ "taggingStatus",
+ "summarizationStatus"
]
}
}
@@ -1925,6 +1986,9 @@
"query": {
"type": "string",
"minLength": 1
+ },
+ "public": {
+ "type": "boolean"
}
}
}
@@ -1969,8 +2033,8 @@
},
"/lists/{listId}/bookmarks": {
"get": {
- "description": "Get the bookmarks in a list",
- "summary": "Get a bookmarks in a list",
+ "description": "Get bookmarks in the list",
+ "summary": "Get bookmarks in the list",
"tags": [
"Lists"
],
@@ -1985,6 +2049,19 @@
},
{
"schema": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc"
+ ],
+ "default": "desc"
+ },
+ "required": false,
+ "name": "sortOrder",
+ "in": "query"
+ },
+ {
+ "schema": {
"type": "number"
},
"required": false,
@@ -2071,28 +2148,6 @@
"204": {
"description": "No content - the bookmark was added"
},
- "400": {
- "description": "Bookmark already in list",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "string"
- },
- "message": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "message"
- ]
- }
- }
- }
- },
"404": {
"description": "List or bookmark not found",
"content": {
@@ -2222,6 +2277,61 @@
}
}
}
+ },
+ "post": {
+ "description": "Create a new tag",
+ "summary": "Create a new tag",
+ "tags": [
+ "Tags"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "requestBody": {
+ "description": "The data to create the tag with.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ "required": [
+ "name"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "201": {
+ "description": "The created tag",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "name"
+ ]
+ }
+ }
+ }
+ }
+ }
}
},
"/tags/{tagId}": {
@@ -2357,7 +2467,19 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/Tag"
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "name"
+ ]
}
}
}
@@ -2389,8 +2511,8 @@
},
"/tags/{tagId}/bookmarks": {
"get": {
- "description": "Get the bookmarks with the tag",
- "summary": "Get a bookmarks with the tag",
+ "description": "Get bookmarks with the tag",
+ "summary": "Get bookmarks with the tag",
"tags": [
"Tags"
],
@@ -2405,6 +2527,19 @@
},
{
"schema": {
+ "type": "string",
+ "enum": [
+ "asc",
+ "desc"
+ ],
+ "default": "desc"
+ },
+ "required": false,
+ "name": "sortOrder",
+ "in": "query"
+ },
+ {
+ "schema": {
"type": "number"
},
"required": false,
diff --git a/packages/open-api/lib/bookmarks.ts b/packages/open-api/lib/bookmarks.ts
index e344d656..8fb0eb8c 100644
--- a/packages/open-api/lib/bookmarks.ts
+++ b/packages/open-api/lib/bookmarks.ts
@@ -9,6 +9,7 @@ import {
zBareBookmarkSchema,
zManipulatedTagSchema,
zNewBookmarkRequestSchema,
+ zSortOrder,
zUpdateBookmarksRequestSchema,
} from "@karakeep/shared/types/bookmarks";
@@ -60,6 +61,10 @@ registry.registerPath({
.object({
archived: z.boolean().optional(),
favourited: z.boolean().optional(),
+ sortOrder: zSortOrder
+ .exclude(["relevance"])
+ .optional()
+ .default(zSortOrder.Enum.desc),
})
.merge(PaginationSchema)
.merge(IncludeContentSearchParamSchema),
@@ -87,6 +92,7 @@ registry.registerPath({
query: z
.object({
q: z.string(),
+ sortOrder: zSortOrder.optional().default(zSortOrder.Enum.relevance),
})
.merge(PaginationSchema)
.merge(IncludeContentSearchParamSchema),
diff --git a/packages/open-api/lib/lists.ts b/packages/open-api/lib/lists.ts
index 2273d33b..992b96c4 100644
--- a/packages/open-api/lib/lists.ts
+++ b/packages/open-api/lib/lists.ts
@@ -4,6 +4,7 @@ import {
} from "@asteasolutions/zod-to-openapi";
import { z } from "zod";
+import { zSortOrder } from "@karakeep/shared/types/bookmarks";
import {
zBookmarkListSchema,
zEditBookmarkListSchema,
@@ -190,13 +191,21 @@ registry.registerPath({
registry.registerPath({
method: "get",
path: "/lists/{listId}/bookmarks",
- description: "Get the bookmarks in a list",
- summary: "Get a bookmarks in a list",
+ description: "Get bookmarks in the list",
+ summary: "Get bookmarks in the list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema }),
- query: PaginationSchema.merge(IncludeContentSearchParamSchema),
+ query: z
+ .object({
+ sortOrder: zSortOrder
+ .exclude(["relevance"])
+ .optional()
+ .default(zSortOrder.Enum.desc),
+ })
+ .merge(PaginationSchema)
+ .merge(IncludeContentSearchParamSchema),
},
responses: {
200: {
@@ -232,14 +241,6 @@ registry.registerPath({
204: {
description: "No content - the bookmark was added",
},
- 400: {
- description: "Bookmark already in list",
- content: {
- "application/json": {
- schema: ErrorSchema,
- },
- },
- },
404: {
description: "List or bookmark not found",
content: {
diff --git a/packages/open-api/lib/tags.ts b/packages/open-api/lib/tags.ts
index c51e3b84..0a4f62cb 100644
--- a/packages/open-api/lib/tags.ts
+++ b/packages/open-api/lib/tags.ts
@@ -4,8 +4,11 @@ import {
} from "@asteasolutions/zod-to-openapi";
import { z } from "zod";
+import { zSortOrder } from "@karakeep/shared/types/bookmarks";
import {
+ zCreateTagRequestSchema,
zGetTagResponseSchema,
+ zTagBasicSchema,
zUpdateTagRequestSchema,
} from "@karakeep/shared/types/tags";
@@ -56,6 +59,35 @@ registry.registerPath({
});
registry.registerPath({
+ method: "post",
+ path: "/tags",
+ description: "Create a new tag",
+ summary: "Create a new tag",
+ tags: ["Tags"],
+ security: [{ [BearerAuth.name]: [] }],
+ request: {
+ body: {
+ description: "The data to create the tag with.",
+ content: {
+ "application/json": {
+ schema: zCreateTagRequestSchema,
+ },
+ },
+ },
+ },
+ responses: {
+ 201: {
+ description: "The created tag",
+ content: {
+ "application/json": {
+ schema: zTagBasicSchema,
+ },
+ },
+ },
+ },
+});
+
+registry.registerPath({
method: "get",
path: "/tags/{tagId}",
description: "Get tag by its id",
@@ -134,7 +166,7 @@ registry.registerPath({
description: "The updated tag",
content: {
"application/json": {
- schema: TagSchema,
+ schema: zTagBasicSchema,
},
},
},
@@ -152,13 +184,21 @@ registry.registerPath({
registry.registerPath({
method: "get",
path: "/tags/{tagId}/bookmarks",
- description: "Get the bookmarks with the tag",
- summary: "Get a bookmarks with the tag",
+ description: "Get bookmarks with the tag",
+ summary: "Get bookmarks with the tag",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ tagId: TagIdSchema }),
- query: PaginationSchema.merge(IncludeContentSearchParamSchema),
+ query: z
+ .object({
+ sortOrder: zSortOrder
+ .exclude(["relevance"])
+ .optional()
+ .default(zSortOrder.Enum.desc),
+ })
+ .merge(PaginationSchema)
+ .merge(IncludeContentSearchParamSchema),
},
responses: {
200: {
diff --git a/packages/open-api/package.json b/packages/open-api/package.json
index dfbb0bb6..900af481 100644
--- a/packages/open-api/package.json
+++ b/packages/open-api/package.json
@@ -19,6 +19,7 @@
"typecheck": "tsc --noEmit",
"generate": "tsx index.ts",
"format": "prettier . --ignore-path ../../.prettierignore",
+ "format:fix": "prettier . --write --ignore-path ../../.prettierignore",
"lint": "eslint ."
},
"main": "index.ts",
diff --git a/packages/open-api/tsconfig.json b/packages/open-api/tsconfig.json
index d97c8ef4..a795b96a 100644
--- a/packages/open-api/tsconfig.json
+++ b/packages/open-api/tsconfig.json
@@ -5,5 +5,5 @@
"exclude": ["node_modules"],
"compilerOptions": {
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
- },
+ }
}