Skip to content

Commit 79449ae

Browse files
authored
Merge pull request #330 from snehaljha-sf/flexipage_wrapper_assess
@W-18480483: Flexipage wrapper assess
2 parents 5ffe2da + a3fd1fa commit 79449ae

26 files changed

+2493
-134
lines changed

messages/assess.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"allVersionsDescription": "Migrate all versions of a component",
3131
"changeMessage": " %s will be changed from %s to %s",
3232
"angularOSWarning": " Angular OmniScript will not be migrated, please convert this to LWC based Omniscript",
33-
"apexLwcGA": "Please select the type of component to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
33+
"relatedObjectGA": "Please select the type of component to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, 'flexipage' for FlexiPages, or 'apex,lwc,flexipage' if you want to include all types.",
3434
"apexLwc": "Please select the type of component to assess: 'apex' for Apex classes.",
3535
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3636
"noPackageInstalled": "No package installed on given org.",
@@ -124,5 +124,18 @@
124124
"errorParsingData": "Error while parsing data for template",
125125
"errorGeneratingHTML": "Error while generating HTML from template for {} with properties {}",
126126
"unexpectedError": "Unexpected Assessment error",
127-
"errorEvaluatingExpression": "Error evaluating expression: {0}, {1}"
127+
"errorEvaluatingExpression": "Error evaluating expression: {0}, {1}",
128+
"retrievingFlexiPages": "Retrieving FlexiPages",
129+
"successfullyRetrievedFlexiPages": "Successfully retrieved %s FlexiPages",
130+
"assessingFlexiPages": "Assessing FlexiPages",
131+
"completedProcessingAllFlexiPages": "Completed processing all flexipage files. Total processed: %s",
132+
"completedProcessingFlexiPage": "Completed processing %s - Errors: %s",
133+
"processingFlexiPage": "Processing flexipage file: %s",
134+
"startingFlexiPageProcessing": "Starting to process flexipage: %s",
135+
"readFlexiPageContent": "Read file content, size: %s characters",
136+
"updatedModifiedContent": "updated content in file: %s",
137+
"generatedDiffForFile": "Generated diff for file: %s",
138+
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s",
139+
"flexipagesWithChanges": "Found %s flexipage files with changes",
140+
"migratingFlexiPages": "Migrating FlexiPages"
128141
}

messages/migrate.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
3131
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
3232
"allVersionsDescription": "Migrate all versions of a component",
33-
"apexLwcGA": "Please select the type of components to migrate: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
33+
"relatedObjectGA": "Please select the type of components to migrate: 'apex' for Apex classes, 'lwc' for Lightning Web Components, 'flexipage' for FlexiPages, 'expsites' for Experience Sites, or 'apex,lwc,flexipage,expsites' if you want to include all types.",
3434
"apexLwc": "Please select the type of components to migrate: 'apex' for Apex classes.",
3535
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
3636
"noPackageInstalled": "No package installed on given org.",
@@ -113,6 +113,18 @@
113113
"errorGeneratingHTML": "Error while generating HTML from template for {} with properties {}",
114114
"errorEvaluatingExpression": "Error evaluating expression: {0}, {1}",
115115
"manuallySwitchDesignerToStandardDataModel": "To complete the setup, please manually run the required Apex code to configure OmniStudio Designers to use the Standard Data Model <br> https://help.salesforce.com/s/articleView?id=xcloud.os_migrate_change_the_sobject_data_model_after_migration.htm&type=5",
116+
"retrievingFlexiPages": "Retrieving FlexiPages",
117+
"successfullyRetrievedFlexiPages": "Successfully retrieved %s FlexiPages",
118+
"migratingFlexiPages": "Migrating FlexiPages",
119+
"completedProcessingAllFlexiPages": "Completed processing all flexipage files. Total processed: %s",
120+
"completedProcessingFlexiPage": "Completed processing %s - Errors: %s",
121+
"processingFlexiPage": "Processing flexipage file: %s",
122+
"startingFlexiPageProcessing": "Starting to process flexipage: %s",
123+
"readFlexiPageContent": "Read file content, size: %s characters",
124+
"updatedModifiedContent": "updated content in file: %s",
125+
"generatedDiffForFile": "Generated diff for file: %s",
126+
"errorProcessingFlexiPage": "Error processing flexipage file: %s, %s",
127+
"flexipagesWithChanges": "Found %s flexipage files with changes",
116128
"omniGlobalAutoNumberPrefEnabled": "Successfully enabled OmniGlobalAutoNumberPref org preference",
117129
"errorEnablingOmniGlobalAutoNumberPref": "Error enabling OmniGlobalAutoNumberPref org preference",
118130
"performingPreMigrationChecks": "Performing pre-migration checks for Global Auto Number...",

