Skip to content

Commit 6cb5efd

Browse files
chore: resolved comments
1 parent 773234d commit 6cb5efd

File tree

6 files changed

+885
-577
lines changed

6 files changed

+885
-577
lines changed

messages/assess.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"commandDescription": "If your Omnistudio components are on custom data model, assess the migration of the components from Omnistudio managed package runtime to Omnistudio standard runtime. If your Omnistudio components are on standard data model, assess the updates made to the component names and references.See: https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_naming_conventions.htm&type=5",
1414
"errorNoOrgResults": "No records found in the org '%s' to migrate.",
1515
"onlyFlagDescription": "Migrate a single component: os | ip | fc | dm | autonumber | cl",
16+
"invalidOnlyFlag": "Invalid parameter entered. Select a valid parameter from these options: os | ip | fc | dm | autonumber | cl",
1617
"couldNotTruncate": "We couldn't clear all %s records.",
1718
"couldNotTruncateOmnniProcess": "We couldn't clear all records of your %s because the %s is referenced in an Omniscript or a Flexcard.",
1819
"invalidOrRepeatingOmniscriptElementNames": "Omniscript with invalid or duplicate element names found. Rename your Omniscript elements and try again.",

src/commands/omnistudio/migration/assess.ts

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,11 @@ export default class Assess extends OmniStudioBaseCommand {
281281
private async assessDataRaptors(assesmentInfo: AssessmentInfo, namespace: string, conn: Connection): Promise<void> {
282282
const drMigrator = new DataRaptorMigrationTool(namespace, conn, Logger, messages, this.ux);
283283
assesmentInfo.dataRaptorAssessmentInfos = await drMigrator.assess();
284-
Logger.logVerbose(
285-
messages.getMessage('assessedDataRaptorsCount', [assesmentInfo.dataRaptorAssessmentInfos.length])
284+
this.logAssessmentCompletionIfNeeded(
285+
'assessedDataRaptorsCount',
286+
'dataRaptorAssessmentCompleted',
287+
assesmentInfo.dataRaptorAssessmentInfos.length
286288
);
287-
Logger.log(messages.getMessage('dataRaptorAssessmentCompleted'));
288289
}
289290

290291
private async assessFlexCards(
@@ -294,10 +295,12 @@ export default class Assess extends OmniStudioBaseCommand {
294295
allVersions: boolean
295296
): Promise<void> {
296297
const flexMigrator = new CardMigrationTool(namespace, conn, Logger, messages, this.ux, allVersions);
297-
Logger.logVerbose(messages.getMessage('flexCardAssessment'));
298298
assesmentInfo.flexCardAssessmentInfos = await flexMigrator.assess();
299-
Logger.logVerbose(messages.getMessage('assessedFlexCardsCount', [assesmentInfo.flexCardAssessmentInfos.length]));
300-
Logger.log(messages.getMessage('flexCardAssessmentCompleted'));
299+
this.logAssessmentCompletionIfNeeded(
300+
'assessedFlexCardsCount',
301+
'flexCardAssessmentCompleted',
302+
assesmentInfo.flexCardAssessmentInfos.length
303+
);
301304
}
302305

303306
private async assessOmniScripts(
@@ -308,7 +311,6 @@ export default class Assess extends OmniStudioBaseCommand {
308311
exportType: OmniScriptExportType
309312
): Promise<void> {
310313
const exportComponentType = exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
311-
Logger.logVerbose(messages.getMessage('omniScriptAssessment', [exportComponentType]));
312314
const osMigrator = new OmniScriptMigrationTool(exportType, namespace, conn, Logger, messages, this.ux, allVersions);
313315
const newOmniAssessmentInfo = await osMigrator.assess(
314316
assesmentInfo.dataRaptorAssessmentInfos,
@@ -327,19 +329,26 @@ export default class Assess extends OmniStudioBaseCommand {
327329
if (exportType === OmniScriptExportType.OS) {
328330
// For OmniScript assessment, update osAssessmentInfos
329331
assesmentInfo.omniAssessmentInfo.osAssessmentInfos = newOmniAssessmentInfo.osAssessmentInfos;
330-
Logger.logVerbose(
331-
messages.getMessage('assessedOmniScriptsCount', [assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length])
332-
);
333332
} else {
334333
// For Integration Procedure assessment, update ipAssessmentInfos
335334
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos = newOmniAssessmentInfo.ipAssessmentInfos;
336-
Logger.logVerbose(
337-
messages.getMessage('assessedIntegrationProceduresCount', [
338-
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
339-
])
335+
}
336+
337+
if (exportType === OmniScriptExportType.OS) {
338+
this.logAssessmentCompletionIfNeeded(
339+
'assessedOmniScriptsCount',
340+
'omniScriptAssessmentCompleted',
341+
assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length,
342+
[exportComponentType]
343+
);
344+
} else {
345+
this.logAssessmentCompletionIfNeeded(
346+
'assessedIntegrationProceduresCount',
347+
'omniScriptAssessmentCompleted',
348+
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
349+
[exportComponentType]
340350
);
341351
}
342-
Logger.log(messages.getMessage('omniScriptAssessmentCompleted', [exportComponentType]));
343352
}
344353

345354
private async assessGlobalAutoNumbers(
@@ -378,4 +387,21 @@ export default class Assess extends OmniStudioBaseCommand {
378387
};
379388
}
380389
}
390+
391+
/**
392+
* Logs assessment completion with count and completion message if needed
393+
* Skips logging when standard data model with metadata API is enabled
394+
*/
395+
private logAssessmentCompletionIfNeeded(
396+
countMessageKey: string,
397+
completionMessageKey: string,
398+
count: number,
399+
completionParams?: string[]
400+
): void {
401+
if (isStandardDataModelWithMetadataAPIEnabled()) {
402+
return;
403+
}
404+
Logger.logVerbose(messages.getMessage(countMessageKey, [count]));
405+
Logger.log(messages.getMessage(completionMessageKey, completionParams || []));
406+
}
381407
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ export default class Migrate extends OmniStudioBaseCommand {
7575
}),
7676
};
7777

78+
// OmniStudio components that don't need migration logging when metadata API is enabled
79+
private readonly OMNISTUDIO_COMPONENTS_FOR_LOGGING = [
80+
Constants.Omniscript,
81+
Constants.IntegrationProcedure,
82+
Constants.Flexcard,
83+
Constants.DataMapper,
84+
];
85+
7886
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7987
public async run(): Promise<any> {
8088
Logger.initialiseLogger(this.ux, this.logger, 'migrate', this.flags.verbose);
@@ -389,22 +397,10 @@ export default class Migrate extends OmniStudioBaseCommand {
389397
for (const cls of migrationObjects) {
390398
try {
391399
const componentName = cls.getName();
392-
const shouldSkipLogging = this.shouldSkipMigrationLogging(componentName);
393400

394-
if (!shouldSkipLogging) {
395-
Logger.log(messages.getMessage('migratingComponent', [componentName]));
396-
}
397-
debugTimer.lap('Migrating: ' + componentName);
401+
this.logMigrationStart(componentName, debugTimer);
398402
const results = await cls.migrate();
399-
400-
// Skip success/failure logs for components that don't need migration when metadata API is enabled
401-
if (!shouldSkipLogging) {
402-
if (results.some((result) => result?.errors?.length > 0) && !isStandardDataModelWithMetadataAPIEnabled()) {
403-
Logger.error(messages.getMessage('migrationFailed', [componentName]));
404-
} else {
405-
Logger.log(messages.getMessage('migrationCompleted', [componentName]));
406-
}
407-
}
403+
this.logMigrationComplete(componentName, results);
408404

409405
objectMigrationResults = objectMigrationResults.concat(
410406
results.map((r) => {
@@ -434,6 +430,33 @@ export default class Migrate extends OmniStudioBaseCommand {
434430
return objectMigrationResults;
435431
}
436432

433+
/**
434+
* Log the start of component migration and track timing
435+
*/
436+
private logMigrationStart(componentName: string, debugTimer: DebugTimer): void {
437+
const shouldSkipLogging = this.shouldSkipMigrationLogging(componentName);
438+
439+
if (!shouldSkipLogging) {
440+
Logger.log(messages.getMessage('migratingComponent', [componentName]));
441+
debugTimer.lap('Migrating: ' + componentName);
442+
}
443+
}
444+
445+
/**
446+
* Log the completion or failure of component migration
447+
*/
448+
private logMigrationComplete(componentName: string, results: MigrationResult[]): void {
449+
const shouldSkipLogging = this.shouldSkipMigrationLogging(componentName);
450+
451+
if (!shouldSkipLogging) {
452+
if (results.some((result) => result?.errors?.length > 0) && !isStandardDataModelWithMetadataAPIEnabled()) {
453+
Logger.error(messages.getMessage('migrationFailed', [componentName]));
454+
} else {
455+
Logger.log(messages.getMessage('migrationCompleted', [componentName]));
456+
}
457+
}
458+
}
459+
437460
/**
438461
* Check if migration logging should be skipped for a component
439462
* Returns true if Metadata API is enabled and the component doesn't need migration
@@ -444,14 +467,9 @@ export default class Migrate extends OmniStudioBaseCommand {
444467
}
445468

446469
// Skip logging for OmniStudio components that don't need migration when metadata API is enabled
447-
const omnistudioComponents = [
448-
Constants.Omniscript,
449-
Constants.IntegrationProcedure,
450-
Constants.Flexcard,
451-
Constants.DataMapper,
452-
];
453-
454-
return omnistudioComponents.some((component) => componentName.toLowerCase().includes(component.toLowerCase()));
470+
return this.OMNISTUDIO_COMPONENTS_FOR_LOGGING.some((component) =>
471+
componentName.toLowerCase().includes(component.toLowerCase())
472+
);
455473
}
456474

457475
/**

src/utils/config/OmniStudioMetadataCleanupService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class OmniStudioMetadataCleanupService {
6767
try {
6868
if (isStandardDataModelWithMetadataAPIEnabled()) {
6969
// When on Standard data model with Metadata API enabled, the metadata tables should not be cleaned
70-
return true;
70+
return false;
7171
}
7272

7373
Logger.log(this.messages.getMessage('startingMetadataCleanup'));

0 commit comments

Comments
 (0)