aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/services/abstractions/IAccountService.ts
blob: 0645eb6e7a4a1a2d89a1fe6b0632b641a1449e27 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type {KnownProblem} from "$models/internal/KnownProblem";
import type {Writable} from "svelte/store";

export interface IAccountService {
    session: Writable<Session>,

    login_async(payload: LoginPayload): Promise<LoginResponse>,

    logout_async(): Promise<void>,

    create_account_async(payload: CreateAccountPayload): Promise<CreateAccountResponse>,

    delete_current_async(): Promise<DeleteAccountResponse>,

    update_current_async(payload: UpdateAccountPayload): Promise<UpdateAccountResponse>,
}

export type Session = {
    username: string,
    displayName: string,
    id: string,
    _lastUpdated: number
}

export type LoginPayload = {
    username: string,
    password: string,
    persist: boolean
}

export type LoginResponse = {
    isLoggedIn: boolean,
    knownProblem?: KnownProblem
}

export type CreateAccountPayload = {
    username: string,
    password: string,
}

export type CreateAccountResponse = {
    isCreated: boolean,
    knownProblem?: KnownProblem
}

export type DeleteAccountResponse = {
    isDeleted: boolean
}

export type UpdateAccountPayload = {
    username: string,
    password: string
}

export type UpdateAccountResponse = {
    isUpdated: boolean,
    knownProblem?: KnownProblem
}