@strapi/content-releases 5.0.0-beta.4 → 5.0.0-beta.6

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 (47) hide show
  1. package/dist/_chunks/{App-BIYLcg31.mjs → App-CVlffj0R.mjs} +32 -22
  2. package/dist/_chunks/App-CVlffj0R.mjs.map +1 -0
  3. package/dist/_chunks/{App-BEGE2QNe.js → App-CbOy9Yd2.js} +35 -25
  4. package/dist/_chunks/App-CbOy9Yd2.js.map +1 -0
  5. package/dist/_chunks/{PurchaseContentReleases-sD6ADHk2.js → PurchaseContentReleases-DAHdUpAA.js} +4 -4
  6. package/dist/_chunks/PurchaseContentReleases-DAHdUpAA.js.map +1 -0
  7. package/dist/_chunks/{PurchaseContentReleases-C8djn9fP.mjs → PurchaseContentReleases-Ex09YpKR.mjs} +5 -5
  8. package/dist/_chunks/PurchaseContentReleases-Ex09YpKR.mjs.map +1 -0
  9. package/dist/_chunks/{en-C4IblV7-.mjs → en-B9Ur3VsE.mjs} +2 -1
  10. package/dist/_chunks/en-B9Ur3VsE.mjs.map +1 -0
  11. package/dist/_chunks/{en-B07S6EN4.js → en-DtFJ5ViE.js} +2 -1
  12. package/dist/_chunks/en-DtFJ5ViE.js.map +1 -0
  13. package/dist/_chunks/{index-BoeHjl4L.mjs → index-B7mc1tVq.mjs} +62 -49
  14. package/dist/_chunks/index-B7mc1tVq.mjs.map +1 -0
  15. package/dist/_chunks/{index-CNPFfE_a.js → index-Bwn36oqx.js} +63 -50
  16. package/dist/_chunks/index-Bwn36oqx.js.map +1 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/ReleaseAction.d.ts +1 -1
  20. package/dist/admin/src/components/ReleaseListCell.d.ts +0 -0
  21. package/dist/admin/src/services/release.d.ts +61 -26
  22. package/dist/server/index.js +72 -10
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/server/index.mjs +72 -10
  25. package/dist/server/index.mjs.map +1 -1
  26. package/dist/server/src/controllers/index.d.ts +1 -0
  27. package/dist/server/src/controllers/index.d.ts.map +1 -1
  28. package/dist/server/src/controllers/release.d.ts +1 -0
  29. package/dist/server/src/controllers/release.d.ts.map +1 -1
  30. package/dist/server/src/index.d.ts +2 -1
  31. package/dist/server/src/index.d.ts.map +1 -1
  32. package/dist/server/src/migrations/index.d.ts.map +1 -1
  33. package/dist/server/src/routes/release.d.ts.map +1 -1
  34. package/dist/server/src/services/index.d.ts +1 -1
  35. package/dist/server/src/services/release.d.ts +2 -2
  36. package/dist/server/src/services/release.d.ts.map +1 -1
  37. package/dist/shared/contracts/releases.d.ts +17 -1
  38. package/dist/shared/contracts/releases.d.ts.map +1 -1
  39. package/package.json +10 -10
  40. package/dist/_chunks/App-BEGE2QNe.js.map +0 -1
  41. package/dist/_chunks/App-BIYLcg31.mjs.map +0 -1
  42. package/dist/_chunks/PurchaseContentReleases-C8djn9fP.mjs.map +0 -1
  43. package/dist/_chunks/PurchaseContentReleases-sD6ADHk2.js.map +0 -1
  44. package/dist/_chunks/en-B07S6EN4.js.map +0 -1
  45. package/dist/_chunks/en-C4IblV7-.mjs.map +0 -1
  46. package/dist/_chunks/index-BoeHjl4L.mjs.map +0 -1
  47. package/dist/_chunks/index-CNPFfE_a.js.map +0 -1
