@strapi/data-transfer 5.0.0-beta.0 → 5.0.0-beta.2
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/engine/diagnostic.d.ts.map +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.d.ts +2 -2
- package/dist/index.js +55 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -37
- package/dist/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +4 -4
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +3 -3
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +5 -5
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +3 -3
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +2 -2
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts +2 -2
- package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/configuration.d.ts +2 -2
- package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/entities.d.ts +2 -2
- package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +4 -4
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/links.d.ts +2 -2
- package/dist/strapi/providers/local-source/links.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +2 -2
- package/dist/strapi/providers/remote-source/index.d.ts +2 -2
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/queries/entity.d.ts +2 -2
- package/dist/strapi/queries/entity.d.ts.map +1 -1
- package/dist/strapi/queries/link.d.ts +2 -2
- package/dist/strapi/queries/link.d.ts.map +1 -1
- package/dist/utils/components.d.ts +94 -13
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/schema.d.ts +2 -2
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/transaction.d.ts +2 -2
- package/dist/utils/transaction.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { Transform, PassThrough, Writable, Readable, Duplex, pipeline } from "st
|
|
|
2
2
|
import path, { extname, join, posix } from "path";
|
|
3
3
|
import { EOL } from "os";
|
|
4
4
|
import { chain } from "stream-chain";
|
|
5
|
-
import { isArray, zip, isObject, uniq, isEqual, mapValues, pick, reject as reject$1, capitalize, isNumber, isEmpty, last, difference, set, omit, has, pipe, assign, map as map$1, size, isNil, clone,
|
|
5
|
+
import { isArray, zip, isObject, uniq, isEqual, mapValues, pick, reject as reject$1, capitalize, isNumber, isEmpty, last, difference, set, omit, get, has, pipe, assign, map as map$1, size, isNil, clone, once, castArray, keyBy } from "lodash/fp";
|
|
6
6
|
import { diff as diff$1 } from "semver";
|
|
7
7
|
import { scryptSync, createCipheriv, createDecipheriv, randomUUID } from "crypto";
|
|
8
8
|
import { EventEmitter } from "events";
|
|
@@ -1255,6 +1255,34 @@ const deleteComponent = async (uid, componentToDelete) => {
|
|
|
1255
1255
|
await deleteComponents(uid, componentToDelete);
|
|
1256
1256
|
await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
1257
1257
|
};
|
|
1258
|
+
const resolveComponentUID = ({
|
|
1259
|
+
paths,
|
|
1260
|
+
strapi: strapi2,
|
|
1261
|
+
data,
|
|
1262
|
+
contentType
|
|
1263
|
+
}) => {
|
|
1264
|
+
let value = data;
|
|
1265
|
+
let cType = contentType;
|
|
1266
|
+
for (const path2 of paths) {
|
|
1267
|
+
value = get(path2, value);
|
|
1268
|
+
if (typeof cType === "function") {
|
|
1269
|
+
cType = cType(value);
|
|
1270
|
+
}
|
|
1271
|
+
if (path2 in cType.attributes) {
|
|
1272
|
+
const attribute = cType.attributes[path2];
|
|
1273
|
+
if (attribute.type === "component") {
|
|
1274
|
+
cType = strapi2.getModel(attribute.component);
|
|
1275
|
+
}
|
|
1276
|
+
if (attribute.type === "dynamiczone") {
|
|
1277
|
+
cType = ({ __component }) => strapi2.getModel(__component);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
if ("uid" in cType) {
|
|
1282
|
+
return cType.uid;
|
|
1283
|
+
}
|
|
1284
|
+
return void 0;
|
|
1285
|
+
};
|
|
1258
1286
|
const sanitizeComponentLikeAttributes = (model, data) => {
|
|
1259
1287
|
const { attributes } = model;
|
|
1260
1288
|
const componentLikeAttributesKey = Object.entries(attributes).filter(([, attribute]) => attribute.type === "component" || attribute.type === "dynamiczone").map(([key]) => key);
|
|
@@ -1273,13 +1301,9 @@ const createEntityQuery = (strapi2) => {
|
|
|
1273
1301
|
return getComponents(uid, entity2);
|
|
1274
1302
|
},
|
|
1275
1303
|
delete(uid, componentsToDelete) {
|
|
1276
|
-
return deleteComponents(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
{
|
|
1280
|
-
loadComponents: false
|
|
1281
|
-
}
|
|
1282
|
-
);
|
|
1304
|
+
return deleteComponents(uid, componentsToDelete, {
|
|
1305
|
+
loadComponents: false
|
|
1306
|
+
});
|
|
1283
1307
|
}
|
|
1284
1308
|
};
|
|
1285
1309
|
const query = (uid) => {
|
|
@@ -1620,29 +1644,6 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1620
1644
|
const { type, id, data } = entity2;
|
|
1621
1645
|
const { create, getDeepPopulateComponentLikeQuery } = query(type);
|
|
1622
1646
|
const contentType = strapi2.getModel(type);
|
|
1623
|
-
let cType = contentType;
|
|
1624
|
-
const resolveType = (paths) => {
|
|
1625
|
-
let value = data;
|
|
1626
|
-
for (const path2 of paths) {
|
|
1627
|
-
value = get(path2, value);
|
|
1628
|
-
if (typeof cType === "function") {
|
|
1629
|
-
cType = cType(value);
|
|
1630
|
-
}
|
|
1631
|
-
if (path2 in cType.attributes) {
|
|
1632
|
-
const attribute = cType.attributes[path2];
|
|
1633
|
-
if (attribute.type === "component") {
|
|
1634
|
-
cType = strapi2.getModel(attribute.component);
|
|
1635
|
-
}
|
|
1636
|
-
if (attribute.type === "dynamiczone") {
|
|
1637
|
-
cType = ({ __component }) => strapi2.getModel(__component);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
if ("uid" in cType) {
|
|
1642
|
-
return cType.uid;
|
|
1643
|
-
}
|
|
1644
|
-
return void 0;
|
|
1645
|
-
};
|
|
1646
1647
|
try {
|
|
1647
1648
|
const created = await create({
|
|
1648
1649
|
data,
|
|
@@ -1652,8 +1653,8 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1652
1653
|
const diffs = diff(data, created);
|
|
1653
1654
|
updateMappingTable(type, id, created.id);
|
|
1654
1655
|
diffs.forEach((diff2) => {
|
|
1655
|
-
if (diff2.kind === "modified" && last(diff2.path) === "id") {
|
|
1656
|
-
const target =
|
|
1656
|
+
if (diff2.kind === "modified" && last(diff2.path) === "id" && "kind" in contentType) {
|
|
1657
|
+
const target = resolveComponentUID({ paths: diff2.path, data, contentType, strapi: strapi2 });
|
|
1657
1658
|
if (!target) {
|
|
1658
1659
|
return;
|
|
1659
1660
|
}
|
|
@@ -2283,11 +2284,31 @@ function getFileStats(filepath, strapi2, isLocal = false) {
|
|
|
2283
2284
|
});
|
|
2284
2285
|
});
|
|
2285
2286
|
}
|
|
2287
|
+
async function signFile(file) {
|
|
2288
|
+
const { provider } = strapi.plugins.upload;
|
|
2289
|
+
const { provider: providerName } = strapi.config.get("plugin.upload");
|
|
2290
|
+
const isPrivate = await provider.isPrivate();
|
|
2291
|
+
if (file?.provider === providerName && isPrivate) {
|
|
2292
|
+
const signUrl = async (file2) => {
|
|
2293
|
+
const signedUrl = await provider.getSignedUrl(file2);
|
|
2294
|
+
file2.url = signedUrl.url;
|
|
2295
|
+
};
|
|
2296
|
+
await signUrl(file);
|
|
2297
|
+
if (file.formats) {
|
|
2298
|
+
for (const format of Object.keys(file.formats)) {
|
|
2299
|
+
await signUrl(file.formats[format]);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2286
2304
|
const createAssetsStream = (strapi2) => {
|
|
2287
2305
|
const generator = async function* () {
|
|
2288
2306
|
const stream2 = strapi2.db.queryBuilder("plugin::upload.file").select("*").stream();
|
|
2289
2307
|
for await (const file of stream2) {
|
|
2290
2308
|
const isLocalProvider = file.provider === "local";
|
|
2309
|
+
if (!isLocalProvider) {
|
|
2310
|
+
await signFile(file);
|
|
2311
|
+
}
|
|
2291
2312
|
const filepath = isLocalProvider ? join(strapi2.dirs.static.public, file.url) : file.url;
|
|
2292
2313
|
const stats = await getFileStats(filepath, strapi2, isLocalProvider);
|
|
2293
2314
|
const stream22 = getFileStream(filepath, strapi2, isLocalProvider);
|
|
@@ -2945,10 +2966,8 @@ class RemoteStrapiSourceProvider {
|
|
|
2945
2966
|
});
|
|
2946
2967
|
}
|
|
2947
2968
|
async getSchemas() {
|
|
2948
|
-
const schemas = await this.dispatcher?.dispatchTransferAction(
|
|
2949
|
-
|
|
2950
|
-
) ?? null;
|
|
2951
|
-
return schemas;
|
|
2969
|
+
const schemas = await this.dispatcher?.dispatchTransferAction("getSchemas");
|
|
2970
|
+
return schemas ?? null;
|
|
2952
2971
|
}
|
|
2953
2972
|
async #startStep(step) {
|
|
2954
2973
|
try {
|