@translated/lara 1.6.0 → 1.6.2

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,4 +1,4 @@
1
- import { PortableCrypto } from "./portable-crypto";
1
+ import type { PortableCrypto } from "./portable-crypto";
2
2
  /** @internal */
3
3
  export declare class BrowserCrypto implements PortableCrypto {
4
4
  private readonly subtle;
@@ -12,14 +12,14 @@ class BrowserCrypto {
12
12
  async digest(data) {
13
13
  const encoder = new TextEncoder();
14
14
  const buffer = (await this.subtle.digest("sha-256", encoder.encode(data))).slice(0, 16);
15
- return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('');
15
+ return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, "0")).join("");
16
16
  }
17
17
  async hmac(key, data) {
18
18
  const encoder = new TextEncoder();
19
19
  encoder.encode(data);
20
20
  const cKey = await this.subtle.importKey("raw", encoder.encode(key), {
21
21
  name: "hmac",
22
- hash: { name: "sha-256" },
22
+ hash: { name: "sha-256" }
23
23
  }, false, ["sign"]);
24
24
  const buffer = await this.subtle.sign("hmac", cKey, encoder.encode(data));
25
25
  return btoa(String.fromCharCode(...new Uint8Array(buffer)));
@@ -1,3 +1,3 @@
1
- import { PortableCrypto } from "./portable-crypto";
1
+ import type { PortableCrypto } from "./portable-crypto";
2
2
  export { PortableCrypto } from "./portable-crypto";
3
3
  export default function instance(): PortableCrypto;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = instance;
4
4
  const browser_crypto_1 = require("./browser-crypto");
5
5
  const node_crypto_1 = require("./node-crypto");
6
- let _instance = undefined;
6
+ let _instance;
7
7
  function instance() {
8
8
  if (_instance === undefined) {
9
9
  if (typeof window !== "undefined")
@@ -1,4 +1,4 @@
1
- import { PortableCrypto } from "./portable-crypto";
1
+ import type { PortableCrypto } from "./portable-crypto";
2
2
  /** @internal */
3
3
  export declare class NodeCrypto implements PortableCrypto {
4
4
  digest(data: string): Promise<string>;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.NodeCrypto = void 0;
37
- const crypto = __importStar(require("crypto"));
37
+ const crypto = __importStar(require("node:crypto"));
38
38
  /** @internal */
39
39
  class NodeCrypto {
40
40
  digest(data) {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { version } from "./sdk-version";
2
1
  export { Credentials } from "./credentials";
3
- export { LaraError, TimeoutError, LaraApiError } from "./errors";
4
- export { Translator, TranslatorOptions, Memories, MemoryImportCallback, TranslateOptions, Documents, DocumentTranslateOptions } from "./translator/translator";
5
- export { Memory, MemoryImport, TextBlock, TextResult, Document, DocumentStatus, DocumentUploadOptions, DocumentDownloadOptions } from "./translator/models";
2
+ export { LaraApiError, LaraError, TimeoutError } from "./errors";
6
3
  export { MultiPartFile } from "./net/client";
4
+ export { version } from "./sdk-version";
5
+ export { Document, DocumentDownloadOptions, DocumentStatus, DocumentUploadOptions, Memory, MemoryImport, NGGlossaryMatch, NGMemoryMatch, TextBlock, TextResult } from "./translator/models";
6
+ export { Documents, DocumentTranslateOptions, Memories, MemoryImportCallback, TranslateOptions, Translator, TranslatorOptions } from "./translator/translator";
package/lib/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocumentStatus = exports.Documents = exports.Memories = exports.Translator = exports.LaraApiError = exports.TimeoutError = exports.LaraError = exports.Credentials = exports.version = void 0;
4
- var sdk_version_1 = require("./sdk-version");
5
- Object.defineProperty(exports, "version", { enumerable: true, get: function () { return sdk_version_1.version; } });
3
+ exports.Translator = exports.Memories = exports.Documents = exports.DocumentStatus = exports.version = exports.TimeoutError = exports.LaraError = exports.LaraApiError = exports.Credentials = void 0;
6
4
  var credentials_1 = require("./credentials");
7
5
  Object.defineProperty(exports, "Credentials", { enumerable: true, get: function () { return credentials_1.Credentials; } });
8
6
  var errors_1 = require("./errors");
7
+ Object.defineProperty(exports, "LaraApiError", { enumerable: true, get: function () { return errors_1.LaraApiError; } });
9
8
  Object.defineProperty(exports, "LaraError", { enumerable: true, get: function () { return errors_1.LaraError; } });
10
9
  Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
11
- Object.defineProperty(exports, "LaraApiError", { enumerable: true, get: function () { return errors_1.LaraApiError; } });
12
- var translator_1 = require("./translator/translator");
13
- Object.defineProperty(exports, "Translator", { enumerable: true, get: function () { return translator_1.Translator; } });
14
- Object.defineProperty(exports, "Memories", { enumerable: true, get: function () { return translator_1.Memories; } });
15
- Object.defineProperty(exports, "Documents", { enumerable: true, get: function () { return translator_1.Documents; } });
10
+ var sdk_version_1 = require("./sdk-version");
11
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return sdk_version_1.version; } });
16
12
  var models_1 = require("./translator/models");
17
13
  Object.defineProperty(exports, "DocumentStatus", { enumerable: true, get: function () { return models_1.DocumentStatus; } });
14
+ var translator_1 = require("./translator/translator");
15
+ Object.defineProperty(exports, "Documents", { enumerable: true, get: function () { return translator_1.Documents; } });
16
+ Object.defineProperty(exports, "Memories", { enumerable: true, get: function () { return translator_1.Memories; } });
17
+ Object.defineProperty(exports, "Translator", { enumerable: true, get: function () { return translator_1.Translator; } });
@@ -1,4 +1,4 @@
1
- import { BaseURL, ClientResponse, LaraClient, MultiPartFile } from "./client";
1
+ import { type BaseURL, type ClientResponse, LaraClient, type MultiPartFile } from "./client";
2
2
  /** @internal */
3
3
  export declare class BrowserLaraClient extends LaraClient {
4
4
  private readonly baseUrl;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserLaraClient = void 0;
4
4
  const client_1 = require("./client");
5
5
  function hasDefaultPort(port, secure) {
6
- return port === 80 && !secure || port === 443 && secure;
6
+ return (port === 80 && !secure) || (port === 443 && secure);
7
7
  }
8
8
  /** @internal */
9
9
  class BrowserLaraClient extends client_1.LaraClient {
@@ -16,7 +16,7 @@ class BrowserLaraClient extends client_1.LaraClient {
16
16
  }
17
17
  async send(path, headers, body) {
18
18
  var _a;
19
- let requestBody = undefined;
19
+ let requestBody;
20
20
  if (body) {
21
21
  if (headers["Content-Type"] === "multipart/form-data") {
22
22
  delete headers["Content-Type"]; // browser will set it automatically
@@ -25,7 +25,7 @@ class BrowserLaraClient extends client_1.LaraClient {
25
25
  if (!value)
26
26
  continue;
27
27
  if (Array.isArray(value))
28
- value.forEach(v => formBody.append(key, v));
28
+ value.forEach((v) => formBody.append(key, v));
29
29
  else
30
30
  formBody.append(key, value);
31
31
  }
@@ -1,4 +1,4 @@
1
- import { Readable } from "node:stream";
1
+ import type { Readable } from "node:stream";
2
2
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
3
3
  /** @internal */
4
4
  export type BaseURL = {
package/lib/net/client.js CHANGED
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LaraClient = void 0;
7
- const sdk_version_1 = require("../sdk-version");
8
7
  const crypto_1 = __importDefault(require("../crypto"));
9
8
  const errors_1 = require("../errors");
9
+ const sdk_version_1 = require("../sdk-version");
10
10
  function parseContent(content) {
11
11
  if (content === undefined || content === null)
12
12
  return content;
@@ -19,7 +19,7 @@ function parseContent(content) {
19
19
  else
20
20
  return content;
21
21
  }
22
- if (typeof content == "object") {
22
+ if (typeof content === "object") {
23
23
  const result = {};
24
24
  for (const [key, value] of Object.entries(content)) {
25
25
  const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
@@ -54,12 +54,12 @@ class LaraClient {
54
54
  }
55
55
  async request(method, path, body, files, headers) {
56
56
  if (!path.startsWith("/"))
57
- path = "/" + path;
57
+ path = `/${path}`;
58
58
  const _headers = {
59
59
  "X-HTTP-Method-Override": method,
60
60
  "X-Lara-Date": new Date().toUTCString(),
61
61
  "X-Lara-SDK-Name": "lara-node",
62
- 'X-Lara-SDK-Version': sdk_version_1.version,
62
+ "X-Lara-SDK-Version": sdk_version_1.version,
63
63
  ...this.extraHeaders,
64
64
  ...headers
65
65
  };
@@ -72,7 +72,7 @@ class LaraClient {
72
72
  _headers["Content-MD5"] = await this.crypto.digest(jsonBody);
73
73
  }
74
74
  }
75
- let requestBody = undefined;
75
+ let requestBody;
76
76
  if (files) {
77
77
  // validate files
78
78
  for (const [key, file] of Object.entries(files))
@@ -86,7 +86,7 @@ class LaraClient {
86
86
  requestBody = body;
87
87
  }
88
88
  const signature = await this.sign(method, path, _headers);
89
- _headers["Authorization"] = `Lara ${this.accessKeyId}:${signature}`;
89
+ _headers.Authorization = `Lara ${this.accessKeyId}:${signature}`;
90
90
  const response = await this.send(path, _headers, requestBody);
91
91
  if (200 <= response.statusCode && response.statusCode < 300) {
92
92
  return parseContent(response.body.content);
@@ -1,3 +1,3 @@
1
- import { LaraClient } from "./client";
1
+ import type { LaraClient } from "./client";
2
2
  export { LaraClient } from "./client";
3
3
  export default function create(accessKeyId: string, accessKeySecret: string, baseUrl?: string): LaraClient;
package/lib/net/index.js CHANGED
@@ -10,7 +10,7 @@ const DEFAULT_BASE_URL = "https://api.laratranslate.com";
10
10
  function create(accessKeyId, accessKeySecret, baseUrl) {
11
11
  const url = new URL(baseUrl || DEFAULT_BASE_URL);
12
12
  if (url.protocol !== "https:" && url.protocol !== "http:")
13
- throw new TypeError("Invalid URL (protocol): " + url.protocol);
13
+ throw new TypeError(`Invalid URL (protocol): ${url.protocol}`);
14
14
  const parsedURL = {
15
15
  secure: url.protocol === "https:",
16
16
  hostname: url.hostname,
@@ -1,5 +1,5 @@
1
- import { Readable } from "stream";
2
- import { BaseURL, ClientResponse, LaraClient, MultiPartFile } from "./client";
1
+ import { Readable } from "node:stream";
2
+ import { type BaseURL, type ClientResponse, LaraClient, type MultiPartFile } from "./client";
3
3
  /** @internal */
4
4
  export declare class NodeLaraClient extends LaraClient {
5
5
  private readonly baseUrl;
@@ -4,21 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
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");
7
11
  const form_data_1 = __importDefault(require("form-data"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const http_1 = __importDefault(require("http"));
10
- const https_1 = __importDefault(require("https"));
11
- const stream_1 = require("stream");
12
12
  const client_1 = require("./client");
13
13
  /** @internal */
14
14
  class NodeLaraClient extends client_1.LaraClient {
15
15
  constructor(baseUrl, accessKeyId, accessKeySecret) {
16
16
  super(accessKeyId, accessKeySecret);
17
17
  this.baseUrl = baseUrl;
18
- this.agent = baseUrl.secure ? new https_1.default.Agent({ keepAlive: true }) : new http_1.default.Agent({ keepAlive: true });
18
+ this.agent = baseUrl.secure ? new node_https_1.default.Agent({ keepAlive: true }) : new node_http_1.default.Agent({ keepAlive: true });
19
19
  }
20
20
  async send(path, headers, body) {
21
- let requestBody = undefined;
21
+ let requestBody;
22
22
  if (body) {
23
23
  if (headers["Content-Type"] === "multipart/form-data") {
24
24
  const formBody = new form_data_1.default();
@@ -26,7 +26,7 @@ class NodeLaraClient extends client_1.LaraClient {
26
26
  if (!value)
27
27
  continue;
28
28
  if (Array.isArray(value))
29
- value.forEach(v => formBody.append(key, v));
29
+ value.forEach((v) => formBody.append(key, v));
30
30
  else
31
31
  formBody.append(key, value);
32
32
  }
@@ -49,13 +49,14 @@ class NodeLaraClient extends client_1.LaraClient {
49
49
  headers: headers,
50
50
  agent: this.agent
51
51
  };
52
- const req = (this.baseUrl.secure ? https_1.default : http_1.default).request(options, (res) => {
52
+ const req = (this.baseUrl.secure ? node_https_1.default : node_http_1.default).request(options, (res) => {
53
53
  let data = "";
54
- res.on("data", (chunk) => data += chunk);
54
+ // biome-ignore lint/suspicious/noAssignInExpressions: store response data
55
+ res.on("data", (chunk) => (data += chunk));
55
56
  res.on("end", () => {
56
57
  var _a;
57
58
  let json;
58
- if ((_a = res.headers['content-type']) === null || _a === void 0 ? void 0 : _a.includes('text/csv')) {
59
+ if ((_a = res.headers["content-type"]) === null || _a === void 0 ? void 0 : _a.includes("text/csv")) {
59
60
  return resolve({
60
61
  statusCode: res.statusCode,
61
62
  body: {
@@ -66,7 +67,7 @@ class NodeLaraClient extends client_1.LaraClient {
66
67
  try {
67
68
  json = JSON.parse(data);
68
69
  }
69
- catch (e) {
70
+ catch (_e) {
70
71
  reject(new SyntaxError("Invalid JSON response"));
71
72
  }
72
73
  resolve({
@@ -89,9 +90,9 @@ class NodeLaraClient extends client_1.LaraClient {
89
90
  });
90
91
  }
91
92
  wrapMultiPartFile(file) {
92
- if (typeof file === 'string')
93
- file = fs_1.default.createReadStream(file);
94
- if (file instanceof stream_1.Readable)
93
+ if (typeof file === "string")
94
+ file = node_fs_1.default.createReadStream(file);
95
+ if (file instanceof node_stream_1.Readable)
95
96
  return file;
96
97
  throw new TypeError(`Invalid file input in Node.js. Expected a Readable stream or a valid file path, but received ${typeof file}.`);
97
98
  }
@@ -1,9 +1,8 @@
1
+ import type { S3UploadFields } from "../../translator/translator";
2
+ import type { MultiPartFile } from "../client";
1
3
  import { S3Client } from "./client";
2
- import { S3UploadFields } from "../../translator/translator";
3
- import { MultiPartFile } from "../client";
4
4
  /** @internal */
5
5
  export declare class BrowserS3Client extends S3Client {
6
- constructor();
7
6
  _upload(url: string, fields: S3UploadFields, file: File): Promise<void>;
8
7
  download(url: string): Promise<Blob>;
9
8
  wrapMultiPartFile(file: MultiPartFile): File;
@@ -4,9 +4,6 @@ exports.BrowserS3Client = void 0;
4
4
  const client_1 = require("./client");
5
5
  /** @internal */
6
6
  class BrowserS3Client extends client_1.S3Client {
7
- constructor() {
8
- super();
9
- }
10
7
  async _upload(url, fields, file) {
11
8
  const formdata = new FormData();
12
9
  for (const [key, value] of Object.entries(fields)) {
@@ -14,8 +11,8 @@ class BrowserS3Client extends client_1.S3Client {
14
11
  }
15
12
  formdata.append("file", file);
16
13
  await fetch(url, {
17
- method: 'POST',
18
- body: formdata,
14
+ method: "POST",
15
+ body: formdata
19
16
  });
20
17
  }
21
18
  async download(url) {
@@ -1,5 +1,5 @@
1
- import { S3UploadFields } from "../../translator/translator";
2
- import { MultiPartFile } from "../client";
1
+ import type { S3UploadFields } from "../../translator/translator";
2
+ import type { MultiPartFile } from "../client";
3
3
  /** @internal */
4
4
  export declare abstract class S3Client {
5
5
  upload(url: string, fields: S3UploadFields, file: MultiPartFile): Promise<void>;
@@ -1,7 +1,7 @@
1
+ import { Readable } from "node:stream";
2
+ import type { S3UploadFields } from "../../translator/translator";
3
+ import type { MultiPartFile } from "../client";
1
4
  import { S3Client } from "./client";
2
- import { Readable } from "stream";
3
- import { S3UploadFields } from "../../translator/translator";
4
- import { MultiPartFile } from "../client";
5
5
  /** @internal */
6
6
  export declare class NodeS3Client extends S3Client {
7
7
  protected _upload(url: string, fields: S3UploadFields, file: Readable): Promise<void>;
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NodeS3Client = void 0;
7
- const client_1 = require("./client");
8
- const stream_1 = require("stream");
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");
9
10
  const form_data_1 = __importDefault(require("form-data"));
10
- const https_1 = __importDefault(require("https"));
11
- const fs_1 = __importDefault(require("fs"));
11
+ const client_1 = require("./client");
12
12
  /** @internal */
13
13
  class NodeS3Client extends client_1.S3Client {
14
14
  async _upload(url, fields, file) {
@@ -27,19 +27,19 @@ class NodeS3Client extends client_1.S3Client {
27
27
  }
28
28
  async download(url) {
29
29
  return new Promise((resolve, reject) => {
30
- const req = https_1.default.request(url, { method: 'GET' }, (res) => {
30
+ const req = node_https_1.default.request(url, { method: "GET" }, (res) => {
31
31
  const chunks = [];
32
- res.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
33
- res.on('end', () => resolve(Buffer.concat(chunks)));
32
+ res.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
33
+ res.on("end", () => resolve(Buffer.concat(chunks)));
34
34
  });
35
- req.on('error', reject);
35
+ req.on("error", reject);
36
36
  req.end();
37
37
  });
38
38
  }
39
39
  wrapMultiPartFile(file) {
40
- if (typeof file === 'string')
41
- file = fs_1.default.createReadStream(file);
42
- if (file instanceof stream_1.Readable)
40
+ if (typeof file === "string")
41
+ file = node_fs_1.default.createReadStream(file);
42
+ if (file instanceof node_stream_1.Readable)
43
43
  return file;
44
44
  throw new TypeError(`Invalid file input in Node.js. Expected a Readable stream or a valid file path, but received ${typeof file}.`);
45
45
  }
@@ -1 +1 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.6.2";
@@ -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.0";
4
+ exports.version = "1.6.2";
@@ -53,11 +53,29 @@ export interface TextBlock {
53
53
  readonly text: string;
54
54
  readonly translatable?: boolean;
55
55
  }
56
+ export interface NGMemoryMatch {
57
+ memory: string;
58
+ tuid?: string;
59
+ source: string;
60
+ target: string;
61
+ sentence: string;
62
+ translation: string;
63
+ score: number;
64
+ }
65
+ export interface NGGlossaryMatch {
66
+ memory: string;
67
+ language: [string, string];
68
+ term: string;
69
+ translation: string;
70
+ }
56
71
  export interface TextResult<T extends string | string[] | TextBlock[]> {
57
72
  readonly contentType: string;
58
73
  readonly sourceLanguage: string;
59
74
  readonly translation: T;
60
75
  readonly adaptedTo?: string[];
76
+ readonly glossaries?: string[];
77
+ readonly adaptedToMatches?: NGMemoryMatch[] | NGMemoryMatch[][];
78
+ readonly glossariesMatches?: NGGlossaryMatch[] | NGGlossaryMatch[][];
61
79
  }
62
80
  export interface Glossary {
63
81
  readonly id: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentStatus = void 0;
4
+ // biome-ignore format: keep comments aligned
4
5
  var DocumentStatus;
5
6
  (function (DocumentStatus) {
6
7
  DocumentStatus["INITIALIZED"] = "initialized";
@@ -1,7 +1,7 @@
1
- import { Credentials } from "../credentials";
2
- import { LaraClient } from "../net";
3
- import { Document, DocumentDownloadOptions, DocumentUploadOptions, Glossary, GlossaryCounts, GlossaryImport, Memory, MemoryImport, TextBlock, TextResult } from "./models";
4
- import { MultiPartFile } from "../net/client";
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 } from "./models";
5
5
  export type TranslatorOptions = {
6
6
  serverUrl?: string;
7
7
  };
@@ -65,7 +65,7 @@ export declare class Glossaries {
65
65
  getImportStatus(id: string): Promise<GlossaryImport>;
66
66
  waitForImport(gImport: GlossaryImport, updateCallback?: GlossaryImportCallback, maxWaitTime?: number): Promise<GlossaryImport>;
67
67
  counts(id: string): Promise<GlossaryCounts>;
68
- export(id: string, contentType: 'csv/table-uni', source?: string): Promise<string>;
68
+ export(id: string, contentType: "csv/table-uni", source?: string): Promise<string>;
69
69
  }
70
70
  export declare class Translator {
71
71
  protected readonly client: LaraClient;
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Translator = exports.Glossaries = exports.Documents = exports.Memories = void 0;
7
+ const errors_1 = require("../errors");
7
8
  const net_1 = __importDefault(require("../net"));
8
9
  const s3_1 = __importDefault(require("../net/s3"));
9
10
  const models_1 = require("./models");
10
- const errors_1 = require("../errors");
11
11
  class Memories {
12
12
  constructor(client) {
13
13
  this.client = client;
@@ -18,7 +18,8 @@ class Memories {
18
18
  }
19
19
  async create(name, externalId) {
20
20
  return await this.client.post("/memories", {
21
- name, external_id: externalId
21
+ name,
22
+ external_id: externalId
22
23
  });
23
24
  }
24
25
  async get(id) {
@@ -46,7 +47,7 @@ class Memories {
46
47
  }
47
48
  async importTmx(id, tmx, gzip = false) {
48
49
  return await this.client.post(`/memories/${id}/import`, {
49
- compression: gzip ? 'gzip' : undefined
50
+ compression: gzip ? "gzip" : undefined
50
51
  }, {
51
52
  tmx
52
53
  });
@@ -92,10 +93,10 @@ class Memories {
92
93
  }
93
94
  async waitForImport(mImport, updateCallback, maxWaitTime) {
94
95
  const start = Date.now();
95
- while (mImport.progress < 1.) {
96
+ while (mImport.progress < 1.0) {
96
97
  if (maxWaitTime && Date.now() - start > maxWaitTime)
97
98
  throw new errors_1.TimeoutError();
98
- await new Promise(resolve => setTimeout(resolve, this.pollingInterval));
99
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
99
100
  mImport = await this.getImportStatus(mImport.id);
100
101
  if (updateCallback)
101
102
  updateCallback(mImport);
@@ -112,13 +113,13 @@ class Documents {
112
113
  async upload(file, filename, source, target, options) {
113
114
  const { url, fields } = await this.client.get(`/documents/upload-url`, { filename });
114
115
  await this.s3Client.upload(url, fields, file);
115
- const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { 'X-No-Trace': 'true' } : {};
116
- return this.client.post('/documents', {
116
+ const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
117
+ return this.client.post("/documents", {
117
118
  source,
118
119
  target,
119
120
  s3key: fields.key,
120
121
  adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo,
121
- glossaries: options === null || options === void 0 ? void 0 : options.glossaries,
122
+ glossaries: options === null || options === void 0 ? void 0 : options.glossaries
122
123
  }, undefined, headers);
123
124
  }
124
125
  async status(id) {
@@ -126,7 +127,7 @@ class Documents {
126
127
  }
127
128
  async download(id, options) {
128
129
  const { url } = await this.client.get(`/documents/${id}/download-url`, {
129
- output_format: options === null || options === void 0 ? void 0 : options.outputFormat,
130
+ output_format: options === null || options === void 0 ? void 0 : options.outputFormat
130
131
  });
131
132
  return await this.s3Client.download(url);
132
133
  }
@@ -142,7 +143,7 @@ class Documents {
142
143
  const maxWaitTime = 1000 * 60 * 15; // 15 minutes
143
144
  const start = Date.now();
144
145
  while (Date.now() - start < maxWaitTime) {
145
- await new Promise(resolve => setTimeout(resolve, pollingInterval));
146
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
146
147
  const { status, errorReason } = await this.status(id);
147
148
  if (status === models_1.DocumentStatus.TRANSLATED)
148
149
  return await this.download(id, downloadOptions);
@@ -160,10 +161,10 @@ class Glossaries {
160
161
  this.pollingInterval = 2000;
161
162
  }
162
163
  async list() {
163
- return await this.client.get('/glossaries');
164
+ return await this.client.get("/glossaries");
164
165
  }
165
166
  async create(name) {
166
- return await this.client.post('/glossaries', { name });
167
+ return await this.client.post("/glossaries", { name });
167
168
  }
168
169
  async get(id) {
169
170
  try {
@@ -184,7 +185,7 @@ class Glossaries {
184
185
  }
185
186
  async importCsv(id, csv, gzip = false) {
186
187
  return await this.client.post(`/glossaries/${id}/import`, {
187
- compression: gzip ? 'gzip' : undefined
188
+ compression: gzip ? "gzip" : undefined
188
189
  }, {
189
190
  csv
190
191
  });
@@ -194,10 +195,10 @@ class Glossaries {
194
195
  }
195
196
  async waitForImport(gImport, updateCallback, maxWaitTime) {
196
197
  const start = Date.now();
197
- while (gImport.progress < 1.) {
198
+ while (gImport.progress < 1.0) {
198
199
  if (maxWaitTime && Date.now() - start > maxWaitTime)
199
200
  throw new errors_1.TimeoutError();
200
- await new Promise(resolve => setTimeout(resolve, this.pollingInterval));
201
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
201
202
  gImport = await this.getImportStatus(gImport.id);
202
203
  if (updateCallback)
203
204
  updateCallback(gImport);
@@ -226,14 +227,22 @@ class Translator {
226
227
  return await this.client.get("/languages");
227
228
  }
228
229
  async translate(text, source, target, options) {
229
- const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { 'X-No-Trace': 'true' } : {};
230
+ const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
230
231
  return await this.client.post("/translate", {
231
- q: text, source, target, source_hint: options === null || options === void 0 ? void 0 : options.sourceHint,
232
- content_type: options === null || options === void 0 ? void 0 : options.contentType, multiline: (options === null || options === void 0 ? void 0 : options.multiline) !== false,
233
- adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo, glossaries: options === null || options === void 0 ? void 0 : options.glossaries, instructions: options === null || options === void 0 ? void 0 : options.instructions,
234
- timeout: options === null || options === void 0 ? void 0 : options.timeoutInMillis, priority: options === null || options === void 0 ? void 0 : options.priority,
235
- use_cache: options === null || options === void 0 ? void 0 : options.useCache, cache_ttl: options === null || options === void 0 ? void 0 : options.cacheTTLSeconds,
236
- verbose: options === null || options === void 0 ? void 0 : options.verbose,
232
+ q: text,
233
+ source,
234
+ target,
235
+ source_hint: options === null || options === void 0 ? void 0 : options.sourceHint,
236
+ content_type: options === null || options === void 0 ? void 0 : options.contentType,
237
+ multiline: (options === null || options === void 0 ? void 0 : options.multiline) !== false,
238
+ adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo,
239
+ glossaries: options === null || options === void 0 ? void 0 : options.glossaries,
240
+ instructions: options === null || options === void 0 ? void 0 : options.instructions,
241
+ timeout: options === null || options === void 0 ? void 0 : options.timeoutInMillis,
242
+ priority: options === null || options === void 0 ? void 0 : options.priority,
243
+ use_cache: options === null || options === void 0 ? void 0 : options.useCache,
244
+ cache_ttl: options === null || options === void 0 ? void 0 : options.cacheTTLSeconds,
245
+ verbose: options === null || options === void 0 ? void 0 : options.verbose
237
246
  }, undefined, headers);
238
247
  }
239
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "engines": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "rm -rf lib/* lib-browser/* && node scripts/generate-sdk-version.js && tsc && webpack",
11
- "version": "node scripts/generate-sdk-version.js && git add src/sdk-version.ts"
11
+ "version": "node scripts/generate-sdk-version.js && git add src/sdk-version.ts",
12
+ "biome:check": "biome check",
13
+ "biome:write": "biome check --write"
12
14
  },
13
15
  "files": [
14
16
  "lib",
@@ -36,6 +38,7 @@
36
38
  "form-data": "^4.0.2"
37
39
  },
38
40
  "devDependencies": {
41
+ "@biomejs/biome": "^2.0.6",
39
42
  "@types/node": "^22.15.18",
40
43
  "typescript": "^5.8.3",
41
44
  "webpack": "^5.99.8",