@@ -213,13 +213,16 @@ async function disableContentTypeLocalized({ oldContentTypes, contentTypes: cont
213
213
  if (!oldContentTypes) {
214
214
  return;
215
215
  }
216
+ const i18nPlugin = strapi.plugin("i18n");
217
+ if (!i18nPlugin) {
218
+ return;
219
+ }
216
220
  for (const uid in contentTypes2) {
217
221
  if (!oldContentTypes[uid]) {
218
222
  continue;
219
223
  }
220
224
  const oldContentType = oldContentTypes[uid];
221
225
  const contentType = contentTypes2[uid];
222
- const i18nPlugin = strapi.plugin("i18n");
223
226
  const { isLocalizedContentType } = i18nPlugin.service("content-types");
224
227
  if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
225
228
  await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
@@ -232,13 +235,16 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
232
235
  if (!oldContentTypes) {
233
236
  return;
234
237
  }
238
+ const i18nPlugin = strapi.plugin("i18n");
239
+ if (!i18nPlugin) {
240
+ return;
241
+ }
235
242
  for (const uid in contentTypes2) {
236
243
  if (!oldContentTypes[uid]) {
237
244
  continue;
238
245
  }
239
246
  const oldContentType = oldContentTypes[uid];
240
247
  const contentType = contentTypes2[uid];
241
- const i18nPlugin = strapi.plugin("i18n");
242
248
  const { isLocalizedContentType } = i18nPlugin.service("content-types");
243
249
  const { getDefaultLocale } = i18nPlugin.service("locales");
244
250
  if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
@@ -651,12 +657,18 @@ const createReleaseService = ({ strapi: strapi2 }) => {
651
657
  }
652
658
  });
653
659
  },
654
- async findManyWithContentTypeEntryAttached(contentTypeUid, entryId) {
660
+ async findManyWithContentTypeEntryAttached(contentTypeUid, entriesIds) {
661
+ let entries = entriesIds;
662
+ if (!Array.isArray(entriesIds)) {
663
+ entries = [entriesIds];
664
+ }
655
665
  const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
656
666
  where: {
657
667
  actions: {
658
668
  target_type: contentTypeUid,
659
- target_id: entryId
669
+ target_id: {
670
+ $in: entries
671
+ }
660
672
  },
661
673
  releasedAt: {
662
674
  $null: true
@@ -667,18 +679,25 @@ const createReleaseService = ({ strapi: strapi2 }) => {
667
679
  actions: {
668
680
  where: {
669
681
  target_type: contentTypeUid,
670
- target_id: entryId
682
+ target_id: {
683
+ $in: entries
684
+ }
685
+ },
686
+ populate: {
687
+ entry: {
688
+ select: ["id"]
689
+ }
671
690
  }
672
691
  }
673
692
  }
674
693
  });
675
694
  return releases.map((release2) => {
676
695
  if (release2.actions?.length) {
677
- const [actionForEntry] = release2.actions;
696
+ const actionsForEntry = release2.actions;
678
697
  delete release2.actions;
679
698
  return {
680
699
  ...release2,
681
- action: actionForEntry
700
+ actions: actionsForEntry
682
701
  };
683
702
  }
684
703
  return release2;
@@ -1295,6 +1314,35 @@ const releaseController = {
1295
1314
  };
1296
1315
  ctx.body = { data };
1297
1316
  },
1317
+ async mapEntriesToReleases(ctx) {
1318
+ const { contentTypeUid, entriesIds } = ctx.query;
1319
+ if (!contentTypeUid || !entriesIds) {
1320
+ throw new errors.ValidationError("Missing required query parameters");
1321
+ }
1322
+ const releaseService = getService("release", { strapi });
1323
+ const releasesWithActions = await releaseService.findManyWithContentTypeEntryAttached(
1324
+ contentTypeUid,
1325
+ entriesIds
1326
+ );
1327
+ const mappedEntriesInReleases = releasesWithActions.reduce(
1328
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1329
+ (acc, release2) => {
1330
+ release2.actions.forEach((action) => {
1331
+ if (!acc[action.entry.id]) {
1332
+ acc[action.entry.id] = [{ id: release2.id, name: release2.name }];
1333
+ } else {
1334
+ acc[action.entry.id].push({ id: release2.id, name: release2.name });
1335
+ }
1336
+ });
1337
+ return acc;
1338
+ },
1339
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1340
+ {}
1341
+ );
1342
+ ctx.body = {
1343
+ data: mappedEntriesInReleases
1344
+ };
1345
+ },
1298
1346
  async create(ctx) {
1299
1347
  const user = ctx.state.user;
1300
1348
  const releaseArgs = ctx.request.body;
@@ -1306,9 +1354,7 @@ const releaseController = {
1306
1354
  model: RELEASE_MODEL_UID
1307
1355
  });
1308
1356
  ctx.created({
1309
- body: {
1310
- data: await permissionsManager.sanitizeOutput(release2)
1311
- }
1357
+ data: await permissionsManager.sanitizeOutput(release2)
1312
1358
  });
1313
1359
  },
1314
1360
  async update(ctx) {
@@ -1486,6 +1532,22 @@ const controllers = { release: releaseController, "release-action": releaseActio
1486
1532
  const release = {
1487
1533
  type: "admin",
1488
1534
  routes: [
1535
+ {
1536
+ method: "GET",
1537
+ path: "/mapEntriesToReleases",
1538
+ handler: "release.mapEntriesToReleases",
1539
+ config: {
1540
+ policies: [
1541
+ "admin::isAuthenticatedAdmin",
1542
+ {
1543
+ name: "admin::hasPermissions",
1544
+ config: {
1545
+ actions: ["plugin::content-releases.read"]
1546
+ }
1547
+ }
1548
+ ]
1549
+ }
1550
+ },
1489
1551
  {
1490
1552
  method: "POST",
1491
1553
  path: "/",