@contentstack/cli-cm-bulk-publish 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version)
21
- @contentstack/cli-cm-bulk-publish/1.3.3 linux-x64 node-v16.20.0
21
+ @contentstack/cli-cm-bulk-publish/1.3.4 linux-x64 node-v16.20.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -72,6 +72,7 @@ FLAGS
72
72
  -e, --environments=<value>... Environments where assets will be published
73
73
  -l, --locales=<value>... Locales to where assets will be published
74
74
  -y, --yes Agree to process the command with the current configuration
75
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
75
76
  --bulk-publish=<value> [default: true] By default this flag is set as true. It indicates that contentstack's
76
77
  bulkpublish API will be used to publish the assets
77
78
  --delivery-token=<value> Delivery token for source environment
@@ -134,13 +135,14 @@ Unpublish assets from given environment
134
135
  ```
135
136
  USAGE
136
137
  $ csdx cm:assets:unpublish [-a <value>] [-e <value>] [-c <value>] [-y] [--locale <value>] [--branch <value>]
137
- [--retry-failed <value>] [--bulk-unpublish <value>] [--delivery-token <value>]
138
+ [--retry-failed <value>] [--bulk-unpublish <value>] [--api-version <value>] [--delivery-token <value>]
138
139
 
139
140
  FLAGS
140
141
  -a, --alias=<value> Alias(name) for the management token
141
142
  -c, --config=<value> Path to the config file
142
143
  -e, --environment=<value> Source Environment
143
144
  -y, --yes Agree to process the command with the current configuration
145
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
144
146
  --branch=<value> [default: main] Specify the branch to fetch the content (by default the main branch is
145
147
  selected)
146
148
  --bulk-unpublish=<value> [default: true] By default this flag is set as true. It indicates that contentstack's
@@ -218,6 +220,7 @@ FLAGS
218
220
  -l, --locales=<value>... Locales where entries will be published
219
221
  -t, --contentTypes=<value>... The Contenttypes from which entries will be published
220
222
  -y, --yes Agree to process the command with the current configuration
223
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
221
224
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
222
225
  bulkpublish API will be used to publish the entries
223
226
  --content-types=<value>... The Contenttypes from which entries will be published
@@ -281,6 +284,7 @@ FLAGS
281
284
  -e, --environments=<value>... Environments where assets will be published
282
285
  -l, --locales=<value>... Locales to where assets will be published
283
286
  -y, --yes Agree to process the command with the current configuration
287
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
284
288
  --bulk-publish=<value> [default: true] By default this flag is set as true. It indicates that contentstack's
285
289
  bulkpublish API will be used to publish the assets
286
290
  --delivery-token=<value> Delivery token for source environment
@@ -403,6 +407,7 @@ FLAGS
403
407
  -a, --alias=<value> Alias(name) for the management token
404
408
  -c, --config=<value> Path to the config file
405
409
  -y, --yes Agree to process the command with the current configuration
410
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
406
411
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
407
412
  bulkpublish API will be used to publish the entries
408
413
  --content-type=<value>... The Contenttypes from which entries will be published
@@ -475,6 +480,7 @@ FLAGS
475
480
  -e, --environments=<value>... Environments where entries will be published
476
481
  -l, --locales=<value>... Locales where entries will be published
477
482
  -y, --yes Agree to process the command with the current configuration
483
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
478
484
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
479
485
  bulkpublish API will be used to publish the entries
480
486
  --content-types=<value>... The Contenttypes from which entries need to be published
@@ -550,6 +556,7 @@ FLAGS
550
556
  -e, --environments=<value>... Destination environments
551
557
  -l, --locales=<value>... Locales where edited entries will be published
552
558
  -y, --yes Agree to process the command with the current configuration
559
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
553
560
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
554
561
  bulkpublish API will be used to publish the entries
555
562
  --content-types=<value>... The Contenttypes which will be checked for edited entries
@@ -615,6 +622,7 @@ FLAGS
615
622
  -c, --config=<value> Path to the config file
616
623
  -e, --environments=<value>... Destination environments
617
624
  -y, --yes Agree to process the command with the current configuration
625
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
618
626
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
619
627
  bulkpublish API will be used to publish the entries
620
628
  --content-types=<value>... The Contenttypes from which entries will be published
@@ -711,6 +719,7 @@ FLAGS
711
719
  -e, --environment=<value> Source Environment
712
720
  -l, --locale=<value> Locale filter
713
721
  -y, --yes Agree to process the command with the current configuration
722
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
714
723
  --bulk-unpublish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
715
724
  bulkpublish API will be used to unpublish the entries and assets
716
725
  --content-type=<value> Content type filter
@@ -802,6 +811,7 @@ FLAGS
802
811
  -c, --config=<value> Path to the config file
803
812
  -e, --environments=<value>... Destination environments
804
813
  -y, --yes Agree to process the command with the current configuration
814
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
805
815
  --content-types=<value>... The Contenttypes from which entries will be published
806
816
  --locales=<value> Source locale
807
817
  --retry-failed=<value> Retry publishing failed entries from the logfile
@@ -867,6 +877,7 @@ FLAGS
867
877
  -e, --environments=<value>... Environments where entries will be published
868
878
  -l, --locales=<value>... Locales where entries will be published
869
879
  -y, --yes Agree to process the command with the current configuration
880
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
870
881
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
871
882
  bulkpublish API will be used to publish the entries
872
883
  --content-types=<value>... The Contenttypes from which entries need to be published
@@ -944,6 +955,7 @@ FLAGS
944
955
  -e, --environments=<value>... Destination environments
945
956
  -l, --locales=<value>... Locales where edited entries will be published
946
957
  -y, --yes Agree to process the command with the current configuration
958
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
947
959
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
948
960
  bulkpublish API will be used to publish the entries
949
961
  --content-types=<value>... The Contenttypes which will be checked for edited entries
@@ -1011,6 +1023,7 @@ FLAGS
1011
1023
  -c, --config=<value> Path to the config file
1012
1024
  -e, --environments=<value>... Destination environments
1013
1025
  -y, --yes Agree to process the command with the current configuration
1026
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
1014
1027
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
1015
1028
  bulkpublish API will be used to publish the entries
1016
1029
  --content-types=<value>... The Contenttypes from which entries will be published
@@ -1078,6 +1091,7 @@ FLAGS
1078
1091
  -c, --config=<value> Path to the config file
1079
1092
  -e, --environments=<value>... Destination environments
1080
1093
  -y, --yes Agree to process the command with the current configuration
1094
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
1081
1095
  --content-types=<value>... The Contenttypes from which entries will be published
1082
1096
  --locales=<value> Source locale
1083
1097
  --retry-failed=<value> Retry publishing failed entries from the logfile
@@ -1133,13 +1147,15 @@ Unpublish entries from the given environment
1133
1147
  ```
1134
1148
  USAGE
