@contentstack/cli-cm-import 2.0.0-beta.5 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import/2.0.0-beta.5 linux-x64 node-v22.22.0
50
+ @contentstack/cli-cm-import/2.0.0-beta.7 linux-x64 node-v22.22.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -55,8 +55,8 @@ class ImportCommand extends cli_command_1.Command {
55
55
  logAndPrintErrorDetails(error, importConfig) {
56
56
  var _a;
57
57
  cli_utilities_1.cliux.print('\n');
58
- const logPath = (0, cli_utilities_1.getLogPath)();
59
- const logMsg = `The log has been stored at '${logPath}'`;
58
+ const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
59
+ const logMsg = `The log has been stored at '${sessionLogPath}'`;
60
60
  const backupDir = importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir;
61
61
  const backupDirMsg = backupDir
62
62
  ? `The backup content has been stored at '${backupDir}'`
@@ -73,8 +73,8 @@ class ImportCommand extends cli_command_1.Command {
73
73
  logSuccessAndBackupMessages(backupDir, importConfig) {
74
74
  var _a;
75
75
  cli_utilities_1.cliux.print('\n');
76
- const logPath = (0, cli_utilities_1.getLogPath)();
77
- const logMsg = `The log has been stored at '${logPath}'`;
76
+ const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
77
+ const logMsg = `The log has been stored at '${sessionLogPath}'`;
78
78
  const backupDirMsg = `The backup content has been stored at '${backupDir}'`;
79
79
  cli_utilities_1.log.success(logMsg, importConfig.context);
80
80
  cli_utilities_1.log.info(backupDirMsg, importConfig.context);
@@ -0,0 +1,57 @@
1
+ export declare const PATH_CONSTANTS: {
2
+ /** Root mapper directory (contains module-specific mapper subdirs) */
3
+ readonly MAPPER: "mapper";
4
+ /** Common mapper file names */
5
+ readonly FILES: {
6
+ readonly SUCCESS: "success.json";
7
+ readonly FAILS: "fails.json";
8
+ readonly UID_MAPPING: "uid-mapping.json";
9
+ readonly URL_MAPPING: "url-mapping.json";
10
+ readonly UID_MAPPER: "uid-mapper.json";
11
+ readonly SCHEMA: "schema.json";
12
+ readonly SETTINGS: "settings.json";
13
+ readonly MODIFIED_SCHEMAS: "modified-schemas.json";
14
+ readonly UNIQUE_MAPPING: "unique-mapping.json";
15
+ readonly TAXONOMIES: "taxonomies.json";
16
+ readonly ENVIRONMENTS: "environments.json";
17
+ readonly PENDING_EXTENSIONS: "pending_extensions.js";
18
+ readonly PENDING_GLOBAL_FIELDS: "pending_global_fields.js";
19
+ readonly INDEX: "index.json";
20
+ readonly FOLDER_MAPPING: "folder-mapping.json";
21
+ readonly VERSIONED_ASSETS: "versioned-assets.json";
22
+ };
23
+ /** Module subdirectory names within mapper */
24
+ readonly MAPPER_MODULES: {
25
+ readonly ASSETS: "assets";
26
+ readonly ENTRIES: "entries";
27
+ readonly CONTENT_TYPES: "content_types";
28
+ readonly TAXONOMIES: "taxonomies";
29
+ readonly TAXONOMY_TERMS: "terms";
30
+ readonly GLOBAL_FIELDS: "global_fields";
31
+ readonly EXTENSIONS: "extensions";
32
+ readonly WORKFLOWS: "workflows";
33
+ readonly WEBHOOKS: "webhooks";
34
+ readonly LABELS: "labels";
35
+ readonly ENVIRONMENTS: "environments";
36
+ readonly MARKETPLACE_APPS: "marketplace_apps";
37
+ readonly CUSTOM_ROLES: "custom-roles";
38
+ readonly LANGUAGES: "languages";
39
+ };
40
+ /** Content directory names (used in both import and export) */
41
+ readonly CONTENT_DIRS: {
42
+ readonly ASSETS: "assets";
43
+ readonly ENTRIES: "entries";
44
+ readonly CONTENT_TYPES: "content_types";
45
+ readonly TAXONOMIES: "taxonomies";
46
+ readonly GLOBAL_FIELDS: "global_fields";
47
+ readonly EXTENSIONS: "extensions";
48
+ readonly WEBHOOKS: "webhooks";
49
+ readonly WORKFLOWS: "workflows";
50
+ readonly LABELS: "labels";
51
+ readonly ENVIRONMENTS: "environments";
52
+ readonly STACK: "stack";
53
+ readonly LOCALES: "locales";
54
+ readonly MARKETPLACE_APPS: "marketplace_apps";
55
+ };
56
+ };
57
+ export type PathConstants = typeof PATH_CONSTANTS;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PATH_CONSTANTS = void 0;
4
+ exports.PATH_CONSTANTS = {
5
+ /** Root mapper directory (contains module-specific mapper subdirs) */
6
+ MAPPER: 'mapper',
7
+ /** Common mapper file names */
8
+ FILES: {
9
+ SUCCESS: 'success.json',
10
+ FAILS: 'fails.json',
11
+ UID_MAPPING: 'uid-mapping.json',
12
+ URL_MAPPING: 'url-mapping.json',
13
+ UID_MAPPER: 'uid-mapper.json',
14
+ SCHEMA: 'schema.json',
15
+ SETTINGS: 'settings.json',
16
+ MODIFIED_SCHEMAS: 'modified-schemas.json',
17
+ UNIQUE_MAPPING: 'unique-mapping.json',
18
+ TAXONOMIES: 'taxonomies.json',
19
+ ENVIRONMENTS: 'environments.json',
20
+ PENDING_EXTENSIONS: 'pending_extensions.js',
21
+ PENDING_GLOBAL_FIELDS: 'pending_global_fields.js',
22
+ INDEX: 'index.json',
23
+ FOLDER_MAPPING: 'folder-mapping.json',
24
+ VERSIONED_ASSETS: 'versioned-assets.json',
25
+ },
26
+ /** Module subdirectory names within mapper */
27
+ MAPPER_MODULES: {
28
+ ASSETS: 'assets',
29
+ ENTRIES: 'entries',
30
+ CONTENT_TYPES: 'content_types',
31
+ TAXONOMIES: 'taxonomies',
32
+ TAXONOMY_TERMS: 'terms',
33
+ GLOBAL_FIELDS: 'global_fields',
34
+ EXTENSIONS: 'extensions',
35
+ WORKFLOWS: 'workflows',
36
+ WEBHOOKS: 'webhooks',
37
+ LABELS: 'labels',
38
+ ENVIRONMENTS: 'environments',
39
+ MARKETPLACE_APPS: 'marketplace_apps',
40
+ CUSTOM_ROLES: 'custom-roles',
41
+ LANGUAGES: 'languages',
42
+ },
43
+ /** Content directory names (used in both import and export) */
44
+ CONTENT_DIRS: {
45
+ ASSETS: 'assets',
46
+ ENTRIES: 'entries',
47
+ CONTENT_TYPES: 'content_types',
48
+ TAXONOMIES: 'taxonomies',
49
+ GLOBAL_FIELDS: 'global_fields',
50
+ EXTENSIONS: 'extensions',
51
+ WEBHOOKS: 'webhooks',
52
+ WORKFLOWS: 'workflows',
53
+ LABELS: 'labels',
54
+ ENVIRONMENTS: 'environments',
55
+ STACK: 'stack',
56
+ LOCALES: 'locales',
57
+ MARKETPLACE_APPS: 'marketplace_apps',
58
+ },
59
+ };
@@ -13,6 +13,7 @@ const includes_1 = tslib_1.__importDefault(require("lodash/includes"));
13
13
  const uuid_1 = require("uuid");
14
14
  const node_path_1 = require("node:path");
15
15
  const cli_utilities_1 = require("@contentstack/cli-utilities");
16
+ const constants_1 = require("../../constants");
16
17
  const config_1 = tslib_1.__importDefault(require("../../config"));
17
18
  const utils_1 = require("../../utils");
18
19
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
@@ -26,14 +27,14 @@ class ImportAssets extends base_class_1.default {
26
27
  this.assetsFolderMap = {};
27
28
  this.importConfig.context.module = utils_1.MODULE_CONTEXTS.ASSETS;
28
29
  this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ASSETS];
29
- this.assetsPath = (0, node_path_1.join)(this.importConfig.backupDir, 'assets');
30
- this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'assets');
31
- this.assetUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, 'uid-mapping.json');
32
- this.assetUrlMapperPath = (0, node_path_1.join)(this.mapperDirPath, 'url-mapping.json');
33
- this.assetFolderUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, 'folder-mapping.json');
30
+ this.assetsPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.CONTENT_DIRS.ASSETS);
31
+ this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ASSETS);
32
+ this.assetUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
33
+ this.assetUrlMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.URL_MAPPING);
34
+ this.assetFolderUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.FOLDER_MAPPING);
34
35
  this.assetsRootPath = (0, node_path_1.join)(this.importConfig.backupDir, this.assetConfig.dirName);
