@strapi/data-transfer 5.0.0-beta.1 → 5.0.0-beta.3

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.
Files changed (38) hide show
  1. package/dist/engine/diagnostic.d.ts.map +1 -1
  2. package/dist/index.js +56 -30
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +57 -31
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/strapi/providers/local-destination/index.d.ts +2 -2
  7. package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
  8. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +2 -2
  9. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
  10. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +3 -3
  11. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
  12. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +1 -1
  13. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts.map +1 -1
  14. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +1 -1
  15. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
  16. package/dist/strapi/providers/local-source/assets.d.ts +1 -1
  17. package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
  18. package/dist/strapi/providers/local-source/configuration.d.ts +1 -1
  19. package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
  20. package/dist/strapi/providers/local-source/entities.d.ts +1 -1
  21. package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
  22. package/dist/strapi/providers/local-source/index.d.ts +2 -2
  23. package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
  24. package/dist/strapi/providers/local-source/links.d.ts +1 -1
  25. package/dist/strapi/providers/local-source/links.d.ts.map +1 -1
  26. package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
  27. package/dist/strapi/queries/entity.d.ts +1 -1
  28. package/dist/strapi/queries/entity.d.ts.map +1 -1
  29. package/dist/strapi/queries/link.d.ts +1 -1
  30. package/dist/strapi/queries/link.d.ts.map +1 -1
  31. package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
  32. package/dist/utils/components.d.ts +12 -2
  33. package/dist/utils/components.d.ts.map +1 -1
  34. package/dist/utils/providers.d.ts +1 -1
  35. package/dist/utils/providers.d.ts.map +1 -1
  36. package/dist/utils/transaction.d.ts +1 -1
  37. package/dist/utils/transaction.d.ts.map +1 -1
  38. package/package.json +9 -9
@@ -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,MAAM,CAAC,EAAE,GACjC,CAAC,SAAS,cAAc,GACtB,kBAAkB,C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M,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"}
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);
@@ -1644,29 +1672,6 @@ const createEntitiesWriteStream = (options) => {
1644
1672
  const { type, id, data } = entity2;
1645
1673
  const { create, getDeepPopulateComponentLikeQuery } = query(type);
1646
1674
  const contentType = strapi2.getModel(type);
1647
- let cType = contentType;
1648
- const resolveType = (paths) => {
1649
- let value = data;
1650
- for (const path2 of paths) {
1651
- value = fp.get(path2, value);
1652
- if (typeof cType === "function") {
1653
- cType = cType(value);
1654
- }
1655
- if (path2 in cType.attributes) {
1656
- const attribute = cType.attributes[path2];
1657
- if (attribute.type === "component") {
1658
- cType = strapi2.getModel(attribute.component);
1659
- }
1660
- if (attribute.type === "dynamiczone") {
1661
- cType = ({ __component }) => strapi2.getModel(__component);
1662
- }
1663
- }
1664
- }
1665
- if ("uid" in cType) {
1666
- return cType.uid;
1667
- }
1668
- return void 0;
1669
- };
1670
1675
  try {
1671
1676
  const created = await create({
1672
1677
  data,
@@ -1676,8 +1681,8 @@ const createEntitiesWriteStream = (options) => {
1676
1681
  const diffs = diff(data, created);
1677
1682
  updateMappingTable(type, id, created.id);
1678
1683
  diffs.forEach((diff2) => {
1679
- if (diff2.kind === "modified" && fp.last(diff2.path) === "id") {
1680
- const target = resolveType(diff2.path);
1684
+ if (diff2.kind === "modified" && fp.last(diff2.path) === "id" && "kind" in contentType) {
1685
+ const target = resolveComponentUID({ paths: diff2.path, data, contentType, strapi: strapi2 });
1681
1686
  if (!target) {
1682
1687
  return;
1683
1688
  }
@@ -2307,11 +2312,31 @@ function getFileStats(filepath, strapi2, isLocal = false) {
2307
2312
  });
2308
2313
  });
2309
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
+ }
2310
2332
  const createAssetsStream = (strapi2) => {
2311
2333
  const generator = async function* () {
2312
2334
  const stream2 = strapi2.db.queryBuilder("plugin::upload.file").select("*").stream();
2313
2335
  for await (const file of stream2) {
2314
2336
  const isLocalProvider = file.provider === "local";
2337
+ if (!isLocalProvider) {
2338
+ await signFile(file);
2339
+ }
2315
2340
  const filepath = isLocalProvider ? path.join(strapi2.dirs.static.public, file.url) : file.url;
2316
2341
  const stats = await getFileStats(filepath, strapi2, isLocalProvider);
2317
2342
  const stream22 = getFileStream(filepath, strapi2, isLocalProvider);
@@ -2969,9 +2994,7 @@ class RemoteStrapiSourceProvider {
2969
2994
  });
2970
2995
  }
2971
2996
  async getSchemas() {
2972
- const schemas = await this.dispatcher?.dispatchTransferAction(
2973
- "getSchemas"
2974
- );
2997
+ const schemas = await this.dispatcher?.dispatchTransferAction("getSchemas");
2975
2998
  return schemas ?? null;
2976
2999
  }
2977
3000
  async #startStep(step) {
@@ -3110,8 +3133,11 @@ const transformUpgradeHeader = (header = "") => {
3110
3133
  return header.split(",").map((s) => s.trim().toLowerCase());
3111
3134
  };
3112
3135
  let timeouts;
3136
+ const hasHttpServer = () => {
3137
+ return typeof strapi !== "undefined" && !!strapi?.server?.httpServer;
3138
+ };
3113
3139
  const disableTimeouts = () => {
3114
- if (!strapi?.server?.httpServer) {
3140
+ if (!hasHttpServer()) {
3115
3141
  return;
3116
3142
  }
3117
3143
  const { httpServer } = strapi.server;
@@ -3126,7 +3152,7 @@ const disableTimeouts = () => {
3126
3152
  strapi.log.info("[Data transfer] Disabling http timeouts");
3127
3153
  };
3128
3154
  const resetTimeouts = () => {
3129
- if (!strapi?.server?.httpServer || !timeouts) {
3155
+ if (!hasHttpServer() || !timeouts) {
3130
3156
  return;
3131
3157
  }
3132
3158
  const { httpServer } = strapi.server;