@contentstack/cli-cm-import 1.22.0 → 1.23.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/README.md +1 -1
- package/lib/commands/cm/stacks/import.js +2 -1
- package/lib/import/modules/base-class.js +13 -3
- package/lib/import/modules/content-types.js +2 -3
- package/lib/import/modules/global-fields.d.ts +10 -3
- package/lib/import/modules/global-fields.js +64 -18
- package/lib/utils/content-type-helper.js +71 -69
- package/lib/utils/global-field-helper.d.ts +24 -0
- package/lib/utils/global-field-helper.js +29 -0
- package/oclif.manifest.json +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import/1.
|
|
50
|
+
@contentstack/cli-cm-import/1.23.0 linux-x64 node-v22.15.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -18,7 +18,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
18
18
|
// Note setting host to create cma client
|
|
19
19
|
importConfig.host = this.cmaHost;
|
|
20
20
|
importConfig.region = this.region;
|
|
21
|
-
|
|
21
|
+
if (this.developerHubUrl)
|
|
22
|
+
importConfig.developerHubBaseUrl = this.developerHubUrl;
|
|
22
23
|
if (this.personalizeUrl)
|
|
23
24
|
importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
|
|
24
25
|
backupDir = importConfig.cliLogsPath || importConfig.backupDir;
|
|
@@ -105,7 +105,7 @@ class BaseClass {
|
|
|
105
105
|
* @return {Promise} Promise<void>
|
|
106
106
|
*/
|
|
107
107
|
makeAPICall(apiOptions, isLastRequest = false) {
|
|
108
|
-
var _a;
|
|
108
|
+
var _a, _b, _c;
|
|
109
109
|
if (apiOptions.serializeData instanceof Function) {
|
|
110
110
|
apiOptions = apiOptions.serializeData(apiOptions);
|
|
111
111
|
}
|
|
@@ -190,8 +190,18 @@ class BaseClass {
|
|
|
190
190
|
return this.stack.contentType().create(apiData).then(onSuccess).catch(onReject);
|
|
191
191
|
case 'update-cts':
|
|
192
192
|
return apiData.update().then(onSuccess).catch(onReject);
|
|
193
|
+
case 'create-gfs':
|
|
194
|
+
return this.stack.globalField({ api_version: '3.2' }).create(apiData).then(onSuccess).catch(onReject);
|
|
193
195
|
case 'update-gfs':
|
|
194
|
-
|
|
196
|
+
let globalFieldUid = (_a = apiData.uid) !== null && _a !== void 0 ? _a : (_b = apiData.global_field) === null || _b === void 0 ? void 0 : _b.uid;
|
|
197
|
+
return this.stack
|
|
198
|
+
.globalField(globalFieldUid, { api_version: '3.2' })
|
|
199
|
+
.fetch()
|
|
200
|
+
.then(async (response) => {
|
|
201
|
+
response.parent = (apiData === null || apiData === void 0 ? void 0 : apiData.uid) ? apiData : apiData.global_field;
|
|
202
|
+
await response.update().then(onSuccess).catch(onReject);
|
|
203
|
+
})
|
|
204
|
+
.catch(onReject);
|
|
195
205
|
case 'create-environments':
|
|
196
206
|
return this.stack
|
|
197
207
|
.environment()
|
|
@@ -232,7 +242,7 @@ class BaseClass {
|
|
|
232
242
|
.then(onSuccess)
|
|
233
243
|
.catch(onReject);
|
|
234
244
|
case 'create-entries':
|
|
235
|
-
if ((
|
|
245
|
+
if ((_c = additionalInfo[apiData === null || apiData === void 0 ? void 0 : apiData.uid]) === null || _c === void 0 ? void 0 : _c.isLocalized) {
|
|
236
246
|
return apiData.update({ locale: additionalInfo.locale }).then(onSuccess).catch(onReject);
|
|
237
247
|
}
|
|
238
248
|
return this.stack
|
|
@@ -170,7 +170,7 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
170
170
|
(0, utils_1.log)(this.importConfig, `Updated the global field ${uid} with content type references`, 'info');
|
|
171
171
|
};
|
|
172
172
|
const onReject = ({ error, apiData: { uid } = undefined }) => {
|
|
173
|
-
(0, utils_1.log)(this.importConfig, `
|
|
173
|
+
(0, utils_1.log)(this.importConfig, `Failed to update the global field '${uid}' ${(0, utils_1.formatError)(error)}`, 'error');
|
|
174
174
|
};
|
|
175
175
|
return await this.makeConcurrentCall({
|
|
176
176
|
processName: 'Update pending global fields',
|
|
@@ -196,8 +196,7 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
196
196
|
const { apiData: { uid }, } = apiOptions;
|
|
197
197
|
const globalField = (0, lodash_1.find)(this.gFs, { uid });
|
|
198
198
|
(0, utils_1.lookupExtension)(this.importConfig, globalField.schema, this.importConfig.preserveStackVersion, this.installedExtensions);
|
|
199
|
-
|
|
200
|
-
const globalFieldPayload = this.stack.globalField(uid);
|
|
199
|
+
const globalFieldPayload = this.stack.globalField(uid, { api_version: '3.2' });
|
|
201
200
|
Object.assign(globalFieldPayload, (0, lodash_1.cloneDeep)(globalField));
|
|
202
201
|
apiOptions.apiData = globalFieldPayload;
|
|
203
202
|
return apiOptions;
|
|
@@ -26,15 +26,22 @@ export default class ImportGlobalFields extends BaseClass {
|
|
|
26
26
|
private gFsConfig;
|
|
27
27
|
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
28
28
|
start(): Promise<any>;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
seedGFs(): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* @method serializeGFs
|
|
32
|
+
* @param {ApiOptions} apiOptions ApiOptions
|
|
33
|
+
* @returns {ApiOptions} ApiOptions
|
|
34
|
+
*/
|
|
35
|
+
serializeGFs(apiOptions: ApiOptions): ApiOptions;
|
|
36
|
+
updateGFs(): Promise<any>;
|
|
37
|
+
updateSerializedGFs({ apiParams, element: globalField, isLastRequest, }: {
|
|
31
38
|
apiParams: ApiOptions;
|
|
32
39
|
element: Record<string, string>;
|
|
33
40
|
isLastRequest: boolean;
|
|
34
41
|
}): Promise<unknown>;
|
|
35
42
|
replaceGFs(): Promise<any>;
|
|
36
43
|
/**
|
|
37
|
-
* @method
|
|
44
|
+
* @method serializeReplaceGFs
|
|
38
45
|
* @param {ApiOptions} apiOptions ApiOptions
|
|
39
46
|
* @returns {ApiOptions} ApiOptions
|
|
40
47
|
*/
|
|
@@ -12,6 +12,7 @@ const lodash_1 = require("lodash");
|
|
|
12
12
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
13
13
|
const utils_1 = require("../../utils");
|
|
14
14
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
15
|
+
const global_field_helper_1 = require("../../utils/global-field-helper");
|
|
15
16
|
class ImportGlobalFields extends base_class_1.default {
|
|
16
17
|
constructor({ importConfig, stackAPIClient }) {
|
|
17
18
|
super({ importConfig, stackAPIClient });
|
|
@@ -33,6 +34,7 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
33
34
|
this.marketplaceAppMapperPath = path.join((0, cli_utilities_1.sanitizePath)(this.config.data), 'mapper', 'marketplace_apps', 'uid-mapping.json');
|
|
34
35
|
}
|
|
35
36
|
async start() {
|
|
37
|
+
var _a;
|
|
36
38
|
this.gFs = utils_1.fsUtil.readFile(path.join(this.gFsFolderPath, this.gFsConfig.fileName));
|
|
37
39
|
if (!this.gFs || (0, lodash_1.isEmpty)(this.gFs)) {
|
|
38
40
|
(0, utils_1.log)(this.config, 'No global fields found to import', 'info');
|
|
@@ -43,8 +45,12 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
43
45
|
this.gFsUidMapper = (utils_1.fsUtil.readFile(this.gFsUidMapperPath) || {});
|
|
44
46
|
}
|
|
45
47
|
this.installedExtensions = ((await utils_1.fsUtil.readFile(this.marketplaceAppMapperPath)) || { extension_uid: {} }).extension_uid;
|
|
46
|
-
await this.
|
|
47
|
-
|
|
48
|
+
await this.seedGFs();
|
|
49
|
+
if ((_a = this.seedGFs) === null || _a === void 0 ? void 0 : _a.length)
|
|
50
|
+
utils_1.fsUtil.writeFile(this.gFsPendingPath, this.pendingGFs);
|
|
51
|
+
(0, utils_1.log)(this.importConfig, 'Created Global Fields', 'success');
|
|
52
|
+
await this.updateGFs();
|
|
53
|
+
(0, utils_1.log)(this.importConfig, 'Updated Global Fields', 'success');
|
|
48
54
|
if (this.importConfig.replaceExisting && this.existingGFs.length > 0) {
|
|
49
55
|
await this.replaceGFs().catch((error) => {
|
|
50
56
|
(0, utils_1.log)(this.importConfig, `Error while replacing global fields ${(0, utils_1.formatError)(error)}`, 'error');
|
|
@@ -52,22 +58,21 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
52
58
|
}
|
|
53
59
|
(0, utils_1.log)(this.config, 'Global fields import has been completed!', 'info');
|
|
54
60
|
}
|
|
55
|
-
async
|
|
61
|
+
async seedGFs() {
|
|
56
62
|
const onSuccess = ({ response: globalField, apiData: { uid } = undefined }) => {
|
|
57
63
|
this.createdGFs.push(globalField);
|
|
58
64
|
this.gFsUidMapper[uid] = globalField;
|
|
59
|
-
utils_1.
|
|
60
|
-
(0, utils_1.log)(this.config, 'Global field ' + uid + ' created successfully', 'success');
|
|
65
|
+
(0, utils_1.log)(this.importConfig, `Global field ${globalField.uid} created successfully`, 'success');
|
|
61
66
|
};
|
|
62
67
|
const onReject = ({ error, apiData: globalField = undefined }) => {
|
|
63
|
-
var _a;
|
|
64
|
-
const uid = globalField.uid;
|
|
65
|
-
if ((
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
const uid = (_a = globalField === null || globalField === void 0 ? void 0 : globalField.global_field) === null || _a === void 0 ? void 0 : _a.uid;
|
|
70
|
+
if ((_b = error === null || error === void 0 ? void 0 : error.errors) === null || _b === void 0 ? void 0 : _b.title) {
|
|
66
71
|
if (this.importConfig.replaceExisting) {
|
|
67
72
|
this.existingGFs.push(globalField);
|
|
68
73
|
}
|
|
69
74
|
if (!this.importConfig.skipExisting) {
|
|
70
|
-
(0, utils_1.log)(this.importConfig, `Global fields '${uid}' already exist`, 'info');
|
|
75
|
+
(0, utils_1.log)(this.importConfig, `Global fields '${(_c = globalField === null || globalField === void 0 ? void 0 : globalField.global_field) === null || _c === void 0 ? void 0 : _c.uid}' already exist`, 'info');
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
else {
|
|
@@ -80,15 +85,48 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
80
85
|
processName: 'Import global fields',
|
|
81
86
|
apiContent: this.gFs,
|
|
82
87
|
apiParams: {
|
|
88
|
+
serializeData: this.serializeGFs.bind(this),
|
|
83
89
|
reject: onReject.bind(this),
|
|
84
90
|
resolve: onSuccess.bind(this),
|
|
85
91
|
entity: 'create-gfs',
|
|
86
92
|
includeParamOnCompletion: true,
|
|
87
93
|
},
|
|
88
94
|
concurrencyLimit: this.reqConcurrency,
|
|
89
|
-
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @method serializeGFs
|
|
99
|
+
* @param {ApiOptions} apiOptions ApiOptions
|
|
100
|
+
* @returns {ApiOptions} ApiOptions
|
|
101
|
+
*/
|
|
102
|
+
serializeGFs(apiOptions) {
|
|
103
|
+
const { apiData: globalField } = apiOptions;
|
|
104
|
+
const updatedGF = (0, lodash_1.cloneDeep)(global_field_helper_1.gfSchemaTemplate);
|
|
105
|
+
updatedGF.global_field.uid = globalField.uid;
|
|
106
|
+
updatedGF.global_field.title = globalField.title;
|
|
107
|
+
apiOptions.apiData = updatedGF;
|
|
108
|
+
return apiOptions;
|
|
109
|
+
}
|
|
110
|
+
async updateGFs() {
|
|
111
|
+
const onSuccess = ({ response: globalField, apiData: { uid } = undefined }) => {
|
|
112
|
+
(0, utils_1.log)(this.importConfig, `Updated the global field ${uid}`, 'info');
|
|
113
|
+
};
|
|
114
|
+
const onReject = ({ error, apiData: { uid } = undefined }) => {
|
|
115
|
+
(0, utils_1.log)(this.importConfig, `Failed to update the global field '${uid}' ${(0, utils_1.formatError)(error)}`, 'error');
|
|
116
|
+
};
|
|
117
|
+
return await this.makeConcurrentCall({
|
|
118
|
+
processName: 'Update Global Fields',
|
|
119
|
+
apiContent: this.gFs,
|
|
120
|
+
apiParams: {
|
|
121
|
+
reject: onReject.bind(this),
|
|
122
|
+
resolve: onSuccess.bind(this),
|
|
123
|
+
entity: 'update-gfs',
|
|
124
|
+
includeParamOnCompletion: true,
|
|
125
|
+
},
|
|
126
|
+
concurrencyLimit: this.reqConcurrency,
|
|
127
|
+
}, this.updateSerializedGFs.bind(this));
|
|
90
128
|
}
|
|
91
|
-
async
|
|
129
|
+
async updateSerializedGFs({ apiParams, element: globalField, isLastRequest, }) {
|
|
92
130
|
return new Promise(async (resolve, reject) => {
|
|
93
131
|
(0, utils_1.lookupExtension)(this.config, globalField.schema, this.config.preserveStackVersion, this.installedExtensions);
|
|
94
132
|
let flag = { supressed: false };
|
|
@@ -97,8 +135,12 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
97
135
|
this.pendingGFs.push(globalField.uid);
|
|
98
136
|
}
|
|
99
137
|
return this.stack
|
|
100
|
-
.globalField()
|
|
101
|
-
.
|
|
138
|
+
.globalField(globalField.uid, { api_version: '3.2' })
|
|
139
|
+
.fetch()
|
|
140
|
+
.then((response) => {
|
|
141
|
+
Object.assign(response, globalField);
|
|
142
|
+
return response.update();
|
|
143
|
+
})
|
|
102
144
|
.then((response) => {
|
|
103
145
|
apiParams.resolve({
|
|
104
146
|
response,
|
|
@@ -116,13 +158,17 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
116
158
|
});
|
|
117
159
|
}
|
|
118
160
|
async replaceGFs() {
|
|
119
|
-
const onSuccess = ({ response: globalField, apiData
|
|
161
|
+
const onSuccess = ({ response: globalField, apiData }) => {
|
|
162
|
+
var _a, _b, _c;
|
|
163
|
+
const uid = (_c = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.uid) !== null && _a !== void 0 ? _a : (_b = apiData === null || apiData === void 0 ? void 0 : apiData.global_field) === null || _b === void 0 ? void 0 : _b.uid) !== null && _c !== void 0 ? _c : 'unknown';
|
|
120
164
|
this.createdGFs.push(globalField);
|
|
121
165
|
this.gFsUidMapper[uid] = globalField;
|
|
122
166
|
utils_1.fsUtil.writeFile(this.gFsUidMapperPath, this.gFsUidMapper);
|
|
123
|
-
(0, utils_1.log)(this.config,
|
|
167
|
+
(0, utils_1.log)(this.config, `Global field '${uid}' replaced successfully`, 'success');
|
|
124
168
|
};
|
|
125
|
-
const onReject = ({ error, apiData
|
|
169
|
+
const onReject = ({ error, apiData }) => {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
const uid = (_c = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.uid) !== null && _a !== void 0 ? _a : (_b = apiData === null || apiData === void 0 ? void 0 : apiData.global_field) === null || _b === void 0 ? void 0 : _b.uid) !== null && _c !== void 0 ? _c : 'unknown';
|
|
126
172
|
(0, utils_1.log)(this.importConfig, `Global fields '${uid}' failed to replace`, 'error');
|
|
127
173
|
(0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(error), 'error');
|
|
128
174
|
this.failedGFs.push({ uid });
|
|
@@ -141,13 +187,13 @@ class ImportGlobalFields extends base_class_1.default {
|
|
|
141
187
|
}, undefined, false);
|
|
142
188
|
}
|
|
143
189
|
/**
|
|
144
|
-
* @method
|
|
190
|
+
* @method serializeReplaceGFs
|
|
145
191
|
* @param {ApiOptions} apiOptions ApiOptions
|
|
146
192
|
* @returns {ApiOptions} ApiOptions
|
|
147
193
|
*/
|
|
148
194
|
serializeReplaceGFs(apiOptions) {
|
|
149
195
|
const { apiData: globalField } = apiOptions;
|
|
150
|
-
const globalFieldPayload = this.stack.globalField(globalField.uid);
|
|
196
|
+
const globalFieldPayload = this.stack.globalField(globalField.uid, { api_version: '3.2' });
|
|
151
197
|
Object.assign(globalFieldPayload, (0, lodash_1.cloneDeep)(globalField), {
|
|
152
198
|
stackHeaders: globalFieldPayload.stackHeaders,
|
|
153
199
|
});
|
|
@@ -87,81 +87,83 @@ const suppressSchemaReference = function (schema, flag) {
|
|
|
87
87
|
exports.suppressSchemaReference = suppressSchemaReference;
|
|
88
88
|
const removeReferenceFields = async function (schema, flag = { supressed: false }, stackAPIClient) {
|
|
89
89
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
else if (schema[i].data_type === 'blocks') {
|
|
95
|
-
for (var block in schema[i].blocks) {
|
|
96
|
-
await (0, exports.removeReferenceFields)(schema[i].blocks[block].schema, flag, stackAPIClient);
|
|
90
|
+
if (schema === null || schema === void 0 ? void 0 : schema.length) {
|
|
91
|
+
for (let i = 0; i < schema.length; i++) {
|
|
92
|
+
if (schema[i].data_type === 'group') {
|
|
93
|
+
await (0, exports.removeReferenceFields)(schema[i].schema, flag, stackAPIClient);
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Check if content-type exists
|
|
102
|
-
// If exists, then no change should be required.
|
|
103
|
-
let isContentTypeError = false;
|
|
104
|
-
for (let j = 0; j < schema[i].reference_to.length; j++) {
|
|
105
|
-
try {
|
|
106
|
-
await stackAPIClient.contentType(schema[i].reference_to[j]).fetch();
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
// Else warn and modify the schema object.
|
|
110
|
-
isContentTypeError = true;
|
|
111
|
-
console.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
|
|
95
|
+
else if (schema[i].data_type === 'blocks') {
|
|
96
|
+
for (var block in schema[i].blocks) {
|
|
97
|
+
await (0, exports.removeReferenceFields)(schema[i].blocks[block].schema, flag, stackAPIClient);
|
|
112
98
|
}
|
|
113
99
|
}
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
100
|
+
else if (schema[i].data_type === 'reference') {
|
|
101
|
+
flag.supressed = true;
|
|
102
|
+
// Check if content-type exists
|
|
103
|
+
// If exists, then no change should be required.
|
|
104
|
+
let isContentTypeError = false;
|
|
105
|
+
for (let j = 0; j < schema[i].reference_to.length; j++) {
|
|
106
|
+
try {
|
|
107
|
+
await stackAPIClient.contentType(schema[i].reference_to[j]).fetch();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
// Else warn and modify the schema object.
|
|
111
|
+
isContentTypeError = true;
|
|
112
|
+
console.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (isContentTypeError) {
|
|
116
|
+
schema.splice(i, 1);
|
|
117
|
+
--i;
|
|
118
|
+
if (schema.length < 1) {
|
|
119
|
+
schema.push({
|
|
120
|
+
data_type: 'text',
|
|
121
|
+
display_name: 'dummyTest',
|
|
122
|
+
uid: 'dummy_test',
|
|
123
|
+
field_metadata: {
|
|
124
|
+
description: '',
|
|
125
|
+
default_value: '',
|
|
126
|
+
version: 3,
|
|
127
|
+
},
|
|
129
128
|
format: '',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
error_messages: {
|
|
130
|
+
format: '',
|
|
131
|
+
},
|
|
132
|
+
multiple: false,
|
|
133
|
+
mandatory: false,
|
|
134
|
+
unique: false,
|
|
135
|
+
non_localizable: false,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
140
|
+
else if (
|
|
141
|
+
// handling entry references in json rte
|
|
142
|
+
schema[i].data_type === 'json' &&
|
|
143
|
+
schema[i].field_metadata.allow_json_rte &&
|
|
144
|
+
schema[i].field_metadata.embed_entry &&
|
|
145
|
+
schema[i].reference_to.length > 1) {
|
|
146
|
+
flag.supressed = true;
|
|
147
|
+
schema[i].reference_to = ['sys_assets'];
|
|
148
|
+
}
|
|
149
|
+
else if (
|
|
150
|
+
// handling entry references in json rte
|
|
151
|
+
schema[i].data_type === 'json' &&
|
|
152
|
+
((_b = (_a = schema[i]) === null || _a === void 0 ? void 0 : _a.field_metadata) === null || _b === void 0 ? void 0 : _b.rich_text_type) &&
|
|
153
|
+
((_d = (_c = schema[i]) === null || _c === void 0 ? void 0 : _c.field_metadata) === null || _d === void 0 ? void 0 : _d.embed_entry) &&
|
|
154
|
+
((_f = (_e = schema[i]) === null || _e === void 0 ? void 0 : _e.reference_to) === null || _f === void 0 ? void 0 : _f.length) > 1) {
|
|
155
|
+
flag.supressed = true;
|
|
156
|
+
schema[i].reference_to = ['sys_assets'];
|
|
157
|
+
}
|
|
158
|
+
else if (
|
|
159
|
+
// handling entry references in rte
|
|
160
|
+
schema[i].data_type === 'text' &&
|
|
161
|
+
((_h = (_g = schema[i]) === null || _g === void 0 ? void 0 : _g.field_metadata) === null || _h === void 0 ? void 0 : _h.rich_text_type) &&
|
|
162
|
+
((_k = (_j = schema[i]) === null || _j === void 0 ? void 0 : _j.field_metadata) === null || _k === void 0 ? void 0 : _k.embed_entry) &&
|
|
163
|
+
((_m = (_l = schema[i]) === null || _l === void 0 ? void 0 : _l.reference_to) === null || _m === void 0 ? void 0 : _m.length) >= 1) {
|
|
164
|
+
flag.supressed = true;
|
|
165
|
+
schema[i].reference_to = ['sys_assets'];
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global field utiles
|
|
3
|
+
* schema template
|
|
4
|
+
* remove reference fields
|
|
5
|
+
* suppress mandatory fields
|
|
6
|
+
*/
|
|
7
|
+
export declare const gfSchemaTemplate: {
|
|
8
|
+
global_field: {
|
|
9
|
+
title: string;
|
|
10
|
+
uid: string;
|
|
11
|
+
schema: {
|
|
12
|
+
display_name: string;
|
|
13
|
+
uid: string;
|
|
14
|
+
data_type: string;
|
|
15
|
+
field_metadata: {
|
|
16
|
+
_default: boolean;
|
|
17
|
+
};
|
|
18
|
+
unique: boolean;
|
|
19
|
+
mandatory: boolean;
|
|
20
|
+
multiple: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Global field utiles
|
|
4
|
+
* schema template
|
|
5
|
+
* remove reference fields
|
|
6
|
+
* suppress mandatory fields
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.gfSchemaTemplate = void 0;
|
|
10
|
+
exports.gfSchemaTemplate = {
|
|
11
|
+
"global_field": {
|
|
12
|
+
"title": "Seed",
|
|
13
|
+
"uid": "",
|
|
14
|
+
"schema": [
|
|
15
|
+
{
|
|
16
|
+
"display_name": "Title",
|
|
17
|
+
"uid": "title",
|
|
18
|
+
"data_type": "text",
|
|
19
|
+
"field_metadata": {
|
|
20
|
+
"_default": true
|
|
21
|
+
},
|
|
22
|
+
"unique": false,
|
|
23
|
+
"mandatory": true,
|
|
24
|
+
"multiple": false
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"description": "Seed "
|
|
28
|
+
}
|
|
29
|
+
};
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.23.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.
|
|
8
|
+
"@contentstack/cli-audit": "~1.13.0",
|
|
9
9
|
"@contentstack/cli-command": "~1.5.0",
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
11
|
-
"@contentstack/management": "~1.
|
|
10
|
+
"@contentstack/cli-utilities": "~1.12.0",
|
|
11
|
+
"@contentstack/management": "~1.21.4",
|
|
12
12
|
"@contentstack/cli-variants": "~1.2.1",
|
|
13
|
-
"@oclif/core": "^4.
|
|
13
|
+
"@oclif/core": "^4.3.0",
|
|
14
14
|
"big-json": "^3.2.0",
|
|
15
15
|
"bluebird": "^3.7.2",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
|
-
"debug": "^4.4.
|
|
18
|
-
"fs-extra": "^11.
|
|
17
|
+
"debug": "^4.4.1",
|
|
18
|
+
"fs-extra": "^11.3.0",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
20
|
"marked": "^4.3.0",
|
|
21
21
|
"merge": "^2.1.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"winston": "^3.17.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@oclif/test": "^4.1.
|
|
28
|
+
"@oclif/test": "^4.1.13",
|
|
29
29
|
"@types/big-json": "^3.2.5",
|
|
30
30
|
"@types/bluebird": "^3.5.42",
|
|
31
31
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@types/uuid": "^9.0.8",
|
|
37
37
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
38
38
|
"eslint": "^8.57.1",
|
|
39
|
-
"eslint-config-oclif": "^6.0.
|
|
39
|
+
"eslint-config-oclif": "^6.0.62",
|
|
40
40
|
"mocha": "^10.8.2",
|
|
41
41
|
"nyc": "^15.1.0",
|
|
42
|
-
"oclif": "^4.17.
|
|
42
|
+
"oclif": "^4.17.46",
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
44
|
"typescript": "^4.9.5"
|
|
45
45
|
},
|