@lokalise/polyglot-sdk 5.0.0 → 5.2.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
2
|
import type { ClientOptions, ClientOptionsWithRequestContext, PolyglotClientConfig } from './types/client';
|
|
3
|
-
import type { GenerateVariantsRequest, LqaSyncRequest, ScoreTranslationsRequest, TranslateAsyncRequestBody, TranslateSyncRequest } from './types/requests';
|
|
3
|
+
import type { GenerateVariantsRequest, LqaAsyncRequestBody, LqaSyncRequest, ScoreTranslationsRequest, TranslateAsyncRequestBody, TranslateSyncRequest } from './types/requests';
|
|
4
4
|
import type { ContentUnitLqaResponse, ContentUnitTranslationResponse, PolyglotClientSyncIterativeResponse, ScoreTranslationsResponse, TranslateAsyncResponse } from './types/responses';
|
|
5
5
|
export declare class PolyglotClient {
|
|
6
6
|
private readonly client;
|
|
@@ -29,6 +29,8 @@ export declare class PolyglotClient {
|
|
|
29
29
|
scoreTranslations(request: ScoreTranslationsRequest, options?: ClientOptions): Promise<ScoreTranslationsResponse>;
|
|
30
30
|
private callTranslateSyncApi;
|
|
31
31
|
translateAsync(requestBody: TranslateAsyncRequestBody, options: ClientOptionsWithRequestContext): Promise<Either<Error, TranslateAsyncResponse>>;
|
|
32
|
+
lqaAsync(requestBody: LqaAsyncRequestBody, options: ClientOptionsWithRequestContext): Promise<Either<Error, TranslateAsyncResponse>>;
|
|
33
|
+
private callAsyncApi;
|
|
32
34
|
private callLqaSyncApi;
|
|
33
35
|
private wrapWithErrorHandling;
|
|
34
36
|
/**
|
|
@@ -159,10 +159,39 @@ class PolyglotClient {
|
|
|
159
159
|
return result.body.contentUnits;
|
|
160
160
|
}
|
|
161
161
|
async translateAsync(requestBody, options) {
|
|
162
|
+
const result = await this.callAsyncApi('/v1/content/actions/translate-async', requestBody, options, 'Translate asynchronously (Polyglot)');
|
|
163
|
+
if (result.error === null) {
|
|
164
|
+
result.error = new node_core_1.InternalError({
|
|
165
|
+
message: 'Failed to schedule asynchronous translation',
|
|
166
|
+
errorCode: 'FAILED_TO_SCHEDULE_ASYNC_TRANSLATION',
|
|
167
|
+
details: {
|
|
168
|
+
originCorrelationId: requestBody.originCorrelationId,
|
|
169
|
+
tenantId: requestBody.tenantId,
|
|
170
|
+
ownerId: requestBody.ownerId,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
async lqaAsync(requestBody, options) {
|
|
177
|
+
const result = await this.callAsyncApi('/v1/content/actions/lqa-async', requestBody, options, 'LQA asynchronously (Polyglot)');
|
|
178
|
+
if (result.error === null) {
|
|
179
|
+
result.error = new node_core_1.InternalError({
|
|
180
|
+
message: 'Failed to schedule asynchronous LQA',
|
|
181
|
+
errorCode: 'FAILED_TO_SCHEDULE_ASYNC_LQA',
|
|
182
|
+
details: {
|
|
183
|
+
originCorrelationId: requestBody.originCorrelationId,
|
|
184
|
+
tenantId: requestBody.tenantId,
|
|
185
|
+
ownerId: requestBody.ownerId,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
async callAsyncApi(path, requestBody, options, requestLabel) {
|
|
162
192
|
const resolvedOptions = resolveOptions(options);
|
|
163
|
-
const requestLabel = 'Translate asynchronously (Polyglot)';
|
|
164
193
|
const result = await this.wrapWithErrorHandling(() => {
|
|
165
|
-
return (0, node_core_1.sendPost)(this.client,
|
|
194
|
+
return (0, node_core_1.sendPost)(this.client, path, requestBody, {
|
|
166
195
|
reqContext: resolvedOptions.reqContext,
|
|
167
196
|
retryConfig: this.retryConfig,
|
|
168
197
|
throwOnError: false,
|
|
@@ -174,21 +203,9 @@ class PolyglotClient {
|
|
|
174
203
|
requestLabel,
|
|
175
204
|
});
|
|
176
205
|
});
|
|
177
|
-
if (result.error)
|
|
206
|
+
if (result.error)
|
|
178
207
|
return result;
|
|
179
|
-
|
|
180
|
-
if (result.result.statusCode === 202) {
|
|
181
|
-
return (0, node_core_1.success)(result.result.body);
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
return (0, node_core_1.failure)(new node_core_1.InternalError({
|
|
185
|
-
message: 'Failed to schedule asynchronous translation',
|
|
186
|
-
errorCode: 'FAILED_TO_SCHEDULE_ASYNC_TRANSLATION',
|
|
187
|
-
details: {
|
|
188
|
-
originCorrelationId: requestBody.originCorrelationId,
|
|
189
|
-
},
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
208
|
+
return result.result.statusCode === 202 ? (0, node_core_1.success)(result.result.body) : (0, node_core_1.failure)(null);
|
|
192
209
|
}
|
|
193
210
|
async callLqaSyncApi(request, options) {
|
|
194
211
|
const resolvedOptions = resolveOptions(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolyglotClient.js","sourceRoot":"","sources":["../../src/sdk/PolyglotClient.ts"],"names":[],"mappings":";;;AACA,mDAO4B;AAE5B,4EAAsE;AAKtE,0DAAsD;AACtD,iEAA2F;AAC3F,iDAGuB;
|
|
1
|
+
{"version":3,"file":"PolyglotClient.js","sourceRoot":"","sources":["../../src/sdk/PolyglotClient.ts"],"names":[],"mappings":";;;AACA,mDAO4B;AAE5B,4EAAsE;AAKtE,0DAAsD;AACtD,iEAA2F;AAC3F,iDAGuB;AA0BvB,MAAM,sBAAsB,GAAkB;IAC5C,OAAO,EAAE,KAAK;CACf,CAAA;AAED,SAAS,cAAc,CAAC,OAAsB;IAC5C,OAAO;QACL,GAAG,OAAO;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO;KAC9F,CAAA;AACH,CAAC;AAED,MAAa,cAAc;IACR,MAAM,CAAQ;IACd,aAAa,CAAyB;IACtC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AA;QAC5B,IAAI,IAAA,mBAAO,EAAC,CAAC,CAAC,EAAE,CAAC;YACf,KAAK,GAAG,IAAA,iCAAqB,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,6BAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7D,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,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AA9XD,wCA8XC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommonErrorType, ContentUnitTranslationResponse } from './responses';
|
|
1
|
+
import type { CommonErrorType, ContentUnitTranslationResponse, LqaIssue } from './responses';
|
|
2
2
|
export type TranslateAsyncCallbackRequestBody = {
|
|
3
3
|
data: {
|
|
4
4
|
originCorrelationId: string;
|
|
@@ -8,3 +8,13 @@ export type TranslateAsyncCallbackRequestBody = {
|
|
|
8
8
|
errors: CommonErrorType[];
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
+
export type LqaAsyncCallbackRequestBody = {
|
|
12
|
+
originCorrelationId: string;
|
|
13
|
+
data: {
|
|
14
|
+
contentUnitId: string;
|
|
15
|
+
translationId: string;
|
|
16
|
+
suggestion: string | null;
|
|
17
|
+
issues: LqaIssue[];
|
|
18
|
+
}[];
|
|
19
|
+
errors: CommonErrorType[];
|
|
20
|
+
};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
type AsyncRequestCommons = {
|
|
2
|
+
tenantId: string;
|
|
3
|
+
ownerId: string;
|
|
4
|
+
callbackUrl: string;
|
|
5
|
+
callbackToken: string;
|
|
6
|
+
originCorrelationId: string;
|
|
7
|
+
};
|
|
1
8
|
export type TranslateSyncRequest = {
|
|
2
9
|
sourceLocale: string;
|
|
3
10
|
targetLocale: string;
|
|
@@ -5,13 +12,7 @@ export type TranslateSyncRequest = {
|
|
|
5
12
|
context?: PolyglotAssetsRequest;
|
|
6
13
|
integration?: IntegrationKind;
|
|
7
14
|
};
|
|
8
|
-
export type TranslateAsyncRequestBody = TranslateSyncRequest &
|
|
9
|
-
tenantId: string;
|
|
10
|
-
ownerId: string;
|
|
11
|
-
callbackUrl: string;
|
|
12
|
-
callbackToken: string;
|
|
13
|
-
originCorrelationId: string;
|
|
14
|
-
};
|
|
15
|
+
export type TranslateAsyncRequestBody = TranslateSyncRequest & AsyncRequestCommons;
|
|
15
16
|
export type TranslateSyncContentUnits = {
|
|
16
17
|
id: string;
|
|
17
18
|
context?: {
|
|
@@ -29,6 +30,10 @@ export type LqaSyncRequest = {
|
|
|
29
30
|
contentUnits: LqaContentUnit[];
|
|
30
31
|
integration?: AiIntegrationKind;
|
|
31
32
|
};
|
|
33
|
+
export type LqaAsyncRequestBody = Omit<LqaSyncRequest, 'assets' | 'contentUnits'> & {
|
|
34
|
+
context?: PolyglotAssetsRequest;
|
|
35
|
+
contentUnits: AsyncLqaContentUnit[];
|
|
36
|
+
} & AsyncRequestCommons;
|
|
32
37
|
export type LqaContentUnit = {
|
|
33
38
|
id: string;
|
|
34
39
|
assets?: {
|
|
@@ -36,11 +41,18 @@ export type LqaContentUnit = {
|
|
|
36
41
|
};
|
|
37
42
|
segments: LqaSegment[];
|
|
38
43
|
};
|
|
44
|
+
export type AsyncLqaContentUnit = Omit<LqaContentUnit, 'assets' | 'segments'> & {
|
|
45
|
+
context?: {
|
|
46
|
+
description?: string;
|
|
47
|
+
};
|
|
48
|
+
segments: AsyncLqaSegment[];
|
|
49
|
+
};
|
|
39
50
|
export type LqaSegment = {
|
|
40
51
|
sourceValue: string;
|
|
41
52
|
position: number;
|
|
42
53
|
translations: LqaTranslation[];
|
|
43
54
|
};
|
|
55
|
+
export type AsyncLqaSegment = Omit<LqaSegment, 'position'>;
|
|
44
56
|
export type LqaTranslation = {
|
|
45
57
|
id: string;
|
|
46
58
|
locale: string;
|
|
@@ -80,8 +92,9 @@ export type PolyglotAssetsRequest = {
|
|
|
80
92
|
export type PolyglotGlossaryTermRequest = {
|
|
81
93
|
term: string;
|
|
82
94
|
description?: string;
|
|
83
|
-
translatable
|
|
84
|
-
|
|
95
|
+
translatable?: boolean;
|
|
96
|
+
forbidden?: boolean;
|
|
97
|
+
caseSensitive?: boolean;
|
|
85
98
|
translations: {
|
|
86
99
|
locale: string;
|
|
87
100
|
translation: string;
|
|
@@ -9,7 +9,6 @@ export type PolyglotSyncResponse<T extends object> = {
|
|
|
9
9
|
errors?: CommonErrorType[];
|
|
10
10
|
integration: string;
|
|
11
11
|
};
|
|
12
|
-
export type PolyglotAsyncResponse = Record<string, never>;
|
|
13
12
|
export type CommonErrorType = {
|
|
14
13
|
errorCode: string;
|
|
15
14
|
message: string;
|
|
@@ -40,13 +39,14 @@ export type ContentUnitLqaResponse = {
|
|
|
40
39
|
export type SegmentLqaResponse = {
|
|
41
40
|
id: string;
|
|
42
41
|
value: string;
|
|
43
|
-
issues:
|
|
44
|
-
severity: LqaSeverityResponse;
|
|
45
|
-
category: LqaCategoryResponse;
|
|
46
|
-
comment?: string;
|
|
47
|
-
}[];
|
|
42
|
+
issues: LqaIssue[];
|
|
48
43
|
suggestion?: string;
|
|
49
44
|
};
|
|
45
|
+
export type LqaIssue = {
|
|
46
|
+
severity: LqaSeverityResponse;
|
|
47
|
+
category: LqaCategoryResponse;
|
|
48
|
+
comment?: string;
|
|
49
|
+
};
|
|
50
50
|
export type PolyglotGenerateVariantsResponse = {
|
|
51
51
|
variants: string[];
|
|
52
52
|
integration: string;
|
|
@@ -74,3 +74,4 @@ export type TranslateAsyncResponse = {
|
|
|
74
74
|
requestId: string;
|
|
75
75
|
expectedAt: string;
|
|
76
76
|
};
|
|
77
|
+
export type LqaAsyncResponse = TranslateAsyncResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/polyglot-sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Lokalise",
|
|
6
6
|
"url": "https://lokalise.com/"
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@amplitude/analytics-types": "^2.5.0",
|
|
36
|
-
"@lokalise/fastify-extras": "^
|
|
36
|
+
"@lokalise/fastify-extras": "^20.0.0",
|
|
37
37
|
"@lokalise/id-utils": "^2.0.0",
|
|
38
|
-
"@lokalise/node-core": "^9.
|
|
38
|
+
"@lokalise/node-core": "^9.19.0",
|
|
39
39
|
"@lokalise/zod-extras": "^2.0.1",
|
|
40
|
-
"undici": "^6.
|
|
40
|
+
"undici": "^6.18.0",
|
|
41
41
|
"undici-retry": "^5.0.2",
|
|
42
42
|
"zod": "^3.23.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^20.12.
|
|
45
|
+
"@types/node": "^20.12.12",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
47
47
|
"@typescript-eslint/parser": "^7.4.0",
|
|
48
48
|
"@vitest/coverage-v8": "^0.34.6",
|