summaryrefslogtreecommitdiff
path: root/src/lib/types/cards.ts
blob: 39e2b1526a2b997c26a0384d43c9aca6772ae811 (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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// src/types.ts

import { ReactNode } from "react";

// Language definition
export interface Language {
  code: string;
  name: string;
  nativeName?: string;
  supportsSource?: boolean;
  supportsTarget?: boolean;
  progress: number;
  cardCount: number;
}

// Translation service provider
export interface Provider {
  id: string;
  name: string;
}

// Translation history item
export interface TranslationHistoryItem {
  id: number;
  text: string;
  translation: string;
  from: string;
  to: string;
  provider: string;
  timestamp: number;
}

// Response from translation API
export interface TranslationResponse {
  translation: string;
  source: string;
  target: string;
  provider: string;
  characters: number;
}

// Error response from API
export interface ErrorResponse {
  error: string;
  details?: any;
}

// Props for components
export interface LanguageSelectorProps {
  value: string;
  onChange: (value: string) => void;
  languages: Language[];
  showCharCount?: boolean;
  charCount?: number;
  showCopyButton?: boolean;
  onCopy?: () => void;
  setMore?: (t: { text: string; lang: string }) => void;
  text?: string;
  disabled?: boolean;
}

export interface TextAreaProps {
  value: string;
  onChange: (value: string) => void;
  lang?: string;
  transliteration?: TransliterationOptions;
  placeholder: string;
  readOnly?: boolean;
}

export interface ProviderSelectorProps {
  value: string;
  onChange: (value: string) => void;
  providers: Provider[];
}

export interface TranslationHistoryProps {
  items: TranslationHistoryItem[];
  languages: Language[];
  providers: Provider[];
}

export interface TransliterationOptions extends Language {
  scripts: TransliterationLanguage[];
}
export interface TransliterationLanguage extends Language {
  toScripts: Language[];
}

export type Meaning = {
  pos: string; // part of speech;
  meaning: string[];
  etymology: string;
  references?: any;
};

export type Prompts = {
  translate: string;
};
export type AnalyzeRes = {
  word: string;
  syllables: string[];
  ipa: string;
  pos: POS;
};
type POS = string;

export type WordData = {
  spelling: string;
  lang: string;
  ipa: string;
  meanings: Meaning[];
  references?: any;
};

// app proper
// Mock data for the app
export type UserStats = {
  streakDays: number;
  cardsLearned: number;
  minutesStudied: number;
  dueToday: number;
};
export type UserData = {
  id: number;
  name: string;
  stats: UserStats;
};
export type DeckResponse = {
  lesson: {
    name: string;
    description: string;
    language: string;
    id: number;
    cardCount: number;
  };
  cards: CardResponse[];
};

export interface SRSProgress {
  repetitionCount: number;
  easeFactor: number;
  interval: number;
  nextReviewDate: number;
  lastReviewed: number;
  isMastered: boolean;
}

export interface ReviewResult {
  cardId: number;
  accuracy: number;
  reviewTime: number;
}
export type CardResponse = {
  id: number;
  text: string;
  note: string | null;
  progress: SRSProgress;
  expression: {
    id: number;
    ipa: Array<{ ipa: string; tags: string[] }>;
    spelling: string;
    type: ExpressionType;
    syllables: number | null;
    confidence: number;
    lang: string;
    frequency: number;
    prosody: any;
    senses: Sense[];
    isBookmarked: boolean;
  };
};
export type Sense = {
  etymology: string;
  pos: string;
  forms: Array<{ form: string; tags: string[] }>;
  related: any;
  senses: Array<{ glosses: string[]; links: Array<[string, string]> }>;
};

export type SyllableProsody = { isLong: boolean; tone: number; lang: string };

export interface Deck {
  id: number;
  name: string;
  description: string;
  cardCount: number;
  dueCards: number;
  progress: number;
  language: string;
}

export interface Card {
  id: number;
  front: ReactNode;
  back: ReactNode;
  language: string;
  difficulty: number;
  nextReview: Date;
  interval: number;
  easeFactor: number;
}

export type ExpressionType = "word" | "expression" | "syllable";
export type ExpressionSearchParams = {
  lang?: string;
  spelling?: string;
  pos?: string;
  syllables?: { num: number; sign: string }; // ">" | "<" | "="
  frequency?: { num: number; above: boolean };
  type?: ExpressionType;
};

export type SyllableRes = { input: string; result: SyllableToken[] };
export type SyllableToken = [IPACharacter, SyllablePart];
export type IPACharacter = string; // one char mostly
export enum SyllablePart {
  INITIAL = "#",
  OTHER_ONSET = "C",
  VOWEL = "V",
  OTHER_VOWEL = "v",
  FINAL_VOWEL = ">",
  OTHER_OFFSET = "c",
  CODA = "$",
}

export type ProsodyWordDB = Omit<ProsodyWord, "syllables"> & {
  syllables: string;
};
export interface ProsodyWord {
  id: number;
  spelling: string;
  frequency: number | null;
  lang: string;
  ipa: string;
  tags: string;
  syllables: ProsodySyllable[];
  notes: string | null;
}
// -o is spelling, -/ is ipa
export type ProsodySyllable = {
  ipa: string;
  spelling: string;
  long: boolean;
  notes: string | null;
  onseto: string;
  onset: string;
  nucleuso: string;
  nucleus: string;
  codao: string;
  coda: string;
  rhymeo: string;
  rhyme: string;
  tonen: string;
  tonenm: string;
  tone: string;
};