@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
@@ -236,13 +236,16 @@ async function disableContentTypeLocalized({ oldContentTypes, contentTypes: cont
236
236
  if (!oldContentTypes) {
237
237
  return;
238
238
  }
239
+ const i18nPlugin = strapi.plugin("i18n");
240
+ if (!i18nPlugin) {
241
+ return;
242
+ }
239
243
  for (const uid in contentTypes2) {
240
244
  if (!oldContentTypes[uid]) {
241
245
  continue;
242
246
  }
243
247
  const oldContentType = oldContentTypes[uid];
244
248
  const contentType = contentTypes2[uid];
245
- const i18nPlugin = strapi.plugin("i18n");
246
249
  const { isLocalizedContentType } = i18nPlugin.service("content-types");
247
250
  if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
248
251
  await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
@@ -255,13 +258,16 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
255
258
  if (!oldContentTypes) {
256
259
  return;
257
260
  }
261
+ const i18nPlugin = strapi.plugin("i18n");
262
+ if (!i18nPlugin) {
263
+ return;
264
+ }
258
265
  for (const uid in contentTypes2) {
259
266
  if (!oldContentTypes[uid]) {
260
267
  continue;
261
268
  }
262
269
  const oldContentType = oldContentTypes[uid];
263
270
  const contentType = contentTypes2[uid];
264
- const i18nPlugin = strapi.plugin("i18n");
265
271
  const { isLocalizedContentType } = i18nPlugin.service("content-types");
266
272
  const { getDefaultLocale } = i18nPlugin.service("locales");
267
273
  if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
@@ -674,12 +680,18 @@ const createReleaseService = ({ strapi: strapi2 }) => {
674
680
  }
675
681
  });
676
682
  },
677
- async findManyWithContentTypeEntryAttached(contentTypeUid, entryId) {
683
+ async findManyWithContentTypeEntryAttached(contentTypeUid, entriesIds) {
684
+ let entries = entriesIds;
685
+ if (!Array.isArray(entriesIds)) {
686
+ entries = [entriesIds];
687
+ }
678
688
  const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
679
689
  where: {
680
690
  actions: {
681
691
  target_type: contentTypeUid,
682
- target_id: entryId
692
+ target_id: {
693
+ $in: entries
694
+ }
683
695
  },
684
696
  releasedAt: {
685
697
  $null: true
@@ -690,18 +702,25 @@ const createReleaseService = ({ strapi: strapi2 }) => {
690
702
  actions: {
691
703
  where: {
692
704
  target_type: contentTypeUid,
693
- target_id: entryId
705
+ target_id: {
706
+ $in: entries
707
+ }
708
+ },
709
+ populate: {
710
+ entry: {
711
+ select: ["id"]
712
+ }
694
713
  }
695
714
  }
696
715
  }
697
716
  });
698
717
  return releases.map((release2) => {
699
718
  if (release2.actions?.length) {
700
- const [actionForEntry] = release2.actions;
719
+ const actionsForEntry = release2.actions;
701
720
  delete release2.actions;
702
721
  return {
703
722
  ...release2,
704
- action: actionForEntry
723
+ actions: actionsForEntry
705
724
  };
706
725
  }
707
726
  return release2;
@@ -1318,6 +1337,35 @@ const releaseController = {
1318
1337
  };
1319
1338
  ctx.body = { data };
1320
1339
  },
1340
+ async mapEntriesToReleases(ctx) {
1341
+ const { contentTypeUid, entriesIds } = ctx.query;
1342
+ if (!contentTypeUid || !entriesIds) {
1343
+ throw new utils.errors.ValidationError("Missing required query parameters");
1344
+ }
1345
+ const releaseService = getService("release", { strapi });
1346
+ const releasesWithActions = await releaseService.findManyWithContentTypeEntryAttached(
1347
+ contentTypeUid,
1348
+ entriesIds
1349
+ );
1350
+ const mappedEntriesInReleases = releasesWithActions.reduce(
1351
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1352
+ (acc, release2) => {
1353
+ release2.actions.forEach((action) => {
1354
+ if (!acc[action.entry.id]) {
1355
+ acc[action.entry.id] = [{ id: release2.id, name: release2.name }];
1356
+ } else {
1357
+ acc[action.entry.id].push({ id: release2.id, name: release2.name });
1358
+ }
1359
+ });
1360
+ return acc;
1361
+ },
1362
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1363
+ {}
1364
+ );
1365
+ ctx.body = {
1366
+ data: mappedEntriesInReleases
1367
+ };
1368
+ },
1321
1369
  async create(ctx) {
1322
1370
  const user = ctx.state.user;
1323
1371
  const releaseArgs = ctx.request.body;
@@ -1329,9 +1377,7 @@ const releaseController = {
1329
1377
  model: RELEASE_MODEL_UID
1330
1378
  });
1331
1379
  ctx.created({
1332
- body: {
1333
- data: await permissionsManager.sanitizeOutput(release2)
1334
- }
1380
+ data: await permissionsManager.sanitizeOutput(release2)
1335
1381
  });
1336
1382
  },
1337
1383
  async update(ctx) {
@@ -1509,6 +1555,22 @@ const controllers = { release: releaseController, "release-action": releaseActio
1509
1555
  const release = {
1510
1556
  type: "admin",
1511
1557
  routes: [
1558
+ {
1559
+ method: "GET",
1560
+ path: "/mapEntriesToReleases",
1561
+ handler: "release.mapEntriesToReleases",
1562
+ config: {
1563
+ policies: [
1564
+ "admin::isAuthenticatedAdmin",
1565
+ {
1566
+ name: "admin::hasPermissions",
1567
+ config: {
1568
+ actions: ["plugin::content-releases.read"]
1569
+ }
1570
+ }
1571
+ ]
1572
+ }
1573
+ },
1512
1574
  {
1513
1575
  method: "POST",
1514
1576
  path: "/",