Skip to content

Commit

Permalink
Merge pull request #256 from salesforcecli/u/abhinavkumar2/W-16276171
Browse files Browse the repository at this point in the history
U/abhinavkumar2/w 16276171
  • Loading branch information
AbhinavKumar-sf authored Nov 1, 2024
2 parents e3a0d23 + 5a6baab commit dde566d
Show file tree
Hide file tree
Showing 8 changed files with 429 additions and 393 deletions.
684 changes: 351 additions & 333 deletions src/migration/dataraptor.ts

Large diffs are not rendered by default.

40 changes: 26 additions & 14 deletions src/migration/flexcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
const flexCards = await this.getAllActiveCards();
const flexCardsAssessmentInfos = this.processCardComponents(flexCards);
this.ux.log('flexCardsAssessmentInfos');
this.ux.log((flexCardsAssessmentInfos).toString());
// this.ux.log(flexCardsAssessmentInfos.toString());
return flexCardsAssessmentInfos;
} catch (err) {
this.ux.log(err);
Expand All @@ -110,22 +110,34 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo

// Now process each OmniScript and its elements
for (const flexCard of limitedFlexCards) {
// Await here since processOSComponents is now async
//this.ux.log(flexCard['Name']);
const flexCardAssessmentInfo: FlexCardAssessmentInfo = {
name: flexCard['Name'],
id: '',
dependenciesIP: null,
dependenciesDR: [],
dependenciesOS: [],
infos: [],
warnings: [],
};
flexCardAssessmentInfos.push(flexCardAssessmentInfo);
// Await here since processOSComponents is now async
//this.ux.log(flexCard['Name']);
const flexCardAssessmentInfo: FlexCardAssessmentInfo = {
name: flexCard['Name'],
id: flexCard['Id'],
dependenciesIP: [],
dependenciesDR: [],
dependenciesOS: [],
infos: [],
warnings: [],
};
this.updateDependencies(flexCard, flexCardAssessmentInfo);
flexCardAssessmentInfos.push(flexCardAssessmentInfo);
}
return flexCardAssessmentInfos;
}
}