35
36
  this.fs = new cli_utilities_1.FsUtility({ basePath: this.mapperDirPath });
36
- this.environments = this.fs.readFile((0, node_path_1.join)(this.importConfig.backupDir, 'environments', 'environments.json'), true);
37
+ this.environments = this.fs.readFile((0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.CONTENT_DIRS.ENVIRONMENTS, constants_1.PATH_CONSTANTS.FILES.ENVIRONMENTS), true);
37
38
  }
38
39
  /**
39
40
  * @method start
@@ -141,7 +142,9 @@ class ImportAssets extends base_class_1.default {
141
142
  */
142
143
  async importAssets(isVersion = false) {
143
144
  const processName = isVersion ? 'import versioned assets' : 'import assets';
144
- const indexFileName = isVersion ? 'versioned-assets.json' : 'assets.json';
145
+ const indexFileName = isVersion
146
+ ? constants_1.PATH_CONSTANTS.FILES.VERSIONED_ASSETS
147
+ : this.assetConfig.fileName;
145
148
  const basePath = isVersion ? (0, node_path_1.join)(this.assetsPath, 'versions') : this.assetsPath;
146
149
  const progressProcessName = isVersion ? utils_1.PROCESS_NAMES.ASSET_VERSIONS : utils_1.PROCESS_NAMES.ASSET_UPLOAD;
147
150
  cli_utilities_1.log.debug(`Importing ${processName} from ${basePath}`, this.importConfig.context);
@@ -259,7 +262,10 @@ class ImportAssets extends base_class_1.default {
259
262
  * @returns {Promise<void>} Promise<void>
260
263
  */
261
264
  async publish() {
262
- const fs = new cli_utilities_1.FsUtility({ basePath: this.assetsPath, indexFileName: 'assets.json' });
265
+ const fs = new cli_utilities_1.FsUtility({
266
+ basePath: this.assetsPath,
267
+ indexFileName: this.assetConfig.fileName,
268
+ });
263
269
  if ((0, isEmpty_1.default)(this.assetsUidMap)) {
264
270
  cli_utilities_1.log.debug('Loading asset UID mappings from file', this.importConfig.context);
265
271
  this.assetsUidMap = fs.readFile(this.assetUidMapperPath, true);
@@ -416,7 +422,10 @@ class ImportAssets extends base_class_1.default {
416
422
  return count;
417
423
  }
418
424
  async countPublishableAssets() {
419
- const fsUtil = new cli_utilities_1.FsUtility({ basePath: this.assetsPath, indexFileName: 'assets.json' });
425
+ const fsUtil = new cli_utilities_1.FsUtility({
426
+ basePath: this.assetsPath,
427
+ indexFileName: this.assetConfig.fileName,
428
+ });
420
429
  let count = 0;
421
430
  for (const _ of (0, values_1.default)(fsUtil.indexFileContent)) {
422
431
  const chunkData = await fsUtil.readChunkFiles.next().catch(() => ({}));
@@ -1,9 +1,14 @@
1
- import { Stack } from '@contentstack/management/types/stack';
2
- import { CLIProgressManager } from '@contentstack/cli-utilities';
1
+ import { ManagementStack, CLIProgressManager } from '@contentstack/cli-utilities';
3
2
  import { ImportConfig, ModuleClassParams } from '../../types';
4
3
  export type AdditionalKeys = {
5
4
  backupDir: string;
6
5
  };
6
+ export type CompleteProgressOptions = {
7
+ moduleName?: string;
8
+ customSuccessMessage?: string;
9
+ customWarningMessage?: string;
10
+ context?: Record<string, any>;
11
+ };
7
12
  export type ApiModuleType = 'create-assets' | 'replace-assets' | 'publish-assets' | 'create-assets-folder' | 'create-extensions' | 'update-extensions' | 'create-locale' | 'update-locale' | 'create-gfs' | 'create-cts' | 'update-cts' | 'update-gfs' | 'create-environments' | 'create-labels' | 'update-labels' | 'create-webhooks' | 'create-workflows' | 'create-custom-role' | 'create-entries' | 'update-entries' | 'publish-entries' | 'delete-entries' | 'create-taxonomies' | 'create-terms' | 'import-taxonomy';
8
13
  export type ApiOptions = {
9
14
  uid?: string;
@@ -35,13 +40,13 @@ export type CustomPromiseHandlerInput = {
35
40
  };
36
41
  export type CustomPromiseHandler = (input: CustomPromiseHandlerInput) => Promise<any>;
37
42
  export default abstract class BaseClass {
38
- readonly client: Stack;
43
+ readonly client: ManagementStack;
39
44
  importConfig: ImportConfig;
40
45
  modulesConfig: any;
41
46
  protected progressManager: CLIProgressManager | null;
42
47
  protected currentModuleName: string;
43
48
  constructor({ importConfig, stackAPIClient }: Omit<ModuleClassParams, 'moduleName'>);
44
- get stack(): Stack;
49
+ get stack(): ManagementStack;
45
50
  static printFinalSummary(): void;
46
51
  /**
47
52
  * Create simple progress manager
@@ -55,6 +60,17 @@ export default abstract class BaseClass {
55
60
  * Complete progress manager
56
61
  */
57
62
  protected completeProgress(success?: boolean, error?: string): void;
63
+ /**
64
+ * Complete progress and log success/warning message based on errors
65
+ * Checks the progress manager's failure count to determine if errors occurred
66
+ * @param options - Options object containing:
67
+ * - moduleName: The module name to generate the message (e.g., 'Content types', 'Entries')
68
+ * If not provided, uses this.currentModuleName
69
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been imported successfully!"
70
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been imported with some errors. Please check the logs at: {sessionLogPath}"
71
+ * - context: Optional context for logging
72
+ */
73
+ protected completeProgressWithMessage(options?: CompleteProgressOptions): void;
58
74
  protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
59
75
  /**
60
76
  * @method delay
@@ -54,6 +54,34 @@ class BaseClass {
54
54
  (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.complete(success, error);
55
55
  this.progressManager = null;
56
56
  }
57
+ /**
58
+ * Complete progress and log success/warning message based on errors
59
+ * Checks the progress manager's failure count to determine if errors occurred
60
+ * @param options - Options object containing:
61
+ * - moduleName: The module name to generate the message (e.g., 'Content types', 'Entries')
62
+ * If not provided, uses this.currentModuleName
63
+ * - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been imported successfully!"
64
+ * - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been imported with some errors. Please check the logs at: {sessionLogPath}"
65
+ * - context: Optional context for logging
66
+ */
67
+ completeProgressWithMessage(options) {
68
+ var _a, _b;
69
+ const logContext = (options === null || options === void 0 ? void 0 : options.context) || ((_a = this.importConfig) === null || _a === void 0 ? void 0 : _a.context) || {};
70
+ const failureCount = ((_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.getFailureCount()) || 0;
71
+ const hasErrors = failureCount > 0;
72
+ const name = (options === null || options === void 0 ? void 0 : options.moduleName) || this.currentModuleName || 'Module';
73
+ // Generate default messages if not provided
74
+ const successMessage = (options === null || options === void 0 ? void 0 : options.customSuccessMessage) || `${name} have been imported successfully!`;
75
+ const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
76
+ const warningMessage = (options === null || options === void 0 ? void 0 : options.customWarningMessage) || `${name} have been imported with some errors. Please check the logs at: ${sessionLogPath}`;
77
+ this.completeProgress(true);
78
+ if (hasErrors) {
79
+ cli_utilities_1.log.warn(warningMessage, logContext);
80
+ }
81
+ else {
82
+ cli_utilities_1.log.success(successMessage, logContext);
83
+ }
84
+ }
57
85
  async withLoadingSpinner(message, action) {
58
86
  var _a;
59
87
  const logConfig = cli_utilities_1.configHandler.get('log') || {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const node_path_1 = require("node:path");
5
5
  const cli_utilities_1 = require("@contentstack/cli-utilities");
6
+ const constants_1 = require("../../constants");
6
7
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
7
8
  const utils_1 = require("../../utils");
8
9
  class ImportComposableStudio {
@@ -12,9 +13,9 @@ class ImportComposableStudio {
12
13
  this.composableStudioConfig = importConfig.modules['composable-studio'];
13
14
  // Setup paths
14
15
  this.composableStudioPath = (0, node_path_1.join)(this.importConfig.backupDir, this.composableStudioConfig.dirName);
15
- this.projectMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', this.composableStudioConfig.dirName);
16
+ this.projectMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, this.composableStudioConfig.dirName);
16
17
  this.composableStudioFilePath = (0, node_path_1.join)(this.composableStudioPath, this.composableStudioConfig.fileName);
17
- this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'environments', 'uid-mapping.json');
18
+ this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENVIRONMENTS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
18
19
  this.envUidMapper = {};
19
20
  // Initialize HttpClient with Studio API base URL
20
21
  this.apiClient = new cli_utilities_1.HttpClient();
@@ -10,6 +10,7 @@ const tslib_1 = require("tslib");
10
10
  const path = tslib_1.__importStar(require("path"));
11
11
  const lodash_1 = require("lodash");
12
12
  const cli_utilities_1 = require("@contentstack/cli-utilities");
13
+ const constants_1 = require("../../constants");
13
14
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
14
15
  const content_type_helper_1 = require("../../utils/content-type-helper");
15
16
  const utils_1 = require("../../utils");
@@ -23,24 +24,22 @@ class ContentTypesImport extends base_class_1.default {
23
24
  this.gFsConfig = importConfig.modules['global-fields'];
24
25
  this.reqConcurrency = this.cTsConfig.writeConcurrency || this.importConfig.writeConcurrency;
25
26
  this.cTsFolderPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(this.cTsConfig.dirName));
26
- this.cTsMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), 'mapper', 'content_types');
27
- this.cTsSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), 'mapper', 'content_types', 'success.json');
28
- this.gFsFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(this.gFsConfig.dirName));
29
- this.gFsMapperFolderPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'global_fields', 'success.json');
30
- this.gFsPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'global_fields', 'pending_global_fields.js');
31
- this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), 'mapper', 'marketplace_apps', 'uid-mapping.json');
27
+ this.cTsMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.CONTENT_TYPES);
28
+ this.cTsSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.CONTENT_TYPES, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
29
+ this.gFsFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), (0, cli_utilities_1.sanitizePath)(this.gFsConfig.dirName));
30
+ this.gFsMapperFolderPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
31
+ this.gFsPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.GLOBAL_FIELDS, constants_1.PATH_CONSTANTS.FILES.PENDING_GLOBAL_FIELDS);
32
+ this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.MARKETPLACE_APPS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
32
33
  this.ignoredFilesInContentTypesFolder = new Map([
33
34
  ['__master.json', 'true'],
34
35
  ['__priority.json', 'true'],
35
- ['schema.json', 'true'],
36
+ [constants_1.PATH_CONSTANTS.FILES.SCHEMA, 'true'],
36
37
  ['.DS_Store', 'true'],
37
38
  ]);
