@translated/lara 1.0.1 → 1.1.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/_test.js +9 -14
- package/lib/errors.d.ts +3 -3
- package/lib/errors.js +4 -4
- package/lib/net/client.js +1 -1
- package/lib/sdk-version.d.ts +1 -1
- package/lib/sdk-version.js +1 -1
- package/lib/translator/translator.d.ts +1 -0
- package/lib/translator/translator.js +1 -1
- package/package.json +3 -2
package/lib/_test.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const credentials_1 = require("./credentials");
|
|
4
3
|
const translator_1 = require("./translator/translator");
|
|
5
|
-
const
|
|
6
|
-
const lara = new translator_1.Translator(credentials, {
|
|
7
|
-
serverUrl: "http://localhost:8000/"
|
|
8
|
-
});
|
|
4
|
+
const credentials_1 = require("./credentials");
|
|
9
5
|
async function main() {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log("Block (2):", blockResult2.translation);
|
|
6
|
+
const credentials = new credentials_1.Credentials("7GAFEDT3LDJAJH9HFA1CDJULDU", "EBXxbk71Mx6yR9YG48f1jDyY4s5QQLOff0GcTw2QlfY");
|
|
7
|
+
const translator = new translator_1.Translator(credentials, {
|
|
8
|
+
serverUrl: "http://localhost:8000/"
|
|
9
|
+
});
|
|
10
|
+
console.log(await translator.translate("This is a test.", "en", "it", {
|
|
11
|
+
priority: "background"
|
|
12
|
+
}));
|
|
18
13
|
}
|
|
19
|
-
main().
|
|
14
|
+
main().catch(console.error);
|
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
|
|
8
|
-
readonly
|
|
9
|
-
constructor(statusCode: number,
|
|
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,
|
|
12
|
-
super(
|
|
11
|
+
constructor(statusCode, type, message) {
|
|
12
|
+
super(message);
|
|
13
13
|
this.statusCode = statusCode;
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
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.
|
|
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) {
|
package/lib/sdk-version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.1.0";
|
package/lib/sdk-version.js
CHANGED
|
@@ -114,7 +114,7 @@ class Translator {
|
|
|
114
114
|
return await this.client.post("/translate", {
|
|
115
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
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
|
|
117
|
+
instructions: options === null || options === void 0 ? void 0 : options.instructions, timeout: options === null || options === void 0 ? void 0 : options.timeoutInMillis, priority: options === null || options === void 0 ? void 0 : options.priority
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@translated/lara",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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",
|