@translated/lara 1.0.1 → 1.2.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/errors.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare class TimeoutError extends LaraError {
4
4
  }
5
5
  export declare class LaraApiError extends LaraError {
6
6
  readonly statusCode: number;
7
- readonly name: string;
8
- readonly errorMessage: string;
9
- constructor(statusCode: number, name: string, message: string);
7
+ readonly type: string;
8
+ readonly message: string;
9
+ constructor(statusCode: number, type: string, message: string);
10
10
  }
package/lib/errors.js CHANGED
@@ -8,11 +8,11 @@ class TimeoutError extends LaraError {
8
8
  }
9
9
  exports.TimeoutError = TimeoutError;
10
10
  class LaraApiError extends LaraError {
11
- constructor(statusCode, name, message) {
12
- super(`[HTTP ${statusCode}] ${name}: ${message}`);
11
+ constructor(statusCode, type, message) {
12
+ super(message);
13
13
  this.statusCode = statusCode;
14
- this.name = name;
15
- this.errorMessage = message;
14
+ this.type = type;
15
+ this.message = message;
16
16
  }
17
17
  }
18
18
  exports.LaraApiError = LaraApiError;
package/lib/net/client.js CHANGED
@@ -84,7 +84,7 @@ class LaraClient {
84
84
  }
85
85
  else {
86
86
  const error = response.body.error || {};
87
- throw new errors_1.LaraApiError(response.statusCode, error.name || "UnknownError", error.message || "An unknown error occurred");
87
+ throw new errors_1.LaraApiError(response.statusCode, error.type || "UnknownError", error.message || "An unknown error occurred");
88
88
  }
89
89
  }
90
90
  async sign(method, path, headers) {
@@ -1 +1 @@
1
- export declare const version = "1.0.0";
1
+ export declare const version = "1.2.0";
@@ -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.0.0";
4
+ exports.version = "1.2.0";
@@ -28,6 +28,9 @@ export type TranslateOptions = {
28
28
  contentType?: string;
29
29
  multiline?: boolean;
30
30
  timeoutInMillis?: number;
31
+ priority?: "normal" | "background";
32
+ useCache?: boolean | "overwrite";
33
+ cacheTTLSeconds?: number;
31
34
  };
32
35
  export declare class Translator {
33
36
  private readonly client;
@@ -112,9 +112,11 @@ class Translator {
112
112
  }
113
113
  async translate(text, source, target, options) {
114
114
  return await this.client.post("/translate", {
115
- q: text, source, target, source_hint: options === null || options === void 0 ? void 0 : options.sourceHint, content_type: options === null || options === void 0 ? void 0 : options.contentType,
116
- multiline: (options === null || options === void 0 ? void 0 : options.multiline) !== false, adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo,
117
- instructions: options === null || options === void 0 ? void 0 : options.instructions, timeout: options === null || options === void 0 ? void 0 : options.timeoutInMillis
115
+ q: text, source, target, source_hint: options === null || options === void 0 ? void 0 : options.sourceHint,
116
+ content_type: options === null || options === void 0 ? void 0 : options.contentType, multiline: (options === null || options === void 0 ? void 0 : options.multiline) !== false,
117
+ adapt_to: options === null || options === void 0 ? void 0 : options.adaptTo, instructions: options === null || options === void 0 ? void 0 : options.instructions,
118
+ timeout: options === null || options === void 0 ? void 0 : options.timeoutInMillis, priority: options === null || options === void 0 ? void 0 : options.priority,
119
+ use_cache: options === null || options === void 0 ? void 0 : options.useCache, cache_ttl: options === null || options === void 0 ? void 0 : options.cacheTTLSeconds
118
120
  });
119
121
  }
120
122
  }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "engines": {
7
7
  "node": ">=12.*"
8
8
  },
9
9
  "scripts": {
10
- "build": "rm -rf lib/* lib-browser/* && node scripts/generate-sdk-version.js && tsc && webpack"
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
12
  },
12
13
  "files": [
13
14
  "lib",
package/lib/_test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/_test.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const credentials_1 = require("./credentials");
4
- const translator_1 = require("./translator/translator");
5
- const credentials = new credentials_1.Credentials("7GAFEDT3LDJAJH9HFA1CDJULDU", "EBXxbk71Mx6yR9YG48f1jDyY4s5QQLOff0GcTw2QlfY");
6
- const lara = new translator_1.Translator(credentials, {
7
- serverUrl: "http://localhost:8000/"
8
- });
9
- async function main() {
10
- const textResult = await lara.translate("Hello, world!", "en", "it");
11
- console.log("Text:", textResult.translation);
12
- const arrayResult = await lara.translate(["Hello, world!", "Goodbye, world!"], "en", "it");
13
- console.log("Array:", arrayResult.translation);
14
- const blockResult = await lara.translate([{ text: "Hello, world!" }, { text: "Goodbye, world!" }], "en", "it");
15
- console.log("Block:", blockResult.translation);
16
- const blockResult2 = await lara.translate([{ text: "Hello, world!", translatable: false }, { text: "Goodbye, world!" }], "en", "it");
17
- console.log("Block (2):", blockResult2.translation);
18
- }
19
- main().then(() => console.log("done")).catch(console.error);