@translated/lara 1.6.6 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Documents.d.ts +12 -0
- package/lib/Documents.js +71 -0
- package/lib/Glossaries.d.ts +17 -0
- package/lib/Glossaries.js +68 -0
- package/lib/Memories.d.ts +18 -0
- package/lib/Memories.js +95 -0
- package/lib/Translator.d.ts +24 -0
- package/lib/Translator.js +152 -0
- package/lib/index.d.ts +2 -6
- package/lib/index.js +2 -17
- package/lib/models/Authentication.d.ts +12 -0
- package/lib/models/Authentication.js +1 -0
- package/lib/models/UploadableFile.d.ts +1 -0
- package/lib/models/UploadableFile.js +1 -0
- package/lib/models/documents.d.ts +51 -0
- package/lib/{translator/models.js → models/documents.js} +2 -6
- package/lib/models/glossaries.d.ts +19 -0
- package/lib/models/glossaries.js +1 -0
- package/lib/models/index.d.ts +6 -0
- package/lib/models/index.js +6 -0
- package/lib/models/memories.d.ts +19 -0
- package/lib/models/memories.js +1 -0
- package/lib/models/translator.d.ts +48 -0
- package/lib/models/translator.js +1 -0
- package/lib/sdk-version.js +1 -4
- package/lib/utils/errors.js +12 -0
- package/lib/utils/formdata/browser.d.ts +2 -0
- package/lib/utils/formdata/browser.js +15 -0
- package/lib/utils/formdata/index.d.ts +4 -0
- package/lib/utils/formdata/index.js +10 -0
- package/lib/utils/formdata/node.d.ts +5 -0
- package/lib/utils/formdata/node.js +16 -0
- package/lib/utils/sleep.d.ts +2 -0
- package/lib/utils/sleep.js +1 -0
- package/lib/utils/toCamelCase.d.ts +2 -0
- package/lib/utils/toCamelCase.js +16 -0
- package/lib/utils/toSnakeCase.js +1 -3
- package/package.json +23 -13
- package/lib/credentials.d.ts +0 -5
- package/lib/credentials.js +0 -10
- package/lib/crypto/browser-crypto.d.ts +0 -11
- package/lib/crypto/browser-crypto.js +0 -28
- package/lib/crypto/index.d.ts +0 -3
- package/lib/crypto/index.js +0 -15
- package/lib/crypto/node-crypto.d.ts +0 -6
- package/lib/crypto/node-crypto.js +0 -55
- package/lib/crypto/portable-crypto.d.ts +0 -5
- package/lib/crypto/portable-crypto.js +0 -2
- package/lib/errors.js +0 -18
- package/lib/net/browser-client.d.ts +0 -8
- package/lib/net/browser-client.js +0 -62
- package/lib/net/client.d.ts +0 -34
- package/lib/net/client.js +0 -108
- package/lib/net/index.d.ts +0 -3
- package/lib/net/index.js +0 -23
- package/lib/net/node-client.d.ts +0 -10
- package/lib/net/node-client.js +0 -103
- package/lib/net/s3/browser-client.d.ts +0 -9
- package/lib/net/s3/browser-client.js +0 -28
- package/lib/net/s3/client.d.ts +0 -9
- package/lib/net/s3/client.js +0 -10
- package/lib/net/s3/index.d.ts +0 -3
- package/lib/net/s3/index.js +0 -13
- package/lib/net/s3/node-client.d.ts +0 -10
- package/lib/net/s3/node-client.js +0 -47
- package/lib/translator/models.d.ts +0 -105
- package/lib/translator/translator.d.ts +0 -80
- package/lib/translator/translator.js +0 -265
- /package/lib/{errors.d.ts → utils/errors.d.ts} +0 -0
package/lib/net/node-client.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Readable } from "node:stream";
|
|
2
|
-
import { type BaseURL, type ClientResponse, LaraClient, type MultiPartFile } from "./client";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export declare class NodeLaraClient extends LaraClient {
|
|
5
|
-
private readonly baseUrl;
|
|
6
|
-
private readonly agent;
|
|
7
|
-
constructor(baseUrl: BaseURL, accessKeyId: string, accessKeySecret: string);
|
|
8
|
-
protected send(path: string, headers: Record<string, string>, body?: Record<string, any>): Promise<ClientResponse>;
|
|
9
|
-
protected wrapMultiPartFile(file: MultiPartFile): Readable;
|
|
10
|
-
}
|
package/lib/net/node-client.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NodeLaraClient = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_http_1 = __importDefault(require("node:http"));
|
|
9
|
-
const node_https_1 = __importDefault(require("node:https"));
|
|
10
|
-
const node_stream_1 = require("node:stream");
|
|
11
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
12
|
-
const client_1 = require("./client");
|
|
13
|
-
/** @internal */
|
|
14
|
-
class NodeLaraClient extends client_1.LaraClient {
|
|
15
|
-
constructor(baseUrl, accessKeyId, accessKeySecret) {
|
|
16
|
-
super(accessKeyId, accessKeySecret);
|
|
17
|
-
this.baseUrl = baseUrl;
|
|
18
|
-
this.agent = baseUrl.secure ? new node_https_1.default.Agent({ keepAlive: true }) : new node_http_1.default.Agent({ keepAlive: true });
|
|
19
|
-
}
|
|
20
|
-
async send(path, headers, body) {
|
|
21
|
-
let requestBody;
|
|
22
|
-
if (body) {
|
|
23
|
-
if (headers["Content-Type"] === "multipart/form-data") {
|
|
24
|
-
const formBody = new form_data_1.default();
|
|
25
|
-
for (const [key, value] of Object.entries(body)) {
|
|
26
|
-
if (!value)
|
|
27
|
-
continue;
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
for (const v of value)
|
|
30
|
-
formBody.append(key, v);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
formBody.append(key, value);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
headers = {
|
|
37
|
-
...headers,
|
|
38
|
-
...formBody.getHeaders()
|
|
39
|
-
};
|
|
40
|
-
requestBody = formBody;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
requestBody = JSON.stringify(body, undefined, 0);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
const options = {
|
|
48
|
-
host: this.baseUrl.hostname,
|
|
49
|
-
port: this.baseUrl.port,
|
|
50
|
-
path: path,
|
|
51
|
-
method: "POST",
|
|
52
|
-
headers: headers,
|
|
53
|
-
agent: this.agent
|
|
54
|
-
};
|
|
55
|
-
const req = (this.baseUrl.secure ? node_https_1.default : node_http_1.default).request(options, (res) => {
|
|
56
|
-
let data = "";
|
|
57
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: store response data
|
|
58
|
-
res.on("data", (chunk) => (data += chunk));
|
|
59
|
-
res.on("end", () => {
|
|
60
|
-
var _a;
|
|
61
|
-
let json;
|
|
62
|
-
if ((_a = res.headers["content-type"]) === null || _a === void 0 ? void 0 : _a.includes("text/csv")) {
|
|
63
|
-
return resolve({
|
|
64
|
-
statusCode: res.statusCode,
|
|
65
|
-
body: {
|
|
66
|
-
content: data
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
json = JSON.parse(data);
|
|
72
|
-
}
|
|
73
|
-
catch (_e) {
|
|
74
|
-
reject(new SyntaxError("Invalid JSON response"));
|
|
75
|
-
}
|
|
76
|
-
resolve({
|
|
77
|
-
statusCode: res.statusCode,
|
|
78
|
-
body: json
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
req.on("error", reject);
|
|
83
|
-
if (requestBody instanceof form_data_1.default) {
|
|
84
|
-
requestBody.pipe(req);
|
|
85
|
-
}
|
|
86
|
-
else if (requestBody) {
|
|
87
|
-
req.write(requestBody);
|
|
88
|
-
req.end();
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
req.end();
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
wrapMultiPartFile(file) {
|
|
96
|
-
if (typeof file === "string")
|
|
97
|
-
file = node_fs_1.default.createReadStream(file);
|
|
98
|
-
if (file instanceof node_stream_1.Readable)
|
|
99
|
-
return file;
|
|
100
|
-
throw new TypeError(`Invalid file input in Node.js. Expected a Readable stream or a valid file path, but received ${typeof file}.`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.NodeLaraClient = NodeLaraClient;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { S3UploadFields } from "../../translator/translator";
|
|
2
|
-
import type { MultiPartFile } from "../client";
|
|
3
|
-
import { S3Client } from "./client";
|
|
4
|
-
/** @internal */
|
|
5
|
-
export declare class BrowserS3Client extends S3Client {
|
|
6
|
-
_upload(url: string, fields: S3UploadFields, file: File): Promise<void>;
|
|
7
|
-
download(url: string): Promise<Blob>;
|
|
8
|
-
wrapMultiPartFile(file: MultiPartFile): File;
|
|
9
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BrowserS3Client = void 0;
|
|
4
|
-
const client_1 = require("./client");
|
|
5
|
-
/** @internal */
|
|
6
|
-
class BrowserS3Client extends client_1.S3Client {
|
|
7
|
-
async _upload(url, fields, file) {
|
|
8
|
-
const formdata = new FormData();
|
|
9
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
10
|
-
formdata.append(key, value);
|
|
11
|
-
}
|
|
12
|
-
formdata.append("file", file);
|
|
13
|
-
await fetch(url, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
body: formdata
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
async download(url) {
|
|
19
|
-
const response = await fetch(url);
|
|
20
|
-
return response.blob();
|
|
21
|
-
}
|
|
22
|
-
wrapMultiPartFile(file) {
|
|
23
|
-
if (file instanceof File)
|
|
24
|
-
return file;
|
|
25
|
-
throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof file}.`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.BrowserS3Client = BrowserS3Client;
|
package/lib/net/s3/client.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { S3UploadFields } from "../../translator/translator";
|
|
2
|
-
import type { MultiPartFile } from "../client";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export declare abstract class S3Client {
|
|
5
|
-
upload(url: string, fields: S3UploadFields, file: MultiPartFile): Promise<void>;
|
|
6
|
-
protected abstract _upload(url: string, fields: S3UploadFields, file: any): Promise<void>;
|
|
7
|
-
protected abstract download(url: string): Promise<Blob | Buffer>;
|
|
8
|
-
protected abstract wrapMultiPartFile(file: MultiPartFile): any;
|
|
9
|
-
}
|
package/lib/net/s3/client.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S3Client = void 0;
|
|
4
|
-
/** @internal */
|
|
5
|
-
class S3Client {
|
|
6
|
-
async upload(url, fields, file) {
|
|
7
|
-
return this._upload(url, fields, this.wrapMultiPartFile(file));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.S3Client = S3Client;
|
package/lib/net/s3/index.d.ts
DELETED
package/lib/net/s3/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = create;
|
|
4
|
-
const browser_client_1 = require("./browser-client");
|
|
5
|
-
const node_client_1 = require("./node-client");
|
|
6
|
-
function create() {
|
|
7
|
-
if (typeof window !== "undefined") {
|
|
8
|
-
return new browser_client_1.BrowserS3Client();
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return new node_client_1.NodeS3Client();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Readable } from "node:stream";
|
|
2
|
-
import type { S3UploadFields } from "../../translator/translator";
|
|
3
|
-
import type { MultiPartFile } from "../client";
|
|
4
|
-
import { S3Client } from "./client";
|
|
5
|
-
/** @internal */
|
|
6
|
-
export declare class NodeS3Client extends S3Client {
|
|
7
|
-
protected _upload(url: string, fields: S3UploadFields, file: Readable): Promise<void>;
|
|
8
|
-
download(url: string): Promise<Buffer>;
|
|
9
|
-
wrapMultiPartFile(file: MultiPartFile): Readable;
|
|
10
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NodeS3Client = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_https_1 = __importDefault(require("node:https"));
|
|
9
|
-
const node_stream_1 = require("node:stream");
|
|
10
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
11
|
-
const client_1 = require("./client");
|
|
12
|
-
/** @internal */
|
|
13
|
-
class NodeS3Client extends client_1.S3Client {
|
|
14
|
-
async _upload(url, fields, file) {
|
|
15
|
-
const formData = new form_data_1.default();
|
|
16
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
17
|
-
formData.append(key, value);
|
|
18
|
-
}
|
|
19
|
-
formData.append("file", file);
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
formData.submit(url, (err) => {
|
|
22
|
-
if (err)
|
|
23
|
-
return reject(err);
|
|
24
|
-
resolve();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async download(url) {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
const req = node_https_1.default.request(url, { method: "GET" }, (res) => {
|
|
31
|
-
const chunks = [];
|
|
32
|
-
res.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
33
|
-
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
34
|
-
});
|
|
35
|
-
req.on("error", reject);
|
|
36
|
-
req.end();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
wrapMultiPartFile(file) {
|
|
40
|
-
if (typeof file === "string")
|
|
41
|
-
file = node_fs_1.default.createReadStream(file);
|
|
42
|
-
if (file instanceof node_stream_1.Readable)
|
|
43
|
-
return file;
|
|
44
|
-
throw new TypeError(`Invalid file input in Node.js. Expected a Readable stream or a valid file path, but received ${typeof file}.`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.NodeS3Client = NodeS3Client;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export interface Memory {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly createdAt: Date;
|
|
4
|
-
readonly updatedAt: Date;
|
|
5
|
-
readonly sharedAt: Date;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly externalId?: string;
|
|
8
|
-
readonly secret?: string;
|
|
9
|
-
readonly ownerId: string;
|
|
10
|
-
readonly collaboratorsCount: number;
|
|
11
|
-
}
|
|
12
|
-
export interface MemoryImport {
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly begin: number;
|
|
15
|
-
readonly end: number;
|
|
16
|
-
readonly channel: number;
|
|
17
|
-
readonly size: number;
|
|
18
|
-
readonly progress: number;
|
|
19
|
-
}
|
|
20
|
-
export declare enum DocumentStatus {
|
|
21
|
-
INITIALIZED = "initialized",// just been created
|
|
22
|
-
ANALYZING = "analyzing",// being analyzed for language detection and chars count
|
|
23
|
-
PAUSED = "paused",// paused after analysis, needs user confirm
|
|
24
|
-
READY = "ready",// ready to be translated
|
|
25
|
-
TRANSLATING = "translating",
|
|
26
|
-
TRANSLATED = "translated",
|
|
27
|
-
ERROR = "error"
|
|
28
|
-
}
|
|
29
|
-
export interface DocxExtractionParams {
|
|
30
|
-
extractComments?: boolean;
|
|
31
|
-
acceptRevisions?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export type DocumentOptions = {
|
|
34
|
-
adaptTo?: string[];
|
|
35
|
-
glossaries?: string[];
|
|
36
|
-
noTrace?: boolean;
|
|
37
|
-
style?: TranslationStyle;
|
|
38
|
-
};
|
|
39
|
-
export type DocumentDownloadOptions = {
|
|
40
|
-
outputFormat?: string;
|
|
41
|
-
};
|
|
42
|
-
export type DocumentUploadOptions = DocumentOptions & {
|
|
43
|
-
password?: string;
|
|
44
|
-
extractionParams?: DocxExtractionParams;
|
|
45
|
-
};
|
|
46
|
-
export interface Document {
|
|
47
|
-
readonly id: string;
|
|
48
|
-
readonly status: DocumentStatus;
|
|
49
|
-
readonly source?: string;
|
|
50
|
-
readonly target: string;
|
|
51
|
-
readonly filename: string;
|
|
52
|
-
readonly createdAt: Date;
|
|
53
|
-
readonly updatedAt: Date;
|
|
54
|
-
readonly options?: DocumentOptions;
|
|
55
|
-
readonly translatedChars?: number;
|
|
56
|
-
readonly totalChars?: number;
|
|
57
|
-
readonly errorReason?: string;
|
|
58
|
-
}
|
|
59
|
-
export interface TextBlock {
|
|
60
|
-
readonly text: string;
|
|
61
|
-
readonly translatable?: boolean;
|
|
62
|
-
}
|
|
63
|
-
export interface NGMemoryMatch {
|
|
64
|
-
memory: string;
|
|
65
|
-
tuid?: string;
|
|
66
|
-
language: [string, string];
|
|
67
|
-
sentence: string;
|
|
68
|
-
translation: string;
|
|
69
|
-
score: number;
|
|
70
|
-
}
|
|
71
|
-
export interface NGGlossaryMatch {
|
|
72
|
-
glossary: string;
|
|
73
|
-
language: [string, string];
|
|
74
|
-
term: string;
|
|
75
|
-
translation: string;
|
|
76
|
-
}
|
|
77
|
-
export interface TextResult<T extends string | string[] | TextBlock[]> {
|
|
78
|
-
readonly contentType: string;
|
|
79
|
-
readonly sourceLanguage: string;
|
|
80
|
-
readonly translation: T;
|
|
81
|
-
readonly adaptedTo?: string[];
|
|
82
|
-
readonly glossaries?: string[];
|
|
83
|
-
readonly adaptedToMatches?: NGMemoryMatch[] | NGMemoryMatch[][];
|
|
84
|
-
readonly glossariesMatches?: NGGlossaryMatch[] | NGGlossaryMatch[][];
|
|
85
|
-
}
|
|
86
|
-
export interface Glossary {
|
|
87
|
-
readonly id: string;
|
|
88
|
-
readonly name: string;
|
|
89
|
-
readonly ownerId: string;
|
|
90
|
-
readonly createdAt: Date;
|
|
91
|
-
readonly updatedAt: Date;
|
|
92
|
-
}
|
|
93
|
-
export interface GlossaryImport {
|
|
94
|
-
readonly id: string;
|
|
95
|
-
readonly begin: number;
|
|
96
|
-
readonly end: number;
|
|
97
|
-
readonly channel: number;
|
|
98
|
-
readonly size: number;
|
|
99
|
-
readonly progress: number;
|
|
100
|
-
}
|
|
101
|
-
export interface GlossaryCounts {
|
|
102
|
-
unidirectional?: Record<string, number>;
|
|
103
|
-
multidirectional?: number;
|
|
104
|
-
}
|
|
105
|
-
export type TranslationStyle = "faithful" | "fluid" | "creative";
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Credentials } from "../credentials";
|
|
2
|
-
import { type LaraClient } from "../net";
|
|
3
|
-
import type { MultiPartFile } from "../net/client";
|
|
4
|
-
import { type Document, type DocumentDownloadOptions, type DocumentUploadOptions, type Glossary, type GlossaryCounts, type GlossaryImport, type Memory, type MemoryImport, type TextBlock, type TextResult, type TranslationStyle } from "./models";
|
|
5
|
-
export type TranslatorOptions = {
|
|
6
|
-
serverUrl?: string;
|
|
7
|
-
};
|
|
8
|
-
export type MemoryImportCallback = (memoryImport: MemoryImport) => void;
|
|
9
|
-
export declare class Memories {
|
|
10
|
-
private readonly client;
|
|
11
|
-
private readonly pollingInterval;
|
|
12
|
-
constructor(client: LaraClient);
|
|
13
|
-
list(): Promise<Memory[]>;
|
|
14
|
-
create(name: string, externalId?: string): Promise<Memory>;
|
|
15
|
-
get(id: string): Promise<Memory | null>;
|
|
16
|
-
delete(id: string): Promise<Memory>;
|
|
17
|
-
update(id: string, name: string): Promise<Memory>;
|
|
18
|
-
connect<T extends string | string[]>(ids: T): Promise<T extends string ? Memory : Memory[]>;
|
|
19
|
-
importTmx(id: string, tmx: MultiPartFile, gzip?: boolean): Promise<MemoryImport>;
|
|
20
|
-
addTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string, headers?: Record<string, string>): Promise<MemoryImport>;
|
|
21
|
-
deleteTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string): Promise<MemoryImport>;
|
|
22
|
-
getImportStatus(id: string): Promise<MemoryImport>;
|
|
23
|
-
waitForImport(mImport: MemoryImport, updateCallback?: MemoryImportCallback, maxWaitTime?: number): Promise<MemoryImport>;
|
|
24
|
-
}
|
|
25
|
-
export type TranslateOptions = {
|
|
26
|
-
sourceHint?: string;
|
|
27
|
-
adaptTo?: string[];
|
|
28
|
-
instructions?: string[];
|
|
29
|
-
glossaries?: string[];
|
|
30
|
-
contentType?: string;
|
|
31
|
-
multiline?: boolean;
|
|
32
|
-
timeoutInMillis?: number;
|
|
33
|
-
priority?: "normal" | "background";
|
|
34
|
-
useCache?: boolean | "overwrite";
|
|
35
|
-
cacheTTLSeconds?: number;
|
|
36
|
-
noTrace?: boolean;
|
|
37
|
-
verbose?: boolean;
|
|
38
|
-
headers?: Record<string, string>;
|
|
39
|
-
style?: TranslationStyle;
|
|
40
|
-
};
|
|
41
|
-
export type DocumentTranslateOptions = DocumentUploadOptions & DocumentDownloadOptions;
|
|
42
|
-
export type S3UploadFields = {
|
|
43
|
-
acl: string;
|
|
44
|
-
bucket: string;
|
|
45
|
-
key: string;
|
|
46
|
-
};
|
|
47
|
-
export declare class Documents {
|
|
48
|
-
private readonly client;
|
|
49
|
-
private readonly s3Client;
|
|
50
|
-
constructor(client: LaraClient);
|
|
51
|
-
upload(file: MultiPartFile, filename: string, source: string | null, target: string, options?: DocumentUploadOptions): Promise<Document>;
|
|
52
|
-
status(id: string): Promise<Document>;
|
|
53
|
-
download(id: string, options?: DocumentDownloadOptions): Promise<Blob | Buffer>;
|
|
54
|
-
translate(file: MultiPartFile, filename: string, source: string | null, target: string, options?: DocumentTranslateOptions): Promise<Blob | Buffer>;
|
|
55
|
-
}
|
|
56
|
-
export type GlossaryImportCallback = (glossaryImport: GlossaryImport) => void;
|
|
57
|
-
export declare class Glossaries {
|
|
58
|
-
private readonly client;
|
|
59
|
-
private readonly pollingInterval;
|
|
60
|
-
constructor(client: LaraClient);
|
|
61
|
-
list(): Promise<Glossary[]>;
|
|
62
|
-
create(name: string): Promise<Glossary>;
|
|
63
|
-
get(id: string): Promise<Glossary | null>;
|
|
64
|
-
delete(id: string): Promise<Glossary>;
|
|
65
|
-
update(id: string, name: string): Promise<Glossary>;
|
|
66
|
-
importCsv(id: string, csv: MultiPartFile, gzip?: boolean): Promise<GlossaryImport>;
|
|
67
|
-
getImportStatus(id: string): Promise<GlossaryImport>;
|
|
68
|
-
waitForImport(gImport: GlossaryImport, updateCallback?: GlossaryImportCallback, maxWaitTime?: number): Promise<GlossaryImport>;
|
|
69
|
-
counts(id: string): Promise<GlossaryCounts>;
|
|
70
|
-
export(id: string, contentType: "csv/table-uni", source?: string): Promise<string>;
|
|
71
|
-
}
|
|
72
|
-
export declare class Translator {
|
|
73
|
-
protected readonly client: LaraClient;
|
|
74
|
-
readonly memories: Memories;
|
|
75
|
-
readonly documents: Documents;
|
|
76
|
-
readonly glossaries: Glossaries;
|
|
77
|
-
constructor(credentials: Credentials, options?: TranslatorOptions);
|
|
78
|
-
getLanguages(): Promise<string[]>;
|
|
79
|
-
translate<T extends string | string[] | TextBlock[]>(text: T, source: string | null, target: string, options?: TranslateOptions): Promise<TextResult<T>>;
|
|
80
|
-
}
|