@strapi/content-releases 5.2.0 → 5.3.0

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 (40) hide show
  1. package/dist/_chunks/{App-Cne--1Z8.mjs → App-BX6_LcmS.mjs} +297 -112
  2. package/dist/_chunks/App-BX6_LcmS.mjs.map +1 -0
  3. package/dist/_chunks/{App-BKB1esYS.js → App-DITZWWqI.js} +337 -152
  4. package/dist/_chunks/App-DITZWWqI.js.map +1 -0
  5. package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs → ReleasesSettingsPage-BMgLwqci.mjs} +2 -2
  6. package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs.map → ReleasesSettingsPage-BMgLwqci.mjs.map} +1 -1
  7. package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js → ReleasesSettingsPage-DZcRvN_O.js} +2 -2
  8. package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js.map → ReleasesSettingsPage-DZcRvN_O.js.map} +1 -1
  9. package/dist/_chunks/{en-CmYoEnA7.js → en-BWPPsSH-.js} +11 -2
  10. package/dist/_chunks/en-BWPPsSH-.js.map +1 -0
  11. package/dist/_chunks/{en-D0yVZFqf.mjs → en-D9Q4YW03.mjs} +11 -2
  12. package/dist/_chunks/en-D9Q4YW03.mjs.map +1 -0
  13. package/dist/_chunks/{index-Cy7qwpaU.mjs → index-CBsSVKTv.mjs} +22 -4
  14. package/dist/_chunks/index-CBsSVKTv.mjs.map +1 -0
  15. package/dist/_chunks/{index-5Odi61vw.js → index-TfMp19WL.js} +22 -4
  16. package/dist/_chunks/index-TfMp19WL.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/EntryValidationPopover.d.ts +13 -0
  20. package/dist/server/index.js +72 -6
  21. package/dist/server/index.js.map +1 -1
  22. package/dist/server/index.mjs +72 -6
  23. package/dist/server/index.mjs.map +1 -1
  24. package/dist/server/src/index.d.ts +2 -6
  25. package/dist/server/src/index.d.ts.map +1 -1
  26. package/dist/server/src/middlewares/documents.d.ts.map +1 -1
  27. package/dist/server/src/services/index.d.ts +2 -6
  28. package/dist/server/src/services/index.d.ts.map +1 -1
  29. package/dist/server/src/services/release-action.d.ts +3 -7
  30. package/dist/server/src/services/release-action.d.ts.map +1 -1
  31. package/dist/server/src/utils/index.d.ts.map +1 -1
  32. package/dist/shared/contracts/release-actions.d.ts +8 -1
  33. package/dist/shared/contracts/release-actions.d.ts.map +1 -1
  34. package/package.json +11 -10
  35. package/dist/_chunks/App-BKB1esYS.js.map +0 -1
  36. package/dist/_chunks/App-Cne--1Z8.mjs.map +0 -1
  37. package/dist/_chunks/en-CmYoEnA7.js.map +0 -1
  38. package/dist/_chunks/en-D0yVZFqf.mjs.map +0 -1
  39. package/dist/_chunks/index-5Odi61vw.js.map +0 -1
  40. package/dist/_chunks/index-Cy7qwpaU.mjs.map +0 -1
@@ -111,6 +111,13 @@ const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
111
111
  // @ts-expect-error - FIXME: entity here is unnecessary
112
112
  entry
113
113
  );
114
+ const workflowsService = strapi2.plugin("review-workflows").service("workflows");
115
+ const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
116
+ populate: "stageRequiredToPublish"
117
+ });
118
+ if (workflow?.stageRequiredToPublish) {
119
+ return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
120
+ }
114
121
  return true;