private updateDependencies(flexCard, flexCardAssessmentInfo): void {
let dataSource = JSON.parse(flexCard[this.namespacePrefix + 'Datasource__c']);
if (dataSource?.datasource) {
dataSource = dataSource.dataSource;
}
if (dataSource['type'] === 'DataRaptor') {
flexCardAssessmentInfo.dependenciesDR.push(dataSource['value']['bundle']);
} else if (dataSource.type === 'IntegrationProcedures') {
flexCardAssessmentInfo.dependenciesIP.push(dataSource['value']['ipMethod']);
}
}
// Query all cards that are active
private async getAllActiveCards(): Promise<AnyJson[]> {
//DebugTimer.getInstance().lap('Query Vlocity Cards');
Expand Down
23 changes: 15 additions & 8 deletions src/migration/omniscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,16 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
for (const elem of elements) {
const type = elem[this.namespacePrefix + 'Type__c'];
const elemName = `${elem['Name']}`;
const propertySet = JSON.parse(elem[this.namespacePrefix + 'PropertySet__c'] || '{}');

// Check for OmniScript dependencies
if (type === 'OmniScript') {
const nameVal = `${elemName}_OmniScript`;
dependencyOS.push(nameVal);
const type = propertySet['Type'];
const subtype = propertySet['Sub Type'];
const language = propertySet['Language'];
const osName = type + '_' + subtype + '_' + language;
dependencyOS.push(osName + ' ( ' + nameVal + ' ) <br>');
if (!existingOmniscriptNames.has(nameVal)) {
missingOS.push(nameVal);
}
Expand All @@ -232,24 +237,26 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
// Check for Integration Procedure Action dependencies
if (type === 'Integration Procedure Action') {
const nameVal = `${elemName}_Integration Procedure Action`;
dependencyIP.push(propertySet['integrationProcedureKey'] + ' (' + nameVal + ') <br>');
if (!existingOmniscriptNames.has(nameVal) && !existingFlexCardNames.has(nameVal)) {
dependencyIP.push(nameVal);
missingIP.push(nameVal);
}
}

// Check for DataRaptor dependencies
if (['DataRaptor Extract Action', 'DataRaptor Turbo Action', 'DataRaptor Post Action'].includes(type)) {
const nameVal = `${elemName}_${type}`;
dependencyDR.push(propertySet['bundle'] + ' ( ' + nameVal + ' ) <br>');
if (!existingOmniscriptNames.has(nameVal) && !existingDataRaptorNames.has(nameVal)) {
dependencyDR.push(nameVal);
missingDR.push(nameVal);
}
}

if (type === 'Remote Action') {
const nameVal = `${elemName}_${type}`;
dependenciesRA.push(nameVal);
const className = propertySet['remoteClass'];
const methodName = propertySet['remoteMethod'];
dependenciesRA.push(className + '.' + methodName + ' (' + nameVal + ') <br>');
}
}

Expand All @@ -266,10 +273,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
const osAssessmentInfo: OSAssessmentInfo = {
name: omniscript['Name'],
id: omniscript['Id'],
dependenciesIP: [],
missingIP: dependencyIP,
dependenciesDR: [],
missingDR: dependencyDR,
dependenciesIP: dependencyIP,
missingIP: [],
dependenciesDR: dependencyDR,
missingDR: [],
dependenciesOS: dependencyOS,
missingOS: missingOS,
dependenciesRemoteAction: dependenciesRA,
Expand Down
4 changes: 2 additions & 2 deletions src/migration/related/ApexMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ApexMigration extends BaseRelatedObjectMigration implements Related
private readonly callableInterface: InterfaceImplements;
private readonly vlocityOpenInterface2: InterfaceImplements;
private readonly vlocityOpenInterface: InterfaceImplements;
private updatedNamespace = this.namespace;
private updatedNamespace = 'omnistudio';
public constructor(projectPath: string, namespace: string, org: Org) {
super(projectPath, namespace, org);
this.callableInterface = new InterfaceImplements(CALLABLE, this.namespace);
Expand Down Expand Up @@ -71,7 +71,7 @@ export class ApexMigration extends BaseRelatedObjectMigration implements Related
if (file.ext !== '.cls') continue;
try {
const apexAssementInfo = this.processApexFile(file);
if (apexAssementInfo && apexAssementInfo.diff && apexAssementInfo.diff.length === 0) continue;
if (apexAssementInfo && apexAssementInfo.diff.length === 0) continue;
fileAssessmentInfo.push(apexAssementInfo);
} catch (err) {
Logger.logger.error(`Error processing ${file.name}`);
Expand Down
4 changes: 2 additions & 2 deletions src/migration/related/LwcMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class LwcMigration extends BaseRelatedObjectMigration {
const type = 'assessment';
const pwd = shell.pwd();
shell.cd(this.projectPath);
// sfProject.retrieve(LWCTYPE, this.org.getUsername());
sfProject.retrieve(LWCTYPE, this.org.getUsername());
const filesMap = this.processLwcFiles(this.projectPath);
shell.cd(pwd);
return this.processFiles(filesMap, type);
Expand Down Expand Up @@ -59,7 +59,7 @@ export class LwcMigration extends BaseRelatedObjectMigration {
const jsonData: LWCAssessmentInfo[] = [];
fileMap.forEach((fileList, dir) => {
const changeInfos: FileChangeInfo[] = [];
if (dir !== 'lwc') {
if (dir !== 'lwc' && !dir.endsWith('English') && !dir.includes('_') && !dir.includes('cf')) {
for (const file of fileList) {
if (this.isValideFile(file.name)) {
const processor = FileProcessorFactory.getFileProcessor(file.ext);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class QueryTools {
let allrecords = [];

const query = QueryTools.buildCustomObjectQuery(namespace, objectName, fields, filters);

// Execute the query
let results = await connection.query<AnyJson>(query);

Expand Down
64 changes: 32 additions & 32 deletions src/utils/resultsbuilder/assessmentReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export class AssessmentReporter {
public static async generate(result: AssessmentInfo, instanceUrl: string): Promise<void> {
let htmlBody = '';

htmlBody += '<br />' + this.generateLwcAssesment(result.lwcAssessmentInfos);
htmlBody += '<br />' + this.generateOmniAssesment(result.omniAssessmentInfo, instanceUrl);
htmlBody += '<br />' + this.generateCardAssesment(result.flexCardAssessmentInfos, instanceUrl);
htmlBody += '<br />' + this.generateDRAssesment(result.dataRaptorAssessmentInfos, instanceUrl);
htmlBody += '<br />' + this.generateApexAssesment(result.apexAssessmentInfos);
htmlBody += '<br />' + this.generateOmniAssesment(result.omniAssessmentInfo);
htmlBody += '<br />' + this.generateCardAssesment(result.flexCardAssessmentInfos);
htmlBody += '<br />' + this.generateDRAssesment(result.dataRaptorAssessmentInfos);
htmlBody += '<br />' + this.generateLwcAssesment(result.lwcAssessmentInfos);

const doc = this.generateDocument(htmlBody);
const fileUrl = process.cwd() + '/assessmentresults.html';
Expand All @@ -35,12 +35,12 @@ export class AssessmentReporter {
tableBody += `
<html>
<head>
<title>OmniStudio Migration Results</title>
<title>OmniStudio Migration Assessment</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/design-system/2.17.5/styles/salesforce-lightning-design-system.min.css" />
</head>
<body>
<div style="margin: 20px;">
<div class="slds-text-heading_large">OmniStudio Migration Results</div>`;
<div class="slds-text-heading_large">OmniStudio Migration Assessment</div>`;
tableBody += '<div class="slds-text-heading_large">LWC Assessment</div>';
for (const lwcAssessmentInfo of lwcAssessmentInfos) {
let changeInfoRows = '';
Expand Down Expand Up @@ -87,16 +87,16 @@ export class AssessmentReporter {
return this.getApexAssessmentReport(tableBody);
}

private static generateOmniAssesment(omniAssessmentInfo: OmniAssessmentInfo): string {
private static generateOmniAssesment(omniAssessmentInfo: OmniAssessmentInfo, instanceUrl: string): string {
let htmlBody = '';

// htmlBody += '<br />' + this.generateLwcAssesment(result.lwcAssessmentInfos);
htmlBody += '<br />' + this.generateOSAssesment(omniAssessmentInfo.osAssessmentInfos);
htmlBody += '<br />' + this.generateIPAssesment(omniAssessmentInfo.ipAssessmentInfos);
htmlBody += '<br />' + this.generateOSAssesment(omniAssessmentInfo.osAssessmentInfos, instanceUrl);
htmlBody += '<br />' + this.generateIPAssesment(omniAssessmentInfo.ipAssessmentInfos, instanceUrl);
return htmlBody;
}

private static generateOSAssesment(osAssessmentInfos: OSAssessmentInfo[]): string {
private static generateOSAssesment(osAssessmentInfos: OSAssessmentInfo[], instanceUrl: string): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">Omniscript Components Assessment</div>';

Expand All @@ -107,26 +107,26 @@ export class AssessmentReporter {
<div class="slds-truncate" title="${osAssessmentInfo.name}">${osAssessmentInfo.name}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 100px;">
<div class="slds-truncate" title="${osAssessmentInfo.id}">${osAssessmentInfo.id}</div>
<div class="slds-truncate" title="${osAssessmentInfo.id}"><a href="${instanceUrl}/${osAssessmentInfo.id}">${osAssessmentInfo.id}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.dependenciesOS}">${osAssessmentInfo.dependenciesOS}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<!-- <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.missingOS}">${osAssessmentInfo.missingOS}</div>
</td>
</td> -->
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.dependenciesIP}">${osAssessmentInfo.dependenciesIP}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<!-- <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.missingIP}">${osAssessmentInfo.missingIP}</div>
</td>
</td> -->
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.dependenciesDR}">${osAssessmentInfo.dependenciesDR}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<!-- <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.missingDR}">${osAssessmentInfo.missingDR}</div>
</td>
</td> -->
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${osAssessmentInfo.dependenciesRemoteAction}">${osAssessmentInfo.dependenciesRemoteAction}</div>
</td>
Expand All @@ -137,7 +137,7 @@ export class AssessmentReporter {
return this.getOSAssessmentReport(tableBody);
}

private static generateIPAssesment(ipAssessmentInfos: IPAssessmentInfo[]): string {
private static generateIPAssesment(ipAssessmentInfos: IPAssessmentInfo[], instanceUrl: string): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">Integration Procedure Components Assessment</div>';

Expand All @@ -148,11 +148,11 @@ export class AssessmentReporter {
<div class="slds-truncate" title="${ipAssessmentInfo.name}">${ipAssessmentInfo.name}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 100px;">
<div class="slds-truncate" title="${ipAssessmentInfo.id}">${ipAssessmentInfo.id}</div>
<div class="slds-truncate" title="${ipAssessmentInfo.id}"><a href="${instanceUrl}/${ipAssessmentInfo.id}">${ipAssessmentInfo.id}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<!-- <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${ipAssessmentInfo.dependenciesOS}">${ipAssessmentInfo.dependenciesOS}</div>
</td>
</td> -->
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${ipAssessmentInfo.dependenciesIP}">${ipAssessmentInfo.dependenciesIP}</div>
</td>
Expand All @@ -169,7 +169,7 @@ export class AssessmentReporter {
return this.getIPAssessmentReport(tableBody);
}

private static generateCardAssesment(flexCardAssessmentInfos: FlexCardAssessmentInfo[]): string {
private static generateCardAssesment(flexCardAssessmentInfos: FlexCardAssessmentInfo[], instanceUrl: string): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">Flexcard Components Assessment</div>';
for (const card of flexCardAssessmentInfos) {
Expand All @@ -179,7 +179,7 @@ export class AssessmentReporter {
<div class="slds-truncate" title="${card.name}">${card.name}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 100px;">
<div class="slds-truncate" title="${card.id}">${card.id}</div>
<div class="slds-truncate" title="${card.id}"><a href="${instanceUrl}/${card.id}">${card.id}</div>
</td>
<td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;">
<div title="${card.dependenciesOS}">${card.dependenciesOS}</div>
Expand All @@ -197,7 +197,7 @@ export class AssessmentReporter {
return this.getCardAssessmentReport(tableBody);
}

private static generateDRAssesment(dataRaptorAssessmentInfos: DataRaptorAssessmentInfo[]): string {
private static generateDRAssesment(dataRaptorAssessmentInfos: DataRaptorAssessmentInfo[], instanceUrl): string {
let tableBody = '';
tableBody += '<div class="slds-text-heading_large">Data Raptor Components Assessment</div>';
for (const dr of dataRaptorAssessmentInfos) {
Expand Down Expand Up @@ -287,21 +287,21 @@ export class AssessmentReporter {
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Omniscript Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<!-- <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Omniscript Missing Dependencies</div>
</th>
</th> -->
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Integration Procedures Dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<!-- <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Integration Procedures Missing Dependencies</div>
</th>
</th> -->
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Data Raptor dependencies</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<!-- <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Data Raptor Missing dependencies</div>
</th>
</th> -->
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Remote Action dependencies</div>
</th>
Expand All @@ -327,9 +327,9 @@ export class AssessmentReporter {
<th class="" scope="col" style="width: 10%; word-wrap: break-word; white-space: normal; text-align: left;">
<div class="slds-truncate" title="ID">ID</div>
</th>
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<!-- <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Omniscript Dependencies</div>
</th>
</th> -->
<th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;">
<div title="Dependencies">Integration Procedures Dependencies</div>
</th>
Expand Down
1 change: 0 additions & 1 deletion src/utils/resultsbuilder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ResultsBuilder {
const doc = this.generateDocument(htmlBody);
const fileUrl = process.cwd() + '/migrationresults.html';
fs.writeFileSync(fileUrl, doc);

await open('file://' + fileUrl);
}

Expand Down

0 comments on commit dde566d

Please sign in to comment.