From 4a580d713621f99abb8baabc9b847ce039d44842 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 4 Oct 2025 13:40:24 +0100 Subject: 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 --- packages/trpc/routers/importSessions.ts | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/trpc/routers/importSessions.ts (limited to 'packages/trpc/routers/importSessions.ts') 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 }; + }), +}); -- cgit v1.3-1-g0d28