@@ -26,6 +26,7 @@ export default class ExportMarketplaceApps {
26
26
public appSdk : ContentstackMarketplaceClient ;
27
27
public exportConfig : ExportConfig ;
28
28
public command : Command ;
29
+ public query : Record < string , any > ;
29
30
30
31
constructor ( { exportConfig } : Omit < ModuleClassParams , 'stackAPIClient' | 'moduleName' > ) {
31
32
this . exportConfig = exportConfig ;
@@ -51,6 +52,7 @@ export default class ExportMarketplaceApps {
51
52
await fsUtil . makeDirectory ( this . marketplaceAppPath ) ;
52
53
this . developerHubBaseUrl = this . exportConfig . developerHubBaseUrl || ( await getDeveloperHubUrl ( this . exportConfig ) ) ;
53
54
this . exportConfig . org_uid = await getOrgUid ( this . exportConfig ) ;
55
+ this . query = { target_uids : this . exportConfig . source_stack } ;
54
56
55
57
// NOTE init marketplace app sdk
56
58
const host = this . developerHubBaseUrl . split ( '://' ) . pop ( ) ;
@@ -64,6 +66,16 @@ export default class ExportMarketplaceApps {
64
66
* library if it is available.
65
67
*/
66
68
async exportApps ( ) : Promise < any > {
69
+ // currently support only app_uids or installation_uids
70
+ const externalQuery = this . exportConfig . query ?. modules [ 'marketplace-apps' ] ;
71
+ if ( externalQuery ) {
72
+ if ( externalQuery . app_uid ?. $in ?. length > 0 ) {
73
+ this . query . app_uids = externalQuery . app_uid . $in . join ( ',' ) ;
74
+ }
75
+ if ( externalQuery . installation_uid ?. $in ?. length > 0 ) {
76
+ this . query . installation_uids = externalQuery . installation_uid ?. $in ?. join ( ',' ) ;
77
+ }
78
+ }
67
79
await this . getStackSpecificApps ( ) ;
68
80
await this . getAppManifestAndAppConfig ( ) ;
69
81
@@ -186,7 +198,7 @@ export default class ExportMarketplaceApps {
186
198
const collection = await this . appSdk
187
199
. marketplace ( this . exportConfig . org_uid )
188
200
. installation ( )
189
- . fetchAll ( { target_uids : this . exportConfig . source_stack , skip } )
201
+ . fetchAll ( { ... this . query , skip } )
190
202
. catch ( ( error ) => {
191
203
log ( this . exportConfig , `Failed to export marketplace-apps ${ formatError ( error ) } ` , 'error' ) ;
192
204
log ( this . exportConfig , error , 'error' ) ;
0 commit comments