@contentstack/cli-cm-import 1.28.1 → 2.0.0-beta
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 +5 -7
- package/lib/commands/cm/stacks/import.d.ts +2 -0
- package/lib/commands/cm/stacks/import.js +46 -11
- package/lib/config/index.js +0 -1
- package/lib/import/module-importer.js +6 -20
- package/lib/import/modules/assets.d.ts +6 -0
- package/lib/import/modules/assets.js +102 -25
- package/lib/import/modules/base-class.d.ts +17 -0
- package/lib/import/modules/base-class.js +45 -0
- package/lib/import/modules/content-types.d.ts +7 -10
- package/lib/import/modules/content-types.js +132 -68
- package/lib/import/modules/custom-roles.d.ts +6 -2
- package/lib/import/modules/custom-roles.js +80 -69
- package/lib/import/modules/entries.d.ts +7 -0
- package/lib/import/modules/entries.js +278 -163
- package/lib/import/modules/environments.d.ts +3 -0
- package/lib/import/modules/environments.js +69 -38
- package/lib/import/modules/extensions.d.ts +3 -0
- package/lib/import/modules/extensions.js +99 -64
- package/lib/import/modules/global-fields.d.ts +8 -1
- package/lib/import/modules/global-fields.js +123 -63
- package/lib/import/modules/index.d.ts +1 -0
- package/lib/import/modules/index.js +1 -0
- package/lib/import/modules/labels.d.ts +3 -0
- package/lib/import/modules/labels.js +104 -54
- package/lib/import/modules/locales.d.ts +15 -4
- package/lib/import/modules/locales.js +194 -94
- package/lib/import/modules/marketplace-apps.d.ts +6 -3
- package/lib/import/modules/marketplace-apps.js +177 -102
- package/lib/import/modules/personalize.d.ts +11 -4
- package/lib/import/modules/personalize.js +138 -47
- package/lib/import/modules/stack.d.ts +6 -0
- package/lib/import/modules/stack.js +71 -27
- package/lib/import/modules/taxonomies.d.ts +4 -2
- package/lib/import/modules/taxonomies.js +60 -46
- package/lib/import/modules/variant-entries.d.ts +7 -4
- package/lib/import/modules/variant-entries.js +76 -35
- package/lib/import/modules/webhooks.d.ts +3 -0
- package/lib/import/modules/webhooks.js +71 -40
- package/lib/import/modules/workflows.d.ts +3 -0
- package/lib/import/modules/workflows.js +98 -48
- package/lib/types/default-config.d.ts +0 -1
- package/lib/types/import-config.d.ts +0 -1
- package/lib/types/index.d.ts +1 -12
- package/lib/utils/backup-handler.js +0 -1
- package/lib/utils/constants.d.ts +243 -0
- package/lib/utils/constants.js +264 -0
- package/lib/utils/import-config-handler.js +2 -0
- package/lib/utils/import-path-resolver.js +3 -13
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +6 -2
- package/lib/utils/marketplace-app-helper.js +3 -8
- package/lib/utils/progress-strategy-registry.d.ts +7 -0
- package/lib/utils/progress-strategy-registry.js +72 -0
- package/lib/utils/setup-branch.js +1 -1
- package/oclif.manifest.json +2 -2
- package/package.json +2 -2
- package/lib/import/modules-js/assets.d.ts +0 -33
- package/lib/import/modules-js/assets.js +0 -428
- package/lib/import/modules-js/content-types.d.ts +0 -34
- package/lib/import/modules-js/content-types.js +0 -204
- package/lib/import/modules-js/custom-roles.d.ts +0 -15
- package/lib/import/modules-js/custom-roles.js +0 -143
- package/lib/import/modules-js/entries.d.ts +0 -54
- package/lib/import/modules-js/entries.js +0 -1280
- package/lib/import/modules-js/environments.d.ts +0 -13
- package/lib/import/modules-js/environments.js +0 -85
- package/lib/import/modules-js/extensions.d.ts +0 -18
- package/lib/import/modules-js/extensions.js +0 -86
- package/lib/import/modules-js/global-fields.d.ts +0 -13
- package/lib/import/modules-js/global-fields.js +0 -106
- package/lib/import/modules-js/index.d.ts +0 -1
- package/lib/import/modules-js/index.js +0 -33
- package/lib/import/modules-js/labels.d.ts +0 -20
- package/lib/import/modules-js/labels.js +0 -148
- package/lib/import/modules-js/locales.d.ts +0 -24
- package/lib/import/modules-js/locales.js +0 -196
- package/lib/import/modules-js/marketplace-apps.d.ts +0 -63
- package/lib/import/modules-js/marketplace-apps.js +0 -429
- package/lib/import/modules-js/webhooks.d.ts +0 -17
- package/lib/import/modules-js/webhooks.js +0 -85
- package/lib/import/modules-js/workflows.d.ts +0 -19
- package/lib/import/modules-js/workflows.js +0 -170
- package/lib/utils/log.d.ts +0 -12
- package/lib/utils/log.js +0 -31
|
@@ -17,7 +17,8 @@ class EntriesImport extends base_class_1.default {
|
|
|
17
17
|
constructor({ importConfig, stackAPIClient }) {
|
|
18
18
|
super({ importConfig, stackAPIClient });
|
|
19
19
|
this.entriesForVariant = [];
|
|
20
|
-
this.importConfig.context.module =
|
|
20
|
+
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.ENTRIES;
|
|
21
|
+
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ENTRIES];
|
|
21
22
|
this.assetUidMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), 'mapper', 'assets', 'uid-mapping.json');
|
|
22
23
|
this.assetUrlMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), 'mapper', 'assets', 'url-mapping.json');
|
|
23
24
|
this.entriesMapperPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), 'mapper', 'entries');
|
|
@@ -44,107 +45,207 @@ class EntriesImport extends base_class_1.default {
|
|
|
44
45
|
this.rteCTsWithRef = [];
|
|
45
46
|
}
|
|
46
47
|
async start() {
|
|
47
|
-
var _a;
|
|
48
48
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
cli_utilities_1.log.debug('Starting entries import process...', this.importConfig.context);
|
|
50
|
+
const [contentTypesCount, localesCount, totalEntryChunks, totalActualEntries, totalEntriesForPublishing] = await this.analyzeEntryData();
|
|
51
|
+
if (contentTypesCount === 0) {
|
|
52
|
+
cli_utilities_1.log.info('No content types found for entry import', this.importConfig.context);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
const progress = this.createNestedProgress(this.currentModuleName);
|
|
56
|
+
this.initializeProgress(progress, {
|
|
57
|
+
contentTypesCount,
|
|
58
|
+
localesCount,
|
|
59
|
+
totalEntryChunks,
|
|
60
|
+
totalActualEntries,
|
|
61
|
+
totalEntriesForPublishing,
|
|
62
|
+
});
|
|
63
|
+
// Step 1: Prepare content types
|
|
64
|
+
progress
|
|
65
|
+
.startProcess(utils_1.PROCESS_NAMES.CT_PREPARATION)
|
|
66
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CT_PREPARATION].PREPARING, utils_1.PROCESS_NAMES.CT_PREPARATION);
|
|
65
67
|
await this.disableMandatoryCTReferences();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await this.createEntries(entryRequestOption);
|
|
75
|
-
}
|
|
76
|
-
cli_utilities_1.log.success('Entry creation process completed', this.importConfig.context);
|
|
68
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.CT_PREPARATION, true);
|
|
69
|
+
// Step 2: Create entries
|
|
70
|
+
progress
|
|
71
|
+
.startProcess(utils_1.PROCESS_NAMES.ENTRIES_CREATE)
|
|
72
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.ENTRIES_CREATE].CREATING, utils_1.PROCESS_NAMES.ENTRIES_CREATE);
|
|
73
|
+
await this.processEntryCreation();
|
|
74
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.ENTRIES_CREATE, true);
|
|
75
|
+
// Step 3: Replace existing entries if needed
|
|
77
76
|
if (this.importConfig.replaceExisting) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
cli_utilities_1.log.success('Entry replacement process completed', this.importConfig.context);
|
|
77
|
+
progress
|
|
78
|
+
.startProcess(utils_1.PROCESS_NAMES.ENTRIES_REPLACE_EXISTING)
|
|
79
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.ENTRIES_REPLACE_EXISTING].REPLACING, utils_1.PROCESS_NAMES.ENTRIES_REPLACE_EXISTING);
|
|
80
|
+
await this.processEntryReplacement();
|
|
81
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.ENTRIES_REPLACE_EXISTING, true);
|
|
86
82
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
utils_1.fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries);
|
|
107
|
-
cli_utilities_1.log.success('Entry references update process completed', this.importConfig.context);
|
|
108
|
-
cli_utilities_1.log.info('Restoring content type changes', this.importConfig.context);
|
|
109
|
-
await this.enableMandatoryCTReferences().catch((error) => {
|
|
110
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context), 'Error while updating content type references');
|
|
111
|
-
});
|
|
112
|
-
cli_utilities_1.log.success('Content type references restored successfully', this.importConfig.context);
|
|
113
|
-
// Update field rule of content types which are got removed earlier
|
|
114
|
-
cli_utilities_1.log.info('Updating the field rules of content type', this.importConfig.context);
|
|
115
|
-
await this.updateFieldRules().catch((error) => {
|
|
116
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context), 'Error while updating field rules of content type');
|
|
117
|
-
});
|
|
118
|
-
cli_utilities_1.log.success('Entries imported successfully', this.importConfig.context);
|
|
119
|
-
// Publishing entries
|
|
83
|
+
// Step 4: Update entries with references
|
|
84
|
+
progress
|
|
85
|
+
.startProcess(utils_1.PROCESS_NAMES.REFERENCE_UPDATES)
|
|
86
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.REFERENCE_UPDATES].UPDATING, utils_1.PROCESS_NAMES.REFERENCE_UPDATES);
|
|
87
|
+
await this.processEntryReferenceUpdates();
|
|
88
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.REFERENCE_UPDATES, true);
|
|
89
|
+
// Step 5: Restore content types
|
|
90
|
+
progress
|
|
91
|
+
.startProcess(utils_1.PROCESS_NAMES.CT_RESTORATION)
|
|
92
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CT_RESTORATION].RESTORING, utils_1.PROCESS_NAMES.CT_RESTORATION);
|
|
93
|
+
await this.enableMandatoryCTReferences();
|
|
94
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.CT_RESTORATION, true);
|
|
95
|
+
// Step 6: Update field rules
|
|
96
|
+
progress
|
|
97
|
+
.startProcess(utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE)
|
|
98
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE].UPDATING, utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE);
|
|
99
|
+
await this.updateFieldRules();
|
|
100
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE, true);
|
|
101
|
+
// Step 7: Publish entries if not skipped
|
|
120
102
|
if (!this.importConfig.skipEntriesPublish) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
cli_utilities_1.log.debug(`Loaded ${Object.keys(this.envs).length} environments for publishing`, this.importConfig.context);
|
|
129
|
-
}
|
|
130
|
-
for (let entryRequestOption of entryRequestOptions) {
|
|
131
|
-
await this.publishEntries(entryRequestOption).catch((error) => {
|
|
132
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid: entryRequestOption.cTUid, locale: entryRequestOption.locale }), `Error in publishing entries of ${entryRequestOption.cTUid} in locale ${entryRequestOption.locale}`);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
cli_utilities_1.log.success('All the entries have been published successfully', this.importConfig.context);
|
|
103
|
+
progress
|
|
104
|
+
.startProcess(utils_1.PROCESS_NAMES.ENTRIES_PUBLISH)
|
|
105
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.ENTRIES_PUBLISH].PUBLISHING, utils_1.PROCESS_NAMES.ENTRIES_PUBLISH);
|
|
106
|
+
await this.processEntryPublishing();
|
|
107
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.ENTRIES_PUBLISH, true);
|
|
136
108
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.
|
|
109
|
+
// Step 8: Cleanup and finalization
|
|
110
|
+
progress
|
|
111
|
+
.startProcess(utils_1.PROCESS_NAMES.CLEANUP)
|
|
112
|
+
.updateStatus(utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.CLEANUP].CLEANING, utils_1.PROCESS_NAMES.CLEANUP);
|
|
113
|
+
await this.processCleanup();
|
|
114
|
+
progress.completeProcess(utils_1.PROCESS_NAMES.CLEANUP, true);
|
|
115
|
+
this.completeProgress(true);
|
|
116
|
+
cli_utilities_1.log.success('Entries imported successfully', this.importConfig.context);
|
|
142
117
|
}
|
|
143
118
|
catch (error) {
|
|
144
119
|
this.createEntryDataForVariantEntry();
|
|
120
|
+
this.completeProgress(false, (error === null || error === void 0 ? void 0 : error.message) || 'Entries import failed');
|
|
145
121
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context));
|
|
146
122
|
}
|
|
147
123
|
}
|
|
124
|
+
async analyzeEntryData() {
|
|
125
|
+
return this.withLoadingSpinner('ENTRIES: Analyzing import data...', async () => {
|
|
126
|
+
cli_utilities_1.log.debug('Loading content types for entry analysis', this.importConfig.context);
|
|
127
|
+
this.cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
|
|
128
|
+
if (!this.cTs || (0, lodash_1.isEmpty)(this.cTs)) {
|
|
129
|
+
return [0, 0, 0, 0, 0];
|
|
130
|
+
}
|
|
131
|
+
cli_utilities_1.log.debug('Loading installed extensions for entry processing', this.importConfig.context);
|
|
132
|
+
this.installedExtensions = (utils_1.fsUtil.readFile(this.marketplaceAppMapperPath) || { extension_uid: {} }).extension_uid;
|
|
133
|
+
cli_utilities_1.log.debug('Loading asset mappings', this.importConfig.context);
|
|
134
|
+
this.assetUidMapper = utils_1.fsUtil.readFile(this.assetUidMapperPath) || {};
|
|
135
|
+
this.assetUrlMapper = utils_1.fsUtil.readFile(this.assetUrlMapperPath) || {};
|
|
136
|
+
cli_utilities_1.log.debug('Loading taxonomy data', this.importConfig.context);
|
|
137
|
+
this.taxonomies = utils_1.fsUtil.readFile(this.taxonomiesPath);
|
|
138
|
+
cli_utilities_1.log.debug('Setting up mapper directories', this.importConfig.context);
|
|
139
|
+
utils_1.fsUtil.makeDirectory(this.entriesMapperPath);
|
|
140
|
+
cli_utilities_1.log.debug('Loading locales data', this.importConfig.context);
|
|
141
|
+
this.locales = (0, lodash_1.values)(utils_1.fsUtil.readFile(this.localesPath));
|
|
142
|
+
this.locales.unshift(this.importConfig.master_locale);
|
|
143
|
+
const contentTypesCount = this.cTs.length;
|
|
144
|
+
const localesCount = this.locales.length;
|
|
145
|
+
let totalEntryChunks = 0;
|
|
146
|
+
let totalActualEntries = 0;
|
|
147
|
+
let totalEntriesForPublishing = 0;
|
|
148
|
+
for (let locale of this.locales) {
|
|
149
|
+
for (let contentType of this.cTs) {
|
|
150
|
+
const basePath = path.join(this.entriesPath, contentType.uid, locale.code);
|
|
151
|
+
const fs = new cli_utilities_1.FsUtility({ basePath, indexFileName: 'index.json' });
|
|
152
|
+
const indexer = fs.indexFileContent;
|
|
153
|
+
const chunksInThisCTLocale = (0, lodash_1.values)(indexer).length;
|
|
154
|
+
totalEntryChunks += chunksInThisCTLocale;
|
|
155
|
+
for (const _ in indexer) {
|
|
156
|
+
try {
|
|
157
|
+
const chunk = await fs.readChunkFiles.next();
|
|
158
|
+
if (chunk) {
|
|
159
|
+
const entriesInChunk = (0, lodash_1.values)(chunk).length;
|
|
160
|
+
totalActualEntries += entriesInChunk;
|
|
161
|
+
// Count entries with publish details
|
|
162
|
+
if (!this.importConfig.skipEntriesPublish) {
|
|
163
|
+
const publishableEntries = (0, lodash_1.values)(chunk).filter((entry) => entry.publish_details && entry.publish_details.length > 0);
|
|
164
|
+
totalEntriesForPublishing += publishableEntries.length;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
cli_utilities_1.log.debug(`Error reading chunk for ${contentType.uid}/${locale.code}`, this.importConfig.context);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
cli_utilities_1.log.debug(`Analysis complete: ${contentTypesCount} content types, ${localesCount} locales, ${totalEntryChunks} total chunks, ${totalActualEntries} total entries, ${totalEntriesForPublishing} total publishable entries`, this.importConfig.context);
|
|
175
|
+
return [contentTypesCount, localesCount, totalEntryChunks, totalActualEntries, totalEntriesForPublishing];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
initializeProgress(progress, counts) {
|
|
179
|
+
const { contentTypesCount, totalEntryChunks, totalActualEntries, totalEntriesForPublishing } = counts;
|
|
180
|
+
// Use appropriate counts for each process
|
|
181
|
+
progress.addProcess(utils_1.PROCESS_NAMES.CT_PREPARATION, contentTypesCount);
|
|
182
|
+
progress.addProcess(utils_1.PROCESS_NAMES.ENTRIES_CREATE, totalActualEntries); // Use actual entries
|
|
183
|
+
if (this.importConfig.replaceExisting) {
|
|
184
|
+
progress.addProcess(utils_1.PROCESS_NAMES.ENTRIES_REPLACE_EXISTING, totalActualEntries);
|
|
185
|
+
}
|
|
186
|
+
progress.addProcess(utils_1.PROCESS_NAMES.REFERENCE_UPDATES, totalActualEntries);
|
|
187
|
+
progress.addProcess(utils_1.PROCESS_NAMES.CT_RESTORATION, contentTypesCount);
|
|
188
|
+
progress.addProcess(utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE, 1);
|
|
189
|
+
if (!this.importConfig.skipEntriesPublish) {
|
|
190
|
+
progress.addProcess(utils_1.PROCESS_NAMES.ENTRIES_PUBLISH, totalEntriesForPublishing);
|
|
191
|
+
}
|
|
192
|
+
progress.addProcess(utils_1.PROCESS_NAMES.CLEANUP, 1);
|
|
193
|
+
cli_utilities_1.log.debug(`Initialized progress tracking for ${contentTypesCount} content types`, this.importConfig.context);
|
|
194
|
+
}
|
|
195
|
+
async processEntryCreation() {
|
|
196
|
+
cli_utilities_1.log.info('Starting entry creation process', this.importConfig.context);
|
|
197
|
+
const entryRequestOptions = this.populateEntryCreatePayload();
|
|
198
|
+
cli_utilities_1.log.debug(`Generated ${entryRequestOptions.length} entry creation tasks`, this.importConfig.context);
|
|
199
|
+
for (let entryRequestOption of entryRequestOptions) {
|
|
200
|
+
await this.createEntries(entryRequestOption);
|
|
201
|
+
}
|
|
202
|
+
cli_utilities_1.log.debug('Writing entry UID mappings to file', this.importConfig.context);
|
|
203
|
+
await utils_1.fileHelper.writeLargeFile(path.join(this.entriesMapperPath, 'uid-mapping.json'), this.entriesUidMapper);
|
|
204
|
+
utils_1.fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries);
|
|
205
|
+
}
|
|
206
|
+
async processEntryReplacement() {
|
|
207
|
+
cli_utilities_1.log.info('Starting Replace Existing process', this.importConfig.context);
|
|
208
|
+
const entryRequestOptions = this.populateEntryCreatePayload();
|
|
209
|
+
for (let entryRequestOption of entryRequestOptions) {
|
|
210
|
+
await this.replaceEntries(entryRequestOption).catch((error) => {
|
|
211
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid: entryRequestOption.cTUid, locale: entryRequestOption.locale }), 'Error while replacing existing entries');
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async processEntryReferenceUpdates() {
|
|
216
|
+
cli_utilities_1.log.info('Starting entry references update process', this.importConfig.context);
|
|
217
|
+
const entryUpdateRequestOptions = this.populateEntryUpdatePayload();
|
|
218
|
+
cli_utilities_1.log.debug(`Generated ${entryUpdateRequestOptions.length} entry update tasks`, this.importConfig.context);
|
|
219
|
+
for (let entryUpdateRequestOption of entryUpdateRequestOptions) {
|
|
220
|
+
await this.updateEntriesWithReferences(entryUpdateRequestOption).catch((error) => {
|
|
221
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid: entryUpdateRequestOption.cTUid, locale: entryUpdateRequestOption.locale }), `Error while updating entries references of ${entryUpdateRequestOption.cTUid} in locale ${entryUpdateRequestOption.locale}`);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
utils_1.fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries);
|
|
225
|
+
}
|
|
226
|
+
async processEntryPublishing() {
|
|
227
|
+
cli_utilities_1.log.info('Starting entry publishing process', this.importConfig.context);
|
|
228
|
+
this.envs = utils_1.fileHelper.readFileSync(this.envPath);
|
|
229
|
+
cli_utilities_1.log.debug(`Loaded ${Object.keys(this.envs || {}).length} environments for publishing`, this.importConfig.context);
|
|
230
|
+
const entryRequestOptions = this.populateEntryCreatePayload();
|
|
231
|
+
for (let entryRequestOption of entryRequestOptions) {
|
|
232
|
+
await this.publishEntries(entryRequestOption).catch((error) => {
|
|
233
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid: entryRequestOption.cTUid, locale: entryRequestOption.locale }), `Error in publishing entries of ${entryRequestOption.cTUid} in locale ${entryRequestOption.locale}`);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async processCleanup() {
|
|
238
|
+
var _a, _b;
|
|
239
|
+
if (((_a = this.autoCreatedEntries) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
240
|
+
cli_utilities_1.log.info(`Removing ${this.autoCreatedEntries.length} entries from master language which got created by default`, this.importConfig.context);
|
|
241
|
+
await this.removeAutoCreatedEntries().catch((error) => {
|
|
242
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context), 'Error while removing auto created entries in master locale');
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
cli_utilities_1.log.debug('Creating entry data for variant entries', this.importConfig.context);
|
|
246
|
+
this.createEntryDataForVariantEntry();
|
|
247
|
+
(_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, 'Cleanup completed', null, utils_1.PROCESS_NAMES.CLEANUP);
|
|
248
|
+
}
|
|
148
249
|
/**
|
|
149
250
|
* The function `createEntryDataForVariantEntry` writes the `entriesForVariant` data to a JSON file
|
|
150
251
|
* named `data-for-variant-entry.json`.
|
|
@@ -158,10 +259,14 @@ class EntriesImport extends base_class_1.default {
|
|
|
158
259
|
async disableMandatoryCTReferences() {
|
|
159
260
|
cli_utilities_1.log.debug(`Starting to disable mandatory CT references for ${this.cTs.length} content types`, this.importConfig.context);
|
|
160
261
|
const onSuccess = ({ response: contentType, apiData: { uid } }) => {
|
|
262
|
+
var _a;
|
|
263
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `content type: ${uid}`, null, utils_1.PROCESS_NAMES.CT_PREPARATION);
|
|
161
264
|
cli_utilities_1.log.success(`'${uid}' content type references removed temporarily`, this.importConfig.context);
|
|
162
265
|
cli_utilities_1.log.debug(`Successfully processed content type: '${uid}'`, this.importConfig.context);
|
|
163
266
|
};
|
|
164
267
|
const onReject = ({ error, apiData: { uid } }) => {
|
|
268
|
+
var _a;
|
|
269
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `content type: ${uid}`, (error === null || error === void 0 ? void 0 : error.message) || `${uid} content type references removal failed`, utils_1.PROCESS_NAMES.CT_PREPARATION);
|
|
165
270
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }), `'${uid}' content type references removal failed`);
|
|
166
271
|
};
|
|
167
272
|
return await this.makeConcurrentCall({
|
|
@@ -259,6 +364,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
259
364
|
const indexerCount = (0, lodash_1.values)(indexer).length;
|
|
260
365
|
if (indexerCount === 0) {
|
|
261
366
|
cli_utilities_1.log.debug(`No entries found for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
367
|
+
//this.progressManager?.tick(true, `${cTUid} - ${locale} (no entries)`, null, PROCESS_NAMES.ENTRIES_CREATE);
|
|
262
368
|
return Promise.resolve();
|
|
263
369
|
}
|
|
264
370
|
cli_utilities_1.log.debug(`Starting to create entries for ${cTUid} in locale ${locale} - ${indexerCount} chunks to process`, this.importConfig.context);
|
|
@@ -285,15 +391,16 @@ class EntriesImport extends base_class_1.default {
|
|
|
285
391
|
const contentType = (0, lodash_1.find)(this.cTs, { uid: cTUid });
|
|
286
392
|
cli_utilities_1.log.debug(`Found content type schema for ${cTUid}`, this.importConfig.context);
|
|
287
393
|
const onSuccess = ({ response, apiData: entry, additionalInfo }) => {
|
|
288
|
-
var _a, _b;
|
|
289
|
-
|
|
394
|
+
var _a, _b, _c;
|
|
395
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `${entry === null || entry === void 0 ? void 0 : entry.title} - ${entry === null || entry === void 0 ? void 0 : entry.uid}`, null, utils_1.PROCESS_NAMES.ENTRIES_CREATE);
|
|
396
|
+
if ((_b = additionalInfo[entry.uid]) === null || _b === void 0 ? void 0 : _b.isLocalized) {
|
|
290
397
|
let oldUid = additionalInfo[entry.uid].entryOldUid;
|
|
291
398
|
this.entriesForVariant.push({ content_type: cTUid, entry_uid: oldUid, locale });
|
|
292
399
|
cli_utilities_1.log.info(`Localized entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
293
400
|
cli_utilities_1.log.debug(`Mapped localized entry UID: ${entry.uid} → ${oldUid}`, this.importConfig.context);
|
|
294
401
|
entry.uid = oldUid;
|
|
295
402
|
entry.entryOldUid = oldUid;
|
|
296
|
-
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
403
|
+
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
297
404
|
entriesCreateFileHelper.writeIntoFile({ [oldUid]: entry }, { mapKeyVal: true });
|
|
298
405
|
}
|
|
299
406
|
else {
|
|
@@ -304,28 +411,27 @@ class EntriesImport extends base_class_1.default {
|
|
|
304
411
|
// For example : To create entry1 in fr-fr, where en-us is the master locale
|
|
305
412
|
// entry1 will get created in en-us first, then fr-fr version will be created
|
|
306
413
|
// thus entry1 has to be removed from en-us at the end.
|
|
307
|
-
if (!isMasterLocale && !((
|
|
414
|
+
if (!isMasterLocale && !((_c = additionalInfo[entry.uid]) === null || _c === void 0 ? void 0 : _c.isLocalized)) {
|
|
308
415
|
this.autoCreatedEntries.push({ cTUid, locale, entryUid: response.uid });
|
|
309
416
|
cli_utilities_1.log.debug(`Marked entry for auto-cleanup: ${response.uid} in master locale`, this.importConfig.context);
|
|
310
417
|
}
|
|
311
418
|
this.entriesUidMapper[entry.uid] = response.uid;
|
|
312
|
-
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
313
|
-
entry.entryOldUid = entry.uid;
|
|
419
|
+
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
420
|
+
entry.entryOldUid = entry.uid;
|
|
314
421
|
entriesCreateFileHelper.writeIntoFile({ [entry.uid]: entry }, { mapKeyVal: true });
|
|
315
422
|
}
|
|
316
423
|
};
|
|
317
424
|
const onReject = ({ error, apiData: entry, additionalInfo }) => {
|
|
318
|
-
var _a, _b;
|
|
425
|
+
var _a, _b, _c;
|
|
319
426
|
const { title, uid } = entry;
|
|
320
|
-
|
|
427
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `${title} - ${uid}`, `Error while creating entry title '${title}'`, utils_1.PROCESS_NAMES.ENTRIES_CREATE);
|
|
321
428
|
this.entriesForVariant = this.entriesForVariant.filter((item) => !(item.locale === locale && item.entry_uid === uid));
|
|
322
429
|
cli_utilities_1.log.debug(`Removed failed entry from variant list: ${uid}`, this.importConfig.context);
|
|
323
|
-
// NOTE: write existing entries into files to handler later
|
|
324
430
|
if (error.errorCode === 119) {
|
|
325
|
-
if (((
|
|
431
|
+
if (((_b = error === null || error === void 0 ? void 0 : error.errors) === null || _b === void 0 ? void 0 : _b.title) || ((_c = error === null || error === void 0 ? void 0 : error.errors) === null || _c === void 0 ? void 0 : _c.uid)) {
|
|
326
432
|
if (this.importConfig.replaceExisting) {
|
|
327
433
|
entry.entryOldUid = uid;
|
|
328
|
-
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
434
|
+
entry.sourceEntryFilePath = path.join((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(additionalInfo.entryFileName));
|
|
329
435
|
existingEntriesFileHelper.writeIntoFile({ [uid]: entry }, { mapKeyVal: true });
|
|
330
436
|
cli_utilities_1.log.debug(`Queued existing entry for replacement: ${title} (${uid})`, this.importConfig.context);
|
|
331
437
|
}
|
|
@@ -365,13 +471,12 @@ class EntriesImport extends base_class_1.default {
|
|
|
365
471
|
additionalInfo: { contentType, locale, cTUid, entryFileName: indexer[index], isMasterLocale },
|
|
366
472
|
},
|
|
367
473
|
concurrencyLimit: this.importConcurrency,
|
|
368
|
-
}).then(() => {
|
|
369
|
-
entriesCreateFileHelper === null || entriesCreateFileHelper === void 0 ? void 0 : entriesCreateFileHelper.completeFile(true);
|
|
370
|
-
existingEntriesFileHelper === null || existingEntriesFileHelper === void 0 ? void 0 : existingEntriesFileHelper.completeFile(true);
|
|
371
|
-
cli_utilities_1.log.success(`Created entries for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
372
474
|
});
|
|
373
475
|
}
|
|
374
476
|
}
|
|
477
|
+
entriesCreateFileHelper === null || entriesCreateFileHelper === void 0 ? void 0 : entriesCreateFileHelper.completeFile(true);
|
|
478
|
+
existingEntriesFileHelper === null || existingEntriesFileHelper === void 0 ? void 0 : existingEntriesFileHelper.completeFile(true);
|
|
479
|
+
cli_utilities_1.log.success(`Created entries for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
375
480
|
}
|
|
376
481
|
/**
|
|
377
482
|
* @method serializeEntries
|
|
@@ -490,10 +595,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
490
595
|
additionalInfo: { contentType, locale, cTUid },
|
|
491
596
|
},
|
|
492
597
|
concurrencyLimit: this.importConcurrency,
|
|
493
|
-
}, this.replaceEntriesHandler.bind(this))
|
|
494
|
-
entriesReplaceFileHelper === null || entriesReplaceFileHelper === void 0 ? void 0 : entriesReplaceFileHelper.completeFile(true);
|
|
495
|
-
cli_utilities_1.log.success(`Replaced entries for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
496
|
-
});
|
|
598
|
+
}, this.replaceEntriesHandler.bind(this));
|
|
497
599
|
}
|
|
498
600
|
}
|
|
499
601
|
}
|
|
@@ -573,10 +675,13 @@ class EntriesImport extends base_class_1.default {
|
|
|
573
675
|
const contentType = (0, lodash_1.find)(this.cTs, { uid: cTUid });
|
|
574
676
|
cli_utilities_1.log.debug(`Found content type schema for reference updates: ${cTUid}`, this.importConfig.context);
|
|
575
677
|
const onSuccess = ({ response, apiData: { uid, url, title } }) => {
|
|
678
|
+
var _a;
|
|
576
679
|
cli_utilities_1.log.info(`Updated entry: '${title}' of content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
577
680
|
cli_utilities_1.log.debug(`Updated entry references for: ${uid}`, this.importConfig.context);
|
|
681
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `${title} - ${uid}`, null, utils_1.PROCESS_NAMES.REFERENCE_UPDATES);
|
|
578
682
|
};
|
|
579
683
|
const onReject = ({ error, apiData: { uid, title } }) => {
|
|
684
|
+
var _a;
|
|
580
685
|
// NOTE Remove from list if any entry import failed
|
|
581
686
|
this.entriesForVariant = this.entriesForVariant.filter((item) => !(item.locale === locale && item.entry_uid === uid));
|
|
582
687
|
cli_utilities_1.log.debug(`Removed failed reference update entry from variant list: ${uid}`, this.importConfig.context);
|
|
@@ -587,6 +692,7 @@ class EntriesImport extends base_class_1.default {
|
|
|
587
692
|
entry: { uid: this.entriesUidMapper[uid], title },
|
|
588
693
|
entryId: uid,
|
|
589
694
|
});
|
|
695
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `Entry: '${title}' of content type ${cTUid} in locale ${locale}`, (error === null || error === void 0 ? void 0 : error.message) || `Failed to update references of entry '${uid}'`, utils_1.PROCESS_NAMES.REFERENCE_UPDATES);
|
|
590
696
|
};
|
|
591
697
|
for (const index in indexer) {
|
|
592
698
|
cli_utilities_1.log.debug(`Processing reference update chunk ${index} of ${indexerCount} for ${cTUid} in ${locale}`, this.importConfig.context);
|
|
@@ -610,8 +716,6 @@ class EntriesImport extends base_class_1.default {
|
|
|
610
716
|
additionalInfo: { contentType, locale, cTUid },
|
|
611
717
|
},
|
|
612
718
|
concurrencyLimit: this.importConcurrency,
|
|
613
|
-
}).then(() => {
|
|
614
|
-
cli_utilities_1.log.success(`Updated entries for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
615
719
|
});
|
|
616
720
|
}
|
|
617
721
|
}
|
|
@@ -665,11 +769,14 @@ class EntriesImport extends base_class_1.default {
|
|
|
665
769
|
}
|
|
666
770
|
async enableMandatoryCTReferences() {
|
|
667
771
|
const onSuccess = ({ response: contentType, apiData: { uid } }) => {
|
|
772
|
+
var _a;
|
|
773
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `content type: ${uid}`, null, utils_1.PROCESS_NAMES.CT_RESTORATION);
|
|
668
774
|
cli_utilities_1.log.success(`${uid} content type references updated`, this.importConfig.context);
|
|
669
775
|
};
|
|
670
776
|
const onReject = ({ error, apiData: { uid } }) => {
|
|
671
|
-
|
|
672
|
-
|
|
777
|
+
var _a;
|
|
778
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `content type: ${uid}`, (error === null || error === void 0 ? void 0 : error.message) || `Failed to update references of content type ${uid}`, utils_1.PROCESS_NAMES.CT_RESTORATION);
|
|
779
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { uid }), `Failed to update references of content type ${uid}`);
|
|
673
780
|
};
|
|
674
781
|
return await this.makeConcurrentCall({
|
|
675
782
|
processName: 'Update content type references',
|
|
@@ -727,69 +834,75 @@ class EntriesImport extends base_class_1.default {
|
|
|
727
834
|
});
|
|
728
835
|
}
|
|
729
836
|
async updateFieldRules() {
|
|
730
|
-
var _a, _b, _c;
|
|
837
|
+
var _a, _b, _c, _d, _e;
|
|
731
838
|
let cTsWithFieldRules = (utils_1.fsUtil.readFile(path.join(this.cTsPath + '/field_rules_uid.json')) || []);
|
|
732
839
|
if (!cTsWithFieldRules || (cTsWithFieldRules === null || cTsWithFieldRules === void 0 ? void 0 : cTsWithFieldRules.length) === 0) {
|
|
733
840
|
cli_utilities_1.log.debug('No content types with field rules found to update', this.importConfig.context);
|
|
734
841
|
return;
|
|
735
842
|
}
|
|
736
843
|
cli_utilities_1.log.debug(`Found ${cTsWithFieldRules.length} content types with field rules to update`, this.importConfig.context);
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
844
|
+
try {
|
|
845
|
+
for (let cTUid of cTsWithFieldRules) {
|
|
846
|
+
cli_utilities_1.log.debug(`Processing field rules for content type: ${cTUid}`, this.importConfig.context);
|
|
847
|
+
const cTs = utils_1.fsUtil.readFile(path.join(this.cTsPath, 'schema.json'));
|
|
848
|
+
const contentType = (0, lodash_1.find)(cTs, { uid: cTUid });
|
|
849
|
+
if (contentType.field_rules) {
|
|
850
|
+
cli_utilities_1.log.debug(`Found ${contentType.field_rules.length} field rules for content type: ${cTUid}`, this.importConfig.context);
|
|
851
|
+
const fieldDatatypeMap = {};
|
|
852
|
+
for (let i = 0; i < ((_a = contentType.schema) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
853
|
+
const field = contentType.schema[i].uid;
|
|
854
|
+
fieldDatatypeMap[field] = contentType.schema[i].data_type;
|
|
855
|
+
}
|
|
856
|
+
let fieldRuleLength = (_b = contentType.field_rules) === null || _b === void 0 ? void 0 : _b.length;
|
|
857
|
+
let updatedRulesCount = 0;
|
|
858
|
+
for (let k = 0; k < fieldRuleLength; k++) {
|
|
859
|
+
let fieldRuleConditionLength = (_c = contentType.field_rules[k].conditions) === null || _c === void 0 ? void 0 : _c.length;
|
|
860
|
+
for (let i = 0; i < fieldRuleConditionLength; i++) {
|
|
861
|
+
if (fieldDatatypeMap[contentType.field_rules[k].conditions[i].operand_field] === 'reference') {
|
|
862
|
+
let fieldRulesValue = contentType.field_rules[k].conditions[i].value;
|
|
863
|
+
let fieldRulesArray = fieldRulesValue.split('.');
|
|
864
|
+
let updatedValue = [];
|
|
865
|
+
for (const element of fieldRulesArray) {
|
|
866
|
+
let splittedFieldRulesValue = element;
|
|
867
|
+
if (this.entriesUidMapper.hasOwnProperty(splittedFieldRulesValue)) {
|
|
868
|
+
updatedValue.push(this.entriesUidMapper[splittedFieldRulesValue]);
|
|
869
|
+
cli_utilities_1.log.debug(`Updated field rule reference: ${splittedFieldRulesValue} → ${this.entriesUidMapper[splittedFieldRulesValue]}`, this.importConfig.context);
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
updatedValue.push(element);
|
|
873
|
+
}
|
|
766
874
|
}
|
|
875
|
+
contentType.field_rules[k].conditions[i].value = updatedValue.join('.');
|
|
876
|
+
updatedRulesCount++;
|
|
767
877
|
}
|
|
768
|
-
contentType.field_rules[k].conditions[i].value = updatedValue.join('.');
|
|
769
|
-
updatedRulesCount++;
|
|
770
878
|
}
|
|
771
879
|
}
|
|
880
|
+
cli_utilities_1.log.debug(`Updated ${updatedRulesCount} field rule references for content type: ${cTUid}`, this.importConfig.context);
|
|
881
|
+
const contentTypeResponse = await this.stack
|
|
882
|
+
.contentType(contentType.uid)
|
|
883
|
+
.fetch()
|
|
884
|
+
.catch((error) => {
|
|
885
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid }));
|
|
886
|
+
});
|
|
887
|
+
if (!contentTypeResponse) {
|
|
888
|
+
cli_utilities_1.log.debug(`Skipping field rules update for ${cTUid} - content type not found`, this.importConfig.context);
|
|
889
|
+
continue;
|
|
890
|
+
}
|
|
891
|
+
contentTypeResponse.field_rules = contentType.field_rules;
|
|
892
|
+
await contentTypeResponse.update().catch((error) => {
|
|
893
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid }));
|
|
894
|
+
});
|
|
895
|
+
cli_utilities_1.log.success(`Updated the field rules of ${cTUid}`, this.importConfig.context);
|
|
772
896
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
.contentType(contentType.uid)
|
|
776
|
-
.fetch()
|
|
777
|
-
.catch((error) => {
|
|
778
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid }));
|
|
779
|
-
});
|
|
780
|
-
if (!contentTypeResponse) {
|
|
781
|
-
cli_utilities_1.log.debug(`Skipping field rules update for ${cTUid} - content type not found`, this.importConfig.context);
|
|
782
|
-
continue;
|
|
897
|
+
else {
|
|
898
|
+
cli_utilities_1.log.info(`No field rules found in content type ${cTUid} to update`, this.importConfig.context);
|
|
783
899
|
}
|
|
784
|
-
contentTypeResponse.field_rules = contentType.field_rules;
|
|
785
|
-
await contentTypeResponse.update().catch((error) => {
|
|
786
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid }));
|
|
787
|
-
});
|
|
788
|
-
cli_utilities_1.log.success(`Updated the field rules of ${cTUid}`, this.importConfig.context);
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
cli_utilities_1.log.info(`No field rules found in content type ${cTUid} to update`, this.importConfig.context);
|
|
792
900
|
}
|
|
901
|
+
(_d = this.progressManager) === null || _d === void 0 ? void 0 : _d.tick(true, `Updated field rules for ${cTsWithFieldRules.length} content types`, null, utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE);
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
(_e = this.progressManager) === null || _e === void 0 ? void 0 : _e.tick(false, 'Field rules update', (error === null || error === void 0 ? void 0 : error.message) || 'Field rules update failed', utils_1.PROCESS_NAMES.FIELD_RULES_UPDATE);
|
|
905
|
+
throw error;
|
|
793
906
|
}
|
|
794
907
|
}
|
|
795
908
|
async publishEntries({ cTUid, locale }) {
|
|
@@ -806,11 +919,15 @@ class EntriesImport extends base_class_1.default {
|
|
|
806
919
|
}
|
|
807
920
|
cli_utilities_1.log.debug(`Starting to publish entries for ${cTUid} in locale ${locale} - ${indexerCount} chunks to process`, this.importConfig.context);
|
|
808
921
|
const onSuccess = ({ response, apiData: { environments, entryUid, locales }, additionalInfo }) => {
|
|
922
|
+
var _a;
|
|
809
923
|
cli_utilities_1.log.success(`Published the entry: '${entryUid}' of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments === null || environments === void 0 ? void 0 : environments.join(',')}' and Locales '${locales === null || locales === void 0 ? void 0 : locales.join(',')}'`, this.importConfig.context);
|
|
810
924
|
cli_utilities_1.log.debug(`Published entry ${entryUid} to ${(environments === null || environments === void 0 ? void 0 : environments.length) || 0} environments and ${(locales === null || locales === void 0 ? void 0 : locales.length) || 0} locales`, this.importConfig.context);
|
|
925
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `Published the entry: '${entryUid}' of Content Type '${cTUid}' and Locale '${locale}`, null, utils_1.PROCESS_NAMES.ENTRIES_PUBLISH);
|
|
811
926
|
};
|
|
812
927
|
const onReject = ({ error, apiData: { environments, entryUid, locales }, additionalInfo }) => {
|
|
928
|
+
var _a;
|
|
813
929
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { cTUid, locale }), `Failed to publish: '${entryUid}' entry of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments === null || environments === void 0 ? void 0 : environments.join(',')}' and Locales '${locales === null || locales === void 0 ? void 0 : locales.join(',')}'`);
|
|
930
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, `Failed to publish: '${entryUid}' entry of Content Type '${cTUid}' and Locale '${locale}'`, `Failed to publish: '${entryUid}' entry of Content Type '${cTUid}' and Locale '${locale}'`, utils_1.PROCESS_NAMES.ENTRIES_PUBLISH);
|
|
814
931
|
};
|
|
815
932
|
for (const index in indexer) {
|
|
816
933
|
cli_utilities_1.log.debug(`Processing publish chunk ${index} of ${indexerCount} for ${cTUid} in ${locale}`, this.importConfig.context);
|
|
@@ -848,8 +965,6 @@ class EntriesImport extends base_class_1.default {
|
|
|
848
965
|
additionalInfo: { contentType, locale, cTUid },
|
|
849
966
|
},
|
|
850
967
|
concurrencyLimit: this.importConcurrency,
|
|
851
|
-
}).then(() => {
|
|
852
|
-
cli_utilities_1.log.success(`Published entries for content type ${cTUid} in locale ${locale}`, this.importConfig.context);
|
|
853
968
|
});
|
|
854
969
|
}
|
|
855
970
|
}
|