Skip to content

Commit 35c8844

Browse files
chore: added test cases
1 parent 6cb5efd commit 35c8844

File tree

7 files changed

+926
-18
lines changed

7 files changed

+926
-18
lines changed

messages/assess.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,6 @@
224224
"omniStudioAllVersionsProcessingConsentNotGiven": "You've not consented to assess all versions of the Omnistudio components. We cannot proceed with the assessment.",
225225
"omniStudioAllVersionsProcessingConsentGiven": "You've consented to assess all versions of the Omnistudio components.",
226226
"preparingStorageForMetadataEnabledOrg": "Preparing storage for %s org on Standard Data Model with Metadata API enabled",
227-
"processingNotRequired": "Assessment not required for Standard Data Model Orgs with Metadata API enabled"
227+
"processingNotRequired": "Assessment not required for Standard Data Model Orgs with Metadata API enabled",
228+
"skippingTruncation": "Skipping Trunction as standard data model org"
228229
}

messages/migrate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,5 +323,6 @@
323323
"globalAutoNumberUnSupportedInOmnistudioPackage": "Feature not supported - Omni Global Auto Number is not supported in Omnistudio Foundation package orgs.",
324324
"orgUsecaseDetails": "The Org is on %s data model with %s and Omnistudio Metadata API %s",
325325
"preparingStorageForMetadataEnabledOrg": "Preparing storage for %s org on Standard Data Model with Metadata API enabled",
326-
"processingNotRequired": "Migration not required for Standard Data Model Orgs with Metadata API enabled"
326+
"processingNotRequired": "Migration not required for Standard Data Model Orgs with Metadata API enabled",
327+
"skippingTruncation": "Skipping Trunction as standard data model org"
327328
}

src/commands/omnistudio/migration/migrate.ts

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ export default class Migrate extends OmniStudioBaseCommand {
7676
};
7777

7878
// OmniStudio components that don't need migration logging when metadata API is enabled
79-
private readonly OMNISTUDIO_COMPONENTS_FOR_LOGGING = [
80-
Constants.Omniscript,
81-
Constants.IntegrationProcedure,
82-
Constants.Flexcard,
83-
Constants.DataMapper,
84-
];
79+
private readonly OMNISTUDIO_COMPONENTS_FOR_LOGGING = [Constants.CustomLabel, Constants.GlobalAutoNumber];
8580

