Skip to content

Commit be466f0

Browse files
fix: cleaned up assessment report
2 parents e7c2432 + 08e373e commit be466f0

File tree

17 files changed

+1315
-278
lines changed

17 files changed

+1315
-278
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ out.log
4343
migrationresults.html
4444

4545
oclif.manifest.json
46-
omnistudio_migration
47-
46+
omnistudio_migration

package.json

Lines changed: 1 addition & 2 deletions
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": "1.4.1-dev.5",
4+
"version": "1.4.1-dev.8",
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
@@ -36,7 +36,6 @@
3636
"@salesforce/ts-sinon": "^1",
3737
"@types/babel__traverse": "^7.20.6",
3838
"@types/jsforce": "^1.11.5",
39-
"@types/mocha": "^10.0.8",
4039
"@typescript-eslint/eslint-plugin": "^4.2.0",
4140
"@typescript-eslint/parser": "^4.2.0",
4241
"chai": "^4.4.1",

src/commands/omnistudio/migration/assess.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { AssessmentInfo } from '../../../utils/interfaces';
66
import { AssessmentReporter } from '../../../utils/resultsbuilder/assessmentReporter';
77
import { LwcMigration } from '../../../migration/related/LwcMigration';
88
import { ApexMigration } from '../../../migration/related/ApexMigration';
9+
import { OmniScriptExportType, OmniScriptMigrationTool } from '../../../migration/omniscript';
10+
import { CardMigrationTool } from '../../../migration/flexcard';
11+
import { DataRaptorMigrationTool } from '../../../migration/dataraptor';
12+
import { DebugTimer, DataRaptorAssessmentInfo, FlexCardAssessmentInfo } from '../../../utils';
13+
914
import { Logger } from '../../../utils/logger';
1015
import OmnistudioRelatedObjectMigrationFacade from './OmnistudioRelatedObjectMigrationFacade';
1116

@@ -37,19 +42,42 @@ export default class Assess extends OmniStudioBaseCommand {
3742

3843
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3944
public async run(): Promise<any> {
45+
DebugTimer.getInstance().start();
4046
const namespace = (this.flags.namespace || 'vlocity_ins') as string;
4147
const apiVersion = (this.flags.apiversion || '55.0') as string;
48+
const allVersions = true;
4249
const conn = this.org.getConnection();
4350
Logger.initialiseLogger(this.ux, this.logger);
4451
const projectDirectory = OmnistudioRelatedObjectMigrationFacade.intializeProject();
4552
conn.setApiVersion(apiVersion);
4653
const lwcparser = new LwcMigration(projectDirectory, namespace, this.org);
4754
const apexMigrator = new ApexMigration(projectDirectory, namespace, this.org);
55+
const osMigrator = new OmniScriptMigrationTool(
56+
OmniScriptExportType.All,
57+
namespace,
58+
conn,
59+
this.logger,
60+
messages,
61+
this.ux,
62+
allVersions
63+
);
64+
const flexMigrator = new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions);
65+
const drMigrator = new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux);
4866
this.logger.info(namespace);
4967
this.ux.log(`Using Namespace: ${namespace}`);
68+
69+
const dataRaptorAssessmentInfos: DataRaptorAssessmentInfo[] = await drMigrator.assess();
70+
this.ux.log('dataRaptorAssessmentInfos');
71+
this.ux.log(dataRaptorAssessmentInfos.toString());
72+
const flexCardAssessmentInfos: FlexCardAssessmentInfo[] = await flexMigrator.assess();
73+
const omniAssessmentInfo = await osMigrator.assess(dataRaptorAssessmentInfos, flexCardAssessmentInfos);
74+
5075
const assesmentInfo: AssessmentInfo = {
5176
lwcAssessmentInfos: lwcparser.assessment(),
5277
apexAssessmentInfos: apexMigrator.assess(),
78+
dataRaptorAssessmentInfos,
79+
flexCardAssessmentInfos,
80+
omniAssessmentInfo,
5381
};
5482
await AssessmentReporter.generate(assesmentInfo, conn.instanceUrl);
5583
return assesmentInfo;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const mapping = ['DeveloperName', 'NamespacePrefix', 'QualifiedApiName', 'ClassName__c', 'MethodName__c'];
2+
3+
export default mapping;

