@lokalise/tm-sdk 1.0.0 → 2.0.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,10 +16,11 @@ 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
- bulkFindMatches(groupId: string, request: BulkFindMatchesRequest): Promise<BulkTranslationMemoryMatches[]>;
21
- bulkFindMatchesIterative(groupId: string, request: BulkFindMatchesRequest): AsyncGenerator<BulkTranslationMemoryMatches[]>;
22
+ bulkFindMatches(groupId: string, { filters, options }: BulkFindMatchesRequest): Promise<BulkTranslationMemoryMatches[]>;
23
+ bulkFindMatchesIterative(groupId: string, { filters, options }: BulkFindMatchesRequest): AsyncGenerator<BulkTranslationMemoryMatches[]>;
22
24
  getRecords(groupId: string, pagination?: MandatoryPaginationParams): Promise<TranslationMemoryRecordsResponse>;
23
25
  upsertRecords(groupId: string, records: UpsertRecordDto[]): Promise<void>;
24
26
  private internalBulkFindMatches;
@@ -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
  }
@@ -43,22 +51,31 @@ export class TranslationMemoryClient {
43
51
  throw this.handleError(e);
44
52
  }
45
53
  }
46
- async bulkFindMatches(groupId, request) {
54
+ async bulkFindMatches(groupId, { filters, options }) {
47
55
  const response = [];
48
- for (const filters of chunk(request.filters, this.maxFindMatchesRequestSize)) {
49
- const partialResponse = await this.internalBulkFindMatches(groupId, { filters });
56
+ for (const part of (0, node_core_1.chunk)(filters, this.maxFindMatchesRequestSize)) {
57
+ const partialResponse = await this.internalBulkFindMatches(groupId, {
58
+ filters: part,
59
+ options,
60
+ });
50
61
  response.push(...partialResponse);
51
62
  }
52
63
  return response;
53
64
  }
54
- async *bulkFindMatchesIterative(groupId, request) {
55
- for (const filters of chunk(request.filters, this.maxFindMatchesRequestSize)) {
56
- yield await this.internalBulkFindMatches(groupId, { filters });
65
+ async *bulkFindMatchesIterative(groupId, { filters, options }) {
66
+ for (const part of (0, node_core_1.chunk)(filters, this.maxFindMatchesRequestSize)) {
67
+ yield await this.internalBulkFindMatches(groupId, { filters: part, options });
57
68
  }
58
69
  }
59
70
  async getRecords(groupId, pagination) {
71
+ if (!this.isEnabled) {
72
+ return {
73
+ records: [],
74
+ meta: { count: 0 },
75
+ };
76
+ }
60
77
  try {
61
- const response = await sendGet(this.httpClient, `/v1/groups/${groupId}/records`, {
78
+ const response = await (0, node_core_1.sendGet)(this.httpClient, `/v1/groups/${groupId}/records`, {
62
79
  headers: this.headers,
63
80
  retryConfig: this.retryConfig,
64
81
  requestLabel: '(tm-sdk) Get records',
@@ -74,8 +91,11 @@ export class TranslationMemoryClient {
74
91
  }
75
92
  }
76
93
  async upsertRecords(groupId, records) {
94
+ if (!this.isEnabled) {
95
+ return;
96
+ }
77
97
  try {
78
- await sendPut(this.httpClient, `/v1/groups/${groupId}/records`, records, {
98
+ await (0, node_core_1.sendPut)(this.httpClient, `/v1/groups/${groupId}/records`, records, {
79
99
  headers: this.headers,
80
100
  retryConfig: this.retryConfig,
81
101
  requestLabel: '(tm-sdk) Create or update records',
@@ -86,8 +106,11 @@ export class TranslationMemoryClient {
86
106
  }
87
107
  }
88
108
  async internalBulkFindMatches(groupId, request) {
109
+ if (!this.isEnabled) {
110
+ return [];
111
+ }
89
112
  try {
90
- const response = await sendPost(this.httpClient, `/v1/groups/${groupId}/actions/bulk-find-matches`, request, {
113
+ const response = await (0, node_core_1.sendPost)(this.httpClient, `/v1/groups/${groupId}/actions/bulk-find-matches`, request, {
91
114
  headers: this.headers,
92
115
  retryConfig: this.retryConfig,
93
116
  requestLabel: '(tm-sdk) Bulk find matches',
@@ -101,10 +124,10 @@ export class TranslationMemoryClient {
101
124
  handleError(e) {
102
125
  let error;
103
126
  if (e instanceof Error) {
104
- error = isResponseStatusError(e) ? new TranslationMemoryClientError(e) : e;
127
+ error = (0, node_core_1.isResponseStatusError)(e) ? new TranslationMemoryClientError_1.TranslationMemoryClientError(e) : e;
105
128
  }
106
129
  else {
107
- error = new InternalError({
130
+ error = new node_core_1.InternalError({
108
131
  message: 'Unknown error',
109
132
  errorCode: 'UNKNOWN_ERROR',
110
133
  details: { error: JSON.stringify(e) },
@@ -114,4 +137,5 @@ export class TranslationMemoryClient {
114
137
  return error;
115
138
  }
116
139
  }
140
+ exports.TranslationMemoryClient = TranslationMemoryClient;
117
141
  //# 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,CAAA,CAAC,YAAY;IAE3C,UAAU,CAAQ;IAClB,WAAW,CAAa;IACxB,OAAO,CAAyB;IAChC,aAAa,CAAgB;IAE9C,YAAY,MAAqC;QAC/C,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,MAAM,CAAC,QAAQ,EAAE;SAC3C,CAAA;QACD,IAAI,CAAC,WAAW,GAAG;YACjB,cAAc,EAAE,KAAK;YACrB,WAAW,EAAE,CAAC;YACd,2BAA2B,EAAE,GAAG;YAChC,kBAAkB,EAAE;gBAClB,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG,EAAE,mBAAmB;aACzB;YACD,GAAG,MAAM,CAAC,WAAW;SACtB,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAAe,EACf,OAA2B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AAE,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;AA7KD,0DA6KC"}
@@ -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,6 +1,7 @@
1
1
  import type { PaginationMeta } from '@lokalise/api-common';
2
2
  import type { MayOmit } from '@lokalise/node-core';
3
3
  export type TranslationMemoryMatch = {
4
+ sourceText: string;
4
5
  targetText: string;
5
6
  };
6
7
  export type BulkTranslationMemoryMatches = {
@@ -1,2 +1,3 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=models.js.map
@@ -1,14 +1,18 @@
1
- export type FindMatchesRequest = {
1
+ export type FindMatchesFilter = {
2
2
  sourceText: string;
3
3
  sourceLocale: string;
4
4
  targetLocale: string;
5
5
  prevContent?: string;
6
6
  nextContent?: string;
7
+ };
8
+ export type FindMatchesOptions = {
7
9
  maxMatches?: number;
8
10
  };
9
- export type BulkFindMatchesFilter = FindMatchesRequest & {
11
+ export type BulkFindMatchesFilter = FindMatchesFilter & {
10
12
  filterId?: string;
11
13
  };
14
+ export type FindMatchesRequest = FindMatchesFilter & FindMatchesOptions;
12
15
  export type BulkFindMatchesRequest = {
13
16
  filters: BulkFindMatchesFilter[];
17
+ options?: FindMatchesOptions;
14
18
  };
@@ -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": "2.0.0",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"
@@ -29,23 +29,24 @@
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/id-utils": "^1.0.0",
33
+ "@lokalise/node-core": "^9.9.0",
34
+ "undici": "^6.5.0",
34
35
  "undici-retry": "^5.0.2"
35
36
  },
36
37
  "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",
38
+ "@types/node": "20.11.13",
39
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
40
+ "@typescript-eslint/parser": "^6.20.0",
41
+ "@vitest/coverage-v8": "^1.2.2",
41
42
  "auto-changelog": "^2.4.0",
42
43
  "eslint": "^8.56.0",
43
44
  "eslint-plugin-import": "^2.29.1",
44
- "eslint-plugin-vitest": "^0.3.20",
45
+ "eslint-plugin-vitest": "^0.3.21",
45
46
  "mockttp": "^3.10.1",
46
47
  "prettier": "^3.2.4",
47
48
  "shx": "^0.3.4",
48
49
  "typescript": "5.3.3",
49
- "vitest": "^1.2.1"
50
+ "vitest": "^1.2.2"
50
51
  }
51
52
  }
@@ -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"}