@@ -57,6 +57,8 @@ export default class EntriesImport extends BaseClass {
5757 public rteCTs : any ;
5858 public rteCTsWithRef : any ;
5959 public entriesForVariant : Array < { content_type : string ; locale : string ; entry_uid : string } > = [ ] ;
60+ private composableStudioSuccessPath : string ;
61+ private composableStudioExportPath : string ;
6062
6163 constructor ( { importConfig, stackAPIClient } : ModuleClassParams ) {
6264 super ( { importConfig, stackAPIClient } ) ;
@@ -92,6 +94,26 @@ export default class EntriesImport extends BaseClass {
9294 sanitizePath ( importConfig . modules . locales . dirName ) ,
9395 sanitizePath ( importConfig . modules . locales . fileName ) ,
9496 ) ;
97+
98+ // Initialize composable studio paths if config exists
99+ if ( this . importConfig . modules [ 'composable-studio' ] ) {
100+ this . composableStudioSuccessPath = path . join (
101+ sanitizePath ( this . importConfig . data ) ,
102+ 'mapper' ,
103+ this . importConfig . modules [ 'composable-studio' ] . dirName ,
104+ this . importConfig . modules [ 'composable-studio' ] . fileName ,
105+ ) ;
106+
107+ this . composableStudioExportPath = path . join (
108+ sanitizePath ( this . importConfig . data ) ,
109+ this . importConfig . modules [ 'composable-studio' ] . dirName ,
110+ this . importConfig . modules [ 'composable-studio' ] . fileName ,
111+ ) ;
112+ } else {
113+ this . composableStudioSuccessPath = '' ;
114+ this . composableStudioExportPath = '' ;
115+ }
116+
95117 this . importConcurrency = this . entriesConfig . importConcurrency || importConfig . importConcurrency ;
96118 this . entriesUidMapper = { } ;
97119 this . modifiedCTs = [ ] ;
@@ -116,6 +138,40 @@ export default class EntriesImport extends BaseClass {
116138 return ;
117139 }
118140 log . debug ( `Found ${ this . cTs . length } content types for entry import` , this . importConfig . context ) ;
141+ // If success file doesn't exist but export file does, skip the composition entries
142+ // Only check if composable studio paths are configured
143+ if (
144+ this . composableStudioSuccessPath &&
145+ this . composableStudioExportPath &&
146+ ! fileHelper . fileExistsSync ( this . composableStudioSuccessPath ) &&
147+ fileHelper . fileExistsSync ( this . composableStudioExportPath )
148+ ) {
149+ const exportedProject = fileHelper . readFileSync ( this . composableStudioExportPath ) as {
150+ contentTypeUid : string ;
151+ } ;
152+
153+ if ( exportedProject ?. contentTypeUid ) {
154+ const originalCount = this . cTs . length ;
155+ this . cTs = this . cTs . filter ( ( ct : Record < string , unknown > ) => {
156+ const shouldSkip = ct . uid === exportedProject . contentTypeUid ;
157+ if ( shouldSkip ) {
158+ log . info (
159+ `Skipping entries for content type '${ ct . uid } ' as Composable Studio project was not created successfully` ,
160+ this . importConfig . context ,
161+ ) ;
162+ }
163+ return ! shouldSkip ;
164+ } ) ;
165+
166+ const skippedCount = originalCount - this . cTs . length ;
167+ if ( skippedCount > 0 ) {
168+ log . debug (
169+ `Filtered out ${ skippedCount } composition content type(s) from entry import` ,
170+ this . importConfig . context ,
171+ ) ;
172+ }
173+ }
174+ }
119175
120176 this . installedExtensions = (
121177 ( fsUtil . readFile ( this . marketplaceAppMapperPath ) as any ) || { extension_uid : { } }
@@ -124,10 +180,7 @@ export default class EntriesImport extends BaseClass {
124180
125181 this . assetUidMapper = ( fsUtil . readFile ( this . assetUidMapperPath ) as Record < string , any > ) || { } ;
126182 this . assetUrlMapper = ( fsUtil . readFile ( this . assetUrlMapperPath ) as Record < string , any > ) || { } ;
127- log . debug (
128- `Loaded asset mappings – UIDs: ${ Object . keys ( this . assetUidMapper ) . length } ` ,
129- this . importConfig . context ,
130- ) ;
183+ log . debug ( `Loaded asset mappings – UIDs: ${ Object . keys ( this . assetUidMapper ) . length } ` , this . importConfig . context ) ;
131184
132185 this . taxonomies = ( fsUtil . readFile ( this . taxonomiesPath ) || { } ) as Record < string , any > ;
133186 log . debug ( 'Loaded taxonomy data for entry processing.' , this . importConfig . context ) ;
0 commit comments