1+ /*
2+ * Copyright (c) 2025, salesforce.com, inc.
3+ * All rights reserved.
4+ * Licensed under the BSD 3-Clause license.
5+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+ */
7+
18import * as fs from 'fs' ;
29import * as path from 'path' ;
310import * as shell from 'shelljs' ;
@@ -13,28 +20,83 @@ import { transformFlexipageBundle } from '../../utils/flexipage/flexiPageTransfo
1320import { Flexipage } from '../interfaces' ;
1421import { BaseRelatedObjectMigration } from './BaseRealtedObjectMigration' ;
1522
23+ /**
24+ * FlexipageMigration handles the migration and assessment of FlexiPage components
25+ * in Salesforce OmniStudio migration operations.
26+ *
27+ * This class provides functionality to:
28+ * - Assess FlexiPage components for migration readiness
29+ * - Migrate FlexiPage components to the target format
30+ * - Process FlexiPage XML files and transform their content
31+ * - Generate assessment reports with detailed status information
32+ * - Handle errors and provide detailed error reporting
33+ *
34+ * The migration process involves:
35+ * - Retrieving FlexiPage metadata from the Salesforce org
36+ * - Parsing and analyzing FlexiPage XML files
37+ * - Transforming component structures and properties
38+ * - Generating diff information for visual comparison
39+ * - Writing transformed files back to the project structure
40+ */
1641export class FlexipageMigration extends BaseRelatedObjectMigration {
42+ /** Messages instance for internationalization */
1743 private messages : Messages ;
1844
45+ /**
46+ * Creates a new FlexipageMigration instance.
47+ *
48+ * @param projectPath - The path to the Salesforce project
49+ * @param namespace - The namespace for the migration operation
50+ * @param org - The Salesforce org connection
51+ * @param messages - Messages instance for internationalization
52+ */
1953 public constructor ( projectPath : string , namespace : string , org : Org , messages : Messages ) {
2054 super ( projectPath , namespace , org ) ;
2155 this . messages = messages ;
2256 }
2357
58+ /**
59+ * Returns the object type constant for FlexiPage components.
60+ *
61+ * @returns The FlexiPage constant string
62+ */
2463 public processObjectType ( ) : string {
2564 return Constants . FlexiPage ;
2665 }
2766
67+ /**
68+ * Performs assessment of FlexiPage components to determine migration readiness.
69+ *
70+ * @returns Array of FlexiPage assessment information
71+ */
2872 public assess ( ) : FlexiPageAssessmentInfo [ ] {
2973 Logger . info ( this . messages . getMessage ( 'assessingFlexiPages' ) ) ;
3074 return this . process ( 'assess' ) ;
3175 }
3276
77+ /**
78+ * Performs migration of FlexiPage components to the target format.
79+ *
80+ * @returns Array of FlexiPage assessment information after migration
81+ */
3382 public migrate ( ) : FlexiPageAssessmentInfo [ ] {
3483 Logger . info ( this . messages . getMessage ( 'migratingFlexiPages' ) ) ;
3584 return this . process ( 'migrate' ) ;
3685 }
3786
87+ /**
88+ * Processes FlexiPage files in either assessment or migration mode.
89+ *
90+ * This method:
91+ * - Retrieves FlexiPage metadata from the Salesforce org
92+ * - Reads and processes each FlexiPage XML file
93+ * - Transforms the content based on the specified mode
94+ * - Handles errors and provides detailed logging
95+ * - Generates progress indicators for long-running operations
96+ *
97+ * @param mode - The processing mode: 'assess' for analysis only, 'migrate' for actual transformation
98+ * @returns Array of FlexiPage assessment information
99+ */
38100 private process ( mode : 'assess' | 'migrate' ) : FlexiPageAssessmentInfo [ ] {
39101 Logger . info ( this . messages . getMessage ( 'retrievingFlexiPages' ) ) ;
40102 shell . cd ( this . projectPath ) ;
@@ -76,6 +138,22 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
76138 return flexPageAssessmentInfos ;
77139 }
78140
141+ /**
142+ * Processes a single FlexiPage file for assessment or migration.
143+ *
144+ * This method:
145+ * - Reads the FlexiPage XML file content
146+ * - Parses the XML structure into a JavaScript object
147+ * - Transforms the FlexiPage bundle using the flexipage transformer
148+ * - Generates diff information for visual comparison
149+ * - Writes transformed content back to file in migration mode
150+ * - Handles errors and provides detailed error information
151+ *
152+ * @param fileName - The name of the FlexiPage file
153+ * @param filePath - The full path to the FlexiPage file
154+ * @param mode - The processing mode: 'assess' or 'migrate'
155+ * @returns FlexiPage assessment information with status and error details
156+ */
79157 private processFlexiPage ( fileName : string , filePath : string , mode : 'assess' | 'migrate' ) : FlexiPageAssessmentInfo {
80158 Logger . logVerbose ( this . messages . getMessage ( 'startingFlexiPageProcessing' , [ fileName ] ) ) ;
81159 const fileContent = fs . readFileSync ( filePath , 'utf8' ) ;
0 commit comments