38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
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,
|
||
});
|
||
},
|
||
});
|