Skip to content

Commit 73cc261

Browse files
Merge pull request #453 from sf-aastha-paruthi/u/aparuthi/usecaseMetadataEnabled
@W-20303952 Usecase2b, 3b Metadata API Enabled
2 parents 71d3292 + 35c8844 commit 73cc261

31 files changed

+2240
-568
lines changed

messages/assess.json

Lines changed: 8 additions & 4 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.",
@@ -204,7 +205,7 @@
204205
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again",
205206
"assessmentSuccessfulMessage": "Migration assessment for org %s is complete and reports are ready for review in the folder %s",
206207
"errorCheckingOmniStudioMetadata": "Error while checking the Omnistudio settings metadata status: %s.",
207-
"omniStudioSettingsMetadataAlreadyEnabled": "The Omnistudio Metadata setting is already enabled with standard data model. No need for migration.",
208+
"omniStudioSettingsMetadataAlreadyEnabled": "The Omnistudio Metadata setting is already enabled with standard data model.",
208209
"missingMandatoryField": "Missing mandatory field: %s for %s",
209210
"validatingDrVersioningDisabled": "Checking the Data Mapper versioning setting in your org.",
210211
"drVersioningDisabled": "Proceeding with the assessment as the Data Mapper versioning setting is disabled.",
@@ -217,9 +218,12 @@
217218
"packagesHaveDifferentValue": "Both the InstalledIndustryPackage and TheFirstInstalledOmniPackage have different values.",
218219
"failedToCheckPackagesValue": "Failed to check the value of packages in Omni Interaction Configuration.",
219220
"packageDetails": "Your org contains only the TheFirstInstalledOmniPackage Omni Interaction Configuration.",
220-
"orgUsecaseDetails": "The org is on %s data model with %s ",
221-
"globalAutoNumberUnSupportedInOmnistudioPackage": "Omni Global Auto Number is not supported in Omnistudio Foundation package orgs.",
221+
"orgUsecaseDetails": "The org is on %s data model with %s and Omnistudio Metadata API %s",
222+
"globalAutoNumberUnSupportedInOmnistudioPackage": "Feature not supported - Omni Global Auto Number is not supported in Omnistudio Foundation package orgs.",
222223
"omniStudioAllVersionsProcessingConsent": "Org uses the standard data model. All versions of Omnistudio components such as Omniscripts, Data Mappers, Integration Procedures, and Flexcards must be assessed. But you’ve not specified -a or allversions flag in the command. Proceed to assess all versions of the Omnistudio components? [y/n]",
223224
"omniStudioAllVersionsProcessingConsentNotGiven": "You've not consented to assess all versions of the Omnistudio components. We cannot proceed with the assessment.",
224-
"omniStudioAllVersionsProcessingConsentGiven": "You've consented to assess all versions of the Omnistudio components."
225+
"omniStudioAllVersionsProcessingConsentGiven": "You've consented to assess all versions of the Omnistudio components.",
226+
"preparingStorageForMetadataEnabledOrg": "Preparing storage for %s org on Standard Data Model with Metadata API enabled",
227+
"processingNotRequired": "Assessment not required for Standard Data Model Orgs with Metadata API enabled",
228+
"skippingTruncation": "Skipping Trunction as standard data model org"
225229
}

