Skip to content

Commit 4ec2fa8

Browse files
feat: @W-19181248: Assessment/Migration message for IP & OS components
Changs: - Display respective component label based on only flag - Added the truncate error handling
1 parent d128ab9 commit 4ec2fa8

File tree

8 files changed

+105
-42
lines changed

8 files changed

+105
-42
lines changed

messages/assess.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,27 @@
4040
"errorDuringFlexCardAssessment": "Error during FlexCard assessment",
4141
"errorDuringOmniScriptAssessment": "Error during OmniScript assessment",
4242
"processingFlexCard": "Processing FlexCard: %s",
43-
"processingDataRaptor": "Processing DataRaptor: %s",
43+
"processingDataRaptor": "Processing DataMapper: %s",
4444
"processingOmniScript": "Processing OmniScript: %s",
45-
"foundDataRaptorsToAssess": "Found %s DataRaptors to assess",
46-
"foundOmniScriptsToAssess": "Found %s OmniScripts and Integration Procedures to assess",
47-
"startingDataRaptorAssessment": "Starting DataRaptor assessment",
48-
"startingOmniScriptAssessment": "Starting OmniScript assessment",
45+
"foundDataRaptorsToAssess": "Found %s DataMappers to assess",
46+
"foundOmniScriptsToAssess": "Found %s %s to assess",
47+
"startingDataRaptorAssessment": "Starting DataMappers assessment",
48+
"startingOmniScriptAssessment": "Starting %s assessment",
4949
"allVersionsInfo": "allVersions : %s",
5050
"assessmentInitialization": "Assessment Initialization: Using namespace: %s",
5151
"apiVersionInfo": "API Version: %s",
5252
"assessmentTargets": "Assessment targets: %s",
5353
"relatedObjectsInfo": "Related objects: %s",
5454
"allVersionsFlagInfo": "All versions: %s",
55-
"assessedDataRaptorsCount": "Assessed %s DataRaptors",
56-
"dataRaptorAssessmentCompleted": "DataRaptor assessment completed",
55+
"assessedDataRaptorsCount": "Assessed %s DataMappers",
56+
"dataRaptorAssessmentCompleted": "DataMappers assessment completed",
5757
"flexCardAssessment": "FlexCard Assessment",
5858
"assessedFlexCardsCount": "Assessed %s FlexCards",
5959
"flexCardAssessmentCompleted": "FlexCard assessment completed",
60-
"omniScriptAssessment": "OmniScript and Integration Procedure Assessment",
60+
"omniScriptAssessment": "%s Assessment",
6161
"assessedOmniScriptsCount": "Assessed %s OmniScripts",
6262
"assessedIntegrationProceduresCount": "Assessed %s Integration Procedures",
63-
"omniScriptAssessmentCompleted": "OmniScript and Integration Procedure assessment completed",
63+
"omniScriptAssessmentCompleted": "%s assessment completed",
6464
"startingFlexCardAssessment": "Starting FlexCard assessment",
6565
"foundFlexCardsToAssess": "Found %s FlexCards to assess",
6666
"startingApexAssessment": "Starting Apex assessment in project path: %s",
@@ -90,7 +90,7 @@
9090
"cardNameChangeMessage": "Card name will be changed from %s to %s to follow API naming standards",
9191
"authordNameChangeMessage": "Author name will be changed from %s to %s to follow API naming standards",
9292
"omniScriptNameChangeMessage": "OmniScript reference part %s will be changed to %s during migration.",
93-
"dataRaptorNameChangeMessage": "DataRaptor reference %s will be changed to %s during migration.",
93+
"dataRaptorNameChangeMessage": "DataMapper reference %s will be changed to %s during migration.",
9494
"integrationProcedureNameChangeMessage": "Integration Procedure reference %s will be changed to %s during migration.",
9595
"integrationProcedureManualUpdateMessage": "Integration Procedure reference %s may need manual updates after migration.",
9696
"duplicateCardNameMessage": "Potential duplicate: Another card has the same name %s after name cleaning. This may cause conflicts during migration",

