Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Feb 19, 2024
1 parent dae2441 commit 1c99ea8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
23 changes: 7 additions & 16 deletions packages/contentstack-import/src/import/modules/base-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ export default abstract class BaseClass {
apiData: includeParamOnCompletion ? apiData : undefined,
});

if (
!apiData ||
(entity === 'publish-entries' && !apiData.entryUid) ||
(entity === 'update-extensions' && !apiData.uid)
) {
return Promise.resolve();
}
switch (entity) {
case 'create-assets-folder':
return this.stack
Expand Down Expand Up @@ -284,7 +291,6 @@ export default abstract class BaseClass {
.then(onSuccess)
.catch(onReject);
case 'update-extensions':
if (!apiData.uid) return Promise.resolve();
return this.stack
.extension(apiData.uid)
.fetch()
Expand All @@ -309,14 +315,8 @@ export default abstract class BaseClass {
case 'create-cts':
return this.stack.contentType().create(apiData).then(onSuccess).catch(onReject);
case 'update-cts':
if (!apiData) {
return Promise.resolve();
}
return apiData.update().then(onSuccess).catch(onReject);
case 'update-gfs':
if (!apiData) {
return Promise.resolve();
}
return apiData.update().then(onSuccess).catch(onReject);
case 'create-environments':
return this.stack
Expand Down Expand Up @@ -358,9 +358,6 @@ export default abstract class BaseClass {
.then(onSuccess)
.catch(onReject);
case 'create-entries':
if (!apiData) {
return Promise.resolve();
}
if (additionalInfo[apiData?.uid]?.isLocalized) {
return apiData.update({ locale: additionalInfo.locale }).then(onSuccess).catch(onReject);
}
Expand All @@ -371,14 +368,8 @@ export default abstract class BaseClass {
.then(onSuccess)
.catch(onReject);
case 'update-entries':
if (!apiData) {
return Promise.resolve();
}
return apiData.update({ locale: additionalInfo.locale }).then(onSuccess).catch(onReject);
case 'publish-entries':
if (!apiData || !apiData.entryUid) {
return Promise.resolve();
}
return this.stack
.contentType(additionalInfo.cTUid)
.entry(apiData.entryUid)
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-import/src/import/modules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from 'node:path';

import { log, formatError, fsUtil, fileHelper } from '../../utils';
import BaseClass, { ApiOptions } from './base-class';
import { ModuleClassParams, Extensions, extensionType } from '../../types';
import { ModuleClassParams, Extensions, ExtensionType } from '../../types';

export default class ImportExtensions extends BaseClass {
private mapperDirPath: string;
Expand Down Expand Up @@ -222,10 +222,10 @@ export default class ImportExtensions extends BaseClass {

getContentTypesInScope() {
const extension = values(this.extensions);
extension.forEach((ext: extensionType) => {
extension.forEach((ext: ExtensionType) => {
let ct: any = ext?.scope?.content_types || [];
if ((ct.length === 1 && ct[0] !== '$all') || ct?.length > 1) {
log(this.importConfig, `Removing the Content-types ${ct.join(',')} from Extension ${ext.title}`, 'success');
log(this.importConfig, `Removing the Content-types ${ct.join(',')} from Extension ${ext.title}`, 'info');
const { uid, scope } = ext;
this.extensionObject.push({ uid, scope });
delete ext.scope;
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export { default as ImportConfig } from './import-config';
export * from './entries'
export * from './marketplace-app'

export type extensionType = {
export type ExtensionType = {
uid: string,
scope: Record<string,unknown>,
title: string
Expand Down

0 comments on commit 1c99ea8

Please sign in to comment.