gt 2.18.1 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/api/collectUserEditDiffs.js +23 -23
  3. package/dist/api/collectUserEditDiffs.js.map +1 -1
  4. package/dist/api/downloadFileBatch.js +7 -4
  5. package/dist/api/downloadFileBatch.js.map +1 -1
  6. package/dist/api/saveLocalEdits.js +2 -2
  7. package/dist/api/saveLocalEdits.js.map +1 -1
  8. package/dist/cli/base.d.ts +2 -0
  9. package/dist/cli/base.js +45 -2
  10. package/dist/cli/base.js.map +1 -1
  11. package/dist/cli/commands/api.d.ts +17 -0
  12. package/dist/cli/commands/api.js +153 -0
  13. package/dist/cli/commands/api.js.map +1 -0
  14. package/dist/cli/commands/upload.js +15 -5
  15. package/dist/cli/commands/upload.js.map +1 -1
  16. package/dist/cli/commands/utils/validation.d.ts +4 -0
  17. package/dist/cli/commands/utils/validation.js +12 -5
  18. package/dist/cli/commands/utils/validation.js.map +1 -1
  19. package/dist/config/generateSettings.js +7 -0
  20. package/dist/config/generateSettings.js.map +1 -1
  21. package/dist/console/index.d.ts +1 -0
  22. package/dist/console/index.js +2 -1
  23. package/dist/console/index.js.map +1 -1
  24. package/dist/formats/files/aggregateFiles.js +20 -8
  25. package/dist/formats/files/aggregateFiles.js.map +1 -1
  26. package/dist/formats/files/androidLocale.d.ts +7 -0
  27. package/dist/formats/files/androidLocale.js +32 -0
  28. package/dist/formats/files/androidLocale.js.map +1 -0
  29. package/dist/formats/files/fileMapping.js +31 -24
  30. package/dist/formats/files/fileMapping.js.map +1 -1
  31. package/dist/formats/files/localePath.d.ts +3 -0
  32. package/dist/formats/files/localePath.js +18 -0
  33. package/dist/formats/files/localePath.js.map +1 -0
  34. package/dist/formats/files/supportedFiles.d.ts +2 -1
  35. package/dist/formats/files/supportedFiles.js +4 -2
  36. package/dist/formats/files/supportedFiles.js.map +1 -1
  37. package/dist/formats/files/transformFormat.d.ts +2 -0
  38. package/dist/formats/files/transformFormat.js +6 -3
  39. package/dist/formats/files/transformFormat.js.map +1 -1
  40. package/dist/fs/config/parseFilesConfig.js +5 -1
  41. package/dist/fs/config/parseFilesConfig.js.map +1 -1
  42. package/dist/fs/fileContent.d.ts +65 -0
  43. package/dist/fs/fileContent.js +171 -0
  44. package/dist/fs/fileContent.js.map +1 -0
  45. package/dist/generated/version.d.ts +1 -1
  46. package/dist/generated/version.js +1 -1
  47. package/dist/generated/version.js.map +1 -1
  48. package/dist/state/recentDownloads.d.ts +3 -2
  49. package/dist/state/recentDownloads.js.map +1 -1
  50. package/dist/translation/reviewSetupWarning.js +3 -3
  51. package/dist/translation/reviewSetupWarning.js.map +1 -1
  52. package/dist/utils/api.d.ts +194 -0
  53. package/dist/utils/api.js +268 -0
  54. package/dist/utils/api.js.map +1 -0
  55. package/dist/utils/persistPostprocessHashes.d.ts +1 -7
  56. package/dist/utils/persistPostprocessHashes.js +15 -1
  57. package/dist/utils/persistPostprocessHashes.js.map +1 -1
  58. package/dist/workflows/download.js +4 -4
  59. package/dist/workflows/download.js.map +1 -1
  60. package/dist/workflows/enqueue.js +4 -4
  61. package/dist/workflows/enqueue.js.map +1 -1
  62. package/dist/workflows/publish.js +2 -2
  63. package/dist/workflows/publish.js.map +1 -1
  64. package/dist/workflows/setupProject.js +4 -4
  65. package/dist/workflows/setupProject.js.map +1 -1
  66. package/dist/workflows/stage.js +7 -7
  67. package/dist/workflows/stage.js.map +1 -1
  68. package/dist/workflows/steps/BranchStep.d.ts +2 -2
  69. package/dist/workflows/steps/BranchStep.js +9 -9
  70. package/dist/workflows/steps/BranchStep.js.map +1 -1
  71. package/dist/workflows/steps/DownloadStep.d.ts +3 -3
  72. package/dist/workflows/steps/DownloadStep.js +3 -3
  73. package/dist/workflows/steps/DownloadStep.js.map +1 -1
  74. package/dist/workflows/steps/EnqueueStep.d.ts +5 -3
  75. package/dist/workflows/steps/EnqueueStep.js.map +1 -1
  76. package/dist/workflows/steps/PollJobsStep.d.ts +3 -3
  77. package/dist/workflows/steps/PollJobsStep.js +6 -6
  78. package/dist/workflows/steps/PollJobsStep.js.map +1 -1
  79. package/dist/workflows/steps/PublishStep.d.ts +3 -3
  80. package/dist/workflows/steps/PublishStep.js +3 -3
  81. package/dist/workflows/steps/PublishStep.js.map +1 -1
  82. package/dist/workflows/steps/SetupStep.d.ts +6 -4
  83. package/dist/workflows/steps/SetupStep.js.map +1 -1
  84. package/dist/workflows/steps/TagStep.d.ts +3 -3
  85. package/dist/workflows/steps/TagStep.js +3 -3
  86. package/dist/workflows/steps/TagStep.js.map +1 -1
  87. package/dist/workflows/steps/UploadSourcesStep.d.ts +3 -3
  88. package/dist/workflows/steps/UploadSourcesStep.js +8 -6
  89. package/dist/workflows/steps/UploadSourcesStep.js.map +1 -1
  90. package/dist/workflows/steps/UploadTranslationsStep.d.ts +3 -3
  91. package/dist/workflows/steps/UploadTranslationsStep.js +24 -6
  92. package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -1
  93. package/dist/workflows/upload.js +4 -4
  94. package/dist/workflows/upload.js.map +1 -1
  95. package/dist/workflows/utils/filterFilesForEnqueue.d.ts +2 -2
  96. package/dist/workflows/utils/filterFilesForEnqueue.js.map +1 -1
  97. package/dist/workflows/utils/queryCompletedTranslations.d.ts +3 -3
  98. package/dist/workflows/utils/queryCompletedTranslations.js +2 -2
  99. package/dist/workflows/utils/queryCompletedTranslations.js.map +1 -1
  100. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"download.js","names":[],"sources":["../../src/workflows/download.ts"],"sourcesContent":["import path from 'node:path';\nimport { Settings } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult } from 'generaltranslation/types';\nimport { clearLocaleDirs } from '../fs/clearLocaleDirs.js';\nimport {\n FileStatusTracker,\n PollTranslationJobsStep,\n} from './steps/PollJobsStep.js';\nimport { DownloadTranslationsStep } from './steps/DownloadStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { branchResolutionError } from '../console/index.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { logger } from '../console/logger.js';\nimport { recordWarning } from '../state/translateWarnings.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { FileProperties } from '../types/files.js';\nimport chalk from 'chalk';\nimport type { InlineLibrary } from '../types/libraries.js';\n\nexport type FileTranslationData = {\n [fileId: string]: {\n versionId: string;\n fileName: string;\n /** Source component count for GTJSON files */\n componentCount?: number;\n };\n};\n\n/**\n * Checks the status of translations and downloads them using a workflow pattern\n * @param fileVersionData - Mapping of file IDs to their version and name information\n * @param jobData - Optional job data from enqueue operation\n * @param locales - The locales to wait for\n * @param timeoutDuration - The timeout duration for the wait in seconds\n * @param resolveOutputPath - Function to resolve the output path for a given source path and locale\n * @param options - Settings configuration\n * @param forceRetranslation - Whether to force retranslation\n * @param forceDownload - Whether to force download even if file exists\n * @returns True if all translations are downloaded successfully, false otherwise\n */\nexport async function runDownloadWorkflow({\n fileVersionData,\n jobData,\n branchData,\n locales,\n timeoutDuration,\n resolveOutputPath,\n options,\n inlineLibrary,\n forceRetranslation,\n forceDownload,\n}: {\n fileVersionData: FileTranslationData;\n jobData: EnqueueFilesResult | undefined;\n branchData: BranchData | undefined;\n locales: string[];\n timeoutDuration: number;\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n options: Settings;\n inlineLibrary?: InlineLibrary;\n forceRetranslation?: boolean;\n forceDownload?: boolean;\n}): Promise<boolean> {\n if (!branchData) {\n // Run the branch step\n const branchStep = new BranchStep(gt, options);\n const branchResult = await branchStep.run();\n if (!branchResult) {\n return logErrorAndExit(branchResolutionError);\n }\n branchData = branchResult;\n }\n // readLockfile uses _branchId to select branch-specific lockfile entries.\n // Keep it on a scoped copy so the caller's settings object is not mutated.\n const settingsForBranch: Settings = {\n ...options,\n _branchId: branchData.currentBranch.id,\n };\n // Prepare the query data\n const fileQueryData = prepareFileQueryData(\n fileVersionData,\n locales,\n branchData\n );\n\n // Initialize download status\n const fileTracker: FileStatusTracker = {\n completed: new Map<string, FileProperties>(),\n inProgress: new Map<string, FileProperties>(),\n failed: new Map<string, FileProperties>(),\n skipped: new Map<string, FileProperties>(),\n };\n\n // Step 1: Poll translation jobs if jobData exists\n let pollTimedOut = false;\n if (jobData) {\n const pollStep = new PollTranslationJobsStep(gt, inlineLibrary);\n const pollResult = await pollStep.run({\n fileTracker,\n fileQueryData,\n jobData,\n timeoutDuration,\n forceRetranslation,\n });\n\n if (pollResult.fileTracker.failed.size > 0) {\n logger.error(\n `${chalk.red(`${pollResult.fileTracker.failed.size} file(s) failed to translate:`)}\\n${Array.from(\n pollResult.fileTracker.failed.entries()\n )\n .map(([, value]) => `- ${value.fileName}`)\n .join('\\n')}`\n );\n for (const [, value] of pollResult.fileTracker.failed) {\n recordWarning(\n 'failed_translation',\n value.fileName,\n `Failed to translate for locale ${value.locale}`\n );\n }\n\n // If all files failed translation, exit early\n if (pollResult.fileTracker.completed.size === 0) {\n return false;\n }\n }\n\n // Even if polling timed out, still download whatever completed successfully\n if (!pollResult.success) {\n pollTimedOut = true;\n if (pollResult.fileTracker.completed.size > 0) {\n logger.warn(\n chalk.yellow(\n `Timed out, but ${pollResult.fileTracker.completed.size} translation(s) completed successfully. Downloading completed files...`\n )\n );\n } else {\n return false;\n }\n }\n } else {\n for (const file of fileQueryData) {\n // Staging - assume all files are completed\n fileTracker.completed.set(\n `${file.branchId}:${file.fileId}:${file.versionId}:${file.locale}`,\n file\n );\n }\n }\n\n await clearCompletedLocaleDirs({\n fileTracker,\n locales,\n resolveOutputPath,\n options,\n });\n\n // Step 2: Download translations\n const downloadStep = new DownloadTranslationsStep(\n gt,\n settingsForBranch,\n inlineLibrary\n );\n const downloadResult = await downloadStep.run({\n fileTracker,\n resolveOutputPath,\n forceDownload,\n });\n\n // If polling timed out, report failure even though we downloaded what we could\n if (pollTimedOut) {\n return false;\n }\n\n return downloadResult;\n}\n\nasync function clearCompletedLocaleDirs({\n fileTracker,\n locales,\n resolveOutputPath,\n options,\n}: {\n fileTracker: FileStatusTracker;\n locales: string[];\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n options: Settings;\n}): Promise<void> {\n if (\n options.options?.experimentalClearLocaleDirs !== true ||\n fileTracker.completed.size === 0\n ) {\n return;\n }\n\n const translatedFiles = new Set(\n Array.from(fileTracker.completed.values())\n .map((file) => {\n const outputPath = resolveOutputPath(file.fileName, file.locale);\n // Only clear if the output path is different from the source.\n return outputPath !== null && outputPath !== file.fileName\n ? outputPath\n : null;\n })\n .filter((filePath): filePath is string => filePath !== null)\n );\n\n if (translatedFiles.size === 0) return;\n\n const cwd = path.dirname(options.config);\n\n await clearLocaleDirs(\n translatedFiles,\n locales,\n options.options?.clearLocaleDirsExclude,\n cwd\n );\n}\n\n/**\n * Prepares the file query data from input data and locales\n */\nfunction prepareFileQueryData(\n fileVersionData: FileTranslationData,\n locales: string[],\n branchData: BranchData\n): FileProperties[] {\n const fileQueryData: FileProperties[] = [];\n\n for (const fileId in fileVersionData) {\n for (const locale of locales) {\n fileQueryData.push({\n versionId: fileVersionData[fileId].versionId,\n fileName: fileVersionData[fileId].fileName,\n fileId,\n locale,\n branchId: branchData.currentBranch.id,\n componentCount: fileVersionData[fileId].componentCount,\n });\n }\n }\n\n return fileQueryData;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,eAAsB,oBAAoB,EACxC,iBACA,SACA,YACA,SACA,iBACA,mBACA,SACA,eACA,oBACA,iBAYmB;AACnB,KAAI,CAAC,YAAY;EAGf,MAAM,eAAe,MAAM,IADJ,WAAW,IAAI,QACD,CAAC,KAAK;AAC3C,MAAI,CAAC,aACH,QAAO,gBAAgB,sBAAsB;AAE/C,eAAa;;CAIf,MAAM,oBAA8B;EAClC,GAAG;EACH,WAAW,WAAW,cAAc;EACrC;CAED,MAAM,gBAAgB,qBACpB,iBACA,SACA,WACD;CAGD,MAAM,cAAiC;EACrC,2BAAW,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I,IAC1B,MAAM,KAAK,YAAY,UAAU,QAAQ,CAAC,CACvC,KAAK,SAAS;EACb,MAAM,aAAa,kBAAkB,KAAK,UAAU,KAAK,OAAO;AAEhE,SAAO,eAAe,QAAQ,eAAe,KAAK,WAC9C,aACA;GACJ,CACD,QAAQ,aAAiC,aAAa,KAAK,CAC/D;AAED,KAAI,gBAAgB,SAAS,EAAG;CAEhC,MAAM,MAAM,KAAK,QAAQ,QAAQ,OAAO;AAExC,OAAM,gBACJ,iBACA,SACA,QAAQ,SAAS,wBACjB,IACD;;;;;AAMH,SAAS,qBACP,iBACA,SACA,YACkB;CAClB,MAAM,gBAAkC,EAAE;AAE1C,MAAK,MAAM,UAAU,gBACnB,MAAK,MAAM,UAAU,QACnB,eAAc,KAAK;EACjB,WAAW,gBAAgB,QAAQ;EACnC,UAAU,gBAAgB,QAAQ;EAClC;EACA;EACA,UAAU,WAAW,cAAc;EACnC,gBAAgB,gBAAgB,QAAQ;EACzC,CAAC;AAIN,QAAO"}