messages/migrate.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
"metadataCleanupConsentNotGiven": "You’ve not consented to proceed with the Omnistudio metadata table cleanup. We’ll not be able to proceed with the migration.",
298298
"omniStudioMetadataEnableConsentMessage": "As part of the migration process, the Omnistudio Metadata setting will be enabled. After the setting is enabled, you cannot disable it. Do you want to proceed? [y/n]",
299299
"errorCheckingOmniStudioMetadata": "Error while checking the Omnistudio settings metadata status: %s.",
300-
"omniStudioSettingsMetadataAlreadyEnabled": "The Omnistudio Metadata setting is already enabled with standard data model. No need for migration.",
300+
"omniStudioSettingsMetadataAlreadyEnabled": "The Omnistudio Metadata setting is already enabled with standard data model.",
301301
"omniStudioSettingsMetadataEnabled": "The Omnistudio Metadata setting is enabled with standard data model.",
302302
"timeoutEnablingOmniStudioSettingsMetadata": "Timeout while checking the metadata enablement status. Tried for %s seconds. Refer to registered email for more details.",
303303
"errorEnablingOmniStudioSettingsMetadata": "Error while enabling the Omnistudio Metadata setting: %s.",
@@ -320,6 +320,9 @@
320320
"packagesHaveDifferentValue": "Both the InstalledIndustryPackage and TheFirstInstalledOmniPackage have different values.",
321321
"failedToCheckPackagesValue": "Failed to check the value of packages in Omni Interaction Configuration.",
322322
"packageDetails": "Your org contains only the TheFirstInstalledOmniPackage Omni Interaction Configuration.",
323-
"orgUsecaseDetails": "The Org is on %s data model with %s ",
324-
"globalAutoNumberUnSupportedInOmnistudioPackage": "Omni Global Auto Number is not supported in Omnistudio Foundation package orgs."
323+
"globalAutoNumberUnSupportedInOmnistudioPackage": "Feature not supported - Omni Global Auto Number is not supported in Omnistudio Foundation package orgs.",
324+
"orgUsecaseDetails": "The Org is on %s data model with %s and Omnistudio Metadata API %s",
325+
"preparingStorageForMetadataEnabledOrg": "Preparing storage for %s org on Standard Data Model with Metadata API enabled",
326+
"processingNotRequired": "Migration not required for Standard Data Model Orgs with Metadata API enabled",
327+
"skippingTruncation": "Skipping Trunction as standard data model org"
325328
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import { ProjectPathUtil } from '../../../utils/projectPathUtil';
2020
import { PreMigrate } from '../../../migration/premigrate';
2121
import { PostMigrate } from '../../../migration/postMigrate';
2222
import { CustomLabelsUtil } from '../../../utils/customLabels';
23-
import { initializeDataModelService, isFoundationPackage, isStandardDataModel } from '../../../utils/dataModelService';
23+
import {
24+
initializeDataModelService,
25+
isFoundationPackage,
26+
isStandardDataModel,
27+
isStandardDataModelWithMetadataAPIEnabled,
28+
} from '../../../utils/dataModelService';
2429

2530
import { ValidatorService } from '../../../utils/validatorService';
2631

