@lokalise/polyglot-sdk 20.0.0 → 20.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk/schemas/common/commonSchemas.d.ts +20 -21
- package/dist/sdk/schemas/common/commonSchemas.js +16 -18
- package/dist/sdk/schemas/common/commonSchemas.js.map +1 -1
- 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 +108 -89
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js +3 -2
- package/dist/sdk/schemas/lqa/lqaAsyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.d.ts +100 -91
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js +3 -2
- package/dist/sdk/schemas/lqa/lqaSyncSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/generateVariants.d.ts +63 -64
- package/dist/sdk/schemas/translation/rewriteTextSchemas.d.ts +155 -157
- package/dist/sdk/schemas/translation/rewriteTextSchemas.js +2 -2
- package/dist/sdk/schemas/translation/rewriteTextSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/sharedSchemas.d.ts +257 -58
- package/dist/sdk/schemas/translation/sharedSchemas.js +25 -15
- package/dist/sdk/schemas/translation/sharedSchemas.js.map +1 -1
- package/dist/sdk/schemas/translation/translateAsyncSchemas.d.ts +334 -335
- 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 +491 -254
- 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 +425 -68
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js +25 -7
- package/dist/sdk/schemas/translation/translateTextSegmentSchemas.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { OWNER_ID_SCHEMA } from "../common/asyncRequestSchemas.js";
|
|
3
|
-
import { COMMON_REQUEST_HEADERS_SCHEMA, FORCE_INTEGRATION_SCHEMA, LOCALE_SCHEMA, METADATA_SCHEMA, REAL_INTEGRATION_ENGINE_SCHEMA, TRANSLATION_EXAMPLE_SCHEMA, refineIntegrationIsPresent, } from "../common/commonSchemas.js";
|
|
3
|
+
import { COMMON_REQUEST_HEADERS_SCHEMA, CONTENT_ID_PROP_SCHEMA, FORCE_INTEGRATION_SCHEMA, LOCALE_SCHEMA, METADATA_SCHEMA, REAL_INTEGRATION_ENGINE_SCHEMA, TRANSLATION_EXAMPLE_SCHEMA, refineIntegrationIsPresent, } from "../common/commonSchemas.js";
|
|
4
4
|
import { TRANSLATION_CONTEXT_SCHEMA } from "../common/translationContextSchemas.js";
|
|
5
|
-
import {
|
|
5
|
+
import { HISTORY_ENTRY_SCHEMA, TranslateModeEnum, refineDifferentSourceAndTargetLang, refineHistoryIsPresent, } from "./sharedSchemas.js";
|
|
6
6
|
export const TRANSLATE_TEXT_SEGMENT_BODY_SCHEMA = z
|
|
7
7
|
.object({
|
|
8
8
|
ownerId: OWNER_ID_SCHEMA.optional(),
|
|
@@ -10,19 +10,27 @@ export const TRANSLATE_TEXT_SEGMENT_BODY_SCHEMA = z
|
|
|
10
10
|
targetLocale: LOCALE_SCHEMA,
|
|
11
11
|
integration: REAL_INTEGRATION_ENGINE_SCHEMA.optional(),
|
|
12
12
|
forceIntegration: FORCE_INTEGRATION_SCHEMA.optional(),
|
|
13
|
-
context: TRANSLATION_CONTEXT_SCHEMA.
|
|
14
|
-
description: z.string().min(1).max(CONTENT_UNIT_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15
|
-
translationExamples: z.array(TRANSLATION_EXAMPLE_SCHEMA).optional(),
|
|
16
|
-
}).optional(),
|
|
13
|
+
context: TRANSLATION_CONTEXT_SCHEMA.optional(),
|
|
17
14
|
metadata: METADATA_SCHEMA,
|
|
18
15
|
mode: z
|
|
19
16
|
.nativeEnum(TranslateModeEnum)
|
|
20
17
|
.describe('Specifies the translation mode for the request. Use `translate` if you just want to have a translation of the text. Use `rephrase` in combination with `history` entries to attempt to generate a different wording for the translate. Use `shorten` to try to get the translation shorter while maintaining the message.'),
|
|
18
|
+
desiredVariantsCount: z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.positive()
|
|
22
|
+
.max(10)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('How many variants to generate when using `rephrase` or `shorten`. Polyglot might return less than requested in case some variants were low quality.'),
|
|
21
25
|
text: z.object({
|
|
22
26
|
contentUnitId: CONTENT_ID_PROP_SCHEMA,
|
|
23
27
|
segmentId: CONTENT_ID_PROP_SCHEMA.optional(),
|
|
24
28
|
value: z.string().min(1),
|
|
25
29
|
characterLimit: z.number().optional(),
|
|
30
|
+
translationExamples: z
|
|
31
|
+
.array(TRANSLATION_EXAMPLE_SCHEMA)
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('When defined, the translation will attempt to follow the provided translation examples'),
|
|
26
34
|
}),
|
|
27
35
|
history: z
|
|
28
36
|
.array(HISTORY_ENTRY_SCHEMA)
|
|
@@ -31,6 +39,16 @@ export const TRANSLATE_TEXT_SEGMENT_BODY_SCHEMA = z
|
|
|
31
39
|
})
|
|
32
40
|
.refine(...refineDifferentSourceAndTargetLang)
|
|
33
41
|
.refine(...refineHistoryIsPresent)
|
|
34
|
-
.refine(...refineIntegrationIsPresent)
|
|
42
|
+
.refine(...refineIntegrationIsPresent)
|
|
43
|
+
.refine((body) => {
|
|
44
|
+
return !body.desiredVariantsCount || body.mode !== TranslateModeEnum.TRANSLATE;
|
|
45
|
+
}, 'Field `desiredVariantsCount` can only be set with `mode=shorten` or `mode=rephrase`')
|
|
46
|
+
// Copy deprecated `translationExamples` from `context` to `text`
|
|
47
|
+
.transform((body) => {
|
|
48
|
+
if (!body.text.translationExamples) {
|
|
49
|
+
body.text.translationExamples = body.context?.translationExamples;
|
|
50
|
+
}
|
|
51
|
+
return body;
|
|
52
|
+
});
|
|
35
53
|
export const TRANSLATE_TEXT_SEGMENT_HEADERS_SCHEMA = COMMON_REQUEST_HEADERS_SCHEMA;
|
|
36
54
|
//# sourceMappingURL=translateTextSegmentSchemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateTextSegmentSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/translateTextSegmentSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AACnF,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"translateTextSegmentSchemas.js","sourceRoot":"","sources":["../../../../src/sdk/schemas/translation/translateTextSegmentSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AACnF,O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MAAM,CAAC,GAAG,0BAA0B,CAAC;KACrC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACf,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,SAAS,CAAA;AAChF,CAAC,EAAE,qFAAqF,CAAC;IACzF,iEAAiE;KAChE,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;IAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACnE,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,qCAAqC,GAAG,6BAA6B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/polyglot-sdk",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Lokalise",
|
|
6
6
|
"url": "https://lokalise.com/"
|
|
@@ -38,32 +38,32 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@lokalise/backend-http-client": "^5.0.0",
|
|
41
|
-
"@lokalise/id-utils": "^3.0.
|
|
42
|
-
"@lokalise/node-core": "^
|
|
41
|
+
"@lokalise/id-utils": "^3.0.1",
|
|
42
|
+
"@lokalise/node-core": "^14.1.0",
|
|
43
43
|
"@lokalise/non-translatable-markup": "^3.0.0",
|
|
44
44
|
"@lokalise/supported-languages": "^3.1.0",
|
|
45
45
|
"@lokalise/zod-extras": "^2.1.0",
|
|
46
46
|
"html-escaper": "^3.0.3",
|
|
47
|
-
"undici": "^7.
|
|
47
|
+
"undici": "^7.10.0",
|
|
48
48
|
"undici-retry": "^6.0.0",
|
|
49
|
-
"zod": "^3.
|
|
49
|
+
"zod": "^3.25.56"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@lokalise/fastify-extras": ">=27.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@amplitude/analytics-types": "^2.9.
|
|
55
|
+
"@amplitude/analytics-types": "^2.9.2",
|
|
56
56
|
"@biomejs/biome": "^1.9.4",
|
|
57
57
|
"@lokalise/biome-config": "^2.0.0",
|
|
58
58
|
"@lokalise/fastify-extras": "^27.3.0",
|
|
59
59
|
"@lokalise/tsconfig": "^1.1.0",
|
|
60
60
|
"@types/html-escaper": "^3.0.4",
|
|
61
|
-
"@types/node": "^22.15.
|
|
62
|
-
"@vitest/coverage-v8": "^3.
|
|
61
|
+
"@types/node": "^22.15.30",
|
|
62
|
+
"@vitest/coverage-v8": "^3.2.3",
|
|
63
63
|
"auto-changelog": "^2.5.0",
|
|
64
64
|
"mockttp": "^3.17.1",
|
|
65
65
|
"rimraf": "^6.0.1",
|
|
66
|
-
"ts-deepmerge": "^7.0.
|
|
66
|
+
"ts-deepmerge": "^7.0.3",
|
|
67
67
|
"typescript": "5.8.3",
|
|
68
68
|
"vitest": "^3.0.4"
|
|
69
69
|
}
|