Skip to content

Commit 890f6b2

Browse files
Merge pull request #365 from mdmehran-qureshi/prerelease/develop-ga
@W-19086044 Add custom label migration functionality and resolve merge conflicts
2 parents 873baf3 + 2d41d44 commit 890f6b2

File tree

18 files changed

+1429
-20
lines changed

18 files changed

+1429
-20
lines changed

messages/assess.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"omnistudio:migration:assess -u [email protected] --only=ip",
66
"omnistudio:migration:assess -u [email protected] --only=os",
77
"omnistudio:migration:assess -u [email protected] --only=fc",
8+
"omnistudio:migration:assess -u [email protected] --only=cl",
89
"omnistudio:migration:assess -u [email protected] --only=autonumber"
910
],
1011
"commandDescription": "Assess migration of omnistudio components from custom objects to standard objects",
1112
"errorNoOrgResults": "No results found for the org '%s'.",
12-
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dm | autonumber",
13-
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dm | autonumber",
13+
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dm | autonumber | cl",
14+
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dm | autonumber | cl",
1415
"couldNotDeactivateOmniProcesses": "Could not deactivate current OmniProcesses",
1516
"couldNotTruncate": "Could not truncate %s",
1617
"couldNotTruncateOmnniProcess": "Could not truncate OmniProcess. Please make sure your OS/IP is not referenced in an OmniScrirpt or Flex Card.",
@@ -99,6 +100,10 @@
99100
"integrationProcedureNameChangeMessage": "Integration Procedure reference %s will be changed to %s during migration.",
100101
"integrationProcedureManualUpdateMessage": "Integration Procedure reference %s may need manual updates after migration.",
101102
"duplicateCardNameMessage": "Potential duplicate: Another card has the same name %s after name cleaning. This may cause conflicts during migration",
103+
"startingCustomLabelAssessment": "Starting Custom Label assessment",
104+
"assessedCustomLabelsCount": "Assessed %s Custom Labels",
105+
"customLabelAssessmentCompleted": "Custom Label assessment completed",
106+
"errorDuringCustomLabelAssessment": "Error during Custom Label assessment: %s",
102107
"duplicateGlobalAutoNumberNameMessage": "Potential duplicate: Another Global Auto Number has the same name %s after name cleaning. This may cause conflicts during migration",
103108
"existingApexPrompt": "Do you have a sfdc project that already contains the APEX classes retrieved from your org? [y/n]",
104109
"enterExistingProjectPath": "Enter the path to the project folder that contains the retrieved APEX classes",
@@ -179,5 +184,8 @@
179184
"nameMappingUndefined": "Undefined name mapping found",
180185
"experienceSiteException": "We’ve encountered an exception while processing Experience Cloud sites.",
181186
"reservedKeysFoundInPropertySet": "Reserved keys found in any of output response transformation fields: %s.",
182-
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again"
187+
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again",
188+
"errorFetchingCustomLabels": "Error fetching custom labels: %s",
189+
"customLabelAssessmentSummary": "Custom Label with same name and different value is already exist without namespace.",
190+
"generatedCustomLabelAssessmentReportPage": "Generated custom label assessment report page %s of %s with %s labels"
183191
}

