@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../src/engine/diagnostic.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,GAAG,OAAO,IAAI;IACrE,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;KACjB,GAAG,CAAC,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,CAC1E,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,UAAU,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,KAC7D,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,cAAc,cAAc,EAAE,CAAC;AAE5E,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,SAAS,YAAY,GAC5E,kBAAkB,GAClB,CAAC,SAAS,cAAc,M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;IAClC,KAAK,EAAE,KAAK,CAAC;CACd,CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAC/C,SAAS,EACT;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CACF,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CACzD,MAAM,EACN;IACE,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ,CACF,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QACL,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;KAC9B,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,CAAC;IACpD,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,mBAAmB,CAAC;IAChE,EAAE,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC;CAC7F;AAED,QAAA,MAAM,wBAAwB,aACnB,0BAA0B,KAClC,mBAyDF,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,QAAQ,CAAC;AAUpE,OAAO,KAAK,EAEV,oBAAoB,EAIpB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAGb,eAAe,EACf,oBAAoB,EAEpB,iBAAiB,EACjB,wBAAw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AE,MAAM,CAAC,EAAE,OAAO;IAqR5C,eAAe,CAAC,KAAK,EAAE,aAAa;IAwG9B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAahC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyCtB,cAAc;IAyDd,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAmD3C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBhC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8CjC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAsC9B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB/B,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAc7C;AAED,eAAO,MAAM,oBAAoB,kHAGtB,sBAAsB,yBAGhC,CAAC;AAEF,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,GACjB,CAAC;AAEF,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Readable } from 'stream';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Struct } from '@strapi/types';
|
|
5
5
|
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
|
|
6
6
|
/**
|
|
7
7
|
* Provider options
|
|
@@ -30,7 +30,7 @@ declare class LocalFileSourceProvider implements ISourceProvider {
|
|
|
30
30
|
*/
|
|
31
31
|
bootstrap(): Promise<void>;
|
|
32
32
|
getMetadata(): Promise<IMetadata | null>;
|
|
33
|
-
getSchemas(): Promise<import("lodash").Dictionary<
|
|
33
|
+
getSchemas(): Promise<import("lodash").Dictionary<Struct.Schema>>;
|
|
34
34
|
createEntitiesReadStream(): Readable;
|
|
35
35
|
createSchemasReadStream(): Readable;
|
|
36
36
|
createLinksReadStream(): Readable;
|
package/dist/index.js
CHANGED
|
@@ -1283,6 +1283,34 @@ const deleteComponent = async (uid, componentToDelete) => {
|
|
|
1283
1283
|
await deleteComponents(uid, componentToDelete);
|
|
1284
1284
|
await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
1285
1285
|
};
|
|
1286
|
+
const resolveComponentUID = ({
|
|
1287
|
+
paths,
|
|
1288
|
+
strapi: strapi2,
|
|
1289
|
+
data,
|
|
1290
|
+
contentType
|
|
1291
|
+
}) => {
|
|
1292
|
+
let value = data;
|
|
1293
|
+
let cType = contentType;
|
|
1294
|
+
for (const path2 of paths) {
|
|
1295
|
+
value = fp.get(path2, value);
|
|
1296
|
+
if (typeof cType === "function") {
|
|
1297
|
+
cType = cType(value);
|
|
1298
|
+
}
|
|
1299
|
+
if (path2 in cType.attributes) {
|
|
1300
|
+
const attribute = cType.attributes[path2];
|
|
1301
|
+
if (attribute.type === "component") {
|
|
1302
|
+
cType = strapi2.getModel(attribute.component);
|
|
1303
|
+
}
|
|
1304
|
+
if (attribute.type === "dynamiczone") {
|
|
1305
|
+
cType = ({ __component }) => strapi2.getModel(__component);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
if ("uid" in cType) {
|
|
1310
|
+
return cType.uid;
|
|
1311
|
+
}
|
|
1312
|
+
return void 0;
|
|
1313
|
+
};
|
|
1286
1314
|
const sanitizeComponentLikeAttributes = (model, data) => {
|
|
1287
1315
|
const { attributes } = model;
|
|
1288
1316
|
const componentLikeAttributesKey = Object.entries(attributes).filter(([, attribute]) => attribute.type === "component" || attribute.type === "dynamiczone").map(([key]) => key);
|
|
@@ -1301,13 +1329,9 @@ const createEntityQuery = (strapi2) => {
|
|
|
1301
1329
|
return getComponents(uid, entity2);
|
|
1302
1330
|
},
|
|
1303
1331
|
delete(uid, componentsToDelete) {
|
|
1304
|
-
return deleteComponents(
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
{
|
|
1308
|
-
loadComponents: false
|
|
1309
|
-
}
|
|
1310
|
-
);
|
|
1332
|
+
return deleteComponents(uid, componentsToDelete, {
|
|
1333
|
+
loadComponents: false
|
|
1334
|
+
});
|
|
1311
1335
|
}
|
|
1312
1336
|
};
|
|
1313
1337
|
const query = (uid) => {
|
|
@@ -1648,29 +1672,6 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1648
1672
|
const { type, id, data } = entity2;
|
|
1649
1673
|
const { create, getDeepPopulateComponentLikeQuery } = query(type);
|
|
1650
1674
|
const contentType = strapi2.getModel(type);
|
|
1651
|
-
let cType = contentType;
|
|
1652
|
-
const resolveType = (paths) => {
|
|
1653
|
-
let value = data;
|
|
1654
|
-
for (const path2 of paths) {
|
|
1655
|
-
value = fp.get(path2, value);
|
|
1656
|
-
if (typeof cType === "function") {
|
|
1657
|
-
cType = cType(value);
|
|
1658
|
-
}
|
|
1659
|
-
if (path2 in cType.attributes) {
|
|
1660
|
-
const attribute = cType.attributes[path2];
|
|
1661
|
-
if (attribute.type === "component") {
|
|
1662
|
-
cType = strapi2.getModel(attribute.component);
|
|
1663
|
-
}
|
|
1664
|
-
if (attribute.type === "dynamiczone") {
|
|
1665
|
-
cType = ({ __component }) => strapi2.getModel(__component);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
if ("uid" in cType) {
|
|
1670
|
-
return cType.uid;
|
|
1671
|
-
}
|
|
1672
|
-
return void 0;
|
|
1673
|
-
};
|
|
1674
1675
|
try {
|
|
1675
1676
|
const created = await create({
|
|
1676
1677
|
data,
|
|
@@ -1680,8 +1681,8 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1680
1681
|
const diffs = diff(data, created);
|
|
1681
1682
|
updateMappingTable(type, id, created.id);
|
|
1682
1683
|
diffs.forEach((diff2) => {
|
|
1683
|
-
if (diff2.kind === "modified" && fp.last(diff2.path) === "id") {
|
|
1684
|
-
const target =
|
|
1684
|
+
if (diff2.kind === "modified" && fp.last(diff2.path) === "id" && "kind" in contentType) {
|
|
1685
|
+
const target = resolveComponentUID({ paths: diff2.path, data, contentType, strapi: strapi2 });
|
|
1685
1686
|
if (!target) {
|
|
1686
1687
|
return;
|
|
1687
1688
|
}
|
|
@@ -2311,11 +2312,31 @@ function getFileStats(filepath, strapi2, isLocal = false) {
|
|
|
2311
2312
|
});
|
|
2312
2313
|
});
|
|
2313
2314
|
}
|
|
2315
|
+
async function signFile(file) {
|
|
2316
|
+
const { provider } = strapi.plugins.upload;
|
|
2317
|
+
const { provider: providerName } = strapi.config.get("plugin.upload");
|
|
2318
|
+
const isPrivate = await provider.isPrivate();
|
|
2319
|
+
if (file?.provider === providerName && isPrivate) {
|
|
2320
|
+
const signUrl = async (file2) => {
|
|
2321
|
+
const signedUrl = await provider.getSignedUrl(file2);
|
|
2322
|
+
file2.url = signedUrl.url;
|
|
2323
|
+
};
|
|
2324
|
+
await signUrl(file);
|
|
2325
|
+
if (file.formats) {
|
|
2326
|
+
for (const format of Object.keys(file.formats)) {
|
|
2327
|
+
await signUrl(file.formats[format]);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2314
2332
|
const createAssetsStream = (strapi2) => {
|
|
2315
2333
|
const generator = async function* () {
|
|
2316
2334
|
const stream2 = strapi2.db.queryBuilder("plugin::upload.file").select("*").stream();
|
|
2317
2335
|
for await (const file of stream2) {
|
|
2318
2336
|
const isLocalProvider = file.provider === "local";
|
|
2337
|
+
if (!isLocalProvider) {
|
|
2338
|
+
await signFile(file);
|
|
2339
|
+
}
|
|
2319
2340
|
const filepath = isLocalProvider ? path.join(strapi2.dirs.static.public, file.url) : file.url;
|
|
2320
2341
|
const stats = await getFileStats(filepath, strapi2, isLocalProvider);
|
|
2321
2342
|
const stream22 = getFileStream(filepath, strapi2, isLocalProvider);
|
|
@@ -2973,10 +2994,8 @@ class RemoteStrapiSourceProvider {
|
|
|
2973
2994
|
});
|
|
2974
2995
|
}
|
|
2975
2996
|
async getSchemas() {
|
|
2976
|
-
const schemas = await this.dispatcher?.dispatchTransferAction(
|
|
2977
|
-
|
|
2978
|
-
) ?? null;
|
|
2979
|
-
return schemas;
|
|
2997
|
+
const schemas = await this.dispatcher?.dispatchTransferAction("getSchemas");
|
|
2998
|
+
return schemas ?? null;
|
|
2980
2999
|
}
|
|
2981
3000
|
async #startStep(step) {
|
|
2982
3001
|
try {
|