contentful-import 8.5.20 → 8.5.22

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/dist/index.js CHANGED
@@ -21,6 +21,11 @@ var _transformSpace = _interopRequireDefault(require("./transform/transform-spac
21
21
  var _validations = require("./utils/validations");
22
22
  var _parseOptions = _interopRequireDefault(require("./parseOptions"));
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
28
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
29
  const ONE_SECOND = 1000;
25
30
  function createListrOptions(options) {
26
31
  if (options.useVerboseRenderer) {
@@ -33,9 +38,9 @@ function createListrOptions(options) {
33
38
  collapse: false
34
39
  };
35
40
  }
36
- function runContentfulImport(params) {
41
+ async function runContentfulImport(params) {
37
42
  const log = [];
38
- const options = (0, _parseOptions.default)(params);
43
+ const options = await (0, _parseOptions.default)(params);
39
44
  const listrOptions = createListrOptions(options);
40
45
  const requestQueue = new _pQueue.default({
41
46
  interval: ONE_SECOND,
@@ -71,7 +76,9 @@ function runContentfulImport(params) {
71
76
  }, {
72
77
  title: 'Initialize client',
73
78
  task: (0, _listr2.wrapTask)(async ctx => {
74
- ctx.client = (0, _initClient.default)(options);
79
+ ctx.client = (0, _initClient.default)(_objectSpread(_objectSpread({}, options), {}, {
80
+ content: undefined
81
+ }));
75
82
  })
76
83
  }, {
77
84
  title: 'Checking if destination space already has any content and retrieving it',
@@ -11,6 +11,7 @@ var _package = require("../package");
11
11
  var _headers = require("./utils/headers");
12
12
  var _proxy = require("contentful-batch-libs/dist/proxy");
13
13
  var _addSequenceHeader = _interopRequireDefault(require("contentful-batch-libs/dist/add-sequence-header"));
14
+ var _jsonExt = require("@discoveryjs/json-ext");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -18,7 +19,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
18
19
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
20
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
21
  const SUPPORTED_ENTITY_TYPES = ['contentTypes', 'tags', 'entries', 'assets', 'locales', 'webhooks', 'editorInterfaces'];
21
- function parseOptions(params) {
22
+ async function parseOptions(params) {
22
23
  const defaultOptions = {
23
24
  skipContentModel: false,
24
25
  skipLocales: false,
@@ -61,10 +62,14 @@ function parseOptions(params) {
61
62
  } else {
62
63
  options.errorLogFile = (0, _path.resolve)(process.cwd(), options.errorLogFile);
63
64
  }
64
-
65
- // Further processing
66
65
  options.accessToken = options.managementToken;
67
- options.content = options.content || JSON.parse(_fs.default.readFileSync(options.contentFile));
66
+ if (!options.content) {
67
+ // using a stream parser allows input files > 512 MB
68
+ const fileStream = _fs.default.createReadStream(options.contentFile, {
69
+ encoding: 'utf8'
70
+ });
71
+ options.content = await (0, _jsonExt.parseChunked)(fileStream);
72
+ }
68
73
 
69
74
  // Clean up content to only include supported entity types
70
75
  Object.keys(options.content).forEach(type => {
@@ -43,6 +43,7 @@ async function batchedIdQuery({
43
43
  const batches = getIdBatches(ids);
44
44
  let totalFetched = 0;
45
45
  const allPendingResponses = batches.map(idBatch => {
46
+ // TODO: add batch count to indicate that it's running
46
47
  return requestQueue.add(async () => {
47
48
  const response = await environment[method]({
48
49
  'sys.id[in]': idBatch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-import",
3
- "version": "8.5.20",
3
+ "version": "8.5.22",
4
4
  "description": "this tool allows you to import JSON dump exported by contentful-export",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -50,6 +50,7 @@
50
50
  "url": "https://github.com/contentful/contentful-import/issues"
51
51
  },
52
52
  "dependencies": {
53
+ "@discoveryjs/json-ext": "^0.5.7",
53
54
  "bluebird": "^3.5.1",
54
55
  "cli-table3": "^0.6.0",
55
56
  "contentful-batch-libs": "^9.4.2",
@@ -65,7 +66,7 @@
65
66
  },
66
67
  "devDependencies": {
67
68
  "@babel/cli": "^7.20.7",
68
- "@babel/core": "^7.20.7",
69
+ "@babel/core": "^7.20.12",
69
70
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
70
71
  "@babel/preset-env": "^7.20.2",
71
72
  "babel-eslint": "^10.1.0",
@@ -75,14 +76,14 @@
75
76
  "cz-conventional-changelog": "^3.1.0",
76
77
  "eslint": "^7.2.0",
77
78
  "eslint-config-standard": "^16.0.0",
78
- "eslint-plugin-import": "^2.26.0",
79
- "eslint-plugin-jest": "^27.1.7",
79
+ "eslint-plugin-import": "^2.27.5",
80
+ "eslint-plugin-jest": "^27.2.1",
80
81
  "eslint-plugin-node": "^11.1.0",
81
82
  "eslint-plugin-promise": "^6.1.1",
82
83
  "eslint-plugin-standard": "^5.0.0",
83
- "husky": "^8.0.2",
84
+ "husky": "^8.0.3",
84
85
  "jest": "^29.3.1",
85
- "rimraf": "^3.0.2",
86
+ "rimraf": "^4.1.1",
86
87
  "semantic-release": "^19.0.5"
87
88
  },
88
89
  "files": [