aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/routes/sb1.remote.ts
blob: d2eb0cc2b18e00c1e8f93cbdec366707a47579f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { db } from "$lib/server/db";
import { syncSession } from "$lib/server/db/schema";
import * as v from "valibot"
import { command, query } from "$app/server";
import sb1 from "$lib/server/sb1";

const init_auth_session = command(async () => {
    return await sb1.auth.init_auth_session()
})

const is_ready = query(async () => {
    return await sb1.auth.is_ready()
})

const get_accounts = query(async () => {
    return await sb1.data.get_accounts()
})

const get_transactions = query(v.string(), async (accountKey: string) => {
    return await sb1.data.get_transactions(accountKey)
})

const clear_auth_session = query(async () => {
    await db.delete(syncSession)
})

const get_auth_info = query(async () => {
    return await sb1.auth.get_auth_info()
})

const refresh_tokem = command(async () => {
    await sb1.auth.refresh_tokem()
})

export {
    refresh_tokem,
    init_auth_session,
    is_ready,
    get_accounts,
    get_transactions,
    clear_auth_session,
    get_auth_info,
}