@strapi/content-releases 5.0.0-alpha.0 → 5.0.0-alpha.2
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-dbdAcsz_.mjs → App-LDRseeB6.mjs} +4 -4
- package/dist/_chunks/App-LDRseeB6.mjs.map +1 -0
- package/dist/_chunks/{App-zwe_jKPv.js → App-eRTuh_--.js} +4 -4
- package/dist/_chunks/App-eRTuh_--.js.map +1 -0
- package/dist/_chunks/{index-RBaVMtyr.mjs → index-3U8t7Ohi.mjs} +20 -6
- package/dist/_chunks/index-3U8t7Ohi.mjs.map +1 -0
- package/dist/_chunks/{index-TBrVNrv9.js → index-W5ePH9Ir.js} +22 -8
- package/dist/_chunks/index-W5ePH9Ir.js.map +1 -0
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
- package/dist/server/index.js +31 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +32 -5
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/migrations/index.d.ts +1 -0
- package/dist/server/src/migrations/index.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/validation.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/App-dbdAcsz_.mjs.map +0 -1
- package/dist/_chunks/App-zwe_jKPv.js.map +0 -1
- package/dist/_chunks/index-RBaVMtyr.mjs.map +0 -1
- package/dist/_chunks/index-TBrVNrv9.js.map +0 -1
package/dist/server/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { async, setCreatorFields, convertQueryParams, errors, validateYupSchema, yup as yup$1 } from "@strapi/utils";
|
|
1
|
+
import { contentTypes as contentTypes$1, async, setCreatorFields, convertQueryParams, errors, validateYupSchema, yup as yup$1 } from "@strapi/utils";
|
|
2
2
|
import isEqual from "lodash/isEqual";
|
|
3
3
|
import { difference, keys } from "lodash";
|
|
4
4
|
import _ from "lodash/fp";
|
|
@@ -79,6 +79,24 @@ const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 } =
|
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
+
async function deleteActionsOnDisableDraftAndPublish({
|
|
83
|
+
oldContentTypes,
|
|
84
|
+
contentTypes: contentTypes2
|
|
85
|
+
}) {
|
|
86
|
+
if (!oldContentTypes) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
for (const uid in contentTypes2) {
|
|
90
|
+
if (!oldContentTypes[uid]) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const oldContentType = oldContentTypes[uid];
|
|
94
|
+
const contentType = contentTypes2[uid];
|
|
95
|
+
if (contentTypes$1.hasDraftAndPublish(oldContentType) && !contentTypes$1.hasDraftAndPublish(contentType)) {
|
|
96
|
+
await strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: uid }).execute();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
82
100
|
async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
83
101
|
const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes2)) ?? [];
|
|
84
102
|
if (deletedContentTypes.length) {
|
|
@@ -145,7 +163,9 @@ async function migrateIsValidAndStatusReleases() {
|
|
|
145
163
|
}
|
|
146
164
|
async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
147
165
|
if (oldContentTypes !== void 0 && contentTypes2 !== void 0) {
|
|
148
|
-
const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes)
|
|
166
|
+
const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(
|
|
167
|
+
(uid) => oldContentTypes[uid]?.options?.draftAndPublish
|
|
168
|
+
);
|
|
149
169
|
const releasesAffected = /* @__PURE__ */ new Set();
|
|
150
170
|
async.map(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
|
|
151
171
|
const oldContentType = oldContentTypes[contentTypeUID];
|
|
@@ -232,7 +252,7 @@ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: conte
|
|
|
232
252
|
const register = async ({ strapi: strapi2 }) => {
|
|
233
253
|
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
234
254
|
await strapi2.admin.services.permission.actionProvider.registerMany(ACTIONS);
|
|
235
|
-
strapi2.hook("strapi::content-types.beforeSync").register(disableContentTypeLocalized);
|
|
255
|
+
strapi2.hook("strapi::content-types.beforeSync").register(disableContentTypeLocalized).register(deleteActionsOnDisableDraftAndPublish);
|
|
236
256
|
strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(enableContentTypeLocalized).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
|
|
237
257
|
}
|
|
238
258
|
if (strapi2.plugin("graphql")) {
|
|
@@ -243,7 +263,9 @@ const register = async ({ strapi: strapi2 }) => {
|
|
|
243
263
|
};
|
|
244
264
|
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
245
265
|
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
246
|
-
const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes)
|
|
266
|
+
const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes).filter(
|
|
267
|
+
(uid) => strapi2.contentTypes[uid]?.options?.draftAndPublish
|
|
268
|
+
);
|
|
247
269
|
strapi2.db.lifecycles.subscribe({
|
|
248
270
|
models: contentTypesWithDraftAndPublish,
|
|
249
271
|
async afterDelete(event) {
|
|
@@ -279,7 +301,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
279
301
|
*/
|
|
280
302
|
async beforeDeleteMany(event) {
|
|
281
303
|
const { model, params } = event;
|
|
282
|
-
if (model.kind === "collectionType") {
|
|
304
|
+
if (model.kind === "collectionType" && model.options?.draftAndPublish) {
|
|
283
305
|
const { where } = params;
|
|
284
306
|
const entriesToDelete = await strapi2.db.query(model.uid).findMany({ select: ["id"], where });
|
|
285
307
|
event.state.entriesToDelete = entriesToDelete;
|
|
@@ -1106,6 +1128,11 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1106
1128
|
if (!contentType) {
|
|
1107
1129
|
throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);
|
|
1108
1130
|
}
|
|
1131
|
+
if (!contentType.options?.draftAndPublish) {
|
|
1132
|
+
throw new errors.ValidationError(
|
|
1133
|
+
`Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1109
1136
|
},
|
|
1110
1137
|
async validatePendingReleasesLimit() {
|
|
1111
1138
|
const maximumPendingReleases = strapi2.ee.features.get("cms-content-releases")?.options?.maximumReleases || 3;
|