messages/migrate.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
"omnistudio:migration:migrate -u [email protected] --only=os",
77
"omnistudio:migration:migrate -u [email protected] --only=fc",
88
"omnistudio:migration:migrate -u [email protected] --only=autonumber",
9+
"omnistudio:migration:migrate -u [email protected] --only=cl",
910
"omnistudio:migration:migrate -u [email protected] -r apex,lwc",
1011
"omnistudio:migration:migrate -u [email protected] -r apex",
1112
"omnistudio:migration:migrate -u [email protected] -r lwc"
1213
],
1314
"commandDescription": "Migrate omnistudio components from custom objects to standard objects",
1415
"namespaceFlagDescription": "The namespace of the package",
1516
"errorNoOrgResults": "No results found for the org '%s'.",
16-
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dm | autonumber",
17-
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dm | autonumber",
17+
"onlyFlagDescription": "Migrate a single element: os | ip | fc | dm | autonumber | cl",
18+
"invalidOnlyFlag": "Invalid flag, valid options are: os | ip | fc | dm | autonumber | cl",
1819
"couldNotDeactivateOmniProcesses": "Could not deactivate current OmniProcesses",
1920
"couldNotTruncate": "Could not truncate %s",
2021
"couldNotTruncateOmnniProcess": "Could not truncate OmniProcess. Please make sure your OS/IP is not referenced in an OmniScrirpt or Flex Card.",
@@ -70,6 +71,7 @@
7071
"foundFlexCardsToMigrate": "Found %s FlexCards to migrate",
7172
"foundOmniScriptsToMigrate": "Found %s %s to migrate",
7273
"foundGlobalAutoNumbersToMigrate": "Found %s GlobalAutoNumbers to migrate",
74+
"foundCustomLabelsToMigrate": "Found %s Custom Labels to migrate",
7375
"allVersionsInfo": "allVersions : %s",
7476
"migrationInitialization": "Migration Initialization: Using namespace: %s",
7577
"apiVersionInfo": "API Version: %s",
@@ -232,5 +234,24 @@
232234
"enableStandardRuntimeAfterDesigner": "Standard designer setup successful, proceeding with Standard Runtime enablement",
233235
"skipStandardRuntimeDueToFailure": "Skipping Standard Runtime enablement due to designer setup failure",
234236
"errorCheckingStandardDesigner": "Failed to check standard designer status for package %s: %s",
235-
"relatedObjectsConsentNotGiven": "The related objects will not be processed because the user declined consent."
236-
}
237+
"relatedObjectsConsentNotGiven": "The related objects will not be processed because the user declined consent.",
238+
"startingCustomLabelMigration": "Starting Custom Labels migration",
239+
"customLabelMigrationCompleted": "Custom Labels migration completed. %s labels processed out of %s total",
240+
"errorDuringCustomLabelMigration": "Error during Custom Labels migration: %s",
241+
"callingCloneCustomLabelsAPI": "Calling clone-custom-labels API for namespace: %s",
242+
"cloneCustomLabelsAPIResponse": "Clone custom labels API response summary: %s results",
243+
"errorCallingCloneCustomLabelsAPI": "Error calling clone-custom-labels API: %s",
244+
"callingCloneCustomLabelLocalizationsAPI": "Calling clone-custom-label-localizations API for namespace: %s",
245+
"cloneCustomLabelLocalizationsAPIResponse": "Clone custom label localizations API response summary: %s labels with localizations",
246+
"errorCallingCloneCustomLabelLocalizationsAPI": "Error calling clone-custom-label-localizations API: %s",
247+
"skippingCustomLabelTruncation": "Skipping truncation for Custom Labels",
248+
"labelAlreadyExistsWarning": "Label already exists with status: %s",
249+
"failedToCloneLabelError": "Failed to clone label with status: %s",
250+
"localizationAlreadyExistsWarning": "Localization for %s already exists",
251+
"failedToCreateLocalizationError": "Failed to create localization for %s",
252+
"generatingCustomLabelsReport": "Generating custom labels migration report with %s labels (all statuses) across %s pages of %s each",
253+
"generatedCustomLabelsReportPage": "Generated custom labels report page %s of %s with %s labels",
254+
"errorFetchingCustomLabels": "Error fetching custom labels: %s",
255+
"customLabelAssessmentSummary": "Custom Label with same name and different value is already exist without namespace.",
256+
"generatedCustomLabelAssessmentReportPage": "Generated custom label assessment report page %s of %s with %s labels"
257+
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Constants } from '../../../utils/constants/stringContants';
1818
import { ProjectPathUtil } from '../../../utils/projectPathUtil';
1919
import { PreMigrate } from '../../../migration/premigrate';
2020
import { PostMigrate } from '../../../migration/postMigrate';
21+
import { CustomLabelsUtil } from '../../../utils/customLabels';
2122

2223
Messages.importMessagesDirectory(__dirname);
2324
const messages = Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'assess');
@@ -115,6 +116,8 @@ export default class Assess extends OmniStudioBaseCommand {
115116
},
116117
flexipageAssessmentInfos: [],
117118
experienceSiteAssessmentInfos: [],
119+
customLabelAssessmentInfos: [],
120+
customLabelStatistics: { totalLabels: 0, canBeAutomated: 0, needManualIntervention: 0 },
118121
};
119122

120123
Logger.log(messages.getMessage('assessmentInitialization', [String(namespace)]));
@@ -214,6 +217,7 @@ export default class Assess extends OmniStudioBaseCommand {
214217
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.OS);
215218
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.IP);
216219
await this.assessGlobalAutoNumbers(assesmentInfo, namespace, conn);
220+
await this.assessCustomLabels(assesmentInfo, namespace, conn);
217221
return;
218222
}
219223

