@@ -122,16 +122,16 @@ async function writeFiles(
122122 try {
123123 const indexPath = path . join ( entryPath , 'index.json' ) ;
124124 const localePath = path . join ( entryPath , `${ locale } .json` ) ;
125-
125+
126126 try {
127127 await fs . promises . access ( entryPath ) ;
128128 } catch {
129129 await fs . promises . mkdir ( entryPath , { recursive : true } ) ;
130130 }
131-
131+
132132 await fs . promises . writeFile ( indexPath , JSON . stringify ( fileMeta ) ) ;
133133 await fs . promises . writeFile ( localePath , JSON . stringify ( entryLocale ) ) ;
134- } catch ( error ) {
134+ } catch ( error ) {
135135 console . error ( 'Error writing files:' , error ) ;
136136 throw error ;
137137 }
@@ -456,8 +456,9 @@ function processFieldsRecursive(fields: any[], items: any, title: string, assetJ
456456 break ;
457457 }
458458 case 'boolean' : {
459- const value = items ?. [ field ?. uid ] ;
460- const uid = getLastKey ( field ?. contentstackFieldUid ) ;
459+ const aemFieldName = field ?. otherCmsField ? getLastKey ( field . otherCmsField , ' > ' ) : getLastKey ( field ?. uid ) ;
460+ const value = items ?. [ aemFieldName ] ;
461+ const uid = getLastKey ( field ?. contentstackFieldUid ) ;
461462 if ( typeof value === 'boolean' || ( typeof value === 'object' && value ?. [ ':type' ] ?. includes ( 'separator' ) ) ) {
462463 obj [ uid ] = typeof value === 'boolean' ? value : true ;
463464 }
@@ -482,19 +483,16 @@ function processFieldsRecursive(fields: any[], items: any, title: string, assetJ
482483 case 'reference' : {
483484 const fieldKey = getLastKey ( field ?. contentstackFieldUid ) ;
484485 const refCtUid = field ?. referenceTo ?. [ 0 ] || field ?. uid ;
485-
486486 for ( const [ key , val ] of Object . entries ( items ) as [ string , Record < string , unknown > ] [ ] ) {
487487 if ( ! val ?. configured || ( val [ ':type' ] as string ) === 'nt:folder' ) {
488488 continue ;
489489 }
490-
491490 if (
492491 ( val [ ':type' ] as string ) ?. includes ( 'experiencefragment' ) &&
493492 typeof val ?. localizedFragmentVariationPath === 'string'
494493 ) {
495494 const pathMatchesField = val . localizedFragmentVariationPath . includes ( `/${ field ?. uid } ` ) ;
496495 const pathMatchesRefType = val . localizedFragmentVariationPath . includes ( `/${ refCtUid } ` ) ;
497-
498496 if ( pathMatchesField || pathMatchesRefType ) {
499497 obj [ fieldKey ] = [ {
500498 "uid" : val ?. id ,
@@ -572,14 +570,14 @@ const createEntry = async ({
572570 const assetJson = path . join ( assetsSave , ASSETS_SCHEMA_FILE ) ;
573571 const exists = await isAssetJsonCreated ( assetJson ) ;
574572 let assetJsonData : Record < string , AssetJSON > = { } ;
575-
573+
576574 if ( exists ) {
577575 const assetData = await fs . promises . readFile ( assetJson , 'utf-8' ) ;
578576 if ( typeof assetData === 'string' ) {
579577 assetJsonData = JSON . parse ( assetData ) ;
580578 }
581579 }
582-
580+
583581 const entriesDir = path . resolve ( packagePath ?? '' ) ;
584582 const damPath = path . join ( entriesDir , AEM_DAM_DIR ) ;
585583 const entriesData : Record < string , Record < string , any [ ] > > = { } ;
@@ -606,7 +604,7 @@ const createEntry = async ({
606604 const data = containerCreator ( contentType ?. fieldMapping , items , title , assetJsonData ) ;
607605 data . uid = uid ;
608606 data . publish_details = [ ] ;
609-
607+
610608 if ( contentType ?. contentstackUid && data && mappedLocale ) {
611609 const message = getLogMessage (
612610 srcFunc ,
@@ -635,7 +633,7 @@ const createEntry = async ({
635633 if ( key . endsWith ( '._content_type_uid' ) && typeof value === 'string' ) {
636634 const uidField = key . replace ( '._content_type_uid' , '' ) ;
637635 const refs : string [ ] = entryMapping ?. [ value ] ;
638-
636+
639637 if ( refs ?. length ) {
640638 _ . set ( entry , `${ uidField } .uid` , refs [ 0 ] ) ;
641639 } else {
@@ -647,7 +645,7 @@ const createEntry = async ({
647645 const entriesObject : Record < string , any > = { } ;
648646 for ( const entry of entries ) {
649647 entriesObject [ entry . uid ] = entry ;
650- }
648+ }
651649 const fileMeta = { '1' : `${ locale } .json` } ;
652650 const entryPath = path . join (
653651 process . cwd ( ) ,
0 commit comments