@lokalise/polyglot-sdk 21.0.0 → 21.0.2
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 +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk/helpers/removeUnicodeNullCharacters.d.ts +1 -0
- package/dist/sdk/helpers/removeUnicodeNullCharacters.js +4 -0
- package/dist/sdk/helpers/removeUnicodeNullCharacters.js.map +1 -0
- package/dist/sdk/schemas/common/commonSchemas.d.ts +19 -4
- package/dist/sdk/schemas/common/commonSchemas.js +23 -5
- package/dist/sdk/schemas/common/commonSchemas.js.map +1 -1
- package/dist/sdk/schemas/common/translationContextSchemas.d.ts +19 -19
- package/dist/sdk/schemas/common/translationContextSchemas.js +16 -8
- package/dist/sdk/schemas/common/translationContextSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/commonSchemas.d.ts +330 -0
- package/dist/sdk/schemas/lqa/commonSchemas.js +69 -0
- package/dist/sdk/schemas/lqa/commonSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.d.ts +118 -213
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js +3 -51
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.d.ts +118 -214
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js +3 -51
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/generateVariants.d.ts +15 -15
- package/dist/sdk/schemas/translation/generateVariants.js +7 -1
- package/dist/sdk/schemas/translation/generateVariants.js.map +1 -1
- package/dist/sdk/schemas/translation/rewriteTextSchemas.d.ts +156 -28
- package/dist/sdk/schemas/translation/rewriteTextSchemas.js +10 -3
- package/dist/sdk/schemas/translation/rewriteTextSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/sharedSchemas.d.ts +17 -18
- package/dist/sdk/schemas/translation/sharedSchemas.js +23 -24
- package/dist/sdk/schemas/translation/sharedSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/translateAsyncSchemas.d.ts +13 -13
- package/dist/sdk/schemas/translation/translateAsyncSchemas.js +2 -2
- package/dist/sdk/schemas/translation/translateAsyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/translateSyncSchemas.d.ts +252 -14
- package/dist/sdk/schemas/translation/translateSyncSchemas.js +11 -3
- package/dist/sdk/schemas/translation/translateSyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.d.ts +11 -11
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js +8 -7
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js.map +1 -1
- package/package.json +6 -7
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { AI_INTEGRATION_ENGINE_SCHEMA, COMMON_REQUEST_HEADERS_SCHEMA, FORCE_INTEGRATION_SCHEMA, LOCALE_SCHEMA, refineIntegrationIsPresent, } from "../common/commonSchemas.js";
|
|
3
3
|
import { TRANSLATION_CONTEXT_SCHEMA } from "../common/translationContextSchemas.js";
|
|
4
|
+
import { removeUnicodeNullCharacters } from "../../helpers/removeUnicodeNullCharacters.js";
|
|
4
5
|
import { HISTORY_REQUEST_SCHEMA, SEGMENT_WARNINGS_SCHEMA, VariantsModeEnum, refineDifferentSourceAndTargetLang, refineSingleSegmentSizeLimit, } from "./sharedSchemas.js";
|
|
5
6
|
export const GENERATE_VARIANTS_BODY_SCHEMA = z
|
|
6
7
|
.object({
|
|
7
8
|
assets: TRANSLATION_CONTEXT_SCHEMA.optional(),
|
|
8
9
|
sourceLocale: LOCALE_SCHEMA,
|
|
9
|
-
sourceValue: z
|
|
10
|
+
sourceValue: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.transform(removeUnicodeNullCharacters)
|
|
14
|
+
.describe('Text in source language'),
|
|
10
15
|
targetLocale: LOCALE_SCHEMA,
|
|
11
16
|
targetValue: z
|
|
12
17
|
.string()
|
|
18
|
+
.transform(removeUnicodeNullCharacters)
|
|
13
19
|
.describe('Current translation of the text in target language. AI translator will do its best to avoid returning the same value'),
|
|
14
20
|
integration: AI_INTEGRATION_ENGINE_SCHEMA.optional(),
|
|
15
21
|
forceIntegration: FORCE_INTEGRATION_SCHEMA.optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateVariants.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/generateVariants.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACb,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AAEnF,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,kCAAkC,EAClC,4BAA4B,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC;KAC3C,MAAM,CAAC;IACN,MAAM,EAAE,0BAA0B,CAAC,QAAQ,EAAE;IAC7C,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"generateVariants.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/generateVariants.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACb,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AAEnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,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,CAAC,CAAC,CAAC;IACpC,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,EAAE;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC;KACD,QAAQ,CAAC,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { COMMON_REQUEST_HEADERS_SCHEMA } from '../common/commonSchemas.ts';
|
|
3
|
-
export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
3
|
+
export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
4
4
|
context: z.ZodOptional<z.ZodObject<Omit<{
|
|
5
|
-
description: z.ZodOptional<z.ZodString
|
|
5
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
6
6
|
styleGuide: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
7
|
-
text: z.ZodString
|
|
7
|
+
text: z.ZodEffects<z.ZodString, string, string>;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
9
|
text: string;
|
|
10
10
|
}, {
|
|
@@ -37,14 +37,14 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
37
37
|
}>]>>;
|
|
38
38
|
glossary: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
39
39
|
term: z.ZodString;
|
|
40
|
-
description: z.ZodOptional<z.ZodString
|
|
40
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
41
41
|
translatable: z.ZodDefault<z.ZodBoolean>;
|
|
42
42
|
forbidden: z.ZodDefault<z.ZodBoolean>;
|
|
43
43
|
caseSensitive: z.ZodDefault<z.ZodBoolean>;
|
|
44
44
|
translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
45
45
|
locale: z.ZodEffects<z.ZodString, string, string>;
|
|
46
|
-
translation: z.ZodString
|
|
47
|
-
description: z.ZodOptional<z.ZodString
|
|
46
|
+
translation: z.ZodEffects<z.ZodString, string, string>;
|
|
47
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
48
48
|
}, "strip", z.ZodTypeAny, {
|
|
49
49
|
translation: string;
|
|
50
50
|
locale: string;
|
|
@@ -101,8 +101,8 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
101
101
|
}>, "many">>;
|
|
102
102
|
targetPluralForms: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEnum<["zero", "one", "two", "few", "many", "other"]>, "atleastone">>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>;
|
|
103
103
|
translationExamples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
104
|
-
sourceValue: z.ZodString
|
|
105
|
-
translatedValue: z.ZodString
|
|
104
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
105
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
106
106
|
}, "strip", z.ZodTypeAny, {
|
|
107
107
|
sourceValue: string;
|
|
108
108
|
translatedValue: string;
|
|
@@ -164,9 +164,9 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
164
164
|
}[] | undefined;
|
|
165
165
|
}>>;
|
|
166
166
|
assets: z.ZodOptional<z.ZodObject<Omit<{
|
|
167
|
-
description: z.ZodOptional<z.ZodString
|
|
167
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
168
168
|
styleGuide: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
169
|
-
text: z.ZodString
|
|
169
|
+
text: z.ZodEffects<z.ZodString, string, string>;
|
|
170
170
|
}, "strip", z.ZodTypeAny, {
|
|
171
171
|
text: string;
|
|
172
172
|
}, {
|
|
@@ -199,14 +199,14 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
199
199
|
}>]>>;
|
|
200
200
|
glossary: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
201
201
|
term: z.ZodString;
|
|
202
|
-
description: z.ZodOptional<z.ZodString
|
|
202
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
203
203
|
translatable: z.ZodDefault<z.ZodBoolean>;
|
|
204
204
|
forbidden: z.ZodDefault<z.ZodBoolean>;
|
|
205
205
|
caseSensitive: z.ZodDefault<z.ZodBoolean>;
|
|
206
206
|
translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
207
207
|
locale: z.ZodEffects<z.ZodString, string, string>;
|
|
208
|
-
translation: z.ZodString
|
|
209
|
-
description: z.ZodOptional<z.ZodString
|
|
208
|
+
translation: z.ZodEffects<z.ZodString, string, string>;
|
|
209
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
210
210
|
}, "strip", z.ZodTypeAny, {
|
|
211
211
|
translation: string;
|
|
212
212
|
locale: string;
|
|
@@ -263,8 +263,8 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
263
263
|
}>, "many">>;
|
|
264
264
|
targetPluralForms: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEnum<["zero", "one", "two", "few", "many", "other"]>, "atleastone">>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>;
|
|
265
265
|
translationExamples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
266
|
-
sourceValue: z.ZodString
|
|
267
|
-
translatedValue: z.ZodString
|
|
266
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
267
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
268
268
|
}, "strip", z.ZodTypeAny, {
|
|
269
269
|
sourceValue: string;
|
|
270
270
|
translatedValue: string;
|
|
@@ -335,13 +335,13 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
335
335
|
}>>;
|
|
336
336
|
forceIntegration: z.ZodOptional<z.ZodBoolean>;
|
|
337
337
|
history: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
338
|
-
values: z.ZodArray<z.ZodString, "atleastone">;
|
|
338
|
+
values: z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, string[], [string, ...string[]]>;
|
|
339
339
|
mode: z.ZodPipeline<z.ZodString, z.ZodNativeEnum<{
|
|
340
340
|
readonly REPHRASE: "rephrase";
|
|
341
341
|
readonly SHORTEN: "shorten";
|
|
342
342
|
}>>;
|
|
343
343
|
}, "strip", z.ZodTypeAny, {
|
|
344
|
-
values:
|
|
344
|
+
values: string[];
|
|
345
345
|
mode: "rephrase" | "shorten";
|
|
346
346
|
}, {
|
|
347
347
|
values: [string, ...string[]];
|
|
@@ -412,7 +412,7 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
412
412
|
} | undefined;
|
|
413
413
|
forceIntegration?: boolean | undefined;
|
|
414
414
|
history?: {
|
|
415
|
-
values:
|
|
415
|
+
values: string[];
|
|
416
416
|
mode: "rephrase" | "shorten";
|
|
417
417
|
}[] | undefined;
|
|
418
418
|
}, {
|
|
@@ -540,7 +540,7 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
540
540
|
} | undefined;
|
|
541
541
|
forceIntegration?: boolean | undefined;
|
|
542
542
|
history?: {
|
|
543
|
-
values:
|
|
543
|
+
values: string[];
|
|
544
544
|
mode: "rephrase" | "shorten";
|
|
545
545
|
}[] | undefined;
|
|
546
546
|
}, {
|
|
@@ -667,8 +667,136 @@ export declare const REWRITE_TEXT_SEGMENT_BODY_SCHEMA: z.ZodEffects<z.ZodEffects
|
|
|
667
667
|
}[] | undefined;
|
|
668
668
|
} | undefined;
|
|
669
669
|
forceIntegration?: boolean | undefined;
|
|
670
|
+
history?: {
|
|
671
|
+
values: string[];
|
|
672
|
+
mode: "rephrase" | "shorten";
|
|
673
|
+
}[] | undefined;
|
|
674
|
+
}, {
|
|
675
|
+
value: string;
|
|
676
|
+
mode: string;
|
|
677
|
+
locale: string;
|
|
678
|
+
context?: {
|
|
679
|
+
translationExamples?: {
|
|
680
|
+
sourceValue: string;
|
|
681
|
+
translatedValue: string;
|
|
682
|
+
}[] | undefined;
|
|
683
|
+
description?: string | undefined;
|
|
684
|
+
styleGuide?: {
|
|
685
|
+
targetAudience?: "general" | "technical" | "non-technical" | undefined;
|
|
686
|
+
toneOfVoice?: "friendly" | "empowering" | "informative" | "supportive" | "elegant" | undefined;
|
|
687
|
+
levelOfFormality?: "informal" | "formal" | "neutral" | undefined;
|
|
688
|
+
generalRule?: "active-voice" | "passive-voice" | undefined;
|
|
689
|
+
} | {
|
|
690
|
+
text: string;
|
|
691
|
+
} | undefined;
|
|
692
|
+
glossary?: {
|
|
693
|
+
term: string;
|
|
694
|
+
description?: string | undefined;
|
|
695
|
+
translatable?: boolean | undefined;
|
|
696
|
+
forbidden?: boolean | undefined;
|
|
697
|
+
caseSensitive?: boolean | undefined;
|
|
698
|
+
translations?: {
|
|
699
|
+
translation: string;
|
|
700
|
+
locale: string;
|
|
701
|
+
description?: string | undefined;
|
|
702
|
+
}[] | undefined;
|
|
703
|
+
}[] | undefined;
|
|
704
|
+
} | undefined;
|
|
705
|
+
integration?: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | undefined;
|
|
706
|
+
assets?: {
|
|
707
|
+
translationExamples?: {
|
|
708
|
+
sourceValue: string;
|
|
709
|
+
translatedValue: string;
|
|
710
|
+
}[] | undefined;
|
|
711
|
+
description?: string | undefined;
|
|
712
|
+
styleGuide?: {
|
|
713
|
+
targetAudience?: "general" | "technical" | "non-technical" | undefined;
|
|
714
|
+
toneOfVoice?: "friendly" | "empowering" | "informative" | "supportive" | "elegant" | undefined;
|
|
715
|
+
levelOfFormality?: "informal" | "formal" | "neutral" | undefined;
|
|
716
|
+
generalRule?: "active-voice" | "passive-voice" | undefined;
|
|
717
|
+
} | {
|
|
718
|
+
text: string;
|
|
719
|
+
} | undefined;
|
|
720
|
+
glossary?: {
|
|
721
|
+
term: string;
|
|
722
|
+
description?: string | undefined;
|
|
723
|
+
translatable?: boolean | undefined;
|
|
724
|
+
forbidden?: boolean | undefined;
|
|
725
|
+
caseSensitive?: boolean | undefined;
|
|
726
|
+
translations?: {
|
|
727
|
+
translation: string;
|
|
728
|
+
locale: string;
|
|
729
|
+
description?: string | undefined;
|
|
730
|
+
}[] | undefined;
|
|
731
|
+
}[] | undefined;
|
|
732
|
+
} | undefined;
|
|
733
|
+
forceIntegration?: boolean | undefined;
|
|
670
734
|
history?: {
|
|
671
735
|
values: [string, ...string[]];
|
|
736
|
+
mode: string;
|
|
737
|
+
}[] | undefined;
|
|
738
|
+
}>, {
|
|
739
|
+
value: string;
|
|
740
|
+
mode: "rephrase" | "shorten";
|
|
741
|
+
locale: string;
|
|
742
|
+
context?: {
|
|
743
|
+
translationExamples?: {
|
|
744
|
+
sourceValue: string;
|
|
745
|
+
translatedValue: string;
|
|
746
|
+
}[] | undefined;
|
|
747
|
+
description?: string | undefined;
|
|
748
|
+
styleGuide?: {
|
|
749
|
+
targetAudience?: "general" | "technical" | "non-technical" | undefined;
|
|
750
|
+
toneOfVoice?: "friendly" | "empowering" | "informative" | "supportive" | "elegant" | undefined;
|
|
751
|
+
levelOfFormality?: "informal" | "formal" | "neutral" | undefined;
|
|
752
|
+
generalRule?: "active-voice" | "passive-voice" | undefined;
|
|
753
|
+
} | {
|
|
754
|
+
text: string;
|
|
755
|
+
} | undefined;
|
|
756
|
+
glossary?: {
|
|
757
|
+
term: string;
|
|
758
|
+
translatable: boolean;
|
|
759
|
+
forbidden: boolean;
|
|
760
|
+
caseSensitive: boolean;
|
|
761
|
+
description?: string | undefined;
|
|
762
|
+
translations?: {
|
|
763
|
+
translation: string;
|
|
764
|
+
locale: string;
|
|
765
|
+
description?: string | undefined;
|
|
766
|
+
}[] | undefined;
|
|
767
|
+
}[] | undefined;
|
|
768
|
+
} | undefined;
|
|
769
|
+
integration?: "FT-OpenAI" | "Claude" | "GPT" | "Gemini" | undefined;
|
|
770
|
+
assets?: {
|
|
771
|
+
translationExamples?: {
|
|
772
|
+
sourceValue: string;
|
|
773
|
+
translatedValue: string;
|
|
774
|
+
}[] | undefined;
|
|
775
|
+
description?: string | undefined;
|
|
776
|
+
styleGuide?: {
|
|
777
|
+
targetAudience?: "general" | "technical" | "non-technical" | undefined;
|
|
778
|
+
toneOfVoice?: "friendly" | "empowering" | "informative" | "supportive" | "elegant" | undefined;
|
|
779
|
+
levelOfFormality?: "informal" | "formal" | "neutral" | undefined;
|
|
780
|
+
generalRule?: "active-voice" | "passive-voice" | undefined;
|
|
781
|
+
} | {
|
|
782
|
+
text: string;
|
|
783
|
+
} | undefined;
|
|
784
|
+
glossary?: {
|
|
785
|
+
term: string;
|
|
786
|
+
translatable: boolean;
|
|
787
|
+
forbidden: boolean;
|
|
788
|
+
caseSensitive: boolean;
|
|
789
|
+
description?: string | undefined;
|
|
790
|
+
translations?: {
|
|
791
|
+
translation: string;
|
|
792
|
+
locale: string;
|
|
793
|
+
description?: string | undefined;
|
|
794
|
+
}[] | undefined;
|
|
795
|
+
}[] | undefined;
|
|
796
|
+
} | undefined;
|
|
797
|
+
forceIntegration?: boolean | undefined;
|
|
798
|
+
history?: {
|
|
799
|
+
values: string[];
|
|
672
800
|
mode: "rephrase" | "shorten";
|
|
673
801
|
}[] | undefined;
|
|
674
802
|
}, {
|
|
@@ -779,9 +907,9 @@ export declare const REWRITE_TEXT_ASYNC_BODY_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
779
907
|
readonly GEMINI: "Gemini";
|
|
780
908
|
}>>;
|
|
781
909
|
context: z.ZodOptional<z.ZodObject<Omit<{
|
|
782
|
-
description: z.ZodOptional<z.ZodString
|
|
910
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
783
911
|
styleGuide: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
784
|
-
text: z.ZodString
|
|
912
|
+
text: z.ZodEffects<z.ZodString, string, string>;
|
|
785
913
|
}, "strip", z.ZodTypeAny, {
|
|
786
914
|
text: string;
|
|
787
915
|
}, {
|
|
@@ -814,14 +942,14 @@ export declare const REWRITE_TEXT_ASYNC_BODY_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
814
942
|
}>]>>;
|
|
815
943
|
glossary: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
816
944
|
term: z.ZodString;
|
|
817
|
-
description: z.ZodOptional<z.ZodString
|
|
945
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
818
946
|
translatable: z.ZodDefault<z.ZodBoolean>;
|
|
819
947
|
forbidden: z.ZodDefault<z.ZodBoolean>;
|
|
820
948
|
caseSensitive: z.ZodDefault<z.ZodBoolean>;
|
|
821
949
|
translations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
822
950
|
locale: z.ZodEffects<z.ZodString, string, string>;
|
|
823
|
-
translation: z.ZodString
|
|
824
|
-
description: z.ZodOptional<z.ZodString
|
|
951
|
+
translation: z.ZodEffects<z.ZodString, string, string>;
|
|
952
|
+
description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
825
953
|
}, "strip", z.ZodTypeAny, {
|
|
826
954
|
translation: string;
|
|
827
955
|
locale: string;
|
|
@@ -878,8 +1006,8 @@ export declare const REWRITE_TEXT_ASYNC_BODY_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
878
1006
|
}>, "many">>;
|
|
879
1007
|
targetPluralForms: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEnum<["zero", "one", "two", "few", "many", "other"]>, "atleastone">>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined, ["many" | "zero" | "one" | "two" | "few" | "other", ...("many" | "zero" | "one" | "two" | "few" | "other")[]] | undefined>;
|
|
880
1008
|
translationExamples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
881
|
-
sourceValue: z.ZodString
|
|
882
|
-
translatedValue: z.ZodString
|
|
1009
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
1010
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
883
1011
|
}, "strip", z.ZodTypeAny, {
|
|
884
1012
|
sourceValue: string;
|
|
885
1013
|
translatedValue: string;
|
|
@@ -943,7 +1071,7 @@ export declare const REWRITE_TEXT_ASYNC_BODY_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
943
1071
|
contentUnits: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
944
1072
|
id: z.ZodString;
|
|
945
1073
|
context: z.ZodOptional<z.ZodObject<{
|
|
946
|
-
description: z.ZodString
|
|
1074
|
+
description: z.ZodEffects<z.ZodString, string, string>;
|
|
947
1075
|
}, "strip", z.ZodTypeAny, {
|
|
948
1076
|
description: string;
|
|
949
1077
|
}, {
|
|
@@ -952,7 +1080,7 @@ export declare const REWRITE_TEXT_ASYNC_BODY_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
952
1080
|
characterLimit: z.ZodOptional<z.ZodNumber>;
|
|
953
1081
|
segments: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
954
1082
|
id: z.ZodString;
|
|
955
|
-
value: z.ZodString
|
|
1083
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
956
1084
|
}, "strip", z.ZodTypeAny, {
|
|
957
1085
|
value: string;
|
|
958
1086
|
id: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { ASYNC_REQUEST_SCHEMA, AsyncRequestCallbackStatusEnum, } from "../common/asyncRequestSchemas.js";
|
|
3
|
-
import { AI_INTEGRATION_ENGINE_SCHEMA, COMMON_ERROR_RESPONSE_SCHEMA, COMMON_FAILED_OPERATION_CALLBACK_SCHEMA, COMMON_REQUEST_HEADERS_SCHEMA, FORCE_INTEGRATION_SCHEMA, LOCALE_SCHEMA, refineIntegrationIsPresent, } from "../common/commonSchemas.js";
|
|
3
|
+
import { AI_INTEGRATION_ENGINE_SCHEMA, COMMON_ERROR_RESPONSE_SCHEMA, COMMON_FAILED_OPERATION_CALLBACK_SCHEMA, COMMON_REQUEST_HEADERS_SCHEMA, CONTENT_ID_PROP_SCHEMA, FORCE_INTEGRATION_SCHEMA, LOCALE_SCHEMA, refineIntegrationIsPresent, } from "../common/commonSchemas.js";
|
|
4
4
|
import { TEXT_REWRITING_CONTEXT } from "../common/translationContextSchemas.js";
|
|
5
|
-
import {
|
|
5
|
+
import { HISTORY_REQUEST_SCHEMA, REWRITE_CONTENT_UNIT_SCHEMA, SEGMENT_WARNINGS_SCHEMA, VariantsModeEnum, refineRequestSizeLimit, refineSingleSegmentSizeLimit, refineUniqueIds, } from "./sharedSchemas.js";
|
|
6
6
|
export const REWRITE_TEXT_SEGMENT_BODY_SCHEMA = z
|
|
7
7
|
.object({
|
|
8
8
|
context: TEXT_REWRITING_CONTEXT.optional(),
|
|
@@ -22,7 +22,14 @@ export const REWRITE_TEXT_SEGMENT_BODY_SCHEMA = z
|
|
|
22
22
|
.describe('A specific way of how a new variant is generated. If `rephrase`, it simply gets reworded, if `shorten` - AI tries to also make the translation shorter.'),
|
|
23
23
|
})
|
|
24
24
|
.refine(...refineSingleSegmentSizeLimit)
|
|
25
|
-
.refine(...refineIntegrationIsPresent)
|
|
25
|
+
.refine(...refineIntegrationIsPresent)
|
|
26
|
+
.transform((segment) => {
|
|
27
|
+
if (segment.assets && !segment.context) {
|
|
28
|
+
segment.context = segment.assets;
|
|
29
|
+
}
|
|
30
|
+
segment.assets = undefined;
|
|
31
|
+
return segment;
|
|
32
|
+
});
|
|
26
33
|
export const REWRITE_TEXT_SEGMENT_RESPONSE_SCHEMA = z
|
|
27
34
|
.object({
|
|
28
35
|
generatedAt: z.string().datetime(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteTextSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/rewriteTextSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,uCAAuC,EACvC,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACb,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAC/E,OAAO,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_PLURALS";
|
|
53
53
|
}>, "many">;
|
|
54
54
|
export declare const CONTENT_UNIT_DESCRIPTION_MAX_LENGTH = 32768;
|
|
55
|
-
export declare const CONTENT_ID_PROP_SCHEMA: z.ZodString;
|
|
56
55
|
export declare const TRANSLATE_SEGMENT_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
57
56
|
id: z.ZodString;
|
|
58
57
|
tmMatch: z.ZodOptional<z.ZodObject<{
|
|
59
|
-
sourceValue: z.ZodString
|
|
60
|
-
translatedValue: z.ZodString
|
|
58
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
59
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
61
60
|
}, "strip", z.ZodTypeAny, {
|
|
62
61
|
sourceValue: string;
|
|
63
62
|
translatedValue: string;
|
|
@@ -66,8 +65,8 @@ export declare const TRANSLATE_SEGMENT_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
66
65
|
translatedValue: string;
|
|
67
66
|
}>>;
|
|
68
67
|
translationExamples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
69
|
-
sourceValue: z.ZodString
|
|
70
|
-
translatedValue: z.ZodString
|
|
68
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
69
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
71
70
|
}, "strip", z.ZodTypeAny, {
|
|
72
71
|
sourceValue: string;
|
|
73
72
|
translatedValue: string;
|
|
@@ -75,7 +74,7 @@ export declare const TRANSLATE_SEGMENT_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
75
74
|
sourceValue: string;
|
|
76
75
|
translatedValue: string;
|
|
77
76
|
}>, "many">>;
|
|
78
|
-
value: z.ZodString
|
|
77
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
79
78
|
}, "strip", z.ZodTypeAny, {
|
|
80
79
|
value: string;
|
|
81
80
|
id: string;
|
|
@@ -124,7 +123,7 @@ export declare const TRANSLATE_SEGMENT_SCHEMA: z.ZodEffects<z.ZodObject<{
|
|
|
124
123
|
export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
125
124
|
id: z.ZodString;
|
|
126
125
|
context: z.ZodOptional<z.ZodObject<{
|
|
127
|
-
description: z.ZodString
|
|
126
|
+
description: z.ZodEffects<z.ZodString, string, string>;
|
|
128
127
|
}, "strip", z.ZodTypeAny, {
|
|
129
128
|
description: string;
|
|
130
129
|
}, {
|
|
@@ -134,8 +133,8 @@ export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
134
133
|
segments: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
135
134
|
id: z.ZodString;
|
|
136
135
|
tmMatch: z.ZodOptional<z.ZodObject<{
|
|
137
|
-
sourceValue: z.ZodString
|
|
138
|
-
translatedValue: z.ZodString
|
|
136
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
137
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
139
138
|
}, "strip", z.ZodTypeAny, {
|
|
140
139
|
sourceValue: string;
|
|
141
140
|
translatedValue: string;
|
|
@@ -144,8 +143,8 @@ export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
144
143
|
translatedValue: string;
|
|
145
144
|
}>>;
|
|
146
145
|
translationExamples: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
147
|
-
sourceValue: z.ZodString
|
|
148
|
-
translatedValue: z.ZodString
|
|
146
|
+
sourceValue: z.ZodEffects<z.ZodString, string, string>;
|
|
147
|
+
translatedValue: z.ZodEffects<z.ZodString, string, string>;
|
|
149
148
|
}, "strip", z.ZodTypeAny, {
|
|
150
149
|
sourceValue: string;
|
|
151
150
|
translatedValue: string;
|
|
@@ -153,7 +152,7 @@ export declare const TRANSLATE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
153
152
|
sourceValue: string;
|
|
154
153
|
translatedValue: string;
|
|
155
154
|
}>, "many">>;
|
|
156
|
-
value: z.ZodString
|
|
155
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
157
156
|
}, "strip", z.ZodTypeAny, {
|
|
158
157
|
value: string;
|
|
159
158
|
id: string;
|
|
@@ -309,7 +308,7 @@ export type TranslateContentUnit = z.infer<typeof TRANSLATE_CONTENT_UNIT_SCHEMA>
|
|
|
309
308
|
*/
|
|
310
309
|
export declare const REWRITE_SEGMENT_SCHEMA: z.ZodObject<{
|
|
311
310
|
id: z.ZodString;
|
|
312
|
-
value: z.ZodString
|
|
311
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
313
312
|
}, "strip", z.ZodTypeAny, {
|
|
314
313
|
value: string;
|
|
315
314
|
id: string;
|
|
@@ -320,7 +319,7 @@ export declare const REWRITE_SEGMENT_SCHEMA: z.ZodObject<{
|
|
|
320
319
|
export declare const REWRITE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
321
320
|
id: z.ZodString;
|
|
322
321
|
context: z.ZodOptional<z.ZodObject<{
|
|
323
|
-
description: z.ZodString
|
|
322
|
+
description: z.ZodEffects<z.ZodString, string, string>;
|
|
324
323
|
}, "strip", z.ZodTypeAny, {
|
|
325
324
|
description: string;
|
|
326
325
|
}, {
|
|
@@ -329,7 +328,7 @@ export declare const REWRITE_CONTENT_UNIT_SCHEMA: z.ZodObject<{
|
|
|
329
328
|
characterLimit: z.ZodOptional<z.ZodNumber>;
|
|
330
329
|
segments: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
331
330
|
id: z.ZodString;
|
|
332
|
-
value: z.ZodString
|
|
331
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
333
332
|
}, "strip", z.ZodTypeAny, {
|
|
334
333
|
value: string;
|
|
335
334
|
id: string;
|
|
@@ -393,13 +392,13 @@ export declare const TranslateModeEnum: {
|
|
|
393
392
|
};
|
|
394
393
|
export type TranslateModeEnum = ObjectValues<typeof TranslateModeEnum>;
|
|
395
394
|
export declare const HISTORY_REQUEST_SCHEMA: z.ZodObject<{
|
|
396
|
-
values: z.ZodArray<z.ZodString, "atleastone">;
|
|
395
|
+
values: z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, string[], [string, ...string[]]>;
|
|
397
396
|
mode: z.ZodPipeline<z.ZodString, z.ZodNativeEnum<{
|
|
398
397
|
readonly REPHRASE: "rephrase";
|
|
399
398
|
readonly SHORTEN: "shorten";
|
|
400
399
|
}>>;
|
|
401
400
|
}, "strip", z.ZodTypeAny, {
|
|
402
|
-
values:
|
|
401
|
+
values: string[];
|
|
403
402
|
mode: "rephrase" | "shorten";
|
|
404
403
|
}, {
|
|
405
404
|
values: [string, ...string[]];
|
|
@@ -415,7 +414,7 @@ export declare const HISTORY_ENTRY_SCHEMA: z.ZodObject<{
|
|
|
415
414
|
readonly SHORTEN: "shorten";
|
|
416
415
|
readonly TRANSLATE: "translate";
|
|
417
416
|
}>;
|
|
418
|
-
value: z.ZodString
|
|
417
|
+
value: z.ZodEffects<z.ZodString, string, string>;
|
|
419
418
|
}, "strip", z.ZodTypeAny, {
|
|
420
419
|
value: string;
|
|
421
420
|
mode: "rephrase" | "shorten" | "translate";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { removeUnicodeNullCharacters } from "../../helpers/removeUnicodeNullCharacters.js";
|
|
2
3
|
import { isSegmentUnderLengthLimit } from "../../validation/isSegmentUnderLengthLimit.js";
|
|
3
4
|
import { getRequestSizeLimit, isRequestSizeUnderLimit } from "../../validation/requestSizeLimit.js";
|
|
4
|
-
import { COMMON_ERROR_RESPONSE_SCHEMA, IntegrationEngineEnum, TM_MATCH_SCHEMA,
|
|
5
|
+
import { COMMON_ERROR_RESPONSE_SCHEMA, CONTENT_ID_PROP_SCHEMA, IntegrationEngineEnum, TM_MATCH_SCHEMA, TRANSLATION_EXAMPLES_SCHEMA, transformTmMatchToTranslationExamples, } from "../common/commonSchemas.js";
|
|
5
6
|
export const refineDifferentSourceAndTargetLang = [
|
|
6
7
|
(data) => {
|
|
7
8
|
return data.sourceLocale !== data.targetLocale;
|
|
@@ -44,36 +45,25 @@ export const SEGMENT_TRANSLATION_WARNING_SCHEMA = z.object({
|
|
|
44
45
|
kind: z.enum(TRANSLATION_QUALITY_WARNING_KINDS),
|
|
45
46
|
});
|
|
46
47
|
export const SEGMENT_WARNINGS_SCHEMA = z.array(SEGMENT_TRANSLATION_WARNING_SCHEMA);
|
|
47
|
-
const ID_PROP_MAX_LENGTH = 100;
|
|
48
48
|
export const CONTENT_UNIT_DESCRIPTION_MAX_LENGTH = 32768;
|
|
49
49
|
const CONTENT_UNIT_SEGMENTS_MAX_LENGTH = 1000; // context -> https://lokalise.slack.com/archives/C07BVQEMCRJ/p1725002827265889
|
|
50
|
-
export const CONTENT_ID_PROP_SCHEMA = z.string().min(1).max(ID_PROP_MAX_LENGTH);
|
|
51
50
|
export const TRANSLATE_SEGMENT_SCHEMA = z
|
|
52
51
|
.object({
|
|
53
52
|
id: CONTENT_ID_PROP_SCHEMA,
|
|
54
|
-
tmMatch: TM_MATCH_SCHEMA
|
|
55
|
-
translationExamples:
|
|
56
|
-
|
|
57
|
-
.optional()
|
|
58
|
-
.describe('When defined, the translation will attempt to follow the provided translation example'),
|
|
59
|
-
value: z.string().min(1),
|
|
53
|
+
tmMatch: TM_MATCH_SCHEMA,
|
|
54
|
+
translationExamples: TRANSLATION_EXAMPLES_SCHEMA,
|
|
55
|
+
value: z.string().min(1).transform(removeUnicodeNullCharacters),
|
|
60
56
|
})
|
|
61
|
-
.transform(
|
|
62
|
-
if (segment.tmMatch) {
|
|
63
|
-
segment.translationExamples = segment.translationExamples
|
|
64
|
-
? [...segment.translationExamples, segment.tmMatch]
|
|
65
|
-
: [segment.tmMatch];
|
|
66
|
-
}
|
|
67
|
-
if (segment.translationExamples?.length === 0) {
|
|
68
|
-
segment.translationExamples = undefined;
|
|
69
|
-
}
|
|
70
|
-
return segment;
|
|
71
|
-
});
|
|
57
|
+
.transform(transformTmMatchToTranslationExamples);
|
|
72
58
|
export const TRANSLATE_CONTENT_UNIT_SCHEMA = z.object({
|
|
73
59
|
id: CONTENT_ID_PROP_SCHEMA,
|
|
74
60
|
context: z
|
|
75
61
|
.object({
|
|
76
|
-
description: z
|
|
62
|
+
description: z
|
|
63
|
+
.string()
|
|
64
|
+
.min(1)
|
|
65
|
+
.max(CONTENT_UNIT_DESCRIPTION_MAX_LENGTH)
|
|
66
|
+
.transform(removeUnicodeNullCharacters),
|
|
77
67
|
})
|
|
78
68
|
.optional(),
|
|
79
69
|
characterLimit: z.number().optional(),
|
|
@@ -88,13 +78,17 @@ export const TRANSLATE_CONTENT_UNIT_SCHEMA = z.object({
|
|
|
88
78
|
*/
|
|
89
79
|
export const REWRITE_SEGMENT_SCHEMA = z.object({
|
|
90
80
|
id: CONTENT_ID_PROP_SCHEMA,
|
|
91
|
-
value: z.string().min(1),
|
|
81
|
+
value: z.string().min(1).transform(removeUnicodeNullCharacters),
|
|
92
82
|
});
|
|
93
83
|
export const REWRITE_CONTENT_UNIT_SCHEMA = z.object({
|
|
94
84
|
id: CONTENT_ID_PROP_SCHEMA,
|
|
95
85
|
context: z
|
|
96
86
|
.object({
|
|
97
|
-
description: z
|
|
87
|
+
description: z
|
|
88
|
+
.string()
|
|
89
|
+
.min(1)
|
|
90
|
+
.max(CONTENT_UNIT_DESCRIPTION_MAX_LENGTH)
|
|
91
|
+
.transform(removeUnicodeNullCharacters),
|
|
98
92
|
})
|
|
99
93
|
.optional(),
|
|
100
94
|
characterLimit: z.number().optional(),
|
|
@@ -121,6 +115,7 @@ export const HISTORY_REQUEST_SCHEMA = z.object({
|
|
|
121
115
|
values: z
|
|
122
116
|
.array(z.string().min(1))
|
|
123
117
|
.nonempty()
|
|
118
|
+
.transform((values) => values.map(removeUnicodeNullCharacters))
|
|
124
119
|
.describe('Previously generated translation variants'),
|
|
125
120
|
mode: z
|
|
126
121
|
.string()
|
|
@@ -133,7 +128,11 @@ export const HISTORY_REQUEST_SCHEMA = z.object({
|
|
|
133
128
|
*/
|
|
134
129
|
export const HISTORY_ENTRY_SCHEMA = z.object({
|
|
135
130
|
mode: z.nativeEnum(TranslateModeEnum).describe('Previously used translation mode'),
|
|
136
|
-
value: z
|
|
131
|
+
value: z
|
|
132
|
+
.string()
|
|
133
|
+
.min(1)
|
|
134
|
+
.describe('Previous version of the translation')
|
|
135
|
+
.transform(removeUnicodeNullCharacters),
|
|
137
136
|
});
|
|
138
137
|
/**
|
|
139
138
|
* Streaming events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"sharedSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/sharedSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAA;AAE1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AACnG,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,2BAA2B,EAC3B,qCAAqC,GACtC,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;IACpC,CAAC,IAA2D,EAAE,EAAE;QAC9D,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,SAAS;YACzC,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