Files
finanzen/convex/comdirect/sync.ts

38 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { action } from "../_generated/server";
import { v } from "convex/values";
import { internal } from "../_generated/api";
import { getAuthUserId } from "@convex-dev/auth/server";
/** @deprecated Nutze api.bank.sync.run leitet an den Orchestrator mit FinTS-Fallback weiter. */
export const run = action({
args: {
accountId: v.optional(v.id("accounts")),
from: v.string(),
to: v.string(),
pin: v.optional(v.string()),
},
returns: v.object({
importedCount: v.number(),
skippedCount: v.number(),
provider: v.union(v.literal("comdirect"), v.literal("fints")),
awaitingTan: v.boolean(),
}),
handler: async (ctx, args): Promise<{
importedCount: number;
skippedCount: number;
provider: "comdirect" | "fints";
awaitingTan: boolean;
}> => {
const userId = await getAuthUserId(ctx);
if (!userId) throw new Error("Nicht angemeldet");
return await ctx.runAction(internal.bank.orchestrator.runSyncInternal, {
userId,
from: args.from,
to: args.to,
accountId: args.accountId,
pin: args.pin,
});
},
});