1135
1149
  $ csdx cm:entries:unpublish [-a <value>] [-e <value>] [-c <value>] [-y] [--locale <value>] [--branch <value>]
1136
- [--retry-failed <value>] [--bulk-unpublish <value>] [--content-type <value>] [--delivery-token <value>]
1150
+ [--retry-failed <value>] [--bulk-unpublish <value>] [--api-version <value>] [--content-type <value>]
1151
+ [--delivery-token <value>]
1137
1152
 
1138
1153
  FLAGS
1139
1154
  -a, --alias=<value> Alias(name) for the management token
1140
1155
  -c, --config=<value> Path to the config file
1141
1156
  -e, --environment=<value> Source Environment
1142
1157
  -y, --yes Agree to process the command with the current configuration
1158
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
1143
1159
  --branch=<value> [default: main] Specify the branch to fetch the content (by default the main branch is
1144
1160
  selected)
1145
1161
  --bulk-unpublish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
@@ -1206,6 +1222,7 @@ FLAGS
1206
1222
  -l, --locales=<value>... Locales where entries will be published
1207
1223
  -t, --contentTypes=<value>... The Contenttypes from which entries will be published
1208
1224
  -y, --yes Agree to process the command with the current configuration
1225
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
1209
1226
  --bulk-publish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
1210
1227
  bulkpublish API will be used to publish the entries
1211
1228
  --content-types=<value>... The Contenttypes from which entries will be published
@@ -1296,6 +1313,12 @@ EXAMPLES
1296
1313
  Using --branch flag
1297
1314
 
1298
1315
  $ csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]
