aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers/importSessions.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-10-04 13:40:24 +0100
committerGitHub <noreply@github.com>2025-10-04 13:40:24 +0100
commit4a580d713621f99abb8baabc9b847ce039d44842 (patch)
treea2aa6f3ae8045ad50a9316624e2a7028dd098c6b /packages/trpc/routers/importSessions.ts
parent5e331a7d5b8d9666812170547574804d8b6da741 (diff)
downloadkarakeep-4a580d713621f99abb8baabc9b847ce039d44842.tar.zst
feat: Revamp import experience (#2001)
* WIP: import v2 * remove new session button * don't redirect after import * store and lint to root list * models + tests * redesign the progress * simplify the import session for ow * drop status from session schema * split the import session page * i18n * fix test * remove pagination * fix some colors in darkmode * one last fix * add privacy filter * privacy check * fix interactivity of import progress * fix test
Diffstat (limited to 'packages/trpc/routers/importSessions.ts')
-rw-r--r--packages/trpc/routers/importSessions.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/trpc/routers/importSessions.ts b/packages/trpc/routers/importSessions.ts
new file mode 100644
index 00000000..4bdc4f29
--- /dev/null
+++ b/packages/trpc/routers/importSessions.ts
@@ -0,0 +1,48 @@
+import { z } from "zod";
+
+import {
+ zCreateImportSessionRequestSchema,
+ zDeleteImportSessionRequestSchema,
+ zGetImportSessionStatsRequestSchema,
+ zImportSessionWithStatsSchema,
+ zListImportSessionsRequestSchema,
+ zListImportSessionsResponseSchema,
+} from "@karakeep/shared/types/importSessions";
+
+import { authedProcedure, router } from "../index";
+import { ImportSession } from "../models/importSessions";
+
+export const importSessionsRouter = router({
+ createImportSession: authedProcedure
+ .input(zCreateImportSessionRequestSchema)
+ .output(z.object({ id: z.string() }))
+ .mutation(async ({ input, ctx }) => {
+ const session = await ImportSession.create(ctx, input);
+ return { id: session.session.id };
+ }),
+
+ getImportSessionStats: authedProcedure
+ .input(zGetImportSessionStatsRequestSchema)
+ .output(zImportSessionWithStatsSchema)
+ .query(async ({ input, ctx }) => {
+ const session = await ImportSession.fromId(ctx, input.importSessionId);
+ return await session.getWithStats();
+ }),
+
+ listImportSessions: authedProcedure
+ .input(zListImportSessionsRequestSchema)
+ .output(zListImportSessionsResponseSchema)
+ .query(async ({ ctx }) => {
+ const sessions = await ImportSession.getAllWithStats(ctx);
+ return { sessions };
+ }),
+
+ deleteImportSession: authedProcedure
+ .input(zDeleteImportSessionRequestSchema)
+ .output(z.object({ success: z.boolean() }))
+ .mutation(async ({ input, ctx }) => {
+ const session = await ImportSession.fromId(ctx, input.importSessionId);
+ await session.delete();
+ return { success: true };
+ }),
+});