@@ -98,7 +103,9 @@ export default class Assess extends OmniStudioBaseCommand {
98103

99104
// Handle all versions prerequisite for standard data model
100105
if (isStandardDataModel()) {
101-
allVersions = await preMigrate.handleAllVersionsPrerequisites(allVersions);
106+
if (!isStandardDataModelWithMetadataAPIEnabled()) {
107+
allVersions = await preMigrate.handleAllVersionsPrerequisites(allVersions);
108+
}
102109
}
103110
if (relatedObjects) {
104111
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
@@ -274,10 +281,11 @@ export default class Assess extends OmniStudioBaseCommand {
274281
private async assessDataRaptors(assesmentInfo: AssessmentInfo, namespace: string, conn: Connection): Promise<void> {
275282
const drMigrator = new DataRaptorMigrationTool(namespace, conn, Logger, messages, this.ux);
276283
assesmentInfo.dataRaptorAssessmentInfos = await drMigrator.assess();
277-
Logger.logVerbose(
278-
messages.getMessage('assessedDataRaptorsCount', [assesmentInfo.dataRaptorAssessmentInfos.length])
284+
this.logAssessmentCompletionIfNeeded(
285+
'assessedDataRaptorsCount',
286+
'dataRaptorAssessmentCompleted',
287+
assesmentInfo.dataRaptorAssessmentInfos.length
279288
);
280-
Logger.log(messages.getMessage('dataRaptorAssessmentCompleted'));
281289
}
282290

283291
private async assessFlexCards(
@@ -287,10 +295,12 @@ export default class Assess extends OmniStudioBaseCommand {
287295
allVersions: boolean
288296
): Promise<void> {
289297
const flexMigrator = new CardMigrationTool(namespace, conn, Logger, messages, this.ux, allVersions);
290-
Logger.logVerbose(messages.getMessage('flexCardAssessment'));
291298
assesmentInfo.flexCardAssessmentInfos = await flexMigrator.assess();
292-
Logger.logVerbose(messages.getMessage('assessedFlexCardsCount', [assesmentInfo.flexCardAssessmentInfos.length]));
293-
Logger.log(messages.getMessage('flexCardAssessmentCompleted'));
299+
this.logAssessmentCompletionIfNeeded(
300+
'assessedFlexCardsCount',
301+
'flexCardAssessmentCompleted',
302+
assesmentInfo.flexCardAssessmentInfos.length
303+
);
294304
}
295305

296306
private async assessOmniScripts(
@@ -301,7 +311,6 @@ export default class Assess extends OmniStudioBaseCommand {
301311
exportType: OmniScriptExportType
302312
): Promise<void> {
303313
const exportComponentType = exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
304-
Logger.logVerbose(messages.getMessage('omniScriptAssessment', [exportComponentType]));
305314
const osMigrator = new OmniScriptMigrationTool(exportType, namespace, conn, Logger, messages, this.ux, allVersions);
306315
const newOmniAssessmentInfo = await osMigrator.assess(
307316
assesmentInfo.dataRaptorAssessmentInfos,
@@ -320,19 +329,26 @@ export default class Assess extends OmniStudioBaseCommand {
320329
if (exportType === OmniScriptExportType.OS) {
321330
// For OmniScript assessment, update osAssessmentInfos
322331
assesmentInfo.omniAssessmentInfo.osAssessmentInfos = newOmniAssessmentInfo.osAssessmentInfos;
323-
Logger.logVerbose(
324-
messages.getMessage('assessedOmniScriptsCount', [assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length])
325-
);
326332
} else {
327333
// For Integration Procedure assessment, update ipAssessmentInfos
328334
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos = newOmniAssessmentInfo.ipAssessmentInfos;
329-
Logger.logVerbose(
330-
messages.getMessage('assessedIntegrationProceduresCount', [
331-
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
332-
])
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]
333350
);
334351
}
335-
Logger.log(messages.getMessage('omniScriptAssessmentCompleted', [exportComponentType]));
336352
}
337353

338354
private async assessGlobalAutoNumbers(
@@ -371,4 +387,21 @@ export default class Assess extends OmniStudioBaseCommand {
371387
};
372388
}
373389
}
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+
}
374407
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
initializeDataModelService,
3737
isFoundationPackage,
3838
isStandardDataModel,
39+
isStandardDataModelWithMetadataAPIEnabled,
3940
} from '../../../utils/dataModelService';
4041
import { NameMappingRegistry } from '../../../migration/NameMappingRegistry';
4142
import { ValidatorService } from '../../../utils/validatorService';
@@ -74,6 +75,9 @@ export default class Migrate extends OmniStudioBaseCommand {
7475
}),
7576
};
7677

78+
// OmniStudio components that don't need migration logging when metadata API is enabled
79+
private readonly OMNISTUDIO_COMPONENTS_FOR_LOGGING = [Constants.CustomLabel, Constants.GlobalAutoNumber];
80+
7781
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7882
public async run(): Promise<any> {
7983
Logger.initialiseLogger(this.ux, this.logger, 'migrate', this.flags.verbose);
@@ -133,8 +137,11 @@ export default class Migrate extends OmniStudioBaseCommand {
133137
const isExperienceBundleMetadataAPIProgramaticallyEnabled: { value: boolean } = { value: false };
134138

135139
if (isStandardDataModel()) {
136-
allVersions = await preMigrate.handleAllVersionsPrerequisites(allVersions);
137-
await preMigrate.handleOmnistudioMetadataPrerequisites();
140+
if (!isStandardDataModelWithMetadataAPIEnabled()) {
141+
// Only if metadata API is off we need the allVersions Consent and Omnistudio Metadata Cleanup
142+
allVersions = await preMigrate.handleAllVersionsPrerequisites(allVersions);
143+
await preMigrate.handleOmnistudioMetadataPrerequisites();
144+
}
138145
}
139146

140147
let actionItems = [];
@@ -254,7 +261,8 @@ export default class Migrate extends OmniStudioBaseCommand {
254261
orgs,
255262
messages,
256263
actionItems,
257-
objectsToProcess
264+
objectsToProcess,
265+
migrateOnly
258266
);
259267
Logger.log(
260268
messages.getMessage('migrationSuccessfulMessage', [
@@ -357,10 +365,11 @@ export default class Migrate extends OmniStudioBaseCommand {
357365
// Truncate in reverse order (highest dependencies first) - this is correct for cleanup
358366
for (const cls of migrationObjects) {
359367
try {
360-
Logger.log(messages.getMessage('cleaningComponent', [cls.getName()]));
361-
debugTimer.lap('Cleaning: ' + cls.getName());
368+
const componentName = cls.getName();
369+
370+
this.logTruncationStart(componentName, debugTimer);
362371
await cls.truncate();
363-
Logger.log(messages.getMessage('cleaningDone', [cls.getName()]));
372+
this.logTruncationComplete(componentName);
364373
} catch (ex: any) {
365374
objectMigrationResults.push({
366375
name: cls.getName(),
@@ -383,14 +392,12 @@ export default class Migrate extends OmniStudioBaseCommand {
383392
// Migrate in correct dependency order
384393
for (const cls of migrationObjects) {
385394
try {
386-
Logger.log(messages.getMessage('migratingComponent', [cls.getName()]));
387-
debugTimer.lap('Migrating: ' + cls.getName());
395+
const componentName = cls.getName();
396+
397+
this.logMigrationStart(componentName, debugTimer);
388398
const results = await cls.migrate();
389-
if (results.some((result) => result?.errors?.length > 0)) {
390-
Logger.error(messages.getMessage('migrationFailed', [cls.getName()]));
391-
} else {
392-
Logger.log(messages.getMessage('migrationCompleted', [cls.getName()]));
393-
}
399+
this.logMigrationComplete(componentName, results);
400+
394401
objectMigrationResults = objectMigrationResults.concat(
395402
results.map((r) => {
396403
return {
@@ -419,6 +426,80 @@ export default class Migrate extends OmniStudioBaseCommand {
419426
return objectMigrationResults;
420427
}
421428

429+
/**
430+
* Log the start of component migration and track timing
431+
*/
432+
private logMigrationStart(componentName: string, debugTimer: DebugTimer): void {
433+
const shouldSkipLogging = this.shouldSkipLogging(componentName);
434+
435+
if (!shouldSkipLogging) {
436+
Logger.log(messages.getMessage('migratingComponent', [componentName]));
437+
debugTimer.lap('Migrating: ' + componentName);
438+
}
439+
}
440+
441+
/**
442+
* Log the completion or failure of component migration
443+
*/
444+
private logMigrationComplete(componentName: string, results: MigrationResult[]): void {
445+
const shouldSkipLogging = this.shouldSkipLogging(componentName);
446+
447+
if (!shouldSkipLogging) {
448+
if (results.some((result) => result?.errors?.length > 0) && !isStandardDataModelWithMetadataAPIEnabled()) {
449+
Logger.error(messages.getMessage('migrationFailed', [componentName]));
450+
} else {
451+
Logger.log(messages.getMessage('migrationCompleted', [componentName]));
452+
}
453+
}
454+
}
455+
456+
/**
457+
* Check if migration logging should be skipped for a component
458+
* Returns true if Metadata API is enabled and the component doesn't need migration
459+
*/
460+
private shouldSkipTruncationLogging(componentName: string): boolean {
461+
if (isStandardDataModel()) {
462+
return true;
463+
}
464+
465+
return this.shouldSkipLogging(componentName);
466+
}
467+
468+
/**
469+
* Check if migration logging should be skipped for a component
470+
* Returns true if Metadata API is enabled and the component doesn't need migration
471+
*/
472+
private shouldSkipLogging(componentName: string): boolean {
473+
if (!isStandardDataModelWithMetadataAPIEnabled()) {
474+
return false;
475+
}
476+
477+
// Skip logging for OmniStudio components that don't need migration when metadata API is enabled
478+
return !this.OMNISTUDIO_COMPONENTS_FOR_LOGGING.some((component) =>
479+
componentName.toLowerCase().includes(component.toLowerCase())
480+
);
481+
}
482+
483+
/**
484+
* Log the start of component truncation and track timing
485+
*/
486+
private logTruncationStart(componentName: string, debugTimer: DebugTimer): void {
487+
const shouldSkipLogging = this.shouldSkipTruncationLogging(componentName);
488+
if (!shouldSkipLogging) {
489+
Logger.log(messages.getMessage('cleaningComponent', [componentName]));
490+
debugTimer.lap('Cleaning: ' + componentName);
491+
}
492+
}
493+
/**
494+
* Log the completion of component truncation
495+
*/
496+
private logTruncationComplete(componentName: string): void {
497+
const shouldSkipLogging = this.shouldSkipTruncationLogging(componentName);
498+
499+
if (!shouldSkipLogging) {
500+
Logger.log(messages.getMessage('cleaningDone', [componentName]));
501+
}
502+
}
422503
/**
423504
* Get migration objects in the correct dependency order:
424505
* 1. Data Mappers (lowest dependencies)
@@ -519,6 +600,9 @@ export default class Migrate extends OmniStudioBaseCommand {
519600
*/
520601
private async preProcessAllComponents(namespace: string, conn: any, migrateOnly: string): Promise<void> {
521602
try {
603+
if (isStandardDataModelWithMetadataAPIEnabled()) {
604+
return;
605+
}
522606
const nameRegistry = NameMappingRegistry.getInstance();
523607
// Query all components that will be migrated
524608
const dataMappers = await this.queryDataMappers(conn, namespace);

0 commit comments

Comments
 (0)