@intlayer/cli 9.0.0-canary.2 → 9.0.0-canary.20

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 (333) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +1 -1
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_utils_asset.cjs +4 -3
  4. package/dist/cjs/auth/login.cjs +44 -31
  5. package/dist/cjs/auth/login.cjs.map +1 -1
  6. package/dist/cjs/auth/sessionToken.cjs +0 -1
  7. package/dist/cjs/auth/sessionToken.cjs.map +1 -1
  8. package/dist/cjs/build.cjs +6 -7
  9. package/dist/cjs/build.cjs.map +1 -1
  10. package/dist/cjs/bundle.cjs +32 -1
  11. package/dist/cjs/bundle.cjs.map +1 -1
  12. package/dist/cjs/ci.cjs +96 -29
  13. package/dist/cjs/ci.cjs.map +1 -1
  14. package/dist/cjs/cli.cjs +163 -125
  15. package/dist/cjs/cli.cjs.map +1 -1
  16. package/dist/cjs/config.cjs +2 -3
  17. package/dist/cjs/config.cjs.map +1 -1
  18. package/dist/cjs/editor.cjs +0 -1
  19. package/dist/cjs/editor.cjs.map +1 -1
  20. package/dist/cjs/extract.cjs +7 -7
  21. package/dist/cjs/extract.cjs.map +1 -1
  22. package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
  23. package/dist/cjs/fill/extractTranslatableContent.cjs.map +1 -1
  24. package/dist/cjs/fill/fill.cjs +11 -11
  25. package/dist/cjs/fill/fill.cjs.map +1 -1
  26. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +2 -3
  27. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  28. package/dist/cjs/fill/formatFillData.cjs +3 -4
  29. package/dist/cjs/fill/formatFillData.cjs.map +1 -1
  30. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
  31. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
  32. package/dist/cjs/fill/listTranslationsTasks.cjs +2 -2
  33. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  34. package/dist/cjs/fill/translateDictionary.cjs +7 -7
  35. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  36. package/dist/cjs/fill/writeFill.cjs +5 -6
  37. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  38. package/dist/cjs/getTargetDictionary.cjs +2 -3
  39. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  40. package/dist/cjs/index.cjs +4 -4
  41. package/dist/cjs/init.cjs +369 -3
  42. package/dist/cjs/init.cjs.map +1 -1
  43. package/dist/cjs/initBuildOptimization.cjs +81 -0
  44. package/dist/cjs/initBuildOptimization.cjs.map +1 -0
  45. package/dist/cjs/initCompiler.cjs +117 -0
  46. package/dist/cjs/initCompiler.cjs.map +1 -0
  47. package/dist/cjs/initMCP.cjs +24 -21
  48. package/dist/cjs/initMCP.cjs.map +1 -1
  49. package/dist/cjs/initSkills.cjs +31 -28
  50. package/dist/cjs/initSkills.cjs.map +1 -1
  51. package/dist/cjs/listContentDeclaration.cjs +4 -5
  52. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  53. package/dist/cjs/listProjects.cjs +2 -3
  54. package/dist/cjs/listProjects.cjs.map +1 -1
  55. package/dist/cjs/liveSync.cjs +4 -4
  56. package/dist/cjs/liveSync.cjs.map +1 -1
  57. package/dist/cjs/pull.cjs +7 -7
  58. package/dist/cjs/pull.cjs.map +1 -1
  59. package/dist/cjs/push/pullLog.cjs +2 -2
  60. package/dist/cjs/push/pullLog.cjs.map +1 -1
  61. package/dist/cjs/push/push.cjs +13 -13
  62. package/dist/cjs/push/push.cjs.map +1 -1
  63. package/dist/cjs/pushConfig.cjs +2 -3
  64. package/dist/cjs/pushConfig.cjs.map +1 -1
  65. package/dist/cjs/pushLog.cjs.map +1 -1
  66. package/dist/cjs/reviewDoc/reviewDoc.cjs +16 -16
  67. package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
  68. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +12 -12
  69. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
  70. package/dist/cjs/reviewDoc/reviewDocLog.cjs +7 -8
  71. package/dist/cjs/reviewDoc/reviewDocLog.cjs.map +1 -1
  72. package/dist/cjs/scan.cjs +5 -5
  73. package/dist/cjs/scan.cjs.map +1 -1
  74. package/dist/cjs/searchDoc.cjs +2 -3
  75. package/dist/cjs/searchDoc.cjs.map +1 -1
  76. package/dist/cjs/test/listMissingTranslations.cjs +3 -4
  77. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  78. package/dist/cjs/test/test.cjs +11 -11
  79. package/dist/cjs/test/test.cjs.map +1 -1
  80. package/dist/cjs/translateDoc/translateDoc.cjs +6 -6
  81. package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
  82. package/dist/cjs/translateDoc/translateFile.cjs +6 -6
  83. package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
  84. package/dist/cjs/translateDoc/validation.cjs.map +1 -1
  85. package/dist/cjs/utils/calculateChunks.cjs +4 -5
  86. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  87. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  88. package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
  89. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  90. package/dist/cjs/utils/checkLastUpdateTime.cjs +0 -1
  91. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  92. package/dist/cjs/utils/chunkInference.cjs +0 -1
  93. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  94. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  95. package/dist/cjs/utils/formatLineRanges.cjs.map +1 -1
  96. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  97. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -2
  98. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  99. package/dist/cjs/utils/getOutputFilePath.cjs +2 -3
  100. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  101. package/dist/cjs/utils/getParentPackageJSON.cjs +0 -1
  102. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  103. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  104. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +4 -5
  105. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  106. package/dist/cjs/utils/openBrowser.cjs +0 -1
  107. package/dist/cjs/utils/openBrowser.cjs.map +1 -1
  108. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  109. package/dist/cjs/utils/selectCmsEnvironment.cjs.map +1 -1
  110. package/dist/cjs/utils/setupAI.cjs.map +1 -1
  111. package/dist/cjs/watch.cjs +28 -9
  112. package/dist/cjs/watch.cjs.map +1 -1
  113. package/dist/esm/IntlayerEventListener.mjs +1 -0
  114. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  115. package/dist/esm/_virtual/_utils_asset.mjs +4 -2
  116. package/dist/esm/auth/login.mjs +43 -30
  117. package/dist/esm/auth/login.mjs.map +1 -1
  118. package/dist/esm/auth/sessionToken.mjs.map +1 -1
  119. package/dist/esm/build.mjs +3 -3
  120. package/dist/esm/build.mjs.map +1 -1
  121. package/dist/esm/bundle.mjs +32 -1
  122. package/dist/esm/bundle.mjs.map +1 -1
  123. package/dist/esm/ci.mjs +95 -30
  124. package/dist/esm/ci.mjs.map +1 -1
  125. package/dist/esm/cli.mjs +141 -102
  126. package/dist/esm/cli.mjs.map +1 -1
  127. package/dist/esm/config.mjs +1 -1
  128. package/dist/esm/config.mjs.map +1 -1
  129. package/dist/esm/editor.mjs.map +1 -1
  130. package/dist/esm/extract.mjs +3 -3
  131. package/dist/esm/extract.mjs.map +1 -1
  132. package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
  133. package/dist/esm/fill/extractTranslatableContent.mjs.map +1 -1
  134. package/dist/esm/fill/fill.mjs +3 -3
  135. package/dist/esm/fill/fill.mjs.map +1 -1
  136. package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
  137. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  138. package/dist/esm/fill/formatFillData.mjs +1 -1
  139. package/dist/esm/fill/formatFillData.mjs.map +1 -1
  140. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
  141. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
  142. package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
  143. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  144. package/dist/esm/fill/translateDictionary.mjs +1 -1
  145. package/dist/esm/fill/translateDictionary.mjs.map +1 -1
  146. package/dist/esm/fill/writeFill.mjs +2 -2
  147. package/dist/esm/fill/writeFill.mjs.map +1 -1
  148. package/dist/esm/getTargetDictionary.mjs +1 -1
  149. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  150. package/dist/esm/index.mjs +4 -4
  151. package/dist/esm/init.mjs +368 -4
  152. package/dist/esm/init.mjs.map +1 -1
  153. package/dist/esm/initBuildOptimization.mjs +78 -0
  154. package/dist/esm/initBuildOptimization.mjs.map +1 -0
  155. package/dist/esm/initCompiler.mjs +114 -0
  156. package/dist/esm/initCompiler.mjs.map +1 -0
  157. package/dist/esm/initMCP.mjs +23 -20
  158. package/dist/esm/initMCP.mjs.map +1 -1
  159. package/dist/esm/initSkills.mjs +22 -19
  160. package/dist/esm/initSkills.mjs.map +1 -1
  161. package/dist/esm/listContentDeclaration.mjs +2 -2
  162. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  163. package/dist/esm/listProjects.mjs +1 -1
  164. package/dist/esm/listProjects.mjs.map +1 -1
  165. package/dist/esm/liveSync.mjs +2 -2
  166. package/dist/esm/liveSync.mjs.map +1 -1
  167. package/dist/esm/pull.mjs +4 -4
  168. package/dist/esm/pull.mjs.map +1 -1
  169. package/dist/esm/push/pullLog.mjs +2 -2
  170. package/dist/esm/push/pullLog.mjs.map +1 -1
  171. package/dist/esm/push/push.mjs +3 -3
  172. package/dist/esm/push/push.mjs.map +1 -1
  173. package/dist/esm/pushConfig.mjs +1 -1
  174. package/dist/esm/pushConfig.mjs.map +1 -1
  175. package/dist/esm/pushLog.mjs.map +1 -1
  176. package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
  177. package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
  178. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
  179. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
  180. package/dist/esm/reviewDoc/reviewDocLog.mjs +2 -2
  181. package/dist/esm/reviewDoc/reviewDocLog.mjs.map +1 -1
  182. package/dist/esm/scan.mjs +1 -1
  183. package/dist/esm/scan.mjs.map +1 -1
  184. package/dist/esm/searchDoc.mjs +1 -1
  185. package/dist/esm/searchDoc.mjs.map +1 -1
  186. package/dist/esm/test/listMissingTranslations.mjs +2 -2
  187. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  188. package/dist/esm/test/test.mjs +2 -2
  189. package/dist/esm/test/test.mjs.map +1 -1
  190. package/dist/esm/translateDoc/translateDoc.mjs +2 -2
  191. package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
  192. package/dist/esm/translateDoc/translateFile.mjs +2 -2
  193. package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
  194. package/dist/esm/translateDoc/validation.mjs.map +1 -1
  195. package/dist/esm/utils/calculateChunks.mjs +1 -1
  196. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  197. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  198. package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
  199. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  200. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  201. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  202. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  203. package/dist/esm/utils/formatLineRanges.mjs.map +1 -1
  204. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  205. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -1
  206. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  207. package/dist/esm/utils/getOutputFilePath.mjs +1 -1
  208. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  209. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  210. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  211. package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -1
  212. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  213. package/dist/esm/utils/openBrowser.mjs.map +1 -1
  214. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  215. package/dist/esm/utils/selectCmsEnvironment.mjs.map +1 -1
  216. package/dist/esm/utils/setupAI.mjs.map +1 -1
  217. package/dist/esm/watch.mjs +25 -5
  218. package/dist/esm/watch.mjs.map +1 -1
  219. package/dist/types/IntlayerEventListener.d.ts +0 -1
  220. package/dist/types/IntlayerEventListener.d.ts.map +1 -1
  221. package/dist/types/auth/login.d.ts +13 -5
  222. package/dist/types/auth/login.d.ts.map +1 -1
  223. package/dist/types/auth/sessionToken.d.ts +0 -1
  224. package/dist/types/auth/sessionToken.d.ts.map +1 -1
  225. package/dist/types/build.d.ts +0 -1
  226. package/dist/types/build.d.ts.map +1 -1
  227. package/dist/types/bundle.d.ts +0 -1
  228. package/dist/types/bundle.d.ts.map +1 -1
  229. package/dist/types/ci.d.ts +40 -1
  230. package/dist/types/ci.d.ts.map +1 -1
  231. package/dist/types/cli.d.ts +0 -1
  232. package/dist/types/cli.d.ts.map +1 -1
  233. package/dist/types/config.d.ts +0 -1
  234. package/dist/types/config.d.ts.map +1 -1
  235. package/dist/types/editor.d.ts.map +1 -1
  236. package/dist/types/extract.d.ts +0 -1
  237. package/dist/types/extract.d.ts.map +1 -1
  238. package/dist/types/fill/deepMergeContent.d.ts.map +1 -1
  239. package/dist/types/fill/extractTranslatableContent.d.ts.map +1 -1
  240. package/dist/types/fill/fill.d.ts +1 -2
  241. package/dist/types/fill/fill.d.ts.map +1 -1
  242. package/dist/types/fill/formatAutoFilledFilePath.d.ts +0 -1
  243. package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
  244. package/dist/types/fill/formatFillData.d.ts +0 -1
  245. package/dist/types/fill/formatFillData.d.ts.map +1 -1
  246. package/dist/types/fill/getAvailableLocalesInDictionary.d.ts +0 -1
  247. package/dist/types/fill/getAvailableLocalesInDictionary.d.ts.map +1 -1
  248. package/dist/types/fill/getFilterMissingContentPerLocale.d.ts +0 -1
  249. package/dist/types/fill/getFilterMissingContentPerLocale.d.ts.map +1 -1
  250. package/dist/types/fill/listTranslationsTasks.d.ts +1 -2
  251. package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -1
  252. package/dist/types/fill/translateDictionary.d.ts +1 -3
  253. package/dist/types/fill/translateDictionary.d.ts.map +1 -1
  254. package/dist/types/fill/writeFill.d.ts +0 -1
  255. package/dist/types/fill/writeFill.d.ts.map +1 -1
  256. package/dist/types/getTargetDictionary.d.ts +1 -2
  257. package/dist/types/getTargetDictionary.d.ts.map +1 -1
  258. package/dist/types/index.d.ts +5 -4
  259. package/dist/types/init.d.ts +2 -3
  260. package/dist/types/init.d.ts.map +1 -1
  261. package/dist/types/initBuildOptimization.d.ts +20 -0
  262. package/dist/types/initBuildOptimization.d.ts.map +1 -0
  263. package/dist/types/initCompiler.d.ts +18 -0
  264. package/dist/types/initCompiler.d.ts.map +1 -0
  265. package/dist/types/initMCP.d.ts +2 -1
  266. package/dist/types/initMCP.d.ts.map +1 -1
  267. package/dist/types/initSkills.d.ts +2 -3
  268. package/dist/types/initSkills.d.ts.map +1 -1
  269. package/dist/types/listContentDeclaration.d.ts +0 -1
  270. package/dist/types/listContentDeclaration.d.ts.map +1 -1
  271. package/dist/types/listProjects.d.ts +1 -2
  272. package/dist/types/listProjects.d.ts.map +1 -1
  273. package/dist/types/liveSync.d.ts +0 -1
  274. package/dist/types/liveSync.d.ts.map +1 -1
  275. package/dist/types/pull.d.ts +0 -1
  276. package/dist/types/pull.d.ts.map +1 -1
  277. package/dist/types/push/pullLog.d.ts +1 -2
  278. package/dist/types/push/pullLog.d.ts.map +1 -1
  279. package/dist/types/push/push.d.ts +1 -2
  280. package/dist/types/push/push.d.ts.map +1 -1
  281. package/dist/types/pushConfig.d.ts +0 -1
  282. package/dist/types/pushConfig.d.ts.map +1 -1
  283. package/dist/types/pushLog.d.ts.map +1 -1
  284. package/dist/types/reviewDoc/reviewDoc.d.ts +2 -17
  285. package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
  286. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +0 -1
  287. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
  288. package/dist/types/reviewDoc/reviewDocLog.d.ts +1 -2
  289. package/dist/types/reviewDoc/reviewDocLog.d.ts.map +1 -1
  290. package/dist/types/scan.d.ts +3 -2
  291. package/dist/types/scan.d.ts.map +1 -1
  292. package/dist/types/searchDoc.d.ts +1 -6
  293. package/dist/types/searchDoc.d.ts.map +1 -1
  294. package/dist/types/test/listMissingTranslations.d.ts +0 -1
  295. package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
  296. package/dist/types/test/test.d.ts +0 -1
  297. package/dist/types/test/test.d.ts.map +1 -1
  298. package/dist/types/translateDoc/translateDoc.d.ts +1 -16
  299. package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
  300. package/dist/types/translateDoc/translateFile.d.ts +1 -16
  301. package/dist/types/translateDoc/translateFile.d.ts.map +1 -1
  302. package/dist/types/translateDoc/types.d.ts +1 -2
  303. package/dist/types/translateDoc/types.d.ts.map +1 -1
  304. package/dist/types/translateDoc/validation.d.ts +0 -1
  305. package/dist/types/translateDoc/validation.d.ts.map +1 -1
  306. package/dist/types/utils/calculateChunks.d.ts.map +1 -1
  307. package/dist/types/utils/checkAccess.d.ts +0 -1
  308. package/dist/types/utils/checkAccess.d.ts.map +1 -1
  309. package/dist/types/utils/checkConfigConsistency.d.ts.map +1 -1
  310. package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
  311. package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
  312. package/dist/types/utils/chunkInference.d.ts +0 -1
  313. package/dist/types/utils/chunkInference.d.ts.map +1 -1
  314. package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
  315. package/dist/types/utils/formatLineRanges.d.ts.map +1 -1
  316. package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
  317. package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
  318. package/dist/types/utils/getOutputFilePath.d.ts +0 -1
  319. package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
  320. package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
  321. package/dist/types/utils/listSpecialChars.d.ts +4 -2
  322. package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
  323. package/dist/types/utils/mapChunksBetweenFiles.d.ts +0 -1
  324. package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
  325. package/dist/types/utils/openBrowser.d.ts.map +1 -1
  326. package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
  327. package/dist/types/utils/selectCmsEnvironment.d.ts +0 -1
  328. package/dist/types/utils/selectCmsEnvironment.d.ts.map +1 -1
  329. package/dist/types/utils/setupAI.d.ts +1 -3
  330. package/dist/types/utils/setupAI.d.ts.map +1 -1
  331. package/dist/types/watch.d.ts +0 -1
  332. package/dist/types/watch.d.ts.map +1 -1
  333. package/package.json +17 -17
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFilledFilePath.cjs","names":["GREY_DARK"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport { getFormatFromExtension } from '@intlayer/chokidar/utils';\nimport { GREY_DARK } from '@intlayer/config/colors';\nimport { colorize, colorizePath } from '@intlayer/config/logger';\nimport { parseFilePathPattern } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\n\nexport const formatAutoFilledFilePath = async (\n autoFillField: FilePathPattern,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n configuration: IntlayerConfig,\n locale?: Locale\n): Promise<string> => {\n // Validate inputs\n if (!autoFillField) {\n throw new Error('autoFillField must be provided');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename accurately\n const base = basename(dictionaryFilePath);\n\n const { fileExtensions } = configuration.content;\n const extensionMatch = fileExtensions.find((ext) => base.endsWith(ext));\n\n const originalFileName = extensionMatch\n ? base.slice(0, -extensionMatch.length)\n : base.split('.')[0];\n\n console.log({ extensionMatch });\n\n if (!extensionMatch) {\n throw new Error(\n `No extension found for file ${colorizePath(dictionaryFilePath)}. Valid extensions are: ${colorize(\n fileExtensions.join(', '),\n GREY_DARK\n )}`\n );\n }\n\n // Replace placeholders in autoFillField\n const result: string = await parseFilePathPattern(autoFillField, {\n key: dictionaryKey,\n fileName: originalFileName,\n locale,\n extension: extensionMatch,\n format: getFormatFromExtension(extensionMatch),\n });\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,2BAA2B,OACtC,eACA,eACA,oBACA,SACA,eACA,WACoB;AAEpB,KAAI,CAAC,cACH,OAAM,IAAI,MAAM,iCAAiC;AAEnD,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAIvD,MAAM,+BAAgB,mBAAmB;CAEzC,MAAM,EAAE,mBAAmB,cAAc;CACzC,MAAM,iBAAiB,eAAe,MAAM,QAAQ,KAAK,SAAS,IAAI,CAAC;CAEvE,MAAM,mBAAmB,iBACrB,KAAK,MAAM,GAAG,CAAC,eAAe,OAAO,GACrC,KAAK,MAAM,IAAI,CAAC;AAEpB,SAAQ,IAAI,EAAE,gBAAgB,CAAC;AAE/B,KAAI,CAAC,eACH,OAAM,IAAI,MACR,yEAA4C,mBAAmB,CAAC,gEAC9D,eAAe,KAAK,KAAK,EACzBA,kCACD,GACF;CAIH,MAAM,SAAiB,uDAA2B,eAAe;EAC/D,KAAK;EACL,UAAU;EACV;EACA,WAAW;EACX,6DAA+B,eAAe;EAC/C,CAAC;CAGF,MAAM,mDAAoC,mBAAmB,GACzD,4CACQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,sDAHwB,uBACY,EAAE,OAEnB;AAIrB,+BAAe,OAAO,EAAE;EACtB,MAAM,4CAA6B,OAAO;EAC1C,MAAM,6CAA8B,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,wCAAyB,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,iCAAiB,OAAO"}
1
+ {"version":3,"file":"formatAutoFilledFilePath.cjs","names":["GREY_DARK"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport { GREY_DARK } from '@intlayer/config/colors';\nimport { colorize, colorizePath } from '@intlayer/config/logger';\nimport { parseFilePathPattern } from '@intlayer/config/utils';\nimport { getFormatFromExtension } from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\n\nexport const formatAutoFilledFilePath = async (\n autoFillField: FilePathPattern,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n configuration: IntlayerConfig,\n locale?: Locale\n): Promise<string> => {\n // Validate inputs\n if (!autoFillField) {\n throw new Error('autoFillField must be provided');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename accurately\n const base = basename(dictionaryFilePath);\n\n const { fileExtensions } = configuration.content;\n const extensionMatch = fileExtensions.find((ext) => base.endsWith(ext));\n\n const originalFileName = extensionMatch\n ? base.slice(0, -extensionMatch.length)\n : base.split('.')[0];\n\n console.log({ extensionMatch });\n\n if (!extensionMatch) {\n throw new Error(\n `No extension found for file ${colorizePath(dictionaryFilePath)}. Valid extensions are: ${colorize(\n fileExtensions.join(', '),\n GREY_DARK\n )}`\n );\n }\n\n // Replace placeholders in autoFillField\n const result: string = await parseFilePathPattern(autoFillField, {\n key: dictionaryKey,\n fileName: originalFileName,\n locale,\n extension: extensionMatch,\n format: getFormatFromExtension(extensionMatch),\n });\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,2BAA2B,OACtC,eACA,eACA,oBACA,SACA,eACA,WACoB;CAEpB,IAAI,CAAC,eACH,MAAM,IAAI,MAAM,gCAAgC;CAElD,IAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAC7C,MAAM,IAAI,MAAM,0CAA0C;CAE5D,IAAI,CAAC,sBAAsB,OAAO,uBAAuB,UACvD,MAAM,IAAI,MAAM,+CAA+C;CAEjE,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,MAAM,IAAI,MAAM,oCAAoC;CAItD,MAAM,+BAAgB,kBAAkB;CAExC,MAAM,EAAE,mBAAmB,cAAc;CACzC,MAAM,iBAAiB,eAAe,MAAM,QAAQ,KAAK,SAAS,GAAG,CAAC;CAEtE,MAAM,mBAAmB,iBACrB,KAAK,MAAM,GAAG,CAAC,eAAe,MAAM,IACpC,KAAK,MAAM,GAAG,CAAC,CAAC;CAEpB,QAAQ,IAAI,EAAE,eAAe,CAAC;CAE9B,IAAI,CAAC,gBACH,MAAM,IAAI,MACR,yEAA4C,kBAAkB,EAAE,gEAC9D,eAAe,KAAK,IAAI,GACxBA,iCACF,GACF;CAIF,MAAM,SAAiB,uDAA2B,eAAe;EAC/D,KAAK;EACL,UAAU;EACV;EACA,WAAW;EACX,2DAA+B,cAAc;CAC/C,CAAC;CAGD,MAAM,mDAAoC,kBAAkB,IACxD,4CACQ,SAAS,kBAAkB;CAGvC,IAAI,OAAO,WAAW,IAAI,KAAK,OAAO,WAAW,KAAK,GAIpD,qDAHwB,sBACW,GAAG,MAEpB;CAIpB,8BAAe,MAAM,GAAG;EACtB,MAAM,4CAA6B,MAAM;EACzC,MAAM,6CAA8B,OAAO;EAI3C,IACE,OAAO,WAAW,GAAG,KACrB,CAAC,iBAAiB,WAAW,iBAAiB,GAC9C;GAEA,MAAM,wCAAyB,SAAS,OAAO,UAAU,CAAC,CAAC;GAG3D,IACE,CAAC,OAAO,WAAW,OAAO,KAC1B,CAAC,OAAO,WAAW,OAAO,KAC1B,CAAC,OAAO,WAAW,OAAO,KAC1B,CAAC,OAAO,WAAW,QAAQ,KAC3B,CAAC,OAAO,WAAW,SAAS,GAE5B,OAAO;EAEX;EAGA,OAAO;CACT;CAGA,gCAAiB,MAAM;AACzB"}
@@ -1,8 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_utils_getOutputFilePath = require('../utils/getOutputFilePath.cjs');
4
3
  let node_path = require("node:path");
5
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
4
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
6
5
 
7
6
  //#region src/fill/formatFillData.ts
8
7
  /** Merge FillData entries that resolve to the same file path. */
@@ -26,11 +25,11 @@ const formatFillData = async (fillField, localeList, filePath, dictionaryKey, co
26
25
  const sourceLocaleMatch = locales.find((loc) => cleanComponentFileName.endsWith(`.${loc}`));
27
26
  if (sourceLocaleMatch) cleanComponentFileName = cleanComponentFileName.slice(0, -(sourceLocaleMatch.length + 1));
28
27
  const uncapitalizedName = cleanComponentFileName.charAt(0).toLowerCase() + cleanComponentFileName.slice(1);
29
- const componentFormat = (0, _intlayer_chokidar_utils.getFormatFromExtension)(extension);
28
+ const componentFormat = (0, _intlayer_engine_utils.getFormatFromExtension)(extension);
30
29
  const getContext = (locale, patternString) => {
31
30
  let format = "json";
32
31
  if (patternString) {
33
- const extFormat = (0, _intlayer_chokidar_utils.getFormatFromExtension)((0, node_path.extname)(patternString));
32
+ const extFormat = (0, _intlayer_engine_utils.getFormatFromExtension)((0, node_path.extname)(patternString));
34
33
  if (extFormat) format = extFormat;
35
34
  }
36
35
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"formatFillData.cjs","names":["resolveOutputPattern","getPatternForLocale"],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import { basename, dirname, extname, relative } from 'node:path';\nimport { getFormatFromExtension } from '@intlayer/chokidar/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryKey, Fill } from '@intlayer/types/dictionary';\nimport type { FilePathPatternContext } from '@intlayer/types/filePathPattern';\nimport {\n getPatternForLocale,\n resolveOutputPattern,\n} from '../utils/getOutputFilePath';\n\nexport type FillData = {\n localeList: Locale[];\n filePath: string;\n isPerLocale: boolean;\n};\n\n/** Merge FillData entries that resolve to the same file path. */\nconst groupByFilePath = (entries: FillData[]): FillData[] =>\n entries.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n for (const loc of curr.localeList) {\n if (!existing.localeList.includes(loc)) existing.localeList.push(loc);\n }\n // Multiple locales sharing one path → multilingual file\n existing.isPerLocale = false;\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\nexport const formatFillData = async (\n fillField: Fill,\n localeList: Locale[],\n filePath: string,\n dictionaryKey: DictionaryKey,\n configuration: IntlayerConfig\n): Promise<FillData[]> => {\n if (!fillField || typeof fillField === 'boolean') return [];\n\n const { baseDir } = configuration.system;\n const { defaultLocale, locales } = configuration.internationalization;\n\n const extension = extname(filePath);\n const base = basename(filePath);\n\n const { fileExtensions } = configuration.content;\n const extensionMatch = fileExtensions.find((ext) => base.endsWith(ext));\n\n let cleanComponentFileName = extensionMatch\n ? base.slice(0, -extensionMatch.length)\n : base.split('.')[0];\n\n // Strip source locale if present\n const sourceLocaleMatch = locales.find((loc) =>\n cleanComponentFileName.endsWith(`.${loc}`)\n );\n if (sourceLocaleMatch) {\n cleanComponentFileName = cleanComponentFileName.slice(\n 0,\n -(sourceLocaleMatch.length + 1)\n );\n }\n\n const uncapitalizedName =\n cleanComponentFileName.charAt(0).toLowerCase() +\n cleanComponentFileName.slice(1);\n const componentFormat = getFormatFromExtension(extension);\n\n const getContext = (\n locale: Locale,\n patternString?: string\n ): FilePathPatternContext => {\n let format: FilePathPatternContext['format'] = 'json';\n if (patternString) {\n const extFormat = getFormatFromExtension(extname(patternString) as any);\n if (extFormat) format = extFormat as any;\n }\n return {\n key: dictionaryKey,\n componentDirPath: relative(baseDir, dirname(filePath)),\n componentFileName: cleanComponentFileName,\n fileName: uncapitalizedName,\n componentFormat:\n componentFormat as FilePathPatternContext['componentFormat'],\n componentExtension:\n extension as FilePathPatternContext['componentExtension'],\n format,\n locale,\n extension:\n configuration.content.fileExtensions.find((ext) =>\n ext.endsWith(extension)\n ) ?? configuration.content.fileExtensions[0],\n };\n };\n\n /**\n * Evaluate a scalar Fill pattern (string or function) for a list of locales.\n *\n * - Uses a dummy locale probe to detect whether the pattern varies per locale.\n * - `forcePerLocale` overrides the probe for object-fill entries where each\n * locale always maps to its own dedicated file regardless of whether the\n * path itself contains the locale string.\n */\n const processPattern = async (\n pattern: Fill,\n locales: Locale[],\n forcePerLocale = false\n ): Promise<FillData[]> => {\n const dummyLocale = '###########locale###########' as Locale;\n const patternString = typeof pattern === 'string' ? pattern : undefined;\n\n const dummyPath = await resolveOutputPattern(\n pattern,\n dummyLocale,\n getContext(dummyLocale, patternString),\n filePath,\n baseDir\n );\n const isPatternPerLocale =\n forcePerLocale ||\n (typeof dummyPath === 'string' && dummyPath.includes(dummyLocale));\n\n if (isPatternPerLocale) {\n const resolvedPaths: FillData[] = [];\n for (const locale of locales) {\n const absolutePath = await resolveOutputPattern(\n pattern,\n locale,\n getContext(locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath !== false) {\n resolvedPaths.push({\n filePath: absolutePath,\n localeList: [locale],\n isPerLocale: true,\n });\n }\n }\n return groupByFilePath(resolvedPaths);\n }\n\n // Single multilingual path — resolve using the default locale for context\n const absolutePath = await resolveOutputPattern(\n pattern,\n defaultLocale as Locale,\n getContext(defaultLocale as Locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath === false) return [];\n return [\n { filePath: absolutePath, localeList: locales, isPerLocale: false },\n ];\n };\n\n // Object fill: each locale key maps to its own pattern.\n // Object fill entries are always per-locale in intent (each locale → its own file).\n if (typeof fillField === 'object' && fillField !== null) {\n const results: FillData[] = [];\n for (const locale of localeList) {\n const pattern = getPatternForLocale(fillField, locale);\n if (pattern) {\n const res = await processPattern(pattern, [locale], true);\n results.push(...res);\n }\n }\n return groupByFilePath(results);\n }\n\n // Scalar string or function pattern\n return processPattern(fillField, localeList);\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,mBAAmB,YACvB,QAAQ,QAAQ,KAAK,SAAS;CAC5B,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,SAAS;AACpE,KAAI,UAAU;AACZ,OAAK,MAAM,OAAO,KAAK,WACrB,KAAI,CAAC,SAAS,WAAW,SAAS,IAAI,CAAE,UAAS,WAAW,KAAK,IAAI;AAGvE,WAAS,cAAc;OAEvB,KAAI,KAAK,KAAK;AAEhB,QAAO;GACN,EAAE,CAAe;AAEtB,MAAa,iBAAiB,OAC5B,WACA,YACA,UACA,eACA,kBACwB;AACxB,KAAI,CAAC,aAAa,OAAO,cAAc,UAAW,QAAO,EAAE;CAE3D,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,eAAe,YAAY,cAAc;CAEjD,MAAM,mCAAoB,SAAS;CACnC,MAAM,+BAAgB,SAAS;CAE/B,MAAM,EAAE,mBAAmB,cAAc;CACzC,MAAM,iBAAiB,eAAe,MAAM,QAAQ,KAAK,SAAS,IAAI,CAAC;CAEvE,IAAI,yBAAyB,iBACzB,KAAK,MAAM,GAAG,CAAC,eAAe,OAAO,GACrC,KAAK,MAAM,IAAI,CAAC;CAGpB,MAAM,oBAAoB,QAAQ,MAAM,QACtC,uBAAuB,SAAS,IAAI,MAAM,CAC3C;AACD,KAAI,kBACF,0BAAyB,uBAAuB,MAC9C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,UAAsB,EAAE;AAC9B,OAAK,MAAM,UAAU,YAAY;GAC/B,MAAM,UAAUC,oDAAoB,WAAW,OAAO;AACtD,OAAI,SAAS;IACX,MAAM,MAAM,MAAM,eAAe,SAAS,CAAC,OAAO,EAAE,KAAK;AACzD,YAAQ,KAAK,GAAG,IAAI;;;AAGxB,SAAO,gBAAgB,QAAQ;;AAIjC,QAAO,eAAe,WAAW,WAAW"}
1
+ {"version":3,"file":"formatFillData.cjs","names":["resolveOutputPattern","getPatternForLocale"],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import { basename, dirname, extname, relative } from 'node:path';\nimport { getFormatFromExtension } from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryKey, Fill } from '@intlayer/types/dictionary';\nimport type { FilePathPatternContext } from '@intlayer/types/filePathPattern';\nimport {\n getPatternForLocale,\n resolveOutputPattern,\n} from '../utils/getOutputFilePath';\n\nexport type FillData = {\n localeList: Locale[];\n filePath: string;\n isPerLocale: boolean;\n};\n\n/** Merge FillData entries that resolve to the same file path. */\nconst groupByFilePath = (entries: FillData[]): FillData[] =>\n entries.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n for (const loc of curr.localeList) {\n if (!existing.localeList.includes(loc)) existing.localeList.push(loc);\n }\n // Multiple locales sharing one path → multilingual file\n existing.isPerLocale = false;\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\nexport const formatFillData = async (\n fillField: Fill,\n localeList: Locale[],\n filePath: string,\n dictionaryKey: DictionaryKey,\n configuration: IntlayerConfig\n): Promise<FillData[]> => {\n if (!fillField || typeof fillField === 'boolean') return [];\n\n const { baseDir } = configuration.system;\n const { defaultLocale, locales } = configuration.internationalization;\n\n const extension = extname(filePath);\n const base = basename(filePath);\n\n const { fileExtensions } = configuration.content;\n const extensionMatch = fileExtensions.find((ext) => base.endsWith(ext));\n\n let cleanComponentFileName = extensionMatch\n ? base.slice(0, -extensionMatch.length)\n : base.split('.')[0];\n\n // Strip source locale if present\n const sourceLocaleMatch = locales.find((loc) =>\n cleanComponentFileName.endsWith(`.${loc}`)\n );\n if (sourceLocaleMatch) {\n cleanComponentFileName = cleanComponentFileName.slice(\n 0,\n -(sourceLocaleMatch.length + 1)\n );\n }\n\n const uncapitalizedName =\n cleanComponentFileName.charAt(0).toLowerCase() +\n cleanComponentFileName.slice(1);\n const componentFormat = getFormatFromExtension(extension);\n\n const getContext = (\n locale: Locale,\n patternString?: string\n ): FilePathPatternContext => {\n let format: FilePathPatternContext['format'] = 'json';\n if (patternString) {\n const extFormat = getFormatFromExtension(extname(patternString) as any);\n if (extFormat) format = extFormat as any;\n }\n return {\n key: dictionaryKey,\n componentDirPath: relative(baseDir, dirname(filePath)),\n componentFileName: cleanComponentFileName,\n fileName: uncapitalizedName,\n componentFormat:\n componentFormat as FilePathPatternContext['componentFormat'],\n componentExtension:\n extension as FilePathPatternContext['componentExtension'],\n format,\n locale,\n extension:\n configuration.content.fileExtensions.find((ext) =>\n ext.endsWith(extension)\n ) ?? configuration.content.fileExtensions[0],\n };\n };\n\n /**\n * Evaluate a scalar Fill pattern (string or function) for a list of locales.\n *\n * - Uses a dummy locale probe to detect whether the pattern varies per locale.\n * - `forcePerLocale` overrides the probe for object-fill entries where each\n * locale always maps to its own dedicated file regardless of whether the\n * path itself contains the locale string.\n */\n const processPattern = async (\n pattern: Fill,\n locales: Locale[],\n forcePerLocale = false\n ): Promise<FillData[]> => {\n const dummyLocale = '###########locale###########' as Locale;\n const patternString = typeof pattern === 'string' ? pattern : undefined;\n\n const dummyPath = await resolveOutputPattern(\n pattern,\n dummyLocale,\n getContext(dummyLocale, patternString),\n filePath,\n baseDir\n );\n const isPatternPerLocale =\n forcePerLocale ||\n (typeof dummyPath === 'string' && dummyPath.includes(dummyLocale));\n\n if (isPatternPerLocale) {\n const resolvedPaths: FillData[] = [];\n for (const locale of locales) {\n const absolutePath = await resolveOutputPattern(\n pattern,\n locale,\n getContext(locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath !== false) {\n resolvedPaths.push({\n filePath: absolutePath,\n localeList: [locale],\n isPerLocale: true,\n });\n }\n }\n return groupByFilePath(resolvedPaths);\n }\n\n // Single multilingual path — resolve using the default locale for context\n const absolutePath = await resolveOutputPattern(\n pattern,\n defaultLocale as Locale,\n getContext(defaultLocale as Locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath === false) return [];\n return [\n { filePath: absolutePath, localeList: locales, isPerLocale: false },\n ];\n };\n\n // Object fill: each locale key maps to its own pattern.\n // Object fill entries are always per-locale in intent (each locale → its own file).\n if (typeof fillField === 'object' && fillField !== null) {\n const results: FillData[] = [];\n for (const locale of localeList) {\n const pattern = getPatternForLocale(fillField, locale);\n if (pattern) {\n const res = await processPattern(pattern, [locale], true);\n results.push(...res);\n }\n }\n return groupByFilePath(results);\n }\n\n // Scalar string or function pattern\n return processPattern(fillField, localeList);\n};\n"],"mappings":";;;;;;;AAkBA,MAAM,mBAAmB,YACvB,QAAQ,QAAQ,KAAK,SAAS;CAC5B,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,QAAQ;CACnE,IAAI,UAAU;EACZ,KAAK,MAAM,OAAO,KAAK,YACrB,IAAI,CAAC,SAAS,WAAW,SAAS,GAAG,GAAG,SAAS,WAAW,KAAK,GAAG;EAGtE,SAAS,cAAc;CACzB,OACE,IAAI,KAAK,IAAI;CAEf,OAAO;AACT,GAAG,CAAC,CAAe;AAErB,MAAa,iBAAiB,OAC5B,WACA,YACA,UACA,eACA,kBACwB;CACxB,IAAI,CAAC,aAAa,OAAO,cAAc,WAAW,OAAO,CAAC;CAE1D,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,eAAe,YAAY,cAAc;CAEjD,MAAM,mCAAoB,QAAQ;CAClC,MAAM,+BAAgB,QAAQ;CAE9B,MAAM,EAAE,mBAAmB,cAAc;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MAAM;KACnB,aAAa;IACf,CAAC;GAEL;GACA,OAAO,gBAAgB,aAAa;EACtC;EAGA,MAAM,eAAe,MAAMA,qDACzB,SACA,eACA,WAAW,eAAyB,aAAa,GACjD,UACA,OACF;EACA,IAAI,iBAAiB,OAAO,OAAO,CAAC;EACpC,OAAO,CACL;GAAE,UAAU;GAAc,YAAY;GAAS,aAAa;EAAM,CACpE;CACF;CAIA,IAAI,OAAO,cAAc,YAAY,cAAc,MAAM;EACvD,MAAM,UAAsB,CAAC;EAC7B,KAAK,MAAM,UAAU,YAAY;GAC/B,MAAM,UAAUC,oDAAoB,WAAW,MAAM;GACrD,IAAI,SAAS;IACX,MAAM,MAAM,MAAM,eAAe,SAAS,CAAC,MAAM,GAAG,IAAI;IACxD,QAAQ,KAAK,GAAG,GAAG;GACrB;EACF;EACA,OAAO,gBAAgB,OAAO;CAChC;CAGA,OAAO,eAAe,WAAW,UAAU;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"getAvailableLocalesInDictionary.cjs","names":[],"sources":["../../../src/fill/getAvailableLocalesInDictionary.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively traverses dictionary content to find all locales that have actual translations.\n * Returns a Set of locale strings that are present in the translation nodes.\n */\nconst extractLocalesFromContent = (\n content: any,\n locales: Set<Locale> = new Set()\n): Set<Locale> => {\n if (!content || typeof content !== 'object') {\n return locales;\n }\n\n // Check if this is a translation node\n if (content.nodeType === 'translation' && content.translation) {\n // Add all locale keys from the translation map\n Object.keys(content.translation).forEach((locale) => {\n locales.add(locale as Locale);\n });\n }\n\n // Recursively check nested objects\n for (const value of Object.values(content)) {\n if (value && typeof value === 'object') {\n extractLocalesFromContent(value, locales);\n }\n }\n\n return locales;\n};\n\n/**\n * Gets all locales that have actual translations in the dictionary content.\n * Only returns locales that are present in at least one translation node.\n */\nexport const getAvailableLocalesInDictionary = (\n dictionary: Dictionary\n): Locale[] => {\n const localesSet = extractLocalesFromContent(dictionary.content);\n return Array.from(localesSet);\n};\n"],"mappings":";;;;;;;AAOA,MAAM,6BACJ,SACA,0BAAuB,IAAI,KAAK,KAChB;AAChB,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAIT,KAAI,QAAQ,aAAa,iBAAiB,QAAQ,YAEhD,QAAO,KAAK,QAAQ,YAAY,CAAC,SAAS,WAAW;AACnD,UAAQ,IAAI,OAAiB;GAC7B;AAIJ,MAAK,MAAM,SAAS,OAAO,OAAO,QAAQ,CACxC,KAAI,SAAS,OAAO,UAAU,SAC5B,2BAA0B,OAAO,QAAQ;AAI7C,QAAO;;;;;;AAOT,MAAa,mCACX,eACa;CACb,MAAM,aAAa,0BAA0B,WAAW,QAAQ;AAChE,QAAO,MAAM,KAAK,WAAW"}
1
+ {"version":3,"file":"getAvailableLocalesInDictionary.cjs","names":[],"sources":["../../../src/fill/getAvailableLocalesInDictionary.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively traverses dictionary content to find all locales that have actual translations.\n * Returns a Set of locale strings that are present in the translation nodes.\n */\nconst extractLocalesFromContent = (\n content: any,\n locales: Set<Locale> = new Set()\n): Set<Locale> => {\n if (!content || typeof content !== 'object') {\n return locales;\n }\n\n // Check if this is a translation node\n if (content.nodeType === 'translation' && content.translation) {\n // Add all locale keys from the translation map\n Object.keys(content.translation).forEach((locale) => {\n locales.add(locale as Locale);\n });\n }\n\n // Recursively check nested objects\n for (const value of Object.values(content)) {\n if (value && typeof value === 'object') {\n extractLocalesFromContent(value, locales);\n }\n }\n\n return locales;\n};\n\n/**\n * Gets all locales that have actual translations in the dictionary content.\n * Only returns locales that are present in at least one translation node.\n */\nexport const getAvailableLocalesInDictionary = (\n dictionary: Dictionary\n): Locale[] => {\n const localesSet = extractLocalesFromContent(dictionary.content);\n return Array.from(localesSet);\n};\n"],"mappings":";;;;;;;AAOA,MAAM,6BACJ,SACA,0BAAuB,IAAI,IAAI,MACf;CAChB,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAIT,IAAI,QAAQ,aAAa,iBAAiB,QAAQ,aAEhD,OAAO,KAAK,QAAQ,WAAW,CAAC,CAAC,SAAS,WAAW;EACnD,QAAQ,IAAI,MAAgB;CAC9B,CAAC;CAIH,KAAK,MAAM,SAAS,OAAO,OAAO,OAAO,GACvC,IAAI,SAAS,OAAO,UAAU,UAC5B,0BAA0B,OAAO,OAAO;CAI5C,OAAO;AACT;;;;;AAMA,MAAa,mCACX,eACa;CACb,MAAM,aAAa,0BAA0B,WAAW,OAAO;CAC/D,OAAO,MAAM,KAAK,UAAU;AAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFilterMissingContentPerLocale.cjs","names":[],"sources":["../../../src/fill/getFilterMissingContentPerLocale.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively compares source content with target content and returns only the missing parts.\n * For per-locale files where content is simple JSON (not translation nodes).\n *\n * @param sourceContent - The source content to check\n * @param targetContent - The existing target content\n * @returns Only the content that's missing in the target\n */\nconst filterMissingContent = (sourceContent: any, targetContent: any): any => {\n // Source is null - only missing if target doesn't already have null\n if (sourceContent === null) {\n return targetContent === null ? undefined : null;\n }\n\n // If target doesn't exist or is null, all source content is missing\n if (targetContent === undefined || targetContent === null) {\n return sourceContent;\n }\n\n // Primitive values: if target exists (even if empty string), consider it translated\n if (typeof sourceContent !== 'object') {\n return undefined;\n }\n\n // Handle arrays\n if (Array.isArray(sourceContent)) {\n if (!Array.isArray(targetContent)) {\n return sourceContent;\n }\n\n const missingItems = sourceContent\n .map((item, index) => filterMissingContent(item, targetContent[index]))\n .filter((item) => item !== undefined);\n\n return missingItems.length > 0 ? missingItems : undefined;\n }\n\n // Handle objects\n const result: any = {};\n let hasMissingContent = false;\n\n for (const [key, value] of Object.entries(sourceContent)) {\n const targetValue = targetContent?.[key];\n const missingValue = filterMissingContent(value, targetValue);\n\n if (missingValue !== undefined) {\n result[key] = missingValue;\n hasMissingContent = true;\n }\n }\n\n return hasMissingContent ? result : undefined;\n};\n\n/**\n * Filters a dictionary to only include content that's missing in the target dictionary.\n * Used for per-locale content declarations in 'complete' mode.\n *\n * @param sourceDictionary - The source dictionary with content to translate\n * @param targetDictionary - The existing target dictionary\n * @returns A dictionary with only the missing content\n */\nexport const getFilterMissingContentPerLocale = (\n sourceDictionary: Dictionary,\n targetDictionary: Dictionary | undefined\n): Dictionary => {\n if (!targetDictionary || !targetDictionary.content) {\n // If no target exists, all source content is missing\n return sourceDictionary;\n }\n\n const missingContent = filterMissingContent(\n sourceDictionary.content,\n targetDictionary.content\n );\n\n return {\n ...sourceDictionary,\n content: missingContent ?? {},\n };\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,eAAoB,kBAA4B;AAE5E,KAAI,kBAAkB,KACpB,QAAO,kBAAkB,OAAO,SAAY;AAI9C,KAAI,kBAAkB,UAAa,kBAAkB,KACnD,QAAO;AAIT,KAAI,OAAO,kBAAkB,SAC3B;AAIF,KAAI,MAAM,QAAQ,cAAc,EAAE;AAChC,MAAI,CAAC,MAAM,QAAQ,cAAc,CAC/B,QAAO;EAGT,MAAM,eAAe,cAClB,KAAK,MAAM,UAAU,qBAAqB,MAAM,cAAc,OAAO,CAAC,CACtE,QAAQ,SAAS,SAAS,OAAU;AAEvC,SAAO,aAAa,SAAS,IAAI,eAAe;;CAIlD,MAAM,SAAc,EAAE;CACtB,IAAI,oBAAoB;AAExB,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,cAAc,EAAE;EACxD,MAAM,cAAc,gBAAgB;EACpC,MAAM,eAAe,qBAAqB,OAAO,YAAY;AAE7D,MAAI,iBAAiB,QAAW;AAC9B,UAAO,OAAO;AACd,uBAAoB;;;AAIxB,QAAO,oBAAoB,SAAS;;;;;;;;;;AAWtC,MAAa,oCACX,kBACA,qBACe;AACf,KAAI,CAAC,oBAAoB,CAAC,iBAAiB,QAEzC,QAAO;CAGT,MAAM,iBAAiB,qBACrB,iBAAiB,SACjB,iBAAiB,QAClB;AAED,QAAO;EACL,GAAG;EACH,SAAS,kBAAkB,EAAE;EAC9B"}
1
+ {"version":3,"file":"getFilterMissingContentPerLocale.cjs","names":[],"sources":["../../../src/fill/getFilterMissingContentPerLocale.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively compares source content with target content and returns only the missing parts.\n * For per-locale files where content is simple JSON (not translation nodes).\n *\n * @param sourceContent - The source content to check\n * @param targetContent - The existing target content\n * @returns Only the content that's missing in the target\n */\nconst filterMissingContent = (sourceContent: any, targetContent: any): any => {\n // Source is null - only missing if target doesn't already have null\n if (sourceContent === null) {\n return targetContent === null ? undefined : null;\n }\n\n // If target doesn't exist or is null, all source content is missing\n if (targetContent === undefined || targetContent === null) {\n return sourceContent;\n }\n\n // Primitive values: if target exists (even if empty string), consider it translated\n if (typeof sourceContent !== 'object') {\n return undefined;\n }\n\n // Handle arrays\n if (Array.isArray(sourceContent)) {\n if (!Array.isArray(targetContent)) {\n return sourceContent;\n }\n\n const missingItems = sourceContent\n .map((item, index) => filterMissingContent(item, targetContent[index]))\n .filter((item) => item !== undefined);\n\n return missingItems.length > 0 ? missingItems : undefined;\n }\n\n // Handle objects\n const result: any = {};\n let hasMissingContent = false;\n\n for (const [key, value] of Object.entries(sourceContent)) {\n const targetValue = targetContent?.[key];\n const missingValue = filterMissingContent(value, targetValue);\n\n if (missingValue !== undefined) {\n result[key] = missingValue;\n hasMissingContent = true;\n }\n }\n\n return hasMissingContent ? result : undefined;\n};\n\n/**\n * Filters a dictionary to only include content that's missing in the target dictionary.\n * Used for per-locale content declarations in 'complete' mode.\n *\n * @param sourceDictionary - The source dictionary with content to translate\n * @param targetDictionary - The existing target dictionary\n * @returns A dictionary with only the missing content\n */\nexport const getFilterMissingContentPerLocale = (\n sourceDictionary: Dictionary,\n targetDictionary: Dictionary | undefined\n): Dictionary => {\n if (!targetDictionary || !targetDictionary.content) {\n // If no target exists, all source content is missing\n return sourceDictionary;\n }\n\n const missingContent = filterMissingContent(\n sourceDictionary.content,\n targetDictionary.content\n );\n\n return {\n ...sourceDictionary,\n content: missingContent ?? {},\n };\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,eAAoB,kBAA4B;CAE5E,IAAI,kBAAkB,MACpB,OAAO,kBAAkB,OAAO,SAAY;CAI9C,IAAI,kBAAkB,UAAa,kBAAkB,MACnD,OAAO;CAIT,IAAI,OAAO,kBAAkB,UAC3B;CAIF,IAAI,MAAM,QAAQ,aAAa,GAAG;EAChC,IAAI,CAAC,MAAM,QAAQ,aAAa,GAC9B,OAAO;EAGT,MAAM,eAAe,cAClB,KAAK,MAAM,UAAU,qBAAqB,MAAM,cAAc,MAAM,CAAC,CAAC,CACtE,QAAQ,SAAS,SAAS,MAAS;EAEtC,OAAO,aAAa,SAAS,IAAI,eAAe;CAClD;CAGA,MAAM,SAAc,CAAC;CACrB,IAAI,oBAAoB;CAExB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,aAAa,GAAG;EACxD,MAAM,cAAc,gBAAgB;EACpC,MAAM,eAAe,qBAAqB,OAAO,WAAW;EAE5D,IAAI,iBAAiB,QAAW;GAC9B,OAAO,OAAO;GACd,oBAAoB;EACtB;CACF;CAEA,OAAO,oBAAoB,SAAS;AACtC;;;;;;;;;AAUA,MAAa,oCACX,kBACA,qBACe;CACf,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,SAEzC,OAAO;CAGT,MAAM,iBAAiB,qBACrB,iBAAiB,SACjB,iBAAiB,OACnB;CAEA,OAAO;EACL,GAAG;EACH,SAAS,kBAAkB,CAAC;CAC9B;AACF"}
@@ -2,10 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_test_listMissingTranslations = require('../test/listMissingTranslations.cjs');
4
4
  let node_path = require("node:path");
5
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
6
5
  let _intlayer_config_colors = require("@intlayer/config/colors");
7
6
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
8
7
  let _intlayer_config_logger = require("@intlayer/config/logger");
8
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
9
9
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
10
10
  let _intlayer_core_plugins = require("@intlayer/core/plugins");
11
11
  let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
@@ -42,7 +42,7 @@ const listTranslationsTasks = (localIds, outputLocales, mode, baseLocale, config
42
42
  }
43
43
  const sourceLocaleContent = (0, _intlayer_core_plugins.getFilterTranslationsOnlyDictionary)(mainDictionaryToProcess, sourceLocale);
44
44
  if (Object.keys(sourceLocaleContent).length === 0) {
45
- appLogger(`${dictionaryPreset} No content found for dictionary in source locale ${(0, _intlayer_chokidar_utils.formatLocale)(sourceLocale)}. Skipping translation for this dictionary.`, { level: "warn" });
45
+ appLogger(`${dictionaryPreset} No content found for dictionary in source locale ${(0, _intlayer_engine_utils.formatLocale)(sourceLocale)}. Skipping translation for this dictionary.`, { level: "warn" });
46
46
  continue;
47
47
  }
48
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"listTranslationsTasks.cjs","names":["listMissingTranslationsWithConfig","ANSIColors"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getFilterTranslationsOnlyDictionary } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { listMissingTranslationsWithConfig } from '../test';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const { missingTranslations } =\n listMissingTranslationsWithConfig(configuration);\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dictionary) => dictionary.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFilled = targetUnmergedDictionary.filled ?? false;\n\n if (dictionaryFilled === true) {\n continue;\n }\n\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n outputLocalesList =\n missingTranslations\n .find(\n (missingTranslation) => missingTranslation.key === dictionaryKey\n )\n ?.locales.filter((locale) => outputLocales.includes(locale)) ?? [];\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} ${colorize('No locales to fill, Skipping', ANSIColors.GREY_DARK)} ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n // Return the list of tasks to execute\n return translationTasks;\n};\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,sDAAyB,cAAc;CAE7C,MAAM,6EAA2C,cAAc;CAC/D,MAAM,gGAAqD,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MACrB,CAAC,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM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pB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAIJ,QAAO"}
1
+ {"version":3,"file":"listTranslationsTasks.cjs","names":["listMissingTranslationsWithConfig","ANSIColors"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getFilterTranslationsOnlyDictionary } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { formatLocale } from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { listMissingTranslationsWithConfig } from '../test';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const { missingTranslations } =\n listMissingTranslationsWithConfig(configuration);\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dictionary) => dictionary.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFilled = targetUnmergedDictionary.filled ?? false;\n\n if (dictionaryFilled === true) {\n continue;\n }\n\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n outputLocalesList =\n missingTranslations\n .find(\n (missingTranslation) => missingTranslation.key === dictionaryKey\n )\n ?.locales.filter((locale) => outputLocales.includes(locale)) ?? [];\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} ${colorize('No locales to fill, Skipping', ANSIColors.GREY_DARK)} ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n // Return the list of tasks to execute\n return translationTasks;\n};\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,sDAAyB,aAAa;CAE5C,MAAM,6EAA2C,aAAa;CAC9D,MAAM,gGAAqD,aAAa;CAGxE,MAAM,wBADsB,OAAO,OAAO,0BAA0B,CAAC,CAAC,KACtB,CAAC,CAAC,QAAQ,eACxD,SAAS,SAAS,WAAW,OAAQ,CACvC;CAEA,MAAM,EAAE,wBACNA,uEAAkC,aAAa;CAEjD,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,eAAe,WAAW,IAAI,MAAM,CACpE;CAEA,MAAM,mBAAsC,CAAC;CAE7C,KAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,sDACJ;GACE;yCACS,KAAKC,wBAAW,SAAS;4CACtB,yBAAyB,GAAG;yCAC/B,KAAKA,wBAAW,SAAS;EACpC,CAAC,CAAC,KAAK,EAAE,GACT,EAAE,SAAS,eAAe,EAAE,CAC9B;EAEA,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAM,0BACJ,yBAAyB;EAG3B,KAFyB,yBAAyB,UAAU,WAEnC,MACvB;EAMF,KAFE,yBAAyB,QAAQ,cAAc,YAAY,QAAQ,WAE9C,OAAO;EAE9B,MAAM,eAAwB,yBAAyB,UACrD;EAEF,IAAI,CAAC,yBAAyB;GAC5B,UACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,OACT,CACF;GACA;EACF;EAEA,IAAI,CAAC,yBAAyB,UAAU;GACtC,UAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,OACT,CAAC;GACD;EACF;EAEA,MAAM,sFACJ,yBACA,YACF;EAEA,IACE,OAAO,KAAK,mBAA8C,CAAC,CAAC,WAAW,GACvE;GACA,UACE,GAAG,iBAAiB,6FAAiE,YAAY,EAAE,8CACnG,EACE,OAAO,OACT,CACF;GACA;EACF;;;;;;EAOA,IAAI,oBAA8B;EAElC,IAAI,SAAS,YACX,oBACE,oBACG,MACE,uBAAuB,mBAAmB,QAAQ,aACrD,CAAC,EACC,QAAQ,QAAQ,WAAW,cAAc,SAAS,MAAM,CAAC,KAAK,CAAC;EAGvE,IAAI,kBAAkB,WAAW,GAAG;GAClC,UACE,GAAG,iBAAiB,yCAAY,gCAAgCA,wBAAW,SAAS,EAAE,qEAAyB,yBAAyB,QAAQ,CAAC,KACjJ,EACE,OAAO,OACT,CACF;GACA;EACF;EAEA,iBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;EAC/C,CAAC;CACH;CAGA,OAAO;AACT"}
@@ -4,10 +4,10 @@ const require_utils_checkAccess = require('../utils/checkAccess.cjs');
4
4
  const require_fill_deepMergeContent = require('./deepMergeContent.cjs');
5
5
  const require_fill_extractTranslatableContent = require('./extractTranslatableContent.cjs');
6
6
  let node_path = require("node:path");
7
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
8
7
  let _intlayer_config_colors = require("@intlayer/config/colors");
9
8
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
10
9
  let _intlayer_config_logger = require("@intlayer/config/logger");
10
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
11
11
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
12
12
  let _intlayer_core_plugins = require("@intlayer/core/plugins");
13
13
  let _intlayer_config_utils = require("@intlayer/config/utils");
@@ -105,22 +105,22 @@ const translateDictionary = async (task, configuration, options) => {
105
105
  }
106
106
  if (mode === "complete") dictionaryToProcess = {
107
107
  ...dictionaryToProcess,
108
- content: (0, _intlayer_chokidar_utils.excludeObjectFormat)(dictionaryToProcess.content, targetLocaleDictionary.content) ?? {}
108
+ content: (0, _intlayer_engine_utils.excludeObjectFormat)(dictionaryToProcess.content, targetLocaleDictionary.content) ?? {}
109
109
  };
110
110
  const localePreset = (0, _intlayer_config_logger.colon)([
111
111
  (0, _intlayer_config_logger.colorize)("[", _intlayer_config_colors.GREY_DARK),
112
- (0, _intlayer_chokidar_utils.formatLocale)(targetLocale),
112
+ (0, _intlayer_engine_utils.formatLocale)(targetLocale),
113
113
  (0, _intlayer_config_logger.colorize)("]", _intlayer_config_colors.GREY_DARK)
114
114
  ].join(""), { colSize: 18 });
115
115
  appLogger(`${task.dictionaryPreset}${localePreset} Preparing ${(0, _intlayer_config_logger.colorizePath)((0, node_path.basename)(targetLocaleDictionary.filePath))}`, { level: "info" });
116
- const chunkedJsonContent = (0, _intlayer_chokidar_utils.chunkJSON)(dictionaryToProcess.content, CHUNK_SIZE);
116
+ const chunkedJsonContent = (0, _intlayer_engine_utils.chunkJSON)(dictionaryToProcess.content, CHUNK_SIZE);
117
117
  const nbOfChunks = chunkedJsonContent.length;
118
118
  if (nbOfChunks > 1) appLogger(`${task.dictionaryPreset}${localePreset} Split into ${(0, _intlayer_config_logger.colorizeNumber)(nbOfChunks)} chunks for translation`, { level: "info" });
119
119
  const chunkResult = [];
120
120
  const chunkPromises = chunkedJsonContent.map(async (chunk) => {
121
121
  const chunkPreset = createChunkPreset(chunk.index, chunk.total);
122
122
  if (nbOfChunks > 1) appLogger(`${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`, { level: "info" });
123
- const reconstructedChunk = (0, _intlayer_chokidar_utils.reconstructFromSingleChunk)(chunk);
123
+ const reconstructedChunk = (0, _intlayer_engine_utils.reconstructFromSingleChunk)(chunk);
124
124
  const { extractedContent: chunkExtractedContent, translatableDictionary: chunkTranslatableDictionary } = require_fill_extractTranslatableContent.extractTranslatableContent(reconstructedChunk);
125
125
  const executeTranslation = async () => {
126
126
  return await (0, _intlayer_config_utils.retryManager)(async () => {
@@ -144,7 +144,7 @@ const translateDictionary = async (task, configuration, options) => {
144
144
  aiOptions
145
145
  }).then((result) => result.data);
146
146
  if (!translationResult?.fileContent) throw new Error("No content result");
147
- const { isIdentic, error } = (0, _intlayer_chokidar_utils.verifyIdenticObjectFormat)(translationResult.fileContent, chunkTranslatableDictionary);
147
+ const { isIdentic, error } = (0, _intlayer_engine_utils.verifyIdenticObjectFormat)(translationResult.fileContent, chunkTranslatableDictionary);
148
148
  if (!isIdentic) throw new Error(`Translation result does not match expected format: ${error}`);
149
149
  notifySuccess();
150
150
  return require_fill_extractTranslatableContent.reinsertTranslatedContent(reconstructedChunk, chunkExtractedContent, translationResult.fileContent);
@@ -170,7 +170,7 @@ const translateDictionary = async (task, configuration, options) => {
170
170
  (await Promise.all(chunkPromises)).sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index).forEach(({ result }) => {
171
171
  chunkResult.push(result);
172
172
  });
173
- const reinsertedContent = (0, _intlayer_chokidar_utils.mergeChunks)(chunkResult);
173
+ const reinsertedContent = (0, _intlayer_engine_utils.mergeChunks)(chunkResult);
174
174
  const merged = {
175
175
  ...dictionaryToProcess,
176
176
  content: reinsertedContent
@@ -1 +1 @@
1
- {"version":3,"file":"translateDictionary.cjs","names":["ANSIColors","getAuthenticatedAPI","extractTranslatableContent","reinsertTranslatedContent","deepMergeContent"],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n chunkJSON,\n excludeObjectFormat,\n formatLocale,\n type JsonChunk,\n mergeChunks,\n reconstructFromSingleChunk,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { getAuthenticatedAPI } from '../utils/checkAccess';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport {\n extractTranslatableContent,\n reinsertTranslatedContent,\n} from './extractTranslatableContent';\nimport type { TranslationTask } from './listTranslationsTasks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst createChunkPreset = (chunkIndex: number, totalChunks: number) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst serializeError = (error: unknown): string => {\n if (error instanceof Error) {\n return error.cause\n ? `${error.message} (cause: ${String(error.cause)})`\n : error.message;\n }\n if (typeof error === 'string') return error;\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n};\n\nconst CHUNK_SIZE = 4000;\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = await getAuthenticatedAPI(configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Look up the target locale dictionary by its locale property.\n // This handles both directory-based paths (/en/file.json → /es/file.json)\n // AND filename-based paths (messages_ICU/en.json → messages_ICU/es.json).\n // Plugins like syncJSON set `dict.locale` correctly, so matching by locale\n // is the only reliable strategy — path string-replacement fails when the\n // locale appears in the filename rather than a directory segment.\n const targetUnmergedDictionary = unmergedDictionariesRecord[\n task.dictionaryKey\n ]?.find(\n (dict) =>\n dict.locale === targetLocale &&\n dict.filePath !== baseUnmergedDictionary.filePath\n );\n\n // Derive the target file path for the fallback (when the file doesn't exist yet).\n // Try directory-style first (/en/ → /es/), then filename-style (en.json → es.json).\n const sourceFilePath = baseUnmergedDictionary.filePath ?? '';\n const derivedTargetFilePath = sourceFilePath.includes(\n `/${task.sourceLocale}/`\n )\n ? sourceFilePath.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n )\n : sourceFilePath.replace(\n new RegExp(`(^|/)${task.sourceLocale}(\\\\.[^/]+)$`),\n `$1${targetLocale}$2`\n );\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: derivedTargetFilePath || undefined,\n locale: targetLocale,\n };\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n // Filter to only untranslated fields, preserving explicit null values as\n // default-locale fallback markers. Applied after both paths converge so\n // the same logic covers per-locale and multilingual dictionaries.\n if (mode === 'complete') {\n dictionaryToProcess = {\n ...dictionaryToProcess,\n content:\n excludeObjectFormat(\n dictionaryToProcess.content,\n targetLocaleDictionary.content\n ) ?? {},\n };\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n dictionaryToProcess.content as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map(async (chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n const reconstructedChunk = reconstructFromSingleChunk(chunk);\n const {\n extractedContent: chunkExtractedContent,\n translatableDictionary: chunkTranslatableDictionary,\n } = extractTranslatableContent(reconstructedChunk);\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent:\n chunkTranslatableDictionary as unknown as JSON,\n presetOutputContent: chunkTranslatableDictionary,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent:\n chunkTranslatableDictionary as unknown as JSON,\n presetOutputContent: chunkTranslatableDictionary,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic, error } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkTranslatableDictionary\n );\n\n if (!isIdentic) {\n throw new Error(\n `Translation result does not match expected format: ${error}`\n );\n }\n\n notifySuccess();\n return reinsertTranslatedContent(\n reconstructedChunk,\n chunkExtractedContent,\n translationResult.fileContent as Record<number, string>\n );\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge translated chunk contents back into a single content object\n const reinsertedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: reinsertedContent,\n };\n\n // Merge newly translated content (including explicit null fallbacks) back\n // into the existing target locale content. Applies to both per-locale and\n // multilingual paths so the target always retains previously translated\n // fields and receives null markers where the source has no translation.\n const finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n merged.content\n );\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n // The dict-level `fill` value may have been lost during JSON serialisation\n // (functions can't be serialised to JSON). Fall back to the config-level\n // fill so that an explicit fill in intlayer.config.ts is honoured.\n const effectiveFillForCheck =\n baseUnmergedDictionary.fill ?? configuration.dictionary?.fill;\n\n if (\n baseUnmergedDictionary.locale &&\n (effectiveFillForCheck === true ||\n effectiveFillForCheck === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0DA,MAAM,qBAAqB,YAAoB,gBAAwB;AACrE,KAAI,eAAe,EAAG,QAAO;AAC7B,2CACE;wCACW,KAAKA,wBAAW,UAAU;8CACpB,aAAa,EAAE;wCACrB,IAAI,eAAeA,wBAAW,UAAU;wCACxC,KAAKA,wBAAW,UAAU;EACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,GAAG,CACf;;AAGH,MAAM,sBAAsB,eAC1B,CAAC,WAAW,eAAe,CAAC,WAAW,SAAS,CAAC,WAAW;AAE9D,MAAM,kBAAkB,UAA2B;AACjD,KAAI,iBAAiB,MACnB,QAAO,MAAM,QACT,GAAG,MAAM,QAAQ,WAAW,OAAO,MAAM,MAAM,CAAC,KAChD,MAAM;AAEZ,KAAI,OAAO,UAA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AAU;IACb,GAAG;IACH,kBAAkB;KAChB,GAAG;KACH,MAAM;KACN,QAAQ;KACT;IACF,CAAC,CAAC,WACD,IAAI,OAAO,MAAM,aAAa,kBAAkB,IAAI,EACpD,WAAW,aAAa,OACzB,CACF;;AAGH,SAAO;GACL,GAAG;GACH;GACD;IAEH;EACE,UAAU;EACV,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,eAC1B,UACE,GAAG,KAAK,iBAAiB,yCAAY,UAAUA,wBAAW,IAAI,CAAC,yCAAY,eAAe,MAAM,EAAEA,wBAAW,UAAU,CAAC,yDAA4B,UAAU,EAAE,CAAC,kDAAqB,SAAS,IAC/L,EACE,OAAO,SACR,CACF;EACH,kBAAkB,EAAE,YAClB,UACE,GAAG,KAAK,iBAAiB,yCAAY,sCAAsCA,wBAAW,IAAI,CAAC,yCAAY,eAAe,MAAM,EAAEA,wBAAW,UAAU,IACnJ,EACE,OAAO,SACR,CACF;EACJ,CACF,EAAE"}
1
+ {"version":3,"file":"translateDictionary.cjs","names":["ANSIColors","getAuthenticatedAPI","extractTranslatableContent","reinsertTranslatedContent","deepMergeContent"],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport {\n chunkJSON,\n excludeObjectFormat,\n formatLocale,\n type JsonChunk,\n mergeChunks,\n reconstructFromSingleChunk,\n verifyIdenticObjectFormat,\n} from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { getAuthenticatedAPI } from '../utils/checkAccess';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport {\n extractTranslatableContent,\n reinsertTranslatedContent,\n} from './extractTranslatableContent';\nimport type { TranslationTask } from './listTranslationsTasks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/engine/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst createChunkPreset = (chunkIndex: number, totalChunks: number) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst serializeError = (error: unknown): string => {\n if (error instanceof Error) {\n return error.cause\n ? `${error.message} (cause: ${String(error.cause)})`\n : error.message;\n }\n if (typeof error === 'string') return error;\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n};\n\nconst CHUNK_SIZE = 4000;\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = await getAuthenticatedAPI(configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Look up the target locale dictionary by its locale property.\n // This handles both directory-based paths (/en/file.json → /es/file.json)\n // AND filename-based paths (messages_ICU/en.json → messages_ICU/es.json).\n // Plugins like syncJSON set `dict.locale` correctly, so matching by locale\n // is the only reliable strategy — path string-replacement fails when the\n // locale appears in the filename rather than a directory segment.\n const targetUnmergedDictionary = unmergedDictionariesRecord[\n task.dictionaryKey\n ]?.find(\n (dict) =>\n dict.locale === targetLocale &&\n dict.filePath !== baseUnmergedDictionary.filePath\n );\n\n // Derive the target file path for the fallback (when the file doesn't exist yet).\n // Try directory-style first (/en/ → /es/), then filename-style (en.json → es.json).\n const sourceFilePath = baseUnmergedDictionary.filePath ?? '';\n const derivedTargetFilePath = sourceFilePath.includes(\n `/${task.sourceLocale}/`\n )\n ? sourceFilePath.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n )\n : sourceFilePath.replace(\n new RegExp(`(^|/)${task.sourceLocale}(\\\\.[^/]+)$`),\n `$1${targetLocale}$2`\n );\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: derivedTargetFilePath || undefined,\n locale: targetLocale,\n };\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n // Filter to only untranslated fields, preserving explicit null values as\n // default-locale fallback markers. Applied after both paths converge so\n // the same logic covers per-locale and multilingual dictionaries.\n if (mode === 'complete') {\n dictionaryToProcess = {\n ...dictionaryToProcess,\n content:\n excludeObjectFormat(\n dictionaryToProcess.content,\n targetLocaleDictionary.content\n ) ?? {},\n };\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n dictionaryToProcess.content as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map(async (chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n const reconstructedChunk = reconstructFromSingleChunk(chunk);\n const {\n extractedContent: chunkExtractedContent,\n translatableDictionary: chunkTranslatableDictionary,\n } = extractTranslatableContent(reconstructedChunk);\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent:\n chunkTranslatableDictionary as unknown as JSON,\n presetOutputContent: chunkTranslatableDictionary,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent:\n chunkTranslatableDictionary as unknown as JSON,\n presetOutputContent: chunkTranslatableDictionary,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic, error } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkTranslatableDictionary\n );\n\n if (!isIdentic) {\n throw new Error(\n `Translation result does not match expected format: ${error}`\n );\n }\n\n notifySuccess();\n return reinsertTranslatedContent(\n reconstructedChunk,\n chunkExtractedContent,\n translationResult.fileContent as Record<number, string>\n );\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge translated chunk contents back into a single content object\n const reinsertedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: reinsertedContent,\n };\n\n // Merge newly translated content (including explicit null fallbacks) back\n // into the existing target locale content. Applies to both per-locale and\n // multilingual paths so the target always retains previously translated\n // fields and receives null markers where the source has no translation.\n const finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n merged.content\n );\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n // The dict-level `fill` value may have been lost during JSON serialisation\n // (functions can't be serialised to JSON). Fall back to the config-level\n // fill so that an explicit fill in intlayer.config.ts is honoured.\n const effectiveFillForCheck =\n baseUnmergedDictionary.fill ?? configuration.dictionary?.fill;\n\n if (\n baseUnmergedDictionary.locale &&\n (effectiveFillForCheck === true ||\n effectiveFillForCheck === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(serializeError(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0DA,MAAM,qBAAqB,YAAoB,gBAAwB;CACrE,IAAI,eAAe,GAAG,OAAO;CAC7B,0CACE;wCACW,KAAKA,wBAAW,SAAS;8CACnB,aAAa,CAAC;wCACpB,IAAI,eAAeA,wBAAW,SAAS;wCACvC,KAAKA,wBAAW,SAAS;CACpC,CAAC,CAAC,KAAK,EAAE,GACT,EAAE,SAAS,EAAE,CACf;AACF;AAEA,MAAM,sBAAsB,eAC1B,CAAC,WAAW,eAAe,CAAC,WAAW,SAAS,CAAC,WAAW;AAE9D,MAAM,kBAAkB,UAA2B;CACjD,IAAI,iBAAiB,OACnB,OAAO,MAAM,QACT,GAAG,MAAM,QAAQ,WAAW,OAAO,MAAM,KAAK,EAAE,KAChD,MAAM;CAEZ,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;AAEA,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MA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KAChB,GAAG;KACH,MAAM;KACN,QAAQ;IACV;GACF,CAAC,CAAC,CAAC,WACD,IAAI,OAAO,MAAM,aAAa,kBAAkB,GAAG,GACnD,WAAW,aAAa,MAC1B,CACF;EACF;EAEA,OAAO;GACL,GAAG;GACH;EACF;CACF,GACA;EACE,UAAU;EACV,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,eAC1B,UACE,GAAG,KAAK,iBAAiB,yCAAY,UAAUA,wBAAW,GAAG,EAAE,yCAAY,eAAe,KAAK,GAAGA,wBAAW,SAAS,EAAE,yDAA4B,UAAU,CAAC,EAAE,kDAAqB,QAAQ,KAC9L,EACE,OAAO,QACT,CACF;EACF,kBAAkB,EAAE,YAClB,UACE,GAAG,KAAK,iBAAiB,yCAAY,sCAAsCA,wBAAW,GAAG,EAAE,yCAAY,eAAe,KAAK,GAAGA,wBAAW,SAAS,KAClJ,EACE,OAAO,QACT,CACF;CACJ,CACF,CAAC,CAAC;AAGJ"}
@@ -1,11 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_fill_formatFillData = require('./formatFillData.cjs');
4
3
  const require_fill_getAvailableLocalesInDictionary = require('./getAvailableLocalesInDictionary.cjs');
5
4
  let node_path = require("node:path");
6
- let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
7
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
8
5
  let _intlayer_config_logger = require("@intlayer/config/logger");
6
+ let _intlayer_engine_build = require("@intlayer/engine/build");
7
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
9
8
  let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
10
9
 
11
10
  //#region src/fill/writeFill.ts
@@ -36,15 +35,15 @@ const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, c
36
35
  continue;
37
36
  }
38
37
  const { fill, ...rest } = contentDeclarationFile;
39
- await (0, _intlayer_chokidar_build.writeContentDeclaration)({
38
+ await (0, _intlayer_engine_build.writeContentDeclaration)({
40
39
  ...rest,
41
40
  filled: true,
42
41
  locale: output.isPerLocale ? output.localeList[0] : void 0,
43
42
  localId: `${contentDeclarationFile.key}::local::${output.filePath}`,
44
43
  filePath: (0, node_path.resolve)(configuration.system.baseDir, output.filePath)
45
44
  }, configuration, { localeList: output.isPerLocale ? output.localeList : outputLocales ?? configuration.internationalization.locales });
46
- if (output.isPerLocale) appLogger(`Auto filled per-locale content declaration for '${(0, _intlayer_config_logger.colorizeKey)(fullDictionary.key)}' written to ${(0, _intlayer_chokidar_utils.formatPath)(output.filePath)} for locale ${(0, _intlayer_chokidar_utils.formatLocale)(output.localeList[0])}`, { level: "info" });
47
- else appLogger(`Auto filled content declaration for '${(0, _intlayer_config_logger.colorizeKey)(fullDictionary.key)}' written to ${(0, _intlayer_chokidar_utils.formatPath)(output.filePath)}`, { level: "info" });
45
+ if (output.isPerLocale) appLogger(`Auto filled per-locale content declaration for '${(0, _intlayer_config_logger.colorizeKey)(fullDictionary.key)}' written to ${(0, _intlayer_engine_utils.formatPath)(output.filePath)} for locale ${(0, _intlayer_engine_utils.formatLocale)(output.localeList[0])}`, { level: "info" });
46
+ else appLogger(`Auto filled content declaration for '${(0, _intlayer_config_logger.colorizeKey)(fullDictionary.key)}' written to ${(0, _intlayer_engine_utils.formatPath)(output.filePath)}`, { level: "info" });
48
47
  }
49
48
  };
50
49
 
@@ -1 +1 @@
1
- {"version":3,"file":"writeFill.cjs","names":["getAvailableLocalesInDictionary","formatFillData"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { writeContentDeclaration } from '@intlayer/chokidar/build';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, Fill } from '@intlayer/types/dictionary';\nimport { type FillData, formatFillData } from './formatFillData';\nimport { getAvailableLocalesInDictionary } from './getAvailableLocalesInDictionary';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const fillOptions: Fill | undefined =\n contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? true;\n\n if ((fillOptions as boolean) === false) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const requestedLocales: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n // Get locales that actually have translations in the content\n const availableLocales = getAvailableLocalesInDictionary(\n contentDeclarationFile\n );\n\n // Only write files for locales that have actual translations\n const localeList = requestedLocales.filter((locale) =>\n availableLocales.includes(locale)\n );\n\n if (localeList.length === 0) {\n appLogger(\n `No translations available for dictionary '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const fillData: FillData[] = await formatFillData(\n fillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of fillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const { fill, ...rest } = contentDeclarationFile;\n\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${output.filePath}`,\n filePath: resolve(configuration.system.baseDir, output.filePath), // Use absolute path for vscode extension\n },\n configuration,\n {\n // Per-locale files: write only the specific locale.\n // Multilingual files (string/function fill, single output): include all\n // output locales (including source) so the file is complete.\n localeList: output.isPerLocale\n ? output.localeList\n : (outputLocales ?? configuration.internationalization.locales),\n }\n );\n\n if (output.isPerLocale) {\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(output.localeList[0])}`,\n { level: 'info' }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n { level: 'info' }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,sDAAyB,cAAc;CAG7C,MAAM,mEAF+B,cAEF,CAAC,uBAAuB;CAE3D,MAAM,EAAE,aAAa;AAErB,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,cACJ,uBAAuB,QAAQ,cAAc,YAAY,QAAQ;AAEnE,KAAK,gBAA4B,OAAO;AACtC,YACE,uEAA0C,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAGF,MAAM,oBACJ,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC;CAGtD,MAAM,mBAAmBA,6EACvB,uBACD;CAGD,MAAM,aAAa,iBAAiB,QAAQ,WAC1C,iBAAiB,SAAS,OAAO,CAClC;AAED,KAAI,WAAW,WAAW,GAAG;AAC3B,YACE,sFAAyD,eAAe,IAAI,CAAC,IAC7E,EACE,OAAO,QACR,CACF;AACD;;CAGF,MAAM,WAAuB,MAAMC,2CACjC,aACA,YACA,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,UAAU;AACnC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,wGAA2E,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAGF,MAAM,EAAE,MAAM,GAAG,SAAS;AAE1B,8DACE;GACE,GAAG;GACH,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,GAAG,uBAAuB,IAAI,WAAW,OAAO;GACzD,iCAAkB,cAAc,OAAO,SAAS,OAAO,SAAS;GACjE,EACD,eACA,EAIE,YAAY,OAAO,cACf,OAAO,aACN,iBAAiB,cAAc,qBAAqB,SAC1D,CACF;AAED,MAAI,OAAO,YACT,WACE,4FAA+D,eAAe,IAAI,CAAC,wDAA0B,OAAO,SAAS,CAAC,yDAA2B,OAAO,WAAW,GAAG,IAC9K,EAAE,OAAO,QAAQ,CAClB;MAED,WACE,iFAAoD,eAAe,IAAI,CAAC,wDAA0B,OAAO,SAAS,IAClH,EAAE,OAAO,QAAQ,CAClB"}
1
+ {"version":3,"file":"writeFill.cjs","names":["getAvailableLocalesInDictionary","formatFillData"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { writeContentDeclaration } from '@intlayer/engine/build';\nimport { formatLocale, formatPath } from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, Fill } from '@intlayer/types/dictionary';\nimport { type FillData, formatFillData } from './formatFillData';\nimport { getAvailableLocalesInDictionary } from './getAvailableLocalesInDictionary';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const fillOptions: Fill | undefined =\n contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? true;\n\n if ((fillOptions as boolean) === false) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const requestedLocales: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n // Get locales that actually have translations in the content\n const availableLocales = getAvailableLocalesInDictionary(\n contentDeclarationFile\n );\n\n // Only write files for locales that have actual translations\n const localeList = requestedLocales.filter((locale) =>\n availableLocales.includes(locale)\n );\n\n if (localeList.length === 0) {\n appLogger(\n `No translations available for dictionary '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const fillData: FillData[] = await formatFillData(\n fillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of fillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const { fill, ...rest } = contentDeclarationFile;\n\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${output.filePath}`,\n filePath: resolve(configuration.system.baseDir, output.filePath), // Use absolute path for vscode extension\n },\n configuration,\n {\n // Per-locale files: write only the specific locale.\n // Multilingual files (string/function fill, single output): include all\n // output locales (including source) so the file is complete.\n localeList: output.isPerLocale\n ? output.localeList\n : (outputLocales ?? configuration.internationalization.locales),\n }\n );\n\n if (output.isPerLocale) {\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(output.localeList[0])}`,\n { level: 'info' }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n { level: 'info' }\n );\n }\n }\n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eAAe,GAAG,EAAE,sDAA0B,OAAO,QAAQ,EAAE,uDAA2B,OAAO,WAAW,EAAE,KAC7K,EAAE,OAAO,OAAO,CAClB;OAEA,UACE,iFAAoD,eAAe,GAAG,EAAE,sDAA0B,OAAO,QAAQ,KACjH,EAAE,OAAO,OAAO,CAClB;CAEJ;AACF"}
@@ -1,8 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let node_path = require("node:path");
4
- let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
5
3
  let _intlayer_config_node = require("@intlayer/config/node");
4
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
6
5
  let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
7
6
 
8
7
  //#region src/getTargetDictionary.ts
@@ -22,7 +21,7 @@ const getTargetUnmergedDictionaries = async (options) => {
22
21
  if (typeof options?.filter !== "undefined") result = result.filter(options?.filter);
23
22
  const gitOptions = options?.gitOptions;
24
23
  if (gitOptions) {
25
- const gitChangedFiles = await (0, _intlayer_chokidar_cli.listGitFiles)(gitOptions);
24
+ const gitChangedFiles = await (0, _intlayer_engine_cli.listGitFiles)(gitOptions);
26
25
  if (gitChangedFiles) result = result.filter((dict) => {
27
26
  if (!dict.filePath) return false;
28
27
  return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);
@@ -1 +1 @@
1
- {"version":3,"file":"getTargetDictionary.cjs","names":[],"sources":["../../src/getTargetDictionary.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { type ListGitFilesOptions, listGitFiles } from '@intlayer/chokidar/cli';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\n// Arguments for the fill function\nexport type GetTargetDictionaryOptions = {\n file?: string | string[];\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getTargetUnmergedDictionaries = async (\n options?: GetTargetDictionaryOptions\n): Promise<Dictionary[]> => {\n const configuration = getConfiguration(options?.configOptions);\n\n const { baseDir } = configuration.system;\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options?.file !== 'undefined') {\n const fileArray = ensureArray(options?.file);\n const relativeFilePaths = fileArray.map((file) =>\n file.startsWith('/') ? relative(baseDir, file) : join('./', file)\n );\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n // Check for absolute path\n relativeFilePaths.includes(dict.filePath)\n );\n }\n\n if (typeof options?.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options?.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options?.filter !== 'undefined') {\n result = result.filter(options?.filter);\n }\n\n const gitOptions = options?.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if (!dict.filePath) return false;\n\n return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);\n });\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;AASA,MAAa,eAAkB,UAAwB,CAAC,MAAM,CAAC,MAAM;AAarE,MAAa,gCAAgC,OAC3C,YAC0B;CAC1B,MAAM,4DAAiC,SAAS,cAAc;CAE9D,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,gGAAqD,cAAc;CACzE,IAAI,SAAS,OAAO,OAAO,2BAA2B,CAAC,MAAM;AAG7D,KAAI,OAAO,SAAS,SAAS,aAAa;EAExC,MAAM,oBADY,YAAY,SAAS,KACJ,CAAC,KAAK,SACvC,KAAK,WAAW,IAAI,2BAAY,SAAS,KAAK,uBAAQ,MAAM,KAAK,CAClE;AAED,WAAS,OAAO,QACb,SACC,KAAK,YAEL,kBAAkB,SAAS,KAAK,SAAS,CAC5C;;AAGH,KAAI,OAAO,SAAS,SAAS,YAC3B,UAAS,OAAO,QAAQ,SACtB,YAAY,SAAS,KAAK,EAAE,SAAS,KAAK,IAAI,CAC/C;AAGH,KAAI,OAAO,SAAS,iBAAiB,YACnC,UAAS,OAAO,QACb,SAAS,CAAC,YAAY,SAAS,aAAa,EAAE,SAAS,KAAK,IAAI,CAClE;AAGH,KAAI,OAAO,SAAS,eAAe,YACjC,UAAS,OAAO,QAAQ,SACtB,YAAY,SAAS,WAAW,EAAE,SAAS,KAAK,YAAY,GAAG,CAChE;AAGH,KAAI,OAAO,SAAS,WAAW,YAC7B,UAAS,OAAO,OAAO,SAAS,OAAO;CAGzC,MAAM,aAAa,SAAS;AAC5B,KAAI,YAAY;EACd,MAAM,kBAAkB,+CAAmB,WAAW;AAEtD,MAAI,gBAIF,UAAS,OAAO,QAAQ,SAAS;AAC/B,OAAI,CAAC,KAAK,SAAU,QAAO;AAE3B,UAAO,gBAAgB,MAAM,YAAY,KAAK,aAAa,QAAQ;IACnE;;AAIN,QAAO"}
1
+ {"version":3,"file":"getTargetDictionary.cjs","names":[],"sources":["../../src/getTargetDictionary.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { type ListGitFilesOptions, listGitFiles } from '@intlayer/engine/cli';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\n// Arguments for the fill function\nexport type GetTargetDictionaryOptions = {\n file?: string | string[];\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getTargetUnmergedDictionaries = async (\n options?: GetTargetDictionaryOptions\n): Promise<Dictionary[]> => {\n const configuration = getConfiguration(options?.configOptions);\n\n const { baseDir } = configuration.system;\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options?.file !== 'undefined') {\n const fileArray = ensureArray(options?.file);\n const relativeFilePaths = fileArray.map((file) =>\n file.startsWith('/') ? relative(baseDir, file) : join('./', file)\n );\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n // Check for absolute path\n relativeFilePaths.includes(dict.filePath)\n );\n }\n\n if (typeof options?.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options?.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options?.filter !== 'undefined') {\n result = result.filter(options?.filter);\n }\n\n const gitOptions = options?.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if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CAEA,OAAO;AACT"}
@@ -3,22 +3,22 @@ const require_extract = require('./extract.cjs');
3
3
  const require_listProjects = require('./listProjects.cjs');
4
4
  const require_liveSync = require('./liveSync.cjs');
5
5
  const require_listContentDeclaration = require('./listContentDeclaration.cjs');
6
+ const require_initSkills = require('./initSkills.cjs');
6
7
  const require_init = require('./init.cjs');
7
8
  const require_editor = require('./editor.cjs');
8
9
  const require_scan = require('./scan.cjs');
10
+ const require_cli = require('./cli.cjs');
11
+ const require_searchDoc = require('./searchDoc.cjs');
12
+ const require_pushConfig = require('./pushConfig.cjs');
9
13
  const require_build = require('./build.cjs');
10
14
  const require_bundle = require('./bundle.cjs');
11
15
  const require_test_listMissingTranslations = require('./test/listMissingTranslations.cjs');
12
16
  const require_test_test = require('./test/test.cjs');
13
17
  const require_fill_fill = require('./fill/fill.cjs');
14
- const require_initSkills = require('./initSkills.cjs');
15
18
  const require_pull = require('./pull.cjs');
16
19
  const require_push_push = require('./push/push.cjs');
17
- const require_pushConfig = require('./pushConfig.cjs');
18
20
  const require_reviewDoc_reviewDoc = require('./reviewDoc/reviewDoc.cjs');
19
- const require_searchDoc = require('./searchDoc.cjs');
20
21
  const require_translateDoc_translateDoc = require('./translateDoc/translateDoc.cjs');
21
- const require_cli = require('./cli.cjs');
22
22
 
23
23
  exports.PLATFORM_OPTIONS = require_initSkills.PLATFORM_OPTIONS;
24
24
  exports.build = require_build.build;