contentful-import 9.0.20 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +155 -160
- package/dist/parseOptions.js +92 -89
- package/dist/tasks/get-destination-data.js +100 -133
- package/dist/tasks/init-client.js +14 -20
- package/dist/tasks/push-to-space/assets.js +66 -74
- package/dist/tasks/push-to-space/creation.js +134 -183
- package/dist/tasks/push-to-space/publishing.js +86 -86
- package/dist/tasks/push-to-space/push-to-space.js +293 -310
- package/dist/transform/transform-space.js +49 -29
- package/dist/transform/transformers.js +50 -55
- package/dist/usageParams.js +113 -74
- package/dist/utils/headers.js +21 -28
- package/dist/utils/schema.js +62 -71
- package/dist/utils/sort-entries.js +83 -60
- package/dist/utils/sort-locales.js +27 -32
- package/dist/utils/validations.js +42 -45
- package/package.json +13 -19
package/dist/index.js
CHANGED
|
@@ -1,172 +1,167 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _parseOptions = _interopRequireDefault(require("./parseOptions"));
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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); }
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
7
|
+
const differenceInSeconds_1 = __importDefault(require("date-fns/differenceInSeconds"));
|
|
8
|
+
const formatDistance_1 = __importDefault(require("date-fns/formatDistance"));
|
|
9
|
+
const listr_1 = __importDefault(require("listr"));
|
|
10
|
+
const listr_update_renderer_1 = __importDefault(require("listr-update-renderer"));
|
|
11
|
+
const listr_verbose_renderer_1 = __importDefault(require("listr-verbose-renderer"));
|
|
12
|
+
const lodash_1 = require("lodash");
|
|
13
|
+
const p_queue_1 = __importDefault(require("p-queue"));
|
|
14
|
+
const logging_1 = require("contentful-batch-libs/dist/logging");
|
|
15
|
+
const listr_2 = require("contentful-batch-libs/dist/listr");
|
|
16
|
+
const init_client_1 = __importDefault(require("./tasks/init-client"));
|
|
17
|
+
const get_destination_data_1 = __importDefault(require("./tasks/get-destination-data"));
|
|
18
|
+
const push_to_space_1 = __importDefault(require("./tasks/push-to-space/push-to-space"));
|
|
19
|
+
const transform_space_1 = __importDefault(require("./transform/transform-space"));
|
|
20
|
+
const validations_1 = require("./utils/validations");
|
|
21
|
+
const parseOptions_1 = __importDefault(require("./parseOptions"));
|
|
29
22
|
const ONE_SECOND = 1000;
|
|
30
23
|
function createListrOptions(options) {
|
|
31
|
-
|
|
24
|
+
if (options.useVerboseRenderer) {
|
|
25
|
+
return {
|
|
26
|
+
renderer: listr_verbose_renderer_1.default
|
|
27
|
+
};
|
|
28
|
+
}
|
|
32
29
|
return {
|
|
33
|
-
|
|
30
|
+
renderer: listr_update_renderer_1.default,
|
|
31
|
+
collapse: false
|
|
34
32
|
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
renderer: _listrUpdateRenderer.default,
|
|
38
|
-
collapse: false
|
|
39
|
-
};
|
|
40
33
|
}
|
|
41
34
|
async function runContentfulImport(params) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
35
|
+
const log = [];
|
|
36
|
+
const options = await (0, parseOptions_1.default)(params);
|
|
37
|
+
const listrOptions = createListrOptions(options);
|
|
38
|
+
const requestQueue = new p_queue_1.default({
|
|
39
|
+
interval: ONE_SECOND,
|
|
40
|
+
intervalCap: options.rateLimit,
|
|
41
|
+
carryoverConcurrencyCount: true
|
|
42
|
+
});
|
|
43
|
+
// Setup custom log listener to store log messages for later
|
|
44
|
+
(0, logging_1.setupLogging)(log);
|
|
45
|
+
const infoTable = new cli_table3_1.default();
|
|
46
|
+
infoTable.push([{ colSpan: 2, content: 'The following entities are going to be imported:' }]);
|
|
47
|
+
Object.keys(options.content).forEach((type) => {
|
|
48
|
+
if (options.skipLocales && type === 'locales') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (options.skipContentModel && (['contentTypes', 'editorInterfaces'].indexOf(type) >= 0)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (options.contentModelOnly && !(['contentTypes', 'editorInterfaces', 'locales'].indexOf(type) >= 0)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
infoTable.push([(0, lodash_1.startCase)(type), options.content[type].length]);
|
|
58
|
+
});
|
|
59
|
+
console.log(infoTable.toString());
|
|
60
|
+
const tasks = new listr_1.default([
|
|
61
|
+
{
|
|
62
|
+
title: 'Validating content-file',
|
|
63
|
+
task: (ctx) => {
|
|
64
|
+
(0, validations_1.assertPayload)(options.content);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: 'Initialize client',
|
|
69
|
+
task: (0, listr_2.wrapTask)(async (ctx) => {
|
|
70
|
+
ctx.client = (0, init_client_1.default)({ ...options, content: undefined });
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'Checking if destination space already has any content and retrieving it',
|
|
75
|
+
task: (0, listr_2.wrapTask)(async (ctx, task) => {
|
|
76
|
+
const destinationData = await (0, get_destination_data_1.default)({
|
|
77
|
+
client: ctx.client,
|
|
78
|
+
spaceId: options.spaceId,
|
|
79
|
+
environmentId: options.environmentId,
|
|
80
|
+
sourceData: options.content,
|
|
81
|
+
skipLocales: options.skipLocales,
|
|
82
|
+
skipContentModel: options.skipContentModel,
|
|
83
|
+
requestQueue
|
|
84
|
+
});
|
|
85
|
+
ctx.sourceDataUntransformed = options.content;
|
|
86
|
+
ctx.destinationData = destinationData;
|
|
87
|
+
(0, validations_1.assertDefaultLocale)(ctx.sourceDataUntransformed, ctx.destinationData);
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: 'Apply transformations to source data',
|
|
92
|
+
task: (0, listr_2.wrapTask)(async (ctx) => {
|
|
93
|
+
const transformedSourceData = (0, transform_space_1.default)(ctx.sourceDataUntransformed, ctx.destinationData);
|
|
94
|
+
ctx.sourceData = transformedSourceData;
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
title: 'Push content to destination space',
|
|
99
|
+
task: (ctx, task) => {
|
|
100
|
+
return (0, push_to_space_1.default)({
|
|
101
|
+
sourceData: ctx.sourceData,
|
|
102
|
+
destinationData: ctx.destinationData,
|
|
103
|
+
client: ctx.client,
|
|
104
|
+
spaceId: options.spaceId,
|
|
105
|
+
environmentId: options.environmentId,
|
|
106
|
+
contentModelOnly: options.contentModelOnly,
|
|
107
|
+
skipLocales: options.skipLocales,
|
|
108
|
+
skipContentModel: options.skipContentModel,
|
|
109
|
+
skipContentPublishing: options.skipContentPublishing,
|
|
110
|
+
timeout: options.timeout,
|
|
111
|
+
retryLimit: options.retryLimit,
|
|
112
|
+
uploadAssets: options.uploadAssets,
|
|
113
|
+
assetsDirectory: options.assetsDirectory,
|
|
114
|
+
listrOptions,
|
|
115
|
+
requestQueue
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
], listrOptions);
|
|
120
|
+
return tasks.run({
|
|
121
|
+
data: {}
|
|
82
122
|
})
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
.then((ctx) => {
|
|
124
|
+
console.log('Finished importing all data');
|
|
125
|
+
const resultTypes = Object.keys(ctx.data);
|
|
126
|
+
if (resultTypes.length) {
|
|
127
|
+
const resultTable = new cli_table3_1.default();
|
|
128
|
+
resultTable.push([{ colSpan: 2, content: 'Imported entities' }]);
|
|
129
|
+
resultTypes.forEach((type) => {
|
|
130
|
+
resultTable.push([(0, lodash_1.startCase)(type), ctx.data[type].length]);
|
|
131
|
+
});
|
|
132
|
+
console.log(resultTable.toString());
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
console.log('No data was imported');
|
|
136
|
+
}
|
|
137
|
+
const endTime = new Date();
|
|
138
|
+
const durationHuman = (0, formatDistance_1.default)(endTime, options.startTime);
|
|
139
|
+
const durationSeconds = (0, differenceInSeconds_1.default)(endTime, options.startTime);
|
|
140
|
+
console.log(`The import took ${durationHuman} (${durationSeconds}s)`);
|
|
141
|
+
return ctx.data;
|
|
98
142
|
})
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
143
|
+
.catch((err) => {
|
|
144
|
+
log.push({
|
|
145
|
+
ts: (new Date()).toJSON(),
|
|
146
|
+
level: 'error',
|
|
147
|
+
error: err
|
|
148
|
+
});
|
|
104
149
|
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
uploadAssets: options.uploadAssets,
|
|
121
|
-
assetsDirectory: options.assetsDirectory,
|
|
122
|
-
listrOptions,
|
|
123
|
-
requestQueue
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}], listrOptions);
|
|
127
|
-
return tasks.run({
|
|
128
|
-
data: {}
|
|
129
|
-
}).then(ctx => {
|
|
130
|
-
console.log('Finished importing all data');
|
|
131
|
-
const resultTypes = Object.keys(ctx.data);
|
|
132
|
-
if (resultTypes.length) {
|
|
133
|
-
const resultTable = new _cliTable.default();
|
|
134
|
-
resultTable.push([{
|
|
135
|
-
colSpan: 2,
|
|
136
|
-
content: 'Imported entities'
|
|
137
|
-
}]);
|
|
138
|
-
resultTypes.forEach(type => {
|
|
139
|
-
resultTable.push([(0, _lodash.startCase)(type), ctx.data[type].length]);
|
|
140
|
-
});
|
|
141
|
-
console.log(resultTable.toString());
|
|
142
|
-
} else {
|
|
143
|
-
console.log('No data was imported');
|
|
144
|
-
}
|
|
145
|
-
const endTime = new Date();
|
|
146
|
-
const durationHuman = (0, _formatDistance.default)(endTime, options.startTime);
|
|
147
|
-
const durationSeconds = (0, _differenceInSeconds.default)(endTime, options.startTime);
|
|
148
|
-
console.log(`The import took ${durationHuman} (${durationSeconds}s)`);
|
|
149
|
-
return ctx.data;
|
|
150
|
-
}).catch(err => {
|
|
151
|
-
log.push({
|
|
152
|
-
ts: new Date().toJSON(),
|
|
153
|
-
level: 'error',
|
|
154
|
-
error: err
|
|
150
|
+
.then((data) => {
|
|
151
|
+
const errorLog = log.filter((logMessage) => logMessage.level !== 'info' && logMessage.level !== 'warning');
|
|
152
|
+
const displayLog = log.filter((logMessage) => logMessage.level !== 'info');
|
|
153
|
+
(0, logging_1.displayErrorLog)(displayLog);
|
|
154
|
+
if (errorLog.length) {
|
|
155
|
+
return (0, logging_1.writeErrorLogFile)(options.errorLogFile, errorLog)
|
|
156
|
+
.then(() => {
|
|
157
|
+
const multiError = new Error('Errors occurred');
|
|
158
|
+
multiError.name = 'ContentfulMultiError';
|
|
159
|
+
multiError.errors = errorLog;
|
|
160
|
+
throw multiError;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
console.log('The import was successful.');
|
|
164
|
+
return data;
|
|
155
165
|
});
|
|
156
|
-
}).then(data => {
|
|
157
|
-
const errorLog = log.filter(logMessage => logMessage.level !== 'info' && logMessage.level !== 'warning');
|
|
158
|
-
const displayLog = log.filter(logMessage => logMessage.level !== 'info');
|
|
159
|
-
(0, _logging.displayErrorLog)(displayLog);
|
|
160
|
-
if (errorLog.length) {
|
|
161
|
-
return (0, _logging.writeErrorLogFile)(options.errorLogFile, errorLog).then(() => {
|
|
162
|
-
const multiError = new Error('Errors occurred');
|
|
163
|
-
multiError.name = 'ContentfulMultiError';
|
|
164
|
-
multiError.errors = errorLog;
|
|
165
|
-
throw multiError;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
console.log('The import was successful.');
|
|
169
|
-
return data;
|
|
170
|
-
});
|
|
171
166
|
}
|
|
172
|
-
|
|
167
|
+
exports.default = runContentfulImport;
|
package/dist/parseOptions.js
CHANGED
|
@@ -1,94 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const format_1 = __importDefault(require("date-fns/format"));
|
|
9
|
+
const package_1 = require("../package");
|
|
10
|
+
const headers_1 = require("./utils/headers");
|
|
11
|
+
const proxy_1 = require("contentful-batch-libs/dist/proxy");
|
|
12
|
+
const add_sequence_header_1 = __importDefault(require("contentful-batch-libs/dist/add-sequence-header"));
|
|
13
|
+
const json_ext_1 = require("@discoveryjs/json-ext");
|
|
14
|
+
const SUPPORTED_ENTITY_TYPES = [
|
|
15
|
+
'contentTypes',
|
|
16
|
+
'tags',
|
|
17
|
+
'entries',
|
|
18
|
+
'assets',
|
|
19
|
+
'locales',
|
|
20
|
+
'webhooks',
|
|
21
|
+
'editorInterfaces'
|
|
22
|
+
];
|
|
22
23
|
async function parseOptions(params) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
options.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
24
|
+
const defaultOptions = {
|
|
25
|
+
skipContentModel: false,
|
|
26
|
+
skipLocales: false,
|
|
27
|
+
skipContentPublishing: false,
|
|
28
|
+
useVerboseRenderer: false,
|
|
29
|
+
environmentId: 'master',
|
|
30
|
+
rawProxy: false,
|
|
31
|
+
uploadAssets: false,
|
|
32
|
+
rateLimit: 7
|
|
33
|
+
};
|
|
34
|
+
const configFile = params.config
|
|
35
|
+
? require((0, path_1.resolve)(process.cwd(), params.config))
|
|
36
|
+
: {};
|
|
37
|
+
const options = {
|
|
38
|
+
...defaultOptions,
|
|
39
|
+
...configFile,
|
|
40
|
+
...params,
|
|
41
|
+
headers: (0, add_sequence_header_1.default)(params.headers || (0, headers_1.getHeadersConfig)(params.header))
|
|
42
|
+
};
|
|
43
|
+
// Validation
|
|
44
|
+
if (!options.spaceId) {
|
|
45
|
+
throw new Error('The `spaceId` option is required.');
|
|
46
|
+
}
|
|
47
|
+
if (!options.managementToken) {
|
|
48
|
+
throw new Error('The `managementToken` option is required.');
|
|
49
|
+
}
|
|
50
|
+
if (!options.contentFile && !options.content) {
|
|
51
|
+
throw new Error('Either the `contentFile` or `content` option are required.');
|
|
52
|
+
}
|
|
53
|
+
if (options.contentModelOnly && options.skipContentModel) {
|
|
54
|
+
throw new Error('`contentModelOnly` and `skipContentModel` cannot be used together');
|
|
55
|
+
}
|
|
56
|
+
if (options.skipLocales && !options.contentModelOnly) {
|
|
57
|
+
throw new Error('`skipLocales` can only be used together with `contentModelOnly`');
|
|
58
|
+
}
|
|
59
|
+
const proxySimpleExp = /.+:\d+/;
|
|
60
|
+
const proxyAuthExp = /.+:.+@.+:\d+/;
|
|
61
|
+
if (typeof options.proxy === 'string' && options.proxy && !(proxySimpleExp.test(options.proxy) || proxyAuthExp.test(options.proxy))) {
|
|
62
|
+
throw new Error('Please provide the proxy config in the following format:\nhost:port or user:password@host:port');
|
|
63
|
+
}
|
|
64
|
+
options.startTime = new Date();
|
|
65
|
+
if (!options.errorLogFile) {
|
|
66
|
+
options.errorLogFile = (0, path_1.resolve)(process.cwd(), `contentful-import-error-log-${options.spaceId}-${(0, format_1.default)(options.startTime, "yyyy-MM-dd'T'HH-mm-ss")}.json`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
options.errorLogFile = (0, path_1.resolve)(process.cwd(), options.errorLogFile);
|
|
70
|
+
}
|
|
71
|
+
options.accessToken = options.managementToken;
|
|
72
|
+
if (!options.content) {
|
|
73
|
+
// using a stream parser allows input files > 512 MB
|
|
74
|
+
const fileStream = fs_1.default.createReadStream(options.contentFile, { encoding: 'utf8' });
|
|
75
|
+
options.content = await (0, json_ext_1.parseChunked)(fileStream);
|
|
76
|
+
}
|
|
77
|
+
// Clean up content to only include supported entity types
|
|
78
|
+
Object.keys(options.content).forEach((type) => {
|
|
79
|
+
if (SUPPORTED_ENTITY_TYPES.indexOf(type) === -1) {
|
|
80
|
+
delete options.content[type];
|
|
81
|
+
}
|
|
70
82
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
SUPPORTED_ENTITY_TYPES.forEach((type) => {
|
|
84
|
+
options.content[type] = options.content[type] || [];
|
|
85
|
+
});
|
|
86
|
+
if (typeof options.proxy === 'string') {
|
|
87
|
+
options.proxy = (0, proxy_1.proxyStringToObject)(options.proxy);
|
|
88
|
+
}
|
|
89
|
+
if (!options.rawProxy && options.proxy) {
|
|
90
|
+
options.httpsAgent = (0, proxy_1.agentFromProxy)(options.proxy);
|
|
91
|
+
delete options.proxy;
|
|
78
92
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
if (typeof options.proxy === 'string') {
|
|
84
|
-
options.proxy = (0, _proxy.proxyStringToObject)(options.proxy);
|
|
85
|
-
}
|
|
86
|
-
if (!options.rawProxy && options.proxy) {
|
|
87
|
-
options.httpsAgent = (0, _proxy.agentFromProxy)(options.proxy);
|
|
88
|
-
delete options.proxy;
|
|
89
|
-
}
|
|
90
|
-
options.application = options.managementApplication || `contentful.import/${_package.version}`;
|
|
91
|
-
options.feature = options.managementFeature || 'library-import';
|
|
92
|
-
return options;
|
|
93
|
+
options.application = options.managementApplication || `contentful.import/${package_1.version}`;
|
|
94
|
+
options.feature = options.managementFeature || 'library-import';
|
|
95
|
+
return options;
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
exports.default = parseOptions;
|