38
39
  // Initialize composable studio paths if config exists
39
40
  if (this.importConfig.modules['composable-studio']) {
40
- // Use contentDir as fallback if data is not available
41
- const basePath = this.importConfig.data || this.importConfig.contentDir;
42
- this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
43
- this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
41
+ this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
42
+ this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
44
43
  }
45
44
  else {
46
45
  this.composableStudioSuccessPath = '';
@@ -54,8 +53,8 @@ class ContentTypesImport extends base_class_1.default {
54
53
  this.createdGFs = [];
55
54
  this.pendingGFs = [];
56
55
  this.pendingExts = [];
57
- this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'taxonomies', 'success.json');
58
- this.extPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'extensions', 'pending_extensions.js');
56
+ this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMIES, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
57
+ this.extPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.EXTENSIONS, constants_1.PATH_CONSTANTS.FILES.PENDING_EXTENSIONS);
59
58
  }
60
59
  async start() {
61
60
  var _a;
@@ -107,8 +106,7 @@ class ContentTypesImport extends base_class_1.default {
107
106
  if (this.pendingGFs.length > 0) {
108
107
  await this.handlePendingGlobalFields(progress);
109
108
  }
110
- this.completeProgress(true);
111
- cli_utilities_1.log.success('Content types have been imported successfully!', this.importConfig.context);
109
+ this.completeProgressWithMessage();
112
110
  }
113
111
  catch (error) {
114
112
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Content types import failed');
@@ -323,7 +321,7 @@ class ContentTypesImport extends base_class_1.default {
323
321
  async analyzeImportData() {
324
322
  var _a, _b, _c, _d, _e;
325
323
  const [cts, gfs, pendingGfs, pendingExt] = await this.withLoadingSpinner('CONTENT TYPES: Analyzing import data...', async () => {
326
- const cts = utils_1.fsUtil.readFile(path.join(this.cTsFolderPath, 'schema.json'));
324
+ const cts = utils_1.fsUtil.readFile(path.join(this.cTsFolderPath, constants_1.PATH_CONSTANTS.FILES.SCHEMA));
327
325
  const gfs = utils_1.fsUtil.readFile(path.resolve(this.gFsFolderPath, this.gFsConfig.fileName));
328
326
  const pendingGfs = utils_1.fsUtil.readFile(this.gFsPendingPath);
329
327
  const pendingExt = utils_1.fsUtil.readFile(this.extPendingPath);
@@ -6,6 +6,7 @@ const values_1 = tslib_1.__importDefault(require("lodash/values"));
6
6
  const node_path_1 = require("node:path");
7
7
  const lodash_1 = require("lodash");
8
8
  const cli_utilities_1 = require("@contentstack/cli-utilities");
9
+ const constants_1 = require("../../constants");
9
10
  const utils_1 = require("../../utils");
10
11
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
11
12
  class ImportCustomRoles extends base_class_1.default {
@@ -49,13 +50,13 @@ class ImportCustomRoles extends base_class_1.default {
49
50
  this.importConfig.context.module = utils_1.MODULE_CONTEXTS.CUSTOM_ROLES;
50
51
  this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.CUSTOM_ROLES];
51
52
  this.customRolesConfig = importConfig.modules.customRoles;
52
- this.customRolesMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'custom-roles');
53
+ this.customRolesMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.CUSTOM_ROLES);
53
54
  this.customRolesFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, this.customRolesConfig.dirName);
54
- this.customRolesUidMapperPath = (0, node_path_1.join)(this.customRolesMapperPath, 'uid-mapping.json');
55
- this.envUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'environments');
56
- this.entriesUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'entries');
57
- this.createdCustomRolesPath = (0, node_path_1.join)(this.customRolesMapperPath, 'success.json');
58
- this.customRolesFailsPath = (0, node_path_1.join)(this.customRolesMapperPath, 'fails.json');
55
+ this.customRolesUidMapperPath = (0, node_path_1.join)(this.customRolesMapperPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
56
+ this.envUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENVIRONMENTS);
57
+ this.entriesUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENTRIES);
58
+ this.createdCustomRolesPath = (0, node_path_1.join)(this.customRolesMapperPath, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
59
+ this.customRolesFailsPath = (0, node_path_1.join)(this.customRolesMapperPath, constants_1.PATH_CONSTANTS.FILES.FAILS);
59
60
  this.customRoles = {};
60
61
  this.failedCustomRoles = [];
61
62
  this.createdCustomRoles = [];
@@ -84,8 +85,7 @@ class ImportCustomRoles extends base_class_1.default {
84
85
  progress.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CUSTOM_ROLES_IMPORT].IMPORTING);
85
86
  await this.importCustomRoles();
86
87
  this.handleImportResults();
87
- this.completeProgress(true);
88
- cli_utilities_1.log.success('Custom roles have been imported successfully!', this.importConfig.context);
88
+ this.completeProgressWithMessage();
89
89
  }
