@lokalise/polyglot-sdk 20.0.0 → 20.0.1
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/schemas/common/translationContextSchemas.d.ts +32 -32
- package/dist/sdk/schemas/common/translationContextSchemas.js +2 -0
- package/dist/sdk/schemas/common/translationContextSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.d.ts +101 -81
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js +2 -0
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.d.ts +93 -83
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js +2 -0
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/generateVariants.d.ts +53 -53
- package/dist/sdk/schemas/translation/rewriteTextSchemas.d.ts +141 -141
- package/dist/sdk/schemas/translation/sharedSchemas.d.ts +257 -57
- package/dist/sdk/schemas/translation/sharedSchemas.js +23 -1
- package/dist/sdk/schemas/translation/sharedSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/translateAsyncSchemas.d.ts +323 -323
- package/dist/sdk/schemas/translation/translateSyncSchemas.d.ts +259 -259
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.d.ts +412 -54
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js +24 -6
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import type { ObjectValues } from '../../types/common.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { IntegrationEngineEnum } from '../common/commonSchemas.ts';
|
|
4
4
|
export type ContentUnitLike = {
|
|
5
5
|
segments: {
|
|
6
6
|
value: string;
|
|
@@ -79,47 +79,47 @@ export declare const TRANSLATE_SEGMENT_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
79
79
|
}, "strip", z.ZodTypeAny, {
|
|
80
80
|
value: string;
|
|
81
81
|
id: string;
|
|
82
|
-
translationExamples?: {
|
|
83
|
-
sourceValue: string;
|
|
84
|
-
translatedValue: string;
|
|
85
|
-
}[] | undefined;
|
|
86
82
|
tmMatch?: {
|
|
87
83
|
sourceValue: string;
|
|
88
84
|
translatedValue: string;
|
|
89
85
|
} | undefined;
|
|
90
|
-
}, {
|
|
91
|
-
value: string;
|
|
92
|
-
id: string;
|
|
93
86
|
translationExamples?: {
|
|
94
87
|
sourceValue: string;
|
|
95
88
|
translatedValue: string;
|
|
96
89
|
}[] | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
value: string;
|
|
92
|
+
id: string;
|
|
97
93
|
tmMatch?: {
|
|
98
94
|
sourceValue: string;
|
|
99
95
|
translatedValue: string;
|
|
100
96
|
} | undefined;
|
|
101
|
-
}>, {
|
|
102
|
-
value: string;
|
|
103
|
-
id: string;
|
|
104
97
|
translationExamples?: {
|
|
105
98
|
sourceValue: string;
|
|
106
99
|
translatedValue: string;
|
|
107
100
|
}[] | undefined;
|
|
101
|
+
}>, {
|
|
102
|
+
value: string;
|
|
103
|
+
id: string;
|
|
108
104
|
tmMatch?: {
|
|
109
105
|
sourceValue: string;
|
|
110
106
|
translatedValue: string;
|
|
111
107
|
} | undefined;
|
|
112
|
-
}, {
|
|
113
|
-
value: string;
|
|
114
|
-
id: string;
|
|
115
108
|
translationExamples?: {
|
|
116
109
|
sourceValue: string;
|
|
117
110
|
translatedValue: string;
|
|
118
111
|
}[] | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
value: string;
|
|
114
|
+
id: string;
|
|
119
115
|
tmMatch?: {
|
|
120
116
|
sourceValue: string;
|
|
121
117
|
translatedValue: string;
|
|
122
118
|
} | undefined;
|
|
119
|
+
translationExamples?: {
|
|
120
|
+
sourceValue: string;
|
|
121
|
+
translatedValue: string;
|
|
122
|
+
}[] | undefined;
|
|
123
123
|
}>;
|
|
124
124
|
export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
125
125
|
id: z.ZodString;
|
|
@@ -157,146 +157,146 @@ export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
157
157
|
}, "strip", z.ZodTypeAny, {
|
|
158
158
|
value: string;
|
|
159
159
|
id: string;
|
|
160
|
-
translationExamples?: {
|
|
161
|
-
sourceValue: string;
|
|
162
|
-
translatedValue: string;
|
|
163
|
-
}[] | undefined;
|
|
164
160
|
tmMatch?: {
|
|
165
161
|
sourceValue: string;
|
|
166
162
|
translatedValue: string;
|
|
167
163
|
} | undefined;
|
|
168
|
-
}, {
|
|
169
|
-
value: string;
|
|
170
|
-
id: string;
|
|
171
164
|
translationExamples?: {
|
|
172
165
|
sourceValue: string;
|
|
173
166
|
translatedValue: string;
|
|
174
167
|
}[] | undefined;
|
|
168
|
+
}, {
|
|
169
|
+
value: string;
|
|
170
|
+
id: string;
|
|
175
171
|
tmMatch?: {
|
|
176
172
|
sourceValue: string;
|
|
177
173
|
translatedValue: string;
|
|
178
174
|
} | undefined;
|
|
179
|
-
}>, {
|
|
180
|
-
value: string;
|
|
181
|
-
id: string;
|
|
182
175
|
translationExamples?: {
|
|
183
176
|
sourceValue: string;
|
|
184
177
|
translatedValue: string;
|
|
185
178
|
}[] | undefined;
|
|
179
|
+
}>, {
|
|
180
|
+
value: string;
|
|
181
|
+
id: string;
|
|
186
182
|
tmMatch?: {
|
|
187
183
|
sourceValue: string;
|
|
188
184
|
translatedValue: string;
|
|
189
185
|
} | undefined;
|
|
190
|
-
}, {
|
|
191
|
-
value: string;
|
|
192
|
-
id: string;
|
|
193
186
|
translationExamples?: {
|
|
194
187
|
sourceValue: string;
|
|
195
188
|
translatedValue: string;
|
|
196
189
|
}[] | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
value: string;
|
|
192
|
+
id: string;
|
|
197
193
|
tmMatch?: {
|
|
198
194
|
sourceValue: string;
|
|
199
195
|
translatedValue: string;
|
|
200
196
|
} | undefined;
|
|
201
|
-
}>, "atleastone">, [{
|
|
202
|
-
value: string;
|
|
203
|
-
id: string;
|
|
204
197
|
translationExamples?: {
|
|
205
198
|
sourceValue: string;
|
|
206
199
|
translatedValue: string;
|
|
207
200
|
}[] | undefined;
|
|
201
|
+
}>, "atleastone">, [{
|
|
202
|
+
value: string;
|
|
203
|
+
id: string;
|
|
208
204
|
tmMatch?: {
|
|
209
205
|
sourceValue: string;
|
|
210
206
|
translatedValue: string;
|
|
211
207
|
} | undefined;
|
|
212
|
-
}, ...{
|
|
213
|
-
value: string;
|
|
214
|
-
id: string;
|
|
215
208
|
translationExamples?: {
|
|
216
209
|
sourceValue: string;
|
|
217
210
|
translatedValue: string;
|
|
218
211
|
}[] | undefined;
|
|
212
|
+
}, ...{
|
|
213
|
+
value: string;
|
|
214
|
+
id: string;
|
|
219
215
|
tmMatch?: {
|
|
220
216
|
sourceValue: string;
|
|
221
217
|
translatedValue: string;
|
|
222
218
|
} | undefined;
|
|
223
|
-
}[]], [{
|
|
224
|
-
value: string;
|
|
225
|
-
id: string;
|
|
226
219
|
translationExamples?: {
|
|
227
220
|
sourceValue: string;
|
|
228
221
|
translatedValue: string;
|
|
229
222
|
}[] | undefined;
|
|
223
|
+
}[]], [{
|
|
224
|
+
value: string;
|
|
225
|
+
id: string;
|
|
230
226
|
tmMatch?: {
|
|
231
227
|
sourceValue: string;
|
|
232
228
|
translatedValue: string;
|
|
233
229
|
} | undefined;
|
|
234
|
-
}, ...{
|
|
235
|
-
value: string;
|
|
236
|
-
id: string;
|
|
237
230
|
translationExamples?: {
|
|
238
231
|
sourceValue: string;
|
|
239
232
|
translatedValue: string;
|
|
240
233
|
}[] | undefined;
|
|
234
|
+
}, ...{
|
|
235
|
+
value: string;
|
|
236
|
+
id: string;
|
|
241
237
|
tmMatch?: {
|
|
242
238
|
sourceValue: string;
|
|
243
239
|
translatedValue: string;
|
|
244
240
|
} | undefined;
|
|
241
|
+
translationExamples?: {
|
|
242
|
+
sourceValue: string;
|
|
243
|
+
translatedValue: string;
|
|
244
|
+
}[] | undefined;
|
|
245
245
|
}[]]>;
|
|
246
246
|
}, "strip", z.ZodTypeAny, {
|
|
247
|
-
id: string;
|
|
248
247
|
segments: [{
|
|
249
248
|
value: string;
|
|
250
249
|
id: string;
|
|
251
|
-
translationExamples?: {
|
|
252
|
-
sourceValue: string;
|
|
253
|
-
translatedValue: string;
|
|
254
|
-
}[] | undefined;
|
|
255
250
|
tmMatch?: {
|
|
256
251
|
sourceValue: string;
|
|
257
252
|
translatedValue: string;
|
|
258
253
|
} | undefined;
|
|
259
|
-
}, ...{
|
|
260
|
-
value: string;
|
|
261
|
-
id: string;
|
|
262
254
|
translationExamples?: {
|
|
263
255
|
sourceValue: string;
|
|
264
256
|
translatedValue: string;
|
|
265
257
|
}[] | undefined;
|
|
258
|
+
}, ...{
|
|
259
|
+
value: string;
|
|
260
|
+
id: string;
|
|
266
261
|
tmMatch?: {
|
|
267
262
|
sourceValue: string;
|
|
268
263
|
translatedValue: string;
|
|
269
264
|
} | undefined;
|
|
265
|
+
translationExamples?: {
|
|
266
|
+
sourceValue: string;
|
|
267
|
+
translatedValue: string;
|
|
268
|
+
}[] | undefined;
|
|
270
269
|
}[]];
|
|
270
|
+
id: string;
|
|
271
271
|
context?: {
|
|
272
272
|
description: string;
|
|
273
273
|
} | undefined;
|
|
274
274
|
characterLimit?: number | undefined;
|
|
275
275
|
}, {
|
|
276
|
-
id: string;
|
|
277
276
|
segments: [{
|
|
278
277
|
value: string;
|
|
279
278
|
id: string;
|
|
280
|
-
translationExamples?: {
|
|
281
|
-
sourceValue: string;
|
|
282
|
-
translatedValue: string;
|
|
283
|
-
}[] | undefined;
|
|
284
279
|
tmMatch?: {
|
|
285
280
|
sourceValue: string;
|
|
286
281
|
translatedValue: string;
|
|
287
282
|
} | undefined;
|
|
288
|
-
}, ...{
|
|
289
|
-
value: string;
|
|
290
|
-
id: string;
|
|
291
283
|
translationExamples?: {
|
|
292
284
|
sourceValue: string;
|
|
293
285
|
translatedValue: string;
|
|
294
286
|
}[] | undefined;
|
|
287
|
+
}, ...{
|
|
288
|
+
value: string;
|
|
289
|
+
id: string;
|
|
295
290
|
tmMatch?: {
|
|
296
291
|
sourceValue: string;
|
|
297
292
|
translatedValue: string;
|
|
298
293
|
} | undefined;
|
|
294
|
+
translationExamples?: {
|
|
295
|
+
sourceValue: string;
|
|
296
|
+
translatedValue: string;
|
|
297
|
+
}[] | undefined;
|
|
299
298
|
}[]];
|
|
299
|
+
id: string;
|
|
300
300
|
context?: {
|
|
301
301
|
description: string;
|
|
302
302
|
} | undefined;
|
|
@@ -350,7 +350,6 @@ export declare const REWRITE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
350
350
|
id: string;
|
|
351
351
|
}[]]>;
|
|
352
352
|
}, "strip", z.ZodTypeAny, {
|
|
353
|
-
id: string;
|
|
354
353
|
segments: [{
|
|
355
354
|
value: string;
|
|
356
355
|
id: string;
|
|
@@ -358,12 +357,12 @@ export declare const REWRITE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
358
357
|
value: string;
|
|
359
358
|
id: string;
|
|
360
359
|
}[]];
|
|
360
|
+
id: string;
|
|
361
361
|
context?: {
|
|
362
362
|
description: string;
|
|
363
363
|
} | undefined;
|
|
364
364
|
characterLimit?: number | undefined;
|
|
365
365
|
}, {
|
|
366
|
-
id: string;
|
|
367
366
|
segments: [{
|
|
368
367
|
value: string;
|
|
369
368
|
id: string;
|
|
@@ -371,6 +370,7 @@ export declare const REWRITE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
371
370
|
value: string;
|
|
372
371
|
id: string;
|
|
373
372
|
}[]];
|
|
373
|
+
id: string;
|
|
374
374
|
context?: {
|
|
375
375
|
description: string;
|
|
376
376
|
} | undefined;
|
|
@@ -424,3 +424,203 @@ export declare const HISTORY_ENTRY_SCHEMA: z.ZodObject<{
|
|
|
424
424
|
mode: "rephrase" | "shorten" | "translate";
|
|
425
425
|
}>;
|
|
426
426
|
export type HistoryEntry = z.infer<typeof HISTORY_ENTRY_SCHEMA>;
|
|
427
|
+
/**
|
|
428
|
+
* Streaming events
|
|
429
|
+
*/
|
|
430
|
+
export declare const TRANSLATION_EVENT_SCHEMA: z.ZodObject<{
|
|
431
|
+
event: z.ZodLiteral<"translation">;
|
|
432
|
+
data: z.ZodObject<{
|
|
433
|
+
id: z.ZodString;
|
|
434
|
+
content: z.ZodString;
|
|
435
|
+
isComplete: z.ZodBoolean;
|
|
436
|
+
integration: z.ZodNativeEnum<{
|
|
437
|
+
readonly FAKE: "Fake";
|
|
438
|
+
readonly FINETUNED_OPENAI: "FT-OpenAI";
|
|
439
|
+
readonly CLAUDE: "Claude";
|
|
440
|
+
readonly GPT: "GPT";
|
|
441
|
+
readonly GEMINI: "Gemini";
|
|
442
|
+
readonly DEEPL: "DeepL";
|
|
443
|
+
readonly GOOGLE_TRANSLATE: "GoogleTranslate";
|
|
444
|
+
readonly MICROSOFT_TRANSLATOR: "MicrosoftTranslator";
|
|
445
|
+
}>;
|
|
446
|
+
polyglotRefId: z.ZodOptional<z.ZodString>;
|
|
447
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
448
|
+
kind: z.ZodEnum<["EDITED_NON_TRANSLATABLE_CONTENT", "EDITED_ICU_PLURALS"]>;
|
|
449
|
+
}, "strip", z.ZodTypeAny, {
|
|
450
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
451
|
+
}, {
|
|
452
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
453
|
+
}>, "many">>;
|
|
454
|
+
}, "strip", z.ZodTypeAny, {
|
|
455
|
+
id: string;
|
|
456
|
+
content: string;
|
|
457
|
+
isComplete: boolean;
|
|
458
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
459
|
+
polyglotRefId?: string | undefined;
|
|
460
|
+
warnings?: {
|
|
461
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
462
|
+
}[] | undefined;
|
|
463
|
+
}, {
|
|
464
|
+
id: string;
|
|
465
|
+
content: string;
|
|
466
|
+
isComplete: boolean;
|
|
467
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
468
|
+
polyglotRefId?: string | undefined;
|
|
469
|
+
warnings?: {
|
|
470
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
471
|
+
}[] | undefined;
|
|
472
|
+
}>;
|
|
473
|
+
}, "strip", z.ZodTypeAny, {
|
|
474
|
+
event: "translation";
|
|
475
|
+
data: {
|
|
476
|
+
id: string;
|
|
477
|
+
content: string;
|
|
478
|
+
isComplete: boolean;
|
|
479
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
480
|
+
polyglotRefId?: string | undefined;
|
|
481
|
+
warnings?: {
|
|
482
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
483
|
+
}[] | undefined;
|
|
484
|
+
};
|
|
485
|
+
}, {
|
|
486
|
+
event: "translation";
|
|
487
|
+
data: {
|
|
488
|
+
id: string;
|
|
489
|
+
content: string;
|
|
490
|
+
isComplete: boolean;
|
|
491
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
492
|
+
polyglotRefId?: string | undefined;
|
|
493
|
+
warnings?: {
|
|
494
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
495
|
+
}[] | undefined;
|
|
496
|
+
};
|
|
497
|
+
}>;
|
|
498
|
+
export declare const ERROR_EVENT_SCHEMA: z.ZodObject<{
|
|
499
|
+
event: z.ZodLiteral<"error">;
|
|
500
|
+
data: z.ZodObject<{
|
|
501
|
+
message: z.ZodString;
|
|
502
|
+
errorCode: z.ZodString;
|
|
503
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
504
|
+
}, "strip", z.ZodTypeAny, {
|
|
505
|
+
message: string;
|
|
506
|
+
errorCode: string;
|
|
507
|
+
details?: Record<string, unknown> | undefined;
|
|
508
|
+
}, {
|
|
509
|
+
message: string;
|
|
510
|
+
errorCode: string;
|
|
511
|
+
details?: Record<string, unknown> | undefined;
|
|
512
|
+
}>;
|
|
513
|
+
}, "strip", z.ZodTypeAny, {
|
|
514
|
+
event: "error";
|
|
515
|
+
data: {
|
|
516
|
+
message: string;
|
|
517
|
+
errorCode: string;
|
|
518
|
+
details?: Record<string, unknown> | undefined;
|
|
519
|
+
};
|
|
520
|
+
}, {
|
|
521
|
+
event: "error";
|
|
522
|
+
data: {
|
|
523
|
+
message: string;
|
|
524
|
+
errorCode: string;
|
|
525
|
+
details?: Record<string, unknown> | undefined;
|
|
526
|
+
};
|
|
527
|
+
}>;
|
|
528
|
+
export declare const STREAMING_EVENT_SCHEMA: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
529
|
+
event: z.ZodLiteral<"translation">;
|
|
530
|
+
data: z.ZodObject<{
|
|
531
|
+
id: z.ZodString;
|
|
532
|
+
content: z.ZodString;
|
|
533
|
+
isComplete: z.ZodBoolean;
|
|
534
|
+
integration: z.ZodNativeEnum<{
|
|
535
|
+
readonly FAKE: "Fake";
|
|
536
|
+
readonly FINETUNED_OPENAI: "FT-OpenAI";
|
|
537
|
+
readonly CLAUDE: "Claude";
|
|
538
|
+
readonly GPT: "GPT";
|
|
539
|
+
readonly GEMINI: "Gemini";
|
|
540
|
+
readonly DEEPL: "DeepL";
|
|
541
|
+
readonly GOOGLE_TRANSLATE: "GoogleTranslate";
|
|
542
|
+
readonly MICROSOFT_TRANSLATOR: "MicrosoftTranslator";
|
|
543
|
+
}>;
|
|
544
|
+
polyglotRefId: z.ZodOptional<z.ZodString>;
|
|
545
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
546
|
+
kind: z.ZodEnum<["EDITED_NON_TRANSLATABLE_CONTENT", "EDITED_ICU_PLURALS"]>;
|
|
547
|
+
}, "strip", z.ZodTypeAny, {
|
|
548
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
549
|
+
}, {
|
|
550
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
551
|
+
}>, "many">>;
|
|
552
|
+
}, "strip", z.ZodTypeAny, {
|
|
553
|
+
id: string;
|
|
554
|
+
content: string;
|
|
555
|
+
isComplete: boolean;
|
|
556
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
557
|
+
polyglotRefId?: string | undefined;
|
|
558
|
+
warnings?: {
|
|
559
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
560
|
+
}[] | undefined;
|
|
561
|
+
}, {
|
|
562
|
+
id: string;
|
|
563
|
+
content: string;
|
|
564
|
+
isComplete: boolean;
|
|
565
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
566
|
+
polyglotRefId?: string | undefined;
|
|
567
|
+
warnings?: {
|
|
568
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
569
|
+
}[] | undefined;
|
|
570
|
+
}>;
|
|
571
|
+
}, "strip", z.ZodTypeAny, {
|
|
572
|
+
event: "translation";
|
|
573
|
+
data: {
|
|
574
|
+
id: string;
|
|
575
|
+
content: string;
|
|
576
|
+
isComplete: boolean;
|
|
577
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
578
|
+
polyglotRefId?: string | undefined;
|
|
579
|
+
warnings?: {
|
|
580
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
581
|
+
}[] | undefined;
|
|
582
|
+
};
|
|
583
|
+
}, {
|
|
584
|
+
event: "translation";
|
|
585
|
+
data: {
|
|
586
|
+
id: string;
|
|
587
|
+
content: string;
|
|
588
|
+
isComplete: boolean;
|
|
589
|
+
integration: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | "DeepL" | "GoogleTranslate" | "MicrosoftTranslator" | "Fake";
|
|
590
|
+
polyglotRefId?: string | undefined;
|
|
591
|
+
warnings?: {
|
|
592
|
+
kind: "EDITED_NON_TRANSLATABLE_CONTENT" | "EDITED_ICU_PLURALS";
|
|
593
|
+
}[] | undefined;
|
|
594
|
+
};
|
|
595
|
+
}>, z.ZodObject<{
|
|
596
|
+
event: z.ZodLiteral<"error">;
|
|
597
|
+
data: z.ZodObject<{
|
|
598
|
+
message: z.ZodString;
|
|
599
|
+
errorCode: z.ZodString;
|
|
600
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
601
|
+
}, "strip", z.ZodTypeAny, {
|
|
602
|
+
message: string;
|
|
603
|
+
errorCode: string;
|
|
604
|
+
details?: Record<string, unknown> | undefined;
|
|
605
|
+
}, {
|
|
606
|
+
message: string;
|
|
607
|
+
errorCode: string;
|
|
608
|
+
details?: Record<string, unknown> | undefined;
|
|
609
|
+
}>;
|
|
610
|
+
}, "strip", z.ZodTypeAny, {
|
|
611
|
+
event: "error";
|
|
612
|
+
data: {
|
|
613
|
+
message: string;
|
|
614
|
+
errorCode: string;
|
|
615
|
+
details?: Record<string, unknown> | undefined;
|
|
616
|
+
};
|
|
617
|
+
}, {
|
|
618
|
+
event: "error";
|
|
619
|
+
data: {
|
|
620
|
+
message: string;
|
|
621
|
+
errorCode: string;
|
|
622
|
+
details?: Record<string, unknown> | undefined;
|
|
623
|
+
};
|
|
624
|
+
}>]>;
|
|
625
|
+
export type TranslationEvent = z.infer<typeof TRANSLATION_EVENT_SCHEMA>;
|
|
626
|
+
export type StreamingEvent = TranslationEvent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { isSegmentUnderLengthLimit } from "../../validation/isSegmentUnderLengthLimit.js";
|
|
3
3
|
import { getRequestSizeLimit, isRequestSizeUnderLimit } from "../../validation/requestSizeLimit.js";
|
|
4
|
-
import { TM_MATCH_SCHEMA, TRANSLATION_EXAMPLE_SCHEMA, } from "../common/commonSchemas.js";
|
|
4
|
+
import { COMMON_ERROR_RESPONSE_SCHEMA, IntegrationEngineEnum, TM_MATCH_SCHEMA, TRANSLATION_EXAMPLE_SCHEMA, } from "../common/commonSchemas.js";
|
|
5
5
|
export const refineDifferentSourceAndTargetLang = [
|
|
6
6
|
(data) => {
|
|
7
7
|
return data.sourceLocale !== data.targetLocale;
|
|
@@ -135,4 +135,26 @@ export const HISTORY_ENTRY_SCHEMA = z.object({
|
|
|
135
135
|
mode: z.nativeEnum(TranslateModeEnum).describe('Previously used translation mode'),
|
|
136
136
|
value: z.string().min(1).describe('Previous version of the translation'),
|
|
137
137
|
});
|
|
138
|
+
/**
|
|
139
|
+
* Streaming events
|
|
140
|
+
*/
|
|
141
|
+
export const TRANSLATION_EVENT_SCHEMA = z.object({
|
|
142
|
+
event: z.literal('translation'),
|
|
143
|
+
data: z.object({
|
|
144
|
+
id: z.string(),
|
|
145
|
+
content: z.string(),
|
|
146
|
+
isComplete: z.boolean(),
|
|
147
|
+
integration: z.nativeEnum(IntegrationEngineEnum),
|
|
148
|
+
polyglotRefId: z.string().optional(),
|
|
149
|
+
warnings: SEGMENT_WARNINGS_SCHEMA.optional(),
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
export const ERROR_EVENT_SCHEMA = z.object({
|
|
153
|
+
event: z.literal('error'),
|
|
154
|
+
data: COMMON_ERROR_RESPONSE_SCHEMA,
|
|
155
|
+
});
|
|
156
|
+
export const STREAMING_EVENT_SCHEMA = z.discriminatedUnion('event', [
|
|
157
|
+
TRANSLATION_EVENT_SCHEMA,
|
|
158
|
+
ERROR_EVENT_SCHEMA,
|
|
159
|
+
]);
|
|
138
160
|
//# sourceMappingURL=sharedSchemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AACnG,OAAO,
|
|
1
|
+
{"version":3,"file":"sharedSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AACnG,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AAMnC,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,CAAC,IAAoD,EAAE,EAAE;QACvD,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,CAAA;IAChD,CAAC;IACD,sDAAsD;CAC9C,CAAA;AAEV,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAC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