Skip to content

Commit c118313

Browse files
feat: namespcce, cta and code refactoring (#285)
1 parent 614cc58 commit c118313

22 files changed

+642
-240
lines changed

messages/assess.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
"allVersionsDescription": "Migrate all versions of a component",
3030
"changeMessage": " %s will be changed from %s to %s",
3131
"angularOSWarning": " Angular OmniScript will not be migrated, please convert this to LWC based Omniscript",
32-
"apexLwc": "Please select the type of components to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types."
32+
"apexLwc": "Please select the type of components to assess: 'apex' for Apex classes, 'lwc' for Lightning Web Components, or 'apex,lwc' if you want to include both types.",
33+
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
34+
"noPackageInstalled": "No package installed on given org.",
35+
"alreadyStandardModel": "The org is already on standard data model."
3336
}

messages/migrate.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
3030
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
3131
"allVersionsDescription": "Migrate all versions of a component",
32-
"apexLwc": "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."
32+
"apexLwc": "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+
"invalidNamespace": "The namespace you have passed is not valid namespace, the valid namespace of your org is ",
34+
"noPackageInstalled": "No package installed on given org.",
35+
"alreadyStandardModel": "The org is already on standard data model."
3336
}

src/commands/omnistudio/migration/__tests__/assess.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { OmniScriptMigrationTool } from '../../../../migration/omniscript';
1010
import OmnistudioRelatedObjectMigrationFacade from '../../../../migration/related/OmnistudioRelatedObjectMigrationFacade';
1111
import { OrgUtils } from '../../../../utils/orgUtils';
1212
import { OmnistudioOrgDetails } from '../../../../utils/orgUtils';
13+
import { Constants } from '../../../../utils/constants/stringContants';
1314

1415
// Helper function to normalize paths for comparison
1516

