UNPKG

@translated/lara

Version:

Official Lara SDK for JavaScript and Node.js

60 lines (59 loc) 3.01 kB
import { Credentials } from "../credentials"; import { LaraClient } from "../net"; import { Document, DocumentDownloadOptions, DocumentUploadOptions, Memory, MemoryImport, TextBlock, TextResult } from "./models"; import { MultiPartFile } from "../net/client"; export type TranslatorOptions = { serverUrl?: string; }; export type MemoryImportCallback = (memoryImport: MemoryImport) => void; export declare class Memories { private readonly client; private readonly pollingInterval; constructor(client: LaraClient); list(): Promise<Memory[]>; create(name: string, externalId?: string): Promise<Memory>; get(id: string): Promise<Memory | null>; delete(id: string): Promise<Memory>; update(id: string, name: string): Promise<Memory>; connect<T extends string | string[]>(ids: T): Promise<T extends string ? Memory : Memory[]>; importTmx(id: string, tmx: MultiPartFile, gzip?: boolean): Promise<MemoryImport>; addTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string): Promise<MemoryImport>; deleteTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string): Promise<MemoryImport>; getImportStatus(id: string): Promise<MemoryImport>; waitForImport(mImport: MemoryImport, updateCallback?: MemoryImportCallback, maxWaitTime?: number): Promise<MemoryImport>; } export type TranslateOptions = { sourceHint?: string; adaptTo?: string[]; instructions?: string[]; contentType?: string; multiline?: boolean; timeoutInMillis?: number; priority?: "normal" | "background"; useCache?: boolean | "overwrite"; cacheTTLSeconds?: number; noTrace?: boolean; }; export type DocumentTranslateOptions = DocumentUploadOptions & DocumentDownloadOptions; export type S3UploadFields = { acl: string; bucket: string; key: string; }; export declare class Documents { private readonly client; private readonly s3Client; constructor(client: LaraClient); upload(file: MultiPartFile, filename: string, source: string | null, target: string, options?: DocumentUploadOptions): Promise<Document>; status(id: string): Promise<Document>; download(id: string, options?: DocumentDownloadOptions): Promise<Blob | Buffer>; translate(file: MultiPartFile, filename: string, source: string | null, target: string, options?: DocumentTranslateOptions): Promise<Blob | Buffer>; } export declare class Translator { protected readonly client: LaraClient; readonly memories: Memories; readonly documents: Documents; constructor(credentials: Credentials, options?: TranslatorOptions); getLanguages(): Promise<string[]>; translate<T extends string | string[] | TextBlock[]>(text: T, source: string | null, target: string, options?: TranslateOptions): Promise<TextResult<T>>; }