Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cs 40246 #961

Merged
merged 7 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/contentstack-export/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const config: DefaultConfig = {
// total no of entries fetched in each content type in a single call
limit: 100,
dependencies: ['locales', 'content-types'],
exportVersions: true,
exportVersions: false,
},
extensions: {
dirName: 'extensions',
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/src/export/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class EntriesExport extends BaseClass {
for (let entryRequestOption of entryRequestOptions) {
log(
this.exportConfig,
`Starting export of entries of contenttype - ${entryRequestOption.contentType} locale - ${entryRequestOption.locale}`,
`Starting export of entries of content type - ${entryRequestOption.contentType} locale - ${entryRequestOption.locale}`,
'info',
);
await this.getEntries(entryRequestOption);
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@contentstack/cli-command": "^1.2.11",
"@contentstack/cli-utilities": "^1.5.1",
"@contentstack/management": "~1.10.0",
"@contentstack/management": "~1.10.0",
"@oclif/config": "^1.18.3",
"@oclif/core": "^2.9.3",
"big-json": "^3.2.0",
Expand Down Expand Up @@ -96,4 +96,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
5 changes: 3 additions & 2 deletions packages/contentstack-import/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ const config: DefaultConfig = {
'content-types',
'webhooks',
'custom-roles',
'workflows'
'workflows',
'entries',
],
rateLimit: 5,
preserveStackVersion: false,
Expand All @@ -389,7 +390,7 @@ const config: DefaultConfig = {
developerHubBaseUrl: '',
marketplaceAppEncryptionKey: 'nF2ejRQcTv',
getEncryptionKeyMaxRetry: 3,
useNewModuleStructure: true
useNewModuleStructure: true,
// useBackedupDir: '',
// backupConcurrency: 10,
};
Expand Down
38 changes: 35 additions & 3 deletions packages/contentstack-import/src/import/modules/base-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export type ApiModuleType =
| 'update-labels'
| 'create-webhooks'
| 'create-workflows'
| 'create-custom-role';
| 'create-custom-role'
| 'create-entries'
| 'update-entries'
| 'publish-entries'
| 'delete-entries';

export type ApiOptions = {
uid?: string;
Expand Down Expand Up @@ -231,7 +235,7 @@ export default abstract class BaseClass {
apiOptions = apiOptions.serializeData(apiOptions);
}

const { uid, entity, reject, resolve, apiData, additionalInfo, includeParamOnCompletion } = apiOptions;
const { uid, entity, reject, resolve, apiData, additionalInfo = {}, includeParamOnCompletion } = apiOptions;

const onSuccess = (response: any) =>
resolve({
Expand Down Expand Up @@ -295,6 +299,9 @@ export default abstract class BaseClass {
case 'create-cts':
return this.stack.contentType().create(apiData).then(onSuccess).catch(onReject);
case 'update-cts':
if (additionalInfo.skip) {
return Promise.resolve(onSuccess(apiData));
}
return apiData.update().then(onSuccess).catch(onReject);
case 'update-gfs':
return apiData.update().then(onSuccess).catch(onReject);
Expand Down Expand Up @@ -337,7 +344,32 @@ export default abstract class BaseClass {
.create({ role: apiData as RoleData })
.then(onSuccess)
.catch(onReject);

case 'create-entries':
return this.stack
.contentType(additionalInfo.cTUid)
.entry()
.create({ entry: apiData }, { locale: additionalInfo.locale })
.then(onSuccess)
.catch(onReject);
case 'update-entries':
return apiData.update({ locale: additionalInfo.locale }).then(onSuccess).catch(onReject);
case 'publish-entries':
if (additionalInfo.skip) {
return Promise.resolve(onSuccess(apiData));
}
return this.stack
.contentType(additionalInfo.cTUid)
.entry(additionalInfo.entryUid)
.publish({ publishDetails: apiData, locale: additionalInfo.locale })
.then(onSuccess)
.catch(onReject);
case 'delete-entries':
return this.stack
.contentType(apiData.cTUid)
.entry(apiData.entryUid)
.delete({ locale: this.importConfig?.master_locale?.code })
.then(onSuccess)
.catch(onReject);
default:
return Promise.resolve();
}
Expand Down
Loading