@lokalise/polyglot-sdk 5.6.1 → 6.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/sdk/PolyglotClient.d.ts +4 -8
- package/dist/sdk/PolyglotClient.js +20 -35
- package/dist/sdk/PolyglotClient.js.map +1 -1
- package/dist/sdk/polyglotChunkHandler.d.ts +1 -10
- package/dist/sdk/polyglotChunkHandler.js +1 -97
- package/dist/sdk/polyglotChunkHandler.js.map +1 -1
- package/dist/sdk/segmentUtils.d.ts +1 -2
- package/dist/sdk/segmentUtils.js +1 -10
- package/dist/sdk/segmentUtils.js.map +1 -1
- package/dist/sdk/types/requests.d.ts +15 -26
- package/dist/sdk/types/responses.d.ts +24 -12
- package/package.json +6 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
|
+
import type { RequestResult } from 'undici-retry';
|
|
2
3
|
import type { ClientOptions, ClientOptionsWithRequestContext, PolyglotClientConfig } from './types/client';
|
|
3
|
-
import type { GenerateVariantsRequest, LqaAsyncRequestBody,
|
|
4
|
-
import type {
|
|
4
|
+
import type { GenerateVariantsRequest, LqaAsyncRequestBody, LqaSyncRequestBody, ScoreTranslationsRequest, TranslateAsyncRequestBody, TranslateSyncRequest } from './types/requests';
|
|
5
|
+
import type { ContentUnitTranslationResponse, LqaSyncResponse, PolyglotClientSyncIterativeResponse, ScoreTranslationsResponse, TranslateAsyncResponse } from './types/responses';
|
|
5
6
|
export declare class PolyglotClient {
|
|
6
7
|
private readonly client;
|
|
7
8
|
private readonly clientHeaders;
|
|
@@ -13,11 +14,6 @@ export declare class PolyglotClient {
|
|
|
13
14
|
* the amount of segments exceeds synchronous API limits and will yield the results separately.
|
|
14
15
|
*/
|
|
15
16
|
translateSyncIterative(request: TranslateSyncRequest, options?: ClientOptions): AsyncGenerator<PolyglotClientSyncIterativeResponse<ContentUnitTranslationResponse>>;
|
|
16
|
-
/**
|
|
17
|
-
* Reviews segment translations via LQA process with /lqa-sync API. Will chunk the request automatically into batches if
|
|
18
|
-
* the amount of segments exceeds synchronous API limits and will yield the results separately.
|
|
19
|
-
*/
|
|
20
|
-
lqaSyncIterative(request: LqaSyncRequest, options?: ClientOptions): AsyncGenerator<PolyglotClientSyncIterativeResponse<ContentUnitLqaResponse>>;
|
|
21
17
|
/**
|
|
22
18
|
* Re-translates a given translation pair and provides several different variants. Can take previously generated
|
|
23
19
|
* variants as an input - in attempt to avoid repetition.
|
|
@@ -30,8 +26,8 @@ export declare class PolyglotClient {
|
|
|
30
26
|
private callTranslateSyncApi;
|
|
31
27
|
translateAsync(requestBody: TranslateAsyncRequestBody, options: ClientOptionsWithRequestContext): Promise<Either<Error, TranslateAsyncResponse>>;
|
|
32
28
|
lqaAsync(requestBody: LqaAsyncRequestBody, options: ClientOptionsWithRequestContext): Promise<Either<Error, TranslateAsyncResponse>>;
|
|
29
|
+
lqaSync(requestBody: LqaSyncRequestBody, options: ClientOptionsWithRequestContext): Promise<RequestResult<LqaSyncResponse>>;
|
|
33
30
|
private callAsyncApi;
|
|
34
|
-
private callLqaSyncApi;
|
|
35
31
|
private wrapWithErrorHandling;
|
|
36
32
|
/**
|
|
37
33
|
* Calls the provided request function and logs the execution time and metadata with the provided logger
|
|
@@ -56,19 +56,6 @@ class PolyglotClient {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Reviews segment translations via LQA process with /lqa-sync API. Will chunk the request automatically into batches if
|
|
61
|
-
* the amount of segments exceeds synchronous API limits and will yield the results separately.
|
|
62
|
-
*/
|
|
63
|
-
async *lqaSyncIterative(request, options = DEFAULT_CLIENT_OPTIONS) {
|
|
64
|
-
const chunks = (0, polyglotChunkHandler_1.getChunkedLqaRequest)(request);
|
|
65
|
-
for (const requestChunked of chunks) {
|
|
66
|
-
yield {
|
|
67
|
-
response: await this.callLqaSyncApi(requestChunked, options),
|
|
68
|
-
segmentIdsProcessedByContentUnitId: (0, segmentUtils_1.groupLqaSegmentIdsProcessedByContentUnitId)(requestChunked.contentUnits),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
59
|
/**
|
|
73
60
|
* Re-translates a given translation pair and provides several different variants. Can take previously generated
|
|
74
61
|
* variants as an input - in attempt to avoid repetition.
|
|
@@ -188,13 +175,13 @@ class PolyglotClient {
|
|
|
188
175
|
}
|
|
189
176
|
return result;
|
|
190
177
|
}
|
|
191
|
-
async
|
|
178
|
+
async lqaSync(requestBody, options) {
|
|
192
179
|
const resolvedOptions = resolveOptions(options);
|
|
193
|
-
const
|
|
194
|
-
|
|
180
|
+
const requestLabel = 'LQA synchronously (Polyglot)';
|
|
181
|
+
return await this.wrapWithInstrumentation(() => {
|
|
182
|
+
return (0, node_core_1.sendPost)(this.client, '/v2/content/actions/lqa-sync', requestBody, {
|
|
195
183
|
reqContext: resolvedOptions.reqContext,
|
|
196
184
|
retryConfig: this.retryConfig,
|
|
197
|
-
throwOnError: false,
|
|
198
185
|
timeout: resolvedOptions.timeout,
|
|
199
186
|
headers: {
|
|
200
187
|
...this.clientHeaders,
|
|
@@ -202,18 +189,24 @@ class PolyglotClient {
|
|
|
202
189
|
},
|
|
203
190
|
requestLabel,
|
|
204
191
|
});
|
|
192
|
+
}, {
|
|
193
|
+
requestLabel,
|
|
194
|
+
callMetadata: {
|
|
195
|
+
...resolvedOptions.metadata,
|
|
196
|
+
fakeProcessing: JSON.stringify(resolvedOptions.fakeProcessing),
|
|
197
|
+
reqContext: JSON.stringify({
|
|
198
|
+
reqId: resolvedOptions.reqContext?.reqId,
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
205
201
|
});
|
|
206
|
-
if (result.error)
|
|
207
|
-
return result;
|
|
208
|
-
return result.result.statusCode === 202 ? (0, node_core_1.success)(result.result.body) : (0, node_core_1.failure)(null);
|
|
209
202
|
}
|
|
210
|
-
async
|
|
203
|
+
async callAsyncApi(path, requestBody, options, requestLabel) {
|
|
211
204
|
const resolvedOptions = resolveOptions(options);
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
return (0, node_core_1.sendPost)(this.client, '/v1/content/actions/lqa-sync', request, {
|
|
205
|
+
const result = await this.wrapWithErrorHandling(() => {
|
|
206
|
+
return (0, node_core_1.sendPost)(this.client, path, requestBody, {
|
|
215
207
|
reqContext: resolvedOptions.reqContext,
|
|
216
208
|
retryConfig: this.retryConfig,
|
|
209
|
+
throwOnError: false,
|
|
217
210
|
timeout: resolvedOptions.timeout,
|
|
218
211
|
headers: {
|
|
219
212
|
...this.clientHeaders,
|
|
@@ -221,18 +214,10 @@ class PolyglotClient {
|
|
|
221
214
|
},
|
|
222
215
|
requestLabel,
|
|
223
216
|
});
|
|
224
|
-
}, {
|
|
225
|
-
requestLabel,
|
|
226
|
-
callMetadata: {
|
|
227
|
-
...resolvedOptions.metadata,
|
|
228
|
-
language: `${request.sourceLocale}`,
|
|
229
|
-
fakeProcessing: JSON.stringify(resolvedOptions.fakeProcessing),
|
|
230
|
-
reqContext: JSON.stringify({
|
|
231
|
-
reqId: resolvedOptions.reqContext?.reqId,
|
|
232
|
-
}),
|
|
233
|
-
},
|
|
234
217
|
});
|
|
235
|
-
|
|
218
|
+
if (result.error)
|
|
219
|
+
return result;
|
|
220
|
+
return result.result.statusCode === 202 ? (0, node_core_1.success)(result.result.body) : (0, node_core_1.failure)(null);
|
|
236
221
|
}
|
|
237
222
|
async wrapWithErrorHandling(innerFn) {
|
|
238
223
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolyglotClient.js","sourceRoot":"","sources":["../../src/sdk/PolyglotClient.ts"],"names":[],"mappings":";;;AACA,mDAO4B;AAE5B,4EAAsE;AAKtE,0DAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"PolyglotClient.js","sourceRoot":"","sources":["../../src/sdk/PolyglotClient.ts"],"names":[],"mappings":";;;AACA,mDAO4B;AAE5B,4EAAsE;AAKtE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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;AApWD,wCAoWC"}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TranslateSyncRequest } from './types/requests';
|
|
2
2
|
/**
|
|
3
3
|
* Polyglot synchronous APIs are limited to X items at once - to keep the response time reasonable and not hit
|
|
4
4
|
* any sort of API gateway timeouts.
|
|
5
5
|
*/
|
|
6
6
|
export declare const REQUEST_SIZE_LIMIT_TRANSLATE_SYNC = 15;
|
|
7
|
-
export declare const REQUEST_SIZE_LIMIT_LQA_SYNC = 15;
|
|
8
|
-
export type ContentUnitSegment = {
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
export type ContentUnitResponse<T extends ContentUnitSegment> = {
|
|
12
|
-
id: string;
|
|
13
|
-
segments: T[];
|
|
14
|
-
};
|
|
15
7
|
export declare function getChunkedTranslationRequest(request: TranslateSyncRequest, polyglotSegmentMaxProcessLimit?: number): Generator<TranslateSyncRequest>;
|
|
16
|
-
export declare function getChunkedLqaRequest(request: LqaSyncRequest, polyglotSegmentMaxProcessLimit?: number): Generator<LqaSyncRequest>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getChunkedTranslationRequest = exports.REQUEST_SIZE_LIMIT_TRANSLATE_SYNC = void 0;
|
|
4
4
|
const node_core_1 = require("@lokalise/node-core");
|
|
5
5
|
/**
|
|
6
6
|
* Polyglot synchronous APIs are limited to X items at once - to keep the response time reasonable and not hit
|
|
7
7
|
* any sort of API gateway timeouts.
|
|
8
8
|
*/
|
|
9
9
|
exports.REQUEST_SIZE_LIMIT_TRANSLATE_SYNC = 15;
|
|
10
|
-
exports.REQUEST_SIZE_LIMIT_LQA_SYNC = 15;
|
|
11
10
|
// TODO: AP-1395 - Look at refactoring the chunk methods into smaller alternatives
|
|
12
11
|
// eslint-disable-next-line max-statements
|
|
13
12
|
function* getChunkedTranslationRequest(request, polyglotSegmentMaxProcessLimit = exports.REQUEST_SIZE_LIMIT_TRANSLATE_SYNC) {
|
|
@@ -46,99 +45,4 @@ function* getChunkedTranslationRequest(request, polyglotSegmentMaxProcessLimit =
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
exports.getChunkedTranslationRequest = getChunkedTranslationRequest;
|
|
49
|
-
// TODO: AP-1395 - Look at refactoring the chunk methods into smaller alternatives
|
|
50
|
-
// eslint-disable-next-line max-statements
|
|
51
|
-
function* getChunkedLqaRequest(request, polyglotSegmentMaxProcessLimit = exports.REQUEST_SIZE_LIMIT_LQA_SYNC) {
|
|
52
|
-
const contentUnits = request.contentUnits.filter((contentUnit) => contentUnit.segments.length > 0);
|
|
53
|
-
if (contentUnits.length === 0) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const chunkedRequest = {
|
|
57
|
-
sourceLocale: request.sourceLocale,
|
|
58
|
-
contentUnits: [],
|
|
59
|
-
assets: request.assets,
|
|
60
|
-
};
|
|
61
|
-
let chunkedContentUnit = {
|
|
62
|
-
id: '',
|
|
63
|
-
segments: [],
|
|
64
|
-
};
|
|
65
|
-
let totalTranslationsInRequest = 0;
|
|
66
|
-
for (const contentUnit of contentUnits) {
|
|
67
|
-
let translationsChunked = [];
|
|
68
|
-
let startOffset = 0;
|
|
69
|
-
// ** We have existing translations from a previous contentUnit. Add it to the chunkRequest.
|
|
70
|
-
if (totalTranslationsInRequest !== 0) {
|
|
71
|
-
chunkedRequest.contentUnits.push(chunkedContentUnit);
|
|
72
|
-
}
|
|
73
|
-
// Start a new chunkedContentUnit.
|
|
74
|
-
chunkedContentUnit = {
|
|
75
|
-
id: contentUnit.id,
|
|
76
|
-
segments: [],
|
|
77
|
-
};
|
|
78
|
-
// Cycle through a contentUnit's segment assigning it to translationsChunked until we cannot extract anything
|
|
79
|
-
// further from that segment array.
|
|
80
|
-
for (const segment of contentUnit.segments) {
|
|
81
|
-
do {
|
|
82
|
-
if (!segment.translations || segment.translations.length === 0) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
// Grab translations based off a start index, and it's length calculated by how many translations we
|
|
86
|
-
// have already fetched e.g. We are on the first segment, and we have collected nothing. As a result it
|
|
87
|
-
// will start: 0, end: 15. However, this segment only has four translations, so we add this to the
|
|
88
|
-
// chunkedContentUnit and get out of the current loop and move onto the next segment within the current
|
|
89
|
-
// contentUnit. That next segment has 20 translations. We fetch the next batch of translations
|
|
90
|
-
// start: 0, end: (15 - 4) and add this to the chunkedContentUnit array.
|
|
91
|
-
//
|
|
92
|
-
// We have now reached the limit to chunk-by we yield chunkedContentUnit with the contentUnits with
|
|
93
|
-
// segments and it's translations, reset the start index and stay within the loop because the current
|
|
94
|
-
// segment still has translations to process.
|
|
95
|
-
//
|
|
96
|
-
// If we haven't reached the limit for translations within a contentUnit, we persist it further up in
|
|
97
|
-
// the previous loop **
|
|
98
|
-
//
|
|
99
|
-
// Rinse, wash, and repeat
|
|
100
|
-
translationsChunked = segment.translations.slice(startOffset, polyglotSegmentMaxProcessLimit + startOffset - totalTranslationsInRequest);
|
|
101
|
-
startOffset += polyglotSegmentMaxProcessLimit - totalTranslationsInRequest;
|
|
102
|
-
if (translationsChunked.length === 0) {
|
|
103
|
-
startOffset = 0;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
// Any translations that do not have a locale will be removed
|
|
107
|
-
translationsChunked = filterTranslationsWithoutLanguages(translationsChunked);
|
|
108
|
-
totalTranslationsInRequest += translationsChunked.length;
|
|
109
|
-
if (translationsChunked) {
|
|
110
|
-
chunkedContentUnit.segments.push({
|
|
111
|
-
position: segment.position,
|
|
112
|
-
sourceValue: segment.sourceValue,
|
|
113
|
-
translations: translationsChunked,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
// If we have reached the limit of the number of translations, yield the result and reset everything,
|
|
117
|
-
// except translationChunked.
|
|
118
|
-
if (totalTranslationsInRequest === polyglotSegmentMaxProcessLimit) {
|
|
119
|
-
chunkedRequest.contentUnits.push(chunkedContentUnit);
|
|
120
|
-
yield (0, node_core_1.deepClone)(chunkedRequest);
|
|
121
|
-
chunkedContentUnit = {
|
|
122
|
-
id: contentUnit.id,
|
|
123
|
-
segments: [],
|
|
124
|
-
};
|
|
125
|
-
chunkedRequest.contentUnits = [];
|
|
126
|
-
totalTranslationsInRequest = 0;
|
|
127
|
-
}
|
|
128
|
-
// Did we manage to find any translations from the slice? If not, that means the segment no longer has
|
|
129
|
-
// anything more, move onto the next segment keep whatever chunkedContentUnit we have, persist it
|
|
130
|
-
// further up in the method **.
|
|
131
|
-
} while (translationsChunked.length !== 0);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// In the possibility we have anything left over yield it back.
|
|
135
|
-
if (totalTranslationsInRequest !== 0) {
|
|
136
|
-
chunkedRequest.contentUnits.push(chunkedContentUnit);
|
|
137
|
-
yield (0, node_core_1.deepClone)(chunkedRequest);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.getChunkedLqaRequest = getChunkedLqaRequest;
|
|
141
|
-
const filterTranslationsWithoutLanguages = (translations) => {
|
|
142
|
-
return translations.filter((translation) => translation.locale && translation.locale.length !== 0);
|
|
143
|
-
};
|
|
144
48
|
//# sourceMappingURL=polyglotChunkHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyglotChunkHandler.js","sourceRoot":"","sources":["../../src/sdk/polyglotChunkHandler.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;
|
|
1
|
+
{"version":3,"file":"polyglotChunkHandler.js","sourceRoot":"","sources":["../../src/sdk/polyglotChunkHandler.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAI/C;;;GAGG;AACU,QAAA,iCAAiC,GAAG,EAAE,CAAA;AAEnD,kFAAkF;AAClF,0CAA0C;AAC1C,QAAe,CAAC,CAAC,4BAA4B,CAC3C,OAA6B,EAC7B,iCAAyC,yCAAiC;IAE1E,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAClG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IAED,MAAM,cAAc,GAAyB;QAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,YAAY,EAAE,EAAE;KACjB,CAAA;IAED,IAAI,sBAAsB,GAAG,CAAC,CAAA;IAC9B,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,eAAe,GAAG,EAAE,CAAA;QACxB,IAAI,WAAW,GAAG,CAAC,CAAA;QAEnB,GAAG,CAAC;YACF,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAC1C,WAAW,EACX,8BAA8B,GAAG,WAAW,GAAG,sBAAsB,CACtE,CAAA;YAED,WAAW,IAAI,8BAA8B,GAAG,sBAAsB,CAAA;YACtE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjC,WAAW,GAAG,CAAC,CAAA;gBACf,SAAQ;YACV,CAAC;YAED,sBAAsB,IAAI,eAAe,CAAC,MAAM,CAAA;YAChD,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAA;YAE/E,IAAI,sBAAsB,KAAK,8BAA8B,EAAE,CAAC;gBAC9D,MAAM,IAAA,qBAAS,EAAC,cAAc,CAAC,CAAA;gBAC/B,cAAc,CAAC,YAAY,GAAG,EAAE,CAAA;gBAChC,sBAAsB,GAAG,CAAC,CAAA;YAC5B,CAAC;QACH,CAAC,QAAQ,eAAe,CAAC,MAAM,KAAK,CAAC,EAAC;IACxC,CAAC;IAED,IAAI,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,IAAA,qBAAS,EAAC,cAAc,CAAC,CAAA;IACjC,CAAC;AACH,CAAC;AA/CD,oEA+CC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TranslateSyncContentUnits } from './types/requests';
|
|
2
2
|
export declare function groupTranslationSegmentIdsProcessedByContentUnitId(contentUnits: readonly TranslateSyncContentUnits[]): Record<string, string[]>;
|
|
3
|
-
export declare function groupLqaSegmentIdsProcessedByContentUnitId(contentUnits: readonly LqaContentUnit[]): Record<string, string[]>;
|
package/dist/sdk/segmentUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.groupTranslationSegmentIdsProcessedByContentUnitId = void 0;
|
|
4
4
|
function groupTranslationSegmentIdsProcessedByContentUnitId(contentUnits) {
|
|
5
5
|
return contentUnits.reduce((acc, cu) => {
|
|
6
6
|
if (!acc[cu.id])
|
|
@@ -10,13 +10,4 @@ function groupTranslationSegmentIdsProcessedByContentUnitId(contentUnits) {
|
|
|
10
10
|
}, {});
|
|
11
11
|
}
|
|
12
12
|
exports.groupTranslationSegmentIdsProcessedByContentUnitId = groupTranslationSegmentIdsProcessedByContentUnitId;
|
|
13
|
-
function groupLqaSegmentIdsProcessedByContentUnitId(contentUnits) {
|
|
14
|
-
return contentUnits.reduce((acc, cu) => {
|
|
15
|
-
if (!acc[cu.id])
|
|
16
|
-
acc[cu.id] = [];
|
|
17
|
-
acc[cu.id].push(...cu.segments.flatMap((s) => s.translations).map((t) => t.id));
|
|
18
|
-
return acc;
|
|
19
|
-
}, {});
|
|
20
|
-
}
|
|
21
|
-
exports.groupLqaSegmentIdsProcessedByContentUnitId = groupLqaSegmentIdsProcessedByContentUnitId;
|
|
22
13
|
//# sourceMappingURL=segmentUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmentUtils.js","sourceRoot":"","sources":["../../src/sdk/segmentUtils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,kDAAkD,CAChE,YAAkD;IAElD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;QACV,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAA;QAChC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAChD,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,EAA8B,CAC/B,CAAA;AACH,CAAC;AAXD,gHAWC
|
|
1
|
+
{"version":3,"file":"segmentUtils.js","sourceRoot":"","sources":["../../src/sdk/segmentUtils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,kDAAkD,CAChE,YAAkD;IAElD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;QACV,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAA;QAChC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAChD,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,EAA8B,CAC/B,CAAA;AACH,CAAC;AAXD,gHAWC"}
|
|
@@ -24,40 +24,29 @@ export type TranslateSyncContentUnits = {
|
|
|
24
24
|
value: string;
|
|
25
25
|
}[];
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
28
|
-
sourceLocale: string;
|
|
29
|
-
assets?: PolyglotAssetsRequest;
|
|
30
|
-
contentUnits: LqaContentUnit[];
|
|
31
|
-
integration?: AiIntegrationKind;
|
|
32
|
-
};
|
|
33
|
-
export type LqaAsyncRequestBody = Omit<LqaSyncRequest, 'assets' | 'contentUnits'> & {
|
|
34
|
-
context?: PolyglotAssetsRequest;
|
|
35
|
-
contentUnits: AsyncLqaContentUnit[];
|
|
36
|
-
} & AsyncRequestCommons;
|
|
37
|
-
export type LqaContentUnit = {
|
|
27
|
+
export type LqaTranslation = {
|
|
38
28
|
id: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
segments: LqaSegment[];
|
|
43
|
-
};
|
|
44
|
-
export type AsyncLqaContentUnit = Omit<LqaContentUnit, 'assets' | 'segments'> & {
|
|
45
|
-
context?: {
|
|
46
|
-
description?: string;
|
|
47
|
-
};
|
|
48
|
-
segments: AsyncLqaSegment[];
|
|
29
|
+
locale: string;
|
|
30
|
+
value: string;
|
|
49
31
|
};
|
|
50
32
|
export type LqaSegment = {
|
|
51
33
|
sourceValue: string;
|
|
52
|
-
position: number;
|
|
53
34
|
translations: LqaTranslation[];
|
|
54
35
|
};
|
|
55
|
-
export type
|
|
56
|
-
export type LqaTranslation = {
|
|
36
|
+
export type LqaContentUnit = {
|
|
57
37
|
id: string;
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
context?: {
|
|
39
|
+
description?: string;
|
|
40
|
+
};
|
|
41
|
+
segments: LqaSegment[];
|
|
42
|
+
};
|
|
43
|
+
export type LqaSyncRequestBody = {
|
|
44
|
+
sourceLocale: string;
|
|
45
|
+
context?: PolyglotAssetsRequest;
|
|
46
|
+
integration?: AiIntegrationKind;
|
|
47
|
+
contentUnits: LqaContentUnit[];
|
|
60
48
|
};
|
|
49
|
+
export type LqaAsyncRequestBody = AsyncRequestCommons & LqaSyncRequestBody;
|
|
61
50
|
type SegmentVariantsMode = 'REPHRASE' | 'SHORTEN';
|
|
62
51
|
type SegmentVariantsHistory = {
|
|
63
52
|
values: string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { IntegrationKind } from './requests';
|
|
1
2
|
type ObjectValues<T> = T[keyof T];
|
|
2
|
-
export type PolyglotClientSyncIterativeResponse<T extends
|
|
3
|
+
export type PolyglotClientSyncIterativeResponse<T extends ContentUnitTranslationResponse> = {
|
|
3
4
|
segmentIdsProcessedByContentUnitId: Record<string, string[]>;
|
|
4
5
|
response: T[];
|
|
5
6
|
};
|
|
@@ -58,16 +59,6 @@ export declare const LqaCategoryResponseEnum: {
|
|
|
58
59
|
readonly VERITY: "verity";
|
|
59
60
|
};
|
|
60
61
|
export type LqaCategoryResponseEnum = ObjectValues<typeof LqaCategoryResponseEnum>;
|
|
61
|
-
export type ContentUnitLqaResponse = {
|
|
62
|
-
id: string;
|
|
63
|
-
segments: SegmentLqaResponse[];
|
|
64
|
-
};
|
|
65
|
-
export type SegmentLqaResponse = {
|
|
66
|
-
id: string;
|
|
67
|
-
value: string;
|
|
68
|
-
issues: LqaIssue[];
|
|
69
|
-
suggestion?: string;
|
|
70
|
-
};
|
|
71
62
|
export type LqaIssue = {
|
|
72
63
|
severity: LqaSeverityResponseEnum;
|
|
73
64
|
category: LqaCategoryResponseEnum;
|
|
@@ -96,9 +87,30 @@ export type ScoreTranslationsResponse = {
|
|
|
96
87
|
};
|
|
97
88
|
}>;
|
|
98
89
|
};
|
|
99
|
-
export type
|
|
90
|
+
export type AsyncResponse = {
|
|
100
91
|
requestId: string;
|
|
101
92
|
expectedAt: string;
|
|
102
93
|
};
|
|
94
|
+
export type TranslateAsyncResponse = AsyncResponse;
|
|
103
95
|
export type LqaAsyncResponse = TranslateAsyncResponse;
|
|
96
|
+
export type LqaSyncResponse = {
|
|
97
|
+
integration: IntegrationKind;
|
|
98
|
+
data: Array<{
|
|
99
|
+
contentUnitId: string;
|
|
100
|
+
translationId: string;
|
|
101
|
+
suggestion: null | string;
|
|
102
|
+
issues: Array<{
|
|
103
|
+
category: LqaCategoryResponseEnum;
|
|
104
|
+
severity: LqaSeverityResponseEnum;
|
|
105
|
+
comment: null | string;
|
|
106
|
+
}>;
|
|
107
|
+
}>;
|
|
108
|
+
errors?: Array<{
|
|
109
|
+
contentUnitId: string;
|
|
110
|
+
translationId: string;
|
|
111
|
+
message: string;
|
|
112
|
+
errorCode: string;
|
|
113
|
+
details?: Record<string, unknown>;
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
104
116
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/polyglot-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.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.1",
|
|
36
|
-
"@lokalise/fastify-extras": "^21.
|
|
37
|
-
"@lokalise/id-utils": "^2.
|
|
36
|
+
"@lokalise/fastify-extras": "^21.2.0",
|
|
37
|
+
"@lokalise/id-utils": "^2.1.0",
|
|
38
38
|
"@lokalise/node-core": "^9.20.0",
|
|
39
39
|
"@lokalise/zod-extras": "^2.1.0",
|
|
40
|
-
"undici": "^6.
|
|
40
|
+
"undici": "^6.19.2",
|
|
41
41
|
"undici-retry": "^5.0.2",
|
|
42
42
|
"zod": "^3.23.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^20.14.
|
|
45
|
+
"@types/node": "^20.14.8",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
47
47
|
"@typescript-eslint/parser": "^7.4.0",
|
|
48
48
|
"@vitest/coverage-v8": "^1.6.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"eslint": "^8.57.0",
|
|
51
51
|
"eslint-plugin-import": "^2.29.1",
|
|
52
52
|
"eslint-plugin-vitest": "^0.4.1",
|
|
53
|
-
"mockttp": "^3.
|
|
53
|
+
"mockttp": "^3.12.0",
|
|
54
54
|
"prettier": "^3.2.5",
|
|
55
55
|
"shx": "^0.3.4",
|
|
56
56
|
"ts-deepmerge": "^7.0.0",
|