Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fileignoreconfig:
- filename: package-lock.json
checksum: ff392396cc7545f985afdf0282d387b538371011e5cd5feed4424dfc7d368376
version: ""
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion packages/contentstack-export/src/commands/cm/stacks/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export default class ExportCommand extends Command {
'csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>',
'csdx cm:stacks:export --module <single module name>',
'csdx cm:stacks:export --branch [optional] branch name',
'csdx cm:stacks:export --skip-publish-details',
];

static usage: string =
'cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]';
'cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets] [--skip-publish-details]';

static flags: FlagInput = {
config: flags.string({
Expand Down Expand Up @@ -106,6 +107,14 @@ export default class ExportCommand extends Command {
description: '[optional] Query object (inline JSON or file path) to filter module exports.',
hidden: true,
}),
'skip-publish-details': flags.boolean({
description: '[optional] Skip publish details when exporting entries, assets, and variants.',
default: false,
}),
'latest-publish-details': flags.boolean({
description: '[optional] Only include publish details for the latest version of entries.',
default: false,
}),
};

static aliases: string[] = ['cm:export'];
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export/src/export/modules/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class ExportAssets extends BaseClass {

const queryParam = {
...this.commonQueryParam,
include_publish_details: true,
include_publish_details: this.assetConfig.includePublishDetails !== false,
except: { BASE: this.assetConfig.invalidKeys },
};
this.applyQueryFilters(queryParam, 'assets');
Expand Down Expand Up @@ -203,7 +203,7 @@ export default class ExportAssets extends BaseClass {

const queryParam = {
...this.commonQueryParam,
include_publish_details: true,
include_publish_details: this.assetConfig.includePublishDetails !== false,
except: { BASE: this.assetConfig.invalidKeys },
};

Expand Down
33 changes: 31 additions & 2 deletions packages/contentstack-export/src/export/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default class EntriesExport extends BaseClass {
chunkFileSize?: number;
batchLimit?: number;
exportVersions: boolean;
includePublishDetails?: boolean;
latestPublishDetails?: boolean;
};
private variantEntries!: any;
private entriesDirPath: string;
Expand Down Expand Up @@ -85,7 +87,22 @@ export default class EntriesExport extends BaseClass {
log.debug(`Found project with ID: ${project_id}, enabling variant entry export`, this.exportConfig.context);
}

this.variantEntries = new Export.VariantEntries(Object.assign(this.exportConfig, { project_id }));
// Ensure variant entry config respects publish details flag
const variantConfig = {
...this.exportConfig,
project_id,
modules: {
...this.exportConfig.modules,
variantEntry: {
...this.exportConfig.modules.variantEntry,
query: {
...this.exportConfig.modules.variantEntry.query,
include_publish_details: this.entriesConfig.includePublishDetails !== false
}
}
}
};
this.variantEntries = new Export.VariantEntries(variantConfig);
} catch (error) {
handleAndLogError(error, { ...this.exportConfig.context });
}
Expand Down Expand Up @@ -158,7 +175,7 @@ export default class EntriesExport extends BaseClass {
skip: options.skip,
limit: this.entriesConfig.limit,
include_count: true,
include_publish_details: true,
include_publish_details: this.entriesConfig.includePublishDetails !== false,
query: {
locale: options.locale,
},
Expand Down Expand Up @@ -208,6 +225,18 @@ export default class EntriesExport extends BaseClass {
log.debug('Initialized FsUtility for writing entries', this.exportConfig.context);
}

// Filter publish details if latestPublishDetails is enabled
if (this.entriesConfig.latestPublishDetails && this.entriesConfig.includePublishDetails !== false) {
entriesSearchResponse.items = entriesSearchResponse.items.map(entry => {
if (entry.publish_details) {
entry.publish_details = entry.publish_details.filter(
(detail: any) => detail.version === entry._version
);
}
return entry;
});
}

log.debug(`Writing ${entriesSearchResponse.items.length} entries to file`, this.exportConfig.context);
this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true });

Expand Down
3 changes: 3 additions & 0 deletions packages/contentstack-export/src/types/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default interface DefaultConfig {
displayExecutionTime: boolean;
enableDownloadStatus: boolean;
includeVersionedAssets: boolean;
includePublishDetails?: boolean;
dependencies?: Modules[];
};
content_types: {
Expand Down Expand Up @@ -123,6 +124,8 @@ export default interface DefaultConfig {
limit: number;
dependencies?: Modules[];
exportVersions: boolean;
includePublishDetails?: boolean;
latestPublishDetails?: boolean;
};
personalize: {
dirName: string;
Expand Down
13 changes: 13 additions & 0 deletions packages/contentstack-export/src/utils/export-config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
}
}

// Handle publish details flags
if (exportCmdFlags['skip-publish-details']) {
log.debug('Skipping publish details in export');
config.modules.entries.includePublishDetails = false;
config.modules.assets.includePublishDetails = false;
config.modules.variantEntry.query.include_publish_details = false;
}

if (exportCmdFlags['latest-publish-details']) {
log.debug('Only including latest publish details in export');
config.modules.entries.latestPublishDetails = true;
}

// Add authentication details to config for context tracking
config.authenticationMethod = authenticationMethod;
log.debug('Export configuration setup completed', { ...config });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Exp
content_type_uid,
entry_uid: entry.uid,
locale,
include_publish_details: this.config.modules.variantEntry.query.include_publish_details !== false,
});

if (existsSync(variantEntryBasePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface DefaultConfig {
limit: number;
dependencies?: Modules[];
exportVersions: boolean;
latestPublishDetails?: boolean;
};
variantEntry: {
dirName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type VariantsOption = {
content_type_uid: string;
include_variant?: boolean;
include_count?: boolean;
include_publish_details?: boolean;
include_publish_details: boolean;
callback?: (value: Record<string, any>[]) => void;
} & AnyProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
limit = variantConfig.query.limit || 100,
include_variant = variantConfig.query.include_variant || true,
include_count = variantConfig.query.include_count || true,
include_publish_details = variantConfig.query.include_publish_details || true,
include_publish_details = variantConfig.query.include_publish_details !== false,
} = options;

log.debug(`Fetching variant entries for content type: ${content_type_uid}, entry: ${entry_uid}, locale: ${locale}`, this.exportConfig?.context );
Expand Down Expand Up @@ -159,6 +159,19 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement

if (response?.entries?.length) {
log.debug(`Received ${response.entries?.length} variant entries out of total ${response.count}`, this.exportConfig?.context );

// Filter publish details if latestPublishDetails is enabled
const variantConfig = (this.config as ExportConfig).modules.variantEntry;
if (variantConfig.query.include_publish_details && ((this.config as any).modules.entries.latestPublishDetails)) {
response.entries = response.entries.map(entry => {
if (entry.publish_details) {
entry.publish_details = entry.publish_details.filter(
(detail: any) => detail.version === entry._version
);
}
return entry;
});
}
}

if (callback) {
Expand Down
Loading