@l10nmonster/helpers-lqaboss 3.1.0 → 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,25 @@
1
+ ## @l10nmonster/helpers-lqaboss [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-lqaboss@3.1.0...@l10nmonster/helpers-lqaboss@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-lqaboss [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-lqaboss@3.1.0...@l10nmonster/helpers-lqaboss@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
+
1
23
  # @l10nmonster/helpers-lqaboss [3.1.0](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-lqaboss@3.0.0...@l10nmonster/helpers-lqaboss@3.1.0) (2025-12-20)
2
24
 
3
25
 
package/flowCapture.js CHANGED
@@ -68,7 +68,9 @@ async function extractTextAndMetadataInPageContext() {
68
68
  if (decodedJsonMetadata && decodedJsonMetadata.trim() !== '') {
69
69
  parsedMetadata = JSON.parse(decodedJsonMetadata);
70
70
  }
71
- } catch (e) { parsedMetadata.decodingError = e.message; }
71
+ } catch (e) {
72
+ parsedMetadata.decodingError = e.message;
73
+ }
72
74
 
73
75
  textElements.push({
74
76
  text: activeSegment.text,
@@ -110,7 +112,9 @@ async function extractTextAndMetadataInPageContext() {
110
112
  if (decodedJsonMetadata && decodedJsonMetadata.trim() !== '') {
111
113
  parsedMetadata = JSON.parse(decodedJsonMetadata);
112
114
  }
113
- } catch (e) { parsedMetadata.decodingError = e.message; }
115
+ } catch (e) {
116
+ parsedMetadata.decodingError = e.message;
117
+ }
114
118
 
115
119
  textElements.push({
116
120
  text: capturedText,
package/lqabossActions.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import { lqaboss_capture } from './lqabossCapture.js';
2
2
 
3
- export class LQABossActions {
4
- static name = 'lqaboss';
5
- static help = {
3
+ /**
4
+ * CLI actions for LQA Boss integration.
5
+ * @type {import('@l10nmonster/core').L10nAction}
6
+ */
7
+ export const LQABossActions = {
8
+ name: 'lqaboss',
9
+ help: {
6
10
  description: 'Actions to integrate with LQA Boss.',
7
- };
8
-
9
- static subActions = [ lqaboss_capture ];
10
- }
11
+ },
12
+ subActions: [ lqaboss_capture ],
13
+ };
package/lqabossCapture.js CHANGED
@@ -3,8 +3,13 @@ import readline from 'readline';
3
3
  import { consoleLog } from '@l10nmonster/core';
4
4
  import { FlowSnapshotter } from './flowCapture.js';
5
5
 
6
- export class lqaboss_capture {
7
- static help = {
6
+ /**
7
+ * CLI action for creating an LQA Boss flow.
8
+ * @type {import('@l10nmonster/core').L10nAction}
9
+ */
10
+ export const lqaboss_capture = {
11
+ name: 'lqaboss_capture',
12
+ help: {
8
13
  description: 'create an lqaboss flow.',
9
14
  arguments: [
10
15
  ['<url>', 'the url of the page to capture'],
@@ -13,29 +18,30 @@ export class lqaboss_capture {
13
18
  options: [
14
19
  [ '--lang <srcLang,tgtLang>', 'source and target language pair' ],
15
20
  ],
16
- };
21
+ },
17
22
 
18
- static async action(mm, options) {
19
- if (!options.url || !options.flowName) {
23
+ async action(mm, options) {
24
+ const { url, flowName, lang } = /** @type {{ url?: string, flowName?: string, lang?: string | string[] }} */ (options);
25
+ if (!url || !flowName) {
20
26
  throw new Error('You must specify a url and a flowName');
21
27
  }
22
- const langPairs = options.lang ? (Array.isArray(options.lang) ? options.lang : options.lang.split(',')) : null;
28
+ const langPairs = lang ? (Array.isArray(lang) ? lang : lang.split(',')) : null;
23
29
  let tm;
24
30
  if (langPairs) {
25
31
  const [ sourceLang, targetLang ] = langPairs;
26
32
  tm = mm.tmm.getTM(sourceLang, targetLang);
27
33
  }
28
34
  // Run the capture flow
29
- const lqaBossBuffer = await runCapture(options.url, options.flowName, tm);
35
+ const lqaBossBuffer = await runCapture(url, flowName, tm);
30
36
  if (lqaBossBuffer) {
31
- const filename = `${options.flowName.replace(/[^a-z0-9_.-]/gi, '_')}.lqaboss`;
37
+ const filename = `${flowName.replace(/[^a-z0-9_.-]/gi, '_')}.lqaboss`;
32
38
  await fs.promises.writeFile(filename, lqaBossBuffer);
33
39
  consoleLog`Flow successfully saved as ${filename}`;
34
40
  } else {
35
41
  console.log('No pages were captured. Nothing to save.');
36
42
  }
37
- }
38
- }
43
+ },
44
+ };
39
45
 
40
46
  async function runCapture(startUrl, flowNameBase, tm) {
41
47
  const snapShotter = new FlowSnapshotter(startUrl, flowNameBase);
@@ -5,7 +5,6 @@ import { providers, logVerbose, styleString, opsManager, getBaseDir } from '@l10
5
5
 
6
6
  /**
7
7
  * @typedef {object} LQABossProviderOptions
8
- * @extends BaseTranslationProvider
9
8
  * @property {Object} delegate - Required file store delegate implementing file operations
10
9
  * @property {string} [urlPrefix] - Prefix for the LQA Boss URL
11
10
  * @property {string} [qualityFile] - Path to a quality model JSON file
package/lqabossRoutes.js CHANGED
@@ -1,5 +1,12 @@
1
1
  import { logInfo, logVerbose, logWarn } from '@l10nmonster/core';
2
2
 
3
+ /** @typedef {import('@l10nmonster/core').MonsterManager} MonsterManager */
4
+
5
+ /**
6
+ * Creates LQABoss route handlers for the server extension mechanism.
7
+ * @param {MonsterManager} mm - MonsterManager instance.
8
+ * @returns {Array<[string, string, Function]>} Route definitions.
9
+ */
3
10
  export function createLQABossRoutes(mm) {
4
11
  return [
5
12
  ['post', '/lookup', async (req, res) => {
package/lqabossTmStore.js CHANGED
@@ -1,19 +1,22 @@
1
1
  import { utils } from '@l10nmonster/core';
2
2
 
3
+ /** @typedef {import('@l10nmonster/core').TMStore} TMStore */
4
+
3
5
  /**
4
6
  * Adapter class to expose LQABoss completion files as a TM store.
5
- *
6
- * @class LQABossTmStore
7
+ * @implements {TMStore}
7
8
  */
8
9
  export class LQABossTmStore {
9
10
  id;
10
11
  #storageDelegate;
11
12
  #tm;
12
13
 
14
+ /** @type {'readonly'} */
13
15
  get access() {
14
16
  return 'readonly';
15
17
  }
16
18
 
19
+ /** @type {'job'} */
17
20
  get partitioning() {
18
21
  return 'job';
19
22
  }
@@ -56,8 +59,13 @@ export class LQABossTmStore {
56
59
  return this.#tm;
57
60
  }
58
61
 
62
+ /**
63
+ * @returns {Promise<[string, string][]>}
64
+ */
59
65
  async getAvailableLangPairs() {
60
66
  const tm = await this.#getTM();
67
+
68
+ /** @type {[string, string][]} */
61
69
  const pairs = [];
62
70
  for (const [ sourceLang, targets ] of Object.entries(tm)) {
63
71
  for (const targetLang of Object.keys(targets)) {
@@ -73,21 +81,34 @@ export class LQABossTmStore {
73
81
  return Object.entries(blocks).map(([ jobGuid, job ]) => [ jobGuid, job.updatedAt ]);
74
82
  }
75
83
 
84
+ /**
85
+ * @param {string} sourceLang
86
+ * @param {string} targetLang
87
+ * @param {string[]} blockIds
88
+ * @returns {AsyncGenerator<import('@l10nmonster/core').JobPropsTusPair>}
89
+ */
76
90
  async *getTmBlocks(sourceLang, targetLang, blockIds) {
77
91
  const tm = await this.#getTM();
78
92
  const blocks = tm[sourceLang]?.[targetLang] ?? {};
79
93
  for (const jobGuid of blockIds) {
80
94
  const job = blocks[jobGuid];
81
95
  if (job) {
96
+ // @ts-ignore - type inference issue with TU properties
82
97
  yield* utils.getIteratorFromJobPair(job, job);
83
98
  }
84
99
  }
85
100
  }
86
101
 
102
+ /**
103
+ * @param {string} sourceLang
104
+ * @param {string} targetLang
105
+ * @returns {Promise<import('@l10nmonster/core').TMStoreTOC>}
106
+ */
87
107
  async getTOC(sourceLang, targetLang) {
88
108
  const tm = await this.#getTM();
89
109
  const blocks = tm[sourceLang]?.[targetLang] ?? {};
90
- const toc = { v: 1, sourceLang, targetLang, blocks: {} };
110
+ /** @type {import('@l10nmonster/core').TMStoreTOC} */
111
+ const toc = { v: 1, sourceLang, targetLang, blocks: {}, storedBlocks: [] };
91
112
  for (const [ jobGuid, job ] of Object.entries(blocks)) {
92
113
  toc.blocks[jobGuid] = { blockName: jobGuid, modified: job.updatedAt, jobs: [ [ jobGuid, job.updatedAt ] ] };
93
114
  }
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
- "name": "@l10nmonster/helpers-lqaboss",
3
- "version": "3.1.0",
4
- "description": "LQA Boss helper for L10n Monster",
5
- "main": "index.js",
6
- "type": "module",
7
- "scripts": {
8
- "start": "node index.js",
9
- "test": "node --test test/*.test.js"
10
- },
11
- "dependencies": {
12
- "jszip": "^3.10.1",
13
- "puppeteer": "^24"
14
- },
15
- "peerDependencies": {
16
- "@l10nmonster/core": "3.1.0"
17
- }
2
+ "name": "@l10nmonster/helpers-lqaboss",
3
+ "version": "3.1.1",
4
+ "description": "LQA Boss helper for L10n Monster",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "node index.js",
9
+ "test": "node --test test/*.test.js",
10
+ "typecheck": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "jszip": "^3.10.1",
14
+ "puppeteer": "^24"
15
+ },
16
+ "peerDependencies": {
17
+ "@l10nmonster/core": "3.1.1"
18
+ }
18
19
  }
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-lqaboss@${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": false
24
- },
25
- {
26
- "path": "@semantic-release/git",
27
- "assets": ["CHANGELOG.md", "package.json"],
28
- "message": "chore(release): @l10nmonster/helpers-lqaboss@${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
29
- }
30
- ]
31
- }