@strapi/content-releases 5.2.0 → 5.4.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
@@ -88,6 +88,13 @@ const isEntryValid = async (contentTypeUid, entry, { strapi: strapi2 }) => {
88
88
  // @ts-expect-error - FIXME: entity here is unnecessary
89
89
  entry
90
90
  );
91
+ const workflowsService = strapi2.plugin("review-workflows").service("workflows");
92
+ const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
93
+ populate: "stageRequiredToPublish"
94
+ });
95
+ if (workflow?.stageRequiredToPublish) {
96
+ return entry.strapi_stage.id === workflow.stageRequiredToPublish.id;
97
+ }
91
98
  return true;
92
99
  } catch {
93
100
  return false;
@@ -355,6 +362,7 @@ const register = async ({ strapi: strapi2 }) => {
355
362
  const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
356
363
  const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
357
364
  where: {
365
+ releasedAt: null,
358
366
  actions: {
359
367
  contentType,
360
368
  entryDocumentId: entry.documentId,
@@ -363,7 +371,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
363
371
  }
364
372
  });
365
373
  const entryStatus = await isEntryValid(contentType, entry, { strapi });
366
- await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
374
+ await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
367
375
  where: {
368
376
  contentType,
369
377
  entryDocumentId: entry.documentId,
@@ -1023,16 +1031,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
1023
1031
  const groupName = getGroupName(groupBy);
1024
1032
  return _.groupBy(groupName)(formattedData);
1025
1033
  },
1026
- getContentTypeModelsFromActions(actions) {
1034
+ async getContentTypeModelsFromActions(actions) {
1027
1035
  const contentTypeUids = actions.reduce((acc, action) => {
1028
1036
  if (!acc.includes(action.contentType)) {
1029
1037
  acc.push(action.contentType);
1030
1038
  }
1031
1039
  return acc;
1032
1040
  }, []);
1033
- const contentTypeModelsMap = contentTypeUids.reduce(
1034
- (acc, contentTypeUid) => {
1035
- acc[contentTypeUid] = strapi2.getModel(contentTypeUid);
1041
+ const workflowsService = strapi2.plugin("review-workflows").service("workflows");
1042
+ const contentTypeModelsMap = await async.reduce(contentTypeUids)(
1043
+ async (accPromise, contentTypeUid) => {
1044
+ const acc = await accPromise;
1045
+ const contentTypeModel = strapi2.getModel(contentTypeUid);
1046
+ const workflow = await workflowsService.getAssignedWorkflow(contentTypeUid, {
1047
+ populate: "stageRequiredToPublish"
1048
+ });
1049
+ acc[contentTypeUid] = {
1050
+ ...contentTypeModel,
1051
+ hasReviewWorkflow: !!workflow,
1052
+ stageRequiredToPublish: workflow?.stageRequiredToPublish
1053
+ };
1036
1054
  return acc;
1037
1055
  },
1038
1056
  {}
@@ -1107,6 +1125,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
1107
1125
  }
1108
1126
  getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
1109
1127
  return deletedAction;
1128
+ },
1129
+ async validateActionsByContentTypes(contentTypeUids) {
1130
+ const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
1131
+ where: {
1132
+ contentType: {
1133
+ $in: contentTypeUids
1134
+ },
1135
+ // We only want to validate actions that are going to be published
1136
+ type: "publish",
1137
+ release: {
1138
+ releasedAt: {
1139
+ $null: true
1140
+ }
1141
+ }
1142
+ },
1143
+ populate: { release: true }
1144
+ });
1145
+ const releasesUpdated = [];
1146
+ await async.map(actions, async (action) => {
1147
+ const isValid = await getDraftEntryValidStatus(
1148
+ {
1149
+ contentType: action.contentType,
1150
+ documentId: action.entryDocumentId,
1151
+ locale: action.locale
1152
+ },
1153
+ { strapi: strapi2 }
1154
+ );
1155
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
1156
+ where: {
1157
+ id: action.id
1158
+ },
1159
+ data: {
1160
+ isEntryValid: isValid
1161
+ }
1162
+ });
1163
+ if (!releasesUpdated.includes(action.release.id)) {
1164
+ releasesUpdated.push(action.release.id);
1165
+ }
1166
+ return {
1167
+ id: action.id,
1168
+ isEntryValid: isValid
1169
+ };
1170
+ });
1171
+ if (releasesUpdated.length > 0) {
1172
+ await async.map(releasesUpdated, async (releaseId) => {
1173
+ await getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
1174
+ });
1175
+ }
1110
1176
  }
1111
1177
  };
1112
1178
  };
@@ -1625,7 +1691,7 @@ const releaseActionController = {
1625
1691
  entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
1626
1692
  }));
1627
1693
  const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
1628
- const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
1694
+ const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
1629
1695
  const releaseService = getService("release", { strapi });
1630
1696
  const components = await releaseService.getAllComponents();
1631
1697
  ctx.body = {