@translated/lara 2.0.0-beta.5 → 2.0.0-beta.6

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/Documents.js CHANGED
@@ -3,7 +3,7 @@ import { DocumentStatus, } from './models';
3
3
  import toFormData from './utils/formdata';
4
4
  import toSnakeCase from './utils/toSnakeCase';
5
5
  import sleep from './utils/sleep';
6
- import { LaraApiError, TimeoutError } from './utils/errors';
6
+ import { LaraApiError, LaraTimeoutError } from './utils/errors';
7
7
  import toQueryString from './utils/toQueryString';
8
8
  import isNode from './utils/isNode';
9
9
  export default class Documents {
@@ -75,8 +75,8 @@ export default class Documents {
75
75
  if (status === DocumentStatus.TRANSLATED)
76
76
  return await this.download(id, downloadOptions);
77
77
  if (status === DocumentStatus.ERROR)
78
- throw new LaraApiError(500, 'DocumentError', errorReason);
78
+ throw new LaraApiError(500, errorReason, 'unknown');
79
79
  }
80
- throw new TimeoutError();
80
+ throw new LaraTimeoutError();
81
81
  }
82
82
  }
package/lib/Glossaries.js CHANGED
@@ -1,4 +1,4 @@
1
- import { TimeoutError } from './utils/errors';
1
+ import { LaraTimeoutError } from './utils/errors';
2
2
  import toFormData from './utils/formdata';
3
3
  import sleep from './utils/sleep';
4
4
  import toQueryString from './utils/toQueryString';
@@ -46,7 +46,7 @@ export default class Glossaries {
46
46
  const start = Date.now();
47
47
  while (gImport.progress < 1.0) {
48
48
  if (maxWaitTime && Date.now() - start > maxWaitTime)
49
- throw new TimeoutError();
49
+ throw new LaraTimeoutError();
50
50
  await sleep(this.pollingInterval);
51
51
  gImport = await this.getImportStatus(gImport.id);
52
52
  updateCallback && updateCallback(gImport);
package/lib/Memories.js CHANGED
@@ -1,4 +1,4 @@
1
- import { TimeoutError } from './utils/errors';
1
+ import { LaraTimeoutError } from './utils/errors';
2
2
  import toFormData from './utils/formdata';
3
3
  import sleep from './utils/sleep';
4
4
  export default class Memories {
@@ -79,7 +79,7 @@ export default class Memories {
79
79
  const start = Date.now();
80
80
  while (mImport.progress < 1.0) {
81
81
  if (maxWaitTime && Date.now() - start > maxWaitTime)
82
- throw new TimeoutError();
82
+ throw new LaraTimeoutError();
83
83
  await sleep(this.pollingInterval);
84
84
  mImport = await this.getImportStatus(mImport.id);
85
85
  updateCallback && updateCallback(mImport);
package/lib/Translator.js CHANGED
@@ -4,6 +4,7 @@ import { version } from './sdk-version';
4
4
  import Glossaries from './Glossaries';
5
5
  import Documents from './Documents';
6
6
  import toCamelCase from './utils/toCamelCase';
7
+ import { LaraApiError } from './utils/errors';
7
8
  const DEFAULT_BASE_URL = 'https://api.laratranslate.com';
8
9
  export class Translator {
9
10
  constructor(accessKey, credentials, authToken, options) {
@@ -35,6 +36,7 @@ export class Translator {
35
36
  }
36
37
  return response;
37
38
  }, async (error) => {
39
+ var _a, _b, _c, _d, _e, _f;
38
40
  const originalRequest = error.config;
39
41
  if (originalRequest.isRetry)
40
42
  return Promise.reject(error);
@@ -45,7 +47,7 @@ export class Translator {
45
47
  originalRequest.headers.Authorization = `Bearer ${token}`;
46
48
  return this.client(originalRequest);
47
49
  }
48
- return Promise.reject(error);
50
+ return Promise.reject(new LaraApiError((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 500, (_e = (_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : error.message, (_f = error.response) === null || _f === void 0 ? void 0 : _f.headers['x-transaction-id']));
49
51
  });
50
52
  this.memories = new Memories(this.client);
51
53
  this.glossaries = new Glossaries(this.client);
@@ -1 +1 @@
1
- export declare const version = "2.0.0-beta.4";
1
+ export declare const version = "2.0.0-beta.5";
@@ -1 +1 @@
1
- export const version = '2.0.0-beta.4';
1
+ export const version = '2.0.0-beta.5';
@@ -1,10 +1,10 @@
1
1
  export declare class LaraError extends Error {
2
2
  }
3
- export declare class TimeoutError extends LaraError {
3
+ export declare class LaraTimeoutError extends LaraError {
4
4
  }
5
5
  export declare class LaraApiError extends LaraError {
6
6
  readonly statusCode: number;
7
- readonly type: string;
8
7
  readonly message: string;
9
- constructor(statusCode: number, type: string, message: string);
8
+ readonly idTransaction: string;
9
+ constructor(statusCode: number, message: string, idTransaction: string);
10
10
  }
@@ -1,12 +1,12 @@
1
1
  export class LaraError extends Error {
2
2
  }
3
- export class TimeoutError extends LaraError {
3
+ export class LaraTimeoutError extends LaraError {
4
4
  }
5
5
  export class LaraApiError extends LaraError {
6
- constructor(statusCode, type, message) {
6
+ constructor(statusCode, message, idTransaction) {
7
7
  super(message);
8
8
  this.statusCode = statusCode;
9
- this.type = type;
10
9
  this.message = message;
10
+ this.idTransaction = idTransaction;
11
11
  }
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.6",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "engines": {