contentful-import 9.2.0 → 9.2.2

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.
@@ -3,7 +3,7 @@ const runContentfulImport = require('../dist/index')
3
3
  const usageParams = require('../dist/usageParams')
4
4
  console.log('We moved the CLI version of this tool into our Contentful CLI.\nThis allows our users to use and install only one single CLI tool to get the full Contentful experience.\nFor more info please visit https://github.com/contentful/contentful-cli/tree/master/docs/space/import')
5
5
  runContentfulImport(usageParams)
6
- .then((result) => {
6
+ .then(() => {
7
7
  process.exit(0)
8
8
  })
9
9
  .catch(function (err) {
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ var import_p_queue = __toESM(require("p-queue"));
43
43
  var import_logging7 = require("contentful-batch-libs/dist/logging");
44
44
  var import_listr4 = require("contentful-batch-libs/dist/listr");
45
45
 
46
- // lib/tasks/init-client.js
46
+ // lib/tasks/init-client.ts
47
47
  var import_contentful_management = require("contentful-management");
48
48
  var import_logging = require("contentful-batch-libs/dist/logging");
49
49
  function logHandler(level, data) {
@@ -61,7 +61,7 @@ function initClient(opts) {
61
61
  return (0, import_contentful_management.createClient)(config);
62
62
  }
63
63
 
64
- // lib/tasks/get-destination-data.js
64
+ // lib/tasks/get-destination-data.ts
65
65
  var import_bluebird = __toESM(require("bluebird"));
66
66
  var import_logging2 = require("contentful-batch-libs/dist/logging");
67
67
  var BATCH_CHAR_LIMIT = 1990;
@@ -150,7 +150,7 @@ async function getDestinationData({
150
150
  });
151
151
  }
152
152
  }
153
- result.tags = environment.getTags().then((response) => response.items).catch((e) => {
153
+ result.tags = environment.getTags().then((response) => response.items).catch(() => {
154
154
  delete result.tags;
155
155
  });
156
156
  if (contentModelOnly) {
@@ -174,18 +174,30 @@ async function getDestinationData({
174
174
  return import_bluebird.default.props(result);
175
175
  }
176
176
 
177
- // lib/tasks/push-to-space/push-to-space.js
177
+ // lib/tasks/push-to-space/push-to-space.ts
178
178
  var import_listr = __toESM(require("listr"));
179
179
  var import_listr_verbose_renderer = __toESM(require("listr-verbose-renderer"));
180
180
  var import_logging6 = require("contentful-batch-libs/dist/logging");
181
181
  var import_listr2 = require("contentful-batch-libs/dist/listr");
182
182
 
183
- // lib/tasks/push-to-space/assets.js
183
+ // lib/tasks/push-to-space/assets.ts
184
184
  var import_fs = __toESM(require("fs"));
185
185
  var import_path = require("path");
186
186
  var import_util = require("util");
187
187
  var import_get_entity_name = __toESM(require("contentful-batch-libs/dist/get-entity-name"));
188
188
  var import_logging3 = require("contentful-batch-libs/dist/logging");
189
+
190
+ // lib/utils/errors.ts
191
+ var ContentfulAssetError = class extends Error {
192
+ constructor(message, filePath) {
193
+ super(message);
194
+ this.filePath = filePath;
195
+ }
196
+ };
197
+ var ContentfulMultiError = class extends Error {
198
+ };
199
+
200
+ // lib/tasks/push-to-space/assets.ts
189
201
  var stat = (0, import_util.promisify)(import_fs.default.stat);
190
202
  async function getAssetStreamForURL(url, assetsDirectory) {
191
203
  const [, assetPath] = url.split("//");
@@ -194,8 +206,7 @@ async function getAssetStreamForURL(url, assetsDirectory) {
194
206
  await stat(filePath);
195
207
  return import_fs.default.createReadStream(filePath);
196
208
  } catch (err) {
197
- const error = new Error("Cannot open asset from filesystem");
198
- error.filePath = filePath;
209
+ const error = new ContentfulAssetError("Cannot open asset from filesystem", filePath);
199
210
  throw error;
200
211
  }
201
212
  }
@@ -253,7 +264,7 @@ async function processAssets({
253
264
  return potentiallyProcessedAssets.filter((asset) => asset);
254
265
  }
255
266
 
256
- // lib/tasks/push-to-space/creation.js
267
+ // lib/tasks/push-to-space/creation.ts
257
268
  var import_collection = require("lodash/collection");
258
269
  var import_object = require("lodash/object");
259
270
  var import_get_entity_name2 = __toESM(require("contentful-batch-libs/dist/get-entity-name"));
@@ -389,7 +400,7 @@ function getPlainData(entity) {
389
400
  return (0, import_object.omit)(data, "sys");
390
401
  }
391
402
 
392
- // lib/tasks/push-to-space/publishing.js
403
+ // lib/tasks/push-to-space/publishing.ts
393
404
  var import_get_entity_name3 = __toESM(require("contentful-batch-libs/dist/get-entity-name"));
394
405
  var import_logging5 = require("contentful-batch-libs/dist/logging");
395
406
  async function publishEntities({ entities, requestQueue }) {
@@ -472,7 +483,7 @@ async function runQueue(queue, result = [], requestQueue) {
472
483
  return result;
473
484
  }
474
485
 
475
- // lib/tasks/push-to-space/push-to-space.js
486
+ // lib/tasks/push-to-space/push-to-space.ts
476
487
  var DEFAULT_CONTENT_STRUCTURE = {
477
488
  entries: [],
478
489
  assets: [],
@@ -521,7 +532,7 @@ function pushToSpace({
521
532
  return new import_listr.default([
522
533
  {
523
534
  title: "Connecting to space",
524
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
535
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
525
536
  const space = await client.getSpace(spaceId);
526
537
  const environment = await space.getEnvironment(environmentId);
527
538
  ctx.space = space;
@@ -530,7 +541,7 @@ function pushToSpace({
530
541
  },
531
542
  {
532
543
  title: "Importing Locales",
533
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
544
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
534
545
  const locales2 = await createLocales({
535
546
  context: { target: ctx.environment, type: "Locale" },
536
547
  entities: sourceData.locales,
@@ -543,7 +554,7 @@ function pushToSpace({
543
554
  },
544
555
  {
545
556
  title: "Importing Content Types",
546
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
557
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
547
558
  const contentTypes2 = await createEntities({
548
559
  context: { target: ctx.environment, type: "ContentType" },
549
560
  entities: sourceData.contentTypes,
@@ -556,7 +567,7 @@ function pushToSpace({
556
567
  },
557
568
  {
558
569
  title: "Publishing Content Types",
559
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
570
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
560
571
  const publishedContentTypes = await publishEntities2({
561
572
  entities: ctx.data.contentTypes,
562
573
  sourceEntities: sourceData.contentTypes,
@@ -564,11 +575,11 @@ function pushToSpace({
564
575
  });
565
576
  ctx.data.contentTypes = publishedContentTypes;
566
577
  }),
567
- skip: (ctx) => skipContentModel
578
+ skip: () => skipContentModel
568
579
  },
569
580
  {
570
581
  title: "Importing Tags",
571
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
582
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
572
583
  const tags2 = await createEntities({
573
584
  context: { target: ctx.environment, type: "Tag" },
574
585
  entities: sourceData.tags,
@@ -583,7 +594,7 @@ function pushToSpace({
583
594
  },
584
595
  {
585
596
  title: "Importing Editor Interfaces",
586
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
597
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
587
598
  const allEditorInterfacesBeingFetched = ctx.data.contentTypes.map(async (contentType) => {
588
599
  const editorInterface = sourceData.editorInterfaces.find((editorInterface2) => {
589
600
  return editorInterface2.sys.contentType.sys.id === contentType.sys.id;
@@ -612,7 +623,7 @@ function pushToSpace({
612
623
  },
613
624
  {
614
625
  title: "Uploading Assets",
615
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
626
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
616
627
  const allPendingUploads = [];
617
628
  for (const asset of sourceData.assets) {
618
629
  for (const file of Object.values(asset.transformed.fields.file)) {
@@ -642,11 +653,11 @@ function pushToSpace({
642
653
  const uploads = await Promise.all(allPendingUploads);
643
654
  ctx.data.uploadedAssetFiles = uploads;
644
655
  }),
645
- skip: (ctx) => !uploadAssets || !sourceData.assets.length
656
+ skip: () => !uploadAssets || !sourceData.assets.length
646
657
  },
647
658
  {
648
659
  title: "Importing Assets",
649
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
660
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
650
661
  const assetsToProcess = await createEntities({
651
662
  context: { target: ctx.environment, type: "Asset" },
652
663
  entities: sourceData.assets,
@@ -661,11 +672,11 @@ function pushToSpace({
661
672
  });
662
673
  ctx.data.assets = processedAssets;
663
674
  }),
664
- skip: (ctx) => contentModelOnly
675
+ skip: () => contentModelOnly
665
676
  },
666
677
  {
667
678
  title: "Publishing Assets",
668
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
679
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
669
680
  const publishedAssets = await publishEntities2({
670
681
  entities: ctx.data.assets,
671
682
  sourceEntities: sourceData.assets,
@@ -673,11 +684,11 @@ function pushToSpace({
673
684
  });
674
685
  ctx.data.publishedAssets = publishedAssets;
675
686
  }),
676
- skip: (ctx) => contentModelOnly || skipContentPublishing
687
+ skip: () => contentModelOnly || skipContentPublishing
677
688
  },
678
689
  {
679
690
  title: "Archiving Assets",
680
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
691
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
681
692
  const archivedAssets = await archiveEntities2({
682
693
  entities: ctx.data.assets,
683
694
  sourceEntities: sourceData.assets,
@@ -685,11 +696,11 @@ function pushToSpace({
685
696
  });
686
697
  ctx.data.archivedAssets = archivedAssets;
687
698
  }),
688
- skip: (ctx) => contentModelOnly || skipContentPublishing
699
+ skip: () => contentModelOnly || skipContentPublishing
689
700
  },
690
701
  {
691
702
  title: "Importing Content Entries",
692
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
703
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
693
704
  const entries2 = await createEntries({
694
705
  context: { target: ctx.environment, skipContentModel },
695
706
  entities: sourceData.entries,
@@ -698,11 +709,11 @@ function pushToSpace({
698
709
  });
699
710
  ctx.data.entries = entries2;
700
711
  }),
701
- skip: (ctx) => contentModelOnly
712
+ skip: () => contentModelOnly
702
713
  },
703
714
  {
704
715
  title: "Publishing Content Entries",
705
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
716
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
706
717
  const publishedEntries = await publishEntities2({
707
718
  entities: ctx.data.entries,
708
719
  sourceEntities: sourceData.entries,
@@ -710,11 +721,11 @@ function pushToSpace({
710
721
  });
711
722
  ctx.data.publishedEntries = publishedEntries;
712
723
  }),
713
- skip: (ctx) => contentModelOnly || skipContentPublishing
724
+ skip: () => contentModelOnly || skipContentPublishing
714
725
  },
715
726
  {
716
727
  title: "Archiving Entries",
717
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
728
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
718
729
  const archivedEntries = await archiveEntities2({
719
730
  entities: ctx.data.entries,
720
731
  sourceEntities: sourceData.entries,
@@ -722,11 +733,11 @@ function pushToSpace({
722
733
  });
723
734
  ctx.data.archivedEntries = archivedEntries;
724
735
  }),
725
- skip: (ctx) => contentModelOnly || skipContentPublishing
736
+ skip: () => contentModelOnly || skipContentPublishing
726
737
  },
727
738
  {
728
739
  title: "Creating Web Hooks",
729
- task: (0, import_listr2.wrapTask)(async (ctx, task) => {
740
+ task: (0, import_listr2.wrapTask)(async (ctx) => {
730
741
  const webhooks2 = await createEntities({
731
742
  context: { target: ctx.space, type: "Webhook" },
732
743
  entities: sourceData.webhooks,
@@ -735,7 +746,7 @@ function pushToSpace({
735
746
  });
736
747
  ctx.data.webhooks = webhooks2;
737
748
  }),
738
- skip: (ctx) => contentModelOnly || environmentId !== "master" && "Webhooks can only be imported in master environment"
749
+ skip: () => contentModelOnly || environmentId !== "master" && "Webhooks can only be imported in master environment"
739
750
  }
740
751
  ], listrOptions);
741
752
  }
@@ -750,10 +761,10 @@ function publishEntities2({ entities, sourceEntities, requestQueue }) {
750
761
  return publishEntities({ entities: entitiesToPublish, requestQueue });
751
762
  }
752
763
 
753
- // lib/transform/transform-space.js
764
+ // lib/transform/transform-space.ts
754
765
  var import_object3 = require("lodash/object");
755
766
 
756
- // lib/transform/transformers.js
767
+ // lib/transform/transformers.ts
757
768
  var transformers_exports = {};
758
769
  __export(transformers_exports, {
759
770
  assets: () => assets,
@@ -818,7 +829,7 @@ function removeMetadataTags(entity, tagsEnabled = false) {
818
829
  return entity;
819
830
  }
820
831
 
821
- // lib/utils/sort-entries.js
832
+ // lib/utils/sort-entries.ts
822
833
  var import_collection3 = require("lodash/collection");
823
834
  var _o = __toESM(require("lodash/object"));
824
835
  var import_array = require("lodash/array");
@@ -888,13 +899,13 @@ function merge(left, right, compareFn) {
888
899
  }
889
900
  }
890
901
  if (left.length)
891
- result.push.apply(result, left);
902
+ result.push(...left);
892
903
  if (right.length)
893
- result.push.apply(result, right);
904
+ result.push(...right);
894
905
  return result;
895
906
  }
896
907
 
897
- // lib/utils/sort-locales.js
908
+ // lib/utils/sort-locales.ts
898
909
  function sortLocales(locales2) {
899
910
  const localeByFallback = {};
900
911
  locales2.forEach((locale) => {
@@ -924,7 +935,7 @@ function sortByFallbackKey(localeByFallback, key) {
924
935
  return sortedLocales;
925
936
  }
926
937
 
927
- // lib/transform/transform-space.js
938
+ // lib/transform/transform-space.ts
928
939
  var spaceEntities = [
929
940
  "contentTypes",
930
941
  "entries",
@@ -949,7 +960,7 @@ function transform_space_default(sourceData, destinationData, customTransformers
949
960
  }, baseSpaceData);
950
961
  }
951
962
 
952
- // lib/utils/schema.js
963
+ // lib/utils/schema.ts
953
964
  var import_joi = __toESM(require("joi"));
954
965
  var entrySchema = {
955
966
  sys: import_joi.default.object(),
@@ -1021,7 +1032,7 @@ var payloadSchema = import_joi.default.object({
1021
1032
  webhooks: import_joi.default.array().items(webhookSchema)
1022
1033
  });
1023
1034
 
1024
- // lib/utils/validations.js
1035
+ // lib/utils/validations.ts
1025
1036
  var import_get_entity_name4 = __toESM(require("contentful-batch-libs/dist/get-entity-name"));
1026
1037
  var attachEntityName = (details, payload) => {
1027
1038
  details.map((detail) => {
@@ -1048,7 +1059,7 @@ var assertPayload = (payload) => {
1048
1059
  attachEntityName(result.error.details, payload);
1049
1060
  const invalidEntityCount = countInvalidEntities(result.error.details).join(", ");
1050
1061
  result.error.message = `${invalidEntityCount} - Get further details in the error log file`;
1051
- delete result.error._object;
1062
+ delete result.error._original;
1052
1063
  throw result.error;
1053
1064
  }
1054
1065
  };
@@ -1070,7 +1081,7 @@ var assertDefaultLocale = (source, destination) => {
1070
1081
  }
1071
1082
  };
1072
1083
 
1073
- // lib/parseOptions.js
1084
+ // lib/parseOptions.ts
1074
1085
  var import_fs2 = __toESM(require("fs"));
1075
1086
  var import_path2 = require("path");
1076
1087
  var import_format = __toESM(require("date-fns/format"));
@@ -1078,7 +1089,7 @@ var import_format = __toESM(require("date-fns/format"));
1078
1089
  // package.json
1079
1090
  var version = "0.0.0-determined-by-semantic-release";
1080
1091
 
1081
- // lib/utils/headers.js
1092
+ // lib/utils/headers.ts
1082
1093
  function getHeadersConfig(value) {
1083
1094
  if (!value) {
1084
1095
  return {};
@@ -1099,7 +1110,7 @@ function getHeadersConfig(value) {
1099
1110
  }, {});
1100
1111
  }
1101
1112
 
1102
- // lib/parseOptions.js
1113
+ // lib/parseOptions.ts
1103
1114
  var import_proxy = require("contentful-batch-libs/dist/proxy");
1104
1115
  var import_add_sequence_header = __toESM(require("contentful-batch-libs/dist/add-sequence-header"));
1105
1116
  var import_json_ext = require("@discoveryjs/json-ext");
@@ -1222,7 +1233,7 @@ async function runContentfulImport(params) {
1222
1233
  const tasks = new import_listr3.default([
1223
1234
  {
1224
1235
  title: "Validating content-file",
1225
- task: (ctx) => {
1236
+ task: () => {
1226
1237
  assertPayload(options.content);
1227
1238
  }
1228
1239
  },
@@ -1234,7 +1245,7 @@ async function runContentfulImport(params) {
1234
1245
  },
1235
1246
  {
1236
1247
  title: "Checking if destination space already has any content and retrieving it",
1237
- task: (0, import_listr4.wrapTask)(async (ctx, task) => {
1248
+ task: (0, import_listr4.wrapTask)(async (ctx) => {
1238
1249
  const destinationData = await getDestinationData({
1239
1250
  client: ctx.client,
1240
1251
  spaceId: options.spaceId,
@@ -1258,7 +1269,7 @@ async function runContentfulImport(params) {
1258
1269
  },
1259
1270
  {
1260
1271
  title: "Push content to destination space",
1261
- task: (ctx, task) => {
1272
+ task: (ctx) => {
1262
1273
  return pushToSpace({
1263
1274
  sourceData: ctx.sourceData,
1264
1275
  destinationData: ctx.destinationData,
@@ -1311,7 +1322,7 @@ async function runContentfulImport(params) {
1311
1322
  (0, import_logging7.displayErrorLog)(displayLog);
1312
1323
  if (errorLog.length) {
1313
1324
  return (0, import_logging7.writeErrorLogFile)(options.errorLogFile, errorLog).then(() => {
1314
- const multiError = new Error("Errors occurred");
1325
+ const multiError = new ContentfulMultiError("Errors occurred");
1315
1326
  multiError.name = "ContentfulMultiError";
1316
1327
  multiError.errors = errorLog;
1317
1328
  throw multiError;
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import PQueue from "p-queue";
23
23
  import { displayErrorLog, setupLogging, writeErrorLogFile } from "contentful-batch-libs/dist/logging";
24
24
  import { wrapTask as wrapTask2 } from "contentful-batch-libs/dist/listr";
25
25
 
26
- // lib/tasks/init-client.js
26
+ // lib/tasks/init-client.ts
27
27
  import { createClient } from "contentful-management";
28
28
  import { logEmitter } from "contentful-batch-libs/dist/logging";
29
29
  function logHandler(level, data) {
@@ -41,7 +41,7 @@ function initClient(opts) {
41
41
  return createClient(config);
42
42
  }
43
43
 
44
- // lib/tasks/get-destination-data.js
44
+ // lib/tasks/get-destination-data.ts
45
45
  import Promise2 from "bluebird";
46
46
  import { logEmitter as logEmitter2 } from "contentful-batch-libs/dist/logging";
47
47
  var BATCH_CHAR_LIMIT = 1990;
@@ -130,7 +130,7 @@ async function getDestinationData({
130
130
  });
131
131
  }
132
132
  }
133
- result.tags = environment.getTags().then((response) => response.items).catch((e) => {
133
+ result.tags = environment.getTags().then((response) => response.items).catch(() => {
134
134
  delete result.tags;
135
135
  });
136
136
  if (contentModelOnly) {
@@ -154,18 +154,30 @@ async function getDestinationData({
154
154
  return Promise2.props(result);
155
155
  }
156
156
 
157
- // lib/tasks/push-to-space/push-to-space.js
157
+ // lib/tasks/push-to-space/push-to-space.ts
158
158
  import Listr from "listr";
159
159
  import verboseRenderer from "listr-verbose-renderer";
160
160
  import { logEmitter as logEmitter6 } from "contentful-batch-libs/dist/logging";
161
161
  import { wrapTask } from "contentful-batch-libs/dist/listr";
162
162
 
163
- // lib/tasks/push-to-space/assets.js
163
+ // lib/tasks/push-to-space/assets.ts
164
164
  import fs from "fs";
165
165
  import { join } from "path";
166
166
  import { promisify } from "util";
167
167
  import getEntityName from "contentful-batch-libs/dist/get-entity-name";
168
168
  import { logEmitter as logEmitter3 } from "contentful-batch-libs/dist/logging";
169
+
170
+ // lib/utils/errors.ts
171
+ var ContentfulAssetError = class extends Error {
172
+ constructor(message, filePath) {
173
+ super(message);
174
+ this.filePath = filePath;
175
+ }
176
+ };
177
+ var ContentfulMultiError = class extends Error {
178
+ };
179
+
180
+ // lib/tasks/push-to-space/assets.ts
169
181
  var stat = promisify(fs.stat);
170
182
  async function getAssetStreamForURL(url, assetsDirectory) {
171
183
  const [, assetPath] = url.split("//");
@@ -174,8 +186,7 @@ async function getAssetStreamForURL(url, assetsDirectory) {
174
186
  await stat(filePath);
175
187
  return fs.createReadStream(filePath);
176
188
  } catch (err) {
177
- const error = new Error("Cannot open asset from filesystem");
178
- error.filePath = filePath;
189
+ const error = new ContentfulAssetError("Cannot open asset from filesystem", filePath);
179
190
  throw error;
180
191
  }
181
192
  }
@@ -233,7 +244,7 @@ async function processAssets({
233
244
  return potentiallyProcessedAssets.filter((asset) => asset);
234
245
  }
235
246
 
236
- // lib/tasks/push-to-space/creation.js
247
+ // lib/tasks/push-to-space/creation.ts
237
248
  import { find } from "lodash/collection";
238
249
  import { assign, get, omitBy, omit } from "lodash/object";
239
250
  import getEntityName2 from "contentful-batch-libs/dist/get-entity-name";
@@ -369,7 +380,7 @@ function getPlainData(entity) {
369
380
  return omit(data, "sys");
370
381
  }
371
382
 
372
- // lib/tasks/push-to-space/publishing.js
383
+ // lib/tasks/push-to-space/publishing.ts
373
384
  import getEntityName3 from "contentful-batch-libs/dist/get-entity-name";
374
385
  import { logEmitter as logEmitter5 } from "contentful-batch-libs/dist/logging";
375
386
  async function publishEntities({ entities, requestQueue }) {
@@ -452,7 +463,7 @@ async function runQueue(queue, result = [], requestQueue) {
452
463
  return result;
453
464
  }
454
465
 
455
- // lib/tasks/push-to-space/push-to-space.js
466
+ // lib/tasks/push-to-space/push-to-space.ts
456
467
  var DEFAULT_CONTENT_STRUCTURE = {
457
468
  entries: [],
458
469
  assets: [],
@@ -501,7 +512,7 @@ function pushToSpace({
501
512
  return new Listr([
502
513
  {
503
514
  title: "Connecting to space",
504
- task: wrapTask(async (ctx, task) => {
515
+ task: wrapTask(async (ctx) => {
505
516
  const space = await client.getSpace(spaceId);
506
517
  const environment = await space.getEnvironment(environmentId);
507
518
  ctx.space = space;
@@ -510,7 +521,7 @@ function pushToSpace({
510
521
  },
511
522
  {
512
523
  title: "Importing Locales",
513
- task: wrapTask(async (ctx, task) => {
524
+ task: wrapTask(async (ctx) => {
514
525
  const locales2 = await createLocales({
515
526
  context: { target: ctx.environment, type: "Locale" },
516
527
  entities: sourceData.locales,
@@ -523,7 +534,7 @@ function pushToSpace({
523
534
  },
524
535
  {
525
536
  title: "Importing Content Types",
526
- task: wrapTask(async (ctx, task) => {
537
+ task: wrapTask(async (ctx) => {
527
538
  const contentTypes2 = await createEntities({
528
539
  context: { target: ctx.environment, type: "ContentType" },
529
540
  entities: sourceData.contentTypes,
@@ -536,7 +547,7 @@ function pushToSpace({
536
547
  },
537
548
  {
538
549
  title: "Publishing Content Types",
539
- task: wrapTask(async (ctx, task) => {
550
+ task: wrapTask(async (ctx) => {
540
551
  const publishedContentTypes = await publishEntities2({
541
552
  entities: ctx.data.contentTypes,
542
553
  sourceEntities: sourceData.contentTypes,
@@ -544,11 +555,11 @@ function pushToSpace({
544
555
  });
545
556
  ctx.data.contentTypes = publishedContentTypes;
546
557
  }),
547
- skip: (ctx) => skipContentModel
558
+ skip: () => skipContentModel
548
559
  },
549
560
  {
550
561
  title: "Importing Tags",
551
- task: wrapTask(async (ctx, task) => {
562
+ task: wrapTask(async (ctx) => {
552
563
  const tags2 = await createEntities({
553
564
  context: { target: ctx.environment, type: "Tag" },
554
565
  entities: sourceData.tags,
@@ -563,7 +574,7 @@ function pushToSpace({
563
574
  },
564
575
  {
565
576
  title: "Importing Editor Interfaces",
566
- task: wrapTask(async (ctx, task) => {
577
+ task: wrapTask(async (ctx) => {
567
578
  const allEditorInterfacesBeingFetched = ctx.data.contentTypes.map(async (contentType) => {
568
579
  const editorInterface = sourceData.editorInterfaces.find((editorInterface2) => {
569
580
  return editorInterface2.sys.contentType.sys.id === contentType.sys.id;
@@ -592,7 +603,7 @@ function pushToSpace({
592
603
  },
593
604
  {
594
605
  title: "Uploading Assets",
595
- task: wrapTask(async (ctx, task) => {
606
+ task: wrapTask(async (ctx) => {
596
607
  const allPendingUploads = [];
597
608
  for (const asset of sourceData.assets) {
598
609
  for (const file of Object.values(asset.transformed.fields.file)) {
@@ -622,11 +633,11 @@ function pushToSpace({
622
633
  const uploads = await Promise.all(allPendingUploads);
623
634
  ctx.data.uploadedAssetFiles = uploads;
624
635
  }),
625
- skip: (ctx) => !uploadAssets || !sourceData.assets.length
636
+ skip: () => !uploadAssets || !sourceData.assets.length
626
637
  },
627
638
  {
628
639
  title: "Importing Assets",
629
- task: wrapTask(async (ctx, task) => {
640
+ task: wrapTask(async (ctx) => {
630
641
  const assetsToProcess = await createEntities({
631
642
  context: { target: ctx.environment, type: "Asset" },
632
643
  entities: sourceData.assets,
@@ -641,11 +652,11 @@ function pushToSpace({
641
652
  });
642
653
  ctx.data.assets = processedAssets;
643
654
  }),
644
- skip: (ctx) => contentModelOnly
655
+ skip: () => contentModelOnly
645
656
  },
646
657
  {
647
658
  title: "Publishing Assets",
648
- task: wrapTask(async (ctx, task) => {
659
+ task: wrapTask(async (ctx) => {
649
660
  const publishedAssets = await publishEntities2({
650
661
  entities: ctx.data.assets,
651
662
  sourceEntities: sourceData.assets,
@@ -653,11 +664,11 @@ function pushToSpace({
653
664
  });
654
665
  ctx.data.publishedAssets = publishedAssets;
655
666
  }),
656
- skip: (ctx) => contentModelOnly || skipContentPublishing
667
+ skip: () => contentModelOnly || skipContentPublishing
657
668
  },
658
669
  {
659
670
  title: "Archiving Assets",
660
- task: wrapTask(async (ctx, task) => {
671
+ task: wrapTask(async (ctx) => {
661
672
  const archivedAssets = await archiveEntities2({
662
673
  entities: ctx.data.assets,
663
674
  sourceEntities: sourceData.assets,
@@ -665,11 +676,11 @@ function pushToSpace({
665
676
  });
666
677
  ctx.data.archivedAssets = archivedAssets;
667
678
  }),
668
- skip: (ctx) => contentModelOnly || skipContentPublishing
679
+ skip: () => contentModelOnly || skipContentPublishing
669
680
  },
670
681
  {
671
682
  title: "Importing Content Entries",
672
- task: wrapTask(async (ctx, task) => {
683
+ task: wrapTask(async (ctx) => {
673
684
  const entries2 = await createEntries({
674
685
  context: { target: ctx.environment, skipContentModel },
675
686
  entities: sourceData.entries,
@@ -678,11 +689,11 @@ function pushToSpace({
678
689
  });
679
690
  ctx.data.entries = entries2;
680
691
  }),
681
- skip: (ctx) => contentModelOnly
692
+ skip: () => contentModelOnly
682
693
  },
683
694
  {
684
695
  title: "Publishing Content Entries",
685
- task: wrapTask(async (ctx, task) => {
696
+ task: wrapTask(async (ctx) => {
686
697
  const publishedEntries = await publishEntities2({
687
698
  entities: ctx.data.entries,
688
699
  sourceEntities: sourceData.entries,
@@ -690,11 +701,11 @@ function pushToSpace({
690
701
  });
691
702
  ctx.data.publishedEntries = publishedEntries;
692
703
  }),
693
- skip: (ctx) => contentModelOnly || skipContentPublishing
704
+ skip: () => contentModelOnly || skipContentPublishing
694
705
  },
695
706
  {
696
707
  title: "Archiving Entries",
697
- task: wrapTask(async (ctx, task) => {
708
+ task: wrapTask(async (ctx) => {
698
709
  const archivedEntries = await archiveEntities2({
699
710
  entities: ctx.data.entries,
700
711
  sourceEntities: sourceData.entries,
@@ -702,11 +713,11 @@ function pushToSpace({
702
713
  });
703
714
  ctx.data.archivedEntries = archivedEntries;
704
715
  }),
705
- skip: (ctx) => contentModelOnly || skipContentPublishing
716
+ skip: () => contentModelOnly || skipContentPublishing
706
717
  },
707
718
  {
708
719
  title: "Creating Web Hooks",
709
- task: wrapTask(async (ctx, task) => {
720
+ task: wrapTask(async (ctx) => {
710
721
  const webhooks2 = await createEntities({
711
722
  context: { target: ctx.space, type: "Webhook" },
712
723
  entities: sourceData.webhooks,
@@ -715,7 +726,7 @@ function pushToSpace({
715
726
  });
716
727
  ctx.data.webhooks = webhooks2;
717
728
  }),
718
- skip: (ctx) => contentModelOnly || environmentId !== "master" && "Webhooks can only be imported in master environment"
729
+ skip: () => contentModelOnly || environmentId !== "master" && "Webhooks can only be imported in master environment"
719
730
  }
720
731
  ], listrOptions);
721
732
  }
@@ -730,10 +741,10 @@ function publishEntities2({ entities, sourceEntities, requestQueue }) {
730
741
  return publishEntities({ entities: entitiesToPublish, requestQueue });
731
742
  }
732
743
 
733
- // lib/transform/transform-space.js
744
+ // lib/transform/transform-space.ts
734
745
  import { omit as omit3, defaults } from "lodash/object";
735
746
 
736
- // lib/transform/transformers.js
747
+ // lib/transform/transformers.ts
737
748
  var transformers_exports = {};
738
749
  __export(transformers_exports, {
739
750
  assets: () => assets,
@@ -798,7 +809,7 @@ function removeMetadataTags(entity, tagsEnabled = false) {
798
809
  return entity;
799
810
  }
800
811
 
801
- // lib/utils/sort-entries.js
812
+ // lib/utils/sort-entries.ts
802
813
  import { some, filter, map } from "lodash/collection";
803
814
  import * as _o from "lodash/object";
804
815
  import { flatten } from "lodash/array";
@@ -868,13 +879,13 @@ function merge(left, right, compareFn) {
868
879
  }
869
880
  }
870
881
  if (left.length)
871
- result.push.apply(result, left);
882
+ result.push(...left);
872
883
  if (right.length)
873
- result.push.apply(result, right);
884
+ result.push(...right);
874
885
  return result;
875
886
  }
876
887
 
877
- // lib/utils/sort-locales.js
888
+ // lib/utils/sort-locales.ts
878
889
  function sortLocales(locales2) {
879
890
  const localeByFallback = {};
880
891
  locales2.forEach((locale) => {
@@ -904,7 +915,7 @@ function sortByFallbackKey(localeByFallback, key) {
904
915
  return sortedLocales;
905
916
  }
906
917
 
907
- // lib/transform/transform-space.js
918
+ // lib/transform/transform-space.ts
908
919
  var spaceEntities = [
909
920
  "contentTypes",
910
921
  "entries",
@@ -929,7 +940,7 @@ function transform_space_default(sourceData, destinationData, customTransformers
929
940
  }, baseSpaceData);
930
941
  }
931
942
 
932
- // lib/utils/schema.js
943
+ // lib/utils/schema.ts
933
944
  import Joi from "joi";
934
945
  var entrySchema = {
935
946
  sys: Joi.object(),
@@ -1001,7 +1012,7 @@ var payloadSchema = Joi.object({
1001
1012
  webhooks: Joi.array().items(webhookSchema)
1002
1013
  });
1003
1014
 
1004
- // lib/utils/validations.js
1015
+ // lib/utils/validations.ts
1005
1016
  import getEntityName4 from "contentful-batch-libs/dist/get-entity-name";
1006
1017
  var attachEntityName = (details, payload) => {
1007
1018
  details.map((detail) => {
@@ -1028,7 +1039,7 @@ var assertPayload = (payload) => {
1028
1039
  attachEntityName(result.error.details, payload);
1029
1040
  const invalidEntityCount = countInvalidEntities(result.error.details).join(", ");
1030
1041
  result.error.message = `${invalidEntityCount} - Get further details in the error log file`;
1031
- delete result.error._object;
1042
+ delete result.error._original;
1032
1043
  throw result.error;
1033
1044
  }
1034
1045
  };
@@ -1050,7 +1061,7 @@ var assertDefaultLocale = (source, destination) => {
1050
1061
  }
1051
1062
  };
1052
1063
 
1053
- // lib/parseOptions.js
1064
+ // lib/parseOptions.ts
1054
1065
  import fs2 from "fs";
1055
1066
  import { resolve } from "path";
1056
1067
  import format from "date-fns/format";
@@ -1058,7 +1069,7 @@ import format from "date-fns/format";
1058
1069
  // package.json
1059
1070
  var version = "0.0.0-determined-by-semantic-release";
1060
1071
 
1061
- // lib/utils/headers.js
1072
+ // lib/utils/headers.ts
1062
1073
  function getHeadersConfig(value) {
1063
1074
  if (!value) {
1064
1075
  return {};
@@ -1079,7 +1090,7 @@ function getHeadersConfig(value) {
1079
1090
  }, {});
1080
1091
  }
1081
1092
 
1082
- // lib/parseOptions.js
1093
+ // lib/parseOptions.ts
1083
1094
  import { proxyStringToObject, agentFromProxy } from "contentful-batch-libs/dist/proxy";
1084
1095
  import addSequenceHeader from "contentful-batch-libs/dist/add-sequence-header";
1085
1096
  import { parseChunked } from "@discoveryjs/json-ext";
@@ -1202,7 +1213,7 @@ async function runContentfulImport(params) {
1202
1213
  const tasks = new Listr2([
1203
1214
  {
1204
1215
  title: "Validating content-file",
1205
- task: (ctx) => {
1216
+ task: () => {
1206
1217
  assertPayload(options.content);
1207
1218
  }
1208
1219
  },
@@ -1214,7 +1225,7 @@ async function runContentfulImport(params) {
1214
1225
  },
1215
1226
  {
1216
1227
  title: "Checking if destination space already has any content and retrieving it",
1217
- task: wrapTask2(async (ctx, task) => {
1228
+ task: wrapTask2(async (ctx) => {
1218
1229
  const destinationData = await getDestinationData({
1219
1230
  client: ctx.client,
1220
1231
  spaceId: options.spaceId,
@@ -1238,7 +1249,7 @@ async function runContentfulImport(params) {
1238
1249
  },
1239
1250
  {
1240
1251
  title: "Push content to destination space",
1241
- task: (ctx, task) => {
1252
+ task: (ctx) => {
1242
1253
  return pushToSpace({
1243
1254
  sourceData: ctx.sourceData,
1244
1255
  destinationData: ctx.destinationData,
@@ -1291,7 +1302,7 @@ async function runContentfulImport(params) {
1291
1302
  displayErrorLog(displayLog);
1292
1303
  if (errorLog.length) {
1293
1304
  return writeErrorLogFile(options.errorLogFile, errorLog).then(() => {
1294
- const multiError = new Error("Errors occurred");
1305
+ const multiError = new ContentfulMultiError("Errors occurred");
1295
1306
  multiError.name = "ContentfulMultiError";
1296
1307
  multiError.errors = errorLog;
1297
1308
  throw multiError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-import",
3
- "version": "9.2.0",
3
+ "version": "9.2.2",
4
4
  "description": "this tool allows you to import JSON dump exported by contentful-export",
5
5
  "main": "dist/index.mjs",
6
6
  "typings": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "build": "tsup",
22
22
  "build:watch": "babel lib --out-dir dist --watch",
23
23
  "clean": "rimraf dist && rimraf coverage",
24
- "lint": "eslint lib bin/contentful-import test",
24
+ "lint": "eslint lib bin/contentful-import test && tsc",
25
25
  "pretest": "npm run lint && npm run build",
26
26
  "test": "npm run test:unit && npm run test:integration",
27
27
  "test:unit": "jest --testPathPattern=test/unit --runInBand --coverage",
@@ -73,11 +73,11 @@
73
73
  "bluebird": "^3.5.1",
74
74
  "cli-table3": "^0.6.0",
75
75
  "contentful-batch-libs": "^9.5.0",
76
- "contentful-management": "^10.46.2",
76
+ "contentful-management": "^10.46.4",
77
77
  "date-fns": "^2.30.0",
78
78
  "eslint": "^8.50.0",
79
79
  "eslint-config-standard": "^17.1.0",
80
- "joi": "^17.10.2",
80
+ "joi": "^17.11.0",
81
81
  "listr": "^0.14.1",
82
82
  "listr-update-renderer": "^0.5.0",
83
83
  "listr-verbose-renderer": "^0.6.0",
@@ -92,20 +92,20 @@
92
92
  "@babel/preset-env": "^7.22.20",
93
93
  "@types/jest": "^29.5.5",
94
94
  "@types/node": "^20.6.3",
95
- "@typescript-eslint/eslint-plugin": "^6.7.2",
96
- "@typescript-eslint/parser": "^6.7.2",
95
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
96
+ "@typescript-eslint/parser": "^6.7.4",
97
97
  "babel-jest": "^29.7.0",
98
98
  "babel-plugin-add-module-exports": "^1.0.2",
99
99
  "babel-preset-env": "^1.7.0",
100
100
  "cz-conventional-changelog": "^3.1.0",
101
101
  "eslint-plugin-import": "^2.28.1",
102
- "eslint-plugin-jest": "^27.4.0",
102
+ "eslint-plugin-jest": "^27.4.2",
103
103
  "eslint-plugin-node": "^11.1.0",
104
104
  "eslint-plugin-promise": "^6.1.1",
105
105
  "eslint-plugin-standard": "^5.0.0",
106
106
  "husky": "^8.0.3",
107
107
  "jest": "^29.7.0",
108
- "rimraf": "^5.0.0",
108
+ "rimraf": "^5.0.5",
109
109
  "semantic-release": "^19.0.5",
110
110
  "ts-jest": "^29.1.1",
111
111
  "tsup": "^7.2.0",