@contentstack/cli-cm-bulk-publish 1.5.0 → 1.7.0

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.
@@ -15,6 +15,8 @@ const assetQueue = getQueue();
15
15
  const { Command } = require('@contentstack/cli-command');
16
16
  const command = new Command();
17
17
  const { isEmpty } = require('../util');
18
+ const { fetchBulkPublishLimit } = require('../util/common-utility');
19
+ const VARIANTS_PUBLISH_API_VERSION = '3.2';
18
20
 
19
21
  let bulkPublishSet = [];
20
22
  let bulkPublishAssetSet = [];
@@ -33,23 +35,33 @@ function getQueryParams(filter) {
33
35
  return queryString;
34
36
  }
35
37
 
36
- async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion) {
38
+ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit, variantsFlag = false) {
37
39
  return new Promise(async (resolve) => {
38
40
  for (let index = 0; index < items.length; index++) {
39
41
  changedFlag = true;
40
42
 
41
43
  if (bulkPublish) {
42
- if (bulkPublishSet.length < 10 && items[index].type === 'entry_published') {
43
- bulkPublishSet.push({
44
+ if (bulkPublishSet.length < bulkPublishLimit && items[index].type === 'entry_published') {
45
+ const entry = {
44
46
  uid: items[index].data.uid,
45
47
  content_type: items[index].content_type_uid,
46
48
  locale: items[index].data.locale || 'en-us',
47
49
  version: items[index].data._version,
48
50
  publish_details: [items[index].data.publish_details] || [],
49
- });
51
+ };
52
+
53
+ if (variantsFlag && Array.isArray(items[index].data.variants) && items[index].data.variants.length > 0) {
54
+ entry.variants = items[index].data.variants || [];
55
+ entry.variant_rules = {
56
+ publish_latest_base: false,
57
+ publish_latest_base_conditionally: true
58
+ };
59
+ }
60
+
61
+ bulkPublishSet.push(JSON.parse(JSON.stringify(entry)));
50
62
  }
51
63
 
52
- if (bulkPublishAssetSet.length < 10 && items[index].type === 'asset_published') {
64
+ if (bulkPublishAssetSet.length < bulkPublishLimit && items[index].type === 'asset_published') {
53
65
  bulkPublishAssetSet.push({
54
66
  uid: items[index].data.uid,
55
67
  version: items[index].data._version,
@@ -57,7 +69,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
57
69
  });
58
70
  }
59
71
 
60
- if (bulkPublishAssetSet.length === 10) {
72
+ if (bulkPublishAssetSet.length === bulkPublishLimit) {
61
73
  await queue.Enqueue({
62
74
  assets: bulkPublishAssetSet,
63
75
  Type: 'asset',
@@ -69,7 +81,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
69
81
  bulkPublishAssetSet = [];
70
82
  }
71
83
 
72
- if (bulkPublishSet.length === 10) {
84
+ if (bulkPublishSet.length === bulkPublishLimit) {
73
85
  await queue.Enqueue({
74
86
  entries: bulkPublishSet,
75
87
  locale: filter.locale,
@@ -81,7 +93,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
81
93
  bulkPublishSet = [];
82
94
  }
83
95
 
84
- if (index === items.length - 1 && bulkPublishAssetSet.length <= 10 && bulkPublishAssetSet.length > 0) {
96
+ if (index === items.length - 1 && bulkPublishAssetSet.length <= bulkPublishLimit && bulkPublishAssetSet.length > 0) {
85
97
  await queue.Enqueue({
86
98
  assets: bulkPublishAssetSet,
87
99
  Type: 'asset',
@@ -93,7 +105,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
93
105
  bulkPublishAssetSet = [];
94
106
  }
95
107
 
96
- if (index === items.length - 1 && bulkPublishSet.length <= 10 && bulkPublishSet.length > 0) {
108
+ if (index === items.length - 1 && bulkPublishSet.length <= bulkPublishLimit && bulkPublishSet.length > 0) {
97
109
  await queue.Enqueue({
98
110
  entries: bulkPublishSet,
99
111
  locale: filter.locale,
@@ -143,6 +155,8 @@ async function getSyncEntries(
143
155
  deliveryToken,
144
156
  destEnv,
145
157
  apiVersion,
158
+ bulkPublishLimit,
159
+ variantsFlag = false,
146
160
  paginationToken = null,
147
161
  ) {
148
162
  return new Promise(async (resolve, reject) => {
@@ -198,8 +212,19 @@ async function getSyncEntries(
198
212
  );
199
213
  }
200
214
 
215
+ if (variantsFlag) {
216
+ for (let index = 0; index < entriesResponse?.items?.length; index++) {
217
+ let variants = [];
218
+ const entries = entriesResponse.items[index];
219
+ variants = await getVariantEntries(stack, entries.content_type_uid, entriesResponse, index, queryParamsObj);
220
+ if (variants.length > 0) {
221
+ entriesResponse.items[index].data.variants = variants;
222
+ }
223
+ }
224
+ }
225
+
201
226
  if (entriesResponse.items.length > 0) {
202
- await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion);
227
+ await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit, variantsFlag);
203
228
  }
204
229
  if (!entriesResponse.pagination_token) {
205
230
  if (!changedFlag) console.log('No Entries/Assets Found published on specified environment');
@@ -215,6 +240,7 @@ async function getSyncEntries(
215
240
  deliveryToken,
216
241
  destEnv,
217
242
  apiVersion,
243
+ bulkPublishLimit,
218
244
  entriesResponse.pagination_token,
219
245
  );
220
246
  }, 3000);
@@ -241,6 +267,48 @@ function setConfig(conf, bp) {
241
267
  filePath = initializeLogger(logFileName);
242
268
  }
243
269
 
270
+ async function getVariantEntries(stack, contentType, entries, index, queryParams, skip = 0) {
271
+ try {
272
+ let variantQueryParams = {
273
+ locale: queryParams.locale || 'en-us',
274
+ include_count: true,
275
+ skip: skip, // Adding skip parameter for pagination
276
+ limit: 100, // Set a limit to fetch up to 100 entries per request
277
+ };
278
+ const entryUid = entries.items[index].data.uid
279
+ const variantsEntriesResponse = await stack
280
+ .contentType(contentType)
281
+ .entry(entryUid)
282
+ .variants()
283
+ .query(variantQueryParams)
284
+ .find();
285
+
286
+ const variants = variantsEntriesResponse.items.map((entry) => ({
287
+ uid: entry.variants._variant._uid,
288
+ }));
289
+
290
+ if (variantsEntriesResponse.items.length === variantQueryParams.limit) {
291
+ const nextVariants = await getVariantEntries(
292
+ stack,
293
+ contentType,
294
+ entries,
295
+ index,
296
+ queryParams,
297
+ skip + variantQueryParams.limit,
298
+ );
299
+ return Array.isArray(nextVariants) ? variants.concat(nextVariants) : variants;
300
+ }
301
+ return variants;
302
+ } catch (error) {
303
+ const errorMessage =
304
+ error?.errorMessage ||
305
+ error?.message ||
306
+ error?.errors ||
307
+ 'Falied to fetch the variant entries, Please contact the admin for support.';
308
+ throw new Error(`Error fetching variants: ${errorMessage}`);
309
+ }
310
+ }
311
+
244
312
  async function start(
245
313
  {
246
314
  retryFailed,
@@ -255,6 +323,7 @@ async function start(
255
323
  destEnv,
256
324
  f_types,
257
325
  apiVersion,
326
+ includeVariants,
258
327
  },
259
328
  stack,
260
329
  config,
@@ -306,7 +375,21 @@ async function start(
306
375
  setConfig(config, bulkPublish);
307
376
  // filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
308
377
  const queryParams = getQueryParams(filter);
309
- await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv, apiVersion);
378
+ const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid);
379
+ if (includeVariants) {
380
+ apiVersion = VARIANTS_PUBLISH_API_VERSION;
381
+ }
382
+ await getSyncEntries(
383
+ stack,
384
+ config,
385
+ queryParams,
386
+ bulkPublish,
387
+ filter,
388
+ deliveryToken,
389
+ destEnv,
390
+ apiVersion, bulkPublishLimit,
391
+ includeVariants,
392
+ );
310
393
  }
311
394
  }
312
395
 
@@ -12,6 +12,7 @@ const { performBulkPublish, publishEntry, initializeLogger } = require('../consu
12
12
  const retryFailedLogs = require('../util/retryfailed');
13
13
  const { validateFile } = require('../util/fs');
14
14
  const { isEmpty } = require('../util');
15
+ const { fetchBulkPublishLimit } = require('../util/common-utility');
15
16
 
16
17
  let changedFlag = false;
17
18
  const queue = getQueue();
@@ -226,6 +227,7 @@ async function getEntries(
226
227
  environments,
227
228
  sourceEnv,
228
229
  apiVersion,
230
+ bulkPublishLimit,
229
231
  skip = 0,
230
232
  ) {
231
233
  return new Promise((resolve, reject) => {
@@ -253,7 +255,7 @@ async function getEntries(
253
255
  localizedEntry = localizedEntry || {};
254
256
  if (checkNonLocalizedFieldChanges(schema, entry, localizedEntry)) {
255
257
  if (bulkPublish) {
256
- if (bulkPublishSet.length < 10) {
258
+ if (bulkPublishSet.length < bulkPublishLimit) {
257
259
  bulkPublishSet.push({
258
260
  uid: entry.uid,
259
261
  content_type: contentType,
@@ -261,7 +263,7 @@ async function getEntries(
261
263
  publish_details: localizedEntry.publish_details || [],
262
264
  });
263
265
  }
264
- if (bulkPublishSet.length === 10) {
266
+ if (bulkPublishSet.length === bulkPublishLimit) {
265
267
  await queue.Enqueue({
266
268
  entries: bulkPublishSet,
267
269
  locale: locale.code,
@@ -293,7 +295,7 @@ async function getEntries(
293
295
  reject(error);
294
296
  }
295
297
  }
296
- if (bulkPublishSet.length > 0 && bulkPublishSet.length < 10) {
298
+ if (bulkPublishSet.length > 0 && bulkPublishSet.length < bulkPublishLimit) {
297
299
  await queue.Enqueue({
298
300
  entries: bulkPublishSet,
299
301
  locale: locale.code,
@@ -311,7 +313,7 @@ async function getEntries(
311
313
  bulkPublishSet = [];
312
314
  return resolve();
313
315
  }
314
- await getEntries(stack, schema, contentType, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion, skipCount);
316
+ await getEntries(stack, schema, contentType, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion, bulkPublishLimit, skipCount);
315
317
  return resolve();
316
318
  })
317
319
  .catch((error) => reject(error));
@@ -363,10 +365,11 @@ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, enviro
363
365
  setConfig(config, bulkPublish);
364
366
  const masterLocale = 'en-us';
365
367
  const languages = await getLanguages(stack);
368
+ const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid);
366
369
  for (const element of contentTypes) {
367
370
  /* eslint-disable no-await-in-loop */
368
371
  const schema = await getContentTypeSchema(stack, element);
369
- await getEntries(stack, schema, element, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion);
372
+ await getEntries(stack, schema, element, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion, bulkPublishLimit);
370
373
  /* eslint-enable no-await-in-loop */
371
374
  }
372
375
  }
@@ -10,6 +10,7 @@ const retryFailedLogs = require('../util/retryfailed');
10
10
  const { validateFile } = require('../util/fs');
11
11
  const { setDelayForBulkPublish } = require('../util');
12
12
  const { isEmpty } = require('../util');
13
+ const { fetchBulkPublishLimit } = require('../util/common-utility');
13
14
 
14
15
  let skipCount;
15
16
  const queue = getQueue();
@@ -30,7 +31,7 @@ async function getEnvironment(stack, environmentName) {
30
31
  });
31
32
  }
32
33
 
33
- async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skip = 0) {
34
+ async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, bulkPublishLimit, skip = 0) {
34
35
  return new Promise((resolve, reject) => {
35
36
  skipCount = skip;
36
37
 
@@ -57,7 +58,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
57
58
  if (publishedEntry && publishedEntry.version < entries[index]._version) {
58
59
  changedFlag = true;
59
60
  if (bulkPublish) {
60
- if (bulkPublishSet.length < 10) {
61
+ if (bulkPublishSet.length < bulkPublishLimit) {
61
62
  bulkPublishSet.push({
62
63
  uid: entries[index].uid,
63
64
  content_type: contentType,
@@ -77,7 +78,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
77
78
  });
78
79
  }
79
80
  }
80
- if (bulkPublishSet.length === 10) {
81
+ if (bulkPublishSet.length === bulkPublishLimit) {
81
82
  await queue.Enqueue({
82
83
  entries: bulkPublishSet,
83
84
  locale,
@@ -91,7 +92,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
91
92
  if (
92
93
  index === responseEntries.items.length - 1 &&
93
94
  bulkPublishSet.length > 0 &&
94
- bulkPublishSet.length <= 10
95
+ bulkPublishSet.length <= bulkPublishLimit
95
96
  ) {
96
97
  await queue.Enqueue({
97
98
  entries: bulkPublishSet,
@@ -162,11 +163,12 @@ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, locale
162
163
  }
163
164
  } else if (sourceEnv) {
164
165
  setConfig(config, bulkPublish);
166
+ const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid)
165
167
  const environmentDetails = await getEnvironment(stack, sourceEnv);
166
168
  for (let i = 0; i < contentTypes.length; i += 1) {
167
169
  for (let j = 0; j < locales.length; j += 1) {
168
170
  /* eslint-disable no-await-in-loop */
169
- await getEntries(stack, contentTypes[i], environmentDetails.uid, locales[j], bulkPublish, environments, apiVersion);
171
+ await getEntries(stack, contentTypes[i], environmentDetails.uid, locales[j], bulkPublish, environments, apiVersion,bulkPublishLimit );
170
172
  /* eslint-enable no-await-in-loop */
171
173
  }
172
174
  }
@@ -9,6 +9,7 @@ const retryFailedLogs = require('../util/retryfailed');
9
9
  const { validateFile } = require('../util/fs');
10
10
  const { isEmpty } = require('../util');
11
11
  const { fetchBulkPublishLimit } = require('../util/common-utility');
12
+ const VARIANTS_PUBLISH_API_VERSION = '3.2';
12
13
 
13
14
  const queue = getQueue();
14
15
 
@@ -27,6 +28,8 @@ async function getEntries(
27
28
  environments,
28
29
  apiVersion,
29
30
  bulkPublishLimit,
31
+ variantsFlag = false,
32
+ entry_uid = undefined,
30
33
  skip = 0,
31
34
  ) {
32
35
  return new Promise((resolve, reject) => {
@@ -39,6 +42,13 @@ async function getEntries(
39
42
  include_publish_details: true,
40
43
  };
41
44
 
45
+ if (variantsFlag) {
46
+ queryParams.apiVersion = VARIANTS_PUBLISH_API_VERSION;
47
+ }
48
+ if (entry_uid) {
49
+ queryParams.uid = entry_uid;
50
+ }
51
+
42
52
  stack
43
53
  .contentType(contentType)
44
54
  .entry()
@@ -47,16 +57,31 @@ async function getEntries(
47
57
  .then(async (entriesResponse) => {
48
58
  skipCount += entriesResponse.items.length;
49
59
  let entries = entriesResponse.items;
50
- for (let index = 0; index < entriesResponse.items.length; index++) {
60
+
61
+ for (let index = 0; index < entries.length; index++) {
62
+ let variants = [];
51
63
  if (bulkPublish) {
64
+ let entry;
52
65
  if (bulkPublishSet.length < bulkPublishLimit) {
53
- bulkPublishSet.push({
66
+ entry = {
54
67
  uid: entries[index].uid,
55
68
  content_type: contentType,
56
69
  locale,
57
70
  publish_details: entries[index].publish_details || [],
58
- });
71
+ };
72
+
73
+ if (variantsFlag) {
74
+ variants = await getVariantEntries(stack, contentType, entries, index, queryParams);
75
+ if (variants.length > 0) {
76
+ entry.variant_rules = {
77
+ publish_latest_base: false,
78
+ publish_latest_base_conditionally: true,
79
+ };
80
+ entry.variants = variants;
81
+ }
82
+ }
59
83
  }
84
+ bulkPublishSet.push(entry);
60
85
 
61
86
  if (bulkPublishSet.length === bulkPublishLimit) {
62
87
  await queue.Enqueue({
@@ -71,7 +96,7 @@ async function getEntries(
71
96
  }
72
97
 
73
98
  if (
74
- index === entriesResponse.items.length - 1 &&
99
+ index === entries.length - 1 &&
75
100
  bulkPublishSet.length <= bulkPublishLimit &&
76
101
  bulkPublishSet.length > 0
77
102
  ) {
@@ -84,7 +109,7 @@ async function getEntries(
84
109
  apiVersion,
85
110
  });
86
111
  bulkPublishSet = [];
87
- } // bulkPublish
112
+ }
88
113
  } else {
89
114
  await queue.Enqueue({
90
115
  content_type: contentType,
@@ -110,6 +135,8 @@ async function getEntries(
110
135
  environments,
111
136
  apiVersion,
112
137
  bulkPublishLimit,
138
+ variantsFlag,
139
+ entry_uid,
113
140
  skipCount,
114
141
  );
115
142
  return resolve();
@@ -118,6 +145,56 @@ async function getEntries(
118
145
  });
119
146
  }
120
147
 
148
+ async function getVariantEntries(stack, contentType, entries, index, queryParams, skip = 0) {
149
+ try {
150
+ let variantQueryParams = {
151
+ locale: queryParams.locale || 'en-us',
152
+ include_count: true,
153
+ skip: skip, // Adding skip parameter for pagination
154
+ limit: 100, // Set a limit to fetch up to 100 entries per request
155
+ include_publish_details: true,
156
+ };
157
+
158
+ const variantsEntriesResponse = await stack
159
+ .contentType(contentType)
160
+ .entry(entries[index].uid)
161
+ .variants()
162
+ .query(variantQueryParams)
163
+ .find();
164
+
165
+ // Map the response items to extract variant UIDs
166
+ const variants = variantsEntriesResponse.items.map((entry) => ({
167
+ uid: entry.variants._variant._uid,
168
+ }));
169
+
170
+ // Check if there are more entries to fetch
171
+ if (variantsEntriesResponse.items.length === variantQueryParams.limit) {
172
+ // Recursively fetch the next set of variants with updated skip value
173
+ const nextVariants = await getVariantEntries(
174
+ stack,
175
+ contentType,
176
+ entries,
177
+ index,
178
+ queryParams,
179
+ skip + variantQueryParams.limit,
180
+ );
181
+
182
+ // Ensure nextVariants is an array before concatenation
183
+ return Array.isArray(nextVariants) ? variants.concat(nextVariants) : variants;
184
+ }
185
+
186
+ return variants;
187
+ } catch (error) {
188
+ // Handle error message retrieval from different properties
189
+ const errorMessage =
190
+ error?.errorMessage ||
191
+ error?.message ||
192
+ error?.errors ||
193
+ 'Falied to fetch the variant entries, Please contact the admin for support.';
194
+ throw new Error(`Error fetching variants: ${errorMessage}`);
195
+ }
196
+ }
197
+
121
198
  async function getContentTypes(stack, skip = 0, contentTypes = []) {
122
199
  return new Promise((resolve, reject) => {
123
200
  skipCount = skip;
@@ -154,7 +231,17 @@ function setConfig(conf, bp) {
154
231
  }
155
232
 
156
233
  async function start(
157
- { retryFailed, bulkPublish, publishAllContentTypes, contentTypes, locales, environments, apiVersion },
234
+ {
235
+ retryFailed,
236
+ bulkPublish,
237
+ publishAllContentTypes,
238
+ contentTypes,
239
+ locales,
240
+ environments,
241
+ apiVersion,
242
+ includeVariants,
243
+ entryUid,
244
+ },
158
245
  stack,
159
246
  config,
160
247
  ) {
@@ -168,12 +255,16 @@ async function start(
168
255
  }
169
256
  process.exit(0);
170
257
  });
258
+
259
+ if (includeVariants) {
260
+ apiVersion = VARIANTS_PUBLISH_API_VERSION;
261
+ }
262
+
171
263
  if (retryFailed) {
172
264
  if (typeof retryFailed === 'string') {
173
265
  if (!validateFile(retryFailed, ['publish-entries', 'bulk-publish-entries'])) {
174
266
  return false;
175
267
  }
176
-
177
268
  bulkPublish = retryFailed.match(new RegExp('bulk')) ? true : false;
178
269
  setConfig(config, bulkPublish);
179
270
  if (bulkPublish) {
@@ -201,6 +292,8 @@ async function start(
201
292
  environments,
202
293
  apiVersion,
203
294
  bulkPublishLimit,
295
+ includeVariants,
296
+ entryUid,
204
297
  );
205
298
  /* eslint-enable no-await-in-loop */
206
299
  }
@@ -9,6 +9,7 @@ const { performBulkPublish, publishEntry, initializeLogger } = require('../consu
9
9
  const retryFailedLogs = require('../util/retryfailed');
10
10
  const { validateFile } = require('../util/fs');
11
11
  const { isEmpty } = require('../util');
12
+ const { fetchBulkPublishLimit } = require('../util/common-utility');
12
13
 
13
14
  const queue = getQueue();
14
15
  let skipCount;
@@ -42,7 +43,7 @@ async function getEnvironment(stack, environmentName) {
42
43
  });
43
44
  }
44
45
 
45
- async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skip = 0) {
46
+ async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, bulkPublishLimit, skip = 0) {
46
47
  return new Promise((resolve, reject) => {
47
48
  skipCount = skip;
48
49
 
@@ -68,7 +69,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
68
69
  if (!publishedEntry) {
69
70
  changedFlag = true;
70
71
  if (bulkPublish) {
71
- if (bulkPublishSet.length < 10) {
72
+ if (bulkPublishSet.length < bulkPublishLimit) {
72
73
  bulkPublishSet.push({
73
74
  uid: entries[index].uid,
74
75
  content_type: contentType,
@@ -89,7 +90,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
89
90
  }
90
91
  }
91
92
  if (bulkPublish) {
92
- if (bulkPublishSet.length === 10) {
93
+ if (bulkPublishSet.length === bulkPublishLimit) {
93
94
  await queue.Enqueue({
94
95
  entries: bulkPublishSet,
95
96
  locale,
@@ -102,7 +103,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
102
103
  }
103
104
  if (
104
105
  index === responseEntries.items.length - 1 &&
105
- bulkPublishSet.length < 10 &&
106
+ bulkPublishSet.length < bulkPublishLimit &&
106
107
  bulkPublishSet.length > 0
107
108
  ) {
108
109
  await queue.Enqueue({
@@ -162,10 +163,11 @@ async function start({ sourceEnv, environments, locale, contentTypes, bulkPublis
162
163
  } else {
163
164
  setConfig(config, bulkPublish);
164
165
  if (sourceEnv) {
166
+ const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid);
165
167
  const environmentDetails = await getEnvironment(stack, sourceEnv);
166
168
  for (let i = 0; i < contentTypes.length; i += 1) {
167
169
  /* eslint-disable no-await-in-loop */
168
- await getEntries(stack, contentTypes[i], environmentDetails.uid, locale, bulkPublish, environments, apiVersion);
170
+ await getEntries(stack, contentTypes[i], environmentDetails.uid, locale, bulkPublish, environments, apiVersion, bulkPublishLimit);
169
171
  /* eslint-enable no-await-in-loop */
170
172
  changedFlag = false;
171
173
  }
@@ -12,6 +12,7 @@ const { configHandler } = require('@contentstack/cli-utilities');
12
12
  let config = configHandler
13
13
  const { initializeLogger, performBulkUnPublish, publishUsingVersion } = require('../consumer/publish');
14
14
  const getStack = require('../util/client.js').getStack;
15
+ const { fetchBulkPublishLimit } = require('../util/common-utility');
15
16
 
16
17
  const intervalBetweenPublishRequests = 3; // interval in seconds
17
18
 
@@ -185,6 +186,7 @@ async function revertUsingLogs(logFileName) {
185
186
  branch: response.file[0].message.branch || 'main'
186
187
  });
187
188
  logs = await formatLogData(stack, response.file);
189
+ const bulkPublishLimit = fetchBulkPublishLimit(stack?.org_uid);
188
190
 
189
191
  logs.environments.forEach((environment, envIndex) => {
190
192
  switch (logs.type) {
@@ -199,7 +201,7 @@ async function revertUsingLogs(logFileName) {
199
201
  // handle revert case
200
202
 
201
203
  publishDetailsForThisEnvironment.forEach((publishDetail) => {
202
- if (bulkPublishSet.length < 10) {
204
+ if (bulkPublishSet.length < bulkPublishLimit) {
203
205
  bulkPublishSet.push({
204
206
  uid,
205
207
  version: publishDetail.version,
@@ -209,7 +211,7 @@ async function revertUsingLogs(logFileName) {
209
211
  });
210
212
  }
211
213
 
212
- if (bulkPublishSet.length === 10) {
214
+ if (bulkPublishSet.length === bulkPublishLimit) {
213
215
  const data = {
214
216
  entries: bulkPublishSet,
215
217
  environments: [environment.name],
@@ -222,7 +224,7 @@ async function revertUsingLogs(logFileName) {
222
224
  }
223
225
  });
224
226
  } else {
225
- if (bulkUnpublishSet.length < 10) {
227
+ if (bulkUnpublishSet.length < bulkPublishLimit) {
226
228
  bulkUnpublishSet.push({
227
229
  uid,
228
230
  locale,
@@ -231,7 +233,7 @@ async function revertUsingLogs(logFileName) {
231
233
  });
232
234
  }
233
235
 
234
- if (bulkUnpublishSet.length === 10) {
236
+ if (bulkUnpublishSet.length === bulkPublishLimit) {
235
237
  unpublishQueue.Enqueue({
236
238
  entries: bulkUnpublishSet,
237
239
  environments: [environment.name],
@@ -244,7 +246,7 @@ async function revertUsingLogs(logFileName) {
244
246
  }
245
247
 
246
248
  if (entryIndex === logs.entries[loc].length - 1) {
247
- if (bulkUnpublishSet.length <= 10 && bulkUnpublishSet.length !== 0) {
249
+ if (bulkUnpublishSet.length <= bulkPublishLimit && bulkUnpublishSet.length !== 0) {
248
250
  unpublishQueue.Enqueue({
249
251
  entries: bulkUnpublishSet,
250
252
  environments: [environment.name],
@@ -255,7 +257,7 @@ async function revertUsingLogs(logFileName) {
255
257
  bulkUnpublishSet = [];
256
258
  }
257
259
 
258
- if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
260
+ if (bulkPublishSet.length <= bulkPublishLimit && bulkPublishSet.length !== 0) {
259
261
  const data = {
260
262
  entries: bulkPublishSet,
261
263
  environments: [environment.name],
@@ -288,7 +290,7 @@ async function revertUsingLogs(logFileName) {
288
290
  // handle revert case
289
291
 
290
292
  publishDetailsForThisEnvironment.forEach((publishDetail) => {
291
- if (bulkPublishSet.length < 10) {
293
+ if (bulkPublishSet.length < bulkPublishLimit) {
292
294
  bulkPublishSet.push({
293
295
  uid,
294
296
  version: publishDetail.version,
@@ -296,7 +298,7 @@ async function revertUsingLogs(logFileName) {
296
298
  });
297
299
  }
298
300
 
299
- if (bulkPublishSet.length === 10) {
301
+ if (bulkPublishSet.length === bulkPublishLimit) {
300
302
  const data = {
301
303
  assets: bulkPublishSet,
302
304
  environments: [environment.name],
@@ -309,14 +311,14 @@ async function revertUsingLogs(logFileName) {
309
311
  }
310
312
  });
311
313
  } else {
312
- if (bulkUnpublishSet.length < 10) {
314
+ if (bulkUnpublishSet.length < bulkPublishLimit) {
313
315
  bulkUnpublishSet.push({
314
316
  uid,
315
317
  publish_details: [],
316
318
  });
317
319
  }
318
320
 
319
- if (bulkUnpublishSet.length === 10) {
321
+ if (bulkUnpublishSet.length === bulkPublishLimit) {
320
322
  unpublishQueue.Enqueue({
321
323
  assets: bulkUnpublishSet,
322
324
  environments: [environment.name],
@@ -328,7 +330,7 @@ async function revertUsingLogs(logFileName) {
328
330
  }
329
331
 
330
332
  if (assetIndex === logs.assets.length - 1) {
331
- if (bulkUnpublishSet.length <= 10 && bulkUnpublishSet.length !== 0) {
333
+ if (bulkUnpublishSet.length <= bulkPublishLimit && bulkUnpublishSet.length !== 0) {
332
334
  unpublishQueue.Enqueue({
333
335
  assets: bulkUnpublishSet,
334
336
  environments: [environment.name],
@@ -338,7 +340,7 @@ async function revertUsingLogs(logFileName) {
338
340
  bulkUnpublishSet = [];
339
341
  }
340
342
 
341
- if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
343
+ if (bulkPublishSet.length <= bulkPublishLimit && bulkPublishSet.length !== 0) {
342
344
  const data = {
343
345
  assets: bulkPublishSet,
344
346
  environments: [environment.name],