messages/migrate.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
"migratingComponent": "Migrating: %s",
6666
"migrationCompleted": "Migration completed: %s",
6767
"formulaSyntaxError": "There was some problem while updating the formula syntax, please check the all the formula's syntax once : %s",
68-
"foundDataRaptorsToMigrate": "Found %s DataRaptors to migrate",
68+
"foundDataRaptorsToMigrate": "Found %s DataMappers to migrate",
6969
"foundFlexCardsToMigrate": "Found %s FlexCards to migrate",
70-
"foundOmniScriptsToMigrate": "Found %s OmniScripts and Integration Procedures to migrate",
70+
"foundOmniScriptsToMigrate": "Found %s %s to migrate",
7171
"allVersionsInfo": "allVersions : %s",
7272
"migrationInitialization": "Migration Initialization: Using namespace: %s",
7373
"apiVersionInfo": "API Version: %s",
@@ -94,7 +94,7 @@
9494
"packageSelectionPrompt": "Enter the number of the package to use (1-%s):",
9595
"invalidPackageSelection": "Invalid selection. Please enter a number between 1 and %s.",
9696
"selectedPackage": "Selected package: %s (Version: %s)",
97-
"dataRaptorNameChangeMessage": "DataRaptor reference %s will be changed to %s during migration.",
97+
"dataRaptorNameChangeMessage": "DataMapper reference %s will be changed to %s during migration.",
9898
"integrationProcedureNameChangeMessage": "Integration Procedure reference %s will be changed to %s during migration.",
9999
"integrationProcedureManualUpdateMessage": "Integration Procedure reference %s may need manual updates after migration.",
100100
"cardAuthorNameChangeMessage": "Card author name has been modified to fit naming rules: %s",
@@ -114,5 +114,6 @@
114114
"labelStatusFailed": "Failed",
115115
"labelStatusComplete": "Complete",
116116
"migrationConsentNotGiven": "Couldn't confirm whether assessment errors are resolved",
117-
"migrationConsentMessage": "Ensure that all items in the assessment report are marked as Green before proceeding with the migration. Do you want to proceed?"
117+
"migrationConsentMessage": "Ensure that all items in the assessment report are marked as Green before proceeding with the migration. Do you want to proceed?",
118+
"truncationFailed": "Truncation failed for %s: %s"
118119
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export default class Assess extends OmniStudioBaseCommand {
168168
// If no specific component is specified, assess all components
169169
await this.assessDataRaptors(assesmentInfo, namespace, conn);
170170
await this.assessFlexCards(assesmentInfo, namespace, conn, allVersions);
171-
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.All);
171+
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.OS);
172+
await this.assessOmniScripts(assesmentInfo, namespace, conn, allVersions, OmniScriptExportType.IP);
172173
return;
173174
}
174175

