Files
Ivan Rezchikov 628dd6384b
Build and Deploy / test-backend (push) Successful in 1m11s
Build and Deploy / lint-frontend (push) Successful in 21s
Build and Deploy / build-backend (push) Successful in 58s
Build and Deploy / deploy (push) Canceled after 0s
Build and Deploy / build-frontend (push) Canceled after 5m38s
version 1
2026-09-18 00:45:51 +03:00

132 lines
2.4 KiB
TypeScript

export const LANGUAGE_CODES = ["en", "it", "ru"] as const;
export type Language = (typeof LANGUAGE_CODES)[number];
export type Source = "provider" | "cache";
export const PARTS_OF_SPEECH = [
"noun",
"verb",
"adjective",
"adverb",
"pronoun",
] as const;
export type PartOfSpeech = (typeof PARTS_OF_SPEECH)[number] | (string & {});
export function isLanguage(value: string): value is Language {
return (LANGUAGE_CODES as readonly string[]).includes(value);
}
export function parseLanguage(value: string): Language | null {
const normalized = value.trim().toLowerCase();
return isLanguage(normalized) ? normalized : null;
}
export interface Form {
word: string;
tags?: string[];
}
export interface Quote {
text: string;
reference: string;
}
export interface Sense {
definition: string;
tags?: string[];
examples?: string[];
quotes?: Quote[];
synonyms?: string[];
antonyms?: string[];
}
export interface Entry {
language: Language;
partOfSpeech: PartOfSpeech;
ipa?: string;
forms?: Form[];
senses: Sense[];
synonyms?: string[];
antonyms?: string[];
}
export interface TranslationResult {
source_text: string;
source_lang: Language;
target_lang: Language;
translations: string[];
provider: string;
model?: string;
source: Source;
generated_at?: string;
}
export interface DictionaryResult {
word: string;
entries: Entry[];
provider: string;
model?: string;
source: Source;
generated_at?: string;
}
export interface CollocationsResult {
word: string;
lang: Language;
provider: string;
model?: string;
source: Source;
collocations: string[];
generated_at?: string;
}
export interface ExamplesResult {
word: string;
lang: Language;
provider: string;
model?: string;
source: Source;
examples: string[];
generated_at?: string;
}
export interface DeepLUsage {
character_count: number;
character_limit: number;
}
export interface AIUsage {
requests: number;
tokens: number;
token_limit: number;
}
export interface UsageResult {
deepl?: DeepLUsage;
ai: AIUsage;
}
export type CollectionType = "auto" | "user";
export interface CollectionResult {
id: string;
name: string;
lang: Language;
userId: string;
words: string[];
type: CollectionType;
updated_at: string;
created_at: string;
}
export type Fetched<T> = T & { fetched_at: string };
export interface User {
id: string;
email: string;
first_name: string;
second_name: string;
created_at: string;
}