src/commands/omnistudio/migration/assess.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Assess extends OmniStudioBaseCommand {
4242
}),
4343
relatedobjects: flags.string({
4444
char: 'r',
45-
description: messages.getMessage('apexLwc'),
45+
description: messages.getMessage('relatedObjectGA'),
4646
}),
4747
verbose: flags.builtin({
4848
type: 'builtin',
@@ -108,6 +108,7 @@ export default class Assess extends OmniStudioBaseCommand {
108108
osAssessmentInfos: [],
109109
ipAssessmentInfos: [],
110110
},
111+
flexipageAssessmentInfos: [],
111112
};
112113

113114
Logger.log(messages.getMessage('assessmentInitialization', [String(namespace)]));
@@ -122,7 +123,7 @@ export default class Assess extends OmniStudioBaseCommand {
122123
// Assess related objects if specified
123124
if (relatedObjects) {
124125
// To-Do: Add LWC to valid options when GA is released
125-
const validOptions = [Constants.Apex];
126+
const validOptions = [Constants.Apex, Constants.FlexiPage];
126127
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
127128

128129
// Validate input
@@ -143,6 +144,7 @@ export default class Assess extends OmniStudioBaseCommand {
143144
const relatedObjectAssessmentResult = omnistudioRelatedObjectsMigration.assessAll(objectsToProcess);
144145
assesmentInfo.lwcAssessmentInfos = relatedObjectAssessmentResult.lwcAssessmentInfos;
145146
assesmentInfo.apexAssessmentInfos = relatedObjectAssessmentResult.apexAssessmentInfos;
147+
assesmentInfo.flexipageAssessmentInfos = relatedObjectAssessmentResult.flexipageAssessmentInfos;
146148
}
147149
try {
148150
orgs.rollbackFlags = await OrgPreferences.checkRollbackFlags(conn);

src/commands/omnistudio/migration/migrate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class Migrate extends OmniStudioBaseCommand {
5757
}),
5858
relatedobjects: flags.string({
5959
char: 'r',
60-
description: messages.getMessage('apexLwc'),
60+
description: messages.getMessage('relatedObjectGA'),
6161
}),
6262
verbose: flags.builtin({
6363
type: 'builtin',
@@ -126,7 +126,7 @@ export default class Migrate extends OmniStudioBaseCommand {
126126
const isExperienceBundleMetadataAPIProgramaticallyEnabled: { value: boolean } = { value: false };
127127
if (relatedObjects) {
128128
// To-Do: Add LWC to valid options when GA is released
129-
const validOptions = [Constants.Apex, Constants.ExpSites];
129+
const validOptions = [Constants.Apex, Constants.ExpSites, Constants.FlexiPage];
130130
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
131131
// Validate input
132132
for (const obj of objectsToProcess) {
@@ -186,7 +186,8 @@ export default class Migrate extends OmniStudioBaseCommand {
186186
const relatedObjectMigrationResult = omnistudioRelatedObjectsMigration.migrateAll(objectsToProcess);
187187
generatePackageXml.createChangeList(
188188
relatedObjectMigrationResult.apexAssessmentInfos,
189-
relatedObjectMigrationResult.lwcAssessmentInfos
189+
relatedObjectMigrationResult.lwcAssessmentInfos,
190+
relatedObjectMigrationResult.flexipageAssessmentInfos
190191
);
191192

192193
// POST MIGRATION

src/error/errorInterfaces.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export class KeyNotFoundInStorageError extends Error {
2+
public componentType: string;
3+
public key: string;
4+
5+
public constructor(key: string, componentType: string) {
6+
super(`Key ${key} not found in storage`);
7+
this.key = key;
8+
this.componentType = componentType;
9+
}
10+
}
11+
12+
export class DuplicateKeyError extends Error {
13+
public componentType: string;
14+
public key: string;
15+
16+
public constructor(key: string, componentType: string) {
17+
super(`Key ${key} is duplicate in storage`);
18+
this.key = key;
19+
this.componentType = componentType;
20+
}
21+
}
22+
23+
export class TargetPropertyNotFoundError extends Error {
24+
public componentName: string;
25+
26+
public constructor(componentName: string) {
27+
super(`Target property not found for component ${componentName}`);
28+
this.componentName = componentName;
29+
}
30+
}

src/migration/base.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import { UX } from '@salesforce/command';
22
import { Connection, Messages } from '@salesforce/core';
3-
import cliProgress from 'cli-progress';
3+
import * as cliProgress from 'cli-progress';
44
import { DebugTimer, QueryTools } from '../utils';
55
import { NetUtils } from '../utils/net';
66
import { Stringutil } from '../utils/StringValue/stringutil';
77
import { Logger } from '../utils/logger';
88
import { TransformData, UploadRecordResult } from './interfaces';
99

1010
export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integration Procedure' | 'GlobalAutoNumber';
11+
export type RelatedObjectType = 'Flexipage';
1112

1213
/**
1314
* Creates a progress bar for migration/assessment operations
1415
*
1516
* @param action - The action being performed (e.g., 'Migrating', 'Assessing')
16-
* @param componentType - The type of component being processed
17+
* @param type - The type of component being processed
1718
* @returns A configured cliProgress.SingleBar instance
1819
*/
19-
export const createProgressBar = (action: string, componentType: ComponentType): cliProgress.SingleBar => {
20+
export const createProgressBar = (action: string, type: ComponentType | RelatedObjectType): cliProgress.SingleBar => {
2021
return new cliProgress.SingleBar({
21-
format: `${action} ${componentType} |${
22-
componentType === 'Omniscript and Integration Procedure' ? '' : '\t\t\t\t'
22+
format: `${action} ${type} |${
23+
type === 'Omniscript and Integration Procedure' ? '' : '\t\t\t\t'
2324
} {bar} | {percentage}% || {value}/{total} Tasks`,
2425
barCompleteChar: '\u2588',
2526
barIncompleteChar: '\u2591',

src/migration/flexcard.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
185185
}
186186
uniqueNames.add(cleanedName);
187187

188+
this.addToAssessmentStorage(originalName, cleanedName);
189+
188190
// Check for author name changes
189191
const originalAuthor = flexCard[this.namespacePrefix + 'Author__c'];
190192
if (originalAuthor) {
@@ -584,6 +586,18 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
584586
}
585587
}
586588

589+
private addToAssessmentStorage(originalName: string, cleanedName: string) {
590+
let storage: MigrationStorage = StorageUtil.getOmnistudioAssessmentStorage();
591+
if (storage.fcStorage.has(originalName)) {
592+
storage.fcStorage.get(originalName).isDuplicate = true;
593+
} else {
594+
storage.fcStorage.set(originalName, {
595+
name: cleanedName,
596+
isDuplicate: false,
597+
});
598+
}
599+
}
600+
587601
private prepareStorageForFlexcards(
588602
cardsUploadInfo: Map<string, UploadRecordResult>,
589603
originalRecords: Map<string, any>

src/migration/interfaces.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,33 @@ export interface RelatedObjectMigrationResult {
9696
lwcComponents: string[];
9797
}
9898

99+
export interface Flexipage {
100+
[key: string]: string | FlexiPageRegion[];
101+
flexiPageRegions: FlexiPageRegion[];
102+
}
103+
104+
export interface FlexiPageRegion {
105+
[key: string]: string | FlexiItemInstance[];
106+
itemInstances?: FlexiItemInstance[];
107+
}
108+
109+
export interface FlexiItemInstance {
110+
[key: string]: string | FlexiComponentInstance;
111+
componentInstance: FlexiComponentInstance;
112+
}
113+
114+
export interface FlexiComponentInstance {
115+
[key: string]: string | FlexiComponentInstanceProperty[];
116+
componentInstanceProperties: FlexiComponentInstanceProperty[];
117+
componentName: string;
118+
identifier?: string;
119+
}
120+
121+
export interface FlexiComponentInstanceProperty {
122+
name: string;
123+
value?: string;
124+
}
125+
99126
export interface ExpSitePageJson {
100127
// Index signature to allow any additional properties
101128
[key: string]: any;

src/migration/omniscript.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,13 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
428428

429429
const warnings: string[] = [];
430430

431+
if (omniProcessType === 'OmniScript') {
432+
this.addToAssessmentStorage(
433+
existingTypeVal,
434+
existingSubTypeVal,
435+
omniscript[this.namespacePrefix + 'Language__c']
436+
);
437+
}
431438
const recordName =
432439
`${existingTypeVal.cleanName()}_` +
433440
`${existingSubTypeVal.cleanName()}` +
@@ -774,6 +781,21 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
774781
};
775782
}
776783

784+
private addToAssessmentStorage(type: StringVal, subtype: StringVal, language: string) {
785+
let storage: MigrationStorage = StorageUtil.getOmnistudioAssessmentStorage();
786+
const key = `${type.val}${subtype.val}${language}`;
787+
if (storage.osStorage.has(key)) {
788+
storage.osStorage.get(key).isDuplicate = true;
789+
} else {
790+
storage.osStorage.set(key, {
791+
type: type.cleanName(),
792+
subtype: subtype.cleanName(),
793+
language: language || 'English',
794+
isDuplicate: false,
795+
});
796+
}
797+
}
798+
777799
private updateStorageForOmniscript(
778800
osUploadInfo: Map<string, UploadRecordResult>,
779801
originalOsRecords: Map<string, any>

0 commit comments

Comments
 (0)