summaryrefslogtreecommitdiff
path: root/src/lib/types
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/types')
-rw-r--r--src/lib/types/cards.ts210
-rw-r--r--src/lib/types/index.ts2
2 files changed, 211 insertions, 1 deletions
diff --git a/src/lib/types/cards.ts b/src/lib/types/cards.ts
new file mode 100644
index 0000000..0592a34
--- /dev/null
+++ b/src/lib/types/cards.ts
@@ -0,0 +1,210 @@
+// 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;
+ progress: SRSProgress;
+ expression: {
+ ipa: Array<{ ipa: string; tags: string[] }>;
+ spelling: string;
+ type: ExpressionType;
+ syllables: number;
+ confidence: number;
+ lang: string;
+ frequency: number;
+ prosody: any;
+ senses: Sense[];
+ };
+};
+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;
+};
diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts
index 0a46643..ce3f5fb 100644
--- a/src/lib/types/index.ts
+++ b/src/lib/types/index.ts
@@ -98,7 +98,7 @@ export type AddSense = {
parent_id: number | bigint;
spelling: string;
etymology?: string;
- pos: string;
+ pos?: string;
ipa?: string;
prosody?: string;
senses?: string;