@contentstack/cli-cm-export 1.17.0 → 1.18.1
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 +1 -1
- package/lib/commands/cm/stacks/export.d.ts +2 -0
- package/lib/commands/cm/stacks/export.js +43 -15
- package/lib/export/module-exporter.js +16 -10
- package/lib/export/modules/assets.d.ts +0 -5
- package/lib/export/modules/assets.js +47 -32
- package/lib/export/modules/base-class.d.ts +1 -0
- package/lib/export/modules/base-class.js +16 -2
- package/lib/export/modules/content-types.d.ts +1 -1
- package/lib/export/modules/content-types.js +25 -12
- package/lib/export/modules/custom-roles.js +50 -9
- package/lib/export/modules/entries.d.ts +1 -1
- package/lib/export/modules/entries.js +63 -16
- package/lib/export/modules/environments.js +29 -7
- package/lib/export/modules/extensions.js +30 -7
- package/lib/export/modules/global-fields.js +27 -7
- package/lib/export/modules/index.js +10 -3
- package/lib/export/modules/labels.js +29 -7
- package/lib/export/modules/locales.d.ts +1 -1
- package/lib/export/modules/locales.js +29 -7
- package/lib/export/modules/marketplace-apps.d.ts +2 -1
- package/lib/export/modules/marketplace-apps.js +62 -15
- package/lib/export/modules/personalize.js +23 -6
- package/lib/export/modules/stack.js +57 -12
- package/lib/export/modules/taxonomies.d.ts +0 -1
- package/lib/export/modules/taxonomies.js +40 -30
- package/lib/export/modules/webhooks.js +29 -7
- package/lib/export/modules/workflows.js +38 -10
- package/lib/types/export-config.d.ts +6 -1
- package/lib/types/index.d.ts +11 -0
- package/lib/utils/basic-login.js +7 -8
- package/lib/utils/common-helper.js +3 -4
- package/lib/utils/export-config-handler.js +44 -0
- package/lib/utils/marketplace-app-helper.js +1 -2
- package/lib/utils/setup-branches.js +1 -1
- package/lib/utils/setup-export-dir.js +1 -1
- package/messages/index.json +69 -1
- package/oclif.manifest.json +9 -1
- package/package.json +4 -4
|
@@ -6,6 +6,7 @@ const find_1 = tslib_1.__importDefault(require("lodash/find"));
|
|
|
6
6
|
const forEach_1 = tslib_1.__importDefault(require("lodash/forEach"));
|
|
7
7
|
const values_1 = tslib_1.__importDefault(require("lodash/values"));
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
9
10
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
10
11
|
const utils_1 = require("../../utils");
|
|
11
12
|
class ExportCustomRoles extends base_class_1.default {
|
|
@@ -16,65 +17,105 @@ class ExportCustomRoles extends base_class_1.default {
|
|
|
16
17
|
this.existingRoles = { Admin: 1, Developer: 1, 'Content Manager': 1 };
|
|
17
18
|
this.localesMap = {};
|
|
18
19
|
this.sourceLocalesMap = {};
|
|
20
|
+
this.exportConfig.context.module = 'custom-roles';
|
|
19
21
|
}
|
|
20
22
|
async start() {
|
|
21
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
cli_utilities_1.log.debug('Starting custom roles export process...', this.exportConfig.context);
|
|
22
25
|
this.rolesFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.customRolesConfig.dirName);
|
|
26
|
+
cli_utilities_1.log.debug(`Custom roles folder path: ${this.rolesFolderPath}`, this.exportConfig.context);
|
|
23
27
|
await utils_1.fsUtil.makeDirectory(this.rolesFolderPath);
|
|
28
|
+
cli_utilities_1.log.debug('Created custom roles directory', this.exportConfig.context);
|
|
24
29
|
this.customRolesLocalesFilepath = (0, node_path_1.resolve)(this.rolesFolderPath, this.customRolesConfig.customRolesLocalesFileName);
|
|
30
|
+
cli_utilities_1.log.debug(`Custom roles locales file path: ${this.customRolesLocalesFilepath}`, this.exportConfig.context);
|
|
25
31
|
await this.getCustomRoles();
|
|
26
32
|
await this.getLocales();
|
|
27
33
|
await this.getCustomRolesLocales();
|
|
34
|
+
cli_utilities_1.log.debug(`Custom roles export completed. Total custom roles: ${(_a = Object.keys(this.customRoles)) === null || _a === void 0 ? void 0 : _a.length}`, this.exportConfig.context);
|
|
28
35
|
}
|
|
29
36
|
async getCustomRoles() {
|
|
37
|
+
var _a;
|
|
38
|
+
cli_utilities_1.log.debug('Fetching all roles from the stack...', this.exportConfig.context);
|
|
30
39
|
const roles = await this.stack
|
|
31
40
|
.role()
|
|
32
41
|
.fetchAll({ include_rules: true, include_permissions: true })
|
|
33
|
-
.then((data) =>
|
|
34
|
-
|
|
42
|
+
.then((data) => {
|
|
43
|
+
var _a;
|
|
44
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = data.items) === null || _a === void 0 ? void 0 : _a.length) || 0} total roles`, this.exportConfig.context);
|
|
45
|
+
return data;
|
|
46
|
+
})
|
|
47
|
+
.catch((err) => {
|
|
48
|
+
cli_utilities_1.log.debug('Error occurred while fetching roles', this.exportConfig.context);
|
|
49
|
+
return (0, cli_utilities_1.handleAndLogError)(err, Object.assign({}, this.exportConfig.context));
|
|
50
|
+
});
|
|
35
51
|
const customRoles = roles.items.filter((role) => !this.existingRoles[role.name]);
|
|
52
|
+
cli_utilities_1.log.debug(`Found ${customRoles.length} custom roles out of ${((_a = roles.items) === null || _a === void 0 ? void 0 : _a.length) || 0} total roles`, this.exportConfig.context);
|
|
36
53
|
if (!customRoles.length) {
|
|
37
|
-
|
|
54
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('ROLES_NO_CUSTOM_ROLES'), this.exportConfig.context);
|
|
38
55
|
return;
|
|
39
56
|
}
|
|
40
57
|
customRoles.forEach((role) => {
|
|
41
|
-
|
|
58
|
+
cli_utilities_1.log.debug(`Processing custom role: ${role === null || role === void 0 ? void 0 : role.name} (${role === null || role === void 0 ? void 0 : role.uid})`, this.exportConfig.context);
|
|
59
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('ROLES_EXPORTING_ROLE', role === null || role === void 0 ? void 0 : role.name), this.exportConfig.context);
|
|
42
60
|
this.customRoles[role.uid] = role;
|
|
43
61
|
});
|
|
44
|
-
|
|
62
|
+
const customRolesFilePath = (0, node_path_1.resolve)(this.rolesFolderPath, this.customRolesConfig.fileName);
|
|
63
|
+
cli_utilities_1.log.debug(`Writing custom roles to: ${customRolesFilePath}`, this.exportConfig.context);
|
|
64
|
+
utils_1.fsUtil.writeFile(customRolesFilePath, this.customRoles);
|
|
45
65
|
}
|
|
46
66
|
async getLocales() {
|
|
67
|
+
var _a;
|
|
68
|
+
cli_utilities_1.log.debug('Fetching locales for custom roles mapping...', this.exportConfig.context);
|
|
47
69
|
const locales = await this.stack
|
|
48
70
|
.locale()
|
|
49
71
|
.query({})
|
|
50
72
|
.find()
|
|
51
|
-
.then((data) =>
|
|
52
|
-
|
|
73
|
+
.then((data) => {
|
|
74
|
+
var _a;
|
|
75
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = data === null || data === void 0 ? void 0 : data.items) === null || _a === void 0 ? void 0 : _a.length) || 0} locales`, this.exportConfig.context);
|
|
76
|
+
return data;
|
|
77
|
+
})
|
|
78
|
+
.catch((err) => {
|
|
79
|
+
cli_utilities_1.log.debug('Error occurred while fetching locales', this.exportConfig.context);
|
|
80
|
+
return (0, cli_utilities_1.handleAndLogError)(err, Object.assign({}, this.exportConfig.context));
|
|
81
|
+
});
|
|
53
82
|
for (const locale of locales.items) {
|
|
83
|
+
cli_utilities_1.log.debug(`Mapping locale: ${locale === null || locale === void 0 ? void 0 : locale.name} (${locale === null || locale === void 0 ? void 0 : locale.uid})`, this.exportConfig.context);
|
|
54
84
|
this.sourceLocalesMap[locale.uid] = locale;
|
|
55
85
|
}
|
|
86
|
+
cli_utilities_1.log.debug(`Mapped ${(_a = Object.keys(this.sourceLocalesMap)) === null || _a === void 0 ? void 0 : _a.length} locales`, this.exportConfig.context);
|
|
56
87
|
}
|
|
57
88
|
async getCustomRolesLocales() {
|
|
58
|
-
var _a, _b;
|
|
89
|
+
var _a, _b, _c;
|
|
90
|
+
cli_utilities_1.log.debug('Processing custom roles locales mapping...', this.exportConfig.context);
|
|
59
91
|
for (const role of (0, values_1.default)(this.customRoles)) {
|
|
60
92
|
const customRole = role;
|
|
93
|
+
cli_utilities_1.log.debug(`Processing locales for custom role: ${customRole === null || customRole === void 0 ? void 0 : customRole.name}`, this.exportConfig.context);
|
|
61
94
|
const rulesLocales = (0, find_1.default)(customRole.rules, (rule) => rule.module === 'locale');
|
|
62
95
|
if ((_a = rulesLocales === null || rulesLocales === void 0 ? void 0 : rulesLocales.locales) === null || _a === void 0 ? void 0 : _a.length) {
|
|
96
|
+
cli_utilities_1.log.debug(`Found ${rulesLocales.locales.length} locales for role: ${customRole === null || customRole === void 0 ? void 0 : customRole.name}`, this.exportConfig.context);
|
|
63
97
|
(0, forEach_1.default)(rulesLocales.locales, (locale) => {
|
|
98
|
+
cli_utilities_1.log.debug(`Adding locale ${locale} to custom roles mapping`, this.exportConfig.context);
|
|
64
99
|
this.localesMap[locale] = 1;
|
|
65
100
|
});
|
|
66
101
|
}
|
|
67
102
|
}
|
|
68
103
|
if ((_b = (0, keys_1.default)(this.localesMap)) === null || _b === void 0 ? void 0 : _b.length) {
|
|
104
|
+
cli_utilities_1.log.debug(`Processing ${(_c = (0, keys_1.default)(this.localesMap)) === null || _c === void 0 ? void 0 : _c.length} custom role locales`, this.exportConfig.context);
|
|
69
105
|
for (const locale in this.localesMap) {
|
|
70
106
|
if (this.sourceLocalesMap[locale] !== undefined) {
|
|
71
107
|
const sourceLocale = this.sourceLocalesMap[locale];
|
|
108
|
+
cli_utilities_1.log.debug(`Mapping locale ${locale} (${sourceLocale.name})`, this.exportConfig.context);
|
|
72
109
|
sourceLocale === null || sourceLocale === void 0 ? true : delete sourceLocale.stackHeaders;
|
|
73
110
|
}
|
|
74
111
|
this.localesMap[locale] = this.sourceLocalesMap[locale];
|
|
75
112
|
}
|
|
113
|
+
cli_utilities_1.log.debug(`Writing custom roles locales to: ${this.customRolesLocalesFilepath}`, this.exportConfig.context);
|
|
76
114
|
utils_1.fsUtil.writeFile(this.customRolesLocalesFilepath, this.localesMap);
|
|
77
115
|
}
|
|
116
|
+
else {
|
|
117
|
+
cli_utilities_1.log.debug('No custom role locales found to process', this.exportConfig.context);
|
|
118
|
+
}
|
|
78
119
|
}
|
|
79
120
|
}
|
|
80
121
|
exports.default = ExportCustomRoles;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExportConfig, ModuleClassParams } from '../../types';
|
|
2
1
|
import BaseClass, { ApiOptions } from './base-class';
|
|
2
|
+
import { ExportConfig, ModuleClassParams } from '../../types';
|
|
3
3
|
export default class EntriesExport extends BaseClass {
|
|
4
4
|
private stackAPIClient;
|
|
5
5
|
exportConfig: ExportConfig;
|
|
@@ -4,9 +4,9 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const path = tslib_1.__importStar(require("path"));
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
6
|
const cli_variants_1 = require("@contentstack/cli-variants");
|
|
7
|
+
const cli_utilities_2 = require("@contentstack/cli-utilities");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
9
|
-
const cli_utilities_2 = require("@contentstack/cli-utilities");
|
|
10
10
|
class EntriesExport extends base_class_1.default {
|
|
11
11
|
constructor({ exportConfig, stackAPIClient }) {
|
|
12
12
|
super({ exportConfig, stackAPIClient });
|
|
@@ -18,46 +18,70 @@ class EntriesExport extends base_class_1.default {
|
|
|
18
18
|
this.localesFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
19
19
|
this.schemaFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.content_types.dirName), 'schema.json');
|
|
20
20
|
this.projectInstance = new cli_variants_1.ExportProjects(this.exportConfig);
|
|
21
|
+
this.exportConfig.context.module = 'entries';
|
|
21
22
|
}
|
|
22
23
|
async start() {
|
|
23
24
|
var _a, _b;
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
+
cli_utilities_1.log.debug('Starting entries export process...', this.exportConfig.context);
|
|
26
27
|
const locales = utils_1.fsUtil.readFile(this.localesFilePath);
|
|
28
|
+
if (!Array.isArray(locales) || (locales === null || locales === void 0 ? void 0 : locales.length) === 0) {
|
|
29
|
+
cli_utilities_1.log.debug(`No locales found in ${this.localesFilePath}`, this.exportConfig.context);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
cli_utilities_1.log.debug(`Loaded ${locales === null || locales === void 0 ? void 0 : locales.length} locales from ${this.localesFilePath}`, this.exportConfig.context);
|
|
33
|
+
}
|
|
27
34
|
const contentTypes = utils_1.fsUtil.readFile(this.schemaFilePath);
|
|
28
|
-
if (contentTypes.length === 0) {
|
|
29
|
-
|
|
35
|
+
if ((contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes.length) === 0) {
|
|
36
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('CONTENT_TYPE_NO_TYPES'), this.exportConfig.context);
|
|
30
37
|
return;
|
|
31
38
|
}
|
|
39
|
+
cli_utilities_1.log.debug(`Loaded ${contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes.length} content types from ${this.schemaFilePath}`, this.exportConfig.context);
|
|
32
40
|
// NOTE Check if variant is enabled in specific stack
|
|
33
41
|
if (this.exportConfig.personalizationEnabled) {
|
|
42
|
+
cli_utilities_1.log.debug('Personalization is enabled, checking for variant entries...', this.exportConfig.context);
|
|
34
43
|
let project_id;
|
|
35
44
|
try {
|
|
36
45
|
const project = await this.projectInstance.projects({ connectedStackApiKey: this.exportConfig.apiKey });
|
|
37
46
|
if (project && ((_a = project[0]) === null || _a === void 0 ? void 0 : _a.uid)) {
|
|
38
47
|
project_id = project[0].uid;
|
|
39
48
|
this.exportVariantEntry = true;
|
|
49
|
+
cli_utilities_1.log.debug(`Found project with ID: ${project_id}, enabling variant entry export`, this.exportConfig.context);
|
|
40
50
|
}
|
|
41
51
|
this.variantEntries = new cli_variants_1.Export.VariantEntries(Object.assign(this.exportConfig, { project_id }));
|
|
42
52
|
}
|
|
43
53
|
catch (error) {
|
|
44
|
-
(0,
|
|
54
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
45
55
|
}
|
|
46
56
|
}
|
|
47
57
|
const entryRequestOptions = this.createRequestObjects(locales, contentTypes);
|
|
58
|
+
cli_utilities_1.log.debug(`Created ${entryRequestOptions.length} entry request objects for processing`, this.exportConfig.context);
|
|
48
59
|
for (let entryRequestOption of entryRequestOptions) {
|
|
60
|
+
cli_utilities_1.log.debug(`Processing entries for content type: ${entryRequestOption.contentType}, locale: ${entryRequestOption.locale}`, this.exportConfig.context);
|
|
49
61
|
await this.getEntries(entryRequestOption);
|
|
50
62
|
(_b = this.entriesFileHelper) === null || _b === void 0 ? void 0 : _b.completeFile(true);
|
|
51
|
-
|
|
63
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENTRIES_EXPORT_COMPLETE', entryRequestOption.contentType, entryRequestOption.locale), this.exportConfig.context);
|
|
52
64
|
}
|
|
53
|
-
|
|
65
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENTRIES_EXPORT_SUCCESS'), this.exportConfig.context);
|
|
54
66
|
}
|
|
55
67
|
catch (error) {
|
|
56
|
-
(0,
|
|
57
|
-
throw new Error('Failed to export entries');
|
|
68
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
58
69
|
}
|
|
59
70
|
}
|
|
60
71
|
createRequestObjects(locales, contentTypes) {
|
|
72
|
+
if (!Array.isArray(locales) || (locales === null || locales === void 0 ? void 0 : locales.length) === 0) {
|
|
73
|
+
cli_utilities_1.log.debug('No locales found, using master locale only', this.exportConfig.context);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
cli_utilities_1.log.debug(`Found ${locales.length} locales for export`, this.exportConfig.context);
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(contentTypes) || contentTypes.length === 0) {
|
|
79
|
+
cli_utilities_1.log.debug('No content types found, skipping entries export', this.exportConfig.context);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
cli_utilities_1.log.debug(`Found ${contentTypes.length} content types for export`, this.exportConfig.context);
|
|
84
|
+
}
|
|
61
85
|
let requestObjects = [];
|
|
62
86
|
contentTypes.forEach((contentType) => {
|
|
63
87
|
if (Object.keys(locales).length !== 0) {
|
|
@@ -73,9 +97,11 @@ class EntriesExport extends base_class_1.default {
|
|
|
73
97
|
locale: this.exportConfig.master_locale.code,
|
|
74
98
|
});
|
|
75
99
|
});
|
|
100
|
+
cli_utilities_1.log.debug(`Created ${requestObjects.length} total request objects`, this.exportConfig.context);
|
|
76
101
|
return requestObjects;
|
|
77
102
|
}
|
|
78
103
|
async getEntries(options) {
|
|
104
|
+
var _a, _b;
|
|
79
105
|
options.skip = options.skip || 0;
|
|
80
106
|
let requestObject = {
|
|
81
107
|
locale: options.locale,
|
|
@@ -87,6 +113,8 @@ class EntriesExport extends base_class_1.default {
|
|
|
87
113
|
locale: options.locale,
|
|
88
114
|
},
|
|
89
115
|
};
|
|
116
|
+
this.applyQueryFilters(requestObject, 'entries');
|
|
117
|
+
cli_utilities_1.log.debug(`Fetching entries with request: ${JSON.stringify(requestObject)}`, this.exportConfig.context);
|
|
90
118
|
let entriesSearchResponse;
|
|
91
119
|
try {
|
|
92
120
|
entriesSearchResponse = await this.stackAPIClient
|
|
@@ -94,14 +122,16 @@ class EntriesExport extends base_class_1.default {
|
|
|
94
122
|
.entry()
|
|
95
123
|
.query(requestObject)
|
|
96
124
|
.find();
|
|
125
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = entriesSearchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} entries out of total ${entriesSearchResponse.count}`, this.exportConfig.context);
|
|
97
126
|
}
|
|
98
127
|
catch (error) {
|
|
99
|
-
(0,
|
|
100
|
-
throw
|
|
128
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.exportConfig.context), { contentType: options.contentType, locale: options.locale }));
|
|
129
|
+
throw error;
|
|
101
130
|
}
|
|
102
|
-
if (Array.isArray(entriesSearchResponse.items) && entriesSearchResponse.items.length > 0) {
|
|
131
|
+
if (Array.isArray(entriesSearchResponse === null || entriesSearchResponse === void 0 ? void 0 : entriesSearchResponse.items) && ((_b = entriesSearchResponse === null || entriesSearchResponse === void 0 ? void 0 : entriesSearchResponse.items) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
103
132
|
if (options.skip === 0) {
|
|
104
133
|
const entryBasePath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale));
|
|
134
|
+
cli_utilities_1.log.debug(`Creating directory for entries at: ${entryBasePath}`, this.exportConfig.context);
|
|
105
135
|
await utils_1.fsUtil.makeDirectory(entryBasePath);
|
|
106
136
|
this.entriesFileHelper = new cli_utilities_1.FsUtility({
|
|
107
137
|
moduleName: 'entries',
|
|
@@ -111,10 +141,14 @@ class EntriesExport extends base_class_1.default {
|
|
|
111
141
|
keepMetadata: false,
|
|
112
142
|
omitKeys: this.entriesConfig.invalidKeys,
|
|
113
143
|
});
|
|
144
|
+
cli_utilities_1.log.debug('Initialized FsUtility for writing entries', this.exportConfig.context);
|
|
114
145
|
}
|
|
146
|
+
cli_utilities_1.log.debug(`Writing ${entriesSearchResponse.items.length} entries to file`, this.exportConfig.context);
|
|
115
147
|
this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true });
|
|
116
148
|
if (this.entriesConfig.exportVersions) {
|
|
149
|
+
cli_utilities_1.log.debug('Exporting entry versions is enabled', this.exportConfig.context);
|
|
117
150
|
let versionedEntryPath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale), 'versions');
|
|
151
|
+
cli_utilities_1.log.debug(`Creating versioned entries directory at: ${versionedEntryPath}`, this.exportConfig.context);
|
|
118
152
|
utils_1.fsUtil.makeDirectory(versionedEntryPath);
|
|
119
153
|
await this.fetchEntriesVersions(entriesSearchResponse.items, {
|
|
120
154
|
locale: options.locale,
|
|
@@ -124,6 +158,7 @@ class EntriesExport extends base_class_1.default {
|
|
|
124
158
|
}
|
|
125
159
|
// NOTE Export all base entry specific 'variant entries'
|
|
126
160
|
if (this.exportVariantEntry) {
|
|
161
|
+
cli_utilities_1.log.debug('Exporting variant entries for base entries', this.exportConfig.context);
|
|
127
162
|
await this.variantEntries.exportVariantEntry({
|
|
128
163
|
locale: options.locale,
|
|
129
164
|
contentTypeUid: options.contentType,
|
|
@@ -132,20 +167,26 @@ class EntriesExport extends base_class_1.default {
|
|
|
132
167
|
}
|
|
133
168
|
options.skip += this.entriesConfig.limit || 100;
|
|
134
169
|
if (options.skip >= entriesSearchResponse.count) {
|
|
170
|
+
cli_utilities_1.log.debug(`Completed fetching all entries for content type: ${options.contentType}, locale: ${options.locale}`, this.exportConfig.context);
|
|
135
171
|
return Promise.resolve(true);
|
|
136
172
|
}
|
|
173
|
+
cli_utilities_1.log.debug(`Continuing to fetch entries with skip: ${options.skip}`, this.exportConfig.context);
|
|
137
174
|
return await this.getEntries(options);
|
|
138
175
|
}
|
|
139
176
|
}
|
|
140
177
|
async fetchEntriesVersions(entries, options) {
|
|
178
|
+
cli_utilities_1.log.debug(`Fetching versions for ${entries.length} entries`, this.exportConfig.context);
|
|
141
179
|
const onSuccess = ({ response, apiData: entry }) => {
|
|
142
|
-
|
|
143
|
-
|
|
180
|
+
const versionFilePath = path.join((0, cli_utilities_2.sanitizePath)(options.versionedEntryPath), (0, cli_utilities_2.sanitizePath)(`${entry.uid}.json`));
|
|
181
|
+
cli_utilities_1.log.debug(`Writing versioned entry to: ${versionFilePath}`, this.exportConfig.context);
|
|
182
|
+
utils_1.fsUtil.writeFile(versionFilePath, response);
|
|
183
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENTRIES_VERSIONED_EXPORT_SUCCESS', options.contentType, entry.uid, options.locale), this.exportConfig.context);
|
|
144
184
|
};
|
|
145
185
|
const onReject = ({ error, apiData: { uid } = undefined }) => {
|
|
146
|
-
|
|
147
|
-
(0,
|
|
186
|
+
cli_utilities_1.log.debug(`Failed to fetch versioned entry for uid: ${uid}`, this.exportConfig.context);
|
|
187
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.exportConfig.context), { uid }), cli_utilities_1.messageHandler.parse('ENTRIES_EXPORT_VERSIONS_FAILED', uid));
|
|
148
188
|
};
|
|
189
|
+
cli_utilities_1.log.debug(`Starting concurrent calls for versioned entries with batch limit: ${this.entriesConfig.batchLimit}`, this.exportConfig.context);
|
|
149
190
|
return await this.makeConcurrentCall({
|
|
150
191
|
apiBatches: [entries],
|
|
151
192
|
module: 'versioned-entries',
|
|
@@ -160,9 +201,11 @@ class EntriesExport extends base_class_1.default {
|
|
|
160
201
|
}, this.entryVersionHandler.bind(this));
|
|
161
202
|
}
|
|
162
203
|
async entryVersionHandler({ apiParams, element: entry, }) {
|
|
204
|
+
cli_utilities_1.log.debug(`Processing versioned entry: ${entry.uid}`, this.exportConfig.context);
|
|
163
205
|
return new Promise(async (resolve, reject) => {
|
|
164
206
|
return await this.getEntryByVersion(apiParams.queryParam, entry)
|
|
165
207
|
.then((response) => {
|
|
208
|
+
cli_utilities_1.log.debug(`Successfully fetched versions for entry: ${entry.uid}`, this.exportConfig.context);
|
|
166
209
|
apiParams.resolve({
|
|
167
210
|
response,
|
|
168
211
|
apiData: entry,
|
|
@@ -170,6 +213,7 @@ class EntriesExport extends base_class_1.default {
|
|
|
170
213
|
resolve(true);
|
|
171
214
|
})
|
|
172
215
|
.catch((error) => {
|
|
216
|
+
cli_utilities_1.log.debug(`Failed to fetch versions for entry: ${entry.uid}`, this.exportConfig.context);
|
|
173
217
|
apiParams.reject({
|
|
174
218
|
error,
|
|
175
219
|
apiData: entry,
|
|
@@ -186,14 +230,17 @@ class EntriesExport extends base_class_1.default {
|
|
|
186
230
|
},
|
|
187
231
|
version: entry._version,
|
|
188
232
|
};
|
|
233
|
+
cli_utilities_1.log.debug(`Fetching entry version ${entry._version} for uid: ${entry.uid}`, this.exportConfig.context);
|
|
189
234
|
const entryResponse = await this.stackAPIClient
|
|
190
235
|
.contentType(options.contentType)
|
|
191
236
|
.entry(entry.uid)
|
|
192
237
|
.fetch(queryRequestObject);
|
|
193
238
|
entries.push(entryResponse);
|
|
194
239
|
if (--entry._version > 0) {
|
|
240
|
+
cli_utilities_1.log.debug(`Continuing to fetch previous version ${entry._version} for entry: ${entry.uid}`, this.exportConfig.context);
|
|
195
241
|
return await this.getEntryByVersion(options, entry, entries);
|
|
196
242
|
}
|
|
243
|
+
cli_utilities_1.log.debug(`Completed fetching all versions for entry: ${entry.uid}, total versions: ${entries.length}`, this.exportConfig.context);
|
|
197
244
|
return entries;
|
|
198
245
|
}
|
|
199
246
|
}
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
6
6
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
7
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
8
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
class ExportEnvironments extends base_class_1.default {
|
|
@@ -12,52 +13,73 @@ class ExportEnvironments extends base_class_1.default {
|
|
|
12
13
|
this.environments = {};
|
|
13
14
|
this.environmentConfig = exportConfig.modules.environments;
|
|
14
15
|
this.qs = { include_count: true };
|
|
16
|
+
this.exportConfig.context.module = 'environments';
|
|
15
17
|
}
|
|
16
18
|
async start() {
|
|
17
|
-
|
|
19
|
+
cli_utilities_1.log.debug('Starting environment export process...', this.exportConfig.context);
|
|
18
20
|
this.environmentsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.environmentConfig.dirName);
|
|
21
|
+
cli_utilities_1.log.debug(`Environments folder path: ${this.environmentsFolderPath}`, this.exportConfig.context);
|
|
19
22
|
await utils_1.fsUtil.makeDirectory(this.environmentsFolderPath);
|
|
23
|
+
cli_utilities_1.log.debug('Created environments directory', this.exportConfig.context);
|
|
20
24
|
await this.getEnvironments();
|
|
25
|
+
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.environments).length} environments`, this.exportConfig.context);
|
|
21
26
|
if (this.environments === undefined || (0, isEmpty_1.default)(this.environments)) {
|
|
22
|
-
|
|
27
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('ENVIRONMENT_NOT_FOUND'), this.exportConfig.context);
|
|
23
28
|
}
|
|
24
29
|
else {
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
const environmentsFilePath = (0, node_path_1.resolve)(this.environmentsFolderPath, this.environmentConfig.fileName);
|
|
31
|
+
cli_utilities_1.log.debug(`Writing environments to: ${environmentsFilePath}`, this.exportConfig.context);
|
|
32
|
+
utils_1.fsUtil.writeFile(environmentsFilePath, this.environments);
|
|
33
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENVIRONMENT_EXPORT_COMPLETE', Object.keys(this.environments).length), this.exportConfig.context);
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
async getEnvironments(skip = 0) {
|
|
30
37
|
if (skip) {
|
|
31
38
|
this.qs.skip = skip;
|
|
39
|
+
cli_utilities_1.log.debug(`Fetching environments with skip: ${skip}`, this.exportConfig.context);
|
|
32
40
|
}
|
|
41
|
+
else {
|
|
42
|
+
cli_utilities_1.log.debug('Fetching environments with initial query', this.exportConfig.context);
|
|
43
|
+
}
|
|
44
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context);
|
|
33
45
|
await this.stack
|
|
34
46
|
.environment()
|
|
35
47
|
.query(this.qs)
|
|
36
48
|
.find()
|
|
37
49
|
.then(async (data) => {
|
|
38
50
|
const { items, count } = data;
|
|
51
|
+
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} environments out of total ${count}`, this.exportConfig.context);
|
|
39
52
|
if (items === null || items === void 0 ? void 0 : items.length) {
|
|
53
|
+
cli_utilities_1.log.debug(`Processing ${items.length} environments`, this.exportConfig.context);
|
|
40
54
|
this.sanitizeAttribs(items);
|
|
41
55
|
skip += this.environmentConfig.limit || 100;
|
|
42
56
|
if (skip >= count) {
|
|
57
|
+
cli_utilities_1.log.debug('Completed fetching all environments', this.exportConfig.context);
|
|
43
58
|
return;
|
|
44
59
|
}
|
|
60
|
+
cli_utilities_1.log.debug(`Continuing to fetch environments with skip: ${skip}`, this.exportConfig.context);
|
|
45
61
|
return await this.getEnvironments(skip);
|
|
46
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
cli_utilities_1.log.debug('No environments found to process', this.exportConfig.context);
|
|
65
|
+
}
|
|
47
66
|
})
|
|
48
67
|
.catch((error) => {
|
|
49
|
-
|
|
50
|
-
(0,
|
|
68
|
+
cli_utilities_1.log.debug('Error occurred while fetching environments', this.exportConfig.context);
|
|
69
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
51
70
|
});
|
|
52
71
|
}
|
|
53
72
|
sanitizeAttribs(environments) {
|
|
54
73
|
var _a;
|
|
74
|
+
cli_utilities_1.log.debug(`Sanitizing ${environments.length} environments`, this.exportConfig.context);
|
|
55
75
|
for (let index = 0; index < (environments === null || environments === void 0 ? void 0 : environments.length); index++) {
|
|
56
76
|
const extUid = environments[index].uid;
|
|
57
77
|
const envName = (_a = environments[index]) === null || _a === void 0 ? void 0 : _a.name;
|
|
78
|
+
cli_utilities_1.log.debug(`Processing environment: ${envName} (${extUid})`, this.exportConfig.context);
|
|
58
79
|
this.environments[extUid] = (0, omit_1.default)(environments[index], ['ACL']);
|
|
59
|
-
|
|
80
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('ENVIRONMENT_EXPORT_SUCCESS', envName), this.exportConfig.context);
|
|
60
81
|
}
|
|
82
|
+
cli_utilities_1.log.debug(`Sanitization complete. Total environments processed: ${Object.keys(this.environments).length}`, this.exportConfig.context);
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
exports.default = ExportEnvironments;
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
5
5
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
8
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
class ExportExtensions extends base_class_1.default {
|
|
@@ -12,52 +13,74 @@ class ExportExtensions extends base_class_1.default {
|
|
|
12
13
|
this.extensions = {};
|
|
13
14
|
this.extensionConfig = exportConfig.modules.extensions;
|
|
14
15
|
this.qs = { include_count: true };
|
|
16
|
+
this.applyQueryFilters(this.qs, 'extensions');
|
|
17
|
+
this.exportConfig.context.module = 'extensions';
|
|
15
18
|
}
|
|
16
19
|
async start() {
|
|
17
|
-
|
|
20
|
+
cli_utilities_1.log.debug('Starting extensions export process...', this.exportConfig.context);
|
|
18
21
|
this.extensionsFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.extensionConfig.dirName);
|
|
22
|
+
cli_utilities_1.log.debug(`Extensions folder path: ${this.extensionsFolderPath}`, this.exportConfig.context);
|
|
19
23
|
await utils_1.fsUtil.makeDirectory(this.extensionsFolderPath);
|
|
24
|
+
cli_utilities_1.log.debug('Created extensions directory', this.exportConfig.context);
|
|
20
25
|
await this.getExtensions();
|
|
26
|
+
cli_utilities_1.log.debug(`Retrieved ${Object.keys(this.extensions).length} extensions`, this.exportConfig.context);
|
|
21
27
|
if (this.extensions === undefined || (0, isEmpty_1.default)(this.extensions)) {
|
|
22
|
-
|
|
28
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('EXTENSION_NOT_FOUND'), this.exportConfig.context);
|
|
23
29
|
}
|
|
24
30
|
else {
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const extensionsFilePath = (0, node_path_1.resolve)(this.extensionsFolderPath, this.extensionConfig.fileName);
|
|
32
|
+
cli_utilities_1.log.debug(`Writing extensions to: ${extensionsFilePath}`, this.exportConfig.context);
|
|
33
|
+
utils_1.fsUtil.writeFile(extensionsFilePath, this.extensions);
|
|
34
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('EXTENSION_EXPORT_COMPLETE', Object.keys(this.extensions).length), this.exportConfig.context);
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
async getExtensions(skip = 0) {
|
|
30
38
|
if (skip) {
|
|
31
39
|
this.qs.skip = skip;
|
|
40
|
+
cli_utilities_1.log.debug(`Fetching extensions with skip: ${skip}`, this.exportConfig.context);
|
|
32
41
|
}
|
|
42
|
+
else {
|
|
43
|
+
cli_utilities_1.log.debug('Fetching extensions with initial query', this.exportConfig.context);
|
|
44
|
+
}
|
|
45
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context);
|
|
33
46
|
await this.stack
|
|
34
47
|
.extension()
|
|
35
48
|
.query(this.qs)
|
|
36
49
|
.find()
|
|
37
50
|
.then(async (data) => {
|
|
38
51
|
const { items, count } = data;
|
|
52
|
+
cli_utilities_1.log.debug(`Fetched ${(items === null || items === void 0 ? void 0 : items.length) || 0} extensions out of total ${count}`, this.exportConfig.context);
|
|
39
53
|
if (items === null || items === void 0 ? void 0 : items.length) {
|
|
54
|
+
cli_utilities_1.log.debug(`Processing ${items.length} extensions`, this.exportConfig.context);
|
|
40
55
|
this.sanitizeAttribs(items);
|
|
41
56
|
skip += this.extensionConfig.limit || 100;
|
|
42
57
|
if (skip >= count) {
|
|
58
|
+
cli_utilities_1.log.debug('Completed fetching all extensions', this.exportConfig.context);
|
|
43
59
|
return;
|
|
44
60
|
}
|
|
61
|
+
cli_utilities_1.log.debug(`Continuing to fetch extensions with skip: ${skip}`, this.exportConfig.context);
|
|
45
62
|
return await this.getExtensions(skip);
|
|
46
63
|
}
|
|
64
|
+
else {
|
|
65
|
+
cli_utilities_1.log.debug('No extensions found to process', this.exportConfig.context);
|
|
66
|
+
}
|
|
47
67
|
})
|
|
48
68
|
.catch((error) => {
|
|
49
|
-
|
|
50
|
-
(0,
|
|
69
|
+
cli_utilities_1.log.debug('Error occurred while fetching extensions', this.exportConfig.context);
|
|
70
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
51
71
|
});
|
|
52
72
|
}
|
|
53
73
|
sanitizeAttribs(extensions) {
|
|
54
74
|
var _a;
|
|
75
|
+
cli_utilities_1.log.debug(`Sanitizing ${extensions.length} extensions`, this.exportConfig.context);
|
|
55
76
|
for (let index = 0; index < (extensions === null || extensions === void 0 ? void 0 : extensions.length); index++) {
|
|
56
77
|
const extUid = extensions[index].uid;
|
|
57
78
|
const extTitle = (_a = extensions[index]) === null || _a === void 0 ? void 0 : _a.title;
|
|
79
|
+
cli_utilities_1.log.debug(`Processing extension: ${extTitle} (${extUid})`, this.exportConfig.context);
|
|
58
80
|
this.extensions[extUid] = (0, omit_1.default)(extensions[index], ['SYS_ACL']);
|
|
59
|
-
|
|
81
|
+
cli_utilities_1.log.info(cli_utilities_1.messageHandler.parse('EXTENSION_EXPORT_SUCCESS', extTitle), this.exportConfig.context);
|
|
60
82
|
}
|
|
83
|
+
cli_utilities_1.log.debug(`Sanitization complete. Total extensions processed: ${Object.keys(this.extensions).length}`, this.exportConfig.context);
|
|
61
84
|
}
|
|
62
85
|
}
|
|
63
86
|
exports.default = ExportExtensions;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path = tslib_1.__importStar(require("path"));
|
|
5
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
6
7
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
7
|
-
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
8
|
class GlobalFieldsExport extends base_class_1.default {
|
|
9
9
|
constructor({ exportConfig, stackAPIClient }) {
|
|
10
10
|
super({ exportConfig, stackAPIClient });
|
|
@@ -15,40 +15,59 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
15
15
|
asc: 'updated_at',
|
|
16
16
|
include_count: true,
|
|
17
17
|
limit: this.globalFieldsConfig.limit,
|
|
18
|
-
include_global_field_schema: true
|
|
18
|
+
include_global_field_schema: true,
|
|
19
19
|
};
|
|
20
20
|
this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.globalFieldsConfig.dirName));
|
|
21
21
|
this.globalFields = [];
|
|
22
|
+
this.applyQueryFilters(this.qs, 'global-fields');
|
|
23
|
+
this.exportConfig.context.module = 'global-fields';
|
|
22
24
|
}
|
|
23
25
|
async start() {
|
|
24
26
|
try {
|
|
25
|
-
|
|
27
|
+
cli_utilities_1.log.debug('Starting global fields export process...', this.exportConfig.context);
|
|
28
|
+
cli_utilities_1.log.debug(`Global fields directory path: ${this.globalFieldsDirPath}`, this.exportConfig.context);
|
|
26
29
|
await utils_1.fsUtil.makeDirectory(this.globalFieldsDirPath);
|
|
30
|
+
cli_utilities_1.log.debug('Created global fields directory', this.exportConfig.context);
|
|
27
31
|
await this.getGlobalFields();
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
cli_utilities_1.log.debug(`Retrieved ${this.globalFields.length} global fields`, this.exportConfig.context);
|
|
33
|
+
const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName);
|
|
34
|
+
cli_utilities_1.log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context);
|
|
35
|
+
utils_1.fsUtil.writeFile(globalFieldsFilePath, this.globalFields);
|
|
36
|
+
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('GLOBAL_FIELDS_EXPORT_COMPLETE', this.globalFields.length), this.exportConfig.context);
|
|
30
37
|
}
|
|
31
38
|
catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
cli_utilities_1.log.debug('Error occurred during global fields export', this.exportConfig.context);
|
|
40
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
async getGlobalFields(skip = 0) {
|
|
44
|
+
var _a;
|
|
37
45
|
if (skip) {
|
|
38
46
|
this.qs.skip = skip;
|
|
47
|
+
cli_utilities_1.log.debug(`Fetching global fields with skip: ${skip}`, this.exportConfig.context);
|
|
39
48
|
}
|
|
49
|
+
cli_utilities_1.log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context);
|
|
40
50
|
let globalFieldsFetchResponse = await this.stackAPIClient.globalField({ api_version: '3.2' }).query(this.qs).find();
|
|
51
|
+
cli_utilities_1.log.debug(`Fetched ${((_a = globalFieldsFetchResponse.items) === null || _a === void 0 ? void 0 : _a.length) || 0} global fields out of total ${globalFieldsFetchResponse.count}`, this.exportConfig.context);
|
|
41
52
|
if (Array.isArray(globalFieldsFetchResponse.items) && globalFieldsFetchResponse.items.length > 0) {
|
|
53
|
+
cli_utilities_1.log.debug(`Processing ${globalFieldsFetchResponse.items.length} global fields`, this.exportConfig.context);
|
|
42
54
|
this.sanitizeAttribs(globalFieldsFetchResponse.items);
|
|
43
55
|
skip += this.globalFieldsConfig.limit || 100;
|
|
44
56
|
if (skip >= globalFieldsFetchResponse.count) {
|
|
57
|
+
cli_utilities_1.log.debug('Completed fetching all global fields', this.exportConfig.context);
|
|
45
58
|
return;
|
|
46
59
|
}
|
|
60
|
+
cli_utilities_1.log.debug(`Continuing to fetch global fields with skip: ${skip}`, this.exportConfig.context);
|
|
47
61
|
return await this.getGlobalFields(skip);
|
|
48
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
cli_utilities_1.log.debug('No global fields found to process', this.exportConfig.context);
|
|
65
|
+
}
|
|
49
66
|
}
|
|
50
67
|
sanitizeAttribs(globalFields) {
|
|
68
|
+
cli_utilities_1.log.debug(`Sanitizing ${globalFields.length} global fields`, this.exportConfig.context);
|
|
51
69
|
globalFields.forEach((globalField) => {
|
|
70
|
+
cli_utilities_1.log.debug(`Processing global field: ${globalField.uid || 'unknown'}`, this.exportConfig.context);
|
|
52
71
|
for (let key in globalField) {
|
|
53
72
|
if (this.globalFieldsConfig.validKeys.indexOf(key) === -1) {
|
|
54
73
|
delete globalField[key];
|
|
@@ -56,6 +75,7 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
56
75
|
}
|
|
57
76
|
this.globalFields.push(globalField);
|
|
58
77
|
});
|
|
78
|
+
cli_utilities_1.log.debug(`Sanitization complete. Total global fields processed: ${this.globalFields.length}`, this.exportConfig.context);
|
|
59
79
|
}
|
|
60
80
|
}
|
|
61
81
|
exports.default = GlobalFieldsExport;
|