blob: bfba06f00a9f9fb3beb67702b43771e5bfd1c9f3 (
plain)
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
|
// Card states for FSRS algorithm
export const CardState = {
New: 0,
Learning: 1,
Review: 2,
Relearning: 3,
} as const;
export type CardState = (typeof CardState)[keyof typeof CardState];
// Rating values for reviews
export const Rating = {
Again: 1,
Hard: 2,
Good: 3,
Easy: 4,
} as const;
export type Rating = (typeof Rating)[keyof typeof Rating];
// User
export interface User {
id: string;
username: string;
passwordHash: string;
createdAt: Date;
updatedAt: Date;
}
// Deck
export interface Deck {
id: string;
userId: string;
name: string;
description: string | null;
newCardsPerDay: number;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
syncVersion: number;
}
// Card with FSRS fields
export interface Card {
id: string;
deckId: string;
front: string;
back: string;
// FSRS fields
state: CardState;
due: Date;
stability: number;
difficulty: number;
elapsedDays: number;
scheduledDays: number;
reps: number;
lapses: number;
lastReview: Date | null;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
syncVersion: number;
}
// ReviewLog (append-only)
export interface ReviewLog {
id: string;
cardId: string;
userId: string;
rating: Rating;
state: CardState;
scheduledDays: number;
elapsedDays: number;
reviewedAt: Date;
durationMs: number | null;
syncVersion: number;
}
|