@strapi/content-releases 5.1.1 → 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.
- package/dist/_chunks/{App-Cne--1Z8.mjs → App-BX6_LcmS.mjs} +297 -112
- package/dist/_chunks/App-BX6_LcmS.mjs.map +1 -0
- package/dist/_chunks/{App-BKB1esYS.js → App-DITZWWqI.js} +337 -152
- package/dist/_chunks/App-DITZWWqI.js.map +1 -0
- package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs → ReleasesSettingsPage-BMgLwqci.mjs} +2 -2
- package/dist/_chunks/{ReleasesSettingsPage-C1WwGWIH.mjs.map → ReleasesSettingsPage-BMgLwqci.mjs.map} +1 -1
- package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js → ReleasesSettingsPage-DZcRvN_O.js} +2 -2
- package/dist/_chunks/{ReleasesSettingsPage-kuXIwpWp.js.map → ReleasesSettingsPage-DZcRvN_O.js.map} +1 -1
- package/dist/_chunks/{en-CmYoEnA7.js → en-BWPPsSH-.js} +11 -2
- package/dist/_chunks/en-BWPPsSH-.js.map +1 -0
- package/dist/_chunks/{en-D0yVZFqf.mjs → en-D9Q4YW03.mjs} +11 -2
- package/dist/_chunks/en-D9Q4YW03.mjs.map +1 -0
- package/dist/_chunks/{index-Cy7qwpaU.mjs → index-CBsSVKTv.mjs} +22 -4
- package/dist/_chunks/index-CBsSVKTv.mjs.map +1 -0
- package/dist/_chunks/{index-5Odi61vw.js → index-TfMp19WL.js} +22 -4
- package/dist/_chunks/index-TfMp19WL.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/EntryValidationPopover.d.ts +13 -0
- package/dist/server/index.js +79 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +79 -9
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/index.d.ts +2 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/middlewares/documents.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +2 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/release-action.d.ts +3 -7
- package/dist/server/src/services/release-action.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/release-actions.d.ts +8 -1
- package/dist/shared/contracts/release-actions.d.ts.map +1 -1
- package/package.json +11 -10
- package/dist/_chunks/App-BKB1esYS.js.map +0 -1
- package/dist/_chunks/App-Cne--1Z8.mjs.map +0 -1
- package/dist/_chunks/en-CmYoEnA7.js.map +0 -1
- package/dist/_chunks/en-D0yVZFqf.mjs.map +0 -1
- package/dist/_chunks/index-5Odi61vw.js.map +0 -1
- package/dist/_chunks/index-Cy7qwpaU.mjs.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -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;
|
|
@@ -124,7 +131,11 @@ const getEntry = async ({
|
|
|
124
131
|
status = "draft"
|
|
125
132
|
}, { strapi: strapi2 }) => {
|
|
126
133
|
if (documentId) {
|
|
127
|
-
|
|
134
|
+
const entry = await strapi2.documents(contentType).findOne({ documentId, locale, populate, status });
|
|
135
|
+
if (status === "published" && !entry) {
|
|
136
|
+
return strapi2.documents(contentType).findOne({ documentId, locale, populate, status: "draft" });
|
|
137
|
+
}
|
|
138
|
+
return entry;
|
|
128
139
|
}
|
|
129
140
|
return strapi2.documents(contentType).findFirst({ locale, populate, status });
|
|
130
141
|
};
|
|
@@ -374,6 +385,7 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
374
385
|
const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) => {
|
|
375
386
|
const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
|
|
376
387
|
where: {
|
|
388
|
+
releasedAt: null,
|
|
377
389
|
actions: {
|
|
378
390
|
contentType,
|
|
379
391
|
entryDocumentId: entry.documentId,
|
|
@@ -382,7 +394,7 @@ const updateActionsStatusAndUpdateReleaseStatus = async (contentType, entry) =>
|
|
|
382
394
|
}
|
|
383
395
|
});
|
|
384
396
|
const entryStatus = await isEntryValid(contentType, entry, { strapi });
|
|
385
|
-
await strapi.db.query(RELEASE_ACTION_MODEL_UID).
|
|
397
|
+
await strapi.db.query(RELEASE_ACTION_MODEL_UID).updateMany({
|
|
386
398
|
where: {
|
|
387
399
|
contentType,
|
|
388
400
|
entryDocumentId: entry.documentId,
|
|
@@ -486,8 +498,8 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
486
498
|
const { where } = event.params;
|
|
487
499
|
deleteReleasesActionsAndUpdateReleaseStatus({
|
|
488
500
|
contentType: model.uid,
|
|
489
|
-
locale: where
|
|
490
|
-
...where
|
|
501
|
+
locale: where?.locale ?? null,
|
|
502
|
+
...where?.documentId && { entryDocumentId: where.documentId }
|
|
491
503
|
});
|
|
492
504
|
}
|
|
493
505
|
} catch (error) {
|
|
@@ -1042,16 +1054,26 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1042
1054
|
const groupName = getGroupName(groupBy);
|
|
1043
1055
|
return ___default.default.groupBy(groupName)(formattedData);
|
|
1044
1056
|
},
|
|
1045
|
-
getContentTypeModelsFromActions(actions) {
|
|
1057
|
+
async getContentTypeModelsFromActions(actions) {
|
|
1046
1058
|
const contentTypeUids = actions.reduce((acc, action) => {
|
|
1047
1059
|
if (!acc.includes(action.contentType)) {
|
|
1048
1060
|
acc.push(action.contentType);
|
|
1049
1061
|
}
|
|
1050
1062
|
return acc;
|
|
1051
1063
|
}, []);
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
+
};
|
|
1055
1077
|
return acc;
|
|
1056
1078
|
},
|
|
1057
1079
|
{}
|
|
@@ -1126,6 +1148,54 @@ const createReleaseActionService = ({ strapi: strapi2 }) => {
|
|
|
1126
1148
|
}
|
|
1127
1149
|
getService("release", { strapi: strapi2 }).updateReleaseStatus(releaseId);
|
|
1128
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
|
+
}
|
|
1129
1199
|
}
|
|
1130
1200
|
};
|
|
1131
1201
|
};
|
|
@@ -1644,7 +1714,7 @@ const releaseActionController = {
|
|
|
1644
1714
|
entry: action.entry ? await contentTypeOutputSanitizers[action.contentType](action.entry) : {}
|
|
1645
1715
|
}));
|
|
1646
1716
|
const groupedData = await releaseActionService.groupActions(sanitizedResults, query.sort);
|
|
1647
|
-
const contentTypes2 = releaseActionService.getContentTypeModelsFromActions(results);
|
|
1717
|
+
const contentTypes2 = await releaseActionService.getContentTypeModelsFromActions(results);
|
|
1648
1718
|
const releaseService = getService("release", { strapi });
|
|
1649
1719
|
const components = await releaseService.getAllComponents();
|
|
1650
1720
|
ctx.body = {
|