115
122
  } catch {
116
123
  return false;
@@ -378,6 +385,7 @@ const register = async ({ strapi: strapi2 }) => {
378
385
  const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
379
386
  const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
380
387
  where: {
388
+ releasedAt: null,
381
389
  actions: {
382
390
  contentType,
383
391
  entryDocumentId: entry.documentId,
@@ -386,7 +394,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
386
394
  }
387
395
  });
388
396
  const entryStatus = await isEntryValid(contentType, entry, { strapi });
389
- await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
397
+ await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
390
398
  where: {
391
399
  contentType,
392
400
  entryDocumentId: entry.documentId,
@@ -1046,16 +1054,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
1046
1054
  const groupName = getGroupName(groupBy);
1047
1055
  return ___default.default.groupBy(groupName)(formattedData);
1048
1056
  },
1049
- getContentTypeModelsFromActions(actions) {
1057
+ async getContentTypeModelsFromActions(actions) {
1050
1058
  const contentTypeUids = actions.reduce((acc, action) => {
1051
1059
  if (!acc.includes(action.contentType)) {
1052
1060
  acc.push(action.contentType);
1053
1061
  }
1054
1062
  return acc;
1055
1063
  }, []);
1056
- const contentTypeModelsMap = contentTypeUids.reduce(
1057
- (acc, contentTypeUid) => {
1058
- acc[contentTypeUid] = strapi2.getModel(contentTypeUid);
1064
+ const workflowsService = strapi2.plugin("review-workflows").service("workflows");
1065
+ const contentTypeModelsMap = await utils.async.reduce(contentTypeUids)(
1066
+ async (accPromise, contentTypeUid) => {
1067
+ const acc = await accPromise;
1068
+ const contentTypeModel = strapi2.getModel(contentTypeUid);
1069
+ const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
1070
+ populate: "stageRequiredToPublish"
1071
+ });
1072
+ acc[contentTypeUid] = {
1073
+ ...contentTypeModel,
1074
+ hasReviewWorkflow: !!workflow,
1075
+ stageRequiredToPublish: workflow?.stageRequiredToPublish
1076
+ };
1059
1077
  return acc;
1060
1078
  },
1061
1079
  {}
@@ -1130,6 +1148,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
1130
1148
  }
1131
1149
  getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
1132
1150
  return deletedAction;
1151
+ },
1152
+ async validateActionsByContentTypes(contentTypeUids) {
1153
+ const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
1154
+ where: {
1155
+ contentType: {
1156
+ $in: contentTypeUids
1157
+ },
1158
+ // We only want to validate actions that are going to be published
1159
+ type: "publish",
1160
+ release: {
1161
+ releasedAt: {
1162
+ $null: true
1163
+ }
1164
+ }
1165
+ },
1166
+ populate: { release: true }
1167
+ });
1168
+ const releasesUpdated = [];
1169
+ await utils.async.map(actions, async (action) => {
1170
+ const isValid = await getDraftEntryValidStatus(
1171
+ {
1172
+ contentType: action.contentType,
1173
+ documentId: action.entryDocumentId,
1174
+ locale: action.locale
1175
+ },
1176
+ { strapi: strapi2 }
1177
+ );
1178
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
1179
+ where: {
1180
+ id: action.id
1181
+ },
1182
+ data: {
1183
+ isEntryValid: isValid
1184
+ }
1185
+ });
1186
+ if (!releasesUpdated.includes(action.release.id)) {
1187
+ releasesUpdated.push(action.release.id);
1188
+ }
1189
+ return {
1190
+ id: action.id,
1191
+ isEntryValid: isValid
1192
+ };
1193
+ });
1194
+ if (releasesUpdated.length > 0) {
1195
+ await utils.async.map(releasesUpdated, async (releaseId) => {
1196
+ await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
1197
+ });
1198
+ }
1133
1199
  }
1134
1200
  };
1135
1201
  };
@@ -1648,7 +1714,7 @@ const releaseActionController = {
1648
1714
  entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
1649
1715
  }));
1650
1716
  const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
1651
- const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
1717
+ const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
1652
1718
  const releaseService = getService("release", { strapi });
1653
1719
  const components = await releaseService.getAllComponents();
1654
1720
  ctx.body = {