Skip to content

Commit 14f3b68

Browse files
Merge branch 'release260omnistudiopackage' into u/aparuthi/finalchangesforomnistudiopackage
2 parents 83f5ed2 + 31f5a0e commit 14f3b68

File tree

11 files changed

+700
-34
lines changed

11 files changed

+700
-34
lines changed

messages/assess.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,8 @@
218218
"failedToCheckPackagesValue": "Failed to check the value of packages in Omni Interaction Configuration.",
219219
"packageDetails": "Your org contains only the TheFirstInstalledOmniPackage Omni Interaction Configuration.",
220220
"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+
"globalAutoNumberUnSupportedInOmnistudioPackage": "Omni Global Auto Number is not supported in Omnistudio Foundation package orgs.",
222+
"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]",
223+
"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."
222225
}

messages/migrate.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@
305305
"manuallyEnableOmniStudioSettingsMetadata": "Manually enable the Omnistudio Metadata setting in your org’s Omnistudio Settings page. Refer <a href='https://help.salesforce.com/s/articleView?id=xcloud.os_enable_omnistudio_metadata_api_support.htm&type=5' target='_blank'>this documentation</a> for more details.",
306306
"omniStudioMetadataEnableConsentNotGiven": "You’ve not consented to proceed with enabling the Omnistudio Metadata setting. We’ll not be able to proceed with the migration.",
307307
"enablingOmniStudioSettingsMetadataStatus": "Enabling Omnistudio Metadata setting…",
308-
"omniStudioAllVersionsMigrationConsent": "Org uses the standard data model. All versions of Omnistudio components such as Omniscripts, Data Mappers, Integration Procedures, and Flexcards must be migrated to enable the Omnistudio Metadata API setting. But you’ve not specified -a or allversions flag in the command. Proceed to migrate all versions of the Omnistudio components? [y/n]",
309-
"omniStudioAllVersionsMigrationConsentNotGiven": "You've not consented to migrate all versions of the Omnistudio components. We cannot proceed with the migration.",
310-
"omniStudioAllVersionsMigrationConsentGiven": "You've consented to migrate all versions of the Omnistudio components.",
308+
"omniStudioAllVersionsProcessingConsent": "Org uses the standard data model. All versions of Omnistudio components such as Omniscripts, Data Mappers, Integration Procedures, and Flexcards must be migrated to enable the Omnistudio Metadata API setting. But you’ve not specified -a or allversions flag in the command. Proceed to migrate all versions of the Omnistudio components? [y/n]",
309+
"omniStudioAllVersionsProcessingConsentNotGiven": "You've not consented to migrate all versions of the Omnistudio components. We cannot proceed with the migration.",
310+
"omniStudioAllVersionsProcessingConsentGiven": "You've consented to migrate all versions of the Omnistudio components.",
311311
"customLWCFlexCardReferenceUpdated": "Updated Custom LWC FlexCard reference: %s -> cf%s",
312312
"validatingDrVersioningDisabled": "Checking the Data Mapper versioning setting in your org.",
313313
"drVersioningDisabled": "Proceeding with the migration as the Data Mapper versioning setting is disabled.",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/plugin-omnistudio-migration-tool",
33
"description": "This SFDX plugin migrates FlexCard, OmniScript, DataRaptor, and Integration Procedure custom objects to standard objects.",
4-
"version": "2.0.0-dev.6",
4+
"version": "2.0.0-dev.8",
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {

src/commands/omnistudio/migration/assess.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { PreMigrate } from '../../../migration/premigrate';
2121
import { PostMigrate } from '../../../migration/postMigrate';
2222
import { CustomLabelsUtil } from '../../../utils/customLabels';
2323
import { initializeDataModelService, isFoundationPackage } from '../../../utils/dataModelService';
24+
2425
import { ValidatorService } from '../../../utils/validatorService';
2526

2627
Messages.importMessagesDirectory(__dirname);
@@ -69,7 +70,7 @@ export default class Assess extends OmniStudioBaseCommand {
6970
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7071
public async runAssess(): Promise<any> {
7172
DebugTimer.getInstance().start();
72-
const allVersions = (this.flags.allversions || false) as boolean;
73+
let allVersions = (this.flags.allversions || false) as boolean;
7374
const assessOnly = (this.flags.only || '') as string;
7475
const relatedObjects = (this.flags.relatedobjects || '') as string;
7576
const isExperienceBundleMetadataAPIProgramaticallyEnabled: { value: boolean } = { value: false };
@@ -94,6 +95,12 @@ export default class Assess extends OmniStudioBaseCommand {
9495
const namespace = orgs.packageDetails.namespace;
9596
let projectPath = '';
9697
const preMigrate: PreMigrate = new PreMigrate(namespace, conn, this.logger, messages, this.ux);
98+
99+
// Handle all versions prerequisite for standard data model
100+
if (
101+
DataModel()) {
102+
allVersions = await preMigrate.handleAllVersionsPrerequisites(allVersions);
103+
}
97104
if (relatedObjects) {
98105
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
99106
projectPath = await ProjectPathUtil.getProjectPath(messages, true);

src/migration/flexcard.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
935935
}
936936

937937
uploadResult.newName = transformedCardName;
938+
uploadResult.actualName = transformedCard['Name']; // This is required as storage needs name without version, for replacement in other references
938939
if (transformedCard['Name'] !== card['Name']) {
939940
uploadResult.warnings.unshift(this.messages.getMessage('cardNameChangeMessage', [transformedCardName]));
940941
}
@@ -1000,6 +1001,10 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10001001
if (flexCardAssessmentInfo.errors && flexCardAssessmentInfo.errors.length > 0) {
10011002
value.error = flexCardAssessmentInfo.errors;
10021003
value.migrationSuccess = false;
1004+
} else if (flexCardAssessmentInfo.migrationStatus === 'Needs manual intervention') {
1005+
// Duplicate name and other critical warnings
1006+
value.error = flexCardAssessmentInfo.warnings;
1007+
value.migrationSuccess = false;
10031008
} else {
10041009
value.migrationSuccess = true;
10051010
}
@@ -1059,13 +1064,19 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10591064

10601065
const originalName: string = oldrecord['Name'];
10611066
let value: FlexcardStorage = {
1062-
name: newrecord?.newName,
1067+
name: newrecord?.actualName,
10631068
isDuplicate: false,
10641069
originalName: originalName,
10651070
};
10661071

10671072
if (newrecord === undefined) {
1068-
value.error = ['Migration Failed'];
1073+
// Card was not migrated - check if original record has error details
1074+
if (oldrecord['errors'] && Array.isArray(oldrecord['errors'])) {
1075+
value.error = oldrecord['errors'];
1076+
} else {
1077+
value.error = ['Migration Failed'];
1078+
}
1079+
value.migrationSuccess = false;
10691080
} else {
10701081
if (newrecord.hasErrors) {
10711082
value.error = newrecord.errors;

src/migration/interfaces.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export interface ObjectMapping {
3838
export interface UploadRecordResult {
3939
referenceId: string;
4040
id?: string;
41-
newName?: string;
41+
newName?: string; // Display name (may include version suffix for reports)
42+
actualName?: string; // Actual Salesforce Name field (for references/dependencies)
4243
errors: string[];
4344
warnings: string[];
4445
hasErrors: boolean;

src/migration/premigrate.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ export class PreMigrate extends BaseMigrationTool {
1818
}
1919

2020
/**
21-
* Ensures all versions are migrated when on standard data model.
21+
* Ensures all versions are processed when on standard data model.
2222
* If the -a flag was not provided, prompts user for consent.
2323
*
2424
* @param allVersionsFlagFromCLI - The allVersions flag value from CLI (-a flag)
25-
* @returns true if all versions should be migrated, false otherwise
25+
* @returns true if all versions should be processed, false otherwise
2626
*/
2727
public async handleAllVersionsPrerequisites(allVersionsFlagFromCLI: boolean): Promise<boolean> {
2828
if (allVersionsFlagFromCLI === false) {
29-
// Get user consent to migrate allversions of OmniStudio components for standard data model migration
30-
const omniStudioAllVersionsMigrationConsent = await this.getOmnistudioAllVersionsMigrationConsent();
31-
if (!omniStudioAllVersionsMigrationConsent) {
32-
Logger.error(this.messages.getMessage('omniStudioAllVersionsMigrationConsentNotGiven'));
29+
// Get user consent to process allversions of OmniStudio components for standard data model migration
30+
const omniStudioProcessAllVersionsConsent = await this.getOmnistudioProcessAllVersionsConsent();
31+
if (!omniStudioProcessAllVersionsConsent) {
32+
Logger.error(this.messages.getMessage('omniStudioAllVersionsProcessingConsentNotGiven'));
3333
process.exit(1);
3434
}
3535

36-
Logger.logVerbose(this.messages.getMessage('omniStudioAllVersionsMigrationConsentGiven'));
36+
Logger.logVerbose(this.messages.getMessage('omniStudioAllVersionsProcessingConsentGiven'));
3737
return true;
3838
}
3939
return allVersionsFlagFromCLI;
@@ -131,17 +131,21 @@ export class PreMigrate extends BaseMigrationTool {
131131
deploymentConfig.authKey = process.env[authEnvKey];
132132
if (!deploymentConfig.authKey) {
133133
Logger.warn(this.messages.getMessage('authKeyEnvVarNotSet'));
134-
actionItems.push(this.messages.getMessage('authKeyEnvVarNotSet'));
134+
actionItems.push(
135+
`${this.messages.getMessage('authKeyEnvVarNotSet')}\n${this.messages.getMessage('manualDeploymentSteps', [
136+
documentRegistry.manualDeploymentSteps,
137+
])}`
138+
);
135139
}
136140
}
137141

138142
if (!consent) {
139143
Logger.warn(this.messages.getMessage('deploymentConsentNotGiven'));
140-
actionItems.push(this.messages.getMessage('deploymentConsentNotGiven'));
141-
}
142-
143-
if (!consent || (includeLwc && !deploymentConfig.authKey)) {
144-
actionItems.push(this.messages.getMessage('manualDeploymentSteps', [documentRegistry.manualDeploymentSteps]));
144+
actionItems.push(
145+
`${this.messages.getMessage('deploymentConsentNotGiven')}\n${this.messages.getMessage('manualDeploymentSteps', [
146+
documentRegistry.manualDeploymentSteps,
147+
])}`
148+
);
145149
}
146150

147151
return deploymentConfig;
@@ -284,7 +288,7 @@ export class PreMigrate extends BaseMigrationTool {
284288
*
285289
* @returns Promise<boolean> - true if user consents, false otherwise
286290
*/
287-
private async getOmnistudioAllVersionsMigrationConsent(): Promise<boolean> {
291+
private async getOmnistudioProcessAllVersionsConsent(): Promise<boolean> {
288292
const askWithTimeOut = PromptUtil.askWithTimeOut(this.messages);
289293
let validResponse = false;
290294
let consent = false;
@@ -293,7 +297,7 @@ export class PreMigrate extends BaseMigrationTool {
293297
try {
294298
const resp = await askWithTimeOut(
295299
Logger.prompt.bind(Logger),
296-
this.messages.getMessage('omniStudioAllVersionsMigrationConsent')
300+
this.messages.getMessage('omniStudioAllVersionsProcessingConsent')
297301
);
298302
const response = typeof resp === 'string' ? resp.trim().toLowerCase() : '';
299303

src/migration/related/ApexMigration.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,27 @@ export class ApexMigration extends BaseRelatedObjectMigration {
283283
const implementsInterface = parser.implementsInterfaces;
284284
const tokenUpdates: TokenUpdater[] = [];
285285

286+
const hasCallable = implementsInterface.has(this.callableInterface);
287+
const hasVlocityOpenInterface2 = implementsInterface.has(this.vlocityOpenInterface2);
288+
const hasVlocityOpenInterface = implementsInterface.has(this.vlocityOpenInterface);
289+
286290
// Case 1: Already implements just System.Callable - no changes needed
287-
if (implementsInterface.has(this.callableInterface) && implementsInterface.size === 1) {
291+
if (hasCallable && implementsInterface.size === 1) {
288292
Logger.info(assessMessages.getMessage('fileAlreadyImplementsCallable', [file.name]));
289293
return tokenUpdates;
290294
}
291295

292-
// Case 2: Already implements multiple interfaces including Callable - keep only System.Callable
293-
if (implementsInterface.has(this.callableInterface) && implementsInterface.size > 1) {
296+
// Case 2: Multiple interfaces need to be replaced with System.Callable:
297+
// - Has System.Callable with other interfaces, OR
298+
// - Has both VlocityOpenInterface and VlocityOpenInterface2
299+
if ((hasCallable && implementsInterface.size > 1) || (hasVlocityOpenInterface2 && hasVlocityOpenInterface)) {
294300
Logger.logger.info(assessMessages.getMessage('apexFileHasMultipleInterfaces', [file.name]));
295301
// We need to identify the entire implements clause and replace it
296302
return this.replaceAllInterfaces(implementsInterface, tokenUpdates, parser, file.name);
297303
}
298304

299-
// Case 3: Implements VlocityOpenInterface2 - replace with System.Callable
300-
if (implementsInterface.has(this.vlocityOpenInterface2)) {
305+
// Case 3: Implements only VlocityOpenInterface2 - replace with System.Callable
306+
if (hasVlocityOpenInterface2) {
301307
Logger.logger.info(assessMessages.getMessage('apexFileImplementsVlocityOpenInterface2', [file.name]));
302308
const tokens = implementsInterface.get(this.vlocityOpenInterface2);
303309
tokenUpdates.push(new RangeTokenUpdate(CALLABLE, tokens[0], tokens[1]));
@@ -306,7 +312,9 @@ export class ApexMigration extends BaseRelatedObjectMigration {
306312
} else {
307313
Logger.logger.info(assessMessages.getMessage('apexFileAlreadyHasCallMethod', [file.name]));
308314
}
309-
} else if (implementsInterface.has(this.vlocityOpenInterface)) {
315+
}
316+
// Case 4: Implements only VlocityOpenInterface - replace with System.Callable
317+
else if (hasVlocityOpenInterface) {
310318
Logger.logger.info(assessMessages.getMessage('fileImplementsVlocityOpenInterface', [file.name]));
311319
const tokens = implementsInterface.get(this.vlocityOpenInterface);
312320
tokenUpdates.push(new RangeTokenUpdate(CALLABLE, tokens[0], tokens[1]));

0 commit comments

Comments
 (0)