@@ -219,20 +220,38 @@ export default class Assess extends OmniStudioBaseCommand {
219220
allVersions: boolean,
220221
exportType: OmniScriptExportType
221222
): Promise<void> {
222-
Logger.logVerbose(messages.getMessage('omniScriptAssessment'));
223+
const exportComponentType = exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
224+
Logger.logVerbose(messages.getMessage('omniScriptAssessment', [exportComponentType]));
223225
const osMigrator = new OmniScriptMigrationTool(exportType, namespace, conn, Logger, messages, this.ux, allVersions);
224-
assesmentInfo.omniAssessmentInfo = await osMigrator.assess(
226+
const newOmniAssessmentInfo = await osMigrator.assess(
225227
assesmentInfo.dataRaptorAssessmentInfos,
226228
assesmentInfo.flexCardAssessmentInfos
227229
);
228-
Logger.logVerbose(
229-
messages.getMessage('assessedOmniScriptsCount', [assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length])
230-
);
231-
Logger.logVerbose(
232-
messages.getMessage('assessedIntegrationProceduresCount', [
233-
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
234-
])
235-
);
236-
Logger.log(messages.getMessage('omniScriptAssessmentCompleted'));
230+
231+
// Initialize omniAssessmentInfo if it doesn't exist
232+
if (!assesmentInfo.omniAssessmentInfo) {
233+
assesmentInfo.omniAssessmentInfo = {
234+
osAssessmentInfos: [],
235+
ipAssessmentInfos: [],
236+
};
237+
}
238+
239+
// Merge results instead of overwriting
240+
if (exportType === OmniScriptExportType.OS) {
241+
// For OmniScript assessment, update osAssessmentInfos
242+
assesmentInfo.omniAssessmentInfo.osAssessmentInfos = newOmniAssessmentInfo.osAssessmentInfos;
243+
Logger.logVerbose(
244+
messages.getMessage('assessedOmniScriptsCount', [assesmentInfo.omniAssessmentInfo.osAssessmentInfos.length])
245+
);
246+
} else {
247+
// For Integration Procedure assessment, update ipAssessmentInfos
248+
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos = newOmniAssessmentInfo.ipAssessmentInfos;
249+
Logger.logVerbose(
250+
messages.getMessage('assessedIntegrationProceduresCount', [
251+
assesmentInfo.omniAssessmentInfo.ipAssessmentInfos.length,
252+
])
253+
);
254+
}
255+
Logger.log(messages.getMessage('omniScriptAssessmentCompleted', [exportComponentType]));
237256
}
238257
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class Migrate extends OmniStudioBaseCommand {
8181
}
8282

8383
// eslint-disable-next-line @typescript-eslint/no-explicit-any
84+
// eslint-disable-next-line complexity
8485
public async runMigration(): Promise<any> {
8586
let apiVersion = this.flags.apiversion as string;
8687
const migrateOnly = (this.flags.only || '') as string;
@@ -168,6 +169,12 @@ export default class Migrate extends OmniStudioBaseCommand {
168169
let objectMigrationResults = await this.truncateObjects(migrationObjects, debugTimer);
169170
const allTruncateComplete = objectMigrationResults.length === 0;
170171

172+
// Log truncation errors if any exist
173+
if (!allTruncateComplete) {
174+
this.logTruncationErrors(objectMigrationResults);
175+
return;
176+
}
177+
171178
if (allTruncateComplete) {
172179
objectMigrationResults = await this.migrateObjects(migrationObjects, debugTimer);
173180
}
@@ -276,6 +283,8 @@ export default class Migrate extends OmniStudioBaseCommand {
276283

277284
private async migrateObjects(migrationObjects: MigrationTool[], debugTimer: DebugTimer): Promise<MigratedObject[]> {
278285
let objectMigrationResults: MigratedObject[] = [];
286+
// Migrate in correct dependency order
287+
// DM -> IP -> OS -> FC
279288
for (const cls of migrationObjects.reverse()) {
280289
try {
281290
Logger.log(messages.getMessage('migratingComponent', [cls.getName()]));
@@ -315,8 +324,19 @@ export default class Migrate extends OmniStudioBaseCommand {
315324
if (!migrateOnly) {
316325
migrationObjects = [
317326
new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux),
327+
// Integration Procedure
328+
new OmniScriptMigrationTool(
329+
OmniScriptExportType.IP,
330+
namespace,
331+
conn,
332+
this.logger,
333+
messages,
334+
this.ux,
335+
allVersions
336+
),
337+
// Omniscript
318338
new OmniScriptMigrationTool(
319-
OmniScriptExportType.All,
339+
OmniScriptExportType.OS,
320340
namespace,
321341
conn,
322342
this.logger,
@@ -429,4 +449,12 @@ export default class Migrate extends OmniStudioBaseCommand {
429449

430450
return mergedResults;
431451
}
452+
453+
private logTruncationErrors(objectMigrationResults: MigratedObject[]): void {
454+
objectMigrationResults.forEach((result) => {
455+
if (result.errors && result.errors.length > 0) {
456+
Logger.error(messages.getMessage('truncationFailed', [result.name, result.errors.join(', ')]));
457+
}
458+
});
459+
}
432460
}

src/migration/base.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Stringutil } from '../utils/StringValue/stringutil';
77
import { Logger } from '../utils/logger';
88
import { TransformData, UploadRecordResult } from './interfaces';
99

10-
export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integration Procedure';
10+
export type ComponentType = 'DataMappers' | 'Flexcards' | 'Omniscripts' | 'Integration Procedures';
1111

1212
/**
1313
* Creates a progress bar for migration/assessment operations
@@ -17,10 +17,15 @@ export type ComponentType = 'Data Mapper' | 'Flexcard' | 'Omniscript and Integra
1717
* @returns A configured cliProgress.SingleBar instance
1818
*/
1919
export const createProgressBar = (action: string, componentType: ComponentType): cliProgress.SingleBar => {
20+
// Normalize type to string for comparison
21+
const typeStr = String(componentType);
22+
23+
// Determine if space should be empty or tabs
24+
const noSpaceTypes = ['Omniscript', 'Integration Procedure', 'ExperienceSites'];
25+
const space = noSpaceTypes.includes(typeStr) ? '' : '\t\t\t\t';
26+
2027
return new cliProgress.SingleBar({
21-
format: `${action} ${componentType} |${
22-
componentType === 'Omniscript and Integration Procedure' ? '' : '\t\t\t\t'
23-
} {bar} | {percentage}% || {value}/{total} Tasks`,
28+
format: `${action} ${componentType} | ${space} {bar} | {percentage}% || {value}/{total} Tasks`,
2429
barCompleteChar: '\u2588',
2530
barIncompleteChar: '\u2591',
2631
hideCursor: true,

src/migration/dataraptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
101101
(dr) => dr[this.namespacePrefix + 'Type__c'] !== 'Migration'
102102
).length;
103103
Logger.log(this.messages.getMessage('foundDataRaptorsToMigrate', [nonMigrationDataRaptors]));
104-
const progressBar = createProgressBar('Migrating', 'Data Mapper');
104+
const progressBar = createProgressBar('Migrating', 'DataMappers');
105105
progressBar.start(nonMigrationDataRaptors, progressCounter);
106106
for (let dr of dataRaptors) {
107107
// Skip if Type is "Migration"
@@ -237,7 +237,7 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
237237
const existingDataRaptorNames = new Set<string>();
238238
const dataRaptorItemsMap = await this.getAllDRToItemsMap();
239239

240-
const progressBar = createProgressBar('Assessing', 'Data Mapper');
240+
const progressBar = createProgressBar('Assessing', 'DataMappers');
241241
let progressCounter = 0;
242242
let nonMigrationDataRaptors = dataRaptors.filter(
243243
(dr) => dr[this.namespacePrefix + 'Type__c'] !== 'Migration'

src/migration/flexcard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
8686
const cards = await this.getAllActiveCards();
8787
Logger.log(this.messages.getMessage('foundFlexCardsToMigrate', [cards.length]));
8888

89-
const progressBar = createProgressBar('Migrating', 'Flexcard');
89+
const progressBar = createProgressBar('Migrating', 'Flexcards');
9090
// Save the Vlocity Cards in OmniUiCard
9191
const cardUploadResponse = await this.uploadAllCards(cards, progressBar);
9292

@@ -123,7 +123,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
123123
public async processCardComponents(flexCards: AnyJson[]): Promise<FlexCardAssessmentInfo[]> {
124124
const flexCardAssessmentInfos: FlexCardAssessmentInfo[] = [];
125125
let progressCounter = 0;
126-
const progressBar = createProgressBar('Assessing', 'Flexcard');
126+
const progressBar = createProgressBar('Assessing', 'Flexcards');
127127
progressBar.start(flexCards.length, progressCounter);
128128
const uniqueNames = new Set<string>();
129129

src/migration/omniscript.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
QueryTools,
1313
SortDirection,
1414
} from '../utils';
15-
import { BaseMigrationTool } from './base';
15+
import { BaseMigrationTool, ComponentType } from './base';
1616
import {
1717
InvalidEntityTypeError,
1818
MigrationResult,
@@ -65,7 +65,11 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
6565
}
6666

6767
getName(): string {
68-
return 'OmniScript / Integration Procedures';
68+
if (this.exportType === OmniScriptExportType.IP) {
69+
return 'Integration Procedures';
70+
} else if (this.exportType === OmniScriptExportType.OS) {
71+
return 'Omniscripts';
72+
}
6973
}
7074

7175
getRecordName(record: string) {
@@ -189,9 +193,11 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
189193
flexCardAssessmentInfos: FlexCardAssessmentInfo[]
190194
): Promise<OmniAssessmentInfo> {
191195
try {
192-
Logger.log(this.messages.getMessage('startingOmniScriptAssessment'));
196+
const exportComponentType =
197+
this.exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
198+
Logger.log(this.messages.getMessage('startingOmniScriptAssessment', [exportComponentType]));
193199
const omniscripts = await this.getAllOmniScripts();
194-
Logger.log(this.messages.getMessage('foundOmniScriptsToAssess', [omniscripts.length]));
200+
Logger.log(this.messages.getMessage('foundOmniScriptsToAssess', [omniscripts.length, exportComponentType]));
195201

196202
const omniAssessmentInfos = await this.processOmniComponents(
197203
omniscripts,
@@ -220,7 +226,9 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
220226
const existingDataRaptorNames = new Set(dataRaptorAssessmentInfos.map((info) => info.name));
221227
const existingFlexCardNames = new Set(flexCardAssessmentInfos.map((info) => info.name));
222228

223-
const progressBar = createProgressBar('Assessing', 'Omniscript and Integration Procedure');
229+
const progressBarType: ComponentType =
230+
this.exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
231+
const progressBar = createProgressBar('Assessing', progressBarType);
224232
let progressCounter = 0;
225233
progressBar.start(omniscripts.length, progressCounter);
226234
// First, collect all OmniScript names from the omniscripts array
@@ -509,8 +517,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
509517
// Variables to be returned After Migration
510518
let originalOsRecords = new Map<string, any>();
511519
let osUploadInfo = new Map<string, UploadRecordResult>();
512-
Logger.log(this.messages.getMessage('foundOmniScriptsToMigrate', [omniscripts.length]));
513-
const progressBar = createProgressBar('Migrating', 'Omniscript and Integration Procedure');
520+
const exportComponentType = this.exportType === OmniScriptExportType.IP ? 'Integration Procedures' : 'Omniscripts';
521+
Logger.log(this.messages.getMessage('foundOmniScriptsToMigrate', [omniscripts.length, exportComponentType]));
522+
const progressBarType: ComponentType = exportComponentType;
523+
const progressBar = createProgressBar('Migrating', progressBarType);
514524
let progressCounter = 0;
515525
progressBar.start(omniscripts.length, progressCounter);
516526

0 commit comments

Comments
 (0)