90
90
  catch (error) {
91
91
  this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Custom roles import failed');
@@ -233,8 +233,8 @@ class ImportCustomRoles extends base_class_1.default {
233
233
  cli_utilities_1.log.debug('Creating custom roles mapper directory', this.importConfig.context);
234
234
  await utils_1.fsUtil.makeDirectory(this.customRolesMapperPath);
235
235
  this.customRolesUidMapper = this.loadJsonFileIfExists(this.customRolesUidMapperPath, 'custom roles');
236
- this.environmentsUidMap = this.loadJsonFileIfExists((0, node_path_1.join)(this.envUidMapperFolderPath, 'uid-mapping.json'), 'environments');
237
- this.entriesUidMap = this.loadJsonFileIfExists((0, node_path_1.join)(this.entriesUidMapperFolderPath, 'uid-mapping.json'), 'entries');
236
+ this.environmentsUidMap = this.loadJsonFileIfExists((0, node_path_1.join)(this.envUidMapperFolderPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING), 'environments');
237
+ this.entriesUidMap = this.loadJsonFileIfExists((0, node_path_1.join)(this.entriesUidMapperFolderPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING), 'entries');
238
238
  }
239
239
  loadJsonFileIfExists(path, label) {
240
240
  if (utils_1.fileHelper.fileExistsSync(path)) {
@@ -11,6 +11,7 @@ const path = tslib_1.__importStar(require("path"));
11
11
  const fs_1 = require("fs");
12
12
  const lodash_1 = require("lodash");
13
13
  const cli_utilities_1 = require("@contentstack/cli-utilities");
14
+ const constants_1 = require("../../constants");
14
15
  const utils_1 = require("../../utils");
15
16
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
16
17
  class EntriesImport extends base_class_1.default {
@@ -19,25 +20,23 @@ class EntriesImport extends base_class_1.default {
19
20
  this.entriesForVariant = [];
20
21
  this.importConfig.context.module = utils_1.MODULE_CONTEXTS.ENTRIES;
21
22
  this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ENTRIES];
22
- this.assetUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'assets', 'uid-mapping.json');
23
- this.assetUrlMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'assets', 'url-mapping.json');
24
- this.entriesMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'mapper', 'entries');
25
- this.envPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), 'environments', 'environments.json');
26
- this.entriesUIDMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), 'uid-mapping.json');
27
- this.uniqueUidMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), 'unique-mapping.json');
28
- this.modifiedCTsPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), 'modified-schemas.json');
29
- this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), 'mapper', 'marketplace_apps', 'uid-mapping.json');
30
- this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.contentDir), 'mapper', 'taxonomies', 'terms', 'success.json');
23
+ this.assetUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ASSETS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
24
+ this.assetUrlMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ASSETS, constants_1.PATH_CONSTANTS.FILES.URL_MAPPING);
25
+ this.entriesMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ENTRIES);
26
+ this.envPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), constants_1.PATH_CONSTANTS.CONTENT_DIRS.ENVIRONMENTS, constants_1.PATH_CONSTANTS.FILES.ENVIRONMENTS);
27
+ this.entriesUIDMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
28
+ this.uniqueUidMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), constants_1.PATH_CONSTANTS.FILES.UNIQUE_MAPPING);
29
+ this.modifiedCTsPath = path.join((0, cli_utilities_1.sanitizePath)(this.entriesMapperPath), constants_1.PATH_CONSTANTS.FILES.MODIFIED_SCHEMAS);
30
+ this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.MARKETPLACE_APPS, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
31
+ this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMIES, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMY_TERMS, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
31
32
  this.entriesConfig = importConfig.modules.entries;
