@intlayer/cli 8.1.1 → 8.1.3-canary.0

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.
Files changed (304) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +1 -186
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  4. package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
  5. package/dist/cjs/auth/login.cjs +2 -85
  6. package/dist/cjs/auth/login.cjs.map +1 -1
  7. package/dist/cjs/build.cjs +1 -27
  8. package/dist/cjs/build.cjs.map +1 -1
  9. package/dist/cjs/ci.cjs +1 -73
  10. package/dist/cjs/ci.cjs.map +1 -1
  11. package/dist/cjs/cli.cjs +1 -476
  12. package/dist/cjs/cli.cjs.map +1 -1
  13. package/dist/cjs/config.cjs +1 -12
  14. package/dist/cjs/config.cjs.map +1 -1
  15. package/dist/cjs/editor.cjs +1 -50
  16. package/dist/cjs/editor.cjs.map +1 -1
  17. package/dist/cjs/extract.cjs +1 -96
  18. package/dist/cjs/extract.cjs.map +1 -1
  19. package/dist/cjs/fill/deepMergeContent.cjs +1 -27
  20. package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
  21. package/dist/cjs/fill/fill.cjs +1 -78
  22. package/dist/cjs/fill/fill.cjs.map +1 -1
  23. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -29
  24. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  25. package/dist/cjs/fill/formatFillData.cjs +1 -50
  26. package/dist/cjs/fill/formatFillData.cjs.map +1 -1
  27. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +1 -26
  28. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
  29. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +1 -50
  30. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
  31. package/dist/cjs/fill/index.cjs +1 -6
  32. package/dist/cjs/fill/listTranslationsTasks.cjs +1 -70
  33. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  34. package/dist/cjs/fill/mergeChunks.cjs +1 -28
  35. package/dist/cjs/fill/mergeChunks.cjs.map +1 -1
  36. package/dist/cjs/fill/translateDictionary.cjs +1 -205
  37. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  38. package/dist/cjs/fill/writeFill.cjs +1 -54
  39. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  40. package/dist/cjs/getTargetDictionary.cjs +1 -36
  41. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  42. package/dist/cjs/index.cjs +1 -39
  43. package/dist/cjs/init.cjs +1 -322
  44. package/dist/cjs/init.cjs.map +1 -1
  45. package/dist/cjs/listContentDeclaration.cjs +1 -41
  46. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  47. package/dist/cjs/listProjects.cjs +1 -28
  48. package/dist/cjs/listProjects.cjs.map +1 -1
  49. package/dist/cjs/liveSync.cjs +8 -151
  50. package/dist/cjs/liveSync.cjs.map +1 -1
  51. package/dist/cjs/pull.cjs +1 -146
  52. package/dist/cjs/pull.cjs.map +1 -1
  53. package/dist/cjs/push/pullLog.cjs +3 -102
  54. package/dist/cjs/push/pullLog.cjs.map +1 -1
  55. package/dist/cjs/push/push.cjs +1 -206
  56. package/dist/cjs/push/push.cjs.map +1 -1
  57. package/dist/cjs/pushConfig.cjs +1 -19
  58. package/dist/cjs/pushConfig.cjs.map +1 -1
  59. package/dist/cjs/pushLog.cjs +3 -84
  60. package/dist/cjs/pushLog.cjs.map +1 -1
  61. package/dist/cjs/reviewDoc/reviewDoc.cjs +1 -68
  62. package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
  63. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +1 -94
  64. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
  65. package/dist/cjs/searchDoc.cjs +1 -38
  66. package/dist/cjs/searchDoc.cjs.map +1 -1
  67. package/dist/cjs/test/index.cjs +1 -7
  68. package/dist/cjs/test/listMissingTranslations.cjs +1 -49
  69. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  70. package/dist/cjs/test/test.cjs +1 -51
  71. package/dist/cjs/test/test.cjs.map +1 -1
  72. package/dist/cjs/translateDoc/index.cjs +1 -9
  73. package/dist/cjs/translateDoc/translateDoc.cjs +1 -74
  74. package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
  75. package/dist/cjs/translateDoc/translateFile.cjs +2 -103
  76. package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
  77. package/dist/cjs/translateDoc/validation.cjs +5 -49
  78. package/dist/cjs/translateDoc/validation.cjs.map +1 -1
  79. package/dist/cjs/translation-alignment/alignBlocks.cjs +1 -67
  80. package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
  81. package/dist/cjs/translation-alignment/computeSimilarity.cjs +1 -25
  82. package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
  83. package/dist/cjs/translation-alignment/fingerprintBlock.cjs +1 -23
  84. package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
  85. package/dist/cjs/translation-alignment/index.cjs +1 -22
  86. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +1 -18
  87. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
  88. package/dist/cjs/translation-alignment/normalizeBlock.cjs +1 -22
  89. package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
  90. package/dist/cjs/translation-alignment/pipeline.cjs +1 -37
  91. package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
  92. package/dist/cjs/translation-alignment/planActions.cjs +1 -46
  93. package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
  94. package/dist/cjs/translation-alignment/rebuildDocument.cjs +2 -49
  95. package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
  96. package/dist/cjs/translation-alignment/segmentDocument.cjs +5 -66
  97. package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
  98. package/dist/cjs/utils/calculateChunks.cjs +2 -89
  99. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  100. package/dist/cjs/utils/checkAccess.cjs +1 -81
  101. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  102. package/dist/cjs/utils/checkConfigConsistency.cjs +1 -16
  103. package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
  104. package/dist/cjs/utils/checkFileModifiedRange.cjs +1 -81
  105. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  106. package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -19
  107. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  108. package/dist/cjs/utils/chunkInference.cjs +1 -45
  109. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  110. package/dist/cjs/utils/fixChunkStartEndChars.cjs +3 -27
  111. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  112. package/dist/cjs/utils/formatTimeDiff.cjs +1 -20
  113. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  114. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -16
  115. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  116. package/dist/cjs/utils/getOutputFilePath.cjs +1 -74
  117. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  118. package/dist/cjs/utils/getParentPackageJSON.cjs +1 -20
  119. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  120. package/dist/cjs/utils/listSpecialChars.cjs +2 -54
  121. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  122. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +1 -102
  123. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  124. package/dist/cjs/utils/openBrowser.cjs +1 -19
  125. package/dist/cjs/utils/openBrowser.cjs.map +1 -1
  126. package/dist/cjs/utils/reorderParagraphs.cjs +3 -91
  127. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  128. package/dist/cjs/utils/setupAI.cjs +1 -64
  129. package/dist/cjs/utils/setupAI.cjs.map +1 -1
  130. package/dist/cjs/watch.cjs +1 -43
  131. package/dist/cjs/watch.cjs.map +1 -1
  132. package/dist/esm/IntlayerEventListener.mjs +1 -183
  133. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  134. package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
  135. package/dist/esm/_virtual/_utils_asset.mjs +2 -97
  136. package/dist/esm/auth/login.mjs +2 -82
  137. package/dist/esm/auth/login.mjs.map +1 -1
  138. package/dist/esm/build.mjs +1 -25
  139. package/dist/esm/build.mjs.map +1 -1
  140. package/dist/esm/ci.mjs +1 -71
  141. package/dist/esm/ci.mjs.map +1 -1
  142. package/dist/esm/cli.mjs +1 -473
  143. package/dist/esm/cli.mjs.map +1 -1
  144. package/dist/esm/config.mjs +1 -10
  145. package/dist/esm/config.mjs.map +1 -1
  146. package/dist/esm/editor.mjs +1 -49
  147. package/dist/esm/editor.mjs.map +1 -1
  148. package/dist/esm/extract.mjs +1 -93
  149. package/dist/esm/extract.mjs.map +1 -1
  150. package/dist/esm/fill/deepMergeContent.mjs +1 -25
  151. package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
  152. package/dist/esm/fill/fill.mjs +1 -76
  153. package/dist/esm/fill/fill.mjs.map +1 -1
  154. package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -27
  155. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  156. package/dist/esm/fill/formatFillData.mjs +1 -49
  157. package/dist/esm/fill/formatFillData.mjs.map +1 -1
  158. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +1 -24
  159. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
  160. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +1 -48
  161. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
  162. package/dist/esm/fill/index.mjs +1 -4
  163. package/dist/esm/fill/listTranslationsTasks.mjs +1 -68
  164. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  165. package/dist/esm/fill/mergeChunks.mjs +1 -26
  166. package/dist/esm/fill/mergeChunks.mjs.map +1 -1
  167. package/dist/esm/fill/translateDictionary.mjs +1 -203
  168. package/dist/esm/fill/translateDictionary.mjs.map +1 -1
  169. package/dist/esm/fill/writeFill.mjs +1 -52
  170. package/dist/esm/fill/writeFill.mjs.map +1 -1
  171. package/dist/esm/getTargetDictionary.mjs +1 -33
  172. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  173. package/dist/esm/index.mjs +1 -18
  174. package/dist/esm/init.mjs +1 -317
  175. package/dist/esm/init.mjs.map +1 -1
  176. package/dist/esm/listContentDeclaration.mjs +1 -38
  177. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  178. package/dist/esm/listProjects.mjs +1 -26
  179. package/dist/esm/listProjects.mjs.map +1 -1
  180. package/dist/esm/liveSync.mjs +8 -148
  181. package/dist/esm/liveSync.mjs.map +1 -1
  182. package/dist/esm/pull.mjs +1 -144
  183. package/dist/esm/pull.mjs.map +1 -1
  184. package/dist/esm/push/pullLog.mjs +3 -100
  185. package/dist/esm/push/pullLog.mjs.map +1 -1
  186. package/dist/esm/push/push.mjs +1 -203
  187. package/dist/esm/push/push.mjs.map +1 -1
  188. package/dist/esm/pushConfig.mjs +1 -17
  189. package/dist/esm/pushConfig.mjs.map +1 -1
  190. package/dist/esm/pushLog.mjs +3 -82
  191. package/dist/esm/pushLog.mjs.map +1 -1
  192. package/dist/esm/reviewDoc/reviewDoc.mjs +1 -65
  193. package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
  194. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +1 -92
  195. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
  196. package/dist/esm/searchDoc.mjs +1 -36
  197. package/dist/esm/searchDoc.mjs.map +1 -1
  198. package/dist/esm/test/index.mjs +1 -4
  199. package/dist/esm/test/listMissingTranslations.mjs +1 -46
  200. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  201. package/dist/esm/test/test.mjs +1 -49
  202. package/dist/esm/test/test.mjs.map +1 -1
  203. package/dist/esm/translateDoc/index.mjs +1 -5
  204. package/dist/esm/translateDoc/translateDoc.mjs +1 -71
  205. package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
  206. package/dist/esm/translateDoc/translateFile.mjs +2 -101
  207. package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
  208. package/dist/esm/translateDoc/validation.mjs +5 -46
  209. package/dist/esm/translateDoc/validation.mjs.map +1 -1
  210. package/dist/esm/translation-alignment/alignBlocks.mjs +1 -66
  211. package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
  212. package/dist/esm/translation-alignment/computeSimilarity.mjs +1 -22
  213. package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
  214. package/dist/esm/translation-alignment/fingerprintBlock.mjs +1 -20
  215. package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
  216. package/dist/esm/translation-alignment/index.mjs +1 -11
  217. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +1 -16
  218. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
  219. package/dist/esm/translation-alignment/normalizeBlock.mjs +1 -20
  220. package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
  221. package/dist/esm/translation-alignment/pipeline.mjs +1 -35
  222. package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
  223. package/dist/esm/translation-alignment/planActions.mjs +1 -44
  224. package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
  225. package/dist/esm/translation-alignment/rebuildDocument.mjs +2 -46
  226. package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
  227. package/dist/esm/translation-alignment/segmentDocument.mjs +5 -64
  228. package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
  229. package/dist/esm/utils/calculateChunks.mjs +2 -87
  230. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  231. package/dist/esm/utils/checkAccess.mjs +1 -78
  232. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  233. package/dist/esm/utils/checkConfigConsistency.mjs +1 -14
  234. package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
  235. package/dist/esm/utils/checkFileModifiedRange.mjs +1 -80
  236. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  237. package/dist/esm/utils/checkLastUpdateTime.mjs +1 -17
  238. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  239. package/dist/esm/utils/chunkInference.mjs +1 -43
  240. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  241. package/dist/esm/utils/fixChunkStartEndChars.mjs +3 -25
  242. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  243. package/dist/esm/utils/formatTimeDiff.mjs +1 -18
  244. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  245. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -14
  246. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  247. package/dist/esm/utils/getOutputFilePath.mjs +1 -72
  248. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  249. package/dist/esm/utils/getParentPackageJSON.mjs +1 -18
  250. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  251. package/dist/esm/utils/listSpecialChars.mjs +2 -52
  252. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  253. package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -100
  254. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  255. package/dist/esm/utils/openBrowser.mjs +1 -17
  256. package/dist/esm/utils/openBrowser.mjs.map +1 -1
  257. package/dist/esm/utils/reorderParagraphs.mjs +3 -90
  258. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  259. package/dist/esm/utils/setupAI.mjs +1 -62
  260. package/dist/esm/utils/setupAI.mjs.map +1 -1
  261. package/dist/esm/watch.mjs +1 -41
  262. package/dist/esm/watch.mjs.map +1 -1
  263. package/dist/types/auth/login.d.ts +1 -1
  264. package/dist/types/auth/login.d.ts.map +1 -1
  265. package/dist/types/build.d.ts +1 -1
  266. package/dist/types/build.d.ts.map +1 -1
  267. package/dist/types/config.d.ts +1 -1
  268. package/dist/types/extract.d.ts +1 -1
  269. package/dist/types/extract.d.ts.map +1 -1
  270. package/dist/types/fill/fill.d.ts +1 -1
  271. package/dist/types/fill/fill.d.ts.map +1 -1
  272. package/dist/types/fill/translateDictionary.d.ts +2 -2
  273. package/dist/types/fill/translateDictionary.d.ts.map +1 -1
  274. package/dist/types/fill/writeFill.d.ts.map +1 -1
  275. package/dist/types/getTargetDictionary.d.ts +2 -2
  276. package/dist/types/index.d.ts +4 -1
  277. package/dist/types/init.d.ts +1 -1
  278. package/dist/types/listContentDeclaration.d.ts +1 -1
  279. package/dist/types/listContentDeclaration.d.ts.map +1 -1
  280. package/dist/types/listProjects.d.ts +1 -1
  281. package/dist/types/listProjects.d.ts.map +1 -1
  282. package/dist/types/liveSync.d.ts +1 -1
  283. package/dist/types/pull.d.ts +1 -1
  284. package/dist/types/pull.d.ts.map +1 -1
  285. package/dist/types/push/pullLog.d.ts +1 -1
  286. package/dist/types/push/pullLog.d.ts.map +1 -1
  287. package/dist/types/push/push.d.ts +2 -2
  288. package/dist/types/pushConfig.d.ts +1 -1
  289. package/dist/types/reviewDoc/reviewDoc.d.ts +2 -2
  290. package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
  291. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
  292. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
  293. package/dist/types/searchDoc.d.ts +1 -1
  294. package/dist/types/searchDoc.d.ts.map +1 -1
  295. package/dist/types/test/listMissingTranslations.d.ts +1 -1
  296. package/dist/types/test/test.d.ts +1 -1
  297. package/dist/types/test/test.d.ts.map +1 -1
  298. package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
  299. package/dist/types/translateDoc/types.d.ts +2 -2
  300. package/dist/types/translateDoc/validation.d.ts +1 -1
  301. package/dist/types/utils/checkAccess.d.ts.map +1 -1
  302. package/dist/types/watch.d.ts +1 -1
  303. package/dist/types/watch.d.ts.map +1 -1
  304. package/package.json +13 -13
