-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackend_interface.ts
213 lines (174 loc) · 4.72 KB
/
backend_interface.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
export const ENDPOINT_CREATE_CARD_DECK: string = "/create_card_deck";
export const ENDPOINT_DELETE_CARD_DECK: string = "/delete_card_deck";
export const ENDPOINT_SET_DECK_ICON: string = "/set_deck_icon";
export const ENDPOINT_ADD_RATING: string = "/add_rating";
export const ENDPOINT_CREATE_CARD: string = "/create_card";
export const ENDPOINT_DELETE_CARD: string = "/delete_card";
export const ENDPOINT_EDIT_CARD: string = "/edit_card";
export const ENDPOINT_LIST_CARD_DECKS: string = "/list_card_decks";
export const ENDPOINT_GET_DECK: string = "/get_deck";
export const ENDPOINT_LIST_CARDS: string = "/list_cards";
export const ENDPOINT_LOGIN: string = "/login";
export const ENDPOINT_NEW_USER: string = "/new_user";
export const ENDPOINT_DELETE_USER: string = "/delete_user";
export const ENDPOINT_CHANGE_PASSWORD: string = "/change_password";
export const ENDPOINT_SEARCH_DECKS: string = "/search_decks";
export const ENDPOINT_LIST_FAVORITES: string = "/list_favorites";
export const ENDPOINT_ADD_FAVORITE: string = "/add_favorite";
export const ENDPOINT_DELETE_FAVORITE: string = "/delete_favorite";
export const ENDPOINT_AI_TEST: string = "/ai_test";
export const ENDPOINT_CREATE_DECK_PDF: string = "/create_card_deck_pdf";
export const ENDPOINT_GET_RANDOM_DECKS: string = "/get_random_decks";
type AccessToken = [number, number];
export interface Card {
question: string;
answer: string;
}
export interface CardDeck {
name: string;
user_id: number;
deck_id: number;
num_cards: number;
icon_num: number;
rating: number;
}
// request -> ENDPOINT_CREATE_CARD
export interface CreateCard {
access_token: AccessToken;
deck_id: number;
question: string;
answer: string;
}
// request -> ENDPOINT_DELETE_CARD
export interface DeleteCard {
access_token: AccessToken;
deck_id: number;
card_index: number;
}
// request -> ENDPOINT_EDIT_CARD
export interface EditCard {
access_token: AccessToken;
deck_id: number;
card_index: number;
new_question: string;
new_answer: string;
}
// request -> ENDPOINT_CREATE_CARD_DECK
export interface CreateCardDeck {
access_token: AccessToken;
deck_name: string;
}
// request -> ENDPOINT_DELETE_CARD_DECK
export interface DeleteCardDeck {
access_token: AccessToken;
deck_id: number;
}
// request -> ENDPOINT_ADD_RATING
export interface AddRating {
access_token: AccessToken;
user_id: number;
deck_id: number;
new_rating: number;
}
// request -> ENDPOINT_SET_DECK_ICON
export interface SetDeckIcon {
access_token: AccessToken;
deck_id: number;
icon: number;
}
// request -> ENDPOINT_NEW_USER
export interface NewUser {
user_name: string;
email: string;
password: string;
}
// request -> ENDPOINT_DELETE_USER
export interface DeleteUser {
email: string;
password: string;
}
// request -> ENDPOINT_CHANGE_PASSWORD
export interface ChangePassword {
email: string;
old_password: string;
new_password: string;
}
// request -> ENDPOINT_LIST_CARD_DECKS
export interface ListCardDecks {
access_token: AccessToken;
}
// response <- ENDPOINT_LIST_CARD_DECKS
export interface ListCardDecksResponse {
decks: CardDeck[];
}
// request -> ENDPOINT_GET_DECK
export interface GetDeckRequest {
user_id: number;
deck_id: number;
}
export type GetDeckResponse = CardDeck;
// request -> ENDPOINT_LIST_CARDS
export interface ListCards {
user_id: number;
deck_id: number;
}
// response <- ENDPOINT_LIST_CARDS
export interface ListCardsResponse {
cards: Card[];
}
// request -> ENDPOINT_LOGIN
export interface LoginRequest {
email: string;
password: string;
}
// response <- ENDPOINT_LOGIN
export interface LoginResponse {
access_token: AccessToken;
user_id: number;
}
// request -> ENDPOINT_SEARCH_DECKS
export interface SearchDecksRequest {
prompt: string;
}
// response <- ENDPOINT_SEARCH_DECKS
export interface SearchDecksResponse {
decks: CardDeck[];
}
// request -> ENDPOINT_CREATE_DECK_PDF
export interface UploadPdf {
access_token: AccessToken;
deck_name: string;
file_bytes_base64: string;
}
// request -> ENDPOINT_AI_TEST
export interface AiPromptTest {
prompt: string;
}
// request -> ENDPOINT_LIST_FAVORITES
export interface ListFavoritesRequest {
access_token: AccessToken;
}
// response <- ENDPOINT_LIST_FAVORITES
export interface ListFavoritesResponse {
decks: CardDeck[];
}
// request -> ENDPOINT_ADD_FAVORITE
export interface AddFavorite {
access_token: AccessToken;
user_id: number;
deck_id: number;
}
// request -> ENDPOINT_DELETE_FAVORITE
export interface DeleteFavorite {
access_token: AccessToken;
user_id: number;
deck_id: number;
}
// request -> ENDPOINT_GET_RANDOM_DECKS
export interface RandomDecksRequest {
num_decks: number;
}
// response -> ENDPOINT_GET_RANDOM_DECKS
export interface RandomDecksResponse {
decks: CardDeck[];
}