@translated/lara 1.6.3 → 1.6.5

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.
@@ -1 +1 @@
1
- export declare const version = "1.6.3";
1
+ export declare const version = "1.6.5";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.6.3";
4
+ exports.version = "1.6.5";
@@ -30,6 +30,7 @@ export type DocumentUploadOptions = {
30
30
  adaptTo?: string[];
31
31
  glossaries?: string[];
32
32
  noTrace?: boolean;
33
+ style?: TranslationStyle;
33
34
  };
34
35
  export type DocumentDownloadOptions = {
35
36
  outputFormat?: string;
@@ -95,3 +96,4 @@ export interface GlossaryCounts {
95
96
  unidirectional?: Record<string, number>;
96
97
  multidirectional?: number;
97
98
  }
99
+ export type TranslationStyle = "faithful" | "fluid" | "creative";
@@ -1,7 +1,7 @@
1
1
  import type { Credentials } from "../credentials";
2
2
  import { type LaraClient } from "../net";
3
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 } from "./models";
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
5
  export type TranslatorOptions = {
6
6
  serverUrl?: string;
7
7
  };
@@ -35,6 +35,8 @@ export type TranslateOptions = {
35
35
  cacheTTLSeconds?: number;
36
36
  noTrace?: boolean;
37
37
  verbose?: boolean;
38
+ headers?: Record<string, string>;
39
+ style?: TranslationStyle;
38
40
  };
39
41
  export type DocumentTranslateOptions = DocumentUploadOptions & DocumentDownloadOptions;
40
42
  export type S3UploadFields = {
@@ -119,7 +119,8 @@ class Documents {
119
119
  target,
120
120
  s3key: fields.key,
121
121
  adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo,
122
- glossaries: options === null || options === void 0 ? void 0 : options.glossaries
122
+ glossaries: options === null || options === void 0 ? void 0 : options.glossaries,
123
+ style: options === null || options === void 0 ? void 0 : options.style
123
124
  }, undefined, headers);
124
125
  }
125
126
  async status(id) {
@@ -135,7 +136,8 @@ class Documents {
135
136
  const uploadOptions = {
136
137
  adaptTo: options === null || options === void 0 ? void 0 : options.adaptTo,
137
138
  glossaries: options === null || options === void 0 ? void 0 : options.glossaries,
138
- noTrace: options === null || options === void 0 ? void 0 : options.noTrace
139
+ noTrace: options === null || options === void 0 ? void 0 : options.noTrace,
140
+ style: options === null || options === void 0 ? void 0 : options.style
139
141
  };
140
142
  const { id } = await this.upload(file, filename, source, target, uploadOptions);
141
143
  const downloadOptions = (options === null || options === void 0 ? void 0 : options.outputFormat) ? { outputFormat: options.outputFormat } : undefined;
@@ -227,7 +229,15 @@ class Translator {
227
229
  return await this.client.get("/languages");
228
230
  }
229
231
  async translate(text, source, target, options) {
230
- const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
232
+ const headers = {};
233
+ if (options === null || options === void 0 ? void 0 : options.headers) {
234
+ for (const [name, value] of Object.entries(options.headers)) {
235
+ headers[name] = value;
236
+ }
237
+ }
238
+ if (options === null || options === void 0 ? void 0 : options.noTrace) {
239
+ headers["X-No-Trace"] = "true";
240
+ }
231
241
  return await this.client.post("/translate", {
232
242
  q: text,
233
243
  source,
@@ -242,7 +252,8 @@ class Translator {
242
252
  priority: options === null || options === void 0 ? void 0 : options.priority,
243
253
  use_cache: options === null || options === void 0 ? void 0 : options.useCache,
244
254
  cache_ttl: options === null || options === void 0 ? void 0 : options.cacheTTLSeconds,
245
- verbose: options === null || options === void 0 ? void 0 : options.verbose
255
+ verbose: options === null || options === void 0 ? void 0 : options.verbose,
256
+ style: options === null || options === void 0 ? void 0 : options.style
246
257
  }, undefined, headers);
247
258
  }
248
259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "engines": {