Multiple surveys support for translations download#4
Multiple surveys support for translations download#4rama-medallia wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for downloading translations for multiple surveys in a single CLI invocation.
Changes:
- Update CLI parser to accept repeated
--survey-uuid/--survey-namevalues. - Update translations download flow to handle multiple surveys (IDs in filenames, multiple flat views, combined “Where Used”).
- Update surveys “Where Used” mapping to include survey name context and return a pre-built
Map.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/parser/parser.ts | Accept arrays for survey UUID/name options and add multi-survey examples. |
| src/core/services/translations/types.ts | Change download options to accept multiple surveys. |
| src/core/services/translations/translations-service.ts | Download/export using multiple translation tag IDs; merge “Where Used”; update filenames and notes. |
| src/core/services/surveys/surveys-service.ts | Update “Where Used” builder to include survey name and pre-build a Map. |
| src/commands/translations.ts | Collect multiple surveys from CLI options and pass to download service. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (surveyUuids && surveyUuids.length > 0) { | ||
| for (const uuid of surveyUuids) { | ||
| const survey = await surveyService.getSurveyByUuid(uuid as string); | ||
| if (!survey) { | ||
| throw new ValidationError(`Survey not found for UUID: "${uuid}"`); | ||
| } | ||
| surveyItemList.push(survey); | ||
| } | ||
| survey = surveys[0]; | ||
| } | ||
|
|
||
| if (!survey) { | ||
| if (surveyName) { | ||
| throw new ValidationError(`Survey not found for name: "${surveyName}"`); | ||
| } else { | ||
| throw new ValidationError(`Survey not found for UUID: "${surveyUuid}"`); | ||
| // Process survey names | ||
| if (surveyNames && surveyNames.length > 0) { | ||
| for (const surveyName of surveyNames) { | ||
| const surveys = await surveyService.getSurveyByName(surveyName as string); | ||
| if (surveys.length > 1) { |
There was a problem hiding this comment.
Survey lookups are awaited sequentially inside loops, which adds avoidable latency when multiple surveys are provided. Consider fetching in parallel (e.g., build an array of promises and await Promise.all(...)) and then append results in order.
| notes.push('Contains variable text'); | ||
| } | ||
|
|
||
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. |
There was a problem hiding this comment.
Correct typo: 'idenfity' → 'identify'.
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. | |
| // TODO: Add usage note - Remove due to API limitations and not able to identify usage for all kes/texts in all surveys. |
There was a problem hiding this comment.
To be discussed, mostly will be removed later on.
| notes.push('Contains variable text'); | ||
| } | ||
|
|
||
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. |
There was a problem hiding this comment.
Correct typo: 'kes' → 'keys'.
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. | |
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all keys/texts in all surveys. |
There was a problem hiding this comment.
To be discussed, mostly will be removed later on.
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. | ||
| if (usedInMultiplePlaces) { | ||
| notes.push('Used in multiple surveys'); | ||
| } | ||
|
|
||
| return ''; | ||
| return notes.length > 0 | ||
| ? `${notes.join(' and ')} - please be mindful of the structure when performing the translation.` | ||
| : ''; |
There was a problem hiding this comment.
The TODO comment is contradictory to the behavior (it says to remove the usage note due to limitations, but the code adds it). Also, joining notes with ' and ' can produce awkward output when multiple notes exist (e.g., 'Contains HTML/code and variable text and Used in multiple surveys ...'). Consider clarifying/removing the TODO and improving the note composition (e.g., join with commas and a final 'and', or split the usage note into a separate sentence).
| // TODO: Add usage note - Remove due to API limitations and not able to idenfity usage for all kes/texts in all surveys. | |
| if (usedInMultiplePlaces) { | |
| notes.push('Used in multiple surveys'); | |
| } | |
| return ''; | |
| return notes.length > 0 | |
| ? `${notes.join(' and ')} - please be mindful of the structure when performing the translation.` | |
| : ''; | |
| // Add usage note when we know the text is reused in multiple places. | |
| // Due to API limitations we may not be able to determine usage for all keys/texts in all surveys. | |
| if (usedInMultiplePlaces) { | |
| notes.push('Used in multiple surveys'); | |
| } | |
| if (notes.length === 0) { | |
| return ''; | |
| } | |
| let notesText: string; | |
| if (notes.length === 1) { | |
| notesText = notes[0]; | |
| } else if (notes.length === 2) { | |
| notesText = `${notes[0]} and ${notes[1]}`; | |
| } else { | |
| const allButLast = notes.slice(0, -1).join(', '); | |
| const last = notes[notes.length - 1]; | |
| notesText = `${allButLast} and ${last}`; | |
| } | |
| return `${notesText} - please be mindful of the structure when performing the translation.`; |
There was a problem hiding this comment.
To be discussed, mostly will be removed later on.
Currently, you can only provide one survey UUID or name:
mec translations download --survey-uuid f0473723-45f0-4397-b39e-d2bf3d955a20 mec translations download --survey-name "Customer Feedback"With this enhancement, you can specify multiple surveys: