@lokalise/polyglot-sdk 9.1.0 → 10.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.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk/PolyglotClient.d.ts +13 -11
- package/dist/sdk/PolyglotClient.js +80 -115
- package/dist/sdk/PolyglotClient.js.map +1 -1
- package/dist/sdk/types/client.d.ts +0 -10
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PolyglotClient } from './sdk/PolyglotClient';
|
|
2
2
|
export { PolyglotError } from './sdk/errors/PolyglotError';
|
|
3
|
-
export
|
|
3
|
+
export type { ClientOptions, PolyglotClientConfig } from './sdk/types/client';
|
|
4
4
|
export { AiIntegrationEngineEnum, MtIntegrationEngineEnum, RealIntegrationEngineEnum, IntegrationEngineEnum, } from './sdk/schemas/common/commonSchemas';
|
|
5
5
|
export { TRANSLATION_CONTEXT_SCHEMA, isStructuredStyleGuide, } from './sdk/schemas/common/translationContextSchemas';
|
|
6
6
|
export type { StructuredStyleGuide, FreeformStyleGuide, StyleGuideData, TranslationContext, } from './sdk/schemas/common/translationContextSchemas';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var PolyglotClient_1 = require("./sdk/PolyglotClient");
|
|
|
6
6
|
Object.defineProperty(exports, "PolyglotClient", { enumerable: true, get: function () { return PolyglotClient_1.PolyglotClient; } });
|
|
7
7
|
var PolyglotError_1 = require("./sdk/errors/PolyglotError");
|
|
8
8
|
Object.defineProperty(exports, "PolyglotError", { enumerable: true, get: function () { return PolyglotError_1.PolyglotError; } });
|
|
9
|
-
tslib_1.__exportStar(require("./sdk/types/client"), exports);
|
|
10
9
|
var commonSchemas_1 = require("./sdk/schemas/common/commonSchemas");
|
|
11
10
|
Object.defineProperty(exports, "AiIntegrationEngineEnum", { enumerable: true, get: function () { return commonSchemas_1.AiIntegrationEngineEnum; } });
|
|
12
11
|
Object.defineProperty(exports, "MtIntegrationEngineEnum", { enumerable: true, get: function () { return commonSchemas_1.MtIntegrationEngineEnum; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAA5C,gHAAA,cAAc,OAAA;AACvB,4DAA0D;AAAjD,8GAAA,aAAa,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAA5C,gHAAA,cAAc,OAAA;AACvB,4DAA0D;AAAjD,8GAAA,aAAa,OAAA;AAGtB,oEAK2C;AAJzC,wHAAA,uBAAuB,OAAA;AACvB,wHAAA,uBAAuB,OAAA;AACvB,0HAAA,yBAAyB,OAAA;AACzB,sHAAA,qBAAqB,OAAA;AAEvB,4FAGuD;AAFrD,uIAAA,0BAA0B,OAAA;AAC1B,mIAAA,sBAAsB,OAAA;AASxB,iEAA4F;AAAnF,qHAAA,oBAAoB,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AACnD,8EAAmD;AACnD,6EAAkD;AAClD,+EAAoD;AACpD,uFAA4D;AAE5D,2FAIyD;AAHvD,uIAAA,6BAA6B,OAAA;AAC7B,0IAAA,gCAAgC,OAAA;AAChC,2IAAA,iCAAiC,OAAA;AAQnC,6FAK0D;AAJxD,yIAAA,8BAA8B,OAAA;AAC9B,4IAAA,iCAAiC,OAAA;AACjC,6IAAA,kCAAkC,OAAA;AAClC,6IAAA,kCAAkC,OAAA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
|
-
import
|
|
2
|
+
import { InternalError } from '@lokalise/node-core';
|
|
3
|
+
import { PolyglotError } from './errors/PolyglotError';
|
|
3
4
|
import type { LqaAsyncV1Body, LqaAsyncV1Response } from './schemas/lqa/lqaAsyncV1Schemas';
|
|
4
5
|
import type { LqaSyncV2Body, LqaSyncV2Response } from './schemas/lqa/lqaSyncV2Schemas';
|
|
5
6
|
import type { ScoreV1Body, ScoreV1Response } from './schemas/scoring/scoreV1Schemas';
|
|
6
|
-
import type { GenerateVariantsV1Body } from './schemas/translation/generateVariantsV1';
|
|
7
|
+
import type { GenerateVariantsV1Body, GenerateVariantsV1Response } from './schemas/translation/generateVariantsV1';
|
|
7
8
|
import type { TranslateAsyncV2Body, TranslateAsyncV2Response } from './schemas/translation/translateAsyncV2Schemas';
|
|
8
9
|
import type { TranslateSyncV2Body, TranslateSyncV2Response } from './schemas/translation/translateSyncV2Schemas';
|
|
9
|
-
import type { ClientOptions,
|
|
10
|
+
import type { ClientOptions, PolyglotClientConfig } from './types/client';
|
|
11
|
+
type InstrumentationOutput<T> = Either<PolyglotError | InternalError, T>;
|
|
10
12
|
export declare class PolyglotClient {
|
|
11
13
|
private readonly client;
|
|
12
14
|
private readonly clientHeaders;
|
|
@@ -17,17 +19,16 @@ export declare class PolyglotClient {
|
|
|
17
19
|
* Re-translates a given translation pair and provides several different variants. Can take previously generated
|
|
18
20
|
* variants as an input - in attempt to avoid repetition.
|
|
19
21
|
*/
|
|
20
|
-
generateVariants(request: GenerateVariantsV1Body, options?: ClientOptions): Promise<
|
|
22
|
+
generateVariants(request: GenerateVariantsV1Body, options?: ClientOptions): Promise<InstrumentationOutput<GenerateVariantsV1Response>>;
|
|
21
23
|
/**
|
|
22
24
|
* Scores passed translations
|
|
23
25
|
*/
|
|
24
|
-
scoreTranslations(request: ScoreV1Body, options?: ClientOptions): Promise<ScoreV1Response
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
lqaAsync(requestBody: LqaAsyncV1Body, options
|
|
28
|
-
lqaSync(requestBody: LqaSyncV2Body, options
|
|
29
|
-
private
|
|
30
|
-
private wrapWithErrorHandling;
|
|
26
|
+
scoreTranslations(request: ScoreV1Body, options?: ClientOptions): Promise<InstrumentationOutput<ScoreV1Response>>;
|
|
27
|
+
translateAsync(requestBody: TranslateAsyncV2Body, options?: ClientOptions): Promise<InstrumentationOutput<TranslateAsyncV2Response>>;
|
|
28
|
+
translateSync(requestBody: TranslateSyncV2Body, options?: ClientOptions): Promise<InstrumentationOutput<TranslateSyncV2Response>>;
|
|
29
|
+
lqaAsync(requestBody: LqaAsyncV1Body, options?: ClientOptions): Promise<InstrumentationOutput<LqaAsyncV1Response>>;
|
|
30
|
+
lqaSync(requestBody: LqaSyncV2Body, options?: ClientOptions): Promise<InstrumentationOutput<LqaSyncV2Response>>;
|
|
31
|
+
private getRequestOptions;
|
|
31
32
|
/**
|
|
32
33
|
* Calls the provided request function and logs the execution time and metadata with the provided logger
|
|
33
34
|
* @private
|
|
@@ -35,3 +36,4 @@ export declare class PolyglotClient {
|
|
|
35
36
|
private wrapWithInstrumentation;
|
|
36
37
|
private wrapError;
|
|
37
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PolyglotClient = void 0;
|
|
4
|
+
const backend_http_client_1 = require("@lokalise/backend-http-client");
|
|
4
5
|
const node_core_1 = require("@lokalise/node-core");
|
|
5
|
-
const typeUtils_1 = require("@lokalise/node-core/dist/src/utils/typeUtils");
|
|
6
6
|
const PolyglotError_1 = require("./errors/PolyglotError");
|
|
7
|
+
const lqaSyncV2Schemas_1 = require("./schemas/lqa/lqaSyncV2Schemas");
|
|
8
|
+
const scoreV1Schemas_1 = require("./schemas/scoring/scoreV1Schemas");
|
|
9
|
+
const generateVariantsV1_1 = require("./schemas/translation/generateVariantsV1");
|
|
10
|
+
const translateAsyncV2Schemas_1 = require("./schemas/translation/translateAsyncV2Schemas");
|
|
11
|
+
const translateSyncV2Schemas_1 = require("./schemas/translation/translateSyncV2Schemas");
|
|
7
12
|
const DEFAULT_CLIENT_OPTIONS = {
|
|
8
13
|
timeout: 30000,
|
|
9
14
|
};
|
|
@@ -19,7 +24,7 @@ class PolyglotClient {
|
|
|
19
24
|
retryConfig;
|
|
20
25
|
logger;
|
|
21
26
|
constructor({ baseUrl, jwtToken, retryConfig, logger }) {
|
|
22
|
-
this.client = (0,
|
|
27
|
+
this.client = (0, backend_http_client_1.buildClient)(baseUrl);
|
|
23
28
|
this.clientHeaders = {
|
|
24
29
|
'Content-Type': 'application/json',
|
|
25
30
|
Authorization: `Bearer ${jwtToken}`,
|
|
@@ -46,20 +51,12 @@ class PolyglotClient {
|
|
|
46
51
|
*/
|
|
47
52
|
async generateVariants(request, options = DEFAULT_CLIENT_OPTIONS) {
|
|
48
53
|
const resolvedOptions = resolveOptions(options);
|
|
49
|
-
if (request.sourceValue.trim() === '' || request.targetValue.trim() === '') {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
54
|
const requestLabel = 'Generate variants (Polyglot)';
|
|
53
|
-
|
|
54
|
-
return (0,
|
|
55
|
-
|
|
56
|
-
retryConfig: this.retryConfig,
|
|
57
|
-
timeout: resolvedOptions.timeout,
|
|
58
|
-
headers: {
|
|
59
|
-
...this.clientHeaders,
|
|
60
|
-
'x-fake-processing': resolvedOptions.fakeProcessing ? 'true' : undefined,
|
|
61
|
-
},
|
|
55
|
+
return await this.wrapWithInstrumentation(() => {
|
|
56
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v1/content/actions/generate-variants', request, {
|
|
57
|
+
...this.getRequestOptions(resolvedOptions),
|
|
62
58
|
requestLabel,
|
|
59
|
+
responseSchema: generateVariantsV1_1.GENERATE_VARIANTS_V1_RESPONSE_SCHEMA,
|
|
63
60
|
});
|
|
64
61
|
}, {
|
|
65
62
|
requestLabel,
|
|
@@ -72,7 +69,6 @@ class PolyglotClient {
|
|
|
72
69
|
}),
|
|
73
70
|
},
|
|
74
71
|
});
|
|
75
|
-
return response.body.variants;
|
|
76
72
|
}
|
|
77
73
|
/**
|
|
78
74
|
* Scores passed translations
|
|
@@ -80,16 +76,11 @@ class PolyglotClient {
|
|
|
80
76
|
async scoreTranslations(request, options = DEFAULT_CLIENT_OPTIONS) {
|
|
81
77
|
const resolvedOptions = resolveOptions(options);
|
|
82
78
|
const requestLabel = 'Score translations (Polyglot)';
|
|
83
|
-
|
|
84
|
-
return (0,
|
|
85
|
-
|
|
86
|
-
retryConfig: this.retryConfig,
|
|
87
|
-
timeout: resolvedOptions.timeout,
|
|
88
|
-
headers: {
|
|
89
|
-
...this.clientHeaders,
|
|
90
|
-
'x-fake-processing': resolvedOptions.fakeProcessing ? 'true' : undefined,
|
|
91
|
-
},
|
|
79
|
+
return await this.wrapWithInstrumentation(() => {
|
|
80
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v1/content/actions/score', request, {
|
|
81
|
+
...this.getRequestOptions(resolvedOptions),
|
|
92
82
|
requestLabel,
|
|
83
|
+
responseSchema: scoreV1Schemas_1.SCORE_V1_RESPONSE_SCHEMA,
|
|
93
84
|
});
|
|
94
85
|
}, {
|
|
95
86
|
requestLabel,
|
|
@@ -100,21 +91,15 @@ class PolyglotClient {
|
|
|
100
91
|
}),
|
|
101
92
|
},
|
|
102
93
|
});
|
|
103
|
-
return response.body;
|
|
104
94
|
}
|
|
105
|
-
async
|
|
95
|
+
async translateAsync(requestBody, options = DEFAULT_CLIENT_OPTIONS) {
|
|
106
96
|
const resolvedOptions = resolveOptions(options);
|
|
107
|
-
const requestLabel = 'Translate
|
|
97
|
+
const requestLabel = 'Translate asynchronously (Polyglot)';
|
|
108
98
|
return await this.wrapWithInstrumentation(() => {
|
|
109
|
-
return (0,
|
|
110
|
-
|
|
111
|
-
retryConfig: this.retryConfig,
|
|
112
|
-
timeout: resolvedOptions.timeout,
|
|
113
|
-
headers: {
|
|
114
|
-
...this.clientHeaders,
|
|
115
|
-
'x-fake-processing': resolvedOptions.fakeProcessing ? 'true' : undefined,
|
|
116
|
-
},
|
|
99
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v2/content/actions/translate-async', requestBody, {
|
|
100
|
+
...this.getRequestOptions(resolvedOptions),
|
|
117
101
|
requestLabel,
|
|
102
|
+
responseSchema: translateAsyncV2Schemas_1.TRANSLATE_ASYNC_V2_RESPONSE_SCHEMA,
|
|
118
103
|
});
|
|
119
104
|
}, {
|
|
120
105
|
requestLabel,
|
|
@@ -127,49 +112,34 @@ class PolyglotClient {
|
|
|
127
112
|
},
|
|
128
113
|
});
|
|
129
114
|
}
|
|
130
|
-
async
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
tenantId: requestBody.tenantId,
|
|
139
|
-
ownerId: requestBody.ownerId,
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
async lqaAsync(requestBody, options) {
|
|
146
|
-
const result = await this.callAsyncApi('/v1/content/actions/lqa-async', requestBody, options, 'LQA asynchronously (Polyglot)');
|
|
147
|
-
if (result.error === null) {
|
|
148
|
-
result.error = new node_core_1.InternalError({
|
|
149
|
-
message: 'Failed to schedule asynchronous LQA',
|
|
150
|
-
errorCode: 'FAILED_TO_SCHEDULE_ASYNC_LQA',
|
|
151
|
-
details: {
|
|
152
|
-
originCorrelationId: requestBody.originCorrelationId,
|
|
153
|
-
tenantId: requestBody.tenantId,
|
|
154
|
-
ownerId: requestBody.ownerId,
|
|
155
|
-
},
|
|
115
|
+
async translateSync(requestBody, options = DEFAULT_CLIENT_OPTIONS) {
|
|
116
|
+
const resolvedOptions = resolveOptions(options);
|
|
117
|
+
const requestLabel = 'Translate synchronously (Polyglot)';
|
|
118
|
+
return await this.wrapWithInstrumentation(() => {
|
|
119
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v2/content/actions/translate-sync', requestBody, {
|
|
120
|
+
...this.getRequestOptions(resolvedOptions),
|
|
121
|
+
requestLabel,
|
|
122
|
+
responseSchema: translateSyncV2Schemas_1.TRANSLATE_SYNC_V2_RESPONSE_SCHEMA,
|
|
156
123
|
});
|
|
157
|
-
}
|
|
158
|
-
|
|
124
|
+
}, {
|
|
125
|
+
requestLabel,
|
|
126
|
+
callMetadata: {
|
|
127
|
+
...resolvedOptions.metadata,
|
|
128
|
+
fakeProcessing: JSON.stringify(resolvedOptions.fakeProcessing),
|
|
129
|
+
reqContext: JSON.stringify({
|
|
130
|
+
reqId: resolvedOptions.reqContext?.reqId,
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
});
|
|
159
134
|
}
|
|
160
|
-
async
|
|
135
|
+
async lqaAsync(requestBody, options = DEFAULT_CLIENT_OPTIONS) {
|
|
161
136
|
const resolvedOptions = resolveOptions(options);
|
|
162
|
-
const requestLabel = 'LQA
|
|
137
|
+
const requestLabel = 'LQA asynchronously (Polyglot)';
|
|
163
138
|
return await this.wrapWithInstrumentation(() => {
|
|
164
|
-
return (0,
|
|
165
|
-
|
|
166
|
-
retryConfig: this.retryConfig,
|
|
167
|
-
timeout: resolvedOptions.timeout,
|
|
168
|
-
headers: {
|
|
169
|
-
...this.clientHeaders,
|
|
170
|
-
'x-fake-processing': resolvedOptions.fakeProcessing ? 'true' : undefined,
|
|
171
|
-
},
|
|
139
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v1/content/actions/lqa-async', requestBody, {
|
|
140
|
+
...this.getRequestOptions(resolvedOptions),
|
|
172
141
|
requestLabel,
|
|
142
|
+
responseSchema: translateAsyncV2Schemas_1.TRANSLATE_ASYNC_V2_RESPONSE_SCHEMA,
|
|
173
143
|
});
|
|
174
144
|
}, {
|
|
175
145
|
requestLabel,
|
|
@@ -182,36 +152,36 @@ class PolyglotClient {
|
|
|
182
152
|
},
|
|
183
153
|
});
|
|
184
154
|
}
|
|
185
|
-
async
|
|
155
|
+
async lqaSync(requestBody, options = DEFAULT_CLIENT_OPTIONS) {
|
|
186
156
|
const resolvedOptions = resolveOptions(options);
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
throwOnError: false,
|
|
192
|
-
timeout: resolvedOptions.timeout,
|
|
193
|
-
headers: {
|
|
194
|
-
...this.clientHeaders,
|
|
195
|
-
'x-fake-processing': resolvedOptions.fakeProcessing ? 'true' : undefined,
|
|
196
|
-
},
|
|
157
|
+
const requestLabel = 'LQA synchronously (Polyglot)';
|
|
158
|
+
return await this.wrapWithInstrumentation(() => {
|
|
159
|
+
return (0, backend_http_client_1.sendPost)(this.client, '/v2/content/actions/lqa-sync', requestBody, {
|
|
160
|
+
...this.getRequestOptions(resolvedOptions),
|
|
197
161
|
requestLabel,
|
|
162
|
+
responseSchema: lqaSyncV2Schemas_1.LQA_SYNC_V2_RESPONSE_SCHEMA,
|
|
198
163
|
});
|
|
164
|
+
}, {
|
|
165
|
+
requestLabel,
|
|
166
|
+
callMetadata: {
|
|
167
|
+
...resolvedOptions.metadata,
|
|
168
|
+
fakeProcessing: JSON.stringify(resolvedOptions.fakeProcessing),
|
|
169
|
+
reqContext: JSON.stringify({
|
|
170
|
+
reqId: resolvedOptions.reqContext?.reqId,
|
|
171
|
+
}),
|
|
172
|
+
},
|
|
199
173
|
});
|
|
200
|
-
if (result.error)
|
|
201
|
-
return result;
|
|
202
|
-
return result.result.statusCode === 202 ? (0, node_core_1.success)(result.result.body) : (0, node_core_1.failure)(null);
|
|
203
174
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
175
|
+
getRequestOptions(options) {
|
|
176
|
+
return {
|
|
177
|
+
reqContext: options.reqContext,
|
|
178
|
+
retryConfig: this.retryConfig,
|
|
179
|
+
timeout: options.timeout,
|
|
180
|
+
headers: {
|
|
181
|
+
...this.clientHeaders,
|
|
182
|
+
'x-fake-processing': options.fakeProcessing ? 'true' : undefined,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
215
185
|
}
|
|
216
186
|
/**
|
|
217
187
|
* Calls the provided request function and logs the execution time and metadata with the provided logger
|
|
@@ -224,14 +194,13 @@ class PolyglotClient {
|
|
|
224
194
|
const { result, error } = await innerFn();
|
|
225
195
|
// We might receive an non-satisfactory response, but it might not be an Error object - so we have to wrap it
|
|
226
196
|
if (error) {
|
|
227
|
-
|
|
228
|
-
throw error;
|
|
197
|
+
return { error: this.wrapError(error) };
|
|
229
198
|
}
|
|
230
199
|
successful = true;
|
|
231
|
-
return result;
|
|
200
|
+
return { result: result.body };
|
|
232
201
|
}
|
|
233
|
-
catch (
|
|
234
|
-
|
|
202
|
+
catch (err) {
|
|
203
|
+
return { error: this.wrapError(err) };
|
|
235
204
|
}
|
|
236
205
|
finally {
|
|
237
206
|
this.logger?.info({
|
|
@@ -242,19 +211,15 @@ class PolyglotClient {
|
|
|
242
211
|
});
|
|
243
212
|
}
|
|
244
213
|
}
|
|
245
|
-
wrapError(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
error = (0, node_core_1.isResponseStatusError)(e) ? new PolyglotError_1.PolyglotError(e) : e;
|
|
214
|
+
wrapError(err) {
|
|
215
|
+
if ((0, backend_http_client_1.isResponseStatusError)(err)) {
|
|
216
|
+
return new PolyglotError_1.PolyglotError(err);
|
|
249
217
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
return error;
|
|
218
|
+
return new node_core_1.InternalError({
|
|
219
|
+
message: 'Unknown error',
|
|
220
|
+
errorCode: 'UNKNOWN_ERROR',
|
|
221
|
+
details: { error: JSON.stringify(err) },
|
|
222
|
+
});
|
|
258
223
|
}
|
|
259
224
|
}
|
|
260
225
|
exports.PolyglotClient = PolyglotClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolyglotClient.js","sourceRoot":"","sources":["../../src/sdk/PolyglotClient.ts"],"names":[],"mappings":";;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AAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QAChC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;QACvC,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;gBAChB,GAAG,YAAY;gBACf,UAAU;gBACV,GAAG,EAAE,aAAa,YAAY,EAAE;gBAChC,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;aACxC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,GAAY;QAC5B,IAAI,IAAA,2CAAqB,EAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,6BAAa,CAAC,GAAG,CAAC,CAAA;QAC/B,CAAC;QAED,OAAO,IAAI,yBAAa,CAAC;YACvB,OAAO,EAAE,eAAe;YACxB,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;SACxC,CAAC,CAAA;IACJ,CAAC;CACF;AApQD,wCAoQC"}
|
|
@@ -7,16 +7,6 @@ export type ClientOptions = {
|
|
|
7
7
|
metadata?: Record<string, string>;
|
|
8
8
|
timeout?: number;
|
|
9
9
|
};
|
|
10
|
-
export type ClientOptionsWithRequestContext = {
|
|
11
|
-
fakeProcessing?: boolean;
|
|
12
|
-
reqContext: RequestContext;
|
|
13
|
-
metadata?: Record<string, string>;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
};
|
|
16
|
-
export type InstrumentationOptions = {
|
|
17
|
-
requestLabel: string;
|
|
18
|
-
callMetadata?: Record<string, string>;
|
|
19
|
-
};
|
|
20
10
|
export type PolyglotClientConfig = {
|
|
21
11
|
baseUrl: string;
|
|
22
12
|
jwtToken: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/polyglot-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Lokalise",
|
|
6
6
|
"url": "https://lokalise.com/"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@amplitude/analytics-types": "^2.6.0",
|
|
36
|
-
"@lokalise/
|
|
36
|
+
"@lokalise/backend-http-client": "^2.0.1",
|
|
37
|
+
"@lokalise/fastify-extras": "^21.4.1",
|
|
37
38
|
"@lokalise/id-utils": "^2.1.0",
|
|
38
39
|
"@lokalise/node-core": "^9.20.0",
|
|
39
40
|
"@lokalise/supported-languages": "^2.0.0",
|
|
@@ -43,10 +44,10 @@
|
|
|
43
44
|
"zod": "^3.23.4"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^20.14.
|
|
47
|
+
"@types/node": "^20.14.11",
|
|
47
48
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
48
49
|
"@typescript-eslint/parser": "^7.4.0",
|
|
49
|
-
"@vitest/coverage-v8": "^
|
|
50
|
+
"@vitest/coverage-v8": "^2.0.4",
|
|
50
51
|
"auto-changelog": "^2.4.0",
|
|
51
52
|
"eslint": "^8.57.0",
|
|
52
53
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -56,6 +57,6 @@
|
|
|
56
57
|
"shx": "^0.3.4",
|
|
57
58
|
"ts-deepmerge": "^7.0.0",
|
|
58
59
|
"typescript": "5.5.3",
|
|
59
|
-
"vitest": "^
|
|
60
|
+
"vitest": "^2.0.4"
|
|
60
61
|
}
|
|
61
62
|
}
|