@lokalise/tm-sdk 1.0.0 → 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/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
- export * from './sdk/TranslationMemoryClient';
2
- export * from './sdk/errors/TranslationMemoryClientError';
3
- export * from './sdk/types/requests';
4
- export * from './sdk/types/models';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./sdk/TranslationMemoryClient"), exports);
5
+ tslib_1.__exportStar(require("./sdk/errors/TranslationMemoryClientError"), exports);
6
+ tslib_1.__exportStar(require("./sdk/types/requests"), exports);
7
+ tslib_1.__exportStar(require("./sdk/types/models"), exports);
5
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2CAA2C,CAAA;AACzD,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wEAA6C;AAC7C,oFAAyD;AACzD,+DAAoC;AACpC,6DAAkC"}
@@ -8,6 +8,7 @@ export type TranslationMemoryClientConfig = {
8
8
  jwtToken: string;
9
9
  retryConfig?: Partial<RetryConfig>;
10
10
  errorReporter?: ErrorReporter;
11
+ isEnabled?: boolean;
11
12
  };
12
13
  export declare class TranslationMemoryClient {
13
14
  private readonly maxFindMatchesRequestSize;
@@ -15,6 +16,7 @@ export declare class TranslationMemoryClient {
15
16
  private readonly retryConfig;
16
17
  private readonly headers;
17
18
  private readonly errorReporter?;
19
+ private readonly isEnabled;
18
20
  constructor(config: TranslationMemoryClientConfig);
19
21
  findMatches(groupId: string, request: FindMatchesRequest): Promise<TranslationMemoryMatch[]>;
20
22
  bulkFindMatches(groupId: string, request: BulkFindMatchesRequest): Promise<BulkTranslationMemoryMatches[]>;
@@ -1,14 +1,18 @@
1
- import { buildClient, chunk, InternalError, isResponseStatusError, sendGet, sendPost, sendPut, } from '@lokalise/node-core';
2
- import { TranslationMemoryClientError } from './errors/TranslationMemoryClientError';
3
- import { transformToQueryParam } from './utils';
4
- export class TranslationMemoryClient {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranslationMemoryClient = void 0;
4
+ const node_core_1 = require("@lokalise/node-core");
5
+ const objectUtils_1 = require("@lokalise/node-core/dist/src/utils/objectUtils");
6
+ const TranslationMemoryClientError_1 = require("./errors/TranslationMemoryClientError");
7
+ class TranslationMemoryClient {
5
8
  maxFindMatchesRequestSize = 20; // TODO: TBD
6
9
  httpClient;
7
10
  retryConfig;
8
11
  headers;
9
12
  errorReporter;
13
+ isEnabled;
10
14
  constructor(config) {
11
- this.httpClient = buildClient(config.baseUrl);
15
+ this.httpClient = (0, node_core_1.buildClient)(config.baseUrl);
12
16
  this.headers = {
13
17
  'Content-Type': 'application/json',
14
18
  Authorization: `Bearer ${config.jwtToken}`,
@@ -18,24 +22,28 @@ export class TranslationMemoryClient {
18
22
  maxAttempts: 5,
19
23
  delayBetweenAttemptsInMsecs: 250,
20
24
  statusCodesToRetry: [
21
- 408,
22
- 423,
23
- 429,
24
- 500,
25
- 503,
25
+ 408, // Request timeout
26
+ 423, // Resource is blocked
27
+ 429, // Too Many requests
28
+ 500, // Internal server error
29
+ 503, // Service unavailable
26
30
  504, // Gateway timeout,
27
31
  ],
28
32
  ...config.retryConfig,
29
33
  };
30
34
  this.errorReporter = config.errorReporter;
35
+ this.isEnabled = config.isEnabled ?? true;
31
36
  }
32
37
  async findMatches(groupId, request) {
38
+ if (!this.isEnabled) {
39
+ return [];
40
+ }
33
41
  try {
34
- const response = await sendGet(this.httpClient, `/v1/groups/${groupId}/actions/find-matches`, {
42
+ const response = await (0, node_core_1.sendGet)(this.httpClient, `/v1/groups/${groupId}/actions/find-matches`, {
35
43
  headers: this.headers,
36
44
  retryConfig: this.retryConfig,
37
45
  requestLabel: '(tm-sdk) Find matches',
38
- query: transformToQueryParam(request),
46
+ query: (0, objectUtils_1.transformToKebabCase)(request),
39
47
  });
40
48
  return response.result.body.data;
41
49
  }
@@ -45,20 +53,26 @@ export class TranslationMemoryClient {
45
53
  }
46
54
  async bulkFindMatches(groupId, request) {
47
55
  const response = [];
48
- for (const filters of chunk(request.filters, this.maxFindMatchesRequestSize)) {
56
+ for (const filters of (0, node_core_1.chunk)(request.filters, this.maxFindMatchesRequestSize)) {
49
57
  const partialResponse = await this.internalBulkFindMatches(groupId, { filters });
50
58
  response.push(...partialResponse);
51
59
  }
52
60
  return response;
53
61
  }
54
62
  async *bulkFindMatchesIterative(groupId, request) {
55
- for (const filters of chunk(request.filters, this.maxFindMatchesRequestSize)) {
63
+ for (const filters of (0, node_core_1.chunk)(request.filters, this.maxFindMatchesRequestSize)) {
56
64
  yield await this.internalBulkFindMatches(groupId, { filters });
57
65
  }
58
66
  }
59
67
  async getRecords(groupId, pagination) {
68
+ if (!this.isEnabled) {
69
+ return {
70
+ records: [],
71
+ meta: { count: 0 },
72
+ };
73
+ }
60
74
  try {
61
- const response = await sendGet(this.httpClient, `/v1/groups/${groupId}/records`, {
75
+ const response = await (0, node_core_1.sendGet)(this.httpClient, `/v1/groups/${groupId}/records`, {
62
76
  headers: this.headers,
63
77
  retryConfig: this.retryConfig,
64
78
  requestLabel: '(tm-sdk) Get records',
@@ -74,8 +88,11 @@ export class TranslationMemoryClient {
74
88
  }
75
89
  }
76
90
  async upsertRecords(groupId, records) {
91
+ if (!this.isEnabled) {
92
+ return;
93
+ }
77
94
  try {
78
- await sendPut(this.httpClient, `/v1/groups/${groupId}/records`, records, {
95
+ await (0, node_core_1.sendPut)(this.httpClient, `/v1/groups/${groupId}/records`, records, {
79
96
  headers: this.headers,
80
97
  retryConfig: this.retryConfig,
81
98
  requestLabel: '(tm-sdk) Create or update records',
@@ -86,8 +103,11 @@ export class TranslationMemoryClient {
86
103
  }
87
104
  }
88
105
  async internalBulkFindMatches(groupId, request) {
106
+ if (!this.isEnabled) {
107
+ return [];
108
+ }
89
109
  try {
90
- const response = await sendPost(this.httpClient, `/v1/groups/${groupId}/actions/bulk-find-matches`, request, {
110
+ const response = await (0, node_core_1.sendPost)(this.httpClient, `/v1/groups/${groupId}/actions/bulk-find-matches`, request, {
91
111
  headers: this.headers,
92
112
  retryConfig: this.retryConfig,
93
113
  requestLabel: '(tm-sdk) Bulk find matches',
@@ -101,10 +121,10 @@ export class TranslationMemoryClient {
101
121
  handleError(e) {
102
122
  let error;
103
123
  if (e instanceof Error) {
104
- error = isResponseStatusError(e) ? new TranslationMemoryClientError(e) : e;
124
+ error = (0, node_core_1.isResponseStatusError)(e) ? new TranslationMemoryClientError_1.TranslationMemoryClientError(e) : e;
105
125
  }
106
126
  else {
107
- error = new InternalError({
127
+ error = new node_core_1.InternalError({
108
128
  message: 'Unknown error',
109
129
  errorCode: 'UNKNOWN_ERROR',
110
130
  details: { error: JSON.stringify(e) },
@@ -114,4 +134,5 @@ export class TranslationMemoryClient {
114
134
  return error;
115
135
  }
116
136
  }
137
+ exports.TranslationMemoryClient = TranslationMemoryClient;
117
138
  //# sourceMappingURL=TranslationMemoryClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TranslationMemoryClient.js","sourceRoot":"","sources":["../../src/sdk/TranslationMemoryClient.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,KAAK,EACL,aAAa,EACb,qBAAqB,EACrB,OAAO,EACP,QAAQ,EACR,OAAO,GACR,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAA;AAapF,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAS/C,MAAM,OAAO,uBAAuB;IACjB,yBAAyB,GAAG,EAAE,CA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I,CAAC,OAAO;gBACrB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY,EAAE,4BAA4B;aAC3C,CACF,CAAA;YAED,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAA;QAClC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,CAAU;QAC5B,IAAI,KAAwB,CAAA;QAC5B,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,KAAK,GAAG,IAAA,iCAAqB,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,2DAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5E,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,yBAAa,CAAC;gBACxB,OAAO,EAAE,eAAe;gBACxB,SAAS,EAAE,eAAe;gBAC1B,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;aACtC,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AA1KD,0DA0KC"}
@@ -1,5 +1,8 @@
1
- import { InternalError } from '@lokalise/node-core';
2
- export class TranslationMemoryClientError extends InternalError {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranslationMemoryClientError = void 0;
4
+ const node_core_1 = require("@lokalise/node-core");
5
+ class TranslationMemoryClientError extends node_core_1.InternalError {
3
6
  constructor(error) {
4
7
  super({
5
8
  message: `Translation memory service failed with error: ${error.message}`,
@@ -11,4 +14,5 @@ export class TranslationMemoryClientError extends InternalError {
11
14
  });
12
15
  }
13
16
  }
17
+ exports.TranslationMemoryClientError = TranslationMemoryClientError;
14
18
  //# sourceMappingURL=TranslationMemoryClientError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TranslationMemoryClientError.js","sourceRoot":"","sources":["../../../src/sdk/errors/TranslationMemoryClientError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,OAAO,4BAA6B,SAAQ,aAAa;IAC7D,YAAY,KAA0B;QACpC,KAAK,CAAC;YACJ,OAAO,EAAE,iDAAiD,KAAK,CAAC,OAAO,EAAE;YACzE,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACjD,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;YACD,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAA;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"TranslationMemoryClientError.js","sourceRoot":"","sources":["../../../src/sdk/errors/TranslationMemoryClientError.ts"],"names":[],"mappings":";;;AACA,mDAAmD;AAEnD,MAAa,4BAA6B,SAAQ,yBAAa;IAC7D,YAAY,KAA0B;QACpC,KAAK,CAAC;YACJ,OAAO,EAAE,iDAAiD,KAAK,CAAC,OAAO,EAAE;YACzE,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACjD,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;YACD,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAA;IACJ,CAAC;CACF;AAXD,oEAWC"}
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=apiResponses.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=models.js.map
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=requests.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/tm-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"
@@ -29,23 +29,23 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@lokalise/api-common": "^2.0.0",
32
- "@lokalise/node-core": "^9.7.0",
33
- "undici": "^6.4.0",
32
+ "@lokalise/node-core": "^9.9.0",
33
+ "undici": "^6.5.0",
34
34
  "undici-retry": "^5.0.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "20.11.5",
38
- "@typescript-eslint/eslint-plugin": "^6.13.1",
39
- "@typescript-eslint/parser": "^6.13.1",
40
- "@vitest/coverage-v8": "^1.2.1",
37
+ "@types/node": "20.11.13",
38
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
39
+ "@typescript-eslint/parser": "^6.20.0",
40
+ "@vitest/coverage-v8": "^1.2.2",
41
41
  "auto-changelog": "^2.4.0",
42
42
  "eslint": "^8.56.0",
43
43
  "eslint-plugin-import": "^2.29.1",
44
- "eslint-plugin-vitest": "^0.3.20",
44
+ "eslint-plugin-vitest": "^0.3.21",
45
45
  "mockttp": "^3.10.1",
46
46
  "prettier": "^3.2.4",
47
47
  "shx": "^0.3.4",
48
48
  "typescript": "5.3.3",
49
- "vitest": "^1.2.1"
49
+ "vitest": "^1.2.2"
50
50
  }
51
51
  }
@@ -1,6 +0,0 @@
1
- type TransformObjectKeys<T> = {
2
- [K in keyof T as K extends string ? TransformKey<K> : never]: T[K] extends object ? TransformObjectKeys<T[K]> : T[K];
3
- };
4
- type TransformKey<T extends string> = T extends `${infer F}${infer R}` ? F extends Capitalize<F> ? `-${Lowercase<F>}${TransformKey<R>}` : `${F}${TransformKey<R>}` : Lowercase<T>;
5
- export declare const transformToQueryParam: <T extends object>(object: T) => TransformObjectKeys<T>;
6
- export {};
package/dist/sdk/utils.js DELETED
@@ -1,12 +0,0 @@
1
- // TODO: could this be useful on node-core?
2
- export const transformToQueryParam = (object) => {
3
- const transformed = {};
4
- for (const key in object) {
5
- const value = object[key];
6
- const transformedKey = key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
7
- transformed[transformedKey] =
8
- typeof value === 'object' ? transformToQueryParam(value) : value;
9
- }
10
- return transformed;
11
- };
12
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sdk/utils.ts"],"names":[],"mappings":"AAYA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAmB,MAAS,EAA0B,EAAE;IAC3F,MAAM,WAAW,GAA4B,EAAE,CAAA;IAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QACzB,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;QAEhF,WAAW,CAAC,cAAc,CAAC;YACzB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;KAC7E;IAED,OAAO,WAAqC,CAAA;AAC9C,CAAC,CAAA"}