import { getFlowExecCtxForRemoteFuncs } from "$lib/core/server.utils";
import { command, getRequestEvent, query } from "$app/server";
import { prepareLinkFlow, resolveLinkFlow } from "./service";
import { tokenSchema } from "./data";

export const resolveLinkSQ = query(tokenSchema, async ({ token }) => {
    const event = getRequestEvent();
    const fctx = await getFlowExecCtxForRemoteFuncs(event.locals);
    return resolveLinkFlow(fctx, token);
});

export const prepareLinkSC = command(tokenSchema, async ({ token }) => {
    const event = getRequestEvent();
    const fctx = await getFlowExecCtxForRemoteFuncs(event.locals);
    return prepareLinkFlow(fctx, token);
});
