@translated/lara 1.5.0 → 1.5.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.
package/lib/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export { version } from "./sdk-version";
2
2
  export { Credentials } from "./credentials";
3
3
  export { LaraError, TimeoutError, LaraApiError } from "./errors";
4
4
  export { Translator, TranslatorOptions, Memories, MemoryImportCallback, TranslateOptions, Documents, DocumentTranslateOptions } from "./translator/translator";
5
- export { Memory, MemoryImport, TextBlock, TextResult, Document, DocumentUploadOptions, DocumentDownloadOptions } from "./translator/models";
5
+ export { Memory, MemoryImport, TextBlock, TextResult, Document, DocumentStatus, DocumentUploadOptions, DocumentDownloadOptions } from "./translator/models";
6
6
  export { MultiPartFile } from "./net/client";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Documents = exports.Memories = exports.Translator = exports.LaraApiError = exports.TimeoutError = exports.LaraError = exports.Credentials = exports.version = void 0;
3
+ exports.DocumentStatus = exports.Documents = exports.Memories = exports.Translator = exports.LaraApiError = exports.TimeoutError = exports.LaraError = exports.Credentials = exports.version = void 0;
4
4
  var sdk_version_1 = require("./sdk-version");
5
5
  Object.defineProperty(exports, "version", { enumerable: true, get: function () { return sdk_version_1.version; } });
6
6
  var credentials_1 = require("./credentials");
@@ -13,3 +13,5 @@ var translator_1 = require("./translator/translator");
13
13
  Object.defineProperty(exports, "Translator", { enumerable: true, get: function () { return translator_1.Translator; } });
14
14
  Object.defineProperty(exports, "Memories", { enumerable: true, get: function () { return translator_1.Memories; } });
15
15
  Object.defineProperty(exports, "Documents", { enumerable: true, get: function () { return translator_1.Documents; } });
16
+ var models_1 = require("./translator/models");
17
+ Object.defineProperty(exports, "DocumentStatus", { enumerable: true, get: function () { return models_1.DocumentStatus; } });
@@ -22,11 +22,11 @@ export declare abstract class LaraClient {
22
22
  private readonly extraHeaders;
23
23
  protected constructor(accessKeyId: string, accessKeySecret: string);
24
24
  setExtraHeader(name: string, value: string): void;
25
- get<T>(path: string, params?: Record<string, any>): Promise<T>;
26
- delete<T>(path: string, params?: Record<string, any>): Promise<T>;
27
- post<T>(path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>): Promise<T>;
28
- put<T>(path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>): Promise<T>;
29
- protected request<T>(method: HttpMethod, path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>): Promise<T>;
25
+ get<T>(path: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
26
+ delete<T>(path: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
27
+ post<T>(path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>, headers?: Record<string, string>): Promise<T>;
28
+ put<T>(path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>, headers?: Record<string, string>): Promise<T>;
29
+ protected request<T>(method: HttpMethod, path: string, body?: Record<string, any>, files?: Record<string, MultiPartFile>, headers?: Record<string, string>): Promise<T>;
30
30
  private sign;
31
31
  protected abstract send(path: string, headers: Record<string, string>, body?: Record<string, any>): Promise<ClientResponse>;
32
32
  protected abstract wrapMultiPartFile(file: MultiPartFile): any;
package/lib/net/client.js CHANGED
@@ -40,27 +40,28 @@ class LaraClient {
40
40
  setExtraHeader(name, value) {
41
41
  this.extraHeaders[name] = value;
42
42
  }
43
- get(path, params) {
44
- return this.request("GET", path, params);
43
+ get(path, params, headers) {
44
+ return this.request("GET", path, params, undefined, headers);
45
45
  }
46
- delete(path, params) {
47
- return this.request("DELETE", path, params);
46
+ delete(path, params, headers) {
47
+ return this.request("DELETE", path, params, undefined, headers);
48
48
  }
49
- post(path, body, files) {
50
- return this.request("POST", path, body, files);
49
+ post(path, body, files, headers) {
50
+ return this.request("POST", path, body, files, headers);
51
51
  }
52
- put(path, body, files) {
53
- return this.request("PUT", path, body, files);
52
+ put(path, body, files, headers) {
53
+ return this.request("PUT", path, body, files, headers);
54
54
  }
55
- async request(method, path, body, files) {
55
+ async request(method, path, body, files, headers) {
56
56
  if (!path.startsWith("/"))
57
57
  path = "/" + path;
58
- const headers = {
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
62
  'X-Lara-SDK-Version': sdk_version_1.version,
63
- ...this.extraHeaders
63
+ ...this.extraHeaders,
64
+ ...headers
64
65
  };
65
66
  if (body) {
66
67
  body = Object.fromEntries(Object.entries(body).filter(([_, v]) => v !== undefined && v !== null));
@@ -68,7 +69,7 @@ class LaraClient {
68
69
  body = undefined;
69
70
  if (body) {
70
71
  const jsonBody = JSON.stringify(body, undefined, 0);
71
- headers["Content-MD5"] = await this.crypto.digest(jsonBody);
72
+ _headers["Content-MD5"] = await this.crypto.digest(jsonBody);
72
73
  }
73
74
  }
74
75
  let requestBody = undefined;
@@ -76,17 +77,17 @@ class LaraClient {
76
77
  // validate files
77
78
  for (const [key, file] of Object.entries(files))
78
79
  files[key] = this.wrapMultiPartFile(file);
79
- headers["Content-Type"] = "multipart/form-data";
80
+ _headers["Content-Type"] = "multipart/form-data";
80
81
  requestBody = Object.assign({}, files, body);
81
82
  }
82
83
  else {
83
- headers["Content-Type"] = "application/json";
84
+ _headers["Content-Type"] = "application/json";
84
85
  if (body)
85
86
  requestBody = body;
86
87
  }
87
- const signature = await this.sign(method, path, headers);
88
- headers["Authorization"] = `Lara ${this.accessKeyId}:${signature}`;
89
- const response = await this.send(path, headers, requestBody);
88
+ const signature = await this.sign(method, path, _headers);
89
+ _headers["Authorization"] = `Lara ${this.accessKeyId}:${signature}`;
90
+ const response = await this.send(path, _headers, requestBody);
90
91
  if (200 <= response.statusCode && response.statusCode < 300) {
91
92
  return parseContent(response.body.content);
92
93
  }
@@ -1 +1 @@
1
- export declare const version = "1.5.0";
1
+ export declare const version = "1.5.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.5.0";
4
+ exports.version = "1.5.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "engines": {