UNPKG

@deeplx/core

Version:

An unofficial but powerful and easy-to-use yet free DeepL API client for Node.js using [DeepL](https://www.deepl.com) by porting [OwO-Network/DeepLX](https://github.com/OwO-Network/DeepLX).

81 lines (80 loc) 2.03 kB
import type { FormalityTone, SourceLanguage, TargetLanguage } from './constants.ts'; export type ValueOf<T> = T extends ReadonlyArray<infer R> ? R : T extends Set<infer R> ? R : T[keyof T]; export interface Lang { source_lang_user_selected: string; target_lang: string; source_lang_computed?: string; } export interface CommonJobParams { formality: FormalityTone; transcribe_as: string; mode: string; wasSpoken: boolean; advancedMode: boolean; textType: string; regionalVariant?: string; } export interface Sentence { prefix: string; text: string; id: number; } export interface Job { kind: string; preferred_num_beams: number; raw_en_context_before: string[]; raw_en_context_after: string[]; sentences: Sentence[]; } export interface Params { commonJobParams: CommonJobParams; lang: Lang; jobs: Job[]; timestamp: number; } export interface PostData { jsonrpc: string; method: string; id: number; params: Params; } export interface TranslationBeam { sentences: SentenceResponse[]; num_symbols: number; rephrase_variant: { name: string; }; } export interface Translation { beams: TranslationBeam[]; quality: string; } export interface TranslationResponse { jsonrpc: string; id: number; result: { translations: Translation[]; target_lang: string; source_lang: string; source_lang_is_confident: boolean; detectedLanguages: Record<string, string>; }; } export interface SentenceResponse { text: string; ids: number[]; } export interface DeepLXTranslationErrorResult { code: number; message: string; } export interface DeepLXTranslationSuccessResult { code: number; id: number; data: string; alternatives: string[]; sourceLang: SourceLanguage; targetLang: TargetLanguage; method: 'Free' | 'Pro'; } export type DeepLXTranslationResult = DeepLXTranslationErrorResult | DeepLXTranslationSuccessResult;