@strapi/data-transfer 4.14.0-alpha.0 → 4.14.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/commands/commander.d.ts +35 -0
- package/dist/commands/commander.js +138 -0
- package/dist/commands/commander.js.map +1 -0
- package/dist/commands/data-transfer.d.ts +135 -0
- package/dist/commands/data-transfer.js +359 -0
- package/dist/commands/data-transfer.js.map +1 -0
- package/dist/commands/export/action.d.ts +20 -0
- package/dist/commands/export/action.js +156 -0
- package/dist/commands/export/action.js.map +1 -0
- package/dist/commands/export/command.d.ts +8 -0
- package/dist/commands/export/command.js +30 -0
- package/dist/commands/export/command.js.map +1 -0
- package/dist/commands/helpers.d.ts +30 -0
- package/dist/commands/helpers.js +87 -0
- package/dist/commands/helpers.js.map +1 -0
- package/dist/commands/import/action.d.ts +19 -0
- package/dist/commands/import/action.js +139 -0
- package/dist/commands/import/action.js.map +1 -0
- package/dist/commands/import/command.d.ts +8 -0
- package/dist/commands/import/command.js +75 -0
- package/dist/commands/import/command.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/transfer/action.d.ts +18 -0
- package/dist/commands/transfer/action.js +161 -0
- package/dist/commands/transfer/action.js.map +1 -0
- package/dist/commands/transfer/command.d.ts +8 -0
- package/dist/commands/transfer/command.js +69 -0
- package/dist/commands/transfer/command.js.map +1 -0
- package/dist/engine/index.d.ts +2 -1
- package/dist/engine/index.js +330 -297
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/validation/schemas/index.js.map +1 -1
- package/dist/errors/base.js +3 -0
- package/dist/errors/base.js.map +1 -1
- package/dist/file/providers/destination/index.js +51 -55
- package/dist/file/providers/destination/index.js.map +1 -1
- package/dist/file/providers/source/index.d.ts +1 -1
- package/dist/file/providers/source/index.js +111 -119
- package/dist/file/providers/source/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +4 -3
- package/dist/strapi/providers/local-destination/index.js +120 -125
- package/dist/strapi/providers/local-destination/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +3 -2
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +2 -2
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +5 -2
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +2 -2
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +2 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts +2 -1
- package/dist/strapi/providers/local-source/assets.js +1 -1
- package/dist/strapi/providers/local-source/assets.js.map +1 -1
- package/dist/strapi/providers/local-source/configuration.d.ts +2 -1
- package/dist/strapi/providers/local-source/configuration.js.map +1 -1
- package/dist/strapi/providers/local-source/entities.d.ts +2 -1
- package/dist/strapi/providers/local-source/entities.js.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +4 -3
- package/dist/strapi/providers/local-source/index.js +5 -3
- package/dist/strapi/providers/local-source/index.js.map +1 -1
- package/dist/strapi/providers/local-source/links.d.ts +2 -1
- package/dist/strapi/providers/local-source/links.js.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +1 -1
- package/dist/strapi/providers/remote-destination/index.js +95 -94
- package/dist/strapi/providers/remote-destination/index.js.map +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts +1 -1
- package/dist/strapi/providers/remote-source/index.js +93 -93
- package/dist/strapi/providers/remote-source/index.js.map +1 -1
- package/dist/strapi/providers/utils.d.ts +2 -2
- package/dist/strapi/queries/entity.d.ts +2 -1
- package/dist/strapi/queries/entity.js +4 -4
- package/dist/strapi/queries/entity.js.map +1 -1
- package/dist/strapi/queries/link.d.ts +2 -1
- package/dist/strapi/queries/link.js +13 -4
- package/dist/strapi/queries/link.js.map +1 -1
- package/dist/strapi/remote/handlers/pull.js.map +1 -1
- package/dist/strapi/remote/handlers/push.js.map +1 -1
- package/dist/utils/components.d.ts +22 -0
- package/dist/utils/components.js +381 -0
- package/dist/utils/components.js.map +1 -0
- package/dist/utils/providers.d.ts +2 -1
- package/dist/utils/providers.js.map +1 -1
- package/dist/utils/schema.d.ts +1 -1
- package/dist/utils/transaction.d.ts +2 -2
- package/dist/utils/transaction.js.map +1 -1
- package/package.json +17 -10
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
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.cloneComponents = exports.deleteComponent = exports.deleteComponents = exports.updateComponents = exports.createComponents = exports.getComponents = exports.omitComponentData = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const fp_1 = require("lodash/fp");
|
|
9
|
+
const utils_1 = require("@strapi/utils");
|
|
10
|
+
const isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';
|
|
11
|
+
function omitComponentData(contentType, data) {
|
|
12
|
+
const { attributes } = contentType;
|
|
13
|
+
const componentAttributes = Object.keys(attributes).filter((attributeName) => utils_1.contentTypes.isComponentAttribute(attributes[attributeName]));
|
|
14
|
+
return (0, fp_1.omit)(componentAttributes, data);
|
|
15
|
+
}
|
|
16
|
+
exports.omitComponentData = omitComponentData;
|
|
17
|
+
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
|
|
18
|
+
const createComponents = async (uid, data) => {
|
|
19
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
20
|
+
const componentBody = {};
|
|
21
|
+
const attributeNames = Object.keys(attributes);
|
|
22
|
+
for (const attributeName of attributeNames) {
|
|
23
|
+
const attribute = attributes[attributeName];
|
|
24
|
+
if (!(0, fp_1.has)(attributeName, data) || !utils_1.contentTypes.isComponentAttribute(attribute)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (attribute.type === 'component') {
|
|
28
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
29
|
+
const componentValue = data[attributeName];
|
|
30
|
+
if (componentValue === null) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (repeatable === true) {
|
|
34
|
+
if (!Array.isArray(componentValue)) {
|
|
35
|
+
throw new Error('Expected an array to create repeatable component');
|
|
36
|
+
}
|
|
37
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
38
|
+
const components = (await (0, utils_1.mapAsync)(componentValue, (value) => createComponent(componentUID, value), { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }));
|
|
39
|
+
componentBody[attributeName] = components.map(({ id }) => {
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
__pivot: {
|
|
43
|
+
field: attributeName,
|
|
44
|
+
component_type: componentUID,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const component = await createComponent(componentUID, componentValue);
|
|
51
|
+
componentBody[attributeName] = {
|
|
52
|
+
id: component.id,
|
|
53
|
+
__pivot: {
|
|
54
|
+
field: attributeName,
|
|
55
|
+
component_type: componentUID,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (attribute.type === 'dynamiczone') {
|
|
62
|
+
const dynamiczoneValues = data[attributeName];
|
|
63
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
64
|
+
throw new Error('Expected an array to create repeatable component');
|
|
65
|
+
}
|
|
66
|
+
const createDynamicZoneComponents = async (value) => {
|
|
67
|
+
const { id } = await createComponent(value.__component, value);
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
__component: value.__component,
|
|
71
|
+
__pivot: {
|
|
72
|
+
field: attributeName,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
77
|
+
componentBody[attributeName] = await (0, utils_1.mapAsync)(dynamiczoneValues, createDynamicZoneComponents, { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return componentBody;
|
|
82
|
+
};
|
|
83
|
+
exports.createComponents = createComponents;
|
|
84
|
+
const getComponents = async (uid, entity) => {
|
|
85
|
+
const componentAttributes = utils_1.contentTypes.getComponentAttributes(strapi.getModel(uid));
|
|
86
|
+
if (lodash_1.default.isEmpty(componentAttributes)) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
return strapi.query(uid).load(entity, componentAttributes);
|
|
90
|
+
};
|
|
91
|
+
exports.getComponents = getComponents;
|
|
92
|
+
/*
|
|
93
|
+
delete old components
|
|
94
|
+
create or update
|
|
95
|
+
*/
|
|
96
|
+
const updateComponents = async (uid, entityToUpdate, data) => {
|
|
97
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
98
|
+
const componentBody = {};
|
|
99
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
100
|
+
const attribute = attributes[attributeName];
|
|
101
|
+
if (!(0, fp_1.has)(attributeName, data)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (attribute.type === 'component') {
|
|
105
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
106
|
+
const componentValue = data[attributeName];
|
|
107
|
+
await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);
|
|
108
|
+
if (repeatable === true) {
|
|
109
|
+
if (!Array.isArray(componentValue)) {
|
|
110
|
+
throw new Error('Expected an array to create repeatable component');
|
|
111
|
+
}
|
|
112
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
113
|
+
const components = (await (0, utils_1.mapAsync)(componentValue, (value) => updateOrCreateComponent(componentUID, value), { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }));
|
|
114
|
+
componentBody[attributeName] = components.filter(lodash_1.default.negate(lodash_1.default.isNil)).map(({ id }) => {
|
|
115
|
+
return {
|
|
116
|
+
id,
|
|
117
|
+
__pivot: {
|
|
118
|
+
field: attributeName,
|
|
119
|
+
component_type: componentUID,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const component = await updateOrCreateComponent(componentUID, componentValue);
|
|
126
|
+
componentBody[attributeName] = component && {
|
|
127
|
+
id: component.id,
|
|
128
|
+
__pivot: {
|
|
129
|
+
field: attributeName,
|
|
130
|
+
component_type: componentUID,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (attribute.type === 'dynamiczone') {
|
|
137
|
+
const dynamiczoneValues = data[attributeName];
|
|
138
|
+
await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);
|
|
139
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
140
|
+
throw new Error('Expected an array to create repeatable component');
|
|
141
|
+
}
|
|
142
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
143
|
+
componentBody[attributeName] = await (0, utils_1.mapAsync)(dynamiczoneValues, async (value) => {
|
|
144
|
+
const { id } = await updateOrCreateComponent(value.__component, value);
|
|
145
|
+
return {
|
|
146
|
+
id,
|
|
147
|
+
__component: value.__component,
|
|
148
|
+
__pivot: {
|
|
149
|
+
field: attributeName,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}, { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity });
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return componentBody;
|
|
157
|
+
};
|
|
158
|
+
exports.updateComponents = updateComponents;
|
|
159
|
+
const pickStringifiedId = ({ id, }) => {
|
|
160
|
+
if (typeof id === 'string') {
|
|
161
|
+
return id;
|
|
162
|
+
}
|
|
163
|
+
return `${id}`;
|
|
164
|
+
};
|
|
165
|
+
const deleteOldComponents = async (uid, componentUID, entityToUpdate, attributeName, componentValue) => {
|
|
166
|
+
const previousValue = (await strapi
|
|
167
|
+
.query(uid)
|
|
168
|
+
.load(entityToUpdate, attributeName));
|
|
169
|
+
const idsToKeep = lodash_1.default.castArray(componentValue).filter((0, fp_1.has)('id')).map(pickStringifiedId);
|
|
170
|
+
const allIds = lodash_1.default.castArray(previousValue).filter((0, fp_1.has)('id')).map(pickStringifiedId);
|
|
171
|
+
idsToKeep.forEach((id) => {
|
|
172
|
+
if (!allIds.includes(id)) {
|
|
173
|
+
throw new utils_1.errors.ApplicationError(`Some of the provided components in ${attributeName} are not related to the entity`);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const idsToDelete = lodash_1.default.difference(allIds, idsToKeep);
|
|
177
|
+
if (idsToDelete.length > 0) {
|
|
178
|
+
for (const idToDelete of idsToDelete) {
|
|
179
|
+
await deleteComponent(componentUID, { id: idToDelete });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamiczoneValues) => {
|
|
184
|
+
const previousValue = (await strapi
|
|
185
|
+
.query(uid)
|
|
186
|
+
.load(entityToUpdate, attributeName));
|
|
187
|
+
const idsToKeep = lodash_1.default.castArray(dynamiczoneValues)
|
|
188
|
+
.filter((0, fp_1.has)('id'))
|
|
189
|
+
.map((v) => ({
|
|
190
|
+
id: pickStringifiedId(v),
|
|
191
|
+
__component: v.__component,
|
|
192
|
+
}));
|
|
193
|
+
const allIds = lodash_1.default.castArray(previousValue)
|
|
194
|
+
.filter((0, fp_1.has)('id'))
|
|
195
|
+
.map((v) => ({
|
|
196
|
+
id: pickStringifiedId(v),
|
|
197
|
+
__component: v.__component,
|
|
198
|
+
}));
|
|
199
|
+
idsToKeep.forEach(({ id, __component }) => {
|
|
200
|
+
if (!allIds.find((el) => el.id === id && el.__component === __component)) {
|
|
201
|
+
const err = new Error(`Some of the provided components in ${attributeName} are not related to the entity`);
|
|
202
|
+
Object.assign(err, { status: 400 });
|
|
203
|
+
throw err;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
const idsToDelete = allIds.reduce((acc, { id, __component }) => {
|
|
207
|
+
if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {
|
|
208
|
+
acc.push({ id, __component });
|
|
209
|
+
}
|
|
210
|
+
return acc;
|
|
211
|
+
}, []);
|
|
212
|
+
if (idsToDelete.length > 0) {
|
|
213
|
+
for (const idToDelete of idsToDelete) {
|
|
214
|
+
const { id, __component } = idToDelete;
|
|
215
|
+
await deleteComponent(__component, { id });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {}) => {
|
|
220
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
221
|
+
const attributeNames = Object.keys(attributes);
|
|
222
|
+
for (const attributeName of attributeNames) {
|
|
223
|
+
const attribute = attributes[attributeName];
|
|
224
|
+
if (attribute.type === 'component' || attribute.type === 'dynamiczone') {
|
|
225
|
+
let value;
|
|
226
|
+
if (loadComponents) {
|
|
227
|
+
value = await strapi.query(uid).load(entityToDelete, attributeName);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
value = entityToDelete[attributeName];
|
|
231
|
+
}
|
|
232
|
+
if (!value) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (attribute.type === 'component') {
|
|
236
|
+
const { component: componentUID } = attribute;
|
|
237
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
238
|
+
await (0, utils_1.mapAsync)(lodash_1.default.castArray(value), (subValue) => deleteComponent(componentUID, subValue), {
|
|
239
|
+
concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
// delete dynamic zone components
|
|
244
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
245
|
+
await (0, utils_1.mapAsync)(lodash_1.default.castArray(value), (subValue) => deleteComponent(subValue.__component, subValue), { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity });
|
|
246
|
+
}
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
exports.deleteComponents = deleteComponents;
|
|
252
|
+
const cloneComponents = async (uid, entityToClone, data) => {
|
|
253
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
254
|
+
const componentBody = {};
|
|
255
|
+
const componentData = await getComponents(uid, entityToClone);
|
|
256
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
257
|
+
const attribute = attributes[attributeName];
|
|
258
|
+
// If the attribute is not set or on the component to clone, skip it
|
|
259
|
+
if (!(0, fp_1.has)(attributeName, data) && !(0, fp_1.has)(attributeName, componentData)) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (attribute.type === 'component') {
|
|
263
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
264
|
+
const componentValue = (attributeName in data
|
|
265
|
+
? data[attributeName]
|
|
266
|
+
: componentData[attributeName]);
|
|
267
|
+
if (componentValue === null) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (repeatable === true) {
|
|
271
|
+
if (!Array.isArray(componentValue)) {
|
|
272
|
+
throw new Error('Expected an array to create repeatable component');
|
|
273
|
+
}
|
|
274
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
275
|
+
const components = (await (0, utils_1.mapAsync)(componentValue, (value) => cloneComponent(componentUID, value), { concurrency: isDialectMySQL() ? 1 : Infinity }));
|
|
276
|
+
componentBody[attributeName] = components.filter(lodash_1.default.negate(lodash_1.default.isNil)).map(({ id }) => {
|
|
277
|
+
return {
|
|
278
|
+
id,
|
|
279
|
+
__pivot: {
|
|
280
|
+
field: attributeName,
|
|
281
|
+
component_type: componentUID,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const component = await cloneComponent(componentUID, componentValue);
|
|
288
|
+
componentBody[attributeName] = component && {
|
|
289
|
+
id: component.id,
|
|
290
|
+
__pivot: {
|
|
291
|
+
field: attributeName,
|
|
292
|
+
component_type: componentUID,
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (attribute.type === 'dynamiczone') {
|
|
299
|
+
const dynamiczoneValues = (0, fp_1.has)(attributeName, data)
|
|
300
|
+
? data[attributeName]
|
|
301
|
+
: componentData[attributeName];
|
|
302
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
303
|
+
throw new Error('Expected an array to create repeatable component');
|
|
304
|
+
}
|
|
305
|
+
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
306
|
+
componentBody[attributeName] = await (0, utils_1.mapAsync)(dynamiczoneValues, async (value) => {
|
|
307
|
+
const { id } = await cloneComponent(value.__component, value);
|
|
308
|
+
return {
|
|
309
|
+
id,
|
|
310
|
+
__component: value.__component,
|
|
311
|
+
__pivot: {
|
|
312
|
+
field: attributeName,
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}, { concurrency: isDialectMySQL() ? 1 : Infinity });
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return componentBody;
|
|
320
|
+
};
|
|
321
|
+
exports.cloneComponents = cloneComponents;
|
|
322
|
+
/** *************************
|
|
323
|
+
Component queries
|
|
324
|
+
************************** */
|
|
325
|
+
// components can have nested compos so this must be recursive
|
|
326
|
+
const createComponent = async (uid, data) => {
|
|
327
|
+
const model = strapi.getModel(uid);
|
|
328
|
+
const componentData = await createComponents(uid, data);
|
|
329
|
+
const transform = (0, fp_1.pipe)(
|
|
330
|
+
// Make sure we don't save the component with a pre-defined ID
|
|
331
|
+
(0, fp_1.omit)('id'),
|
|
332
|
+
// Remove the component data from the original data object ...
|
|
333
|
+
(payload) => omitComponentData(model, payload),
|
|
334
|
+
// ... and assign the newly created component instead
|
|
335
|
+
(0, fp_1.assign)(componentData));
|
|
336
|
+
return strapi.query(uid).create({ data: transform(data) });
|
|
337
|
+
};
|
|
338
|
+
// components can have nested compos so this must be recursive
|
|
339
|
+
const updateComponent = async (uid, componentToUpdate, data) => {
|
|
340
|
+
const model = strapi.getModel(uid);
|
|
341
|
+
const componentData = await updateComponents(uid, componentToUpdate, data);
|
|
342
|
+
return strapi.query(uid).update({
|
|
343
|
+
where: {
|
|
344
|
+
id: componentToUpdate.id,
|
|
345
|
+
},
|
|
346
|
+
data: Object.assign(omitComponentData(model, data), componentData),
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
const updateOrCreateComponent = (componentUID, value) => {
|
|
350
|
+
if (value === null) {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
// update
|
|
354
|
+
if ('id' in value && typeof value.id !== 'undefined') {
|
|
355
|
+
// TODO: verify the compo is associated with the entity
|
|
356
|
+
return updateComponent(componentUID, { id: value.id }, value);
|
|
357
|
+
}
|
|
358
|
+
// create
|
|
359
|
+
return createComponent(componentUID, value);
|
|
360
|
+
};
|
|
361
|
+
const deleteComponent = async (uid, componentToDelete) => {
|
|
362
|
+
await deleteComponents(uid, componentToDelete);
|
|
363
|
+
await strapi.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
364
|
+
};
|
|
365
|
+
exports.deleteComponent = deleteComponent;
|
|
366
|
+
const cloneComponent = async (uid, data) => {
|
|
367
|
+
const model = strapi.getModel(uid);
|
|
368
|
+
if (!('id' in data) || typeof data.id === 'undefined') {
|
|
369
|
+
return createComponent(uid, data);
|
|
370
|
+
}
|
|
371
|
+
const componentData = await cloneComponents(uid, { id: data.id }, data);
|
|
372
|
+
const transform = (0, fp_1.pipe)(
|
|
373
|
+
// Make sure we don't save the component with a pre-defined ID
|
|
374
|
+
(0, fp_1.omit)('id'),
|
|
375
|
+
// Remove the component data from the original data object ...
|
|
376
|
+
(payload) => omitComponentData(model, payload),
|
|
377
|
+
// ... and assign the newly created component instead
|
|
378
|
+
(0, fp_1.assign)(componentData));
|
|
379
|
+
return strapi.query(uid).clone(data.id, { data: transform(data) });
|
|
380
|
+
};
|
|
381
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/utils/components.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,kCAAoD;AAEpD,yCAAoF;AAoBpF,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC;AAUnE,SAAS,iBAAiB,CACxB,WAAkD,EAClD,IAA0F;IAE1F,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IACnC,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAC3E,oBAAiB,CAAC,oBAAoB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAClE,CAAC;IAEF,OAAO,IAAA,SAAI,EAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AA4iBC,8CAAiB;AA1iBnB,yFAAyF;AACzF,MAAM,gBAAgB,GAAG,KAAK,EAI5B,GAAS,EACT,IA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G,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AA+BA,0CAAe;AA7BjB,MAAM,cAAc,GAAG,KAAK,EAC1B,GAAS,EACT,IAA2C,EAC3C,EAAE;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEnC,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,WAAW,EAAE;QACrD,OAAO,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KACnC;IAED,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,IAAA,SAAI;IACpB,8DAA8D;IAC9D,IAAA,SAAI,EAAC,IAAI,CAAC;IACV,8DAA8D;IAC9D,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC;IAC9C,qDAAqD;IACrD,IAAA,WAAM,EAAC,aAAa,CAAC,CACtB,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { LoadedStrapi } from '@strapi/types';
|
|
2
|
+
export type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is LoadedStrapi;
|
|
2
3
|
export declare const assertValidStrapi: ValidStrapiAssertion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":";;;AAEA,mDAAkE;AAO3D,MAAM,iBAAiB,GAAyB,CAAC,MAAgB,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE;IACpF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,uCAA2B,CAAC,GAAG,GAAG,8BAA8B,CAAC,CAAC;KAC7E;AACH,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B"}
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LoadedStrapi } from '@strapi/types';
|
|
2
2
|
import { Transaction } from '../../types/utils';
|
|
3
|
-
export declare const createTransaction: (strapi:
|
|
3
|
+
export declare const createTransaction: (strapi: LoadedStrapi) => Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,mCAAoC;AAK7B,MAAM,iBAAiB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,mCAAoC;AAK7B,MAAM,iBAAiB,GAAG,CAAC,MAAoB,EAAe,EAAE;IACrE,MAAM,GAAG,GAAgD,EAAE,CAAC;IAE5D,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,MAAM,GAAwB,IAAI,CAAC;IAEvC,MAAM,CAAC,GAAG,IAAI,qBAAY,EAAE,CAAC;IAC7B,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE;QACzB,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3B,MAAM,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AC,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA3FW,QAAA,iBAAiB,qBA2F5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/data-transfer",
|
|
3
|
-
"version": "4.14.0
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "Data transfer capabilities for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -27,24 +27,31 @@
|
|
|
27
27
|
"main": "./dist/index.js",
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "tsc",
|
|
31
|
-
"build:ts": "
|
|
30
|
+
"build": "run -T tsc -p tsconfig.build.json",
|
|
31
|
+
"build:ts": "run build",
|
|
32
32
|
"clean": "rimraf ./dist",
|
|
33
33
|
"prepublishOnly": "yarn clean && yarn build",
|
|
34
34
|
"test:unit": "run -T jest",
|
|
35
35
|
"test:unit:watch": "run -T jest --watch",
|
|
36
|
-
"watch": "tsc -w --preserveWatchOutput",
|
|
36
|
+
"watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
|
|
37
37
|
"lint": "run -T eslint ."
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"./dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@strapi/logger": "4.14.0
|
|
44
|
-
"@strapi/strapi": "4.14.0
|
|
43
|
+
"@strapi/logger": "4.14.0",
|
|
44
|
+
"@strapi/strapi": "4.14.0",
|
|
45
|
+
"@strapi/types": "4.14.0",
|
|
46
|
+
"@strapi/utils": "4.14.0",
|
|
45
47
|
"chalk": "4.1.2",
|
|
48
|
+
"cli-table3": "0.6.2",
|
|
49
|
+
"commander": "8.3.0",
|
|
46
50
|
"fs-extra": "10.0.0",
|
|
51
|
+
"inquirer": "8.2.5",
|
|
47
52
|
"lodash": "4.17.21",
|
|
53
|
+
"ora": "5.4.1",
|
|
54
|
+
"resolve-cwd": "3.0.0",
|
|
48
55
|
"semver": "7.5.4",
|
|
49
56
|
"stream-chain": "2.2.5",
|
|
50
57
|
"stream-json": "1.8.0",
|
|
@@ -53,14 +60,14 @@
|
|
|
53
60
|
"ws": "8.13.0"
|
|
54
61
|
},
|
|
55
62
|
"peerDependencies": {
|
|
56
|
-
"@strapi/strapi": "4.
|
|
63
|
+
"@strapi/strapi": "^4.13.7"
|
|
57
64
|
},
|
|
58
65
|
"devDependencies": {
|
|
59
|
-
"@tsconfig/node16": "1.0.3",
|
|
60
66
|
"@types/fs-extra": "9.0.13",
|
|
61
67
|
"@types/jest": "29.5.2",
|
|
62
68
|
"@types/koa": "2.13.4",
|
|
63
69
|
"@types/lodash": "^4.14.191",
|
|
70
|
+
"@types/node": "18.11.9",
|
|
64
71
|
"@types/semver": "7.5.0",
|
|
65
72
|
"@types/stream-chain": "2.0.1",
|
|
66
73
|
"@types/stream-json": "1.7.3",
|
|
@@ -70,11 +77,11 @@
|
|
|
70
77
|
"knex": "2.5.0",
|
|
71
78
|
"koa": "2.13.4",
|
|
72
79
|
"rimraf": "3.0.2",
|
|
73
|
-
"typescript": "5.
|
|
80
|
+
"typescript": "5.2.2"
|
|
74
81
|
},
|
|
75
82
|
"engines": {
|
|
76
83
|
"node": ">=16.0.0 <=20.x.x",
|
|
77
84
|
"npm": ">=6.0.0"
|
|
78
85
|
},
|
|
79
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "09b6d7a4b46a87142d29665052ca22ced29fa56a"
|
|
80
87
|
}
|