32
33
  this.entriesPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(this.entriesConfig.dirName));
33
34
  this.cTsPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(importConfig.modules['content-types'].dirName));
34
35
  this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.fileName));
35
36
  // Initialize composable studio paths if config exists
36
37
  if (this.importConfig.modules['composable-studio']) {
37
- // Use contentDir as fallback if data is not available
38
- const basePath = this.importConfig.data || this.importConfig.contentDir;
39
- this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
40
- this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(basePath), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
38
+ this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
39
+ this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
41
40
  }
42
41
  else {
43
42
  this.composableStudioSuccessPath = '';
@@ -123,8 +122,7 @@ class EntriesImport extends base_class_1.default {
123
122
  .updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CLEANUP].CLEANING, utils_1.PROCESS_NAMES.CLEANUP);
124
123
  await this.processCleanup();
125
124
  progress.completeProcess(utils_1.PROCESS_NAMES.CLEANUP, true);
126
- this.completeProgress(true);
127
- cli_utilities_1.log.success('Entries imported successfully', this.importConfig.context);
125
+ this.completeProgressWithMessage();
128
126
  }
129
127
  catch (error) {
130
128
  this.createEntryDataForVariantEntry();
@@ -135,7 +133,7 @@ class EntriesImport extends base_class_1.default {
135
133
  async analyzeEntryData() {
136
134
  return this.withLoadingSpinner('ENTRIES: Analyzing import data...', async () => {
137
135
  cli_utilities_1.log.debug('Loading content types for entry analysis', this.importConfig.context);
138
- this.cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
136
+ this.cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, constants_1.PATH_CONSTANTS.FILES.SCHEMA));
139
137
  if (!this.cTs || (0, lodash_1.isEmpty)(this.cTs)) {
140
138
  return [0, 0, 0, 0, 0];
141
139
  }
@@ -159,7 +157,7 @@ class EntriesImport extends base_class_1.default {
159
157
  for (let locale of this.locales) {
160
158
  for (let contentType of this.cTs) {
161
159
  const basePath = path.join(this.entriesPath, contentType.uid, locale.code);
162
- const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName: 'index.json' });
160
+ const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX });
163
161
  const indexer = fs.indexFileContent;
164
162
  const chunksInThisCTLocale = (0, lodash_1.values)(indexer).length;
165
163
  totalEntryChunks += chunksInThisCTLocale;
@@ -211,7 +209,7 @@ class EntriesImport extends base_class_1.default {
211
209
  await this.createEntries(entryRequestOption);
212
210
  }
213
211
  cli_utilities_1.log.debug('Writing entry UID mappings to file', this.importConfig.context);
214
- await utils_1.fileHelper.writeLargeFile(path.join(this.entriesMapperPath, 'uid-mapping.json'), this.entriesUidMapper);
212
+ await utils_1.fileHelper.writeLargeFile(path.join(this.entriesMapperPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING), this.entriesUidMapper);
215
213
  utils_1.fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries);
216
214
  }