1316
+
1317
+
1318
+
1319
+ Using --api-version flag
1320
+
1321
+ $ csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --api-version [API VERSION]
1299
1322
  ```
1300
1323
 
1301
1324
  _See code: [src/commands/cm/stacks/publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish.js)_
@@ -1409,6 +1432,7 @@ FLAGS
1409
1432
  -e, --environment=<value> Source Environment
1410
1433
  -l, --locale=<value> Locale filter
1411
1434
  -y, --yes Agree to process the command with the current configuration
1435
+ --api-version=<value> API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].
1412
1436
  --bulk-unpublish=<value> [default: true] This flag is set to true by default. It indicates that contentstack's
1413
1437
  bulkpublish API will be used to unpublish the entries and assets
1414
1438
  --content-type=<value> Content type filter
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.3",
2
+ "version": "1.3.4",
3
3
  "commands": {
4
4
  "cm:assets:publish": {
5
5
  "id": "cm:assets:publish",
@@ -124,6 +124,12 @@
124
124
  "multiple": false,
125
125
  "default": "true"
126
126
  },
127
+ "api-version": {
128
+ "name": "api-version",
129
+ "type": "option",
130
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
131
+ "multiple": false
132
+ },
127
133
  "delivery-token": {
128
134
  "name": "delivery-token",
129
135
  "type": "option",
@@ -224,6 +230,12 @@
224
230
  "multiple": false,
225
231
  "default": "true"
226
232
  },
233
+ "api-version": {
234
+ "name": "api-version",
235
+ "type": "option",
236
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
237
+ "multiple": false
238
+ },
227
239
  "delivery-token": {
228
240
  "name": "delivery-token",
229
241
  "type": "option",
@@ -296,6 +308,12 @@
296
308
  "multiple": false,
297
309
  "default": "true"
298
310
  },
311
+ "api-version": {
312
+ "name": "api-version",
313
+ "type": "option",
314
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
315
+ "multiple": false
316
+ },
299
317
  "contentType": {
300
318
  "name": "contentType",
301
319
  "type": "option",
@@ -478,6 +496,12 @@
478
496
  "multiple": false,
479
497
  "default": "true"
480
498
  },
499
+ "api-version": {
500
+ "name": "api-version",
501
+ "type": "option",
502
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
503
+ "multiple": false
504
+ },
481
505
  "sourceEnv": {
482
506
  "name": "sourceEnv",
483
507
  "type": "option",
@@ -650,6 +674,12 @@
650
674
  "multiple": false,
651
675
  "default": "true"
652
676
  },
677
+ "api-version": {
678
+ "name": "api-version",
679
+ "type": "option",
680
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
681
+ "multiple": false
682
+ },
653
683
  "sourceEnv": {
654
684
  "name": "sourceEnv",
655
685
  "type": "option",
@@ -734,6 +764,12 @@
734
764
  "multiple": false,
735
765
  "default": "true"
736
766
  },
767
+ "api-version": {
768
+ "name": "api-version",
769
+ "type": "option",
770
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
771
+ "multiple": false
772
+ },
737
773
  "sourceEnv": {
738
774
  "name": "sourceEnv",
739
775
  "type": "option",
@@ -875,6 +911,12 @@
875
911
  "multiple": false,
876
912
  "default": "true"
877
913
  },
914
+ "api-version": {
915
+ "name": "api-version",
916
+ "type": "option",
917
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
918
+ "multiple": false
919
+ },
878
920
  "publish-all-content-types": {
879
921
  "name": "publish-all-content-types",
880
922
  "type": "boolean",
@@ -1033,6 +1075,12 @@
1033
1075
  "multiple": false,
1034
1076
  "default": "true"
1035
1077
  },
1078
+ "api-version": {
1079
+ "name": "api-version",
1080
+ "type": "option",
1081
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
1082
+ "multiple": false
1083
+ },
1036
1084
  "content-type": {
1037
1085
  "name": "content-type",
1038
1086
  "type": "option",
@@ -1095,6 +1143,12 @@
1095
1143
  "multiple": false,
1096
1144
  "default": "true"
1097
1145
  },
1146
+ "api-version": {
1147
+ "name": "api-version",
1148
+ "type": "option",
1149
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
1150
+ "multiple": false
1151
+ },
1098
1152
  "content-types": {
1099
1153
  "name": "content-types",
1100
1154
  "type": "option",
@@ -1306,7 +1360,10 @@
1306
1360
  "csdx cm:stacks:publish --retry-failed [LOG FILE NAME]",
1307
1361
  "",
1308
1362
  "Using --branch flag",
1309
- "csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]"
1363
+ "csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]",
1364
+ "",
1365
+ "Using --api-version flag",
1366
+ "csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --api-version [API VERSION]"
1310
1367
  ],
1311
1368
  "flags": {},
1312
1369
  "args": {}
@@ -1404,6 +1461,12 @@
1404
1461
  "multiple": false,
1405
1462
  "default": "true"
1406
1463
  },
1464
+ "api-version": {
1465
+ "name": "api-version",
1466
+ "type": "option",
1467
+ "description": "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
1468
+ "multiple": false
1469
+ },
1407
1470
  "content-type": {
1408
1471
  "name": "content-type",
1409
1472
  "type": "option",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-bulk-publish",
3
3
  "description": "Contentstack CLI plugin for bulk publish actions",
4
- "version": "1.3.3",
4
+ "version": "1.3.4",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "^1.2.4",
8
+ "@contentstack/cli-command": "^1.2.5",
9
9
  "@contentstack/cli-utilities": "^1.4.1",
10
10
  "bluebird": "^3.7.2",
11
11
  "chalk": "^4.1.2",
@@ -14,6 +14,8 @@ class AssetsPublishCommand extends Command {
14
14
  assetsFlags.retryFailed = assetsFlags['retry-failed'] || assetsFlags.retryFailed || false;
15
15
  assetsFlags.folderUid = assetsFlags['folder-uid'] || assetsFlags.folderUid;
16
16
  assetsFlags.bulkPublish = assetsFlags['bulk-publish'] || assetsFlags.bulkPublish;
17
+ assetsFlags.apiVersion = assetsFlags['api-version'] || '3'; // setting default value for apiVersion
18
+ delete assetsFlags['api-version']
17
19
  delete assetsFlags['retry-failed'];
18
20
  delete assetsFlags['folder-uid'];
19
21
  delete assetsFlags['bulk-publish'];
@@ -211,6 +213,9 @@ AssetsPublishCommand.flags = {
211
213
  hidden: true,
212
214
  parse: printFlagDeprecation(['-b', '--bulkPublish'], ['--bulk-publish']),
213
215
  }),
216
+ 'api-version': flags.string({
217
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
218
+ }),
214
219
  'delivery-token': flags.string({ description: 'Delivery token for source environment' }),
215
220
  'source-env': flags.string({ description: 'Source environment' }),
216
221
  'content-types': flags.string({ description: 'Content types', hidden: true, multiple: true }), // this is a work around, as this command is to be run with entries:publish command and should not break flags check.
@@ -15,8 +15,10 @@ class UnpublishCommand extends Command {
15
15
  unpublishFlags.retryFailed = unpublishFlags['retry-failed'] || unpublishFlags.retryFailed || false;
16
16
  unpublishFlags.bulkUnpublish = unpublishFlags['bulk-unpublish'] || unpublishFlags.bulkUnpublish;
17
17
  unpublishFlags.deliveryToken = unpublishFlags['delivery-token'] || unpublishFlags.deliveryToken;
18
+ unpublishFlags.apiVersion = unpublishFlags['api-version'] || '3';
18
19
  unpublishFlags.onlyAssets = true;
19
20
  unpublishFlags.onlyEntries = false;
21
+ delete unpublishFlags['api-version']
20
22
  delete unpublishFlags['retry-failed'];
21
23
  delete unpublishFlags['bulk-unpublish'];
22
24
  delete unpublishFlags['delivery-token'];
@@ -155,6 +157,9 @@ UnpublishCommand.flags = {
155
157
  "By default this flag is set as true. It indicates that contentstack's bulkpublish API will be used to unpublish the assets",
156
158
  default: 'true',
157
159
  }),
160
+ 'api-version': flags.string({
161
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
162
+ }),
158
163
  'delivery-token': flags.string({
159
164
  description: 'Delivery Token for source environment',
160
165
  }),
@@ -133,6 +133,10 @@ class CrossPublishCommand extends Command {
133
133
  _flags.bulkPublish = _flags['bulk-publish'];
134
134
  delete _flags['bulk-publish'];
135
135
  }
136
+ if ('api-version' in _flags) {
137
+ _flags.apiVersion = _flags['api-version'] || '3';
138
+ delete _flags['api-version'];
139
+ }
136
140
  if ('source-env' in _flags) {
137
141
  _flags.environment = _flags['source-env'];
138
142
  delete _flags['source-env'];
@@ -180,6 +184,9 @@ CrossPublishCommand.flags = {
180
184
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
181
185
  default: 'true',
182
186
  }),
187
+ 'api-version': flags.string({
188
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
189
+ }),
183
190
  contentType: flags.string({
184
191
  char: 't',
185
192
  description: 'The Content-Types from which entries need to be published',
@@ -16,6 +16,8 @@ class PublishModifiedCommand extends Command {
16
16
  entryEditsFlags.contentTypes = entryEditsFlags['content-types'] || entryEditsFlags.contentTypes;
17
17
  entryEditsFlags.bulkPublish = entryEditsFlags['bulk-publish'] || entryEditsFlags.bulkPublish;
18
18
  entryEditsFlags.sourceEnv = entryEditsFlags['source-env'] || entryEditsFlags.sourceEnv;
19
+ entryEditsFlags.apiVersion = entryEditsFlags['api-version'] || '3';
20
+ delete entryEditsFlags['api-version']
19
21
  delete entryEditsFlags['retry-failed'];
20
22
  delete entryEditsFlags['content-types'];
21
23
  delete entryEditsFlags['bulk-publish'];
@@ -140,6 +142,9 @@ PublishModifiedCommand.flags = {
140
142
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
141
143
  default: 'true',
142
144
  }),
145
+ 'api-version': flags.string({
146
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
147
+ }),
143
148
  sourceEnv: flags.string({
144
149
  char: 's',
145
150
  description: 'Environment from which edited entries will be published',
@@ -19,7 +19,9 @@ class NonlocalizedFieldChangesCommand extends Command {
19
19
  nonlocalizedFieldChangesFlags['source-env'] || nonlocalizedFieldChangesFlags.sourceEnv;
20
20
  nonlocalizedFieldChangesFlags.contentTypes =
21
21
  nonlocalizedFieldChangesFlags['content-types'] || nonlocalizedFieldChangesFlags.contentTypes;
22
-
22
+ nonlocalizedFieldChangesFlags.apiVersion = nonlocalizedFieldChangesFlags['api-version'] || '3';
23
+
24
+ delete nonlocalizedFieldChangesFlags['api-version']
23
25
  delete nonlocalizedFieldChangesFlags['retry-failed'];
24
26
  delete nonlocalizedFieldChangesFlags['bulk-publish'];
25
27
  delete nonlocalizedFieldChangesFlags['source-env'];
@@ -170,6 +172,9 @@ NonlocalizedFieldChangesCommand.flags = {
170
172
  hidden: true,
171
173
  parse: printFlagDeprecation(['-b', '--bulkPublish'], ['--bulk-publish']),
172
174
  }),
175
+ 'api-version': flags.string({
176
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
177
+ }),
173
178
  sourceEnv: flags.string({
174
179
  char: 's',
175
180
  description: 'Source Environment',
@@ -45,6 +45,9 @@ PublishOnlyUnpublished.flags = {
45
45
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
46
46
  default: 'true',
47
47
  }),
48
+ 'api-version': flags.string({
49
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
50
+ }),
48
51
  sourceEnv: flags.string({
49
52
  char: 's',
50
53
  hidden: true,
@@ -20,6 +20,8 @@ class PublishEntriesCommand extends Command {
20
20
  entriesFlags.bulkPublish = entriesFlags['bulk-publish'] || entriesFlags.bulkPublish;
21
21
  entriesFlags.publishAllContentTypes =
22
22
  entriesFlags['publish-all-content-types'] || entriesFlags.publishAllContentTypes || false;
23
+ entriesFlags.apiVersion = entriesFlags['api-version'] || '3';
24
+ delete entriesFlags['api-version'];
23
25
  delete entriesFlags['retry-failed'];
24
26
  delete entriesFlags['content-types'];
25
27
  delete entriesFlags['bulk-publish'];
@@ -185,6 +187,9 @@ PublishEntriesCommand.flags = {
185
187
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
186
188
  default: 'true',
187
189
  }),
190
+ 'api-version': flags.string({
191
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
192
+ }),
188
193
  'publish-all-content-types': flags.boolean({
189
194
  description: '(optional) Publish all contenttypes (cannot be set when contentTypes flag is set)',
190
195
  }),
@@ -18,6 +18,8 @@ class UnpublishCommand extends Command {
18
18
  unpublishFlags.deliveryToken = unpublishFlags['delivery-token'] || unpublishFlags.deliveryToken;
19
19
  unpublishFlags.onlyAssets = false;
20
20
  unpublishFlags.onlyEntries = true;
21
+ unpublishFlags.apiVersion = unpublishFlags['api-version'] || '3';
22
+ delete unpublishFlags['api-version'];
21
23
  delete unpublishFlags['retry-failed'];
22
24
  delete unpublishFlags['bulk-unpublish'];
23
25
  delete unpublishFlags['content-type'];
@@ -156,6 +158,9 @@ UnpublishCommand.flags = {
156
158
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to unpublish the entries",
157
159
  default: 'true',
158
160
  }),
161
+ 'api-version': flags.string({
162
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
163
+ }),
159
164
  'content-type': flags.string({
160
165
  description: 'Content type filter',
161
166
  }),
@@ -15,6 +15,8 @@ class UpdateAndPublishCommand extends Command {
15
15
  addFieldsFlags.retryFailed = addFieldsFlags['retry-failed'] || addFieldsFlags.retryFailed || false;
16
16
  addFieldsFlags.contentTypes = addFieldsFlags['content-types'] || addFieldsFlags.contentTypes;
17
17
  addFieldsFlags.bulkPublish = addFieldsFlags['bulk-publish'] || addFieldsFlags.bulkPublish;
18
+ addFieldsFlags.apiVersion = addFieldsFlags['api-version'] || '3';
19
+ delete addFieldsFlags['api-version'];
18
20
  delete addFieldsFlags['retry-failed'];
19
21
  delete addFieldsFlags['content-types'];
20
22
  delete addFieldsFlags['bulk-publish'];
@@ -120,6 +122,9 @@ UpdateAndPublishCommand.flags = {
120
122
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to publish the entries",
121
123
  default: 'true',
122
124
  }),
125
+ 'api-version': flags.string({
126
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
127
+ }),
123
128
  'content-types': flags.string({
124
129
  description: 'The Contenttypes from which entries will be published',
125
130
  multiple: true,
@@ -50,7 +50,10 @@ StackPublishCommand.examples = [
50
50
  'csdx cm:stacks:publish --retry-failed [LOG FILE NAME]',
51
51
  '',
52
52
  'Using --branch flag',
53
- 'csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]'
53
+ 'csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]',
54
+ '',
55
+ 'Using --api-version flag',
56
+ 'csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --api-version [API VERSION]',
54
57
  ];
55
58
 
56
59
  StackPublishCommand.flags = []; // Same as entries and assets.
@@ -18,6 +18,8 @@ class UnpublishCommand extends Command {
18
18
  unpublishFlags.deliveryToken = unpublishFlags['delivery-token'] || unpublishFlags.deliveryToken;
19
19
  unpublishFlags.onlyAssets = unpublishFlags['only-assets'] || unpublishFlags.onlyAssets;
20
20
  unpublishFlags.onlyEntries = unpublishFlags['only-entries'] || unpublishFlags.onlyEntries;
21
+ unpublishFlags.apiVersion = unpublishFlags['api-version'] || '3';
22
+ delete unpublishFlags['api-version'];
21
23
  delete unpublishFlags['retry-failed'];
22
24
  delete unpublishFlags['bulk-unpublish'];
23
25
  delete unpublishFlags['content-type'];
@@ -190,6 +192,9 @@ UnpublishCommand.flags = {
190
192
  "This flag is set to true by default. It indicates that contentstack's bulkpublish API will be used to unpublish the entries and assets",
191
193
  default: 'true',
192
194
  }),
195
+ 'api-version': flags.string({
196
+ description : "API Version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].",
197
+ }),
193
198
  'content-type': flags.string({
194
199
  description: 'Content type filter',
195
200
  }),
@@ -5,6 +5,9 @@
5
5
  const chalk = require('chalk');
6
6
  const path = require('path');
7
7
  const { formatError } = require('../util');
8
+ const { configHandler } = require('@contentstack/cli-utilities')
9
+ const apiVersionForNRP = '3.2'
10
+ const nrpApiVersionWarning = `Provided apiVersion is invalid. ${apiVersionForNRP} is only supported value. Continuing with regular bulk-publish for now.`
8
11
 
9
12
  const { getLoggerInstance, addLogs, getLogsDirPath } = require('../util/logger');
10
13
  const logsDir = getLogsDirPath();
@@ -211,9 +214,12 @@ async function UnpublishAsset(data, _config, queue) {
211
214
  }
212
215
 
213
216
  async function performBulkPublish(data, _config, queue) {
217
+ // add validation for user uid
218
+ // if user not logged in, then user uid won't be available and NRP too won't work
214
219
  let conf;
215
220
  const bulkPublishObj = data.obj;
216
221
  const stack = bulkPublishObj.stack;
222
+ let payload = {}
217
223
  switch (bulkPublishObj.Type) {
218
224
  case 'entry':
219
225
  conf = {
@@ -221,15 +227,28 @@ async function performBulkPublish(data, _config, queue) {
221
227
  locales: [bulkPublishObj.locale],
222
228
  environments: bulkPublishObj.environments,
223
229
  };
230
+ payload['details'] = conf;
231
+ if (bulkPublishObj.apiVersion) {
232
+ if (!isNaN(bulkPublishObj.apiVersion) && bulkPublishObj.apiVersion === apiVersionForNRP) {
233
+ payload['api_version'] = bulkPublishObj.apiVersion
234
+ } else {
235
+ if (bulkPublishObj.apiVersion !== '3') { // because 3 is the default value for api-version, and it exists for the purpose of display only
236
+ console.log(
237
+ chalk.yellow(nrpApiVersionWarning),
238
+ );
239
+ }
240
+ }
241
+ }
224
242
  stack
225
243
  .bulkOperation()
226
- .publish({ details: conf })
244
+ .publish(payload)
227
245
  .then((bulkPublishEntriesResponse) => {
228
246
  if (!bulkPublishEntriesResponse.error_message) {
229
247
  console.log(
230
248
  chalk.green(
231
249
  `Bulk entries sent for publish ${JSON.stringify(removePublishDetails(bulkPublishObj.entries))}`,
232
250
  ),
251
+ (bulkPublishEntriesResponse.job_id) ? chalk.yellow(`job_id: ${bulkPublishEntriesResponse.job_id}`) : ''
233
252
  );
234
253
  delete bulkPublishObj.stack;
235
254
  addLogs(
@@ -268,14 +287,27 @@ async function performBulkPublish(data, _config, queue) {
268
287
  locales: [bulkPublishObj.locale],
269
288
  environments: bulkPublishObj.environments,
270
289
  };
290
+ payload['details'] = conf;
291
+ if (bulkPublishObj.apiVersion) {
292
+ if (!isNaN(bulkPublishObj.apiVersion) && bulkPublishObj.apiVersion === apiVersionForNRP) {
293
+ payload['api_version'] = bulkPublishObj.apiVersion
294
+ } else {
295
+ if (bulkPublishObj.apiVersion !== '3') { // because 3 is the default value for api-version, and it exists for the purpose of display only
296
+ console.log(
297
+ chalk.yellow(nrpApiVersionWarning),
298
+ );
299
+ }
300
+ }
301
+ }
271
302
  stack
272
303
  .bulkOperation()
273
- .publish({ details: conf })
304
+ .publish(payload)
274
305
  .then((bulkPublishAssetsResponse) => {
275
306
  if (!bulkPublishAssetsResponse.error_message) {
276
307
  console.log(
277
308
  chalk.green(
278
309
  `Bulk assets sent for publish ${JSON.stringify(removePublishDetails(bulkPublishObj.assets))}`,
310
+ (bulkPublishAssetsResponse.job_id) ? chalk.yellow(`job_id: ${bulkPublishAssetsResponse.job_id}`) : ''
279
311
  ),
280
312
  );
281
313
  delete bulkPublishObj.stack;
@@ -318,6 +350,7 @@ async function performBulkUnPublish(data, _config, queue) {
318
350
  let conf;
319
351
  const bulkUnPublishObj = data.obj;
320
352
  const stack = bulkUnPublishObj.stack;
353
+ let payload = {}
321
354
  switch (bulkUnPublishObj.Type) {
322
355
  case 'entry':
323
356
  conf = {
@@ -325,15 +358,28 @@ async function performBulkUnPublish(data, _config, queue) {
325
358
  locales: [bulkUnPublishObj.locale],
326
359
  environments: bulkUnPublishObj.environments,
327
360
  };
361
+ payload['details'] = conf;
362
+ if (bulkUnPublishObj.apiVersion) {
363
+ if (!isNaN(bulkUnPublishObj.apiVersion) && bulkUnPublishObj.apiVersion === apiVersionForNRP) {
364
+ payload['api_version'] = bulkUnPublishObj.apiVersion
365
+ } else {
366
+ if (bulkUnPublishObj.apiVersion !== '3') { // because 3 is the default value for api-version, and it exists for the purpose of display only
367
+ console.log(
368
+ chalk.yellow(nrpApiVersionWarning),
369
+ );
370
+ }
371
+ }
372
+ }
328
373
  stack
329
374
  .bulkOperation()
330
- .unpublish({ details: conf })
375
+ .unpublish(payload)
331
376
  .then((bulkUnPublishEntriesResponse) => {
332
377
  if (!bulkUnPublishEntriesResponse.error_message) {
333
378
  delete bulkUnPublishObj.stack;
334
379
  console.log(
335
380
  chalk.green(
336
381
  `Bulk entries sent for Unpublish ${JSON.stringify(removePublishDetails(bulkUnPublishObj.entries))}`,
382
+ (bulkUnPublishEntriesResponse.job_id) ? chalk.yellow(`job_id: ${bulkUnPublishEntriesResponse.job_id}`) : ''
337
383
  ),
338
384
  );
339
385
  addLogs(
@@ -372,15 +418,28 @@ async function performBulkUnPublish(data, _config, queue) {
372
418
  locales: [bulkUnPublishObj.locale || 'en-us'],
373
419
  environments: bulkUnPublishObj.environments,
374
420
  };
421
+ payload['details'] = conf;
422
+ if (bulkUnPublishObj.apiVersion) {
423
+ if (!isNaN(bulkUnPublishObj.apiVersion) && bulkUnPublishObj.apiVersion === apiVersionForNRP) {
424
+ payload['api_version'] = bulkUnPublishObj.apiVersion
425
+ } else {
426
+ if (bulkUnPublishObj.apiVersion !== '3') { // because 3 is the default value for api-version, and it exists for the purpose of display only
427
+ console.log(
428
+ chalk.yellow(nrpApiVersionWarning),
429
+ );
430
+ }
431
+ }
432
+ }
375
433
  stack
376
434
  .bulkOperation()
377
- .unpublish({ details: conf })
435
+ .unpublish(payload)
378
436
  .then((bulkUnPublishAssetsResponse) => {
379
437
  if (!bulkUnPublishAssetsResponse.error_message) {
380
438
  delete bulkUnPublishObj.stack;
381
439
  console.log(
382
440
  chalk.green(
383
441
  `Bulk assets sent for Unpublish ${JSON.stringify(removePublishDetails(bulkUnPublishObj.assets))}`,
442
+ (bulkUnPublishAssetsResponse.job_id) ? chalk.yellow(`job_id: ${bulkUnPublishAssetsResponse.job_id}`) : ''
384
443
  ),
385
444
  );
386
445
  addLogs(
@@ -199,6 +199,7 @@ async function getEntries(
199
199
  bulkPublish,
200
200
  environments,
201
201
  forceUpdate,
202
+ apiVersion,
202
203
  skip = 0,
203
204
  ) {
204
205
  let queryParams = {
@@ -237,6 +238,7 @@ async function getEntries(
237
238
  Type: 'entry',
238
239
  environments: environments,
239
240
  stack: stack,
241
+ apiVersion
240
242
  });
241
243
  bulkPublishSet = [];
242
244
  }
@@ -265,6 +267,7 @@ async function getEntries(
265
267
  Type: 'entry',
266
268
  environments: environments,
267
269
  stack: stack,
270
+ apiVersion
268
271
  });
269
272
  bulkPublishSet = [];
270
273
  }
@@ -274,7 +277,7 @@ async function getEntries(
274
277
  }
275
278
  return setTimeout(
276
279
  async () =>
277
- getEntries(stack, config, schema, contentType, locale, bulkPublish, environments, forceUpdate, skip),
280
+ getEntries(stack, config, schema, contentType, locale, bulkPublish, environments, forceUpdate, apiVersion, skip),
278
281
  2000,
279
282
  );
280
283
  })
@@ -286,7 +289,7 @@ async function getEntries(
286
289
  /* eslint-disable no-loop-func */
287
290
 
288
291
  async function start(
289
- { contentTypes, locales, environments, retryFailed, bulkPublish, force: forceUpdate },
292
+ { contentTypes, locales, environments, retryFailed, bulkPublish, force: forceUpdate, apiVersion },
290
293
  stack,
291
294
  config,
292
295
  ) {
@@ -332,6 +335,7 @@ async function start(
332
335
  bulkPublish,
333
336
  environments,
334
337
  forceUpdate,
338
+ apiVersion
335
339
  );
336
340
  } catch (err) {
337
341
  console.log(`Failed to get Entries with contentType ${contentTypes[i]} and locale ${locales[j]}`);
@@ -32,7 +32,7 @@ function getQueryParams(filter) {
32
32
  return queryString;
33
33
  }
34
34
 
35
- async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
35
+ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion) {
36
36
  return new Promise(async (resolve) => {
37
37
  for (let index = 0; index < items.length; index++) {
38
38
  changedFlag = true;
@@ -62,6 +62,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
62
62
  locale: filter.locale,
63
63
  environments: destEnv,
64
64
  stack: stack,
65
+ apiVersion
65
66
  });
66
67
  bulkPublishAssetSet = [];
67
68
  }
@@ -73,6 +74,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
73
74
  Type: 'entry',
74
75
  environments: destEnv,
75
76
  stack: stack,
77
+ apiVersion
76
78
  });
77
79
  bulkPublishSet = [];
78
80
  }
@@ -84,6 +86,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
84
86
  locale: filter.locale,
85
87
  environments: destEnv,
86
88
  stack: stack,
89
+ apiVersion
87
90
  });
88
91
  bulkPublishAssetSet = [];
89
92
  }
@@ -95,6 +98,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
95
98
  Type: 'entry',
96
99
  environments: destEnv,
97
100
  stack: stack,
101
+ apiVersion
98
102
  });
99
103
  bulkPublishSet = [];
100
104
  }
@@ -134,6 +138,7 @@ async function getSyncEntries(
134
138
  filter,
135
139
  deliveryToken,
136
140
  destEnv,
141
+ apiVersion,
137
142
  paginationToken = null,
138
143
  ) {
139
144
  return new Promise(async (resolve, reject) => {
@@ -152,6 +157,7 @@ async function getSyncEntries(
152
157
  environment: queryParamsObj.environment,
153
158
  branch: config.branch,
154
159
  });
160
+ Stack.setHost(config.cda)
155
161
 
156
162
  const syncData = {};
157
163
 
@@ -170,7 +176,7 @@ async function getSyncEntries(
170
176
  const entriesResponse = await Stack.sync(syncData);
171
177
 
172
178
  if (entriesResponse.items.length > 0) {
173
- await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv);
179
+ await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion);
174
180
  }
175
181
  if (!entriesResponse.pagination_token) {
176
182
  if (!changedFlag) console.log('No Entries/Assets Found published on specified environment');
@@ -185,6 +191,7 @@ async function getSyncEntries(
185
191
  filter,
186
192
  deliveryToken,
187
193
  destEnv,
194
+ apiVersion,
188
195
  entriesResponse.pagination_token,
189
196
  );
190
197
  }, 3000);
@@ -224,6 +231,7 @@ async function start(
224
231
  onlyEntries,
225
232
  destEnv,
226
233
  f_types,
234
+ apiVersion
227
235
  },
228
236
  stack,
229
237
  config,
@@ -275,7 +283,7 @@ async function start(
275
283
  setConfig(config, bulkPublish);
276
284
  // filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
277
285
  const queryParams = getQueryParams(filter);
278
- await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv);
286
+ await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv, apiVersion);
279
287
  }
280
288
  }
281
289
 
@@ -225,6 +225,7 @@ async function getEntries(
225
225
  bulkPublish,
226
226
  environments,
227
227
  sourceEnv,
228
+ apiVersion,
228
229
  skip = 0,
229
230
  ) {
230
231
  return new Promise((resolve, reject) => {
@@ -267,6 +268,7 @@ async function getEntries(
267
268
  Type: 'entry',
268
269
  environments: environments,
269
270
  stack: stack,
271
+ apiVersion
270
272
  });
271
273
  bulkPublishSet = [];
272
274
  }
@@ -298,6 +300,7 @@ async function getEntries(
298
300
  Type: 'entry',
299
301
  environments: environments,
300
302
  stack: stack,
303
+ apiVersion
301
304
  });
302
305
  bulkPublishSet = [];
303
306
  }
@@ -308,7 +311,7 @@ async function getEntries(
308
311
  bulkPublishSet = [];
309
312
  return resolve();
310
313
  }
311
- await getEntries(stack, schema, contentType, languages, masterLocale, bulkPublish, environments, skipCount);
314
+ await getEntries(stack, schema, contentType, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion, skipCount);
312
315
  return resolve();
313
316
  })
314
317
  .catch((error) => reject(error));
@@ -329,7 +332,7 @@ async function getLanguages(stack) {
329
332
  });
330
333
  }
331
334
 
332
- async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, environments }, stack, config) {
335
+ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, environments, apiVersion }, stack, config) {
333
336
  process.on('beforeExit', async () => {
334
337
  const isErrorLogEmpty = await isEmpty(`${filePath}.error`);
335
338
  const isSuccessLogEmpty = await isEmpty(`${filePath}.success`);
@@ -363,7 +366,7 @@ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, enviro
363
366
  for (const element of contentTypes) {
364
367
  /* eslint-disable no-await-in-loop */
365
368
  const schema = await getContentTypeSchema(stack, element);
366
- await getEntries(stack, schema, element, languages, masterLocale, bulkPublish, environments, sourceEnv);
369
+ await getEntries(stack, schema, element, languages, masterLocale, bulkPublish, environments, sourceEnv, apiVersion);
367
370
  /* eslint-enable no-await-in-loop */
368
371
  }
369
372
  }
@@ -14,7 +14,7 @@ let filePath;
14
14
 
15
15
  /* eslint-disable no-param-reassign */
16
16
 
17
- async function getAssets(stack, folder, bulkPublish, environments, locale, skip = 0) {
17
+ async function getAssets(stack, folder, bulkPublish, environments, locale, apiVersion, skip = 0) {
18
18
  return new Promise((resolve, reject) => {
19
19
  let queryParams = {
20
20
  folder: folder,
@@ -33,7 +33,7 @@ async function getAssets(stack, folder, bulkPublish, environments, locale, skip
33
33
  let assets = assetResponse.items;
34
34
  for (let index = 0; index < assetResponse.items.length; index++) {
35
35
  if (assets[index].is_dir === true) {
36
- await getAssets(stack, assets[index].uid, bulkPublish, environments, locale, 0);
36
+ await getAssets(stack, assets[index].uid, bulkPublish, environments, locale, apiVersion, 0);
37
37
  continue;
38
38
  }
39
39
  if (bulkPublish) {
@@ -51,6 +51,7 @@ async function getAssets(stack, folder, bulkPublish, environments, locale, skip
51
51
  environments: environments,
52
52
  locale,
53
53
  stack: stack,
54
+ apiVersion
54
55
  });
55
56
  bulkPublishSet = [];
56
57
  }
@@ -62,6 +63,7 @@ async function getAssets(stack, folder, bulkPublish, environments, locale, skip
62
63
  environments: environments,
63
64
  locale,
64
65
  stack: stack,
66
+ apiVersion
65
67
  });
66
68
  bulkPublishSet = [];
67
69
  }
@@ -79,7 +81,7 @@ async function getAssets(stack, folder, bulkPublish, environments, locale, skip
79
81
  if (skip === assetResponse.count) {
80
82
  return resolve(true);
81
83
  }
82
- await getAssets(stack, folder, bulkPublish, environments, locale, skip);
84
+ await getAssets(stack, folder, bulkPublish, environments, locale, apiVersion, skip);
83
85
  return resolve();
84
86
  }
85
87
  })
@@ -102,7 +104,7 @@ function setConfig(conf, bp) {
102
104
  filePath = initializeLogger(logFileName);
103
105
  }
104
106
 
105
- async function start({ retryFailed, bulkPublish, environments, folderUid, locales }, stack, config) {
107
+ async function start({ retryFailed, bulkPublish, environments, folderUid, locales, apiVersion }, stack, config) {
106
108
  process.on('beforeExit', async () => {
107
109
  const isErrorLogEmpty = await isEmpty(`${filePath}.error`);
108
110
  const isSuccessLogEmpty = await isEmpty(`${filePath}.success`);
@@ -130,7 +132,7 @@ async function start({ retryFailed, bulkPublish, environments, folderUid, locale
130
132
  } else if (folderUid) {
131
133
  setConfig(config, bulkPublish);
132
134
  for (const element of locales) {
133
- await getAssets(stack, folderUid, bulkPublish, environments, element);
135
+ await getAssets(stack, folderUid, bulkPublish, environments, element, apiVersion);
134
136
  }
135
137
  }
136
138
  }
@@ -30,7 +30,7 @@ async function getEnvironment(stack, environmentName) {
30
30
  });
31
31
  }
32
32
 
33
- async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, skip = 0) {
33
+ async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skip = 0) {
34
34
  return new Promise((resolve, reject) => {
35
35
  skipCount = skip;
36
36
 
@@ -84,6 +84,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
84
84
  Type: 'entry',
85
85
  environments: environments,
86
86
  stack: stack,
87
+ apiVersion
87
88
  });
88
89
  bulkPublishSet = [];
89
90
  }
@@ -98,6 +99,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
98
99
  Type: 'entry',
99
100
  environments: environments,
100
101
  stack: stack,
102
+ apiVersion
101
103
  });
102
104
  bulkPublishSet = [];
103
105
  }
@@ -109,7 +111,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
109
111
  bulkPublishSet = [];
110
112
  return resolve();
111
113
  }
112
- await getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, skipCount);
114
+ await getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skipCount);
113
115
  return resolve();
114
116
  })
115
117
  .catch((error) => {
@@ -131,7 +133,7 @@ function setConfig(conf, bp) {
131
133
  filePath = initializeLogger(logFileName);
132
134
  }
133
135
 
134
- async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, locales, environments }, stack, config) {
136
+ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, locales, environments, apiVersion }, stack, config) {
135
137
  process.on('beforeExit', async () => {
136
138
  const isErrorLogEmpty = await isEmpty(`${filePath}.error`);
137
139
  const isSuccessLogEmpty = await isEmpty(`${filePath}.success`);
@@ -164,7 +166,7 @@ async function start({ retryFailed, bulkPublish, sourceEnv, contentTypes, locale
164
166
  for (let i = 0; i < contentTypes.length; i += 1) {
165
167
  for (let j = 0; j < locales.length; j += 1) {
166
168
  /* eslint-disable no-await-in-loop */
167
- await getEntries(stack, contentTypes[i], environmentDetails.uid, locales[j], bulkPublish, environments);
169
+ await getEntries(stack, contentTypes[i], environmentDetails.uid, locales[j], bulkPublish, environments, apiVersion);
168
170
  /* eslint-enable no-await-in-loop */
169
171
  }
170
172
  }
@@ -18,7 +18,7 @@ let allContentTypes = [];
18
18
  let bulkPublishSet = [];
19
19
  let filePath;
20
20
 
21
- async function getEntries(stack, contentType, locale, bulkPublish, environments, skip = 0) {
21
+ async function getEntries(stack, contentType, locale, bulkPublish, environments, apiVersion, skip = 0) {
22
22
  return new Promise((resolve, reject) => {
23
23
  skipCount = skip;
24
24
 
@@ -55,6 +55,7 @@ async function getEntries(stack, contentType, locale, bulkPublish, environments,
55
55
  Type: 'entry',
56
56
  environments: environments,
57
57
  stack: stack,
58
+ apiVersion
58
59
  });
59
60
  bulkPublishSet = [];
60
61
  }
@@ -70,6 +71,7 @@ async function getEntries(stack, contentType, locale, bulkPublish, environments,
70
71
  Type: 'entry',
71
72
  environments: environments,
72
73
  stack: stack,
74
+ apiVersion
73
75
  });
74
76
  bulkPublishSet = [];
75
77
  } // bulkPublish
@@ -90,7 +92,7 @@ async function getEntries(stack, contentType, locale, bulkPublish, environments,
90
92
  bulkPublishSet = [];
91
93
  return resolve();
92
94
  }
93
- await getEntries(stack, contentType, locale, bulkPublish, environments, skipCount);
95
+ await getEntries(stack, contentType, locale, bulkPublish, environments, apiVersion, skipCount);
94
96
  return resolve();
95
97
  })
96
98
  .catch((error) => reject(error));
@@ -133,7 +135,7 @@ function setConfig(conf, bp) {
133
135
  }
134
136
 
135
137
  async function start(
136
- { retryFailed, bulkPublish, publishAllContentTypes, contentTypes, locales, environments },
138
+ { retryFailed, bulkPublish, publishAllContentTypes, contentTypes, locales, environments, apiVersion },
137
139
  stack,
138
140
  config,
139
141
  ) {
@@ -171,7 +173,7 @@ async function start(
171
173
  for (let loc = 0; loc < locales.length; loc += 1) {
172
174
  for (let i = 0; i < allContentTypes.length; i += 1) {
173
175
  /* eslint-disable no-await-in-loop */
174
- await getEntries(stack, allContentTypes[i].uid || allContentTypes[i], locales[loc], bulkPublish, environments);
176
+ await getEntries(stack, allContentTypes[i].uid || allContentTypes[i], locales[loc], bulkPublish, environments, apiVersion);
175
177
  /* eslint-enable no-await-in-loop */
176
178
  }
177
179
  }
@@ -42,7 +42,7 @@ async function getEnvironment(stack, environmentName) {
42
42
  });
43
43
  }
44
44
 
45
- async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, skip = 0) {
45
+ async function getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skip = 0) {
46
46
  return new Promise((resolve, reject) => {
47
47
  skipCount = skip;
48
48
 
@@ -96,6 +96,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
96
96
  Type: 'entry',
97
97
  environments: environments,
98
98
  stack: stack,
99
+ apiVersion
99
100
  });
100
101
  bulkPublishSet = [];
101
102
  }
@@ -110,6 +111,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
110
111
  Type: 'entry',
111
112
  environments: environments,
112
113
  stack: stack,
114
+ apiVersion
113
115
  });
114
116
  bulkPublishSet = [];
115
117
  }
@@ -121,7 +123,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
121
123
  bulkPublishSet = [];
122
124
  return resolve();
123
125
  }
124
- await getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, skipCount);
126
+ await getEntries(stack, contentType, environmentUid, locale, bulkPublish, environments, apiVersion, skipCount);
125
127
  return resolve();
126
128
  })
127
129
  .catch((error) => {
@@ -130,7 +132,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis
130
132
  });
131
133
  }
132
134
 
133
- async function start({ sourceEnv, environments, locale, contentTypes, bulkPublish, retryFailed }, stack, config) {
135
+ async function start({ sourceEnv, environments, locale, contentTypes, bulkPublish, retryFailed, apiVersion }, stack, config) {
134
136
  process.on('beforeExit', async () => {
135
137
  const isErrorLogEmpty = await isEmpty(`${filePath}.error`);
136
138
  const isSuccessLogEmpty = await isEmpty(`${filePath}.success`);
@@ -163,7 +165,7 @@ async function start({ sourceEnv, environments, locale, contentTypes, bulkPublis
163
165
  const environmentDetails = await getEnvironment(stack, sourceEnv);
164
166
  for (let i = 0; i < contentTypes.length; i += 1) {
165
167
  /* eslint-disable no-await-in-loop */
166
- await getEntries(stack, contentTypes[i], environmentDetails.uid, locale, bulkPublish, environments);
168
+ await getEntries(stack, contentTypes[i], environmentDetails.uid, locale, bulkPublish, environments, apiVersion);
167
169
  /* eslint-enable no-await-in-loop */
168
170
  changedFlag = false;
169
171
  }
@@ -49,7 +49,7 @@ function getQueryParams(filter) {
49
49
  return queryString;
50
50
  }
51
51
 
52
- function bulkAction(stack, items, bulkUnpublish, environment, locale) {
52
+ function bulkAction(stack, items, bulkUnpublish, environment, locale, apiVersion) {
53
53
  return new Promise(async (resolve) => {
54
54
  for (let index = 0; index < items.length; index++) {
55
55
  changedFlag = true;
@@ -79,6 +79,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale) {
79
79
  locale: locale,
80
80
  environments: [environment],
81
81
  stack: stack,
82
+ apiVersion
82
83
  });
83
84
  bulkUnPulishAssetSet = [];
84
85
  }
@@ -90,6 +91,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale) {
90
91
  Type: 'entry',
91
92
  environments: [environment],
92
93
  stack: stack,
94
+ apiVersion
93
95
  });
94
96
  bulkUnPublishSet = [];
95
97
  }
@@ -100,6 +102,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale) {
100
102
  locale: locale,
101
103
  environments: [environment],
102
104
  stack: stack,
105
+ apiVersion
103
106
  });
104
107
  bulkUnPulishAssetSet = [];
105
108
  }
@@ -111,6 +114,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale) {
111
114
  Type: 'entry',
112
115
  environments: [environment],
113
116
  stack: stack,
117
+ apiVersion
114
118
  });
115
119
  bulkUnPublishSet = [];
116
120
  }
@@ -149,6 +153,7 @@ async function getSyncEntries(
149
153
  bulkUnpublish,
150
154
  environment,
151
155
  deliveryToken,
156
+ apiVersion,
152
157
  paginationToken = null,
153
158
  ) {
154
159
  return new Promise(async (resolve, reject) => {
@@ -167,6 +172,7 @@ async function getSyncEntries(
167
172
  environment: queryParamsObj.environment,
168
173
  branch: config.branch,
169
174
  });
175
+ Stack.setHost(config.cda)
170
176
 
171
177
  const syncData = {};
172
178
 
@@ -185,14 +191,14 @@ async function getSyncEntries(
185
191
  const entriesResponse = await Stack.sync(syncData);
186
192
 
187
193
  if (entriesResponse.items.length > 0) {
188
- await bulkAction(stack, entriesResponse.items, bulkUnpublish, environment, locale);
194
+ await bulkAction(stack, entriesResponse.items, bulkUnpublish, environment, locale, apiVersion);
189
195
  }
190
196
  if (entriesResponse.items.length === 0) {
191
197
  if (!changedFlag) console.log('No Entries/Assets Found published on specified environment');
192
198
  return resolve();
193
199
  }
194
200
  setTimeout(async () => {
195
- await getSyncEntries(stack, config, locale, queryParams, bulkUnpublish, environment, deliveryToken, null);
201
+ await getSyncEntries(stack, config, locale, queryParams, bulkUnpublish, environment, deliveryToken, apiVersion, null);
196
202
  }, 3000);
197
203
  } catch (error) {
198
204
  reject(error);
@@ -201,7 +207,7 @@ async function getSyncEntries(
201
207
  }
202
208
 
203
209
  async function start(
204
- { retryFailed, bulkUnpublish, contentType, locale, environment, deliveryToken, onlyAssets, onlyEntries, f_types },
210
+ { retryFailed, bulkUnpublish, contentType, locale, environment, deliveryToken, onlyAssets, onlyEntries, f_types, apiVersion },
205
211
  stack,
206
212
  config,
207
213
  ) {
@@ -253,7 +259,7 @@ async function start(
253
259
  }
254
260
  setConfig(config, bulkUnpublish);
255
261
  const queryParams = getQueryParams(filter);
256
- await getSyncEntries(stack, config, locale, queryParams, bulkUnpublish, environment, deliveryToken);
262
+ await getSyncEntries(stack, config, locale, queryParams, bulkUnpublish, environment, deliveryToken, apiVersion);
257
263
  }
258
264
  }
259
265
 
@@ -122,6 +122,10 @@ function flagsAdapter(flags) {
122
122
  flags.bulkPublish = flags['bulk-publish'];
123
123
  delete flags['bulk-publish'];
124
124
  }
125
+ if ('api-version' in flags) {
126
+ flags.apiVersion = flags['api-version'] || '3';
127
+ delete flags['api-version'];
128
+ }
125
129
  return flags;
126
130
  }
127
131