@@ -233,6 +237,9 @@ export default class Assess extends OmniStudioBaseCommand {
233237
case Constants.GlobalAutoNumber:
234238
await this.assessGlobalAutoNumbers(assesmentInfo, namespace, conn);
235239
break;
240+
case Constants.CustomLabel:
241+
await this.assessCustomLabels(assesmentInfo, namespace, conn);
242+
break;
236243
default:
237244
throw new Error(messages.getMessage('invalidOnlyFlag'));
238245
}
@@ -315,4 +322,21 @@ export default class Assess extends OmniStudioBaseCommand {
315322
);
316323
Logger.log(messages.getMessage('globalAutoNumberAssessmentCompleted'));
317324
}
325+
326+
private async assessCustomLabels(assesmentInfo: AssessmentInfo, namespace: string, conn: Connection): Promise<void> {
327+
try {
328+
Logger.log(messages.getMessage('startingCustomLabelAssessment'));
329+
const customLabelResult = await CustomLabelsUtil.fetchCustomLabels(conn, namespace, messages);
330+
assesmentInfo.customLabelAssessmentInfos = customLabelResult.labels;
331+
assesmentInfo.customLabelStatistics = customLabelResult.statistics;
332+
Logger.logVerbose(
333+
messages.getMessage('assessedCustomLabelsCount', [assesmentInfo.customLabelAssessmentInfos.length])
334+
);
335+
Logger.log(messages.getMessage('customLabelAssessmentCompleted'));
336+
} catch (error) {
337+
Logger.error(messages.getMessage('errorDuringCustomLabelAssessment', [(error as Error).message]));
338+
assesmentInfo.customLabelAssessmentInfos = [];
339+
assesmentInfo.customLabelStatistics = { totalLabels: 0, canBeAutomated: 0, needManualIntervention: 0 };
340+
}
341+
}
318342
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { InvalidEntityTypeError, MigrationResult, MigrationTool } from '../../..
1717
import { ResultsBuilder } from '../../../utils/resultsbuilder';
1818
import { CardMigrationTool } from '../../../migration/flexcard';
1919
import { OmniScriptExportType, OmniScriptMigrationTool } from '../../../migration/omniscript';
20+
import { CustomLabelsMigrationTool } from '../../../migration/customLabels';
2021
import { Logger } from '../../../utils/logger';
2122
import OmnistudioRelatedObjectMigrationFacade from '../../../migration/related/OmnistudioRelatedObjectMigrationFacade';
2223
import { generatePackageXml } from '../../../utils/generatePackageXml';
@@ -439,6 +440,7 @@ export default class Migrate extends OmniStudioBaseCommand {
439440
),
440441
new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions),
441442
new GlobalAutoNumberMigrationTool(namespace, conn, this.logger, messages, this.ux),
443+
new CustomLabelsMigrationTool(namespace, conn, this.logger, messages, this.ux),
442444
];
443445
} else {
444446
// For single component migration, the order doesn't matter as much
@@ -479,6 +481,9 @@ export default class Migrate extends OmniStudioBaseCommand {
479481
case Constants.GlobalAutoNumber:
480482
migrationObjects.push(new GlobalAutoNumberMigrationTool(namespace, conn, this.logger, messages, this.ux));
481483
break;
484+
case Constants.CustomLabel:
485+
migrationObjects.push(new CustomLabelsMigrationTool(namespace, conn, this.logger, messages, this.ux));
486+
break;
482487
default:
483488
throw new Error(messages.getMessage('invalidOnlyFlag'));
484489
}
@@ -655,6 +660,7 @@ export default class Migrate extends OmniStudioBaseCommand {
655660
migratedId: undefined,
656661
warnings: [],
657662
migratedName: '',
663+
localizationStatus: record['localizationStatus'] || {},
658664
};
659665

660666
if (migrationResults.results.has(record['Id'])) {
@@ -670,6 +676,7 @@ export default class Migrate extends OmniStudioBaseCommand {
670676
} else {
671677
obj.status = 'Complete';
672678
}
679+
673680
obj.errors = errors;
674681
obj.migratedId = recordResults.id;
675682
obj.warnings = recordResults.warnings;

0 commit comments

Comments
 (0)