217
215
  async processEntryReplacement() {
@@ -368,7 +366,7 @@ class EntriesImport extends base_class_1.default {
368
366
  async createEntries({ cTUid, locale }) {
369
367
  var _a, _b;
370
368
  const processName = 'Create Entries';
371
- const indexFileName = 'index.json';
369
+ const indexFileName = constants_1.PATH_CONSTANTS.FILES.INDEX;
372
370
  const basePath = path.join(this.entriesPath, cTUid, locale);
373
371
  const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName });
374
372
  const indexer = fs.indexFileContent;
@@ -384,7 +382,7 @@ class EntriesImport extends base_class_1.default {
384
382
  // Write created entries
385
383
  const entriesCreateFileHelper = new cli_utilities_1.FsUtility({
386
384
  moduleName: 'entries',
387
- indexFileName: 'index.json',
385
+ indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX,
388
386
  basePath: path.join(this.entriesMapperPath, cTUid, locale),
389
387
  chunkFileSize: this.entriesConfig.chunkFileSize,
390
388
  keepMetadata: false,
@@ -393,7 +391,7 @@ class EntriesImport extends base_class_1.default {
393
391
  // create file instance for existing entries
394
392
  const existingEntriesFileHelper = new cli_utilities_1.FsUtility({
395
393
  moduleName: 'entries',
396
- indexFileName: 'index.json',
394
+ indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX,
397
395
  basePath: path.join(this.entriesMapperPath, cTUid, locale, 'existing'),
398
396
  chunkFileSize: this.entriesConfig.chunkFileSize,
399
397
  keepMetadata: false,
@@ -545,7 +543,7 @@ class EntriesImport extends base_class_1.default {
545
543
  }
546
544
  async replaceEntries({ cTUid, locale }) {
547
545
  const processName = 'Replace existing Entries';
548
- const indexFileName = 'index.json';
546
+ const indexFileName = constants_1.PATH_CONSTANTS.FILES.INDEX;
549
547
  const basePath = path.join(this.entriesMapperPath, cTUid, locale, 'existing');
550
548
  const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName });
551
549
  const indexer = fs.indexFileContent;
@@ -558,7 +556,7 @@ class EntriesImport extends base_class_1.default {
558
556
  // Write updated entries
559
557
  const entriesReplaceFileHelper = new cli_utilities_1.FsUtility({
560
558
  moduleName: 'entries',
561
- indexFileName: 'index.json',
559
+ indexFileName: constants_1.PATH_CONSTANTS.FILES.INDEX,
562
560
  basePath: path.join(this.entriesMapperPath, cTUid, locale),
563
561
  chunkFileSize: this.entriesConfig.chunkFileSize,
564
562
  keepMetadata: false,
@@ -673,7 +671,7 @@ class EntriesImport extends base_class_1.default {
673
671
  }
674
672
  async updateEntriesWithReferences({ cTUid, locale }) {
675
673
  const processName = 'Update Entries';
676
- const indexFileName = 'index.json';
674
+ const indexFileName = constants_1.PATH_CONSTANTS.FILES.INDEX;
677
675
  const basePath = path.join(this.entriesMapperPath, cTUid, locale);
678
676
  const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName });
679
677
  const indexer = fs.indexFileContent;
@@ -855,7 +853,7 @@ class EntriesImport extends base_class_1.default {
855
853
  try {
856
854
  for (let cTUid of cTsWithFieldRules) {
857
855
  cli_utilities_1.log.debug(`Processing field rules for content type: ${cTUid}`, this.importConfig.context);
858
- const cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
856
+ const cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, constants_1.PATH_CONSTANTS.FILES.SCHEMA));
859
857
  const contentType = (0, lodash_1.find)(cTs, { uid: cTUid });
860
858
  if (contentType.field_rules) {
861
859
  cli_utilities_1.log.debug(`Found ${contentType.field_rules.length} field rules for content type: ${cTUid}`, this.importConfig.context);
@@ -918,7 +916,7 @@ class EntriesImport extends base_class_1.default {
918
916
  }
919
917
  async publishEntries({ cTUid, locale }) {
920
918
  const processName = 'Publish Entries';
921
- const indexFileName = 'index.json';
919
+ const indexFileName = constants_1.PATH_CONSTANTS.FILES.INDEX;
922
920
  const basePath = path.join(this.entriesPath, cTUid, locale);
923
921
  const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName });
924
922
  const indexer = fs.indexFileContent;
@@ -946,16 +944,7 @@ class EntriesImport extends base_class_1.default {
946
944
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid, locale }));
947
945
  });
948
946
  if (chunk) {
949
- let apiContent = (0, lodash_1.values)(chunk);
950
- let apiContentDuplicate = [];
951
- apiContentDuplicate = apiContent.flatMap((content) => {
952
- var _a;
953
- if (((_a = content === null || content === void 0 ? void 0 : content.publish_details) === null || _a === void 0 ? void 0 : _a.length) > 0) {
954
- return content.publish_details.map((publish) => (Object.assign(Object.assign({}, content), { locale: publish.locale, publish_details: [publish] })));
955
- }
956
- return []; // Return an empty array if publish_details is empty
957
- });
958
- apiContent = apiContentDuplicate;
947
+ const apiContent = (0, lodash_1.values)(chunk).filter((content) => { var _a; return ((_a = content === null || content === void 0 ? void 0 : content.publish_details) === null || _a === void 0 ? void 0 : _a.length) > 0; });
959
948
  cli_utilities_1.log.debug(`Processing ${apiContent.length} publishable entries in chunk ${index}`, this.importConfig.context);
960
949
  if ((apiContent === null || apiContent === void 0 ? void 0 : apiContent.length) === 0) {
961
950
  cli_utilities_1.log.debug(`No publishable entries found in chunk ${index}`, this.importConfig.context);