1
+ {"version":3,"file":"download.js","names":[],"sources":["../../src/workflows/download.ts"],"sourcesContent":["import path from 'node:path';\nimport { Settings } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { EnqueueFilesResult } from 'generaltranslation/types';\nimport { clearLocaleDirs } from '../fs/clearLocaleDirs.js';\nimport {\n FileStatusTracker,\n PollTranslationJobsStep,\n} from './steps/PollJobsStep.js';\nimport { DownloadTranslationsStep } from './steps/DownloadStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { branchResolutionError } from '../console/index.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { logger } from '../console/logger.js';\nimport { recordWarning } from '../state/translateWarnings.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { FileProperties } from '../types/files.js';\nimport chalk from 'chalk';\nimport type { InlineLibrary } from '../types/libraries.js';\n\nexport type FileTranslationData = {\n [fileId: string]: {\n versionId: string;\n fileName: string;\n /** Source component count for GTJSON files */\n componentCount?: number;\n };\n};\n\n/**\n * Checks the status of translations and downloads them using a workflow pattern\n * @param fileVersionData - Mapping of file IDs to their version and name information\n * @param jobData - Optional job data from enqueue operation\n * @param locales - The locales to wait for\n * @param timeoutDuration - The timeout duration for the wait in seconds\n * @param resolveOutputPath - Function to resolve the output path for a given source path and locale\n * @param options - Settings configuration\n * @param forceRetranslation - Whether to force retranslation\n * @param forceDownload - Whether to force download even if file exists\n * @returns True if all translations are downloaded successfully, false otherwise\n */\nexport async function runDownloadWorkflow({\n fileVersionData,\n jobData,\n branchData,\n locales,\n timeoutDuration,\n resolveOutputPath,\n options,\n inlineLibrary,\n forceRetranslation,\n forceDownload,\n}: {\n fileVersionData: FileTranslationData;\n jobData: EnqueueFilesResult | undefined;\n branchData: BranchData | undefined;\n locales: string[];\n timeoutDuration: number;\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n options: Settings;\n inlineLibrary?: InlineLibrary;\n forceRetranslation?: boolean;\n forceDownload?: boolean;\n}): Promise<boolean> {\n if (!branchData) {\n // Run the branch step\n const branchStep = new BranchStep(api, options);\n const branchResult = await branchStep.run();\n if (!branchResult) {\n return logErrorAndExit(branchResolutionError);\n }\n branchData = branchResult;\n }\n // readLockfile uses _branchId to select branch-specific lockfile entries.\n // Keep it on a scoped copy so the caller's settings object is not mutated.\n const settingsForBranch: Settings = {\n ...options,\n _branchId: branchData.currentBranch.id,\n };\n // Prepare the query data\n const fileQueryData = prepareFileQueryData(\n fileVersionData,\n locales,\n branchData\n );\n\n // Initialize download status\n const fileTracker: FileStatusTracker = {\n completed: new Map<string, FileProperties>(),\n inProgress: new Map<string, FileProperties>(),\n failed: new Map<string, FileProperties>(),\n skipped: new Map<string, FileProperties>(),\n };\n\n // Step 1: Poll translation jobs if jobData exists\n let pollTimedOut = false;\n if (jobData) {\n const pollStep = new PollTranslationJobsStep(api, inlineLibrary);\n const pollResult = await pollStep.run({\n fileTracker,\n fileQueryData,\n jobData,\n timeoutDuration,\n forceRetranslation,\n });\n\n if (pollResult.fileTracker.failed.size > 0) {\n logger.error(\n `${chalk.red(`${pollResult.fileTracker.failed.size} file(s) failed to translate:`)}\\n${Array.from(\n pollResult.fileTracker.failed.entries()\n )\n .map(([, value]) => `- ${value.fileName}`)\n .join('\\n')}`\n );\n for (const [, value] of pollResult.fileTracker.failed) {\n recordWarning(\n 'failed_translation',\n value.fileName,\n `Failed to translate for locale ${value.locale}`\n );\n }\n\n // If all files failed translation, exit early\n if (pollResult.fileTracker.completed.size === 0) {\n return false;\n }\n }\n\n // Even if polling timed out, still download whatever completed successfully\n if (!pollResult.success) {\n pollTimedOut = true;\n if (pollResult.fileTracker.completed.size > 0) {\n logger.warn(\n chalk.yellow(\n `Timed out, but ${pollResult.fileTracker.completed.size} translation(s) completed successfully. Downloading completed files...`\n )\n );\n } else {\n return false;\n }\n }\n } else {\n for (const file of fileQueryData) {\n // Staging - assume all files are completed\n fileTracker.completed.set(\n `${file.branchId}:${file.fileId}:${file.versionId}:${file.locale}`,\n file\n );\n }\n }\n\n await clearCompletedLocaleDirs({\n fileTracker,\n locales,\n resolveOutputPath,\n options,\n });\n\n // Step 2: Download translations\n const downloadStep = new DownloadTranslationsStep(\n api,\n settingsForBranch,\n inlineLibrary\n );\n const downloadResult = await downloadStep.run({\n fileTracker,\n resolveOutputPath,\n forceDownload,\n });\n\n // If polling timed out, report failure even though we downloaded what we could\n if (pollTimedOut) {\n return false;\n }\n\n return downloadResult;\n}\n\nasync function clearCompletedLocaleDirs({\n fileTracker,\n locales,\n resolveOutputPath,\n options,\n}: {\n fileTracker: FileStatusTracker;\n locales: string[];\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n options: Settings;\n}): Promise<void> {\n if (\n options.options?.experimentalClearLocaleDirs !== true ||\n fileTracker.completed.size === 0\n ) {\n return;\n }\n\n const translatedFiles = new Set(\n Array.from(fileTracker.completed.values())\n .map((file) => {\n const outputPath = resolveOutputPath(file.fileName, file.locale);\n // Only clear if the output path is different from the source.\n return outputPath !== null && outputPath !== file.fileName\n ? outputPath\n : null;\n })\n .filter((filePath): filePath is string => filePath !== null)\n );\n\n if (translatedFiles.size === 0) return;\n\n const cwd = path.dirname(options.config);\n\n await clearLocaleDirs(\n translatedFiles,\n locales,\n options.options?.clearLocaleDirsExclude,\n cwd\n );\n}\n\n/**\n * Prepares the file query data from input data and locales\n */\nfunction prepareFileQueryData(\n fileVersionData: FileTranslationData,\n locales: string[],\n branchData: BranchData\n): FileProperties[] {\n const fileQueryData: FileProperties[] = [];\n\n for (const fileId in fileVersionData) {\n for (const locale of locales) {\n fileQueryData.push({\n versionId: fileVersionData[fileId].versionId,\n fileName: fileVersionData[fileId].fileName,\n fileId,\n locale,\n branchId: branchData.currentBranch.id,\n componentCount: fileVersionData[fileId].componentCount,\n });\n }\n }\n\n return fileQueryData;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,eAAsB,oBAAoB,EACxC,iBACA,SACA,YACA,SACA,iBACA,mBACA,SACA,eACA,oBACA,iBAYmB;AACnB,KAAI,CAAC,YAAY;EAGf,MAAM,eAAe,MAAM,IADJ,WAAW,KAAK,QACF,CAAC,KAAK;AAC3C,MAAI,CAAC,aACH,QAAO,gBAAgB,sBAAsB;AAE/C,eAAa;;CAIf,MAAM,oBAA8B;EAClC,GAAG;EACH,WAAW,WAAW,cAAc;EACrC;CAED,MAAM,gBAAgB,qBACpB,iBACA,SACA,WACD;CAGD,MAAM,cAAiC;EACrC,2BAAW,IAAI,KAA6B;EAC5C,4BAAY,IAAI,KAA6B;EAC7C,wBAAQ,IAAI,KAA6B;EACzC,yBAAS,IAAI,KAA6B;EAC3C;CAGD,IAAI,eAAe;AACnB,KAAI,SAAS;EAEX,MAAM,aAAa,MAAM,IADJ,wBAAwB,KAAK,cACjB,CAAC,IAAI;GACpC;GACA;GACA;GACA;GACA;GACD,CAAC;AAEF,MAAI,WAAW,YAAY,OAAO,OAAO,GAAG;AAC1C,UAAO,MACL,GAAG,MAAM,IAAI,GAAG,WAAW,YAAY,OAAO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D;;;;;AAMH,SAAS,qBACP,iBACA,SACA,YACkB;CAClB,MAAM,gBAAkC,EAAE;AAE1C,MAAK,MAAM,UAAU,gBACnB,MAAK,MAAM,UAAU,QACnB,eAAc,KAAK;EACjB,WAAW,gBAAgB,QAAQ;EACnC,UAAU,gBAAgB,QAAQ;EAClC;EACA;EACA,UAAU,WAAW,cAAc;EACnC,gBAAgB,gBAAgB,QAAQ;EACzC,CAAC;AAIN,QAAO"}
@@ -1,7 +1,7 @@
1
1
  import { logger } from "../console/logger.js";
2
- import { gt } from "../utils/gt.js";
3
2
  import { logCollectedFiles, logErrorAndExit } from "../console/logging.js";
4
3
  import { branchResolutionError, withOriginalError } from "../console/index.js";
4
+ import { api } from "../utils/api.js";
5
5
  import { syncFonts } from "./utils/syncFonts.js";
6
6
  import { BranchStep } from "./steps/BranchStep.js";
7
7
  import { EnqueueStep } from "./steps/EnqueueStep.js";
@@ -22,13 +22,13 @@ async function runEnqueueWorkflow({ files, options, settings, inlineLibrary }) {
22
22
  logCollectedFiles(files, void 0, inlineLibrary);
23
23
  logger.debug("Files: " + JSON.stringify(files, null, 2));
24
24
  await syncFonts(settings);
25
- const branchStep = new BranchStep(gt, settings);
26
- const enqueueStep = new EnqueueStep(gt, settings, options.force);
25
+ const branchStep = new BranchStep(api, settings);
26
+ const enqueueStep = new EnqueueStep(api, settings, options.force);
27
27
  const branchData = await branchStep.run();
28
28
  if (!branchData) return logErrorAndExit(branchResolutionError);
29
29
  logger.debug("Branch data: " + JSON.stringify(branchData, null, 2));
30
30
  const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({
31
- gt,
31
+ gt: api,
32
32
  files: files.map((files) => ({
33
33
  branchId: branchData.currentBranch.id,
34
34
  ...files
@@ -1 +1 @@
1
- {"version":3,"file":"enqueue.js","names":[],"sources":["../../src/workflows/enqueue.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { logger } from '../console/logger.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Enqueues translations for a given set of files\n * - Only enqueues uploaded files\n * - Don't have to worry about double enqueuing files because dedupe on API side\n *\n * @param {FileTranslationData} fileVersionData - The file version data\n * @param {TranslateFlags} options - The options for the enqueue operation\n * @param {Settings} settings - The settings for the enqueue operation\n * @returns {Promise<EnqueueFilesResult>} The enqueue result\n */\nexport async function runEnqueueWorkflow({\n files,\n options,\n settings,\n inlineLibrary,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n inlineLibrary?: InlineLibrary;\n}): Promise<EnqueueFilesResult> {\n try {\n // Log files to be enqueued\n logCollectedFiles(files, undefined, inlineLibrary);\n\n logger.debug('Files: ' + JSON.stringify(files, null, 2));\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n // const queryFileDataStep = new QueryFileDataStep(gt);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // (1) run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n logger.debug('Branch data: ' + JSON.stringify(branchData, null, 2));\n\n // (2) Enqueue the files\n const filesWithBranch = files.map((files) => ({\n branchId: branchData.currentBranch.id,\n ...files,\n }));\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: filesWithBranch,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n logger.debug('Enqueue result: ' + JSON.stringify(enqueueResult, null, 2));\n\n logEnqueueResult(\n enqueueResult,\n filesToEnqueue.length === 0 ? files.length : filesToEnqueue.length\n );\n return enqueueResult;\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Translations could not be enqueued. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n\n// ----- Helper functions ----- //\n\n/**\n * Logs the enqueue result\n * @param enqueueResult - The enqueue result\n * @returns void\n */\nfunction logEnqueueResult(\n enqueueResult: EnqueueFilesResult,\n fileCount: number\n): void {\n if (Object.keys(enqueueResult.jobData).length === 0) {\n logger.success(\n `All ${fileCount} ${fileCount === 1 ? 'file' : 'files'} already translated. 0 files enqueued.`\n );\n } else {\n logger.success(enqueueResult.message);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,eAAsB,mBAAmB,EACvC,OACA,SACA,UACA,iBAM8B;AAC9B,KAAI;AAEF,oBAAkB,OAAO,KAAA,GAAW,cAAc;AAElD,SAAO,MAAM,YAAY,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;AAIxD,QAAM,UAAU,SAAS;EAGzB,MAAM,aAAa,IAAI,WAAW,IAAI,SAAS;EAE/C,MAAM,cAAc,IAAI,YAAY,IAAI,UAAU,QAAQ,MAAM;EAGhE,MAAM,aAAa,MAAM,WAAW,KAAK;AACzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;AAE/C,SAAO,MAAM,kBAAkB,KAAK,UAAU,YAAY,MAAM,EAAE,CAAC;EAOnE,MAAM,EAAE,gBAAgB,iBAAiB,MAAM,sBAAsB;GACnE;GACA,OANsB,MAAM,KAAK,WAAW;IAC5C,UAAU,WAAW,cAAc;IACnC,GAAG;IACJ,EAGuB;GACtB,SAAS,SAAS;GAClB,OAAO,QAAQ;GAChB,CAAC;AACF,MAAI,aAAa,SAAS,EACxB,QAAO,KACL,uBAAuB,aAAa,OAAO,0BAA0B,aAAa,WAAW,IAAI,KAAK,MACvG;EAGH,MAAM,gBAAgB,MAAM,YAAY,IAAI,eAAe;AAE3D,SAAO,MAAM,qBAAqB,KAAK,UAAU,eAAe,MAAM,EAAE,CAAC;AAEzE,mBACE,eACA,eAAe,WAAW,IAAI,MAAM,SAAS,eAAe,OAC7D;AACD,SAAO;UACA,OAAO;AACd,SAAO,gBACL,kBACE,mHACA,MACD,CACF;;;;;;;;AAWL,SAAS,iBACP,eACA,WACM;AACN,KAAI,OAAO,KAAK,cAAc,QAAQ,CAAC,WAAW,EAChD,QAAO,QACL,OAAO,UAAU,GAAG,cAAc,IAAI,SAAS,QAAQ,wCACxD;KAED,QAAO,QAAQ,cAAc,QAAQ"}
1
+ {"version":3,"file":"enqueue.js","names":[],"sources":["../../src/workflows/enqueue.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { logger } from '../console/logger.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Enqueues translations for a given set of files\n * - Only enqueues uploaded files\n * - Don't have to worry about double enqueuing files because dedupe on API side\n *\n * @param {FileTranslationData} fileVersionData - The file version data\n * @param {TranslateFlags} options - The options for the enqueue operation\n * @param {Settings} settings - The settings for the enqueue operation\n * @returns {Promise<EnqueueFilesResult>} The enqueue result\n */\nexport async function runEnqueueWorkflow({\n files,\n options,\n settings,\n inlineLibrary,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n inlineLibrary?: InlineLibrary;\n}): Promise<EnqueueFilesResult> {\n try {\n // Log files to be enqueued\n logCollectedFiles(files, undefined, inlineLibrary);\n\n logger.debug('Files: ' + JSON.stringify(files, null, 2));\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Create workflow with steps\n const branchStep = new BranchStep(api, settings);\n // const queryFileDataStep = new QueryFileDataStep(gt);\n const enqueueStep = new EnqueueStep(api, settings, options.force);\n\n // (1) run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n logger.debug('Branch data: ' + JSON.stringify(branchData, null, 2));\n\n // (2) Enqueue the files\n const filesWithBranch = files.map((files) => ({\n branchId: branchData.currentBranch.id,\n ...files,\n }));\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt: api,\n files: filesWithBranch,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n logger.debug('Enqueue result: ' + JSON.stringify(enqueueResult, null, 2));\n\n logEnqueueResult(\n enqueueResult,\n filesToEnqueue.length === 0 ? files.length : filesToEnqueue.length\n );\n return enqueueResult;\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Translations could not be enqueued. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n\n// ----- Helper functions ----- //\n\n/**\n * Logs the enqueue result\n * @param enqueueResult - The enqueue result\n * @returns void\n */\nfunction logEnqueueResult(\n enqueueResult: EnqueueFilesResult,\n fileCount: number\n): void {\n if (Object.keys(enqueueResult.jobData).length === 0) {\n logger.success(\n `All ${fileCount} ${fileCount === 1 ? 'file' : 'files'} already translated. 0 files enqueued.`\n );\n } else {\n logger.success(enqueueResult.message);\n }\n}\n"],"m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.js";
2
+ import { api } from "../utils/api.js";
3
3
  import { PublishStep } from "./steps/PublishStep.js";
4
4
  import { hasPublishConfig } from "../utils/resolvePublish.js";
5
5
  //#region src/workflows/publish.ts
@@ -18,7 +18,7 @@ async function runPublishWorkflow(files, publishMap, branchId, settings) {
18
18
  fileName: file.fileName
19
19
  }));
20
20
  if (allFileRefs.length === 0) return;
21
- await new PublishStep(gt).run(allFileRefs);
21
+ await new PublishStep(api).run(allFileRefs);
22
22
  } catch (error) {
23
23
  logger.warn(`Failed to publish files: ${error instanceof Error ? error.message : String(error)}`);
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"publish.js","names":[],"sources":["../../src/workflows/publish.ts"],"sourcesContent":["import { Settings } from '../types/index.js';\nimport { PublishStep } from './steps/PublishStep.js';\nimport { gt } from '../utils/gt.js';\nimport { hasPublishConfig } from '../utils/resolvePublish.js';\nimport { logger } from '../console/logger.js';\n\n/**\n * Publishes files to the CDN if publish config exists and the publishMap is non-empty.\n * Shared by translate, upload, and save-local commands.\n */\nexport async function runPublishWorkflow(\n files: { fileId: string; versionId: string; fileName: string }[],\n publishMap: Map<string, boolean>,\n branchId: string,\n settings: Settings\n): Promise<void> {\n if (publishMap.size === 0 || !hasPublishConfig(settings)) return;\n\n try {\n const allFileRefs = files\n .filter((file) => publishMap.has(file.fileId))\n .map((file) => ({\n fileId: file.fileId,\n versionId: file.versionId,\n branchId,\n publish: publishMap.get(file.fileId)!,\n fileName: file.fileName,\n }));\n if (allFileRefs.length === 0) return;\n const publishStep = new PublishStep(gt);\n await publishStep.run(allFileRefs);\n } catch (error) {\n logger.warn(\n `Failed to publish files: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n"],"mappings":";;;;;;;;;AAUA,eAAsB,mBACpB,OACA,YACA,UACA,UACe;AACf,KAAI,WAAW,SAAS,KAAK,CAAC,iBAAiB,SAAS,CAAE;AAE1D,KAAI;EACF,MAAM,cAAc,MACjB,QAAQ,SAAS,WAAW,IAAI,KAAK,OAAO,CAAC,CAC7C,KAAK,UAAU;GACd,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB;GACA,SAAS,WAAW,IAAI,KAAK,OAAO;GACpC,UAAU,KAAK;GAChB,EAAE;AACL,MAAI,YAAY,WAAW,EAAG;AAE9B,QAAM,IADkB,YAAY,GACnB,CAAC,IAAI,YAAY;UAC3B,OAAO;AACd,SAAO,KACL,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACnF"}
1
+ {"version":3,"file":"publish.js","names":[],"sources":["../../src/workflows/publish.ts"],"sourcesContent":["import { Settings } from '../types/index.js';\nimport { PublishStep } from './steps/PublishStep.js';\nimport { api } from '../utils/api.js';\nimport { hasPublishConfig } from '../utils/resolvePublish.js';\nimport { logger } from '../console/logger.js';\n\n/**\n * Publishes files to the CDN if publish config exists and the publishMap is non-empty.\n * Shared by translate, upload, and save-local commands.\n */\nexport async function runPublishWorkflow(\n files: { fileId: string; versionId: string; fileName: string }[],\n publishMap: Map<string, boolean>,\n branchId: string,\n settings: Settings\n): Promise<void> {\n if (publishMap.size === 0 || !hasPublishConfig(settings)) return;\n\n try {\n const allFileRefs = files\n .filter((file) => publishMap.has(file.fileId))\n .map((file) => ({\n fileId: file.fileId,\n versionId: file.versionId,\n branchId,\n publish: publishMap.get(file.fileId)!,\n fileName: file.fileName,\n }));\n if (allFileRefs.length === 0) return;\n const publishStep = new PublishStep(api);\n await publishStep.run(allFileRefs);\n } catch (error) {\n logger.warn(\n `Failed to publish files: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n"],"mappings":";;;;;;;;;AAUA,eAAsB,mBACpB,OACA,YACA,UACA,UACe;AACf,KAAI,WAAW,SAAS,KAAK,CAAC,iBAAiB,SAAS,CAAE;AAE1D,KAAI;EACF,MAAM,cAAc,MACjB,QAAQ,SAAS,WAAW,IAAI,KAAK,OAAO,CAAC,CAC7C,KAAK,UAAU;GACd,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB;GACA,SAAS,WAAW,IAAI,KAAK,OAAO;GACpC,UAAU,KAAK;GAChB,EAAE;AACL,MAAI,YAAY,WAAW,EAAG;AAE9B,QAAM,IADkB,YAAY,IACnB,CAAC,IAAI,YAAY;UAC3B,OAAO;AACd,SAAO,KACL,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACnF"}
@@ -1,6 +1,6 @@
1
- import { gt } from "../utils/gt.js";
2
1
  import { logCollectedFiles, logErrorAndExit } from "../console/logging.js";
3
2
  import { branchResolutionError, withOriginalError } from "../console/index.js";
3
+ import { api } from "../utils/api.js";
4
4
  import { BranchStep } from "./steps/BranchStep.js";
5
5
  import { UploadSourcesStep } from "./steps/UploadSourcesStep.js";
6
6
  import { SetupStep } from "./steps/SetupStep.js";
@@ -17,9 +17,9 @@ async function runSetupProjectWorkflow(files, options, settings, inlineLibrary)
17
17
  try {
18
18
  logCollectedFiles(files, void 0, inlineLibrary);
19
19
  const timeoutMs = calculateTimeoutMs(options.timeout);
20
- const branchStep = new BranchStep(gt, settings);
21
- const uploadStep = new UploadSourcesStep(gt, settings);
22
- const setupStep = new SetupStep(gt, settings, timeoutMs);
20
+ const branchStep = new BranchStep(api, settings);
21
+ const uploadStep = new UploadSourcesStep(api, settings);
22
+ const setupStep = new SetupStep(api, settings, timeoutMs);
23
23
  const branchData = await branchStep.run();
24
24
  if (!branchData) return logErrorAndExit(branchResolutionError);
25
25
  const uploadedFiles = await uploadStep.run({
@@ -1 +1 @@
1
- {"version":3,"file":"setupProject.js","names":[],"sources":["../../src/workflows/setupProject.ts"],"sourcesContent":["import { logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { logCollectedFiles } from '../console/logging.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Sets up a project by uploading files running the setup step\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The branch data\n */\nexport async function runSetupProjectWorkflow(\n files: FileToUpload[],\n options: TranslateFlags,\n settings: Settings,\n inlineLibrary?: InlineLibrary\n): Promise<{\n branchData: BranchData;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files, undefined, inlineLibrary);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n const uploadStep = new UploadSourcesStep(gt, settings);\n const setupStep = new SetupStep(gt, settings, timeoutMs);\n\n // first run the branch step\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // then run the setup step\n await setupStep.run(uploadedFiles, options.force ?? false);\n\n return { branchData };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Project setup could not be completed. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,wBACpB,OACA,SACA,UACA,eAGC;AACD,KAAI;AAEF,oBAAkB,OAAO,KAAA,GAAW,cAAc;EAGlD,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;EAGrD,MAAM,aAAa,IAAI,WAAW,IAAI,SAAS;EAC/C,MAAM,aAAa,IAAI,kBAAkB,IAAI,SAAS;EACtD,MAAM,YAAY,IAAI,UAAU,IAAI,UAAU,UAAU;EAGxD,MAAM,aAAa,MAAM,WAAW,KAAK;AAEzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;EAI/C,MAAM,gBAAgB,MAAM,WAAW,IAAI;GAAE;GAAO;GAAY,CAAC;AAGjE,QAAM,UAAU,IAAI,eAAe,QAAQ,SAAS,MAAM;AAE1D,SAAO,EAAE,YAAY;UACd,OAAO;AACd,SAAO,gBACL,kBACE,qHACA,MACD,CACF"}
1
+ {"version":3,"file":"setupProject.js","names":[],"sources":["../../src/workflows/setupProject.ts"],"sourcesContent":["import { logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { logCollectedFiles } from '../console/logging.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Sets up a project by uploading files running the setup step\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The branch data\n */\nexport async function runSetupProjectWorkflow(\n files: FileToUpload[],\n options: TranslateFlags,\n settings: Settings,\n inlineLibrary?: InlineLibrary\n): Promise<{\n branchData: BranchData;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files, undefined, inlineLibrary);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(api, settings);\n const uploadStep = new UploadSourcesStep(api, settings);\n const setupStep = new SetupStep(api, settings, timeoutMs);\n\n // first run the branch step\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // then run the setup step\n await setupStep.run(uploadedFiles, options.force ?? false);\n\n return { branchData };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Project setup could not be completed. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,wBACpB,OACA,SACA,UACA,eAGC;AACD,KAAI;AAEF,oBAAkB,OAAO,KAAA,GAAW,cAAc;EAGlD,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;EAGrD,MAAM,aAAa,IAAI,WAAW,KAAK,SAAS;EAChD,MAAM,aAAa,IAAI,kBAAkB,KAAK,SAAS;EACvD,MAAM,YAAY,IAAI,UAAU,KAAK,UAAU,UAAU;EAGzD,MAAM,aAAa,MAAM,WAAW,KAAK;AAEzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;EAI/C,MAAM,gBAAgB,MAAM,WAAW,IAAI;GAAE;GAAO;GAAY,CAAC;AAGjE,QAAM,UAAU,IAAI,eAAe,QAAQ,SAAS,MAAM;AAE1D,SAAO,EAAE,YAAY;UACd,OAAO;AACd,SAAO,gBACL,kBACE,qHACA,MACD,CACF"}
@@ -1,7 +1,7 @@
1
1
  import { logger } from "../console/logger.js";
2
- import { gt } from "../utils/gt.js";
3
2
  import { logCollectedFiles, logErrorAndExit } from "../console/logging.js";
4
3
  import { branchResolutionError, withOriginalError } from "../console/index.js";
4
+ import { api } from "../utils/api.js";
5
5
  import { syncFonts } from "./utils/syncFonts.js";
6
6
  import { BranchStep } from "./steps/BranchStep.js";
7
7
  import { UploadSourcesStep } from "./steps/UploadSourcesStep.js";
@@ -24,11 +24,11 @@ async function runStageFilesWorkflow({ files, options, settings, inlineLibrary }
24
24
  logCollectedFiles(files, void 0, inlineLibrary);
25
25
  await syncFonts(settings);
26
26
  const timeoutMs = calculateTimeoutMs(options.timeout);
27
- const branchStep = new BranchStep(gt, settings);
28
- const uploadStep = new UploadSourcesStep(gt, settings);
27
+ const branchStep = new BranchStep(api, settings);
28
+ const uploadStep = new UploadSourcesStep(api, settings);
29
29
  const userEditDiffsStep = new UserEditDiffsStep(settings);
30
- const setupStep = new SetupStep(gt, settings, timeoutMs);
31
- const enqueueStep = new EnqueueStep(gt, settings, options.force);
30
+ const setupStep = new SetupStep(api, settings, timeoutMs);
31
+ const enqueueStep = new EnqueueStep(api, settings, options.force);
32
32
  const branchData = await branchStep.run();
33
33
  if (!branchData) return logErrorAndExit(branchResolutionError);
34
34
  const uploadedFiles = await uploadStep.run({
@@ -37,13 +37,13 @@ async function runStageFilesWorkflow({ files, options, settings, inlineLibrary }
37
37
  });
38
38
  if (options?.saveLocal) await userEditDiffsStep.run(uploadedFiles);
39
39
  if (settings.tag) try {
40
- await new TagStep(gt, settings, !!options.tag).run(uploadedFiles);
40
+ await new TagStep(api, settings, !!options.tag).run(uploadedFiles);
41
41
  } catch {
42
42
  logger.warn("Failed to create translation tag. Continuing...");
43
43
  }
44
44
  await setupStep.run(uploadedFiles);
45
45
  const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({
46
- gt,
46
+ gt: api,
47
47
  files: uploadedFiles,
48
48
  locales: settings.locales,
49
49
  force: options.force
@@ -1 +1 @@
1
- {"version":3,"file":"stage.js","names":[],"sources":["../../src/workflows/stage.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { TagStep } from './steps/TagStep.js';\nimport { UserEditDiffsStep } from './steps/UserEditDiffsStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Sends multiple files for translation to the API using a workflow pattern\n * @param files - Array of file objects to translate\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The translated content or version ID\n */\nexport async function runStageFilesWorkflow({\n files,\n options,\n settings,\n inlineLibrary,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n inlineLibrary?: InlineLibrary;\n}): Promise<{\n branchData: BranchData;\n enqueueResult: EnqueueFilesResult;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files, undefined, inlineLibrary);\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n const uploadStep = new UploadSourcesStep(gt, settings);\n const userEditDiffsStep = new UserEditDiffsStep(settings);\n const setupStep = new SetupStep(gt, settings, timeoutMs);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // first run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // optionally run the user edit diffs step\n if (options?.saveLocal) {\n await userEditDiffsStep.run(uploadedFiles);\n }\n\n // then run the tag step (non-fatal — tagging failure should not block translations)\n if (settings.tag) {\n try {\n const userProvidedTag = !!options.tag;\n const tagStep = new TagStep(gt, settings, userProvidedTag);\n await tagStep.run(uploadedFiles);\n } catch {\n logger.warn('Failed to create translation tag. Continuing...');\n }\n }\n\n // then run the setup step\n await setupStep.run(uploadedFiles);\n\n // then run the enqueue step\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: uploadedFiles,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n return { branchData, enqueueResult };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be sent for translation. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,sBAAsB,EAC1C,OACA,SACA,UACA,iBASC;AACD,KAAI;AAEF,oBAAkB,OAAO,KAAA,GAAW,cAAc;AAIlD,QAAM,UAAU,SAAS;EAGzB,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;EAGrD,MAAM,aAAa,IAAI,WAAW,IAAI,SAAS;EAC/C,MAAM,aAAa,IAAI,kBAAkB,IAAI,SAAS;EACtD,MAAM,oBAAoB,IAAI,kBAAkB,SAAS;EACzD,MAAM,YAAY,IAAI,UAAU,IAAI,UAAU,UAAU;EACxD,MAAM,cAAc,IAAI,YAAY,IAAI,UAAU,QAAQ,MAAM;EAGhE,MAAM,aAAa,MAAM,WAAW,KAAK;AACzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;EAI/C,MAAM,gBAAgB,MAAM,WAAW,IAAI;GAAE;GAAO;GAAY,CAAC;AAGjE,MAAI,SAAS,UACX,OAAM,kBAAkB,IAAI,cAAc;AAI5C,MAAI,SAAS,IACX,KAAI;AAGF,SAAM,IADc,QAAQ,IAAI,UAAU,CADjB,CAAC,QAAQ,IAErB,CAAC,IAAI,cAAc;UAC1B;AACN,UAAO,KAAK,kDAAkD;;AAKlE,QAAM,UAAU,IAAI,cAAc;EAGlC,MAAM,EAAE,gBAAgB,iBAAiB,MAAM,sBAAsB;GACnE;GACA,OAAO;GACP,SAAS,SAAS;GAClB,OAAO,QAAQ;GAChB,CAAC;AACF,MAAI,aAAa,SAAS,EACxB,QAAO,KACL,uBAAuB,aAAa,OAAO,0BAA0B,aAAa,WAAW,IAAI,KAAK,MACvG;AAKH,SAAO;GAAE;GAAY,eAAA,MAFO,YAAY,IAAI,eAAe;GAEvB;UAC7B,OAAO;AACd,SAAO,gBACL,kBACE,wHACA,MACD,CACF"}
1
+ {"version":3,"file":"stage.js","names":[],"sources":["../../src/workflows/stage.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { api } from '../utils/api.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { TagStep } from './steps/TagStep.js';\nimport { UserEditDiffsStep } from './steps/UserEditDiffsStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport type { InlineLibrary } from '../types/libraries.js';\n\n/**\n * Sends multiple files for translation to the API using a workflow pattern\n * @param files - Array of file objects to translate\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The translated content or version ID\n */\nexport async function runStageFilesWorkflow({\n files,\n options,\n settings,\n inlineLibrary,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n inlineLibrary?: InlineLibrary;\n}): Promise<{\n branchData: BranchData;\n enqueueResult: EnqueueFilesResult;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files, undefined, inlineLibrary);\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(api, settings);\n const uploadStep = new UploadSourcesStep(api, settings);\n const userEditDiffsStep = new UserEditDiffsStep(settings);\n const setupStep = new SetupStep(api, settings, timeoutMs);\n const enqueueStep = new EnqueueStep(api, settings, options.force);\n\n // first run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // optionally run the user edit diffs step\n if (options?.saveLocal) {\n await userEditDiffsStep.run(uploadedFiles);\n }\n\n // then run the tag step (non-fatal — tagging failure should not block translations)\n if (settings.tag) {\n try {\n const userProvidedTag = !!options.tag;\n const tagStep = new TagStep(api, settings, userProvidedTag);\n await tagStep.run(uploadedFiles);\n } catch {\n logger.warn('Failed to create translation tag. Continuing...');\n }\n }\n\n // then run the setup step\n await setupStep.run(uploadedFiles);\n\n // then run the enqueue step\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt: api,\n files: uploadedFiles,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n return { branchData, enqueueResult };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be sent for translation. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,sBAAsB,EAC1C,OACA,SACA,UACA,iBASC;AACD,KAAI;AAEF,oBAAkB,OAAO,KAAA,GAAW,cAAc;AAIlD,QAAM,UAAU,SAAS;EAGzB,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;EAGrD,MAAM,aAAa,IAAI,WAAW,KAAK,SAAS;EAChD,MAAM,aAAa,IAAI,kBAAkB,KAAK,SAAS;EACvD,MAAM,oBAAoB,IAAI,kBAAkB,SAAS;EACzD,MAAM,YAAY,IAAI,UAAU,KAAK,UAAU,UAAU;EACzD,MAAM,cAAc,IAAI,YAAY,KAAK,UAAU,QAAQ,MAAM;EAGjE,MAAM,aAAa,MAAM,WAAW,KAAK;AACzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;EAI/C,MAAM,gBAAgB,MAAM,WAAW,IAAI;GAAE;GAAO;GAAY,CAAC;AAGjE,MAAI,SAAS,UACX,OAAM,kBAAkB,IAAI,cAAc;AAI5C,MAAI,SAAS,IACX,KAAI;AAGF,SAAM,IADc,QAAQ,KAAK,UAAU,CADlB,CAAC,QAAQ,IAErB,CAAC,IAAI,cAAc;UAC1B;AACN,UAAO,KAAK,kDAAkD;;AAKlE,QAAM,UAAU,IAAI,cAAc;EAGlC,MAAM,EAAE,gBAAgB,iBAAiB,MAAM,sBAAsB;GACnE,IAAI;GACJ,OAAO;GACP,SAAS,SAAS;GAClB,OAAO,QAAQ;GAChB,CAAC;AACF,MAAI,aAAa,SAAS,EACxB,QAAO,KACL,uBAAuB,aAAa,OAAO,0BAA0B,aAAa,WAAW,IAAI,KAAK,MACvG;AAKH,SAAO;GAAE;GAAY,eAAA,MAFO,YAAY,IAAI,eAAe;GAEvB;UAC7B,OAAO;AACd,SAAO,gBACL,kBACE,wHACA,MACD,CACF"}
@@ -1,7 +1,7 @@
1
- import type { GT } from 'generaltranslation';
1
+ import type { ApiClient } from '../../utils/api.js';
2
2
  import type { Settings } from '../../types/index.js';
3
3
  import { BranchData } from '../../types/branch.js';
4
- type BranchStepClient = Pick<GT, 'queryBranchData' | 'createBranch'>;
4
+ type BranchStepClient = Pick<ApiClient, 'queryBranchData' | 'createBranch'>;
5
5
  type BranchStepSettings = Pick<Settings, 'branchOptions'>;
6
6
  export declare class BranchStep {
7
7
  private spinner;
@@ -80,15 +80,15 @@ var BranchStep = class {
80
80
  });
81
81
  this.branchData.currentBranch = createBranchResult.branch;
82
82
  } catch (error) {
83
- if (error instanceof ApiError && error.code === 403) {
84
- logger.warn("To enable translation branching, upgrade your plan. Falling back to default branch.");
85
- try {
86
- const createBranchResult = await this.gt.createBranch({
87
- branchName: detectedDefaultBranchName,
88
- defaultBranch: true
89
- });
90
- this.branchData.currentBranch = createBranchResult.branch;
91
- } catch {}
83
+ if (!(error instanceof ApiError) || error.code !== 403) throw error;
84
+ logger.warn("To enable translation branching, upgrade your plan. Falling back to default branch.");
85
+ if (branchData.defaultBranch) this.branchData.currentBranch = branchData.defaultBranch;
86
+ else {
87
+ const createBranchResult = await this.gt.createBranch({
88
+ branchName: detectedDefaultBranchName,
89
+ defaultBranch: true
90
+ });
91
+ this.branchData.currentBranch = createBranchResult.branch;
92
92
  }
93
93
  }
94
94
  else this.branchData.currentBranch = currentBranch;
@@ -1 +1 @@
1
- {"version":3,"file":"BranchStep.js","names":[],"sources":["../../../src/workflows/steps/BranchStep.ts"],"sourcesContent":["import { logErrorAndExit } from '../../console/logging.js';\nimport { logger } from '../../console/logger.js';\nimport type { GT } from 'generaltranslation';\nimport type { Settings } from '../../types/index.js';\nimport chalk from 'chalk';\nimport {\n getCurrentBranch,\n getIncomingBranches,\n getCheckedOutBranches,\n} from '../../git/branches.js';\nimport { BranchData } from '../../types/branch.js';\nimport { ApiError } from 'generaltranslation/errors';\n\ntype BranchStepClient = Pick<GT, 'queryBranchData' | 'createBranch'>;\ntype BranchStepSettings = Pick<Settings, 'branchOptions'>;\n\n// Step 1: Resolve the current branch id & update API with branch information\nexport class BranchStep {\n private spinner = logger.createSpinner('dots');\n private branchData: BranchData;\n private settings: BranchStepSettings;\n private gt: BranchStepClient;\n\n constructor(gt: BranchStepClient, settings: BranchStepSettings) {\n this.gt = gt;\n this.settings = settings;\n this.branchData = {\n currentBranch: {\n id: '',\n name: '',\n },\n incomingBranch: null,\n checkedOutBranch: null,\n };\n }\n\n async run(): Promise<BranchData | null> {\n this.spinner.start(`Resolving branch information...`);\n\n // First get some info about the branches we're working with\n let current: {\n currentBranchName: string;\n defaultBranch: boolean;\n } | null = null;\n let incoming: string[] = [];\n let checkedOut: string[] = [];\n let useDefaultBranch: boolean = true;\n let detectedDefaultBranchName: string = 'main';\n let autoDetectFailed = !this.settings.branchOptions.autoDetectBranches;\n\n if (\n this.settings.branchOptions.enabled &&\n this.settings.branchOptions.autoDetectBranches\n ) {\n const [currentResult, incomingResult, checkedOutResult] =\n await Promise.all([\n getCurrentBranch(this.settings.branchOptions.remoteName),\n getIncomingBranches(this.settings.branchOptions.remoteName),\n getCheckedOutBranches(this.settings.branchOptions.remoteName),\n ]);\n current = currentResult;\n incoming = incomingResult;\n checkedOut = checkedOutResult;\n\n if (currentResult) {\n detectedDefaultBranchName = currentResult.defaultBranchName;\n }\n\n // Try env var detection if git commands failed (e.g. Vercel)\n if (!currentResult) {\n autoDetectFailed = true;\n const vercelBranch = process.env.VERCEL_GIT_COMMIT_REF;\n if (vercelBranch) {\n current = { currentBranchName: vercelBranch, defaultBranch: false };\n }\n }\n\n // If detection succeeded, use the detected branch; otherwise fall back to default\n if (current) {\n useDefaultBranch = false;\n }\n }\n if (\n this.settings.branchOptions.enabled &&\n this.settings.branchOptions.currentBranch\n ) {\n current = {\n currentBranchName: this.settings.branchOptions.currentBranch,\n defaultBranch: current?.defaultBranch ?? false, // we have no way of knowing if this is the default branch without using the auto-detection logic\n };\n useDefaultBranch = false;\n }\n\n const branchData = await this.gt.queryBranchData({\n branchNames: [\n ...(current ? [current.currentBranchName] : []),\n ...incoming,\n ...checkedOut,\n ],\n });\n\n if (useDefaultBranch) {\n if (autoDetectFailed) {\n logger.warn(\n 'Branch auto-detection failed. Falling back to the default branch. Use --branch to specify a branch manually.'\n );\n }\n if (!branchData.defaultBranch) {\n const createBranchResult = await this.gt.createBranch({\n branchName: detectedDefaultBranchName,\n defaultBranch: true,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n } else {\n this.branchData.currentBranch = branchData.defaultBranch;\n }\n } else {\n if (!current) {\n return logErrorAndExit(\n 'The current git branch could not be determined. Specify a custom branch or enable automatic branch detection.'\n );\n }\n const currentBranch = branchData.branches.find(\n (b) => b.name === current.currentBranchName\n );\n if (!currentBranch) {\n try {\n const createBranchResult = await this.gt.createBranch({\n branchName: current.currentBranchName,\n defaultBranch: current.defaultBranch,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n } catch (error) {\n if (error instanceof ApiError && error.code === 403) {\n logger.warn(\n 'To enable translation branching, upgrade your plan. Falling back to default branch.'\n );\n // retry with default branch\n try {\n const createBranchResult = await this.gt.createBranch({\n branchName: detectedDefaultBranchName,\n defaultBranch: true,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n } catch {\n // The fallback branch may already exist.\n }\n }\n }\n } else {\n this.branchData.currentBranch = currentBranch;\n }\n }\n\n if (this.branchData.currentBranch.id === '') {\n return logErrorAndExit(\n 'Something went wrong while resolving branch information. Try again.'\n );\n }\n\n // Now set the incoming and checked out branches (first one that exists)\n this.branchData.incomingBranch =\n incoming\n .map((b) => {\n const branch = branchData.branches.find((bb) => bb.name === b);\n if (branch) {\n return branch;\n } else {\n return null;\n }\n })\n .filter((b) => b !== null)[0] ?? null;\n this.branchData.checkedOutBranch =\n checkedOut\n .map((b) => {\n const branch = branchData.branches.find((bb) => bb.name === b);\n if (branch) {\n return branch;\n } else {\n return null;\n }\n })\n .filter((b) => b !== null)[0] ?? null;\n\n // ALWAYS fallback to default branch for checked out branch (to avoid retranslation)\n if (!this.branchData.checkedOutBranch && branchData.defaultBranch) {\n this.branchData.checkedOutBranch = branchData.defaultBranch;\n }\n\n this.spinner.stop(chalk.green('Branch information resolved successfully'));\n\n return this.branchData;\n }\n}\n"],"mappings":";;;;;;AAiBA,IAAa,aAAb,MAAwB;CACtB,UAAkB,OAAO,cAAc,OAAO;CAC9C;CACA;CACA;CAEA,YAAY,IAAsB,UAA8B;AAC9D,OAAK,KAAK;AACV,OAAK,WAAW;AAChB,OAAK,aAAa;GAChB,eAAe;IACb,IAAI;IACJ,MAAM;IACP;GACD,gBAAgB;GAChB,kBAAkB;GACnB;;CAGH,MAAM,MAAkC;AACtC,OAAK,QAAQ,MAAM,kCAAkC;EAGrD,IAAI,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,MACvC,MAAM,EAAE,SAAS,QAAQ,kBAC3B;AACD,OAAI,CAAC,cACH,KAAI;IACF,MAAM,qBAAqB,MAAM,KAAK,GAAG,aAAa;KACpD,YAAY,QAAQ;KACpB,eAAe,QAAQ;KACxB,CAAC;AACF,SAAK,WAAW,gBAAgB,mBAAmB;YAC5C,OAAO;AACd,QAAI,iBAAiB,YAAY,MAAM,SAAS,KAAK;AACnD,YAAO,KACL,sFACD;AAED,SAAI;MACF,MAAM,qBAAqB,MAAM,KAAK,GAAG,aAAa;OACpD,YAAY;OACZ,eAAe;OAChB,CAAC;AACF,WAAK,WAAW,gBAAgB,mBAAmB;aAC7C;;;OAMZ,MAAK,WAAW,gBAAgB;;AAIpC,MAAI,KAAK,WAAW,cAAc,OAAO,GACvC,QAAO,gBACL,sEACD;AAIH,OAAK,WAAW,iBACd,SACG,KAAK,MAAM;GACV,MAAM,SAAS,WAAW,SAAS,MAAM,OAAO,GAAG,SAAS,EAAE;AAC9D,OAAI,OACF,QAAO;OAEP,QAAO;IAET,CACD,QAAQ,MAAM,MAAM,KAAK,CAAC,MAAM;AACrC,OAAK,WAAW,mBACd,WACG,KAAK,MAAM;GACV,MAAM,SAAS,WAAW,SAAS,MAAM,OAAO,GAAG,SAAS,EAAE;AAC9D,OAAI,OACF,QAAO;OAEP,QAAO;IAET,CACD,QAAQ,MAAM,MAAM,KAAK,CAAC,MAAM;AAGrC,MAAI,CAAC,KAAK,WAAW,oBAAoB,WAAW,cAClD,MAAK,WAAW,mBAAmB,WAAW;AAGhD,OAAK,QAAQ,KAAK,MAAM,MAAM,2CAA2C,CAAC;AAE1E,SAAO,KAAK"}
1
+ {"version":3,"file":"BranchStep.js","names":[],"sources":["../../../src/workflows/steps/BranchStep.ts"],"sourcesContent":["import { logErrorAndExit } from '../../console/logging.js';\nimport { logger } from '../../console/logger.js';\nimport type { ApiClient } from '../../utils/api.js';\nimport type { Settings } from '../../types/index.js';\nimport chalk from 'chalk';\nimport {\n getCurrentBranch,\n getIncomingBranches,\n getCheckedOutBranches,\n} from '../../git/branches.js';\nimport { BranchData } from '../../types/branch.js';\nimport { ApiError } from 'generaltranslation/errors';\n\ntype BranchStepClient = Pick<ApiClient, 'queryBranchData' | 'createBranch'>;\ntype BranchStepSettings = Pick<Settings, 'branchOptions'>;\n\n// Step 1: Resolve the current branch id & update API with branch information\nexport class BranchStep {\n private spinner = logger.createSpinner('dots');\n private branchData: BranchData;\n private settings: BranchStepSettings;\n private gt: BranchStepClient;\n\n constructor(gt: BranchStepClient, settings: BranchStepSettings) {\n this.gt = gt;\n this.settings = settings;\n this.branchData = {\n currentBranch: {\n id: '',\n name: '',\n },\n incomingBranch: null,\n checkedOutBranch: null,\n };\n }\n\n async run(): Promise<BranchData | null> {\n this.spinner.start(`Resolving branch information...`);\n\n // First get some info about the branches we're working with\n let current: {\n currentBranchName: string;\n defaultBranch: boolean;\n } | null = null;\n let incoming: string[] = [];\n let checkedOut: string[] = [];\n let useDefaultBranch: boolean = true;\n let detectedDefaultBranchName: string = 'main';\n let autoDetectFailed = !this.settings.branchOptions.autoDetectBranches;\n\n if (\n this.settings.branchOptions.enabled &&\n this.settings.branchOptions.autoDetectBranches\n ) {\n const [currentResult, incomingResult, checkedOutResult] =\n await Promise.all([\n getCurrentBranch(this.settings.branchOptions.remoteName),\n getIncomingBranches(this.settings.branchOptions.remoteName),\n getCheckedOutBranches(this.settings.branchOptions.remoteName),\n ]);\n current = currentResult;\n incoming = incomingResult;\n checkedOut = checkedOutResult;\n\n if (currentResult) {\n detectedDefaultBranchName = currentResult.defaultBranchName;\n }\n\n // Try env var detection if git commands failed (e.g. Vercel)\n if (!currentResult) {\n autoDetectFailed = true;\n const vercelBranch = process.env.VERCEL_GIT_COMMIT_REF;\n if (vercelBranch) {\n current = { currentBranchName: vercelBranch, defaultBranch: false };\n }\n }\n\n // If detection succeeded, use the detected branch; otherwise fall back to default\n if (current) {\n useDefaultBranch = false;\n }\n }\n if (\n this.settings.branchOptions.enabled &&\n this.settings.branchOptions.currentBranch\n ) {\n current = {\n currentBranchName: this.settings.branchOptions.currentBranch,\n defaultBranch: current?.defaultBranch ?? false, // we have no way of knowing if this is the default branch without using the auto-detection logic\n };\n useDefaultBranch = false;\n }\n\n const branchData = await this.gt.queryBranchData({\n branchNames: [\n ...(current ? [current.currentBranchName] : []),\n ...incoming,\n ...checkedOut,\n ],\n });\n\n if (useDefaultBranch) {\n if (autoDetectFailed) {\n logger.warn(\n 'Branch auto-detection failed. Falling back to the default branch. Use --branch to specify a branch manually.'\n );\n }\n if (!branchData.defaultBranch) {\n const createBranchResult = await this.gt.createBranch({\n branchName: detectedDefaultBranchName,\n defaultBranch: true,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n } else {\n this.branchData.currentBranch = branchData.defaultBranch;\n }\n } else {\n if (!current) {\n return logErrorAndExit(\n 'The current git branch could not be determined. Specify a custom branch or enable automatic branch detection.'\n );\n }\n const currentBranch = branchData.branches.find(\n (b) => b.name === current.currentBranchName\n );\n if (!currentBranch) {\n try {\n const createBranchResult = await this.gt.createBranch({\n branchName: current.currentBranchName,\n defaultBranch: current.defaultBranch,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n } catch (error) {\n if (!(error instanceof ApiError) || error.code !== 403) throw error;\n\n logger.warn(\n 'To enable translation branching, upgrade your plan. Falling back to default branch.'\n );\n if (branchData.defaultBranch) {\n this.branchData.currentBranch = branchData.defaultBranch;\n } else {\n const createBranchResult = await this.gt.createBranch({\n branchName: detectedDefaultBranchName,\n defaultBranch: true,\n });\n this.branchData.currentBranch = createBranchResult.branch;\n }\n }\n } else {\n this.branchData.currentBranch = currentBranch;\n }\n }\n\n if (this.branchData.currentBranch.id === '') {\n return logErrorAndExit(\n 'Something went wrong while resolving branch information. Try again.'\n );\n }\n\n // Now set the incoming and checked out branches (first one that exists)\n this.branchData.incomingBranch =\n incoming\n .map((b) => {\n const branch = branchData.branches.find((bb) => bb.name === b);\n if (branch) {\n return branch;\n } else {\n return null;\n }\n })\n .filter((b) => b !== null)[0] ?? null;\n this.branchData.checkedOutBranch =\n checkedOut\n .map((b) => {\n const branch = branchData.branches.find((bb) => bb.name === b);\n if (branch) {\n return branch;\n } else {\n return null;\n }\n })\n .filter((b) => b !== null)[0] ?? null;\n\n // ALWAYS fallback to default branch for checked out branch (to avoid retranslation)\n if (!this.branchData.checkedOutBranch && branchData.defaultBranch) {\n this.branchData.checkedOutBranch = branchData.defaultBranch;\n }\n\n this.spinner.stop(chalk.green('Branch information resolved successfully'));\n\n return this.branchData;\n }\n}\n"],"mappings":";;;;;;AAiBA,IAAa,aAAb,MAAwB;CACtB,UAAkB,OAAO,cAAc,OAAO;CAC9C;CACA;CACA;CAEA,YAAY,IAAsB,UAA8B;AAC9D,OAAK,KAAK;AACV,OAAK,WAAW;AAChB,OAAK,aAAa;GAChB,eAAe;IACb,IAAI;IACJ,MAAM;IACP;GACD,gBAAgB;GAChB,kBAAkB;GACnB;;CAGH,MAAM,MAAkC;AACtC,OAAK,QAAQ,MAAM,kCAAkC;EAGrD,IAAI,UAGO;EACX,IAAI,WAAqB,EAAE;EAC3B,IAAI,aAAuB,EAAE;EAC7B,IAAI,mBAA4B;EAChC,IAAI,4BAAoC;EACxC,IAAI,mBAAmB,CAAC,KAAK,SAAS,cAAc;AAEpD,MACE,KAAK,SAAS,cAAc,WAC5B,KAAK,SAAS,cAAc,oBAC5B;GACA,MAAM,CAAC,eAAe,gBAAgB,oBACpC,MAAM,QAAQ,IAAI;IAChB,iBAAiB,KAAK,SAAS,cAAc,WAAW;IACxD,oBAAoB,KAAK,SAAS,cAAc,WAAW;IAC3D,sBAAsB,KAAK,SAAS,cAAc,WAAW;IAC9D,CAAC;AACJ,aAAU;AACV,cAAW;AACX,gBAAa;AAEb,OAAI,cACF,6BAA4B,cAAc;AAI5C,OAAI,CAAC,eAAe;AAClB,uBAAmB;IACnB,MAAM,eAAe,QAAQ,IAAI;AACjC,QAAI,aACF,WAAU;KAAE,mBAAmB;KAAc,eAAe;KAAO;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M;GACV,MAAM,SAAS,WAAW,SAAS,MAAM,OAAO,GAAG,SAAS,EAAE;AAC9D,OAAI,OACF,QAAO;OAEP,QAAO;IAET,CACD,QAAQ,MAAM,MAAM,KAAK,CAAC,MAAM;AACrC,OAAK,WAAW,mBACd,WACG,KAAK,MAAM;GACV,MAAM,SAAS,WAAW,SAAS,MAAM,OAAO,GAAG,SAAS,EAAE;AAC9D,OAAI,OACF,QAAO;OAEP,QAAO;IAET,CACD,QAAQ,MAAM,MAAM,KAAK,CAAC,MAAM;AAGrC,MAAI,CAAC,KAAK,WAAW,oBAAoB,WAAW,cAClD,MAAK,WAAW,mBAAmB,WAAW;AAGhD,OAAK,QAAQ,KAAK,MAAM,MAAM,2CAA2C,CAAC;AAE1E,SAAO,KAAK"}
@@ -1,4 +1,4 @@
1
- import { GT } from 'generaltranslation';
1
+ import type { ApiClient } from '../../utils/api.js';
2
2
  import { Settings } from '../../types/index.js';
3
3
  import { FileStatusTracker } from './PollJobsStep.js';
4
4
  import type { InlineLibrary } from '../../types/libraries.js';
@@ -8,11 +8,11 @@ export type DownloadTranslationsInput = {
8
8
  forceDownload?: boolean;
9
9
  };
10
10
  export declare class DownloadTranslationsStep {
11
- private gt;
11
+ private api;
12
12
  private settings;
13
13
  private inlineLibrary?;
14
14
  private spinner;
15
- constructor(gt: GT, settings: Settings, inlineLibrary?: InlineLibrary | undefined);
15
+ constructor(api: ApiClient, settings: Settings, inlineLibrary?: InlineLibrary | undefined);
16
16
  run({ fileTracker, resolveOutputPath, forceDownload, }: DownloadTranslationsInput): Promise<boolean>;
17
17
  private downloadFiles;
18
18
  private downloadFilesWithRetry;
@@ -7,8 +7,8 @@ import path from "node:path";
7
7
  //#region src/workflows/steps/DownloadStep.ts
8
8
  var DownloadTranslationsStep = class {
9
9
  spinner = null;
10
- constructor(gt, settings, inlineLibrary) {
11
- this.gt = gt;
10
+ constructor(api, settings, inlineLibrary) {
11
+ this.api = api;
12
12
  this.settings = settings;
13
13
  this.inlineLibrary = inlineLibrary;
14
14
  }
@@ -24,7 +24,7 @@ var DownloadTranslationsStep = class {
24
24
  this.spinner?.stop(chalk.green("No files to download"));
25
25
  return true;
26
26
  }
27
- const readyTranslations = ((await this.gt.queryFileData({ translatedFiles: currentQueryData.map((item) => ({
27
+ const readyTranslations = ((await this.api.queryFileData({ translatedFiles: currentQueryData.map((item) => ({
28
28
  fileId: item.fileId,
29
29
  versionId: item.versionId,
30
30
  branchId: item.branchId,
@@ -1 +1 @@
1
- {"version":3,"file":"DownloadStep.js","names":[],"sources":["../../../src/workflows/steps/DownloadStep.ts"],"sourcesContent":["import chalk from 'chalk';\nimport path from 'node:path';\nimport { logger } from '../../console/logger.js';\nimport {\n BatchedFiles,\n downloadFileBatch,\n DownloadFileBatchResult,\n} from '../../api/downloadFileBatch.js';\nimport { GT } from 'generaltranslation';\nimport { Settings } from '../../types/index.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport { FileStatusTracker } from './PollJobsStep.js';\nimport { TEMPLATE_FILE_NAME } from '../../utils/constants.js';\nimport type { InlineLibrary } from '../../types/libraries.js';\n\nexport type DownloadTranslationsInput = {\n fileTracker: FileStatusTracker;\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n forceDownload?: boolean;\n};\n\nexport class DownloadTranslationsStep {\n private spinner: ReturnType<typeof logger.createProgressBar> | null = null;\n\n constructor(\n private gt: GT,\n private settings: Settings,\n private inlineLibrary?: InlineLibrary\n ) {}\n\n async run({\n fileTracker,\n resolveOutputPath,\n forceDownload,\n }: DownloadTranslationsInput): Promise<boolean> {\n this.spinner = logger.createProgressBar(fileTracker.completed.size);\n this.spinner.start('Downloading files...');\n\n return this.downloadFiles(fileTracker, resolveOutputPath, forceDownload);\n }\n\n private async downloadFiles(\n fileTracker: FileStatusTracker,\n resolveOutputPath: (sourcePath: string, locale: string) => string | null,\n forceDownload?: boolean\n ): Promise<boolean> {\n try {\n // Only download files that are marked as completed\n const currentQueryData = Array.from(fileTracker.completed.values());\n\n // If no files to download, we're done\n if (currentQueryData.length === 0) {\n this.spinner?.stop(chalk.green('No files to download'));\n return true;\n }\n\n // Check for translations\n const responseData = await this.gt.queryFileData({\n translatedFiles: currentQueryData.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n locale: item.locale,\n })),\n });\n const translatedFiles = responseData.translatedFiles || [];\n\n // Filter for ready translations\n const readyTranslations = translatedFiles.filter(\n (file) => file.completedAt !== null\n );\n let missingCount = 0;\n\n if (readyTranslations.length < currentQueryData.length) {\n const readyKeys = new Set(\n readyTranslations.map(\n (t) => `${t.branchId}:${t.fileId}:${t.versionId}:${t.locale}`\n )\n );\n const missing = currentQueryData.filter(\n (item) =>\n !readyKeys.has(\n `${item.branchId}:${item.fileId}:${item.versionId}:${item.locale}`\n )\n );\n missingCount = missing.length;\n logger.warn(\n `Failed to download ${missing.length} file(s):\\n${missing.map((f) => `- ${f.fileName} (${f.locale})`).join('\\n')}`\n );\n for (const f of missing) {\n recordWarning(\n 'failed_download',\n f.fileName,\n `Failed to download for locale ${f.locale}`\n );\n }\n }\n\n // Review gating: skip completed translations for normal files whose\n // effective requiresReview policy is true but that are not approved\n // yet. Skips are intentional, not failures — a review-gated file is\n // simply absent locally and falls back to source behavior.\n // GTJSON is exempt: it is always requested, and the platform filters\n // unapproved components out of the served content itself.\n const requiresReviewPaths =\n this.settings.files?.requiresReviewPaths ?? new Set<string>();\n const reviewGatedKeys = new Set<string>();\n if (requiresReviewPaths.size > 0) {\n for (const translation of readyTranslations) {\n if (translation.approvedAt !== null) continue;\n const fileKey = `${translation.branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;\n const fileProperties = fileTracker.completed.get(fileKey);\n if (!fileProperties) continue;\n if (fileProperties.fileName === TEMPLATE_FILE_NAME) continue;\n const absolutePath = path.resolve(\n process.cwd(),\n fileProperties.fileName\n );\n if (!requiresReviewPaths.has(absolutePath)) continue;\n reviewGatedKeys.add(fileKey);\n fileTracker.completed.delete(fileKey);\n fileTracker.skipped.set(fileKey, fileProperties);\n recordWarning(\n 'pending_review',\n fileProperties.fileName,\n `Translation for locale ${translation.locale} requires review and is not approved yet`\n );\n }\n if (reviewGatedKeys.size > 0) {\n logger.info(\n `Skipped ${reviewGatedKeys.size} file(s) awaiting review approval. They will download once approved.`\n );\n }\n }\n\n // Prepare batch download data\n const batchFiles: BatchedFiles = readyTranslations\n .map((translation) => {\n const fileKey = `${translation.branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;\n\n const fileProperties = fileTracker.completed.get(fileKey);\n if (!fileProperties) {\n return null;\n }\n const outputPath = resolveOutputPath(\n fileProperties.fileName,\n translation.locale\n );\n\n // Skip downloading GTJSON files that are not in the files configuration\n if (outputPath === null) {\n fileTracker.completed.delete(fileKey);\n fileTracker.skipped.set(fileKey, fileProperties);\n return null;\n }\n return {\n branchId: translation.branchId,\n fileId: translation.fileId,\n versionId: translation.versionId,\n locale: translation.locale,\n inputPath: fileProperties.fileName,\n outputPath,\n };\n })\n .filter((file) => file !== null) as BatchedFiles;\n\n if (batchFiles.length > 0) {\n const batchResult = await this.downloadFilesWithRetry(\n fileTracker,\n batchFiles,\n forceDownload\n );\n this.spinner?.stop(\n chalk.green(\n `Downloaded ${batchResult.successful.length} files${batchResult.skipped.length > 0 ? `, skipped ${batchResult.skipped.length} files` : ''}`\n )\n );\n if (batchResult.failed.length > 0) {\n logger.warn(\n `Failed to download ${batchResult.failed.length} files: ${batchResult.failed.map((f) => f.inputPath).join('\\n')}`\n );\n for (const f of batchResult.failed) {\n recordWarning(\n 'failed_download',\n f.inputPath,\n `Failed to download for locale ${f.locale}`\n );\n }\n }\n } else if (missingCount > 0) {\n this.spinner?.stop(\n chalk.yellow('No files downloaded - see warnings above')\n );\n } else {\n this.spinner?.stop(chalk.green('No files to download'));\n }\n\n return true;\n } catch (error) {\n this.spinner?.stop(\n chalk.red('An error occurred while downloading translations')\n );\n logger.error(chalk.red('Error: ') + error);\n return false;\n }\n }\n\n private async downloadFilesWithRetry(\n fileTracker: FileStatusTracker,\n files: BatchedFiles,\n forceDownload?: boolean,\n maxRetries: number = 3,\n initialDelay: number = 1000\n ): Promise<DownloadFileBatchResult> {\n let remainingFiles = files;\n let allSuccessful: BatchedFiles = [];\n let retryCount = 0;\n let allSkipped: BatchedFiles = [];\n while (remainingFiles.length > 0 && retryCount <= maxRetries) {\n const batchResult = await downloadFileBatch(\n fileTracker,\n remainingFiles,\n this.settings,\n forceDownload,\n this.inlineLibrary\n );\n\n allSuccessful = [...allSuccessful, ...batchResult.successful];\n allSkipped = [...allSkipped, ...batchResult.skipped];\n\n this.spinner?.advance(\n batchResult.successful.length +\n batchResult.skipped.length +\n batchResult.failed.length\n );\n\n // If no failures or we've exhausted retries, we're done\n if (batchResult.failed.length === 0 || retryCount === maxRetries) {\n return {\n successful: allSuccessful,\n failed: batchResult.failed,\n skipped: allSkipped,\n };\n }\n\n // Calculate exponential backoff delay\n const delay = initialDelay * Math.pow(2, retryCount);\n logger.error(\n chalk.yellow(\n `Retrying ${batchResult.failed.length} failed file(s) in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})...`\n )\n );\n\n // Wait before retrying\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n remainingFiles = batchResult.failed;\n retryCount++;\n }\n\n return {\n successful: allSuccessful,\n failed: remainingFiles,\n skipped: allSkipped,\n };\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,2BAAb,MAAsC;CACpC,UAAsE;CAEtE,YACE,IACA,UACA,eACA;AAHQ,OAAA,KAAA;AACA,OAAA,WAAA;AACA,OAAA,gBAAA;;CAGV,MAAM,IAAI,EACR,aACA,mBACA,iBAC8C;AAC9C,OAAK,UAAU,OAAO,kBAAkB,YAAY,UAAU,KAAK;AACnE,OAAK,QAAQ,MAAM,uBAAuB;AAE1C,SAAO,KAAK,cAAc,aAAa,mBAAmB,cAAc;;CAG1E,MAAc,cACZ,aACA,mBACA,eACkB;AAClB,MAAI;GAEF,MAAM,mBAAmB,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../../../src/workflows/steps/DownloadStep.ts"],"sourcesContent":["import chalk from 'chalk';\nimport path from 'node:path';\nimport { logger } from '../../console/logger.js';\nimport {\n BatchedFiles,\n downloadFileBatch,\n DownloadFileBatchResult,\n} from '../../api/downloadFileBatch.js';\nimport type { ApiClient } from '../../utils/api.js';\nimport { Settings } from '../../types/index.js';\nimport { recordWarning } from '../../state/translateWarnings.js';\nimport { FileStatusTracker } from './PollJobsStep.js';\nimport { TEMPLATE_FILE_NAME } from '../../utils/constants.js';\nimport type { InlineLibrary } from '../../types/libraries.js';\n\nexport type DownloadTranslationsInput = {\n fileTracker: FileStatusTracker;\n resolveOutputPath: (sourcePath: string, locale: string) => string | null;\n forceDownload?: boolean;\n};\n\nexport class DownloadTranslationsStep {\n private spinner: ReturnType<typeof logger.createProgressBar> | null = null;\n\n constructor(\n private api: ApiClient,\n private settings: Settings,\n private inlineLibrary?: InlineLibrary\n ) {}\n\n async run({\n fileTracker,\n resolveOutputPath,\n forceDownload,\n }: DownloadTranslationsInput): Promise<boolean> {\n this.spinner = logger.createProgressBar(fileTracker.completed.size);\n this.spinner.start('Downloading files...');\n\n return this.downloadFiles(fileTracker, resolveOutputPath, forceDownload);\n }\n\n private async downloadFiles(\n fileTracker: FileStatusTracker,\n resolveOutputPath: (sourcePath: string, locale: string) => string | null,\n forceDownload?: boolean\n ): Promise<boolean> {\n try {\n // Only download files that are marked as completed\n const currentQueryData = Array.from(fileTracker.completed.values());\n\n // If no files to download, we're done\n if (currentQueryData.length === 0) {\n this.spinner?.stop(chalk.green('No files to download'));\n return true;\n }\n\n // Check for translations\n const responseData = await this.api.queryFileData({\n translatedFiles: currentQueryData.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n locale: item.locale,\n })),\n });\n const translatedFiles = responseData.translatedFiles || [];\n\n // Filter for ready translations\n const readyTranslations = translatedFiles.filter(\n (file) => file.completedAt !== null\n );\n let missingCount = 0;\n\n if (readyTranslations.length < currentQueryData.length) {\n const readyKeys = new Set(\n readyTranslations.map(\n (t) => `${t.branchId}:${t.fileId}:${t.versionId}:${t.locale}`\n )\n );\n const missing = currentQueryData.filter(\n (item) =>\n !readyKeys.has(\n `${item.branchId}:${item.fileId}:${item.versionId}:${item.locale}`\n )\n );\n missingCount = missing.length;\n logger.warn(\n `Failed to download ${missing.length} file(s):\\n${missing.map((f) => `- ${f.fileName} (${f.locale})`).join('\\n')}`\n );\n for (const f of missing) {\n recordWarning(\n 'failed_download',\n f.fileName,\n `Failed to download for locale ${f.locale}`\n );\n }\n }\n\n // Review gating: skip completed translations for normal files whose\n // effective requiresReview policy is true but that are not approved\n // yet. Skips are intentional, not failures — a review-gated file is\n // simply absent locally and falls back to source behavior.\n // GTJSON is exempt: it is always requested, and the platform filters\n // unapproved components out of the served content itself.\n const requiresReviewPaths =\n this.settings.files?.requiresReviewPaths ?? new Set<string>();\n const reviewGatedKeys = new Set<string>();\n if (requiresReviewPaths.size > 0) {\n for (const translation of readyTranslations) {\n if (translation.approvedAt !== null) continue;\n const fileKey = `${translation.branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;\n const fileProperties = fileTracker.completed.get(fileKey);\n if (!fileProperties) continue;\n if (fileProperties.fileName === TEMPLATE_FILE_NAME) continue;\n const absolutePath = path.resolve(\n process.cwd(),\n fileProperties.fileName\n );\n if (!requiresReviewPaths.has(absolutePath)) continue;\n reviewGatedKeys.add(fileKey);\n fileTracker.completed.delete(fileKey);\n fileTracker.skipped.set(fileKey, fileProperties);\n recordWarning(\n 'pending_review',\n fileProperties.fileName,\n `Translation for locale ${translation.locale} requires review and is not approved yet`\n );\n }\n if (reviewGatedKeys.size > 0) {\n logger.info(\n `Skipped ${reviewGatedKeys.size} file(s) awaiting review approval. They will download once approved.`\n );\n }\n }\n\n // Prepare batch download data\n const batchFiles: BatchedFiles = readyTranslations\n .map((translation) => {\n const fileKey = `${translation.branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;\n\n const fileProperties = fileTracker.completed.get(fileKey);\n if (!fileProperties) {\n return null;\n }\n const outputPath = resolveOutputPath(\n fileProperties.fileName,\n translation.locale\n );\n\n // Skip downloading GTJSON files that are not in the files configuration\n if (outputPath === null) {\n fileTracker.completed.delete(fileKey);\n fileTracker.skipped.set(fileKey, fileProperties);\n return null;\n }\n return {\n branchId: translation.branchId,\n fileId: translation.fileId,\n versionId: translation.versionId,\n locale: translation.locale,\n inputPath: fileProperties.fileName,\n outputPath,\n };\n })\n .filter((file) => file !== null) as BatchedFiles;\n\n if (batchFiles.length > 0) {\n const batchResult = await this.downloadFilesWithRetry(\n fileTracker,\n batchFiles,\n forceDownload\n );\n this.spinner?.stop(\n chalk.green(\n `Downloaded ${batchResult.successful.length} files${batchResult.skipped.length > 0 ? `, skipped ${batchResult.skipped.length} files` : ''}`\n )\n );\n if (batchResult.failed.length > 0) {\n logger.warn(\n `Failed to download ${batchResult.failed.length} files: ${batchResult.failed.map((f) => f.inputPath).join('\\n')}`\n );\n for (const f of batchResult.failed) {\n recordWarning(\n 'failed_download',\n f.inputPath,\n `Failed to download for locale ${f.locale}`\n );\n }\n }\n } else if (missingCount > 0) {\n this.spinner?.stop(\n chalk.yellow('No files downloaded - see warnings above')\n );\n } else {\n this.spinner?.stop(chalk.green('No files to download'));\n }\n\n return true;\n } catch (error) {\n this.spinner?.stop(\n chalk.red('An error occurred while downloading translations')\n );\n logger.error(chalk.red('Error: ') + error);\n return false;\n }\n }\n\n private async downloadFilesWithRetry(\n fileTracker: FileStatusTracker,\n files: BatchedFiles,\n forceDownload?: boolean,\n maxRetries: number = 3,\n initialDelay: number = 1000\n ): Promise<DownloadFileBatchResult> {\n let remainingFiles = files;\n let allSuccessful: BatchedFiles = [];\n let retryCount = 0;\n let allSkipped: BatchedFiles = [];\n while (remainingFiles.length > 0 && retryCount <= maxRetries) {\n const batchResult = await downloadFileBatch(\n fileTracker,\n remainingFiles,\n this.settings,\n forceDownload,\n this.inlineLibrary\n );\n\n allSuccessful = [...allSuccessful, ...batchResult.successful];\n allSkipped = [...allSkipped, ...batchResult.skipped];\n\n this.spinner?.advance(\n batchResult.successful.length +\n batchResult.skipped.length +\n batchResult.failed.length\n );\n\n // If no failures or we've exhausted retries, we're done\n if (batchResult.failed.length === 0 || retryCount === maxRetries) {\n return {\n successful: allSuccessful,\n failed: batchResult.failed,\n skipped: allSkipped,\n };\n }\n\n // Calculate exponential backoff delay\n const delay = initialDelay * Math.pow(2, retryCount);\n logger.error(\n chalk.yellow(\n `Retrying ${batchResult.failed.length} failed file(s) in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})...`\n )\n );\n\n // Wait before retrying\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n remainingFiles = batchResult.failed;\n retryCount++;\n }\n\n return {\n successful: allSuccessful,\n failed: remainingFiles,\n skipped: allSkipped,\n };\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,2BAAb,MAAsC;CACpC,UAAsE;CAEtE,YACE,KACA,UACA,eACA;AAHQ,OAAA,MAAA;AACA,OAAA,WAAA;AACA,OAAA,gBAAA;;CAGV,MAAM,IAAI,EACR,aACA,mBACA,iBAC8C;AAC9C,OAAK,UAAU,OAAO,kBAAkB,YAAY,UAAU,KAAK;AACnE,OAAK,QAAQ,MAAM,uBAAuB;AAE1C,SAAO,KAAK,cAAc,aAAa,mBAAmB,cAAc;;CAG1E,MAAc,cACZ,aACA,mBACA,eACkB;AAClB,MAAI;GAEF,MAAM,mBAAmB,MAAM,KAAK,YAAY,UAAU,QAAQ,CAAC;AAGnE,OAAI,iBAAiB,WAAW,GAAG;AACjC,SAAK,SAAS,KAAK,MAAM,MAAM,uBAAuB,CAAC;AACvD,WAAO;;GAeT,MAAM,sBAHkB,MARG,KAAK,IAAI,cAAc,EAChD,iBAAiB,iBAAiB,KAAK,UAAU;IAC/C,QAAQ,KAAK;IACb,WAAW,KAAK;IAChB,UAAU,KAAK;IACf,QAAQ,KAAK;IACd,EAAE,EACJ,CAAC,EACmC,mBAAmB,EAAE,E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AAM;AAC1C,UAAO;;;CAIX,MAAc,uBACZ,aACA,OACA,eACA,aAAqB,GACrB,eAAuB,KACW;EAClC,IAAI,iBAAiB;EACrB,IAAI,gBAA8B,EAAE;EACpC,IAAI,aAAa;EACjB,IAAI,aAA2B,EAAE;AACjC,SAAO,eAAe,SAAS,KAAK,cAAc,YAAY;GAC5D,MAAM,cAAc,MAAM,kBACxB,aACA,gBACA,KAAK,UACL,eACA,KAAK,cACN;AAED,mBAAgB,CAAC,GAAG,eAAe,GAAG,YAAY,WAAW;AAC7D,gBAAa,CAAC,GAAG,YAAY,GAAG,YAAY,QAAQ;AAEpD,QAAK,SAAS,QACZ,YAAY,WAAW,SACrB,YAAY,QAAQ,SACpB,YAAY,OAAO,OACtB;AAGD,OAAI,YAAY,OAAO,WAAW,KAAK,eAAe,WACpD,QAAO;IACL,YAAY;IACZ,QAAQ,YAAY;IACpB,SAAS;IACV;GAIH,MAAM,QAAQ,eAAe,KAAK,IAAI,GAAG,WAAW;AACpD,UAAO,MACL,MAAM,OACJ,YAAY,YAAY,OAAO,OAAO,qBAAqB,MAAM,cAAc,aAAa,EAAE,GAAG,WAAW,MAC7G,CACF;AAGD,SAAM,IAAI,SAAS,YAAY,WAAW,SAAS,MAAM,CAAC;AAE1D,oBAAiB,YAAY;AAC7B;;AAGF,SAAO;GACL,YAAY;GACZ,QAAQ;GACR,SAAS;GACV"}
@@ -1,12 +1,14 @@
1
1
  import type { EnqueueFilesResult } from 'generaltranslation/types';
2
- import { GT } from 'generaltranslation';
3
- import { Settings } from '../../types/index.js';
2
+ import type { ApiClient } from '../../utils/api.js';
3
+ import type { Settings } from '../../types/index.js';
4
4
  import type { FileReference } from 'generaltranslation/types';
5
+ type EnqueueClient = Pick<ApiClient, 'enqueueFiles'>;
5
6
  export declare class EnqueueStep {
6
7
  private gt;
7
8
  private settings;
8
9
  private force?;
9
10
  private spinner;
10
- constructor(gt: GT, settings: Settings, force?: boolean | undefined);
11
+ constructor(gt: EnqueueClient, settings: Settings, force?: boolean | undefined);
11
12
  run(files: FileReference[]): Promise<EnqueueFilesResult>;
12
13
  }
14
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"EnqueueStep.js","names":[],"sources":["../../../src/workflows/steps/EnqueueStep.ts"],"sourcesContent":["import type { EnqueueFilesResult } from 'generaltranslation/types';\nimport { logger } from '../../console/logger.js';\nimport { GT } from 'generaltranslation';\nimport { Settings } from '../../types/index.js';\nimport type { FileReference } from 'generaltranslation/types';\nimport chalk from 'chalk';\n\nexport class EnqueueStep {\n private spinner = logger.createSpinner('dots');\n\n constructor(\n private gt: GT,\n private settings: Settings,\n private force?: boolean\n ) {}\n\n async run(files: FileReference[]): Promise<EnqueueFilesResult> {\n if (files.length === 0) {\n return {\n jobData: {},\n locales: this.settings.locales,\n message: 'No files need to be enqueued',\n };\n }\n\n this.spinner.start('Enqueuing translations...');\n\n const result = await this.gt.enqueueFiles(files, {\n sourceLocale: this.settings.defaultLocale,\n targetLocales: this.settings.locales,\n modelProvider: this.settings.modelProvider,\n force: this.force,\n });\n this.spinner.stop(chalk.green('Translations enqueued successfully'));\n return result;\n }\n}\n"],"mappings":";;;AAOA,IAAa,cAAb,MAAyB;CACvB,UAAkB,OAAO,cAAc,OAAO;CAE9C,YACE,IACA,UACA,OACA;AAHQ,OAAA,KAAA;AACA,OAAA,WAAA;AACA,OAAA,QAAA;;CAGV,MAAM,IAAI,OAAqD;AAC7D,MAAI,MAAM,WAAW,EACnB,QAAO;GACL,SAAS,EAAE;GACX,SAAS,KAAK,SAAS;GACvB,SAAS;GACV;AAGH,OAAK,QAAQ,MAAM,4BAA4B;EAE/C,MAAM,SAAS,MAAM,KAAK,GAAG,aAAa,OAAO;GAC/C,cAAc,KAAK,SAAS;GAC5B,eAAe,KAAK,SAAS;GAC7B,eAAe,KAAK,SAAS;GAC7B,OAAO,KAAK;GACb,CAAC;AACF,OAAK,QAAQ,KAAK,MAAM,MAAM,qCAAqC,CAAC;AACpE,SAAO"}
1
+ {"version":3,"file":"EnqueueStep.js","names":[],"sources":["../../../src/workflows/steps/EnqueueStep.ts"],"sourcesContent":["import type { EnqueueFilesResult } from 'generaltranslation/types';\nimport { logger } from '../../console/logger.js';\nimport type { ApiClient } from '../../utils/api.js';\nimport type { Settings } from '../../types/index.js';\nimport type { FileReference } from 'generaltranslation/types';\nimport chalk from 'chalk';\n\ntype EnqueueClient = Pick<ApiClient, 'enqueueFiles'>;\n\nexport class EnqueueStep {\n private spinner = logger.createSpinner('dots');\n\n constructor(\n private gt: EnqueueClient,\n private settings: Settings,\n private force?: boolean\n ) {}\n\n async run(files: FileReference[]): Promise<EnqueueFilesResult> {\n if (files.length === 0) {\n return {\n jobData: {},\n locales: this.settings.locales,\n message: 'No files need to be enqueued',\n };\n }\n\n this.spinner.start('Enqueuing translations...');\n\n const result = await this.gt.enqueueFiles(files, {\n sourceLocale: this.settings.defaultLocale,\n targetLocales: this.settings.locales,\n modelProvider: this.settings.modelProvider,\n force: this.force,\n });\n this.spinner.stop(chalk.green('Translations enqueued successfully'));\n return result;\n }\n}\n"],"mappings":";;;AASA,IAAa,cAAb,MAAyB;CACvB,UAAkB,OAAO,cAAc,OAAO;CAE9C,YACE,IACA,UACA,OACA;AAHQ,OAAA,KAAA;AACA,OAAA,WAAA;AACA,OAAA,QAAA;;CAGV,MAAM,IAAI,OAAqD;AAC7D,MAAI,MAAM,WAAW,EACnB,QAAO;GACL,SAAS,EAAE;GACX,SAAS,KAAK,SAAS;GACvB,SAAS;GACV;AAGH,OAAK,QAAQ,MAAM,4BAA4B;EAE/C,MAAM,SAAS,MAAM,KAAK,GAAG,aAAa,OAAO;GAC/C,cAAc,KAAK,SAAS;GAC5B,eAAe,KAAK,SAAS;GAC7B,eAAe,KAAK,SAAS;GAC7B,OAAO,KAAK;GACb,CAAC;AACF,OAAK,QAAQ,KAAK,MAAM,MAAM,qCAAqC,CAAC;AACpE,SAAO"}
@@ -1,4 +1,4 @@
1
- import { GT } from 'generaltranslation';
1
+ import type { ApiClient } from '../../utils/api.js';
2
2
  import { EnqueueFilesResult } from 'generaltranslation/types';
3
3
  import type { FileProperties } from '../../types/files.js';
4
4
  import { type InlineLibrary } from '../../types/libraries.js';
@@ -20,11 +20,11 @@ export type PollJobsOutput = {
20
20
  fileTracker: FileStatusTracker;
21
21
  };
22
22
  export declare class PollTranslationJobsStep {
23
- private gt;
23
+ private api;
24
24
  private inlineLibrary?;
25
25
  private spinner;
26
26
  private previousProgress;
27
- constructor(gt: GT, inlineLibrary?: InlineLibrary | undefined);
27
+ constructor(api: ApiClient, inlineLibrary?: InlineLibrary | undefined);
28
28
  run({ fileTracker, fileQueryData, jobData, timeoutDuration, forceRetranslation, }: PollJobsInput): Promise<PollJobsOutput>;
29
29
  private updateSpinner;
30
30
  private generateStatusSuffixText;
@@ -7,8 +7,8 @@ import chalk from "chalk";
7
7
  var PollTranslationJobsStep = class {
8
8
  spinner = null;
9
9
  previousProgress = 0;
10
- constructor(gt, inlineLibrary) {
11
- this.gt = gt;
10
+ constructor(api, inlineLibrary) {
11
+ this.api = api;
12
12
  this.inlineLibrary = inlineLibrary;
13
13
  }
14
14
  async run({ fileTracker, fileQueryData, jobData, timeoutDuration, forceRetranslation }) {
@@ -20,13 +20,13 @@ var PollTranslationJobsStep = class {
20
20
  fileQueryData.forEach((item) => {
21
21
  filePropertiesMap.set(getFileTranslationKey(item), item);
22
22
  });
23
- if (!forceRetranslation) (await queryCompletedTranslationKeys(this.gt, fileQueryData)).forEach((fileKey) => {
23
+ if (!forceRetranslation) (await queryCompletedTranslationKeys(this.api, fileQueryData)).forEach((fileKey) => {
24
24
  const fileProperties = filePropertiesMap.get(fileKey);
25
25
  if (fileProperties) fileTracker.completed.set(fileKey, fileProperties);
26
26
  });
27
27
  const jobMap = /* @__PURE__ */ new Map();
28
28
  Object.entries(jobData.jobData).forEach(([jobId, job]) => {
29
- const jobLocale = this.gt.resolveAliasLocale(job.targetLocale);
29
+ const jobLocale = this.api.resolveAliasLocale(job.targetLocale);
30
30
  const key = `${job.branchId}:${job.fileId}:${job.versionId}:${jobLocale}`;
31
31
  jobMap.set(key, {
32
32
  ...job,
@@ -36,7 +36,7 @@ var PollTranslationJobsStep = class {
36
36
  });
37
37
  const jobFileMap = /* @__PURE__ */ new Map();
38
38
  Object.entries(jobData.jobData).forEach(([jobId, job]) => {
39
- const jobLocale = this.gt.resolveAliasLocale(job.targetLocale);
39
+ const jobLocale = this.api.resolveAliasLocale(job.targetLocale);
40
40
  jobFileMap.set(jobId, {
41
41
  branchId: job.branchId,
42
42
  fileId: job.fileId,
@@ -68,7 +68,7 @@ var PollTranslationJobsStep = class {
68
68
  intervalCheck = setInterval(async () => {
69
69
  try {
70
70
  const jobIds = Array.from(jobFileMap.keys());
71
- const jobStatusResponse = await this.gt.checkJobStatus(jobIds);
71
+ const jobStatusResponse = await this.api.checkJobStatus(jobIds);
72
72
  for (const job of jobStatusResponse) {
73
73
  const jobFileProperties = jobFileMap.get(job.jobId);
74
74
  if (jobFileProperties) {