99 ExpSiteComponent ,
1010 ExpSiteComponentAttributes ,
1111 MigrationStorage ,
12+ OmniScriptStandardKey ,
1213 OmniScriptStorage ,
1314 ExpSitePageJson ,
1415 Storage ,
@@ -19,19 +20,22 @@ import { FileDiffUtil } from '../../utils/lwcparser/fileutils/FileDiffUtil';
1920import { ExperienceSiteAssessmentInfo , ExperienceSiteAssessmentPageInfo } from '../../utils' ;
2021import { StorageUtil } from '../../utils/storageUtil' ;
2122import { createProgressBar } from '../base' ;
23+ import { isStandardDataModel } from '../../utils/dataModelService' ;
2224import { BaseRelatedObjectMigration } from './BaseRealtedObjectMigration' ;
2325
2426Messages . importMessagesDirectory ( __dirname ) ;
2527
2628const TARGET_COMPONENT_NAME_OS = 'runtime_omnistudio:omniscript' ;
2729const TARGET_COMPONENT_NAME_FC = 'runtime_omnistudio:flexcard' ;
30+ const TARGET_COMPONENT_NAME_OS_EXP = 'runtime_omnistudio:omniscriptExperienceCloud' ;
2831const FLEXCARD_PREFIX = 'cf' ;
2932
3033export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
3134 private EXPERIENCE_SITES_PATH : string ;
3235 private MIGRATE = 'Migrate' ;
3336 private ASSESS = 'Assess' ;
3437 private messages : Messages ;
38+ private IS_STANDARD_DATA_MODEL : boolean = isStandardDataModel ( ) ;
3539
3640 public constructor ( projectPath : string , namespace : string , org : Org , messages : Messages ) {
3741 super ( projectPath , namespace , org ) ;
@@ -235,6 +239,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
235239 return ;
236240 }
237241
242+ // Check for legacy wrapper component
238243 if ( component . componentName === lookupComponentName ) {
239244 Logger . logVerbose ( this . messages . getMessage ( 'omniWrapperFound' ) ) ;
240245 experienceSiteAssessmentInfo . hasOmnistudioContent = true ;
@@ -250,6 +255,18 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
250255 return ;
251256 }
252257
258+ if ( this . IS_STANDARD_DATA_MODEL ) {
259+ // Check for new LWC components that need reference updates
260+ if ( this . isOmnistudioComponent ( component . componentName ) ) {
261+ Logger . logVerbose ( `Found Omnistudio component: ${ component . componentName } ` ) ;
262+ experienceSiteAssessmentInfo . hasOmnistudioContent = true ;
263+
264+ this . updateOmnistudioComponentReferences ( component , experienceSiteAssessmentInfo , storage , type ) ;
265+
266+ return ;
267+ }
268+ }
269+
253270 const regionsInsideComponent : ExpSiteRegion [ ] = component . regions ;
254271
255272 if ( Array . isArray ( regionsInsideComponent ) ) {
@@ -360,6 +377,106 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
360377 return targetData === undefined || targetData . migrationSuccess === false || targetData . isDuplicate === true ;
361378 }
362379
380+ /**
381+ * Check if component is an Omnistudio LWC component
382+ */
383+ private isOmnistudioComponent ( componentName : string ) : boolean {
384+ return (
385+ componentName === TARGET_COMPONENT_NAME_OS ||
386+ componentName === TARGET_COMPONENT_NAME_FC ||
387+ componentName === TARGET_COMPONENT_NAME_OS_EXP
388+ ) ;
389+ }
390+
391+ /**
392+ * Update references in Omnistudio LWC components
393+ */
394+ private updateOmnistudioComponentReferences (
395+ component : ExpSiteComponent ,
396+ experienceSiteAssessmentInfo : ExperienceSiteAssessmentPageInfo ,
397+ storage : MigrationStorage ,
398+ type : string
399+ ) : void {
400+ if ( component === undefined || component . componentAttributes === undefined ) {
401+ return ;
402+ }
403+ const componentName = component . componentName ;
404+ const attributes = component . componentAttributes ;
405+
406+ if ( componentName === TARGET_COMPONENT_NAME_OS || componentName === TARGET_COMPONENT_NAME_OS_EXP ) {
407+ this . updateOmniScriptComponentReferences ( attributes , experienceSiteAssessmentInfo , storage , type ) ;
408+ } else if ( componentName === TARGET_COMPONENT_NAME_FC ) {
409+ this . updateFlexCardComponentReferences ( attributes , experienceSiteAssessmentInfo , storage , type ) ;
410+ }
411+ }
412+
413+ /**
414+ * Update OmniScript component references (for runtime_omnistudio:omniscript and runtime_omnistudio:omniscriptExperienceCloud)
415+ */
416+ private updateOmniScriptComponentReferences (
417+ attributes : ExpSiteComponentAttributes ,
418+ experienceSiteAssessmentInfo : ExperienceSiteAssessmentPageInfo ,
419+ storage : MigrationStorage ,
420+ type : string
421+ ) : void {
422+ const currentType = attributes [ 'type' ] as string ;
423+ const currentSubType = attributes [ 'subType' ] as string ;
424+ const currentLanguage = attributes [ 'language' ] as string ;
425+
426+ if ( ! currentType || ! currentSubType || ! currentLanguage ) {
427+ return ;
428+ }
429+
430+ // Create the OmniScriptStandardKey object for lookup in osStandardStorage
431+ const lookupKey : OmniScriptStandardKey = {
432+ type : currentType ,
433+ subtype : currentSubType ,
434+ language : currentLanguage ,
435+ } ;
436+ // Look up in osStandardStorage using the object key
437+ const targetDataFromStorage : OmniScriptStorage = StorageUtil . getStandardOmniScript ( storage , lookupKey ) ;
438+
439+ if ( this . shouldAddWarning ( targetDataFromStorage ) ) {
440+ const originalKey = `${ currentType } _${ currentSubType } _${ currentLanguage } ` ;
441+ const warningMsg : string = this . getWarningMessage ( originalKey , targetDataFromStorage ) ;
442+ experienceSiteAssessmentInfo . warnings . push ( warningMsg ) ;
443+ experienceSiteAssessmentInfo . status = type === this . ASSESS ? 'Needs Manual Intervention' : 'Skipped' ;
444+ } else {
445+ // Update the attributes with the new values from storage
446+ attributes [ 'type' ] = targetDataFromStorage . type ;
447+ attributes [ 'subType' ] = targetDataFromStorage . subtype ;
448+ attributes [ 'language' ] = targetDataFromStorage . language ;
449+ }
450+ }
451+
452+ /**
453+ * Update FlexCard component references (for runtime_omnistudio:flexcard)
454+ */
455+ private updateFlexCardComponentReferences (
456+ attributes : ExpSiteComponentAttributes ,
457+ experienceSiteAssessmentInfo : ExperienceSiteAssessmentPageInfo ,
458+ storage : MigrationStorage ,
459+ type : string
460+ ) : void {
461+ const currentFlexCardName = attributes [ 'flexcardName' ] as string ;
462+
463+ if ( ! currentFlexCardName ) {
464+ return ;
465+ }
466+
467+ // Look up in storage to see if this FlexCard was migrated
468+ const targetDataFromStorageFC : FlexcardStorage = storage . fcStorage . get ( currentFlexCardName . toLowerCase ( ) ) ;
469+
470+ if ( this . shouldAddWarning ( targetDataFromStorageFC ) ) {
471+ const warningMsg : string = this . getWarningMessage ( currentFlexCardName , targetDataFromStorageFC ) ;
472+ experienceSiteAssessmentInfo . warnings . push ( warningMsg ) ;
473+ experienceSiteAssessmentInfo . status = type === this . ASSESS ? 'Needs Manual Intervention' : 'Skipped' ;
474+ } else {
475+ // Update the flexcardName with the new value from storage
476+ attributes [ 'flexcardName' ] = targetDataFromStorageFC . name ;
477+ }
478+ }
479+
363480 private getWarningMessage ( oldTypeSubtypeLanguage : string , targetDataFromStorage : Storage ) : string {
364481 if ( targetDataFromStorage === undefined ) {
365482 // Add log verbose
0 commit comments