src/migration/DependencyChecker.ts

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
2+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
/*
5+
import { MigrationTool } from './interfaces';
6+
import { OmniScriptMigrationTool } from './omniscript';
7+
import { CardMigrationTool } from './flexcard';
8+
import { DataRaptorMigrationTool } from './dataraptor';
9+
10+
interface DependencyReport {
11+
name: string;
12+
type: string;
13+
id: string;
14+
missingDependencies: DependencyReport[];
15+
}
16+
*/
17+
18+
export class DependencyChecker {
19+
/*
20+
public static async checkDependencies(migrationObjects: MigrationTool[]): Promise<DependencyReport[]> {
21+
const existingNames = new Set(migrationObjects.map((obj) => obj.getName()));
22+
const componentsReport: DependencyReport[] = [];
23+
24+
for (const migrationObject of migrationObjects) {
25+
const dependencies = await this.getDependencies(migrationObject);
26+
const missing = dependencies.filter((dep) => !existingNames.has(dep));
27+
28+
const componentReport: DependencyReport = {
29+
name: migrationObject.getName(),
30+
type: migrationObject.constructor.name,
31+
id: migrationObject['Id'],
32+
missingDependencies: this.getMissingComponents(missing, migrationObjects),
33+
};
34+
35+
componentsReport.push(componentReport);
36+
}
37+
38+
return componentsReport;
39+
}
40+
41+
private static async getDependencies(migrationObject: MigrationTool): Promise<string[]> {
42+
const dependencyFetchers = {
43+
OmniScriptMigrationTool: this.getOmniScriptDependencies,
44+
CardMigrationTool: this.getCardDependencies,
45+
DataRaptorMigrationTool: this.getDataRaptorDependencies,
46+
};
47+
48+
const fetcher = dependencyFetchers[migrationObject.constructor.name];
49+
return fetcher ? await fetcher(migrationObject) : [];
50+
}
51+
52+
private static async getOmniScriptDependencies(migrationObject: OmniScriptMigrationTool): Promise<string[]> {
53+
const elements = await migrationObject.getAllElementsForOmniScript(migrationObject.getName());
54+
return elements.map((element) => migrationObject.getRecordName(element));
55+
}
56+
57+
private static getCardDependencies(migrationObject: CardMigrationTool): string[] {
58+
return this.fetchIntegrationProceduresAndDataRaptors(migrationObject);
59+
}
60+
61+
private static getDataRaptorDependencies(migrationObject: DataRaptorMigrationTool): string[] {
62+
return []; // Implement actual logic for DataRaptor dependencies
63+
}
64+
65+
private static fetchIntegrationProceduresAndDataRaptors(migrationObject: any): string[] {
66+
// Replace with actual fetching logic
67+
return ['IntegrationProcedure1', 'DataRaptor1'];
68+
}
69+
70+
private static getMissingComponents(missing: string[], migrationObjects: MigrationTool[]): DependencyReport[] {
71+
const missingReports: DependencyReport[] = [];
72+
73+
for (const dep of missing) {
74+
const component = migrationObjects.find((obj) => obj.getName() === dep);
75+
const report = component
76+
? this.createReportForFoundComponent(component, dep)
77+
: this.createReportForUnknownComponent(dep);
78+
missingReports.push(report);
79+
}
80+
81+
return missingReports;
82+
}
83+
84+
private static createReportForFoundComponent(component: MigrationTool, dep: string): DependencyReport {
85+
return {
86+
name: component.getName(),
87+
type: component.constructor.name,
88+
id: component['Id'],
89+
missingDependencies: [],
90+
};
91+
}
92+
93+
private static createReportForUnknownComponent(componentName: string): DependencyReport {
94+
const componentType = this.determineComponentType(componentName);
95+
return {
96+
name: componentName,
97+
type: componentType,
98+
id: '',
99+
missingDependencies: [],
100+
};
101+
}
102+
103+
private static determineComponentType(componentName: string): string {
104+
if (componentName.includes('IntegrationProcedure')) {
105+
return 'Integration Procedure';
106+
} else if (componentName.includes('DataRaptor')) {
107+
return 'DataRaptor';
108+
} else if (componentName.includes('OmniScript')) {
109+
return 'OmniScript';
110+
} else if (componentName.includes('Card')) {
111+
return 'Flex Card';
112+
}
113+
return 'Unknown';
114+
}
115+
*/
116+
}

0 commit comments

Comments
 (0)