@strapi/content-releases 0.0.0-experimental.d8a676a242377cee820b59b21a05d47290d9ac73 → 0.0.0-experimental.e3e48deb89bd0a1b6cc69b698696566fa7854a95
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-bpzO2Ljh.mjs → App-PQlYzNfb.mjs} +181 -167
- package/dist/_chunks/App-PQlYzNfb.mjs.map +1 -0
- package/dist/_chunks/{App-p8aKBitd.js → App-lzeJz92X.js} +179 -165
- package/dist/_chunks/App-lzeJz92X.js.map +1 -0
- package/dist/_chunks/{index-AECgcaDa.mjs → index--4AgLDzb.mjs} +20 -26
- package/dist/_chunks/index--4AgLDzb.mjs.map +1 -0
- package/dist/_chunks/{index-fP3qoWZ4.js → index-Nf1JfI-m.js} +16 -22
- package/dist/_chunks/index-Nf1JfI-m.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/CMReleasesContainer.d.ts +1 -0
- package/dist/admin/src/components/RelativeTime.d.ts +28 -0
- package/dist/admin/src/components/ReleaseActionMenu.d.ts +26 -0
- package/dist/admin/src/components/ReleaseActionOptions.d.ts +9 -0
- package/dist/admin/src/components/ReleaseModal.d.ts +16 -0
- package/dist/admin/src/constants.d.ts +58 -0
- package/dist/admin/src/index.d.ts +3 -0
- package/dist/admin/src/pages/App.d.ts +1 -0
- package/dist/admin/src/pages/PurchaseContentReleases.d.ts +2 -0
- package/dist/admin/src/pages/ReleaseDetailsPage.d.ts +2 -0
- package/dist/admin/src/pages/ReleasesPage.d.ts +8 -0
- package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +181 -0
- package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +39 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/services/axios.d.ts +29 -0
- package/dist/admin/src/services/release.d.ts +369 -0
- package/dist/admin/src/store/hooks.d.ts +7 -0
- package/dist/admin/src/utils/time.d.ts +1 -0
- package/dist/server/index.js +92 -171
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +93 -171
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -0
- package/dist/server/src/constants.d.ts +12 -0
- package/dist/server/src/constants.d.ts.map +1 -0
- package/dist/server/src/content-types/index.d.ts +99 -0
- package/dist/server/src/content-types/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release/index.d.ts +48 -0
- package/dist/server/src/content-types/release/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release/schema.d.ts +47 -0
- package/dist/server/src/content-types/release/schema.d.ts.map +1 -0
- package/dist/server/src/content-types/release-action/index.d.ts +50 -0
- package/dist/server/src/content-types/release-action/index.d.ts.map +1 -0
- package/dist/server/src/content-types/release-action/schema.d.ts +49 -0
- package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -0
- package/dist/server/src/controllers/index.d.ts +18 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -0
- package/dist/server/src/controllers/release-action.d.ts +9 -0
- package/dist/server/src/controllers/release-action.d.ts.map +1 -0
- package/dist/server/src/controllers/release.d.ts +11 -0
- package/dist/server/src/controllers/release.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/release-action.d.ts +3 -0
- package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/release.d.ts +2 -0
- package/dist/server/src/controllers/validation/release.d.ts.map +1 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/destroy.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +2092 -0
- package/dist/server/src/index.d.ts.map +1 -0
- package/dist/server/src/migrations/index.d.ts +10 -0
- package/dist/server/src/migrations/index.d.ts.map +1 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/register.d.ts.map +1 -0
- package/dist/server/src/routes/index.d.ts +35 -0
- package/dist/server/src/routes/index.d.ts.map +1 -0
- package/dist/server/src/routes/release-action.d.ts +18 -0
- package/dist/server/src/routes/release-action.d.ts.map +1 -0
- package/dist/server/src/routes/release.d.ts +18 -0
- package/dist/server/src/routes/release.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +1826 -0
- package/dist/server/src/services/index.d.ts.map +1 -0
- package/dist/server/src/services/release.d.ts +66 -0
- package/dist/server/src/services/release.d.ts.map +1 -0
- package/dist/server/src/services/scheduling.d.ts +18 -0
- package/dist/server/src/services/scheduling.d.ts.map +1 -0
- package/dist/server/src/services/validation.d.ts +14 -0
- package/dist/server/src/services/validation.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +14 -0
- package/dist/server/src/utils/index.d.ts.map +1 -0
- package/dist/shared/contracts/release-actions.d.ts +105 -0
- package/dist/shared/contracts/release-actions.d.ts.map +1 -0
- package/dist/shared/contracts/releases.d.ts +166 -0
- package/dist/shared/contracts/releases.d.ts.map +1 -0
- package/dist/shared/types.d.ts +24 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/validation-schemas.d.ts +2 -0
- package/dist/shared/validation-schemas.d.ts.map +1 -0
- package/package.json +14 -21
- package/dist/_chunks/App-bpzO2Ljh.mjs.map +0 -1
- package/dist/_chunks/App-p8aKBitd.js.map +0 -1
- package/dist/_chunks/index-AECgcaDa.mjs.map +0 -1
- package/dist/_chunks/index-fP3qoWZ4.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -3,7 +3,6 @@ const utils = require("@strapi/utils");
|
|
|
3
3
|
const isEqual = require("lodash/isEqual");
|
|
4
4
|
const lodash = require("lodash");
|
|
5
5
|
const _ = require("lodash/fp");
|
|
6
|
-
const EE = require("@strapi/strapi/dist/utils/ee");
|
|
7
6
|
const nodeSchedule = require("node-schedule");
|
|
8
7
|
const yup = require("yup");
|
|
9
8
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
@@ -27,7 +26,6 @@ function _interopNamespace(e) {
|
|
|
27
26
|
}
|
|
28
27
|
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
29
28
|
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
30
|
-
const EE__default = /* @__PURE__ */ _interopDefault(EE);
|
|
31
29
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
32
30
|
const RELEASE_MODEL_UID = "plugin::content-releases.release";
|
|
33
31
|
const RELEASE_ACTION_MODEL_UID = "plugin::content-releases.release-action";
|
|
@@ -84,7 +82,10 @@ const getService = (name, { strapi: strapi2 } = { strapi: global.strapi }) => {
|
|
|
84
82
|
const getPopulatedEntry = async (contentTypeUid, entryId, { strapi: strapi2 } = { strapi: global.strapi }) => {
|
|
85
83
|
const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
|
|
86
84
|
const populate = await populateBuilderService(contentTypeUid).populateDeep(Infinity).build();
|
|
87
|
-
const entry = await strapi2.
|
|
85
|
+
const entry = await strapi2.db.query(contentTypeUid).findOne({
|
|
86
|
+
where: { id: entryId },
|
|
87
|
+
populate
|
|
88
|
+
});
|
|
88
89
|
return entry;
|
|
89
90
|
};
|
|
90
91
|
const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 } = { strapi: global.strapi }) => {
|
|
@@ -101,28 +102,10 @@ const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 } =
|
|
|
101
102
|
return false;
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
|
-
async function deleteActionsOnDisableDraftAndPublish({
|
|
105
|
-
oldContentTypes,
|
|
106
|
-
contentTypes: contentTypes2
|
|
107
|
-
}) {
|
|
108
|
-
if (!oldContentTypes) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
for (const uid in contentTypes2) {
|
|
112
|
-
if (!oldContentTypes[uid]) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const oldContentType = oldContentTypes[uid];
|
|
116
|
-
const contentType = contentTypes2[uid];
|
|
117
|
-
if (utils.contentTypes.hasDraftAndPublish(oldContentType) && !utils.contentTypes.hasDraftAndPublish(contentType)) {
|
|
118
|
-
await strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: uid }).execute();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
105
|
async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
123
106
|
const deletedContentTypes = lodash.difference(lodash.keys(oldContentTypes), lodash.keys(contentTypes2)) ?? [];
|
|
124
107
|
if (deletedContentTypes.length) {
|
|
125
|
-
await utils.
|
|
108
|
+
await utils.async.map(deletedContentTypes, async (deletedContentTypeUID) => {
|
|
126
109
|
return strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: deletedContentTypeUID }).execute();
|
|
127
110
|
});
|
|
128
111
|
}
|
|
@@ -141,7 +124,7 @@ async function migrateIsValidAndStatusReleases() {
|
|
|
141
124
|
}
|
|
142
125
|
}
|
|
143
126
|
});
|
|
144
|
-
utils.
|
|
127
|
+
utils.async.map(releasesWithoutStatus, async (release2) => {
|
|
145
128
|
const actions = release2.actions;
|
|
146
129
|
const notValidatedActions = actions.filter((action) => action.isEntryValid === null);
|
|
147
130
|
for (const action of notValidatedActions) {
|
|
@@ -172,7 +155,7 @@ async function migrateIsValidAndStatusReleases() {
|
|
|
172
155
|
}
|
|
173
156
|
}
|
|
174
157
|
});
|
|
175
|
-
utils.
|
|
158
|
+
utils.async.map(publishedReleases, async (release2) => {
|
|
176
159
|
return strapi.db.query(RELEASE_MODEL_UID).update({
|
|
177
160
|
where: {
|
|
178
161
|
id: release2.id
|
|
@@ -185,11 +168,9 @@ async function migrateIsValidAndStatusReleases() {
|
|
|
185
168
|
}
|
|
186
169
|
async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
187
170
|
if (oldContentTypes !== void 0 && contentTypes2 !== void 0) {
|
|
188
|
-
const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes)
|
|
189
|
-
(uid) => oldContentTypes[uid]?.options?.draftAndPublish
|
|
190
|
-
);
|
|
171
|
+
const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes);
|
|
191
172
|
const releasesAffected = /* @__PURE__ */ new Set();
|
|
192
|
-
utils.
|
|
173
|
+
utils.async.map(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
|
|
193
174
|
const oldContentType = oldContentTypes[contentTypeUID];
|
|
194
175
|
const contentType = contentTypes2[contentTypeUID];
|
|
195
176
|
if (!isEqual__default.default(oldContentType?.attributes, contentType?.attributes)) {
|
|
@@ -202,8 +183,8 @@ async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: co
|
|
|
202
183
|
release: true
|
|
203
184
|
}
|
|
204
185
|
});
|
|
205
|
-
await utils.
|
|
206
|
-
if (action.entry
|
|
186
|
+
await utils.async.map(actions, async (action) => {
|
|
187
|
+
if (action.entry) {
|
|
207
188
|
const populatedEntry = await getPopulatedEntry(contentTypeUID, action.entry.id, {
|
|
208
189
|
strapi
|
|
209
190
|
});
|
|
@@ -225,71 +206,21 @@ async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: co
|
|
|
225
206
|
});
|
|
226
207
|
}
|
|
227
208
|
}).then(() => {
|
|
228
|
-
utils.
|
|
209
|
+
utils.async.map(releasesAffected, async (releaseId) => {
|
|
229
210
|
return getService("release", { strapi }).updateReleaseStatus(releaseId);
|
|
230
211
|
});
|
|
231
212
|
});
|
|
232
213
|
}
|
|
233
214
|
}
|
|
234
|
-
async function disableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
235
|
-
if (!oldContentTypes) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
for (const uid in contentTypes2) {
|
|
239
|
-
if (!oldContentTypes[uid]) {
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
const oldContentType = oldContentTypes[uid];
|
|
243
|
-
const contentType = contentTypes2[uid];
|
|
244
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
245
|
-
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
246
|
-
if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
|
|
247
|
-
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
248
|
-
locale: null
|
|
249
|
-
}).where({ contentType: uid }).execute();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
async function enableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
|
|
254
|
-
if (!oldContentTypes) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
for (const uid in contentTypes2) {
|
|
258
|
-
if (!oldContentTypes[uid]) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
const oldContentType = oldContentTypes[uid];
|
|
262
|
-
const contentType = contentTypes2[uid];
|
|
263
|
-
const i18nPlugin = strapi.plugin("i18n");
|
|
264
|
-
const { isLocalizedContentType } = i18nPlugin.service("content-types");
|
|
265
|
-
const { getDefaultLocale } = i18nPlugin.service("locales");
|
|
266
|
-
if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
|
|
267
|
-
const defaultLocale = await getDefaultLocale();
|
|
268
|
-
await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
|
|
269
|
-
locale: defaultLocale
|
|
270
|
-
}).where({ contentType: uid }).execute();
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
const { features: features$2 } = require("@strapi/strapi/dist/utils/ee");
|
|
275
215
|
const register = async ({ strapi: strapi2 }) => {
|
|
276
|
-
if (features
|
|
216
|
+
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
277
217
|
await strapi2.admin.services.permission.actionProvider.registerMany(ACTIONS);
|
|
278
|
-
strapi2.hook("strapi::content-types.
|
|
279
|
-
strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(enableContentTypeLocalized).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
|
|
280
|
-
}
|
|
281
|
-
if (strapi2.plugin("graphql")) {
|
|
282
|
-
const graphqlExtensionService = strapi2.plugin("graphql").service("extension");
|
|
283
|
-
graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();
|
|
284
|
-
graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();
|
|
218
|
+
strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
|
|
285
219
|
}
|
|
286
220
|
};
|
|
287
|
-
const { features: features$1 } = require("@strapi/strapi/dist/utils/ee");
|
|
288
221
|
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
289
|
-
if (features
|
|
290
|
-
const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes)
|
|
291
|
-
(uid) => strapi2.contentTypes[uid]?.options?.draftAndPublish
|
|
292
|
-
);
|
|
222
|
+
if (strapi2.ee.features.isEnabled("cms-content-releases")) {
|
|
223
|
+
const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes);
|
|
293
224
|
strapi2.db.lifecycles.subscribe({
|
|
294
225
|
models: contentTypesWithDraftAndPublish,
|
|
295
226
|
async afterDelete(event) {
|
|
@@ -325,7 +256,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
325
256
|
*/
|
|
326
257
|
async beforeDeleteMany(event) {
|
|
327
258
|
const { model, params } = event;
|
|
328
|
-
if (model.kind === "collectionType"
|
|
259
|
+
if (model.kind === "collectionType") {
|
|
329
260
|
const { where } = params;
|
|
330
261
|
const entriesToDelete = await strapi2.db.query(model.uid).findMany({ select: ["id"], where });
|
|
331
262
|
event.state.entriesToDelete = entriesToDelete;
|
|
@@ -565,7 +496,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
565
496
|
validateUniqueNameForPendingRelease(releaseWithCreatorFields.name),
|
|
566
497
|
validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
|
|
567
498
|
]);
|
|
568
|
-
const release2 = await strapi2.
|
|
499
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).create({
|
|
569
500
|
data: {
|
|
570
501
|
...releaseWithCreatorFields,
|
|
571
502
|
status: "empty"
|
|
@@ -579,17 +510,19 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
579
510
|
return release2;
|
|
580
511
|
},
|
|
581
512
|
async findOne(id, query = {}) {
|
|
582
|
-
const
|
|
583
|
-
|
|
513
|
+
const dbQuery = utils.convertQueryParams.transformParamsToQuery(RELEASE_MODEL_UID, query);
|
|
514
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
515
|
+
...dbQuery,
|
|
516
|
+
where: { id }
|
|
584
517
|
});
|
|
585
518
|
return release2;
|
|
586
519
|
},
|
|
587
520
|
findPage(query) {
|
|
588
|
-
|
|
589
|
-
|
|
521
|
+
const dbQuery = utils.convertQueryParams.transformParamsToQuery(RELEASE_MODEL_UID, query ?? {});
|
|
522
|
+
return strapi2.db.query(RELEASE_MODEL_UID).findPage({
|
|
523
|
+
...dbQuery,
|
|
590
524
|
populate: {
|
|
591
525
|
actions: {
|
|
592
|
-
// @ts-expect-error Ignore missing properties
|
|
593
526
|
count: true
|
|
594
527
|
}
|
|
595
528
|
}
|
|
@@ -681,19 +614,15 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
681
614
|
validateUniqueNameForPendingRelease(releaseWithCreatorFields.name, id),
|
|
682
615
|
validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
|
|
683
616
|
]);
|
|
684
|
-
const release2 = await strapi2.
|
|
617
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id } });
|
|
685
618
|
if (!release2) {
|
|
686
619
|
throw new utils.errors.NotFoundError(`No release found for id ${id}`);
|
|
687
620
|
}
|
|
688
621
|
if (release2.releasedAt) {
|
|
689
622
|
throw new utils.errors.ValidationError("Release already published");
|
|
690
623
|
}
|
|
691
|
-
const updatedRelease = await strapi2.
|
|
692
|
-
|
|
693
|
-
* The type returned from the entity service: Partial<Input<"plugin::content-releases.release">>
|
|
694
|
-
* is not compatible with the type we are passing here: UpdateRelease.Request['body']
|
|
695
|
-
*/
|
|
696
|
-
// @ts-expect-error see above
|
|
624
|
+
const updatedRelease = await strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
625
|
+
where: { id },
|
|
697
626
|
data: releaseWithCreatorFields
|
|
698
627
|
});
|
|
699
628
|
if (strapi2.features.future.isEnabled("contentReleasesScheduling")) {
|
|
@@ -716,7 +645,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
716
645
|
validateEntryContentType(action.entry.contentType),
|
|
717
646
|
validateUniqueEntry(releaseId, action)
|
|
718
647
|
]);
|
|
719
|
-
const release2 = await strapi2.
|
|
648
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
|
|
720
649
|
if (!release2) {
|
|
721
650
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
722
651
|
}
|
|
@@ -726,7 +655,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
726
655
|
const { entry, type } = action;
|
|
727
656
|
const populatedEntry = await getPopulatedEntry(entry.contentType, entry.id, { strapi: strapi2 });
|
|
728
657
|
const isEntryValid = await getEntryValidStatus(entry.contentType, populatedEntry, { strapi: strapi2 });
|
|
729
|
-
const releaseAction2 = await strapi2.
|
|
658
|
+
const releaseAction2 = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).create({
|
|
730
659
|
data: {
|
|
731
660
|
type,
|
|
732
661
|
contentType: entry.contentType,
|
|
@@ -739,32 +668,41 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
739
668
|
},
|
|
740
669
|
release: releaseId
|
|
741
670
|
},
|
|
742
|
-
populate: { release: {
|
|
671
|
+
populate: { release: { select: ["id"] }, entry: { select: ["id"] } }
|
|
743
672
|
});
|
|
744
673
|
this.updateReleaseStatus(releaseId);
|
|
745
674
|
return releaseAction2;
|
|
746
675
|
},
|
|
747
676
|
async findActions(releaseId, query) {
|
|
748
|
-
const release2 = await strapi2.
|
|
749
|
-
|
|
677
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
678
|
+
where: { id: releaseId },
|
|
679
|
+
select: ["id"]
|
|
750
680
|
});
|
|
751
681
|
if (!release2) {
|
|
752
682
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
753
683
|
}
|
|
754
|
-
|
|
755
|
-
|
|
684
|
+
const dbQuery = utils.convertQueryParams.transformParamsToQuery(
|
|
685
|
+
RELEASE_ACTION_MODEL_UID,
|
|
686
|
+
query ?? {}
|
|
687
|
+
);
|
|
688
|
+
return strapi2.db.query(RELEASE_ACTION_MODEL_UID).findPage({
|
|
689
|
+
...dbQuery,
|
|
756
690
|
populate: {
|
|
757
691
|
entry: {
|
|
758
692
|
populate: "*"
|
|
759
693
|
}
|
|
760
694
|
},
|
|
761
|
-
|
|
695
|
+
where: {
|
|
762
696
|
release: releaseId
|
|
763
697
|
}
|
|
764
698
|
});
|
|
765
699
|
},
|
|
766
700
|
async countActions(query) {
|
|
767
|
-
|
|
701
|
+
const dbQuery = utils.convertQueryParams.transformParamsToQuery(
|
|
702
|
+
RELEASE_ACTION_MODEL_UID,
|
|
703
|
+
query ?? {}
|
|
704
|
+
);
|
|
705
|
+
return strapi2.db.query(RELEASE_ACTION_MODEL_UID).count(dbQuery);
|
|
768
706
|
},
|
|
769
707
|
async groupActions(actions, groupBy) {
|
|
770
708
|
const contentTypeUids = actions.reduce((acc, action) => {
|
|
@@ -845,10 +783,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
845
783
|
return componentsMap;
|
|
846
784
|
},
|
|
847
785
|
async delete(releaseId) {
|
|
848
|
-
const release2 = await strapi2.
|
|
786
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
787
|
+
where: { id: releaseId },
|
|
849
788
|
populate: {
|
|
850
789
|
actions: {
|
|
851
|
-
|
|
790
|
+
select: ["id"]
|
|
852
791
|
}
|
|
853
792
|
}
|
|
854
793
|
});
|
|
@@ -866,7 +805,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
866
805
|
}
|
|
867
806
|
}
|
|
868
807
|
});
|
|
869
|
-
await strapi2.
|
|
808
|
+
await strapi2.db.query(RELEASE_MODEL_UID).delete({
|
|
809
|
+
where: {
|
|
810
|
+
id: releaseId
|
|
811
|
+
}
|
|
812
|
+
});
|
|
870
813
|
});
|
|
871
814
|
if (strapi2.features.future.isEnabled("contentReleasesScheduling") && release2.scheduledAt) {
|
|
872
815
|
const schedulingService = getService("scheduling", { strapi: strapi2 });
|
|
@@ -877,21 +820,18 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
877
820
|
},
|
|
878
821
|
async publish(releaseId) {
|
|
879
822
|
try {
|
|
880
|
-
const releaseWithPopulatedActionEntries = await strapi2.
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
entry: {
|
|
888
|
-
fields: ["id"]
|
|
889
|
-
}
|
|
823
|
+
const releaseWithPopulatedActionEntries = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
824
|
+
where: { id: releaseId },
|
|
825
|
+
populate: {
|
|
826
|
+
actions: {
|
|
827
|
+
populate: {
|
|
828
|
+
entry: {
|
|
829
|
+
select: ["id"]
|
|
890
830
|
}
|
|
891
831
|
}
|
|
892
832
|
}
|
|
893
833
|
}
|
|
894
|
-
);
|
|
834
|
+
});
|
|
895
835
|
if (!releaseWithPopulatedActionEntries) {
|
|
896
836
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
897
837
|
}
|
|
@@ -930,7 +870,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
930
870
|
await strapi2.db.transaction(async () => {
|
|
931
871
|
for (const { uid, action, id } of singleTypeActions) {
|
|
932
872
|
const populate = await populateBuilderService(uid).populateDeep(Infinity).build();
|
|
933
|
-
const entry = await strapi2.
|
|
873
|
+
const entry = await strapi2.db.query(uid).findOne({ where: { id }, populate });
|
|
934
874
|
try {
|
|
935
875
|
if (action === "publish") {
|
|
936
876
|
await entityManagerService.publish(entry, uid);
|
|
@@ -947,28 +887,22 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
947
887
|
for (const contentTypeUid of Object.keys(collectionTypeActions)) {
|
|
948
888
|
const populate = await populateBuilderService(contentTypeUid).populateDeep(Infinity).build();
|
|
949
889
|
const { entriestoPublishIds, entriesToUnpublishIds } = collectionTypeActions[contentTypeUid];
|
|
950
|
-
const entriesToPublish = await strapi2.
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
$in: entriesToUnpublishIds
|
|
967
|
-
}
|
|
968
|
-
},
|
|
969
|
-
populate
|
|
970
|
-
}
|
|
971
|
-
);
|
|
890
|
+
const entriesToPublish = await strapi2.db.query(contentTypeUid).findMany({
|
|
891
|
+
where: {
|
|
892
|
+
id: {
|
|
893
|
+
$in: entriestoPublishIds
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
populate
|
|
897
|
+
});
|
|
898
|
+
const entriesToUnpublish = await strapi2.db.query(contentTypeUid).findMany({
|
|
899
|
+
where: {
|
|
900
|
+
id: {
|
|
901
|
+
$in: entriesToUnpublishIds
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
populate
|
|
905
|
+
});
|
|
972
906
|
if (entriesToPublish.length > 0) {
|
|
973
907
|
await entityManagerService.publishMany(entriesToPublish, contentTypeUid);
|
|
974
908
|
}
|
|
@@ -977,17 +911,13 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
977
911
|
}
|
|
978
912
|
}
|
|
979
913
|
});
|
|
980
|
-
const release2 = await strapi2.
|
|
914
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).update({
|
|
915
|
+
where: { id: releaseId },
|
|
981
916
|
data: {
|
|
982
|
-
/*
|
|
983
|
-
* The type returned from the entity service: Partial<Input<"plugin::content-releases.release">> looks like it's wrong
|
|
984
|
-
*/
|
|
985
|
-
// @ts-expect-error see above
|
|
986
917
|
releasedAt: /* @__PURE__ */ new Date()
|
|
987
918
|
},
|
|
988
919
|
populate: {
|
|
989
920
|
actions: {
|
|
990
|
-
// @ts-expect-error is not expecting count but it is working
|
|
991
921
|
count: true
|
|
992
922
|
}
|
|
993
923
|
}
|
|
@@ -1103,8 +1033,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
|
|
|
1103
1033
|
};
|
|
1104
1034
|
const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
1105
1035
|
async validateUniqueEntry(releaseId, releaseActionArgs) {
|
|
1106
|
-
const release2 = await strapi2.
|
|
1107
|
-
|
|
1036
|
+
const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
|
|
1037
|
+
where: {
|
|
1038
|
+
id: releaseId
|
|
1039
|
+
},
|
|
1040
|
+
populate: { actions: { populate: { entry: { select: ["id"] } } } }
|
|
1108
1041
|
});
|
|
1109
1042
|
if (!release2) {
|
|
1110
1043
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
@@ -1123,17 +1056,9 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1123
1056
|
if (!contentType) {
|
|
1124
1057
|
throw new utils.errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);
|
|
1125
1058
|
}
|
|
1126
|
-
if (!contentType.options?.draftAndPublish) {
|
|
1127
|
-
throw new utils.errors.ValidationError(
|
|
1128
|
-
`Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
1059
|
},
|
|
1132
1060
|
async validatePendingReleasesLimit() {
|
|
1133
|
-
const maximumPendingReleases = (
|
|
1134
|
-
// @ts-expect-error - options is not typed into features
|
|
1135
|
-
EE__default.default.features.get("cms-content-releases")?.options?.maximumReleases || 3
|
|
1136
|
-
);
|
|
1061
|
+
const maximumPendingReleases = strapi2.ee.features.get("cms-content-releases")?.options?.maximumReleases || 3;
|
|
1137
1062
|
const [, pendingReleasesCount] = await strapi2.db.query(RELEASE_MODEL_UID).findWithCount({
|
|
1138
1063
|
filters: {
|
|
1139
1064
|
releasedAt: {
|
|
@@ -1146,8 +1071,8 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
|
|
|
1146
1071
|
}
|
|
1147
1072
|
},
|
|
1148
1073
|
async validateUniqueNameForPendingRelease(name, id) {
|
|
1149
|
-
const pendingReleases = await strapi2.
|
|
1150
|
-
|
|
1074
|
+
const pendingReleases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
|
|
1075
|
+
where: {
|
|
1151
1076
|
releasedAt: {
|
|
1152
1077
|
$null: true
|
|
1153
1078
|
},
|
|
@@ -1274,7 +1199,7 @@ const releaseController = {
|
|
|
1274
1199
|
}
|
|
1275
1200
|
};
|
|
1276
1201
|
});
|
|
1277
|
-
const pendingReleasesCount = await strapi.query(RELEASE_MODEL_UID).count({
|
|
1202
|
+
const pendingReleasesCount = await strapi.db.query(RELEASE_MODEL_UID).count({
|
|
1278
1203
|
where: {
|
|
1279
1204
|
releasedAt: null
|
|
1280
1205
|
}
|
|
@@ -1420,7 +1345,7 @@ const releaseActionController = {
|
|
|
1420
1345
|
acc[action.contentType] = contentTypePermissionsManager.sanitizeOutput;
|
|
1421
1346
|
return acc;
|
|
1422
1347
|
}, {});
|
|
1423
|
-
const sanitizedResults = await utils.
|
|
1348
|
+
const sanitizedResults = await utils.async.map(results, async (action) => ({
|
|
1424
1349
|
...action,
|
|
1425
1350
|
entry: await contentTypeOutputSanitizers[action.contentType](action.entry)
|
|
1426
1351
|
}));
|
|
@@ -1636,9 +1561,8 @@ const routes = {
|
|
|
1636
1561
|
release,
|
|
1637
1562
|
"release-action": releaseAction
|
|
1638
1563
|
};
|
|
1639
|
-
const { features } = require("@strapi/strapi/dist/utils/ee");
|
|
1640
1564
|
const getPlugin = () => {
|
|
1641
|
-
if (features.isEnabled("cms-content-releases")) {
|
|
1565
|
+
if (strapi.ee.features.isEnabled("cms-content-releases")) {
|
|
1642
1566
|
return {
|
|
1643
1567
|
register,
|
|
1644
1568
|
bootstrap,
|
|
@@ -1650,9 +1574,6 @@ const getPlugin = () => {
|
|
|
1650
1574
|
};
|
|
1651
1575
|
}
|
|
1652
1576
|
return {
|
|
1653
|
-
// Always return register, it handles its own feature check
|
|
1654
|
-
register,
|
|
1655
|
-
// Always return contentTypes to avoid losing data when the feature is disabled
|
|
1656
1577
|
contentTypes
|
|
1657
1578
|
};
|
|
1658
1579
|
};
|