@@ -19,18 +20,17 @@ describe('omnistudio:migration:assess', () => {
1920

2021
// Mock org details
2122
const mockOrgDetailsStandardModel: OmnistudioOrgDetails = {
22-
packageDetails: [
23-
{
24-
version: '1.0.0',
25-
namespace: 'vlocity_ins',
26-
},
27-
],
23+
packageDetails: {
24+
version: '1.0.0',
25+
namespace: 'vlocity_ins',
26+
},
2827
omniStudioOrgPermissionEnabled: false,
2928
orgDetails: {
3029
Name: 'Test Org',
3130
Id: '00D000000000001',
3231
},
3332
dataModel: 'Standard',
33+
hasValidNamespace: true,
3434
};
3535

3636
// Sample data for DataRaptor assessment
@@ -187,8 +187,8 @@ describe('omnistudio:migration:assess', () => {
187187
stubMethod(sandbox, OmnistudioRelatedObjectMigrationFacade.prototype, 'assessAll').callsFake(
188188
(relatedObjects: string[]) => {
189189
const result = {
190-
apexAssessmentInfos: relatedObjects.includes('apex') ? sampleApexAssessment : [],
191-
lwcAssessmentInfos: relatedObjects.includes('lwc') ? sampleLwcAssessment : [],
190+
apexAssessmentInfos: relatedObjects.includes(Constants.Apex) ? sampleApexAssessment : [],
191+
lwcAssessmentInfos: relatedObjects.includes(Constants.LWC) ? sampleLwcAssessment : [],
192192
};
193193
return result;
194194
}
@@ -246,7 +246,7 @@ describe('omnistudio:migration:assess', () => {
246246
.withOrg({ username: '[email protected]' }, true)
247247
.stdout()
248248
.stderr()
249-
.command(['omnistudio:migration:assess', '-o', 'dr'])
249+
.command(['omnistudio:migration:assess', '-o', Constants.DataMapper])
250250
.it('generates assessment files with content only for DataRaptor components', () => {
251251
const dataRaptorContent = fs.readFileSync(
252252
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
@@ -279,7 +279,7 @@ describe('omnistudio:migration:assess', () => {
279279
.withOrg({ username: '[email protected]' }, true)
280280
.stdout()
281281
.stderr()
282-
.command(['omnistudio:migration:assess', '-o', 'fc'])
282+
.command(['omnistudio:migration:assess', '-o', Constants.Flexcard])
283283
.it('generates assessment files with content only for FlexCard components', () => {
284284
const dataRaptorContent = fs.readFileSync(
285285
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
@@ -312,7 +312,7 @@ describe('omnistudio:migration:assess', () => {
312312
.withOrg({ username: '[email protected]' }, true)
313313
.stdout()
314314
.stderr()
315-
.command(['omnistudio:migration:assess', '-o', 'os'])
315+
.command(['omnistudio:migration:assess', '-o', Constants.Omniscript])
316316
.it('generates assessment files with content only for OmniScript components', () => {
317317
const dataRaptorContent = fs.readFileSync(
318318
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
@@ -345,7 +345,7 @@ describe('omnistudio:migration:assess', () => {
345345
.withOrg({ username: '[email protected]' }, true)
346346
.stdout()
347347
.stderr()
348-
.command(['omnistudio:migration:assess', '-o', 'ip'])
348+
.command(['omnistudio:migration:assess', '-o', Constants.IntegrationProcedure])
349349
.it('generates assessment files with content only for Integration Procedure components', () => {
350350
const dataRaptorContent = fs.readFileSync(
351351
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
@@ -397,7 +397,7 @@ describe('omnistudio:migration:assess', () => {
397397
// .withOrg({ username: 'test@org.com' }, true)
398398
// .stdout()
399399
// .stderr()
400-
// .command(['omnistudio:migration:assess', '-r', 'apex'])
400+
// .command(['omnistudio:migration:assess', '-r', ''])
401401
// .it('generates assessment files with content only for Apex components', () => {
402402
// const apexContent = fs.readFileSync(path.join(process.cwd(), 'assessment_reports/apex_assessment.html'), 'utf8');
403403
// void expect(apexContent).to.include('TestApexClass');
@@ -437,7 +437,7 @@ describe('omnistudio:migration:assess', () => {
437437
.withOrg({ username: '[email protected]' }, true)
438438
.stdout()
439439
.stderr()
440-
.command(['omnistudio:migration:assess', '-r', 'lwc'])
440+
.command(['omnistudio:migration:assess', '-r', Constants.LWC])
441441
.it('does not generate LWC assessment file when lwc option is passed since functionality is disabled', () => {
442442
// LWC assessment file should not exist since LWC functionality is disabled
443443
const lwcFilePath = path.join(process.cwd(), 'assessment_reports/lwc_assessment.html');

src/commands/omnistudio/migration/assess.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DebugTimer } from '../../../utils';
1111
import { Logger } from '../../../utils/logger';
1212
import OmnistudioRelatedObjectMigrationFacade from '../../../migration/related/OmnistudioRelatedObjectMigrationFacade';
1313
import { OmnistudioOrgDetails, OrgUtils } from '../../../utils/orgUtils';
14+
import { Constants } from '../../../utils/constants/stringContants';
1415

1516
Messages.importMessagesDirectory(__dirname);
1617
const messages = Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'assess');
@@ -45,24 +46,28 @@ export default class Assess extends OmniStudioBaseCommand {
4546
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4647
public async run(): Promise<any> {
4748
DebugTimer.getInstance().start();
48-
const namespace = (this.flags.namespace || 'vlocity_ins') as string;
4949
const apiVersion = (this.flags.apiversion || '55.0') as string;
5050
const allVersions = (this.flags.allversions || false) as boolean;
5151
const assessOnly = (this.flags.only || '') as string;
5252
const relatedObjects = (this.flags.relatedobjects || '') as string;
5353
const conn = this.org.getConnection();
54-
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, namespace);
54+
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, this.flags.namespace);
5555

56-
if (orgs.packageDetails.length === 0) {
57-
this.ux.log('No package installed on given org.');
56+
if (!orgs.hasValidNamespace) {
57+
this.ux.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
58+
}
59+
60+
if (!orgs.packageDetails) {
61+
this.ux.error(messages.getMessage('noPackageInstalled'));
5862
return;
5963
}
6064

6165
if (orgs.omniStudioOrgPermissionEnabled) {
62-
this.ux.log('The org is already on standard data model.');
66+
this.ux.error(messages.getMessage('alreadyStandardModel'));
6367
return;
6468
}
6569

70+
const namespace = orgs.packageDetails.namespace;
6671
Logger.initialiseLogger(this.ux, this.logger);
6772
conn.setApiVersion(apiVersion);
6873

@@ -80,10 +85,11 @@ export default class Assess extends OmniStudioBaseCommand {
8085
// Assess OmniStudio components
8186
await this.assessOmniStudioComponents(assesmentInfo, assessOnly, namespace, conn, allVersions);
8287

88+
let objectsToProcess: string[];
8389
// Assess related objects if specified
8490
if (relatedObjects) {
85-
const validOptions = ['apex', 'lwc'];
86-
const objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
91+
const validOptions = [Constants.Apex, Constants.LWC];
92+
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
8793

8894
// Validate input
8995
for (const obj of objectsToProcess) {
@@ -103,7 +109,7 @@ export default class Assess extends OmniStudioBaseCommand {
103109
assesmentInfo.apexAssessmentInfos = relatedObjectAssessmentResult.apexAssessmentInfos;
104110
}
105111

106-
await AssessmentReporter.generate(assesmentInfo, conn.instanceUrl, orgs);
112+
await AssessmentReporter.generate(assesmentInfo, conn.instanceUrl, orgs, assessOnly, objectsToProcess);
107113
return assesmentInfo;
108114
}
109115

@@ -125,16 +131,16 @@ export default class Assess extends OmniStudioBaseCommand {
125131
}
126132

127133
switch (assessOnly) {
128-
case 'dr':
134+
case Constants.DataMapper:
129135
await this.assessDataRaptors(assesmentInfo, namespace, conn);
130136
break;
131-
case 'fc':
137+
case Constants.Flexcard:
132138
await this.assessFlexCards(assesmentInfo, namespace, conn, allVersions);
133139
break;
134-
case 'os':
140+
case Constants.Omniscript:
135141
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.OS);
136142
break;
137-
case 'ip':
143+
case Constants.IntegrationProcedure:
138144
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.IP);
139145
break;
140146
default:

src/commands/omnistudio/migration/migrate.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Logger } from '../../../utils/logger';
2222
import OmnistudioRelatedObjectMigrationFacade from '../../../migration/related/OmnistudioRelatedObjectMigrationFacade';
2323
import { generatePackageXml } from '../../../utils/generatePackageXml';
2424
import { OmnistudioOrgDetails, OrgUtils } from '../../../utils/orgUtils';
25+
import { Constants } from '../../../utils/constants/stringContants';
2526

2627
// Initialize Messages with the current plugin directory
2728
Messages.importMessagesDirectory(__dirname);
@@ -59,7 +60,6 @@ export default class Migrate extends OmniStudioBaseCommand {
5960

6061
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6162
public async run(): Promise<any> {
62-
const namespace = (this.flags.namespace || 'vlocity_ins') as string;
6363
const apiVersion = (this.flags.apiversion || '55.0') as string;
6464
const migrateOnly = (this.flags.only || '') as string;
6565
const allVersions = this.flags.allversions || false;
@@ -71,25 +71,30 @@ export default class Migrate extends OmniStudioBaseCommand {
7171
const conn = this.org.getConnection();
7272
conn.setApiVersion(apiVersion);
7373

74-
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, namespace);
74+
const orgs: OmnistudioOrgDetails = await OrgUtils.getOrgDetails(conn, this.flags.namespace);
7575

76-
if (orgs.packageDetails.length === 0) {
77-
this.ux.log('No package installed on given org.');
76+
if (!orgs.hasValidNamespace) {
77+
this.ux.warn(messages.getMessage('invalidNamespace') + orgs.packageDetails.namespace);
78+
}
79+
80+
if (!orgs.packageDetails) {
81+
this.ux.error(messages.getMessage('noPackageInstalled'));
7882
return;
7983
}
8084

8185
if (orgs.omniStudioOrgPermissionEnabled) {
82-
this.ux.log('The org is already on standard data model.');
86+
this.ux.error(messages.getMessage('alreadyStandardModel'));
8387
return;
8488
}
8589

90+
const namespace = orgs.packageDetails.namespace;
8691
// Let's time every step
8792
DebugTimer.getInstance().start();
8893
let projectPath: string;
8994
let objectsToProcess: string[] = [];
9095
let targetApexNamespace: string;
9196
if (relatedObjects) {
92-
const validOptions = ['apex', 'lwc'];
97+
const validOptions = [Constants.Apex, Constants.LWC];
9398
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
9499
// Validate input
95100
for (const obj of objectsToProcess) {
@@ -207,7 +212,7 @@ export default class Migrate extends OmniStudioBaseCommand {
207212
];
208213
} else {
209214
switch (migrateOnly) {
210-
case 'os':
215+
case Constants.Omniscript:
211216
migrationObjects.push(
212217
new OmniScriptMigrationTool(
213218
OmniScriptExportType.OS,
@@ -220,7 +225,7 @@ export default class Migrate extends OmniStudioBaseCommand {
220225
)
221226
);
222227
break;
223-
case 'ip':
228+
case Constants.IntegrationProcedure:
224229
migrationObjects.push(
225230
new OmniScriptMigrationTool(
226231
OmniScriptExportType.IP,
@@ -233,10 +238,10 @@ export default class Migrate extends OmniStudioBaseCommand {
233238
)
234239
);
235240
break;
236-
case 'fc':
241+
case Constants.Flexcard:
237242
migrationObjects.push(new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions));
238243
break;
239-
case 'dr':
244+
case Constants.DataMapper:
240245
migrationObjects.push(new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux));
241246
break;
242247
default:
@@ -262,7 +267,7 @@ export default class Migrate extends OmniStudioBaseCommand {
262267
}
263268

264269
private async getTargetApexNamespace(objectsToProcess: string[], targetApexNamespace: string): Promise<string> {
265-
if (objectsToProcess.includes('apex')) {
270+
if (objectsToProcess.includes(Constants.Apex)) {
266271
targetApexNamespace = await this.ux.prompt(
267272
'Enter the target namespace to be used for calling package Apex classes'
268273
);

src/javascripts/reportGeneratorUtility.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ function filterAndSearchTable(tableId) {
110110
}`;
111111
}
112112

113+
function toggleCtaSummaryPanel() {
114+
const panel = document.getElementById('cta-summary-panel');
115+
const main = document.getElementById('main-panel');
116+
const wrapper = document.getElementById('scrollable-wrapper');
117+
118+
const isVisible = panel.classList.contains('visible');
119+
panel.classList.toggle('visible');
120+
main.classList.toggle('shrunk');
121+
122+
// Ensure smooth scroll into view when opened
123+
if (!isVisible) {
124+
setTimeout(() => {
125+
wrapper.scrollLeft = wrapper.scrollWidth;
126+
}, 200); // wait for transition
127+
}
128+
}
113129
function hideOrShowData(reportTable, rowClass, show) {
114130
const rows = Array.from(reportTable.querySelectorAll(`.${rowClass}`));
115131
rows.forEach((row) => {
@@ -145,3 +161,4 @@ document.addEventListener('DOMContentLoaded', () => {
145161
// Expose globally so HTML inline event handlers can access them
146162
window.toggleFilterDropdown = toggleFilterDropdown;
147163
window.filterAndSearchTable = filterAndSearchTable;
164+
window.toggleCtaSummaryPanel = toggleCtaSummaryPanel;

src/migration/related/ApexMigration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Logger } from '../../utils/logger';
1818
import { ApexAssessmentInfo } from '../../utils';
1919
import { FileDiffUtil } from '../../utils/lwcparser/fileutils/FileDiffUtil';
2020
import { Stringutil } from '../../utils/StringValue/stringutil';
21+
import { Constants } from '../../utils/constants/stringContants';
2122
import { BaseRelatedObjectMigration } from './BaseRealtedObjectMigration';
2223

2324
const APEXCLASS = 'Apexclass';
@@ -39,7 +40,7 @@ export class ApexMigration extends BaseRelatedObjectMigration {
3940
this.vlocityOpenInterface = new InterfaceImplements(VLOCITY_OPEN_INTERFACE, this.namespace);
4041
}
4142
public processObjectType(): string {
42-
return 'apex';
43+
return Constants.Apex;
4344
}
4445
// public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
4546
// throw new Error('Method not implemented.');

src/migration/related/LwcMigration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { sfProject } from '../../utils/sfcli/project/sfProject';
66
import { Logger } from '../../utils/logger';
77
import { FileProcessorFactory } from '../../utils/lwcparser/fileutils/FileProcessorFactory';
88
import { FileChangeInfo, LWCAssessmentInfo } from '../../utils';
9+
import { Constants } from '../../utils/constants/stringContants';
910
import { BaseRelatedObjectMigration } from './BaseRealtedObjectMigration';
1011

1112
const LWC_DIR_PATH = '/force-app/main/default/lwc';
1213
const LWCTYPE = 'LightningComponentBundle';
1314

1415
export class LwcMigration extends BaseRelatedObjectMigration {
1516
public processObjectType(): string {
16-
return 'lwc';
17+
return Constants.LWC;
1718
}
1819
// public identifyObjects(migrationResults: MigrationResult[]): Promise<JSON[]> {
1920
// this.assessment();
@@ -65,7 +66,7 @@ export class LwcMigration extends BaseRelatedObjectMigration {
6566
fileMap.forEach((fileList, dir) => {
6667
const changeInfos: FileChangeInfo[] = [];
6768
if (
68-
dir !== 'lwc' &&
69+
dir !== Constants.LWC &&
6970
!dir.endsWith('MultiLanguage') &&
7071
!dir.endsWith('English') &&
7172
!dir.includes('_') &&

0 commit comments

Comments
 (0)