contentful-import 9.0.21 → 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 +12 -18
|
@@ -1,36 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const object_1 = require("lodash/object");
|
|
30
|
+
const defaultTransformers = __importStar(require("./transformers"));
|
|
31
|
+
const sort_entries_1 = __importDefault(require("../utils/sort-entries"));
|
|
32
|
+
const sort_locales_1 = __importDefault(require("../utils/sort-locales"));
|
|
33
|
+
const spaceEntities = [
|
|
34
|
+
'contentTypes', 'entries', 'assets', 'locales', 'webhooks', 'tags'
|
|
35
|
+
];
|
|
16
36
|
/**
|
|
17
37
|
* Run transformer methods on each item for each kind of entity, in case there
|
|
18
38
|
* is a need to transform data when copying it to the destination space
|
|
19
39
|
*/
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
function default_1(sourceData, destinationData, customTransformers, entities = spaceEntities) {
|
|
41
|
+
const transformers = (0, object_1.defaults)(customTransformers, defaultTransformers);
|
|
42
|
+
const baseSpaceData = (0, object_1.omit)(sourceData, ...entities);
|
|
43
|
+
sourceData.locales = (0, sort_locales_1.default)(sourceData.locales);
|
|
44
|
+
const tagsEnabled = !!destinationData.tags;
|
|
45
|
+
return entities.reduce((transformedSpaceData, type) => {
|
|
46
|
+
// tags don't contain links to other entities, don't need to be sorted
|
|
47
|
+
const sortedEntities = (type === 'tags') ? sourceData[type] : (0, sort_entries_1.default)(sourceData[type]);
|
|
48
|
+
const transformedEntities = sortedEntities.map((entity) => ({
|
|
49
|
+
original: entity,
|
|
50
|
+
transformed: transformers[type](entity, destinationData[type], tagsEnabled)
|
|
51
|
+
}));
|
|
52
|
+
transformedSpaceData[type] = transformedEntities;
|
|
53
|
+
return transformedSpaceData;
|
|
54
|
+
}, baseSpaceData);
|
|
35
55
|
}
|
|
36
|
-
|
|
56
|
+
exports.default = default_1;
|
|
@@ -1,75 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.assets = assets;
|
|
7
|
-
exports.contentTypes = contentTypes;
|
|
8
|
-
exports.entries = entries;
|
|
9
|
-
exports.locales = locales;
|
|
10
|
-
exports.tags = tags;
|
|
11
|
-
exports.webhooks = webhooks;
|
|
12
|
-
var _object = require("lodash/object");
|
|
13
|
-
var _collection = require("lodash/collection");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.locales = exports.assets = exports.webhooks = exports.entries = exports.tags = exports.contentTypes = void 0;
|
|
4
|
+
const object_1 = require("lodash/object");
|
|
5
|
+
const collection_1 = require("lodash/collection");
|
|
14
6
|
/**
|
|
15
7
|
* Default transformer methods for each kind of entity.
|
|
16
8
|
*
|
|
17
9
|
* In the case of assets it also changes the asset url to the upload property
|
|
18
10
|
* as the whole upload process needs to be followed again.
|
|
19
11
|
*/
|
|
20
|
-
|
|
21
12
|
function contentTypes(contentType) {
|
|
22
|
-
|
|
13
|
+
return contentType;
|
|
23
14
|
}
|
|
15
|
+
exports.contentTypes = contentTypes;
|
|
24
16
|
function tags(tag) {
|
|
25
|
-
|
|
17
|
+
return tag;
|
|
26
18
|
}
|
|
19
|
+
exports.tags = tags;
|
|
27
20
|
function entries(entry, _, tagsEnabled = false) {
|
|
28
|
-
|
|
21
|
+
return removeMetadataTags(entry, tagsEnabled);
|
|
29
22
|
}
|
|
23
|
+
exports.entries = entries;
|
|
30
24
|
function webhooks(webhook) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return webhook;
|
|
25
|
+
// Workaround for webhooks with credentials
|
|
26
|
+
if (webhook.httpBasicUsername) {
|
|
27
|
+
delete webhook.httpBasicUsername;
|
|
28
|
+
}
|
|
29
|
+
// Workaround for webhooks with secret headers
|
|
30
|
+
if (webhook.headers) {
|
|
31
|
+
webhook.headers = webhook.headers.filter(header => !header.secret);
|
|
32
|
+
}
|
|
33
|
+
return webhook;
|
|
41
34
|
}
|
|
35
|
+
exports.webhooks = webhooks;
|
|
42
36
|
function assets(asset, _, tagsEnabled = false) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
const transformedAsset = (0, object_1.omit)(asset, 'sys');
|
|
38
|
+
transformedAsset.sys = (0, object_1.pick)(asset.sys, 'id');
|
|
39
|
+
transformedAsset.fields = (0, object_1.pick)(asset.fields, 'title', 'description');
|
|
40
|
+
transformedAsset.fields.file = (0, collection_1.reduce)(asset.fields.file, (newFile, localizedFile, locale) => {
|
|
41
|
+
newFile[locale] = (0, object_1.pick)(localizedFile, 'contentType', 'fileName');
|
|
42
|
+
if (!localizedFile.uploadFrom) {
|
|
43
|
+
const assetUrl = localizedFile.url || localizedFile.upload;
|
|
44
|
+
newFile[locale].upload = `${/^(http|https):\/\//i.test(assetUrl) ? '' : 'https:'}${assetUrl}`;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
newFile[locale].uploadFrom = localizedFile.uploadFrom;
|
|
48
|
+
}
|
|
49
|
+
return newFile;
|
|
50
|
+
}, {});
|
|
51
|
+
return removeMetadataTags(transformedAsset, tagsEnabled);
|
|
57
52
|
}
|
|
53
|
+
exports.assets = assets;
|
|
58
54
|
function locales(locale, destinationLocales) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
transformedLocale
|
|
67
|
-
}
|
|
68
|
-
return transformedLocale;
|
|
55
|
+
const transformedLocale = (0, object_1.pick)(locale, 'code', 'name', 'contentManagementApi', 'contentDeliveryApi', 'fallbackCode', 'optional');
|
|
56
|
+
const destinationLocale = (0, collection_1.find)(destinationLocales, { code: locale.code });
|
|
57
|
+
if (destinationLocale) {
|
|
58
|
+
// This will implicitly remove the locale ID
|
|
59
|
+
// which then causes the create path to not pick `createLocaleWithId` but `createLocale` instead
|
|
60
|
+
transformedLocale.sys = (0, object_1.pick)(destinationLocale.sys, 'id');
|
|
61
|
+
}
|
|
62
|
+
return transformedLocale;
|
|
69
63
|
}
|
|
64
|
+
exports.locales = locales;
|
|
70
65
|
function removeMetadataTags(entity, tagsEnabled = false) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
66
|
+
if (!tagsEnabled) {
|
|
67
|
+
delete entity.metadata;
|
|
68
|
+
}
|
|
69
|
+
return entity;
|
|
70
|
+
}
|
package/dist/usageParams.js
CHANGED
|
@@ -1,76 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
30
|
+
const packageFile = __importStar(require("../package"));
|
|
31
|
+
exports.default = yargs_1.default
|
|
32
|
+
.version(packageFile.version || 'Version only available on installed package')
|
|
33
|
+
.usage('Usage: $0 [options]')
|
|
34
|
+
.option('space-id', {
|
|
35
|
+
describe: 'ID of the destination space',
|
|
36
|
+
type: 'string',
|
|
37
|
+
demand: true
|
|
38
|
+
})
|
|
39
|
+
.option('environment-id', {
|
|
40
|
+
describe: 'ID the environment in the destination space',
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: 'master',
|
|
43
|
+
demand: false
|
|
44
|
+
})
|
|
45
|
+
.option('management-token', {
|
|
46
|
+
describe: 'Contentful management API token for the destination space',
|
|
47
|
+
type: 'string',
|
|
48
|
+
demand: true
|
|
49
|
+
})
|
|
50
|
+
.option('content-file', {
|
|
51
|
+
describe: 'JSON file that contains data to be import to your space',
|
|
52
|
+
type: 'string',
|
|
53
|
+
demand: true
|
|
54
|
+
})
|
|
55
|
+
.option('content-model-only', {
|
|
56
|
+
describe: 'Import only content types',
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
default: false
|
|
59
|
+
})
|
|
60
|
+
.option('skip-content-model', {
|
|
61
|
+
describe: 'Skip importing content types and locales',
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
default: false
|
|
64
|
+
})
|
|
65
|
+
.option('skip-locales', {
|
|
66
|
+
describe: 'Skip importing locales',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
default: false
|
|
69
|
+
})
|
|
70
|
+
.option('skip-content-publishing', {
|
|
71
|
+
describe: 'Skips content publishing. Creates content but does not publish it',
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
default: false
|
|
74
|
+
})
|
|
75
|
+
.option('upload-assets', {
|
|
76
|
+
describe: 'Uses local asset files and uploads them instead of pointing to the URLs of previously uploaded assets. Requires assets-directory',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
default: false
|
|
79
|
+
})
|
|
80
|
+
.implies('upload-assets', 'assets-directory')
|
|
81
|
+
.option('assets-directory', {
|
|
82
|
+
describe: 'Path to a directory with an asset export made using the downloadAssets option to upload those files instead of pointing to the URLs of previously uploaded assets. Requires upload-assets',
|
|
83
|
+
type: 'string'
|
|
84
|
+
})
|
|
85
|
+
.implies('assets-directory', 'upload-assets')
|
|
86
|
+
.option('error-log-file', {
|
|
87
|
+
describe: 'Full path to the error log file',
|
|
88
|
+
type: 'string'
|
|
89
|
+
})
|
|
90
|
+
.option('host', {
|
|
91
|
+
describe: 'Management API host',
|
|
92
|
+
type: 'string',
|
|
93
|
+
default: 'api.contentful.com'
|
|
94
|
+
})
|
|
95
|
+
.option('proxy', {
|
|
96
|
+
describe: 'Proxy configuration in HTTP auth format: [http|https]://host:port or [http|https]://user:password@host:port',
|
|
97
|
+
type: 'string'
|
|
98
|
+
})
|
|
99
|
+
.option('raw-proxy', {
|
|
100
|
+
describe: 'Pass proxy config to Axios instead of creating a custom httpsAgent',
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
default: false
|
|
103
|
+
})
|
|
104
|
+
.option('rate-limit', {
|
|
105
|
+
describe: 'Maximum requests per second used for API requests',
|
|
106
|
+
type: 'number',
|
|
107
|
+
default: 7
|
|
108
|
+
})
|
|
109
|
+
.option('header', {
|
|
110
|
+
alias: 'H',
|
|
111
|
+
type: 'string',
|
|
112
|
+
describe: 'Pass an additional HTTP Header'
|
|
113
|
+
})
|
|
114
|
+
.config('config', 'An optional configuration JSON file containing all the options for a single run')
|
|
115
|
+
.argv;
|
package/dist/utils/headers.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getHeadersConfig = getHeadersConfig;
|
|
7
|
-
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; }
|
|
8
|
-
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; }
|
|
9
|
-
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; }
|
|
10
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
-
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHeadersConfig = void 0;
|
|
12
4
|
/**
|
|
13
5
|
* Turn header option into an object. Invalid header values
|
|
14
6
|
* are ignored.
|
|
@@ -24,22 +16,23 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
24
16
|
* @param value {string|string[]}
|
|
25
17
|
*/
|
|
26
18
|
function getHeadersConfig(value) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const values = Array.isArray(value) ? value : [value];
|
|
31
|
-
return values.reduce((headers, value) => {
|
|
32
|
-
value = value.trim();
|
|
33
|
-
const separatorIndex = value.indexOf(':');
|
|
34
|
-
|
|
35
|
-
// Invalid header format
|
|
36
|
-
if (separatorIndex === -1) {
|
|
37
|
-
return headers;
|
|
19
|
+
if (!value) {
|
|
20
|
+
return {};
|
|
38
21
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
const values = Array.isArray(value) ? value : [value];
|
|
23
|
+
return values.reduce((headers, value) => {
|
|
24
|
+
value = value.trim();
|
|
25
|
+
const separatorIndex = value.indexOf(':');
|
|
26
|
+
// Invalid header format
|
|
27
|
+
if (separatorIndex === -1) {
|
|
28
|
+
return headers;
|
|
29
|
+
}
|
|
30
|
+
const headerKey = value.slice(0, separatorIndex).trim();
|
|
31
|
+
const headerValue = value.slice(separatorIndex + 1).trim();
|
|
32
|
+
return {
|
|
33
|
+
...headers,
|
|
34
|
+
[headerKey]: headerValue
|
|
35
|
+
};
|
|
36
|
+
}, {});
|
|
37
|
+
}
|
|
38
|
+
exports.getHeadersConfig = getHeadersConfig;
|
package/dist/utils/schema.js
CHANGED
|
@@ -1,96 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
exports.payloadSchema = exports.assetSchema = exports.editorInterfaceSchema = exports.webhookSchema = exports.localeSchema = exports.tagSchema = exports.contentTypeSchema = exports.entrySchema = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
8
|
const entrySchema = {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
sys: joi_1.default.object(),
|
|
10
|
+
fields: joi_1.default.object()
|
|
12
11
|
};
|
|
13
12
|
exports.entrySchema = entrySchema;
|
|
14
13
|
const tagSchema = {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
name: joi_1.default.string().required(),
|
|
15
|
+
sys: joi_1.default.object()
|
|
17
16
|
};
|
|
18
17
|
exports.tagSchema = tagSchema;
|
|
19
18
|
const contentTypeSchema = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
then: _joi.default.string().regex(/^Asset|Entry$/),
|
|
33
|
-
otherwise: _joi.default.forbidden()
|
|
34
|
-
})
|
|
35
|
-
}))
|
|
19
|
+
sys: joi_1.default.object(),
|
|
20
|
+
fields: joi_1.default.array().required().items(joi_1.default.object().keys({
|
|
21
|
+
id: joi_1.default.string().required(),
|
|
22
|
+
name: joi_1.default.string().required(),
|
|
23
|
+
type: joi_1.default.string().required().regex(/^Symbol|Text|Integer|Number|Date|Object|Boolean|Array|Link|Location$/),
|
|
24
|
+
validations: joi_1.default.array(),
|
|
25
|
+
disabled: joi_1.default.boolean(),
|
|
26
|
+
omitted: joi_1.default.boolean(),
|
|
27
|
+
required: joi_1.default.boolean(),
|
|
28
|
+
localized: joi_1.default.boolean(),
|
|
29
|
+
linkType: joi_1.default.string().when('type', { is: 'Link', then: joi_1.default.string().regex(/^Asset|Entry$/), otherwise: joi_1.default.forbidden() })
|
|
30
|
+
}))
|
|
36
31
|
};
|
|
37
32
|
exports.contentTypeSchema = contentTypeSchema;
|
|
38
33
|
const assetSchema = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
sys: joi_1.default.object(),
|
|
35
|
+
fields: joi_1.default.object({
|
|
36
|
+
file: joi_1.default.object().pattern(/.+/, joi_1.default.object({
|
|
37
|
+
url: joi_1.default.string().required(),
|
|
38
|
+
details: joi_1.default.object({
|
|
39
|
+
size: joi_1.default.number(),
|
|
40
|
+
image: joi_1.default.object({
|
|
41
|
+
width: joi_1.default.number(),
|
|
42
|
+
height: joi_1.default.number()
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
fileName: joi_1.default.string().required(),
|
|
46
|
+
contentType: joi_1.default.string().required()
|
|
47
|
+
}))
|
|
48
|
+
}).required()
|
|
54
49
|
};
|
|
55
50
|
exports.assetSchema = assetSchema;
|
|
56
51
|
const editorInterfaceSchema = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fieldId: _joi.default.string(),
|
|
60
|
-
widgetId: _joi.default.string()
|
|
61
|
-
})
|
|
52
|
+
sys: joi_1.default.object(),
|
|
53
|
+
controls: joi_1.default.array().items({ fieldId: joi_1.default.string(), widgetId: joi_1.default.string() })
|
|
62
54
|
};
|
|
63
55
|
exports.editorInterfaceSchema = editorInterfaceSchema;
|
|
64
56
|
const localeSchema = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
name: joi_1.default.string().required(),
|
|
58
|
+
internal_code: joi_1.default.string(),
|
|
59
|
+
code: joi_1.default.string().required(),
|
|
60
|
+
fallbackCode: joi_1.default.string().allow(null),
|
|
61
|
+
default: joi_1.default.boolean(),
|
|
62
|
+
contentManagementApi: joi_1.default.boolean(),
|
|
63
|
+
contentDeliveryApi: joi_1.default.boolean(),
|
|
64
|
+
optional: joi_1.default.boolean(),
|
|
65
|
+
sys: joi_1.default.object()
|
|
74
66
|
};
|
|
75
67
|
exports.localeSchema = localeSchema;
|
|
76
68
|
const webhookSchema = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
name: joi_1.default.string(),
|
|
70
|
+
url: joi_1.default.string().replace(/{[^}{]+?}/g, 'x').regex(/^https?:\/\/[^ /}{][^ }{]*$/i).required(),
|
|
71
|
+
topics: joi_1.default.array().required(),
|
|
72
|
+
httpBasicUsername: joi_1.default.string().allow('', null)
|
|
81
73
|
};
|
|
82
|
-
|
|
74
|
+
exports.webhookSchema = webhookSchema;
|
|
83
75
|
/**
|
|
84
76
|
* @returns normalized validation object. Don't use normalized output as payload
|
|
85
77
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
webhooks: _joi.default.array().items(webhookSchema)
|
|
78
|
+
const payloadSchema = joi_1.default.object({
|
|
79
|
+
entries: joi_1.default.array().items(entrySchema),
|
|
80
|
+
contentTypes: joi_1.default.array().items(contentTypeSchema),
|
|
81
|
+
tags: joi_1.default.array().items(tagSchema),
|
|
82
|
+
assets: joi_1.default.array().items(assetSchema),
|
|
83
|
+
locales: joi_1.default.array().items(localeSchema),
|
|
84
|
+
editorInterfaces: joi_1.default.array().items(editorInterfaceSchema),
|
|
85
|
+
webhooks: joi_1.default.array().items(webhookSchema)
|
|
95
86
|
});
|
|
96
|
-
exports.payloadSchema = payloadSchema;
|
|
87
|
+
exports.payloadSchema = payloadSchema;
|