@l10nmonster/helpers-translated 3.0.0-alpha.9 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ ## @l10nmonster/helpers-translated [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.1.0...@l10nmonster/helpers-translated@3.1.1) (2025-12-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
7
+
8
+ ## @l10nmonster/helpers-translated [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.1.0...@l10nmonster/helpers-translated@3.1.1) (2025-12-23)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
14
+
15
+
16
+
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * **@l10nmonster/core:** upgraded to 3.1.1
22
+
23
+ # @l10nmonster/helpers-translated [3.1.0](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-translated@3.0.0...@l10nmonster/helpers-translated@3.1.0) (2025-12-20)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * Add support for async functions for secrets ([5d9d0a9](https://public-github/l10nmonster/l10nmonster/commit/5d9d0a99f45e1f4f16a30a634bea4259b106d74a))
29
+ * **helpers-translated:** Remove content type from Lara ([3664fe2](https://public-github/l10nmonster/l10nmonster/commit/3664fe2f1312d27cdbfbe587e817aa14480de496))
30
+ * **server:** Fix cart cleanup ([9bbcab9](https://public-github/l10nmonster/l10nmonster/commit/9bbcab93e1fd20aeb09f59c828665159f091f37c))
31
+
32
+
33
+ ### Features
34
+
35
+ * **providers:** Support promises for secrets ([3ac66dc](https://public-github/l10nmonster/l10nmonster/commit/3ac66dc13761f671a85f7f3b3df0539d021366dd))
36
+ * **translated:** Add glossary options to MMT ([39eb5d0](https://public-github/l10nmonster/l10nmonster/commit/39eb5d0e6d611539b6b59d986ebf725bfd561a70))
37
+
1
38
  # Changelog
2
39
 
3
40
  All notable changes to this project will be documented in this file.
package/laraProvider.js CHANGED
@@ -3,7 +3,6 @@ import { Credentials, Translator } from '@translated/lara';
3
3
 
4
4
  /**
5
5
  * @typedef {object} LaraProviderOptions
6
- * @extends ChunkedRemoteTranslationProviderOptions
7
6
  * @property {string} keyId - The Lara API key id. This is required.
8
7
  * @property {Promise<string>|string} [keySecret] - The Lara API key secret. Optional, but often needed for authentication.
9
8
  * @property {string | Array<string>} [adaptTo] - An optional single translation memory ID or an array of IDs to adapt translations to.
@@ -24,11 +23,11 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
24
23
  * @param {LaraProviderOptions} options - Configuration options for the provider.
25
24
  */
26
25
  constructor({ keyId, keySecret, adaptTo, glossaries, ...options }) {
26
+ // @ts-ignore - spread loses type info but parent class handles validation
27
27
  super({ maxChunkSize: 60, ...options }); // maximum number of strings sent to Lara is 128 including notes
28
28
  this.#keyId = keyId;
29
29
  this.#keySecret = keySecret;
30
30
  this.#translateOptions = {
31
- contentType: 'text/plain',
32
31
  instructions: [],
33
32
  };
34
33
  adaptTo && (this.#translateOptions.adaptTo = Array.isArray(adaptTo) ? adaptTo : adaptTo.split(','));
@@ -37,11 +36,13 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
37
36
  }
38
37
 
39
38
  async #getLara() {
40
- const credentials = new Credentials(this.#keyId, await (typeof this.#keySecret === 'function' ? this.#keySecret() : this.#keySecret));
39
+ // @ts-ignore - keySecret can be a function or value, TypeScript doesn't narrow correctly
40
+ const resolvedSecret = await (typeof this.#keySecret === 'function' ? this.#keySecret() : this.#keySecret);
41
+ const credentials = new Credentials(this.#keyId, resolvedSecret);
41
42
  return new Translator(credentials);
42
43
  }
43
44
 
44
- prepareTranslateChunkArgs({ sourceLang, targetLang, xmlTus, instructions }) {
45
+ prepareTranslateChunkArgs({ sourceLang, targetLang, xmlTus, jobGuid, chunkNumber, instructions }) {
45
46
  const payload = xmlTus.map(xmlTu => {
46
47
  const textBlock = [];
47
48
  textBlock.push({ text: `bundle: ${xmlTu.bundle} key: ${xmlTu.key} notes: ${xmlTu.notes ?? ''}`, translatable: false });
@@ -49,7 +50,7 @@ export class LaraProvider extends providers.ChunkedRemoteTranslationProvider {
49
50
  return textBlock;
50
51
  }).flat(1);
51
52
  const translateOptions = instructions ? { ...this.#translateOptions, instructions: [...this.#translateOptions.instructions, instructions] } : this.#translateOptions;
52
- return { payload, sourceLang, targetLang, translateOptions };
53
+ return { payload, sourceLang, targetLang, xmlTus, jobGuid, chunkNumber, translateOptions };
53
54
  }
54
55
 
55
56
  async startTranslateChunk(args) {
package/mmtProvider.js CHANGED
@@ -3,7 +3,6 @@ import { ModernMT as MMTClient } from 'modernmt';
3
3
 
4
4
  /**
5
5
  * @typedef {object} MMTProviderOptions
6
- * @extends ChunkedRemoteTranslationProviderOptions
7
6
  * @property {string} [id] - Global identifier (by default 'MMTBatch' or 'MMTRealtime')
8
7
  * @property {Promise<string>|string} apiKey - The ModernMT API key.
9
8
  * @property {string} [webhook] - The webhook URL for batch translation.
@@ -26,6 +25,7 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
26
25
  */
27
26
  constructor({ id, apiKey, webhook, chunkFetcher, hints, glossaries, ignoreGlossaryCase, multiline = true, ...options }) {
28
27
  id ??= webhook ? 'MMTBatch' : 'MMTRealtime';
28
+ // @ts-ignore - spread loses type info but parent class handles validation
29
29
  super({ id, ...options });
30
30
  if (webhook) {
31
31
  if (chunkFetcher) {
@@ -51,8 +51,11 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
51
51
  return {
52
52
  sourceLang,
53
53
  targetLang,
54
+ xmlTus,
55
+ jobGuid,
56
+ chunkNumber,
54
57
  q: xmlTus.map(xmlTu => xmlTu.source),
55
- hints:this.baseRequest.hints,
58
+ hints: this.baseRequest.hints,
56
59
  contextVector: undefined,
57
60
  options: this.baseRequest.options,
58
61
  webhook: this.baseRequest.webhook,
@@ -67,7 +70,9 @@ export class MMTProvider extends providers.ChunkedRemoteTranslationProvider {
67
70
  async startTranslateChunk(args) {
68
71
  const { sourceLang, targetLang, q, hints, contextVector, options, webhook, batchOptions } = args;
69
72
  try {
70
- const mmt = new MMTClient(await (typeof this.#apiKey === 'function' ? this.#apiKey() : this.#apiKey), 'l10n.monster/MMT', '3.0');
73
+ // @ts-ignore - apiKey can be a function or value, TypeScript doesn't narrow correctly
74
+ const resolvedKey = await (typeof this.#apiKey === 'function' ? this.#apiKey() : this.#apiKey);
75
+ const mmt = new MMTClient(resolvedKey, 'l10n.monster/MMT', '3.0');
71
76
  if (webhook) {
72
77
  const response = await mmt.batchTranslate(webhook, sourceLang, targetLang, q, hints, contextVector, batchOptions);
73
78
  return { enqueued: response };
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@l10nmonster/helpers-translated",
3
- "version": "3.0.0-alpha.9",
3
+ "version": "3.1.1",
4
4
  "description": "Helpers to integrate with Translated.com",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "test": "node --test"
8
+ "test": "node --test",
9
+ "typecheck": "tsc --noEmit"
9
10
  },
10
11
  "author": "Diego Lagunas",
11
12
  "license": "MIT",
12
13
  "peerDependencies": {
13
- "@l10nmonster/core": "^3.0.0-alpha.0"
14
+ "@l10nmonster/core": "3.1.1"
14
15
  },
15
16
  "dependencies": {
16
17
  "@translated/lara": "^1.4.0",
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "include": [
4
+ "*.js",
5
+ "**/*.js"
6
+ ],
7
+ "exclude": [
8
+ "node_modules",
9
+ "**/node_modules",
10
+ "test/**",
11
+ "tests/**",
12
+ "**/*.test.js",
13
+ "**/*.spec.js",
14
+ "dist/**",
15
+ "ui/**",
16
+ "types/**"
17
+ ]
18
+ }
package/.releaserc.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "branches": [
3
- "main",
4
- {
5
- "name": "next",
6
- "prerelease": "alpha"
7
- },
8
- {
9
- "name": "beta",
10
- "prerelease": "beta"
11
- }
12
- ],
13
- "tagFormat": "@l10nmonster/helpers-translated@${version}",
14
- "plugins": [
15
- "@semantic-release/commit-analyzer",
16
- "@semantic-release/release-notes-generator",
17
- {
18
- "path": "@semantic-release/changelog",
19
- "changelogFile": "CHANGELOG.md"
20
- },
21
- {
22
- "path": "@semantic-release/npm",
23
- "npmPublish": true
24
- },
25
- {
26
- "path": "@semantic-release/git",
27
- "assets": ["CHANGELOG.md", "package.json"],
28
- "message": "chore(release): @l10nmonster/helpers-translated@${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
29
- }
30
- ]
31
- }