@translated/lara
Version:
Official Lara SDK for JavaScript and Node.js
58 lines (57 loc) • 2.08 kB
TypeScript
import type { LaraClient } from "./net";
import type { MultiPartFile } from "./net/client";
import type { TranslationStyle } from "./translator";
export type S3UploadFields = {
acl: string;
bucket: string;
key: string;
};
export declare enum DocumentStatus {
INITIALIZED = "initialized",// just been created
ANALYZING = "analyzing",// being analyzed for language detection and chars count
PAUSED = "paused",// paused after analysis, needs user confirm
READY = "ready",// ready to be translated
TRANSLATING = "translating",
TRANSLATED = "translated",
ERROR = "error"
}
export interface DocxExtractionParams {
extractComments?: boolean;
acceptRevisions?: boolean;
}
export type DocumentOptions = {
adaptTo?: string[];
glossaries?: string[];
noTrace?: boolean;
style?: TranslationStyle;
};
export type DocumentDownloadOptions = {
outputFormat?: string;
};
export type DocumentUploadOptions = DocumentOptions & {
password?: string;
extractionParams?: DocxExtractionParams;
};
export interface Document {
readonly id: string;
readonly status: DocumentStatus;
readonly source?: string;
readonly target: string;
readonly filename: string;
readonly createdAt: Date;
readonly updatedAt: Date;
readonly options?: DocumentOptions;
readonly translatedChars?: number;
readonly totalChars?: number;
readonly errorReason?: string;
}
export type DocumentTranslateOptions = DocumentUploadOptions & DocumentDownloadOptions;
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>;
}