8681
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8782
public async run(): Promise<any> {
@@ -370,10 +365,11 @@ export default class Migrate extends OmniStudioBaseCommand {
370365
// Truncate in reverse order (highest dependencies first) - this is correct for cleanup
371366
for (const cls of migrationObjects) {
372367
try {
373-
Logger.log(messages.getMessage('cleaningComponent', [cls.getName()]));
374-
debugTimer.lap('Cleaning: ' + cls.getName());
368+
const componentName = cls.getName();
369+
370+
this.logTruncationStart(componentName, debugTimer);
375371
await cls.truncate();
376-
Logger.log(messages.getMessage('cleaningDone', [cls.getName()]));
372+
this.logTruncationComplete(componentName);
377373
} catch (ex: any) {
378374
objectMigrationResults.push({
379375
name: cls.getName(),
@@ -434,7 +430,7 @@ export default class Migrate extends OmniStudioBaseCommand {
434430
* Log the start of component migration and track timing
435431
*/
436432
private logMigrationStart(componentName: string, debugTimer: DebugTimer): void {
437-
const shouldSkipLogging = this.shouldSkipMigrationLogging(componentName);
433+
const shouldSkipLogging = this.shouldSkipLogging(componentName);
438434

439435
if (!shouldSkipLogging) {
440436
Logger.log(messages.getMessage('migratingComponent', [componentName]));
@@ -446,7 +442,7 @@ export default class Migrate extends OmniStudioBaseCommand {
446442
* Log the completion or failure of component migration
447443
*/
448444
private logMigrationComplete(componentName: string, results: MigrationResult[]): void {
449-
const shouldSkipLogging = this.shouldSkipMigrationLogging(componentName);
445+
const shouldSkipLogging = this.shouldSkipLogging(componentName);
450446

451447
if (!shouldSkipLogging) {
452448
if (results.some((result) => result?.errors?.length > 0) && !isStandardDataModelWithMetadataAPIEnabled()) {
@@ -461,17 +457,49 @@ export default class Migrate extends OmniStudioBaseCommand {
461457
* Check if migration logging should be skipped for a component
462458
* Returns true if Metadata API is enabled and the component doesn't need migration
463459
*/
464-
private shouldSkipMigrationLogging(componentName: string): boolean {
460+
private shouldSkipTruncationLogging(componentName: string): boolean {
461+
if (isStandardDataModel()) {
462+
return true;
463+
}
464+
465+
return this.shouldSkipLogging(componentName);
466+
}
467+
468+
/**
469+
* Check if migration logging should be skipped for a component
470+
* Returns true if Metadata API is enabled and the component doesn't need migration
471+
*/
472+
private shouldSkipLogging(componentName: string): boolean {
465473
if (!isStandardDataModelWithMetadataAPIEnabled()) {
466474
return false;
467475
}
468476

469477
// Skip logging for OmniStudio components that don't need migration when metadata API is enabled
470-
return this.OMNISTUDIO_COMPONENTS_FOR_LOGGING.some((component) =>
478+
return !this.OMNISTUDIO_COMPONENTS_FOR_LOGGING.some((component) =>
471479
componentName.toLowerCase().includes(component.toLowerCase())
472480
);
473481
}
474482

483+
/**
484+
* Log the start of component truncation and track timing
485+
*/
486+
private logTruncationStart(componentName: string, debugTimer: DebugTimer): void {
487+
const shouldSkipLogging = this.shouldSkipTruncationLogging(componentName);
488+
if (!shouldSkipLogging) {
489+
Logger.log(messages.getMessage('cleaningComponent', [componentName]));
490+
debugTimer.lap('Cleaning: ' + componentName);
491+
}
492+
}
493+
/**
494+
* Log the completion of component truncation
495+
*/
496+
private logTruncationComplete(componentName: string): void {
497+
const shouldSkipLogging = this.shouldSkipTruncationLogging(componentName);
498+
499+
if (!shouldSkipLogging) {
500+
Logger.log(messages.getMessage('cleaningDone', [componentName]));
501+
}
502+
}
475503
/**
476504
* Get migration objects in the correct dependency order:
477505
* 1. Data Mappers (lowest dependencies)

src/migration/dataraptor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
5858

5959
async truncate(): Promise<void> {
6060
if (this.IS_STANDARD_DATA_MODEL) {
61+
Logger.logVerbose(this.messages.getMessage('skippingTruncation'));
6162
return;
6263
}
6364
await super.truncate(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME);
@@ -295,6 +296,9 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
295296
public async assess(): Promise<DataRaptorAssessmentInfo[]> {
296297
try {
297298
if (isStandardDataModelWithMetadataAPIEnabled()) {
299+
Logger.log(
300+
this.messages.getMessage('skippingAssessmentForStandardOrgWithMetadataAPIEnabled', [Constants.DataMapper])
301+
);
298302
return [];
299303
}
300304
DebugTimer.getInstance().lap('Query data raptors');

src/migration/flexcard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
6666
// Perform Delete of OmniUiCard Records to start migration from scratch
6767
async truncate(): Promise<void> {
6868
if (this.IS_STANDARD_DATA_MODEL) {
69+
Logger.logVerbose(this.messages.getMessage('skippingTruncation'));
6970
return;
7071
}
7172
const objectName = CardMigrationTool.OMNIUICARD_NAME;
@@ -450,15 +451,15 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
450451
}
451452

452453
private handleAssessmentForStdDataModelOrgsWithMetadataAPIEnabled(flexCards: AnyJson[]): FlexCardAssessmentInfo[] {
453-
Logger.log(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Flexcard]));
454+
Logger.logVerbose(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Flexcard]));
454455
let storage: MigrationStorage = StorageUtil.getOmnistudioAssessmentStorage();
455456
this.prepareStorageForRelatedObjectsWhenMetadataAPIEnabled(storage, flexCards);
456457
StorageUtil.printAssessmentStorage();
457458
return [];
458459
}
459460

460461
private handleMigrationForStdDataModelOrgsWithMetadataAPIEnabled(flexcards: AnyJson[]): MigrationResult[] {
461-
Logger.log(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Flexcard]));
462+
Logger.logVerbose(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Flexcard]));
462463
let storage: MigrationStorage = StorageUtil.getOmnistudioMigrationStorage();
463464
this.prepareStorageForRelatedObjectsWhenMetadataAPIEnabled(storage, flexcards);
464465
StorageUtil.printAssessmentStorage();

src/migration/omniscript.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
122122
async truncate(): Promise<void> {
123123
// Truncation is needed when we migrate from custom to standard data model, when on custom data model, no truncation is required
124124
if (this.IS_STANDARD_DATA_MODEL) {
125+
Logger.logVerbose(this.messages.getMessage('skippingTruncation'));
125126
return;
126127
}
127128

@@ -1415,7 +1416,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
14151416
return result;
14161417
}
14171418

1418-
Logger.log(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Omniscript]));
1419+
Logger.logVerbose(this.messages.getMessage('preparingStorageForMetadataEnabledOrg', [Constants.Omniscript]));
14191420
let storage: MigrationStorage = StorageUtil.getOmnistudioMigrationStorage();
14201421
Logger.logVerbose(this.messages.getMessage('updatingStorageForOmniscipt', ['Migration']));
14211422

0 commit comments

Comments
 (0)