@@ -1,95 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require__utils_asset = require('../_virtual/_utils_asset.cjs');
4
- const require_translateDoc_validation = require('../translateDoc/validation.cjs');
5
- const require_translation_alignment_rebuildDocument = require('../translation-alignment/rebuildDocument.cjs');
6
- const require_translation_alignment_pipeline = require('../translation-alignment/pipeline.cjs');
7
- const require_utils_chunkInference = require('../utils/chunkInference.cjs');
8
- const require_utils_fixChunkStartEndChars = require('../utils/fixChunkStartEndChars.cjs');
9
- let _intlayer_chokidar = require("@intlayer/chokidar");
10
- let _intlayer_config = require("@intlayer/config");
11
- let node_path = require("node:path");
12
- let node_fs = require("node:fs");
13
- let node_fs_promises = require("node:fs/promises");
14
- let _intlayer_core = require("@intlayer/core");
15
- let _intlayer_types = require("@intlayer/types");
16
-
17
- //#region src/reviewDoc/reviewDocBlockAware.ts
18
- /**
19
- * Review a file using block-aware alignment.
20
- * This approach:
21
- * 1. Segments both English and French documents into semantic blocks
22
- * 2. Aligns blocks using structure (special chars, numbers) and context
23
- * 3. Detects which blocks changed, were added, or deleted
24
- * 4. Only sends changed/new blocks to AI for translation
25
- * 5. Handles reordering automatically
26
- */
27
- const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLocale, aiOptions, configOptions, customInstructions, changedLines, aiClient, aiConfig) => {
28
- const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
29
- const applicationLogger = (0, _intlayer_config.getAppLogger)(configuration);
30
- const englishText = await (0, node_fs_promises.readFile)(baseFilePath, "utf-8");
31
- const frenchText = await (0, node_fs_promises.readFile)(outputFilePath, "utf-8").catch(() => "");
32
- const basePrompt = require__utils_asset.readAsset("./prompts/REVIEW_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_chokidar.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
33
- const filePrefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
34
- const prefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}][${(0, _intlayer_chokidar.formatLocale)(locale)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
35
- const { englishBlocks, frenchBlocks, plan, segmentsToReview } = require_translation_alignment_pipeline.buildAlignmentPlan({
36
- englishText,
37
- frenchText,
38
- changedLines
39
- });
40
- applicationLogger(`${filePrefix}Block-aware alignment complete. Total blocks: EN=${(0, _intlayer_config.colorizeNumber)(englishBlocks.length)}, FR=${(0, _intlayer_config.colorizeNumber)(frenchBlocks.length)}`);
41
- applicationLogger(`${filePrefix}Actions: reuse=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "reuse").length)}, review=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "review").length)}, new=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "insert_new").length)}, delete=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "delete").length)}`);
42
- if (segmentsToReview.length === 0) {
43
- applicationLogger(`${filePrefix}No segments need review, reusing existing translation`);
44
- (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
45
- (0, node_fs.writeFileSync)(outputFilePath, require_translation_alignment_rebuildDocument.mergeReviewedSegments(plan, frenchBlocks, /* @__PURE__ */ new Map()));
46
- applicationLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(outputFilePath)} updated successfully (no changes needed).`);
47
- return;
48
- }
49
- applicationLogger(`${filePrefix}Segments to review: ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
50
- const reviewedSegmentsMap = /* @__PURE__ */ new Map();
51
- for (const segment of segmentsToReview) {
52
- const segmentNumber = segmentsToReview.indexOf(segment) + 1;
53
- const englishBlock = segment.englishBlock;
54
- const getBaseChunkContextPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///\n` + englishBlock.content + `///chunksEnd///`;
55
- const getFrenchChunkPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${(0, _intlayer_chokidar.formatLocale)(locale, false)}.\n///chunksStart///\n` + (segment.frenchBlockText ?? "") + `///chunksEnd///`;
56
- const reviewedChunkResult = await (0, _intlayer_config.retryManager)(async () => {
57
- const result = await require_utils_chunkInference.chunkInference([
58
- {
59
- role: "system",
60
- content: basePrompt
61
- },
62
- {
63
- role: "system",
64
- content: getBaseChunkContextPrompt()
65
- },
66
- {
67
- role: "system",
68
- content: getFrenchChunkPrompt()
69
- },
70
- {
71
- role: "system",
72
- content: `The next user message will be the **BLOCK ${(0, _intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}** that should be translated in ${(0, _intlayer_core.getLocaleName)(locale, _intlayer_types.Locales.ENGLISH)} (${locale}).`
73
- },
74
- {
75
- role: "user",
76
- content: englishBlock.content
77
- }
78
- ], aiOptions, configuration, aiClient, aiConfig);
79
- applicationLogger(`${prefix}${(0, _intlayer_config.colorizeNumber)(result.tokenUsed)} tokens used - Block ${(0, _intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
80
- let processedChunk = require_translateDoc_validation.sanitizeChunk(result?.fileContent, englishBlock.content);
81
- processedChunk = require_utils_fixChunkStartEndChars.fixChunkStartEndChars(processedChunk, englishBlock.content);
82
- if (!require_translateDoc_validation.validateTranslation(englishBlock.content, processedChunk, applicationLogger)) throw new Error("Validation failed for chunk (structure or length mismatch). Retrying...");
83
- return processedChunk;
84
- })();
85
- reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);
86
- }
87
- const finalFrenchOutput = require_translation_alignment_rebuildDocument.mergeReviewedSegments(plan, frenchBlocks, reviewedSegmentsMap);
88
- (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
89
- (0, node_fs.writeFileSync)(outputFilePath, finalFrenchOutput);
90
- applicationLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(outputFilePath)} created/updated successfully.`);
91
- };
92
-
93
- //#endregion
94
- exports.reviewFileBlockAware = reviewFileBlockAware;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_utils_asset.cjs`),t=require(`../translateDoc/validation.cjs`),n=require(`../translation-alignment/rebuildDocument.cjs`),r=require(`../translation-alignment/pipeline.cjs`),i=require(`../utils/chunkInference.cjs`),a=require(`../utils/fixChunkStartEndChars.cjs`);let o=require(`@intlayer/chokidar/utils`),s=require(`@intlayer/config/node`),c=require(`node:path`),l=require(`@intlayer/config/logger`),u=require(`@intlayer/config/utils`),d=require(`node:fs`),f=require(`node:fs/promises`),p=require(`@intlayer/core/localization`),m=require(`@intlayer/types`);const h=async(h,g,_,v,y,b,x,S,C,w)=>{let T=(0,s.getConfiguration)(b),E=(0,l.getAppLogger)(T),D=await(0,f.readFile)(h,`utf-8`),O=await(0,f.readFile)(g,`utf-8`).catch(()=>``),k=e.readAsset(`./prompts/REVIEW_PROMPT.md`,`utf-8`).replaceAll(`{{localeName}}`,`${(0,o.formatLocale)(_,!1)}`).replaceAll(`{{baseLocaleName}}`,`${(0,o.formatLocale)(v,!1)}`).replace(`{{applicationContext}}`,y?.applicationContext??`-`).replace(`{{customInstructions}}`,x??`-`),A=[(0,l.colon)(`${l.ANSIColors.GREY_DARK}[${(0,o.formatPath)(h)}${l.ANSIColors.GREY_DARK}] `,{colSize:40}),`→ ${l.ANSIColors.RESET}`].join(``),j=[(0,l.colon)(`${l.ANSIColors.GREY_DARK}[${(0,o.formatPath)(h)}${l.ANSIColors.GREY_DARK}][${(0,o.formatLocale)(_)}${l.ANSIColors.GREY_DARK}] `,{colSize:40}),`→ ${l.ANSIColors.RESET}`].join(``),{englishBlocks:M,frenchBlocks:N,plan:P,segmentsToReview:F}=r.buildAlignmentPlan({englishText:D,frenchText:O,changedLines:S});if(E(`${A}Block-aware alignment complete. Total blocks: EN=${(0,l.colorizeNumber)(M.length)}, FR=${(0,l.colorizeNumber)(N.length)}`),E(`${A}Actions: reuse=${(0,l.colorizeNumber)(P.actions.filter(e=>e.kind===`reuse`).length)}, review=${(0,l.colorizeNumber)(P.actions.filter(e=>e.kind===`review`).length)}, new=${(0,l.colorizeNumber)(P.actions.filter(e=>e.kind===`insert_new`).length)}, delete=${(0,l.colorizeNumber)(P.actions.filter(e=>e.kind===`delete`).length)}`),F.length===0){E(`${A}No segments need review, reusing existing translation`),(0,d.mkdirSync)((0,c.dirname)(g),{recursive:!0}),(0,d.writeFileSync)(g,n.mergeReviewedSegments(P,N,new Map)),E(`${(0,l.colorize)(`✔`,l.ANSIColors.GREEN)} File ${(0,o.formatPath)(g)} updated successfully (no changes needed).`);return}E(`${A}Segments to review: ${(0,l.colorizeNumber)(F.length)}`);let I=new Map;for(let e of F){let n=F.indexOf(e)+1,r=e.englishBlock,s=()=>`**BLOCK ${n} of ${F.length}** is the base block in ${(0,o.formatLocale)(v,!1)} as reference.\n///chunksStart///\n`+r.content+`///chunksEnd///`,c=()=>`**BLOCK ${n} of ${F.length}** is the current block to review in ${(0,o.formatLocale)(_,!1)}.\n///chunksStart///\n`+(e.frenchBlockText??``)+`///chunksEnd///`,d=await(0,u.retryManager)(async()=>{let e=await i.chunkInference([{role:`system`,content:k},{role:`system`,content:s()},{role:`system`,content:c()},{role:`system`,content:`The next user message will be the **BLOCK ${(0,l.colorizeNumber)(n)} of ${(0,l.colorizeNumber)(F.length)}** that should be translated in ${(0,p.getLocaleName)(_,m.Locales.ENGLISH)} (${_}).`},{role:`user`,content:r.content}],y,T,C,w);E(`${j}${(0,l.colorizeNumber)(e.tokenUsed)} tokens used - Block ${(0,l.colorizeNumber)(n)} of ${(0,l.colorizeNumber)(F.length)}`);let o=t.sanitizeChunk(e?.fileContent,r.content);if(o=a.fixChunkStartEndChars(o,r.content),!t.validateTranslation(r.content,o,E))throw Error(`Validation failed for chunk (structure or length mismatch). Retrying...`);return o})();I.set(e.actionIndex,d)}let L=n.mergeReviewedSegments(P,N,I);(0,d.mkdirSync)((0,c.dirname)(g),{recursive:!0}),(0,d.writeFileSync)(g,L),E(`${(0,l.colorize)(`✔`,l.ANSIColors.GREEN)} File ${(0,o.formatPath)(g)} created/updated successfully.`)};exports.reviewFileBlockAware=h;
95
2
  //# sourceMappingURL=reviewDocBlockAware.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"reviewDocBlockAware.cjs","names":["readAsset","ANSIColors","buildAlignmentPlan","mergeReviewedSegments","chunkInference","Locales","sanitizeChunk","fixChunkStartEndChars","validateTranslation"],"sources":["../../../src/reviewDoc/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { sanitizeChunk, validateTranslation } from '../translateDoc/validation';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from '../translation-alignment/pipeline';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { AIClient } from '../utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Sanitize artifacts (e.g. Markdown code block wrappers)\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n englishBlock.content\n );\n\n // Fix start/end characters\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n englishBlock.content\n );\n\n // Validate Translation (YAML, Code fences, Length ratio)\n const isValid = validateTranslation(\n englishBlock.content,\n processedChunk,\n applicationLogger\n );\n\n if (!isValid) {\n throw new Error(\n 'Validation failed for chunk (structure or length mismatch). Retrying...'\n );\n }\n\n return processedChunk;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔',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,CAAC,2CAAqB,iBAAiB,OAAO,GAChJ;GAGD,IAAI,iBAAiBC,8CACnB,QAAQ,aACR,aAAa,QACd;AAGD,oBAAiBC,0DACf,gBACA,aAAa,QACd;AASD,OAAI,CANYC,oDACd,aAAa,SACb,gBACA,kBACD,CAGC,OAAM,IAAI,MACR,0EACD;AAGH,UAAO;IACP,EAAE;AAEJ,sBAAoB,IAAI,QAAQ,aAAa,oBAAoB;;CAInE,MAAM,oBAAoBL,oEACxB,MACA,cACA,oBACD;AAED,+CAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,4BAAc,gBAAgB,kBAAkB;AAEhD,mBACE,kCAAY,KAAKF,4BAAW,MAAM,CAAC,2CAAmB,eAAe,CAAC,gCACvE"}
1
+ {"version":3,"file":"reviewDocBlockAware.cjs","names":["readAsset","ANSIColors","buildAlignmentPlan","mergeReviewedSegments","chunkInference","Locales","sanitizeChunk","fixChunkStartEndChars","validateTranslation"],"sources":["../../../src/reviewDoc/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { retryManager } from '@intlayer/config/utils';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { sanitizeChunk, validateTranslation } from '../translateDoc/validation';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from '../translation-alignment/pipeline';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { AIClient } from '../utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Sanitize artifacts (e.g. Markdown code block wrappers)\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n englishBlock.content\n );\n\n // Fix start/end characters\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n englishBlock.content\n );\n\n // Validate Translation (YAML, Code fences, Length ratio)\n const isValid = validateTranslation(\n englishBlock.content,\n processedChunk,\n applicationLogger\n );\n\n if (!isValid) {\n throw new Error(\n 'Validation failed for chunk (structure or length mismatch). Retrying...'\n );\n }\n\n return processedChunk;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} created/updated successfully.`\n );\n};\n"],"mappings":"wrBAuCA,MAAa,EAAuB,MAClC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,IACG,CACH,IAAM,GAAA,EAAA,EAAA,kBAAiC,EAAc,CAC/C,GAAA,EAAA,EAAA,cAAiC,EAAc,CAE/C,EAAc,MAAA,EAAA,EAAA,UAAe,EAAc,QAAQ,CACnD,EAAa,MAAA,EAAA,EAAA,UAAe,EAAgB,QAAQ,CAAC,UAAY,GAAG,CAEpE,EAAaA,EAAAA,UAAU,6BAA8B,QAAQ,CAChE,WAAW,iBAAkB,IAAA,EAAA,EAAA,cAAgB,EAAQ,GAAM,GAAG,CAC9D,WAAW,qBAAsB,IAAA,EAAA,EAAA,cAAgB,EAAY,GAAM,GAAG,CACtE,QAAQ,yBAA0B,GAAW,oBA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I,EAAiBC,EAAAA,cACnB,GAAQ,YACR,EAAa,QACd,CAeD,GAZA,EAAiBC,EAAAA,sBACf,EACA,EAAa,QACd,CASG,CANYC,EAAAA,oBACd,EAAa,QACb,EACA,EACD,CAGC,MAAU,MACR,0EACD,CAGH,OAAO,GACP,EAAE,CAEJ,EAAoB,IAAI,EAAQ,YAAa,EAAoB,CAInE,IAAM,EAAoBL,EAAAA,sBACxB,EACA,EACA,EACD,EAED,EAAA,EAAA,YAAA,EAAA,EAAA,SAAkB,EAAe,CAAE,CAAE,UAAW,GAAM,CAAC,EACvD,EAAA,EAAA,eAAc,EAAgB,EAAkB,CAEhD,EACE,IAAA,EAAA,EAAA,UAAY,IAAKF,EAAAA,WAAW,MAAM,CAAC,SAAA,EAAA,EAAA,YAAmB,EAAe,CAAC,gCACvE"}
@@ -1,39 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_api = require("@intlayer/api");
4
- let _intlayer_config = require("@intlayer/config");
5
-
6
- //#region src/searchDoc.ts
7
- const searchDoc = async ({ query, limit = 10, configOptions }) => {
8
- const config = (0, _intlayer_config.getConfiguration)(configOptions);
9
- const appLogger = (0, _intlayer_config.getAppLogger)(config);
10
- try {
11
- const { searchDoc } = (0, _intlayer_api.getSearchAPI)(void 0, config);
12
- const response = await searchDoc({
13
- input: query,
14
- limit: limit.toString(),
15
- returnContent: "true"
16
- });
17
- if (!response.data || !Array.isArray(response.data)) {
18
- appLogger("No relevant chunks found.");
19
- return;
20
- }
21
- const chunks = response.data;
22
- appLogger(`Found ${(0, _intlayer_config.colorizeNumber)(chunks.length)} relevant chunks:`);
23
- chunks.forEach((chunk) => {
24
- appLogger("---");
25
- appLogger(`${(0, _intlayer_config.colorizeKey)("File")}: ${chunk.fileKey}`);
26
- appLogger(`${(0, _intlayer_config.colorizeKey)("Title")}: ${chunk.docName}`);
27
- appLogger(`${(0, _intlayer_config.colorizeKey)("URL")}: ${chunk.docUrl}`);
28
- appLogger(`${(0, _intlayer_config.colorizeKey)("Chunk")}: ${chunk.chunkNumber}`);
29
- appLogger(`${(0, _intlayer_config.colorizeKey)("Content")}:`);
30
- appLogger(chunk.content);
31
- });
32
- } catch (error) {
33
- appLogger(`Search failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`, { level: "error" });
34
- }
35
- };
36
-
37
- //#endregion
38
- exports.searchDoc = searchDoc;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/api`),t=require(`@intlayer/config/node`),n=require(`@intlayer/config/logger`);const r=async({query:r,limit:i=10,configOptions:a})=>{let o=(0,t.getConfiguration)(a),s=(0,n.getAppLogger)(o);try{let{searchDoc:t}=(0,e.getSearchAPI)(void 0,o),a=await t({input:r,limit:i.toString(),returnContent:`true`});if(!a.data||!Array.isArray(a.data)){s(`No relevant chunks found.`);return}let c=a.data;s(`Found ${(0,n.colorizeNumber)(c.length)} relevant chunks:`),c.forEach(e=>{s(`---`),s(`${(0,n.colorizeKey)(`File`)}: ${e.fileKey}`),s(`${(0,n.colorizeKey)(`Title`)}: ${e.docName}`),s(`${(0,n.colorizeKey)(`URL`)}: ${e.docUrl}`),s(`${(0,n.colorizeKey)(`Chunk`)}: ${e.chunkNumber}`),s(`${(0,n.colorizeKey)(`Content`)}:`),s(e.content)})}catch(e){s(`Search failed: ${e instanceof Error?e.message:`An unknown error occurred`}`,{level:`error`})}};exports.searchDoc=r;
39
2
  //# sourceMappingURL=searchDoc.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchDoc.cjs","names":[],"sources":["../../src/searchDoc.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport {\n colorizeKey,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\n\ninterface SearchDocOptions {\n query: string;\n limit?: number;\n configOptions?: GetConfigurationOptions;\n}\n\nexport const searchDoc = async ({\n query,\n limit = 10,\n configOptions,\n}: SearchDocOptions) => {\n const config = getConfiguration(configOptions);\n const appLogger = getAppLogger(config);\n\n try {\n const { searchDoc } = getSearchAPI(undefined, config);\n const response = await searchDoc({\n input: query,\n limit: limit.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n appLogger('No relevant chunks found.');\n return;\n }\n\n const chunks = response.data;\n\n appLogger(`Found ${colorizeNumber(chunks.length)} relevant chunks:`);\n\n chunks.forEach((chunk: any) => {\n appLogger('---');\n appLogger(`${colorizeKey('File')}: ${chunk.fileKey}`);\n appLogger(`${colorizeKey('Title')}: ${chunk.docName}`);\n appLogger(`${colorizeKey('URL')}: ${chunk.docUrl}`);\n appLogger(`${colorizeKey('Chunk')}: ${chunk.chunkNumber}`);\n appLogger(`${colorizeKey('Content')}:`);\n appLogger(chunk.content);\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n appLogger(`Search failed: ${errorMessage}`, { level: 'error' });\n }\n};\n"],"mappings":";;;;;;AAeA,MAAa,YAAY,OAAO,EAC9B,OACA,QAAQ,IACR,oBACsB;CACtB,MAAM,gDAA0B,cAAc;CAC9C,MAAM,+CAAyB,OAAO;AAEtC,KAAI;EACF,MAAM,EAAE,8CAA2B,QAAW,OAAO;EACrD,MAAM,WAAW,MAAM,UAAU;GAC/B,OAAO;GACP,OAAO,MAAM,UAAU;GACvB,eAAe;GAChB,CAAC;AAEF,MAAI,CAAC,SAAS,QAAQ,CAAC,MAAM,QAAQ,SAAS,KAAK,EAAE;AACnD,aAAU,4BAA4B;AACtC;;EAGF,MAAM,SAAS,SAAS;AAExB,YAAU,8CAAwB,OAAO,OAAO,CAAC,mBAAmB;AAEpE,SAAO,SAAS,UAAe;AAC7B,aAAU,MAAM;AAChB,aAAU,qCAAe,OAAO,CAAC,IAAI,MAAM,UAAU;AACrD,aAAU,qCAAe,QAAQ,CAAC,IAAI,MAAM,UAAU;AACtD,aAAU,qCAAe,MAAM,CAAC,IAAI,MAAM,SAAS;AACnD,aAAU,qCAAe,QAAQ,CAAC,IAAI,MAAM,cAAc;AAC1D,aAAU,qCAAe,UAAU,CAAC,GAAG;AACvC,aAAU,MAAM,QAAQ;IACxB;UACK,OAAO;AAGd,YAAU,kBADR,iBAAiB,QAAQ,MAAM,UAAU,+BACC,EAAE,OAAO,SAAS,CAAC"}
1
+ {"version":3,"file":"searchDoc.cjs","names":[],"sources":["../../src/searchDoc.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport {\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ninterface SearchDocOptions {\n query: string;\n limit?: number;\n configOptions?: GetConfigurationOptions;\n}\n\nexport const searchDoc = async ({\n query,\n limit = 10,\n configOptions,\n}: SearchDocOptions) => {\n const config = getConfiguration(configOptions);\n const appLogger = getAppLogger(config);\n\n try {\n const { searchDoc } = getSearchAPI(undefined, config);\n const response = await searchDoc({\n input: query,\n limit: limit.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n appLogger('No relevant chunks found.');\n return;\n }\n\n const chunks = response.data;\n\n appLogger(`Found ${colorizeNumber(chunks.length)} relevant chunks:`);\n\n chunks.forEach((chunk: any) => {\n appLogger('---');\n appLogger(`${colorizeKey('File')}: ${chunk.fileKey}`);\n appLogger(`${colorizeKey('Title')}: ${chunk.docName}`);\n appLogger(`${colorizeKey('URL')}: ${chunk.docUrl}`);\n appLogger(`${colorizeKey('Chunk')}: ${chunk.chunkNumber}`);\n appLogger(`${colorizeKey('Content')}:`);\n appLogger(chunk.content);\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n appLogger(`Search failed: ${errorMessage}`, { level: 'error' });\n }\n};\n"],"mappings":"sNAiBA,MAAa,EAAY,MAAO,CAC9B,QACA,QAAQ,GACR,mBACsB,CACtB,IAAM,GAAA,EAAA,EAAA,kBAA0B,EAAc,CACxC,GAAA,EAAA,EAAA,cAAyB,EAAO,CAEtC,GAAI,CACF,GAAM,CAAE,cAAA,EAAA,EAAA,cAA2B,IAAA,GAAW,EAAO,CAC/C,EAAW,MAAM,EAAU,CAC/B,MAAO,EACP,MAAO,EAAM,UAAU,CACvB,cAAe,OAChB,CAAC,CAEF,GAAI,CAAC,EAAS,MAAQ,CAAC,MAAM,QAAQ,EAAS,KAAK,CAAE,CACnD,EAAU,4BAA4B,CACtC,OAGF,IAAM,EAAS,EAAS,KAExB,EAAU,UAAA,EAAA,EAAA,gBAAwB,EAAO,OAAO,CAAC,mBAAmB,CAEpE,EAAO,QAAS,GAAe,CAC7B,EAAU,MAAM,CAChB,EAAU,IAAA,EAAA,EAAA,aAAe,OAAO,CAAC,IAAI,EAAM,UAAU,CACrD,EAAU,IAAA,EAAA,EAAA,aAAe,QAAQ,CAAC,IAAI,EAAM,UAAU,CACtD,EAAU,IAAA,EAAA,EAAA,aAAe,MAAM,CAAC,IAAI,EAAM,SAAS,CACnD,EAAU,IAAA,EAAA,EAAA,aAAe,QAAQ,CAAC,IAAI,EAAM,cAAc,CAC1D,EAAU,IAAA,EAAA,EAAA,aAAe,UAAU,CAAC,GAAG,CACvC,EAAU,EAAM,QAAQ,EACxB,OACK,EAAO,CAGd,EAAU,kBADR,aAAiB,MAAQ,EAAM,QAAU,8BACC,CAAE,MAAO,QAAS,CAAC"}
@@ -1,7 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_test_listMissingTranslations = require('./listMissingTranslations.cjs');
3
- const require_test_test = require('./test.cjs');
4
-
5
- exports.listMissingTranslations = require_test_listMissingTranslations.listMissingTranslations;
6
- exports.listMissingTranslationsWithConfig = require_test_listMissingTranslations.listMissingTranslationsWithConfig;
7
- exports.testMissingTranslations = require_test_test.testMissingTranslations;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./listMissingTranslations.cjs`),t=require(`./test.cjs`);exports.listMissingTranslations=e.listMissingTranslations,exports.listMissingTranslationsWithConfig=e.listMissingTranslationsWithConfig,exports.testMissingTranslations=t.testMissingTranslations;
@@ -1,50 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_config = require("@intlayer/config");
4
- let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
5
- let _intlayer_core = require("@intlayer/core");
6
- let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
7
-
8
- //#region src/test/listMissingTranslations.ts
9
- const listMissingTranslationsWithConfig = (configuration) => {
10
- const unmergedDictionariesRecord = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
11
- const mergedDictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
12
- const missingTranslations = [];
13
- const { locales, requiredLocales } = configuration.internationalization;
14
- const dictionariesKeys = Object.keys(unmergedDictionariesRecord);
15
- for (const dictionaryKey of dictionariesKeys) {
16
- const dictionaries = unmergedDictionariesRecord[dictionaryKey];
17
- const multilingualDictionary = dictionaries.filter((dictionary) => !dictionary.locale);
18
- for (const dictionary of multilingualDictionary) {
19
- const missingLocales = (0, _intlayer_core.getMissingLocalesContentFromDictionary)(dictionary, locales);
20
- if (missingLocales.length > 0) missingTranslations.push({
21
- key: dictionaryKey,
22
- id: dictionary.id,
23
- filePath: dictionary.filePath,
24
- locales: missingLocales
25
- });
26
- }
27
- if (dictionaries.filter((dictionary) => dictionary.locale).length === 0) continue;
28
- const mergedDictionary = mergedDictionaries[dictionaryKey];
29
- const missingLocales = (0, _intlayer_core.getMissingLocalesContentFromDictionary)(mergedDictionary, locales);
30
- if (missingLocales.length > 0) missingTranslations.push({
31
- key: dictionaryKey,
32
- locales: missingLocales
33
- });
34
- }
35
- const missingLocalesSet = new Set(missingTranslations.flatMap((t) => t.locales));
36
- const missingLocales = Array.from(missingLocalesSet);
37
- return {
38
- missingTranslations,
39
- missingLocales,
40
- missingRequiredLocales: missingLocales.filter((locale) => (requiredLocales ?? locales).includes(locale))
41
- };
42
- };
43
- const listMissingTranslations = (configurationOptions) => {
44
- return listMissingTranslationsWithConfig((0, _intlayer_config.getConfiguration)(configurationOptions));
45
- };
46
-
47
- //#endregion
48
- exports.listMissingTranslations = listMissingTranslations;
49
- exports.listMissingTranslationsWithConfig = listMissingTranslationsWithConfig;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/config/node`),t=require(`@intlayer/unmerged-dictionaries-entry`),n=require(`@intlayer/core/plugins`),r=require(`@intlayer/dictionaries-entry`);const i=e=>{let i=(0,t.getUnmergedDictionaries)(e),a=(0,r.getDictionaries)(e),o=[],{locales:s,requiredLocales:c}=e.internationalization,l=Object.keys(i);for(let e of l){let t=i[e],r=t.filter(e=>!e.locale);for(let t of r){let r=(0,n.getMissingLocalesContentFromDictionary)(t,s);r.length>0&&o.push({key:e,id:t.id,filePath:t.filePath,locales:r})}if(t.filter(e=>e.locale).length===0)continue;let c=a[e],l=(0,n.getMissingLocalesContentFromDictionary)(c,s);l.length>0&&o.push({key:e,locales:l})}let u=new Set(o.flatMap(e=>e.locales)),d=Array.from(u);return{missingTranslations:o,missingLocales:d,missingRequiredLocales:d.filter(e=>(c??s).includes(e))}},a=t=>i((0,e.getConfiguration)(t));exports.listMissingTranslations=a,exports.listMissingTranslationsWithConfig=i;
50
2
  //# sourceMappingURL=listMissingTranslations.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listMissingTranslations.cjs","names":[],"sources":["../../../src/test/listMissingTranslations.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config';\nimport { getMissingLocalesContentFromDictionary } from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const listMissingTranslationsWithConfig = (\n configuration: IntlayerConfig\n) => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const mergedDictionaries = getDictionaries(configuration);\n\n const missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[] = [];\n\n const { locales, requiredLocales } = configuration.internationalization;\n\n const dictionariesKeys = Object.keys(unmergedDictionariesRecord);\n\n for (const dictionaryKey of dictionariesKeys) {\n const dictionaries: Dictionary[] =\n unmergedDictionariesRecord[dictionaryKey];\n\n const multilingualDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => !dictionary.locale\n );\n\n // Test all by merging all dictionaries to ensure no per-locale dictionary is missing\n for (const dictionary of multilingualDictionary) {\n const missingLocales = getMissingLocalesContentFromDictionary(\n dictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n id: dictionary.id,\n filePath: dictionary.filePath,\n locales: missingLocales,\n });\n }\n }\n\n const perLocaleDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => dictionary.locale\n );\n\n if (perLocaleDictionary.length === 0) {\n continue;\n }\n\n const mergedDictionary = mergedDictionaries[dictionaryKey];\n\n const missingLocales = getMissingLocalesContentFromDictionary(\n mergedDictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n locales: missingLocales,\n });\n }\n }\n\n const missingLocalesSet = new Set(\n missingTranslations.flatMap((t) => t.locales)\n );\n const missingLocales = Array.from(missingLocalesSet);\n\n const missingRequiredLocales = missingLocales.filter((locale) =>\n (requiredLocales ?? locales).includes(locale)\n );\n\n return { missingTranslations, missingLocales, missingRequiredLocales };\n};\n\nexport const listMissingTranslations = (\n configurationOptions?: GetConfigurationOptions\n) => {\n const configuration = getConfiguration(configurationOptions);\n\n return listMissingTranslationsWithConfig(configuration);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,qCACX,kBACG;CACH,MAAM,gGAAqD,cAAc;CACzE,MAAM,uEAAqC,cAAc;CAEzD,MAAM,sBAKA,EAAE;CAER,MAAM,EAAE,SAAS,oBAAoB,cAAc;CAEnD,MAAM,mBAAmB,OAAO,KAAK,2BAA2B;AAEhE,MAAK,MAAM,iBAAiB,kBAAkB;EAC5C,MAAM,eACJ,2BAA2B;EAE7B,MAAM,yBAAuC,aAAa,QACvD,eAAe,CAAC,WAAW,OAC7B;AAGD,OAAK,MAAM,cAAc,wBAAwB;GAC/C,MAAM,4EACJ,YACA,QACD;AAED,OAAI,eAAe,SAAS,EAC1B,qBAAoB,KAAK;IACvB,KAAK;IACL,IAAI,WAAW;IACf,UAAU,WAAW;IACrB,SAAS;IACV,CAAC;;AAQN,MAJ0C,aAAa,QACpD,eAAe,WAAW,OAC5B,CAEuB,WAAW,EACjC;EAGF,MAAM,mBAAmB,mBAAmB;EAE5C,MAAM,4EACJ,kBACA,QACD;AAED,MAAI,eAAe,SAAS,EAC1B,qBAAoB,KAAK;GACvB,KAAK;GACL,SAAS;GACV,CAAC;;CAIN,MAAM,oBAAoB,IAAI,IAC5B,oBAAoB,SAAS,MAAM,EAAE,QAAQ,CAC9C;CACD,MAAM,iBAAiB,MAAM,KAAK,kBAAkB;AAMpD,QAAO;EAAE;EAAqB;EAAgB,wBAJf,eAAe,QAAQ,YACnD,mBAAmB,SAAS,SAAS,OAAO,CAC9C;EAEqE;;AAGxE,MAAa,2BACX,yBACG;AAGH,QAAO,yEAFgC,qBAAqB,CAEL"}
1
+ {"version":3,"file":"listMissingTranslations.cjs","names":[],"sources":["../../../src/test/listMissingTranslations.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getMissingLocalesContentFromDictionary } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const listMissingTranslationsWithConfig = (\n configuration: IntlayerConfig\n) => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const mergedDictionaries = getDictionaries(configuration);\n\n const missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[] = [];\n\n const { locales, requiredLocales } = configuration.internationalization;\n\n const dictionariesKeys = Object.keys(unmergedDictionariesRecord);\n\n for (const dictionaryKey of dictionariesKeys) {\n const dictionaries: Dictionary[] =\n unmergedDictionariesRecord[dictionaryKey];\n\n const multilingualDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => !dictionary.locale\n );\n\n // Test all by merging all dictionaries to ensure no per-locale dictionary is missing\n for (const dictionary of multilingualDictionary) {\n const missingLocales = getMissingLocalesContentFromDictionary(\n dictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n id: dictionary.id,\n filePath: dictionary.filePath,\n locales: missingLocales,\n });\n }\n }\n\n const perLocaleDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => dictionary.locale\n );\n\n if (perLocaleDictionary.length === 0) {\n continue;\n }\n\n const mergedDictionary = mergedDictionaries[dictionaryKey];\n\n const missingLocales = getMissingLocalesContentFromDictionary(\n mergedDictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n locales: missingLocales,\n });\n }\n }\n\n const missingLocalesSet = new Set(\n missingTranslations.flatMap((t) => t.locales)\n );\n const missingLocales = Array.from(missingLocalesSet);\n\n const missingRequiredLocales = missingLocales.filter((locale) =>\n (requiredLocales ?? locales).includes(locale)\n );\n\n return { missingTranslations, missingLocales, missingRequiredLocales };\n};\n\nexport const listMissingTranslations = (\n configurationOptions?: GetConfigurationOptions\n) => {\n const configuration = getConfiguration(configurationOptions);\n\n return listMissingTranslationsWithConfig(configuration);\n};\n"],"mappings":"wRASA,MAAa,EACX,GACG,CACH,IAAM,GAAA,EAAA,EAAA,yBAAqD,EAAc,CACnE,GAAA,EAAA,EAAA,iBAAqC,EAAc,CAEnD,EAKA,EAAE,CAEF,CAAE,UAAS,mBAAoB,EAAc,qBAE7C,EAAmB,OAAO,KAAK,EAA2B,CAEhE,IAAK,IAAM,KAAiB,EAAkB,CAC5C,IAAM,EACJ,EAA2B,GAEvB,EAAuC,EAAa,OACvD,GAAe,CAAC,EAAW,OAC7B,CAGD,IAAK,IAAM,KAAc,EAAwB,CAC/C,IAAM,GAAA,EAAA,EAAA,wCACJ,EACA,EACD,CAEG,EAAe,OAAS,GAC1B,EAAoB,KAAK,CACvB,IAAK,EACL,GAAI,EAAW,GACf,SAAU,EAAW,SACrB,QAAS,EACV,CAAC,CAQN,GAJ0C,EAAa,OACpD,GAAe,EAAW,OAC5B,CAEuB,SAAW,EACjC,SAGF,IAAM,EAAmB,EAAmB,GAEtC,GAAA,EAAA,EAAA,wCACJ,EACA,EACD,CAEG,EAAe,OAAS,GAC1B,EAAoB,KAAK,CACvB,IAAK,EACL,QAAS,EACV,CAAC,CAIN,IAAM,EAAoB,IAAI,IAC5B,EAAoB,QAAS,GAAM,EAAE,QAAQ,CAC9C,CACK,EAAiB,MAAM,KAAK,EAAkB,CAMpD,MAAO,CAAE,sBAAqB,iBAAgB,uBAJf,EAAe,OAAQ,IACnD,GAAmB,GAAS,SAAS,EAAO,CAC9C,CAEqE,EAG3D,EACX,GAIO,GAAA,EAAA,EAAA,kBAFgC,EAAqB,CAEL"}
@@ -1,52 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_test_listMissingTranslations = require('./listMissingTranslations.cjs');
4
- let _intlayer_chokidar = require("@intlayer/chokidar");
5
- let _intlayer_config = require("@intlayer/config");
6
-
7
- //#region src/test/test.ts
8
- const testMissingTranslations = async (options) => {
9
- const config = (0, _intlayer_config.getConfiguration)(options?.configOptions);
10
- const { locales, requiredLocales } = config.internationalization;
11
- const appLogger = (0, _intlayer_config.getAppLogger)(config);
12
- if (options?.build === true) await (0, _intlayer_chokidar.prepareIntlayer)(config, { forceRun: true });
13
- else if (typeof options?.build === "undefined") await (0, _intlayer_chokidar.prepareIntlayer)(config);
14
- const result = require_test_listMissingTranslations.listMissingTranslations(options?.configOptions);
15
- const maxKeyColSize = result.missingTranslations.map((t) => ` - ${t.key}`).reduce((max, t) => Math.max(max, t.length), 0);
16
- const maxLocalesColSize = result.missingTranslations.map((t) => (0, _intlayer_chokidar.formatLocale)(t.locales, false)).reduce((max, t) => Math.max(max, t.length), 0);
17
- const formattedMissingTranslations = result.missingTranslations.map((translation) => [
18
- (0, _intlayer_config.colon)(` - ${(0, _intlayer_config.colorizeKey)(translation.key)}`, {
19
- colSize: maxKeyColSize,
20
- maxSize: 40
21
- }),
22
- " - ",
23
- (0, _intlayer_config.colon)((0, _intlayer_chokidar.formatLocale)(translation.locales, _intlayer_config.ANSIColors.RED), {
24
- colSize: maxLocalesColSize,
25
- maxSize: 40
26
- }),
27
- translation.filePath ? ` - ${(0, _intlayer_chokidar.formatPath)(translation.filePath)}` : "",
28
- translation.id ? " - remote" : ""
29
- ].join(""));
30
- appLogger(`Missing translations:`, { level: "info" });
31
- formattedMissingTranslations.forEach((t) => {
32
- appLogger(t, { level: "info" });
33
- });
34
- appLogger(`Locales: ${(0, _intlayer_chokidar.formatLocale)(locales)}`);
35
- appLogger(`Required locales: ${(0, _intlayer_chokidar.formatLocale)(requiredLocales ?? locales)}`);
36
- appLogger(`Missing locales: ${result.missingLocales.length === 0 ? (0, _intlayer_config.colorize)("-", _intlayer_config.ANSIColors.GREEN) : (0, _intlayer_chokidar.formatLocale)(result.missingLocales, _intlayer_config.ANSIColors.RED)}`);
37
- appLogger(`Missing required locales: ${result.missingRequiredLocales.length === 0 ? (0, _intlayer_config.colorize)("-", _intlayer_config.ANSIColors.GREEN) : (0, _intlayer_chokidar.formatLocale)(result.missingRequiredLocales, _intlayer_config.ANSIColors.RED)}`);
38
- appLogger(`Total missing locales: ${(0, _intlayer_config.colorizeNumber)(result.missingLocales.length, {
39
- one: _intlayer_config.ANSIColors.RED,
40
- other: _intlayer_config.ANSIColors.RED,
41
- zero: _intlayer_config.ANSIColors.GREEN
42
- })}`);
43
- appLogger(`Total missing required locales: ${(0, _intlayer_config.colorizeNumber)(result.missingRequiredLocales.length, {
44
- one: _intlayer_config.ANSIColors.RED,
45
- other: _intlayer_config.ANSIColors.RED,
46
- zero: _intlayer_config.ANSIColors.GREEN
47
- })}`);
48
- };
49
-
50
- //#endregion
51
- exports.testMissingTranslations = testMissingTranslations;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./listMissingTranslations.cjs`);let t=require(`@intlayer/chokidar/utils`),n=require(`@intlayer/config/node`),r=require(`@intlayer/config/logger`),i=require(`@intlayer/chokidar/build`);const a=async a=>{let o=(0,n.getConfiguration)(a?.configOptions),{locales:s,requiredLocales:c}=o.internationalization,l=(0,r.getAppLogger)(o);a?.build===!0?await(0,i.prepareIntlayer)(o,{forceRun:!0}):a?.build===void 0&&await(0,i.prepareIntlayer)(o);let u=e.listMissingTranslations(a?.configOptions),d=u.missingTranslations.map(e=>` - ${e.key}`).reduce((e,t)=>Math.max(e,t.length),0),f=u.missingTranslations.map(e=>(0,t.formatLocale)(e.locales,!1)).reduce((e,t)=>Math.max(e,t.length),0),p=u.missingTranslations.map(e=>[(0,r.colon)(` - ${(0,r.colorizeKey)(e.key)}`,{colSize:d,maxSize:40}),` - `,(0,r.colon)((0,t.formatLocale)(e.locales,r.ANSIColors.RED),{colSize:f,maxSize:40}),e.filePath?` - ${(0,t.formatPath)(e.filePath)}`:``,e.id?` - remote`:``].join(``));l(`Missing translations:`,{level:`info`}),p.forEach(e=>{l(e,{level:`info`})}),l(`Locales: ${(0,t.formatLocale)(s)}`),l(`Required locales: ${(0,t.formatLocale)(c??s)}`),l(`Missing locales: ${u.missingLocales.length===0?(0,r.colorize)(`-`,r.ANSIColors.GREEN):(0,t.formatLocale)(u.missingLocales,r.ANSIColors.RED)}`),l(`Missing required locales: ${u.missingRequiredLocales.length===0?(0,r.colorize)(`-`,r.ANSIColors.GREEN):(0,t.formatLocale)(u.missingRequiredLocales,r.ANSIColors.RED)}`),l(`Total missing locales: ${(0,r.colorizeNumber)(u.missingLocales.length,{one:r.ANSIColors.RED,other:r.ANSIColors.RED,zero:r.ANSIColors.GREEN})}`),l(`Total missing required locales: ${(0,r.colorizeNumber)(u.missingRequiredLocales.length,{one:r.ANSIColors.RED,other:r.ANSIColors.RED,zero:r.ANSIColors.GREEN})}`),u.missingRequiredLocales.length>0&&process.exit(1)};exports.testMissingTranslations=a;
52
2
  //# sourceMappingURL=test.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.cjs","names":["listMissingTranslations","ANSIColors"],"sources":["../../../src/test/test.ts"],"sourcesContent":["import { formatLocale, formatPath, prepareIntlayer } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { listMissingTranslations } from './listMissingTranslations';\n\ntype ListMissingTranslationsOptions = {\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\nexport const testMissingTranslations = async (\n options?: ListMissingTranslationsOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n const { locales, requiredLocales } = config.internationalization;\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n const result = listMissingTranslations(options?.configOptions);\n\n const maxKeyColSize = result.missingTranslations\n .map((t) => ` - ${t.key}`)\n .reduce((max, t) => Math.max(max, t.length), 0);\n const maxLocalesColSize = result.missingTranslations\n .map((t) => formatLocale(t.locales, false))\n .reduce((max, t) => Math.max(max, t.length), 0);\n\n const formattedMissingTranslations = result.missingTranslations.map(\n (translation) =>\n [\n colon(` - ${colorizeKey(translation.key)}`, {\n colSize: maxKeyColSize,\n maxSize: 40,\n }),\n ' - ',\n colon(formatLocale(translation.locales, ANSIColors.RED), {\n colSize: maxLocalesColSize,\n maxSize: 40,\n }),\n\n translation.filePath ? ` - ${formatPath(translation.filePath)}` : '',\n translation.id ? ' - remote' : '',\n ].join('')\n );\n\n appLogger(`Missing translations:`, {\n level: 'info',\n });\n\n formattedMissingTranslations.forEach((t) => {\n appLogger(t, {\n level: 'info',\n });\n });\n\n appLogger(`Locales: ${formatLocale(locales)}`);\n appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);\n appLogger(\n `Missing locales: ${result.missingLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`\n );\n\n appLogger(\n `Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`\n );\n appLogger(\n `Total missing locales: ${colorizeNumber(result.missingLocales.length, {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n })}`\n );\n appLogger(\n `Total missing required locales: ${colorizeNumber(\n result.missingRequiredLocales.length,\n {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n }\n )}`\n );\n};\n"],"mappings":";;;;;;;AAkBA,MAAa,0BAA0B,OACrC,YACG;CACH,MAAM,gDAA0B,SAAS,cAAc;CACvD,MAAM,EAAE,SAAS,oBAAoB,OAAO;CAE5C,MAAM,+CAAyB,OAAO;AAEtC,KAAI,SAAS,UAAU,KACrB,+CAAsB,QAAQ,EAAE,UAAU,MAAM,CAAC;UACxC,OAAO,SAAS,UAAU,YACnC,+CAAsB,OAAO;CAG/B,MAAM,SAASA,6DAAwB,SA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"file":"test.cjs","names":["listMissingTranslations","ANSIColors"],"sources":["../../../src/test/test.ts"],"sourcesContent":["import { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { listMissingTranslations } from './listMissingTranslations';\n\ntype ListMissingTranslationsOptions = {\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\nexport const testMissingTranslations = async (\n options?: ListMissingTranslationsOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n const { locales, requiredLocales } = config.internationalization;\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n const result = listMissingTranslations(options?.configOptions);\n\n const maxKeyColSize = result.missingTranslations\n .map((t) => ` - ${t.key}`)\n .reduce((max, t) => Math.max(max, t.length), 0);\n const maxLocalesColSize = result.missingTranslations\n .map((t) => formatLocale(t.locales, false))\n .reduce((max, t) => Math.max(max, t.length), 0);\n\n const formattedMissingTranslations = result.missingTranslations.map(\n (translation) =>\n [\n colon(` - ${colorizeKey(translation.key)}`, {\n colSize: maxKeyColSize,\n maxSize: 40,\n }),\n ' - ',\n colon(formatLocale(translation.locales, ANSIColors.RED), {\n colSize: maxLocalesColSize,\n maxSize: 40,\n }),\n\n translation.filePath ? ` - ${formatPath(translation.filePath)}` : '',\n translation.id ? ' - remote' : '',\n ].join('')\n );\n\n appLogger(`Missing translations:`, {\n level: 'info',\n });\n\n formattedMissingTranslations.forEach((t) => {\n appLogger(t, {\n level: 'info',\n });\n });\n\n appLogger(`Locales: ${formatLocale(locales)}`);\n appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);\n appLogger(\n `Missing locales: ${result.missingLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`\n );\n\n appLogger(\n `Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`\n );\n appLogger(\n `Total missing locales: ${colorizeNumber(result.missingLocales.length, {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n })}`\n );\n appLogger(\n `Total missing required locales: ${colorizeNumber(\n result.missingRequiredLocales.length,\n {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n }\n )}`\n );\n\n if (result.missingRequiredLocales.length > 0) {\n process.exit(1);\n }\n};\n"],"mappings":"yTAqBA,MAAa,EAA0B,KACrC,IACG,CACH,IAAM,GAAA,EAAA,EAAA,kBAA0B,GAAS,cAAc,CACjD,CAAE,UAAS,mBAAoB,EAAO,qBAEtC,GAAA,EAAA,EAAA,cAAyB,EAAO,CAElC,GAAS,QAAU,GACrB,MAAA,EAAA,EAAA,iBAAsB,EAAQ,CAAE,SAAU,GAAM,CAAC,CACjC,GAAS,QAAU,QACnC,MAAA,EAAA,EAAA,iBAAsB,EAAO,CAG/B,IAAM,EAASA,EAAAA,wBAAwB,GAAS,cAAc,CAExD,EAAgB,EAAO,oBAC1B,IAAK,GAAM,MAAM,EAAE,MAAM,CACzB,QAAQ,EAAK,IAAM,KAAK,IAAI,EAAK,EAAE,OAAO,CAAE,EAAE,CAC3C,EAAoB,EAAO,oBAC9B,IAAK,IAAA,EAAA,EAAA,cAAmB,EAAE,QAAS,GAAM,CAAC,CAC1C,QAAQ,EAAK,IAAM,KAAK,IAAI,EAAK,EAAE,OAAO,CAAE,EAAE,CAE3C,EAA+B,EAAO,oBAAoB,IAC7D,GACC,aACQ,OAAA,EAAA,EAAA,aAAkB,EAAY,IAAI,GAAI,CAC1C,QAAS,EACT,QAAS,GACV,CAAC,CACF,qCACmB,EAAY,QAASC,EAAAA,WAAW,IAAI,CAAE,CACvD,QAAS,EACT,QAAS,GACV,CAAC,CAEF,EAAY,SAAW,OAAA,EAAA,EAAA,YAAiB,EAAY,SAAS,GAAK,GAClE,EAAY,GAAK,YAAc,GAChC,CAAC,KAAK,GAAG,CACb,CAED,EAAU,wBAAyB,CACjC,MAAO,OACR,CAAC,CAEF,EAA6B,QAAS,GAAM,CAC1C,EAAU,EAAG,CACX,MAAO,OACR,CAAC,EACF,CAEF,EAAU,aAAA,EAAA,EAAA,cAAyB,EAAQ,GAAG,CAC9C,EAAU,sBAAA,EAAA,EAAA,cAAkC,GAAmB,EAAQ,GAAG,CAC1E,EACE,oBAAoB,EAAO,eAAe,SAAW,GAAA,EAAA,EAAA,UAAa,IAAKA,EAAAA,WAAW,MAAM,EAAA,EAAA,EAAA,cAAgB,EAAO,eAAgBA,EAAAA,WAAW,IAAI,GAC/I,CAED,EACE,6BAA6B,EAAO,uBAAuB,SAAW,GAAA,EAAA,EAAA,UAAa,IAAKA,EAAAA,WAAW,MAAM,EAAA,EAAA,EAAA,cAAgB,EAAO,uBAAwBA,EAAAA,WAAW,IAAI,GACxK,CACD,EACE,2BAAA,EAAA,EAAA,gBAAyC,EAAO,eAAe,OAAQ,CACrE,IAAKA,EAAAA,WAAW,IAChB,MAAOA,EAAAA,WAAW,IAClB,KAAMA,EAAAA,WAAW,MAClB,CAAC,GACH,CACD,EACE,oCAAA,EAAA,EAAA,gBACE,EAAO,uBAAuB,OAC9B,CACE,IAAKA,EAAAA,WAAW,IAChB,MAAOA,EAAAA,WAAW,IAClB,KAAMA,EAAAA,WAAW,MAClB,CACF,GACF,CAEG,EAAO,uBAAuB,OAAS,GACzC,QAAQ,KAAK,EAAE"}
@@ -1,9 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_translateDoc_validation = require('./validation.cjs');
3
- const require_translateDoc_translateFile = require('./translateFile.cjs');
4
- const require_translateDoc_translateDoc = require('./translateDoc.cjs');
5
-
6
- exports.sanitizeChunk = require_translateDoc_validation.sanitizeChunk;
7
- exports.translateDoc = require_translateDoc_translateDoc.translateDoc;
8
- exports.translateFile = require_translateDoc_translateFile.translateFile;
9
- exports.validateTranslation = require_translateDoc_validation.validateTranslation;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./validation.cjs`),t=require(`./translateFile.cjs`),n=require(`./translateDoc.cjs`);exports.sanitizeChunk=e.sanitizeChunk,exports.translateDoc=n.translateDoc,exports.translateFile=t.translateFile,exports.validateTranslation=e.validateTranslation;
@@ -1,75 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_setupAI = require('../utils/setupAI.cjs');
4
- const require_utils_checkFileModifiedRange = require('../utils/checkFileModifiedRange.cjs');
5
- const require_utils_getOutputFilePath = require('../utils/getOutputFilePath.cjs');
6
- const require_translateDoc_translateFile = require('./translateFile.cjs');
7
- let _intlayer_chokidar = require("@intlayer/chokidar");
8
- let _intlayer_config = require("@intlayer/config");
9
- let node_path = require("node:path");
10
- let node_fs = require("node:fs");
11
- let fast_glob = require("fast-glob");
12
- fast_glob = require_runtime.__toESM(fast_glob);
13
- let node_perf_hooks = require("node:perf_hooks");
14
-
15
- //#region src/translateDoc/translateDoc.ts
16
- const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed = 20, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions, flushStrategy = "incremental" }) => {
17
- const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
18
- const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
19
- const maxConcurrentChunks = nbSimultaneousFileProcessed;
20
- const globalChunkLimiter = (0, _intlayer_chokidar.pLimit)(maxConcurrentChunks);
21
- let docList = await (0, fast_glob.default)(docPattern, { ignore: excludedGlobPattern });
22
- const aiResult = await require_utils_setupAI.setupAI(configuration, aiOptions);
23
- if (!aiResult?.hasAIAccess) return;
24
- const { aiClient, aiConfig } = aiResult;
25
- if (gitOptions) {
26
- const gitChangedFiles = await (0, _intlayer_chokidar.listGitFiles)(gitOptions);
27
- if (gitChangedFiles) docList = docList.filter((path) => gitChangedFiles.some((gitFile) => (0, node_path.join)(process.cwd(), path) === gitFile));
28
- }
29
- const batchStartTime = node_perf_hooks.performance.now();
30
- appLogger(`Translating ${(0, _intlayer_config.colorizeNumber)(docList.length)} files to ${(0, _intlayer_config.colorizeNumber)(locales.length)} locales. \nGlobal Concurrency: ${(0, _intlayer_config.colorizeNumber)(maxConcurrentChunks)} chunks in parallel.`);
31
- const errorState = {
32
- count: 0,
33
- maxErrors: 5,
34
- shouldStop: false
35
- };
36
- await (0, _intlayer_chokidar.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
37
- if (errorState.shouldStop) return;
38
- const absoluteBaseFilePath = (0, node_path.join)(configuration.content.baseDir, docPath);
39
- const outputFilePath = require_utils_getOutputFilePath.getOutputFilePath(absoluteBaseFilePath, locale, baseLocale);
40
- if (skipIfExists && (0, node_fs.existsSync)(outputFilePath)) return;
41
- if (flushStrategy === "incremental" && !(0, node_fs.existsSync)(outputFilePath)) {
42
- (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
43
- (0, node_fs.writeFileSync)(outputFilePath, "");
44
- }
45
- const fileModificationData = require_utils_checkFileModifiedRange.checkFileModifiedRange(outputFilePath, {
46
- skipIfModifiedBefore,
47
- skipIfModifiedAfter
48
- });
49
- if (fileModificationData.isSkipped) {
50
- appLogger(fileModificationData.message);
51
- return;
52
- }
53
- await require_translateDoc_translateFile.translateFile({
54
- baseFilePath: absoluteBaseFilePath,
55
- outputFilePath,
56
- locale,
57
- baseLocale,
58
- configuration,
59
- errorState,
60
- aiOptions,
61
- customInstructions,
62
- aiClient,
63
- aiConfig,
64
- flushStrategy,
65
- limit: globalChunkLimiter
66
- });
67
- })), (task) => task(), 50);
68
- const batchDuration = ((node_perf_hooks.performance.now() - batchStartTime) / 1e3).toFixed(2);
69
- if (errorState.count > 0) appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);
70
- else appLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} Batch completed successfully in ${(0, _intlayer_config.colorizeNumber)(batchDuration)}s.`);
71
- };
72
-
73
- //#endregion
74
- exports.translateDoc = translateDoc;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/setupAI.cjs`),n=require(`../utils/checkFileModifiedRange.cjs`),r=require(`../utils/getOutputFilePath.cjs`),i=require(`./translateFile.cjs`);let a=require(`@intlayer/chokidar/utils`),o=require(`@intlayer/config/node`),s=require(`node:path`),c=require(`@intlayer/chokidar/cli`),l=require(`@intlayer/config/logger`),u=require(`node:fs`),d=require(`fast-glob`);d=e.__toESM(d);let f=require(`node:perf_hooks`);const p=async({docPattern:e,locales:p,excludedGlobPattern:m,baseLocale:h,aiOptions:g,nbSimultaneousFileProcessed:_=20,configOptions:v,customInstructions:y,skipIfModifiedBefore:b,skipIfModifiedAfter:x,skipIfExists:S,gitOptions:C,flushStrategy:w=`incremental`})=>{let T=(0,o.getConfiguration)(v),E=(0,l.getAppLogger)(T),D=_,O=(0,a.pLimit)(D),k=await(0,d.default)(e,{ignore:m}),A=await t.setupAI(T,g);if(!A?.hasAIAccess)return;let{aiClient:j,aiConfig:M}=A;if(C){let e=await(0,c.listGitFiles)(C);e&&(k=k.filter(t=>e.some(e=>(0,s.join)(process.cwd(),t)===e)))}let N=f.performance.now();E(`Translating ${(0,l.colorizeNumber)(k.length)} files to ${(0,l.colorizeNumber)(p.length)} locales. \nGlobal Concurrency: ${(0,l.colorizeNumber)(D)} chunks in parallel.`);let P={count:0,maxErrors:5,shouldStop:!1};await(0,a.parallelize)(k.flatMap(e=>p.map(t=>async()=>{if(P.shouldStop)return;let a=(0,s.join)(T.content.baseDir,e),o=r.getOutputFilePath(a,t,h);if(S&&(0,u.existsSync)(o))return;w===`incremental`&&!(0,u.existsSync)(o)&&((0,u.mkdirSync)((0,s.dirname)(o),{recursive:!0}),(0,u.writeFileSync)(o,``));let c=n.checkFileModifiedRange(o,{skipIfModifiedBefore:b,skipIfModifiedAfter:x});if(c.isSkipped){E(c.message);return}await i.translateFile({baseFilePath:a,outputFilePath:o,locale:t,baseLocale:h,configuration:T,errorState:P,aiOptions:g,customInstructions:y,aiClient:j,aiConfig:M,flushStrategy:w,limit:O})})),e=>e(),50);let F=((f.performance.now()-N)/1e3).toFixed(2);P.count>0?E(`Finished with ${P.count} errors in ${F}s.`):E(`${(0,l.colorize)(`✔`,l.ANSIColors.GREEN)} Batch completed successfully in ${(0,l.colorizeNumber)(F)}s.`)};exports.translateDoc=p;
75
2
  //# sourceMappingURL=translateDoc.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translateDoc.cjs","names":["setupAI","performance","getOutputFilePath","checkFileModifiedRange","translateFile","ANSIColors"],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { listGitFiles, parallelize, pLimit } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // 2. FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // 3. HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,eAAe,OAAO,EACjC,YACA,SACA,qBACA,YACA,WACA,8BAA8B,IAC9B,eACA,oBACA,sBACA,qBACA,cACA,YACA,gBAAgB,oBACS;CACzB,MAAM,uDAAiC,cAAc;CACrD,MAAM,+CAAyB,cAAc;CAK7C,MAAM,sBAAsB;CAC5B,MAAM,oDAA4B,oBAAoB;CAEtD,IAAI,UAAoB,6BAAS,YAAY,EAC3C,QAAQ,qBACT,CAAC;CAEF,MAAM,WAAW,MAAMA,8BAAQ,eAAe,UAAU;AACxD,KAAI,CAAC,UAAU,YAAa;CAC5B,MAAM,EAAE,UAAU,aAAa;AAE/B,KAAI,YAAY;EACd,MAAM,kBAAkB,2CAAmB,WAAW;AACtD,MAAI,gBACF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAAiB,QAAQ,KAAK,EAAE,KAAK,KAAK,QAAQ,CACzE;;CAIL,MAAM,iBAAiBC,4BAAY,KAAK;AAExC,WACE,oDAA8B,QAAQ,OAAO,CAAC,iDAA2B,QAAQ,OAAO,CAAC,uEACjD,oBAAoB,CAAC,sBAC9D;CAED,MAAM,aAAyB;EAC7B,OAAO;EACP,WAAW;EACX,YAAY;EACb;AAyDD,2CArDiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,MAAI,WAAW,WAAY;EAE3B,MAAM,2CAA4B,cAAc,QAAQ,SAAS,QAAQ;EACzE,MAAM,iBAAiBC,kDACrB,sBACA,QACA,WACD;AAGD,MAAI,wCAA2B,eAAe,CAAE;AAEhD,MAAI,kBAAkB,iBAAiB,yBAAY,eAAe,EAAE;AAClE,iDAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,8BAAc,gBAAgB,GAAG;;EAGnC,MAAM,uBAAuBC,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAIF,QAAMC,iDAAc;GAClB,cAAc;GACd;GACQ;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACR,CAAC;GACF,CACH,GAQ4B,SAAS,MAAM,EAFpB,GAEsC;CAG9D,MAAM,kBADeH,4BAAY,KAAK,GACC,kBAAkB,KAAM,QAAQ,EAAE;AAEzE,KAAI,WAAW,QAAQ,EACrB,WAAU,iBAAiB,WAAW,MAAM,aAAa,cAAc,IAAI;KAE3E,WACE,kCAAY,KAAKI,4BAAW,MAAM,CAAC,wEAAkD,cAAc,CAAC,IACrG"}
1
+ {"version":3,"file":"translateDoc.cjs","names":["setupAI","performance","getOutputFilePath","checkFileModifiedRange","translateFile","ANSIColors"],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { listGitFiles } from '@intlayer/chokidar/cli';\nimport { parallelize, pLimit } from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // 2. FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // 3. HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":"iiBAoBA,MAAa,EAAe,MAAO,CACjC,aACA,UACA,sBACA,aACA,YACA,8BAA8B,GAC9B,gBACA,qBACA,uBACA,sBACA,eACA,aACA,gBAAgB,iBACS,CACzB,IAAM,GAAA,EAAA,EAAA,kBAAiC,EAAc,CAC/C,GAAA,EAAA,EAAA,cAAyB,EAAc,CAKvC,EA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