@strapi/content-releases 0.0.0-experimental.check-license → 0.0.0-experimental.d23c1d5b0e45dd06ef09977f526c85468be05403

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 (107) hide show
  1. package/dist/_chunks/App-Cmn2Mkn7.mjs +1343 -0
  2. package/dist/_chunks/App-Cmn2Mkn7.mjs.map +1 -0
  3. package/dist/_chunks/App-FVorrIzF.js +1366 -0
  4. package/dist/_chunks/App-FVorrIzF.js.map +1 -0
  5. package/dist/_chunks/PurchaseContentReleases-C8djn9fP.mjs +51 -0
  6. package/dist/_chunks/PurchaseContentReleases-C8djn9fP.mjs.map +1 -0
  7. package/dist/_chunks/PurchaseContentReleases-sD6ADHk2.js +51 -0
  8. package/dist/_chunks/PurchaseContentReleases-sD6ADHk2.js.map +1 -0
  9. package/dist/_chunks/en-B9Ur3VsE.mjs +86 -0
  10. package/dist/_chunks/en-B9Ur3VsE.mjs.map +1 -0
  11. package/dist/_chunks/en-DtFJ5ViE.js +86 -0
  12. package/dist/_chunks/en-DtFJ5ViE.js.map +1 -0
  13. package/dist/_chunks/index-BfJLth9Z.js +1266 -0
  14. package/dist/_chunks/index-BfJLth9Z.js.map +1 -0
  15. package/dist/_chunks/index-DDohgTaQ.mjs +1245 -0
  16. package/dist/_chunks/index-DDohgTaQ.mjs.map +1 -0
  17. package/dist/admin/index.js +3 -35
  18. package/dist/admin/index.js.map +1 -1
  19. package/dist/admin/index.mjs +3 -35
  20. package/dist/admin/index.mjs.map +1 -1
  21. package/dist/admin/src/components/CMReleasesContainer.d.ts +22 -0
  22. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  23. package/dist/admin/src/components/ReleaseAction.d.ts +3 -0
  24. package/dist/admin/src/components/ReleaseActionMenu.d.ts +26 -0
  25. package/dist/admin/src/components/ReleaseActionOptions.d.ts +9 -0
  26. package/dist/admin/src/components/ReleaseModal.d.ts +16 -0
  27. package/dist/admin/src/constants.d.ts +58 -0
  28. package/dist/admin/src/index.d.ts +3 -15
  29. package/dist/admin/src/pages/App.d.ts +1 -0
  30. package/dist/admin/src/pages/PurchaseContentReleases.d.ts +2 -0
  31. package/dist/admin/src/pages/ReleaseDetailsPage.d.ts +2 -0
  32. package/dist/admin/src/pages/ReleasesPage.d.ts +8 -0
  33. package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +181 -0
  34. package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +39 -0
  35. package/dist/admin/src/pluginId.d.ts +1 -0
  36. package/dist/admin/src/services/axios.d.ts +29 -0
  37. package/dist/admin/src/services/release.d.ts +429 -0
  38. package/dist/admin/src/store/hooks.d.ts +7 -0
  39. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
  40. package/dist/admin/src/utils/time.d.ts +1 -0
  41. package/dist/server/index.js +1776 -6
  42. package/dist/server/index.js.map +1 -1
  43. package/dist/server/index.mjs +1754 -6
  44. package/dist/server/index.mjs.map +1 -1
  45. package/dist/server/src/bootstrap.d.ts +5 -0
  46. package/dist/server/src/bootstrap.d.ts.map +1 -0
  47. package/dist/server/src/constants.d.ts +12 -0
  48. package/dist/server/src/constants.d.ts.map +1 -0
  49. package/dist/server/src/content-types/index.d.ts +99 -0
  50. package/dist/server/src/content-types/index.d.ts.map +1 -0
  51. package/dist/server/src/content-types/release/index.d.ts +48 -0
  52. package/dist/server/src/content-types/release/index.d.ts.map +1 -0
  53. package/dist/server/src/content-types/release/schema.d.ts +47 -0
  54. package/dist/server/src/content-types/release/schema.d.ts.map +1 -0
  55. package/dist/server/src/content-types/release-action/index.d.ts +50 -0
  56. package/dist/server/src/content-types/release-action/index.d.ts.map +1 -0
  57. package/dist/server/src/content-types/release-action/schema.d.ts +49 -0
  58. package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -0
  59. package/dist/server/src/controllers/index.d.ts +20 -0
  60. package/dist/server/src/controllers/index.d.ts.map +1 -0
  61. package/dist/server/src/controllers/release-action.d.ts +10 -0
  62. package/dist/server/src/controllers/release-action.d.ts.map +1 -0
  63. package/dist/server/src/controllers/release.d.ts +12 -0
  64. package/dist/server/src/controllers/release.d.ts.map +1 -0
  65. package/dist/server/src/controllers/validation/release-action.d.ts +8 -0
  66. package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -0
  67. package/dist/server/src/controllers/validation/release.d.ts +2 -0
  68. package/dist/server/src/controllers/validation/release.d.ts.map +1 -0
  69. package/dist/server/src/destroy.d.ts +5 -0
  70. package/dist/server/src/destroy.d.ts.map +1 -0
  71. package/dist/server/src/index.d.ts +2093 -1
  72. package/dist/server/src/index.d.ts.map +1 -0
  73. package/dist/server/src/migrations/index.d.ts +13 -0
  74. package/dist/server/src/migrations/index.d.ts.map +1 -0
  75. package/dist/server/src/register.d.ts +5 -1
  76. package/dist/server/src/register.d.ts.map +1 -0
  77. package/dist/server/src/routes/index.d.ts +35 -0
  78. package/dist/server/src/routes/index.d.ts.map +1 -0
  79. package/dist/server/src/routes/release-action.d.ts +18 -0
  80. package/dist/server/src/routes/release-action.d.ts.map +1 -0
  81. package/dist/server/src/routes/release.d.ts +18 -0
  82. package/dist/server/src/routes/release.d.ts.map +1 -0
  83. package/dist/server/src/services/index.d.ts +1826 -0
  84. package/dist/server/src/services/index.d.ts.map +1 -0
  85. package/dist/server/src/services/release.d.ts +66 -0
  86. package/dist/server/src/services/release.d.ts.map +1 -0
  87. package/dist/server/src/services/scheduling.d.ts +18 -0
  88. package/dist/server/src/services/scheduling.d.ts.map +1 -0
  89. package/dist/server/src/services/validation.d.ts +18 -0
  90. package/dist/server/src/services/validation.d.ts.map +1 -0
  91. package/dist/server/src/utils/index.d.ts +14 -0
  92. package/dist/server/src/utils/index.d.ts.map +1 -0
  93. package/dist/shared/contracts/release-actions.d.ts +131 -0
  94. package/dist/shared/contracts/release-actions.d.ts.map +1 -0
  95. package/dist/shared/contracts/releases.d.ts +182 -0
  96. package/dist/shared/contracts/releases.d.ts.map +1 -0
  97. package/dist/shared/types.d.ts +24 -0
  98. package/dist/shared/types.d.ts.map +1 -0
  99. package/dist/shared/validation-schemas.d.ts +2 -0
  100. package/dist/shared/validation-schemas.d.ts.map +1 -0
  101. package/package.json +41 -30
  102. package/dist/_chunks/en-21947221.js +0 -5
  103. package/dist/_chunks/en-21947221.js.map +0 -1
  104. package/dist/_chunks/en-92157b33.mjs +0 -5
  105. package/dist/_chunks/en-92157b33.mjs.map +0 -1
  106. package/dist/server/src/__tests__/index.test.d.ts +0 -2
  107. /package/dist/admin/src/{tests/index.test.d.ts → components/ReleaseListCell.d.ts} +0 -0
@@ -1,12 +1,1760 @@
1
- const { features } = require("@strapi/strapi/dist/utils/ee");
2
- const register = () => {
3
- if (features.isEnabled("cms-content-releases")) {
4
- console.log("cms-content-releases is enabled");
1
+ import { contentTypes as contentTypes$1, async, setCreatorFields, errors, validateYupSchema, yup as yup$1 } from "@strapi/utils";
2
+ import isEqual from "lodash/isEqual";
3
+ import { difference, keys } from "lodash";
4
+ import _ from "lodash/fp";
5
+ import { scheduleJob } from "node-schedule";
6
+ import * as yup from "yup";
7
+ const RELEASE_MODEL_UID = "plugin::content-releases.release";
8
+ const RELEASE_ACTION_MODEL_UID = "plugin::content-releases.release-action";
9
+ const ACTIONS = [
10
+ {
11
+ section: "plugins",
12
+ displayName: "Read",
13
+ uid: "read",
14
+ pluginName: "content-releases"
15
+ },
16
+ {
17
+ section: "plugins",
18
+ displayName: "Create",
19
+ uid: "create",
20
+ pluginName: "content-releases"
21
+ },
22
+ {
23
+ section: "plugins",
24
+ displayName: "Edit",
25
+ uid: "update",
26
+ pluginName: "content-releases"
27
+ },
28
+ {
29
+ section: "plugins",
30
+ displayName: "Delete",
31
+ uid: "delete",
32
+ pluginName: "content-releases"
33
+ },
34
+ {
35
+ section: "plugins",
36
+ displayName: "Publish",
37
+ uid: "publish",
38
+ pluginName: "content-releases"
39
+ },
40
+ {
41
+ section: "plugins",
42
+ displayName: "Remove an entry from a release",
43
+ uid: "delete-action",
44
+ pluginName: "content-releases"
45
+ },
46
+ {
47
+ section: "plugins",
48
+ displayName: "Add an entry to a release",
49
+ uid: "create-action",
50
+ pluginName: "content-releases"
5
51
  }
52
+ ];
53
+ const ALLOWED_WEBHOOK_EVENTS = {
54
+ RELEASES_PUBLISH: "releases.publish"
6
55
  };
7
- const index = {
8
- register
56
+ const getService = (name, { strapi: strapi2 }) => {
57
+ return strapi2.plugin("content-releases").service(name);
9
58
  };
59
+ const getPopulatedEntry = async (contentTypeUid, entryId, { strapi: strapi2 }) => {
60
+ const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
61
+ const populate = await populateBuilderService(contentTypeUid).populateDeep(Infinity).build();
62
+ const entry = await strapi2.db.query(contentTypeUid).findOne({
63
+ where: { id: entryId },
64
+ populate
65
+ });
66
+ return entry;
67
+ };
68
+ const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 }) => {
69
+ try {
70
+ await strapi2.entityValidator.validateEntityCreation(
71
+ strapi2.getModel(contentTypeUid),
72
+ entry,
73
+ void 0,
74
+ // @ts-expect-error - FIXME: entity here is unnecessary
75
+ entry
76
+ );
77
+ return true;
78
+ } catch {
79
+ return false;
80
+ }
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
+ }
100
+ async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes: contentTypes2 }) {
101
+ const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes2)) ?? [];
102
+ if (deletedContentTypes.length) {
103
+ await async.map(deletedContentTypes, async (deletedContentTypeUID) => {
104
+ return strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: deletedContentTypeUID }).execute();
105
+ });
106
+ }
107
+ }
108
+ async function migrateIsValidAndStatusReleases() {
109
+ const releasesWithoutStatus = await strapi.db.query(RELEASE_MODEL_UID).findMany({
110
+ where: {
111
+ status: null,
112
+ releasedAt: null
113
+ },
114
+ populate: {
115
+ actions: {
116
+ populate: {
117
+ entry: true
118
+ }
119
+ }
120
+ }
121
+ });
122
+ async.map(releasesWithoutStatus, async (release2) => {
123
+ const actions = release2.actions;
124
+ const notValidatedActions = actions.filter((action) => action.isEntryValid === null);
125
+ for (const action of notValidatedActions) {
126
+ if (action.entry) {
127
+ const populatedEntry = await getPopulatedEntry(action.contentType, action.entry.id, {
128
+ strapi
129
+ });
130
+ if (populatedEntry) {
131
+ const isEntryValid = getEntryValidStatus(action.contentType, populatedEntry, { strapi });
132
+ await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
133
+ where: {
134
+ id: action.id
135
+ },
136
+ data: {
137
+ isEntryValid
138
+ }
139
+ });
140
+ }
141
+ }
142
+ }
143
+ return getService("release", { strapi }).updateReleaseStatus(release2.id);
144
+ });
145
+ const publishedReleases = await strapi.db.query(RELEASE_MODEL_UID).findMany({
146
+ where: {
147
+ status: null,
148
+ releasedAt: {
149
+ $notNull: true
150
+ }
151
+ }
152
+ });
153
+ async.map(publishedReleases, async (release2) => {
154
+ return strapi.db.query(RELEASE_MODEL_UID).update({
155
+ where: {
156
+ id: release2.id
157
+ },
158
+ data: {
159
+ status: "done"
160
+ }
161
+ });
162
+ });
163
+ }
164
+ async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: contentTypes2 }) {
165
+ if (oldContentTypes !== void 0 && contentTypes2 !== void 0) {
166
+ const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(
167
+ (uid) => oldContentTypes[uid]?.options?.draftAndPublish
168
+ );
169
+ const releasesAffected = /* @__PURE__ */ new Set();
170
+ async.map(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
171
+ const oldContentType = oldContentTypes[contentTypeUID];
172
+ const contentType = contentTypes2[contentTypeUID];
173
+ if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {
174
+ const actions = await strapi.db.query(RELEASE_ACTION_MODEL_UID).findMany({
175
+ where: {
176
+ contentType: contentTypeUID
177
+ },
178
+ populate: {
179
+ entry: true,
180
+ release: true
181
+ }
182
+ });
183
+ await async.map(actions, async (action) => {
184
+ if (action.entry && action.release) {
185
+ const populatedEntry = await getPopulatedEntry(contentTypeUID, action.entry.id, {
186
+ strapi
187
+ });
188
+ if (populatedEntry) {
189
+ const isEntryValid = await getEntryValidStatus(contentTypeUID, populatedEntry, {
190
+ strapi
191
+ });
192
+ releasesAffected.add(action.release.id);
193
+ await strapi.db.query(RELEASE_ACTION_MODEL_UID).update({
194
+ where: {
195
+ id: action.id
196
+ },
197
+ data: {
198
+ isEntryValid
199
+ }
200
+ });
201
+ }
202
+ }
203
+ });
204
+ }
205
+ }).then(() => {
206
+ async.map(releasesAffected, async (releaseId) => {
207
+ return getService("release", { strapi }).updateReleaseStatus(releaseId);
208
+ });
209
+ });
210
+ }
211
+ }
212
+ async function disableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
213
+ if (!oldContentTypes) {
214
+ return;
215
+ }
216
+ const i18nPlugin = strapi.plugin("i18n");
217
+ if (!i18nPlugin) {
218
+ return;
219
+ }
220
+ for (const uid in contentTypes2) {
221
+ if (!oldContentTypes[uid]) {
222
+ continue;
223
+ }
224
+ const oldContentType = oldContentTypes[uid];
225
+ const contentType = contentTypes2[uid];
226
+ const { isLocalizedContentType } = i18nPlugin.service("content-types");
227
+ if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
228
+ await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
229
+ locale: null
230
+ }).where({ contentType: uid }).execute();
231
+ }
232
+ }
233
+ }
234
+ async function enableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
235
+ if (!oldContentTypes) {
236
+ return;
237
+ }
238
+ const i18nPlugin = strapi.plugin("i18n");
239
+ if (!i18nPlugin) {
240
+ return;
241
+ }
242
+ for (const uid in contentTypes2) {
243
+ if (!oldContentTypes[uid]) {
244
+ continue;
245
+ }
246
+ const oldContentType = oldContentTypes[uid];
247
+ const contentType = contentTypes2[uid];
248
+ const { isLocalizedContentType } = i18nPlugin.service("content-types");
249
+ const { getDefaultLocale } = i18nPlugin.service("locales");
250
+ if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
251
+ const defaultLocale = await getDefaultLocale();
252
+ await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
253
+ locale: defaultLocale
254
+ }).where({ contentType: uid }).execute();
255
+ }
256
+ }
257
+ }
258
+ const register = async ({ strapi: strapi2 }) => {
259
+ if (strapi2.ee.features.isEnabled("cms-content-releases")) {
260
+ await strapi2.service("admin::permission").actionProvider.registerMany(ACTIONS);
261
+ strapi2.hook("strapi::content-types.beforeSync").register(disableContentTypeLocalized).register(deleteActionsOnDisableDraftAndPublish);
262
+ strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(enableContentTypeLocalized).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
263
+ }
264
+ if (strapi2.plugin("graphql")) {
265
+ const graphqlExtensionService = strapi2.plugin("graphql").service("extension");
266
+ graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();
267
+ graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();
268
+ }
269
+ };
270
+ const bootstrap = async ({ strapi: strapi2 }) => {
271
+ if (strapi2.ee.features.isEnabled("cms-content-releases")) {
272
+ const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes).filter(
273
+ (uid) => strapi2.contentTypes[uid]?.options?.draftAndPublish
274
+ );
275
+ strapi2.db.lifecycles.subscribe({
276
+ models: contentTypesWithDraftAndPublish,
277
+ async afterDelete(event) {
278
+ try {
279
+ const { model, result } = event;
280
+ if (model.kind === "collectionType" && model.options?.draftAndPublish) {
281
+ const { id } = result;
282
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
283
+ where: {
284
+ actions: {
285
+ target_type: model.uid,
286
+ target_id: id
287
+ }
288
+ }
289
+ });
290
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
291
+ where: {
292
+ target_type: model.uid,
293
+ target_id: id
294
+ }
295
+ });
296
+ for (const release2 of releases) {
297
+ getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
298
+ }
299
+ }
300
+ } catch (error) {
301
+ strapi2.log.error("Error while deleting release actions after entry delete", { error });
302
+ }
303
+ },
304
+ /**
305
+ * deleteMany hook doesn't return the deleted entries ids
306
+ * so we need to fetch them before deleting the entries to save the ids on our state
307
+ */
308
+ async beforeDeleteMany(event) {
309
+ const { model, params } = event;
310
+ if (model.kind === "collectionType" && model.options?.draftAndPublish) {
311
+ const { where } = params;
312
+ const entriesToDelete = await strapi2.db.query(model.uid).findMany({ select: ["id"], where });
313
+ event.state.entriesToDelete = entriesToDelete;
314
+ }
315
+ },
316
+ /**
317
+ * We delete the release actions related to deleted entries
318
+ * We make this only after deleteMany is succesfully executed to avoid errors
319
+ */
320
+ async afterDeleteMany(event) {
321
+ try {
322
+ const { model, state } = event;
323
+ const entriesToDelete = state.entriesToDelete;
324
+ if (entriesToDelete) {
325
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
326
+ where: {
327
+ actions: {
328
+ target_type: model.uid,
329
+ target_id: {
330
+ $in: entriesToDelete.map((entry) => entry.id)
331
+ }
332
+ }
333
+ }
334
+ });
335
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
336
+ where: {
337
+ target_type: model.uid,
338
+ target_id: {
339
+ $in: entriesToDelete.map((entry) => entry.id)
340
+ }
341
+ }
342
+ });
343
+ for (const release2 of releases) {
344
+ getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
345
+ }
346
+ }
347
+ } catch (error) {
348
+ strapi2.log.error("Error while deleting release actions after entry deleteMany", {
349
+ error
350
+ });
351
+ }
352
+ },
353
+ async afterUpdate(event) {
354
+ try {
355
+ const { model, result } = event;
356
+ if (model.kind === "collectionType" && model.options?.draftAndPublish) {
357
+ const isEntryValid = await getEntryValidStatus(model.uid, result, {
358
+ strapi: strapi2
359
+ });
360
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
361
+ where: {
362
+ target_type: model.uid,
363
+ target_id: result.id
364
+ },
365
+ data: {
366
+ isEntryValid
367
+ }
368
+ });
369
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
370
+ where: {
371
+ actions: {
372
+ target_type: model.uid,
373
+ target_id: result.id
374
+ }
375
+ }
376
+ });
377
+ for (const release2 of releases) {
378
+ getService("release", { strapi: strapi2 }).updateReleaseStatus(release2.id);
379
+ }
380
+ }
381
+ } catch (error) {
382
+ strapi2.log.error("Error while updating release actions after entry update", { error });
383
+ }
384
+ }
385
+ });
386
+ getService("scheduling", { strapi: strapi2 }).syncFromDatabase().catch((err) => {
387
+ strapi2.log.error(
388
+ "Error while syncing scheduled jobs from the database in the content-releases plugin. This could lead to errors in the releases scheduling."
389
+ );
390
+ throw err;
391
+ });
392
+ Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
393
+ strapi2.get("webhookStore").addAllowedEvent(key, value);
394
+ });
395
+ }
396
+ };
397
+ const destroy = async ({ strapi: strapi2 }) => {
398
+ const scheduledJobs = getService("scheduling", {
399
+ strapi: strapi2
400
+ }).getAll();
401
+ for (const [, job] of scheduledJobs) {
402
+ job.cancel();
403
+ }
404
+ };
405
+ const schema$1 = {
406
+ collectionName: "strapi_releases",
407
+ info: {
408
+ singularName: "release",
409
+ pluralName: "releases",
410
+ displayName: "Release"
411
+ },
412
+ options: {
413
+ draftAndPublish: false
414
+ },
415
+ pluginOptions: {
416
+ "content-manager": {
417
+ visible: false
418
+ },
419
+ "content-type-builder": {
420
+ visible: false
421
+ }
422
+ },
423
+ attributes: {
424
+ name: {
425
+ type: "string",
426
+ required: true
427
+ },
428
+ releasedAt: {
429
+ type: "datetime"
430
+ },
431
+ scheduledAt: {
432
+ type: "datetime"
433
+ },
434
+ timezone: {
435
+ type: "string"
436
+ },
437
+ status: {
438
+ type: "enumeration",
439
+ enum: ["ready", "blocked", "failed", "done", "empty"],
440
+ required: true
441
+ },
442
+ actions: {
443
+ type: "relation",
444
+ relation: "oneToMany",
445
+ target: RELEASE_ACTION_MODEL_UID,
446
+ mappedBy: "release"
447
+ }
448
+ }
449
+ };
450
+ const release$1 = {
451
+ schema: schema$1
452
+ };
453
+ const schema = {
454
+ collectionName: "strapi_release_actions",
455
+ info: {
456
+ singularName: "release-action",
457
+ pluralName: "release-actions",
458
+ displayName: "Release Action"
459
+ },
460
+ options: {
461
+ draftAndPublish: false
462
+ },
463
+ pluginOptions: {
464
+ "content-manager": {
465
+ visible: false
466
+ },
467
+ "content-type-builder": {
468
+ visible: false
469
+ }
470
+ },
471
+ attributes: {
472
+ type: {
473
+ type: "enumeration",
474
+ enum: ["publish", "unpublish"],
475
+ required: true
476
+ },
477
+ entry: {
478
+ type: "relation",
479
+ relation: "morphToOne",
480
+ configurable: false
481
+ },
482
+ contentType: {
483
+ type: "string",
484
+ required: true
485
+ },
486
+ locale: {
487
+ type: "string"
488
+ },
489
+ release: {
490
+ type: "relation",
491
+ relation: "manyToOne",
492
+ target: RELEASE_MODEL_UID,
493
+ inversedBy: "actions"
494
+ },
495
+ isEntryValid: {
496
+ type: "boolean"
497
+ }
498
+ }
499
+ };
500
+ const releaseAction$1 = {
501
+ schema
502
+ };
503
+ const contentTypes = {
504
+ release: release$1,
505
+ "release-action": releaseAction$1
506
+ };
507
+ const getGroupName = (queryValue) => {
508
+ switch (queryValue) {
509
+ case "contentType":
510
+ return "contentType.displayName";
511
+ case "action":
512
+ return "type";
513
+ case "locale":
514
+ return _.getOr("No locale", "locale.name");
515
+ default:
516
+ return "contentType.displayName";
517
+ }
518
+ };
519
+ const createReleaseService = ({ strapi: strapi2 }) => {
520
+ const dispatchWebhook = (event, { isPublished, release: release2, error }) => {
521
+ strapi2.eventHub.emit(event, {
522
+ isPublished,
523
+ error,
524
+ release: release2
525
+ });
526
+ };
527
+ const publishSingleTypeAction = async (uid, actionType, entryId) => {
528
+ const entityManagerService = strapi2.plugin("content-manager").service("entity-manager");
529
+ const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
530
+ const populate = await populateBuilderService(uid).populateDeep(Infinity).build();
531
+ const entry = await strapi2.entityService.findOne(uid, entryId, { populate });
532
+ try {
533
+ if (actionType === "publish") {
534
+ await entityManagerService.publish(entry, uid);
535
+ } else {
536
+ await entityManagerService.unpublish(entry, uid);
537
+ }
538
+ } catch (error) {
539
+ if (error instanceof errors.ApplicationError && (error.message === "already.published" || error.message === "already.draft"))
540
+ ;
541
+ else {
542
+ throw error;
543
+ }
544
+ }
545
+ };
546
+ const publishCollectionTypeAction = async (uid, entriesToPublishIds, entriestoUnpublishIds) => {
547
+ const entityManagerService = strapi2.plugin("content-manager").service("entity-manager");
548
+ const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
549
+ const populate = await populateBuilderService(uid).populateDeep(Infinity).build();
550
+ const entriesToPublish = await strapi2.entityService.findMany(uid, {
551
+ filters: {
552
+ id: {
553
+ $in: entriesToPublishIds
554
+ }
555
+ },
556
+ populate
557
+ });
558
+ const entriesToUnpublish = await strapi2.entityService.findMany(uid, {
559
+ filters: {
560
+ id: {
561
+ $in: entriestoUnpublishIds
562
+ }
563
+ },
564
+ populate
565
+ });
566
+ if (entriesToPublish.length > 0) {
567
+ await entityManagerService.publishMany(entriesToPublish, uid);
568
+ }
569
+ if (entriesToUnpublish.length > 0) {
570
+ await entityManagerService.unpublishMany(entriesToUnpublish, uid);
571
+ }
572
+ };
573
+ const getFormattedActions = async (releaseId) => {
574
+ const actions = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).findMany({
575
+ where: {
576
+ release: {
577
+ id: releaseId
578
+ }
579
+ },
580
+ populate: {
581
+ entry: {
582
+ fields: ["id"]
583
+ }
584
+ }
585
+ });
586
+ if (actions.length === 0) {
587
+ throw new errors.ValidationError("No entries to publish");
588
+ }
589
+ const collectionTypeActions = {};
590
+ const singleTypeActions = [];
591
+ for (const action of actions) {
592
+ const contentTypeUid = action.contentType;
593
+ if (strapi2.contentTypes[contentTypeUid].kind === "collectionType") {
594
+ if (!collectionTypeActions[contentTypeUid]) {
595
+ collectionTypeActions[contentTypeUid] = {
596
+ entriesToPublishIds: [],
597
+ entriesToUnpublishIds: []
598
+ };
599
+ }
600
+ if (action.type === "publish") {
601
+ collectionTypeActions[contentTypeUid].entriesToPublishIds.push(action.entry.id);
602
+ } else {
603
+ collectionTypeActions[contentTypeUid].entriesToUnpublishIds.push(action.entry.id);
604
+ }
605
+ } else {
606
+ singleTypeActions.push({
607
+ uid: contentTypeUid,
608
+ action: action.type,
609
+ id: action.entry.id
610
+ });
611
+ }
612
+ }
613
+ return { collectionTypeActions, singleTypeActions };
614
+ };
615
+ return {
616
+ async create(releaseData, { user }) {
617
+ const releaseWithCreatorFields = await setCreatorFields({ user })(releaseData);
618
+ const {
619
+ validatePendingReleasesLimit,
620
+ validateUniqueNameForPendingRelease,
621
+ validateScheduledAtIsLaterThanNow
622
+ } = getService("release-validation", { strapi: strapi2 });
623
+ await Promise.all([
624
+ validatePendingReleasesLimit(),
625
+ validateUniqueNameForPendingRelease(releaseWithCreatorFields.name),
626
+ validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
627
+ ]);
628
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).create({
629
+ data: {
630
+ ...releaseWithCreatorFields,
631
+ status: "empty"
632
+ }
633
+ });
634
+ if (releaseWithCreatorFields.scheduledAt) {
635
+ const schedulingService = getService("scheduling", { strapi: strapi2 });
636
+ await schedulingService.set(release2.id, release2.scheduledAt);
637
+ }
638
+ strapi2.telemetry.send("didCreateContentRelease");
639
+ return release2;
640
+ },
641
+ async findOne(id, query = {}) {
642
+ const dbQuery = strapi2.get("query-params").transform(RELEASE_MODEL_UID, query);
643
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
644
+ ...dbQuery,
645
+ where: { id }
646
+ });
647
+ return release2;
648
+ },
649
+ findPage(query) {
650
+ const dbQuery = strapi2.get("query-params").transform(RELEASE_MODEL_UID, query ?? {});
651
+ return strapi2.db.query(RELEASE_MODEL_UID).findPage({
652
+ ...dbQuery,
653
+ populate: {
654
+ actions: {
655
+ count: true
656
+ }
657
+ }
658
+ });
659
+ },
660
+ async findManyWithContentTypeEntryAttached(contentTypeUid, entriesIds) {
661
+ let entries = entriesIds;
662
+ if (!Array.isArray(entriesIds)) {
663
+ entries = [entriesIds];
664
+ }
665
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
666
+ where: {
667
+ actions: {
668
+ target_type: contentTypeUid,
669
+ target_id: {
670
+ $in: entries
671
+ }
672
+ },
673
+ releasedAt: {
674
+ $null: true
675
+ }
676
+ },
677
+ populate: {
678
+ // Filter the action to get only the content type entry
679
+ actions: {
680
+ where: {
681
+ target_type: contentTypeUid,
682
+ target_id: {
683
+ $in: entries
684
+ }
685
+ },
686
+ populate: {
687
+ entry: {
688
+ select: ["id"]
689
+ }
690
+ }
691
+ }
692
+ }
693
+ });
694
+ return releases.map((release2) => {
695
+ if (release2.actions?.length) {
696
+ const actionsForEntry = release2.actions;
697
+ delete release2.actions;
698
+ return {
699
+ ...release2,
700
+ actions: actionsForEntry
701
+ };
702
+ }
703
+ return release2;
704
+ });
705
+ },
706
+ async findManyWithoutContentTypeEntryAttached(contentTypeUid, entryId) {
707
+ const releasesRelated = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
708
+ where: {
709
+ releasedAt: {
710
+ $null: true
711
+ },
712
+ actions: {
713
+ target_type: contentTypeUid,
714
+ target_id: entryId
715
+ }
716
+ }
717
+ });
718
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
719
+ where: {
720
+ $or: [
721
+ {
722
+ id: {
723
+ $notIn: releasesRelated.map((release2) => release2.id)
724
+ }
725
+ },
726
+ {
727
+ actions: null
728
+ }
729
+ ],
730
+ releasedAt: {
731
+ $null: true
732
+ }
733
+ }
734
+ });
735
+ return releases.map((release2) => {
736
+ if (release2.actions?.length) {
737
+ const [actionForEntry] = release2.actions;
738
+ delete release2.actions;
739
+ return {
740
+ ...release2,
741
+ action: actionForEntry
742
+ };
743
+ }
744
+ return release2;
745
+ });
746
+ },
747
+ async update(id, releaseData, { user }) {
748
+ const releaseWithCreatorFields = await setCreatorFields({ user, isEdition: true })(
749
+ releaseData
750
+ );
751
+ const { validateUniqueNameForPendingRelease, validateScheduledAtIsLaterThanNow } = getService(
752
+ "release-validation",
753
+ { strapi: strapi2 }
754
+ );
755
+ await Promise.all([
756
+ validateUniqueNameForPendingRelease(releaseWithCreatorFields.name, id),
757
+ validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
758
+ ]);
759
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id } });
760
+ if (!release2) {
761
+ throw new errors.NotFoundError(`No release found for id ${id}`);
762
+ }
763
+ if (release2.releasedAt) {
764
+ throw new errors.ValidationError("Release already published");
765
+ }
766
+ const updatedRelease = await strapi2.db.query(RELEASE_MODEL_UID).update({
767
+ where: { id },
768
+ data: releaseWithCreatorFields
769
+ });
770
+ const schedulingService = getService("scheduling", { strapi: strapi2 });
771
+ if (releaseData.scheduledAt) {
772
+ await schedulingService.set(id, releaseData.scheduledAt);
773
+ } else if (release2.scheduledAt) {
774
+ schedulingService.cancel(id);
775
+ }
776
+ this.updateReleaseStatus(id);
777
+ strapi2.telemetry.send("didUpdateContentRelease");
778
+ return updatedRelease;
779
+ },
780
+ async createAction(releaseId, action) {
781
+ const { validateEntryContentType, validateUniqueEntry } = getService("release-validation", {
782
+ strapi: strapi2
783
+ });
784
+ await Promise.all([
785
+ validateEntryContentType(action.entry.contentType),
786
+ validateUniqueEntry(releaseId, action)
787
+ ]);
788
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
789
+ if (!release2) {
790
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
791
+ }
792
+ if (release2.releasedAt) {
793
+ throw new errors.ValidationError("Release already published");
794
+ }
795
+ const { entry, type } = action;
796
+ const populatedEntry = await getPopulatedEntry(entry.contentType, entry.id, { strapi: strapi2 });
797
+ const isEntryValid = await getEntryValidStatus(entry.contentType, populatedEntry, { strapi: strapi2 });
798
+ const releaseAction2 = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).create({
799
+ data: {
800
+ type,
801
+ contentType: entry.contentType,
802
+ locale: entry.locale,
803
+ isEntryValid,
804
+ entry: {
805
+ id: entry.id,
806
+ __type: entry.contentType,
807
+ __pivot: { field: "entry" }
808
+ },
809
+ release: releaseId
810
+ },
811
+ populate: { release: { select: ["id"] }, entry: { select: ["id"] } }
812
+ });
813
+ this.updateReleaseStatus(releaseId);
814
+ return releaseAction2;
815
+ },
816
+ async findActions(releaseId, query) {
817
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
818
+ where: { id: releaseId },
819
+ select: ["id"]
820
+ });
821
+ if (!release2) {
822
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
823
+ }
824
+ const dbQuery = strapi2.get("query-params").transform(RELEASE_ACTION_MODEL_UID, query ?? {});
825
+ return strapi2.db.query(RELEASE_ACTION_MODEL_UID).findPage({
826
+ ...dbQuery,
827
+ populate: {
828
+ entry: {
829
+ populate: "*"
830
+ }
831
+ },
832
+ where: {
833
+ release: releaseId
834
+ }
835
+ });
836
+ },
837
+ async countActions(query) {
838
+ const dbQuery = strapi2.get("query-params").transform(RELEASE_ACTION_MODEL_UID, query ?? {});
839
+ return strapi2.db.query(RELEASE_ACTION_MODEL_UID).count(dbQuery);
840
+ },
841
+ async groupActions(actions, groupBy) {
842
+ const contentTypeUids = actions.reduce((acc, action) => {
843
+ if (!acc.includes(action.contentType)) {
844
+ acc.push(action.contentType);
845
+ }
846
+ return acc;
847
+ }, []);
848
+ const allReleaseContentTypesDictionary = await this.getContentTypesDataForActions(contentTypeUids);
849
+ const allLocalesDictionary = await this.getLocalesDataForActions();
850
+ const formattedData = actions.map((action) => {
851
+ const { mainField, displayName } = allReleaseContentTypesDictionary[action.contentType];
852
+ return {
853
+ ...action,
854
+ locale: action.locale ? allLocalesDictionary[action.locale] : null,
855
+ contentType: {
856
+ displayName,
857
+ mainFieldValue: action.entry[mainField],
858
+ uid: action.contentType
859
+ }
860
+ };
861
+ });
862
+ const groupName = getGroupName(groupBy);
863
+ return _.groupBy(groupName)(formattedData);
864
+ },
865
+ async getLocalesDataForActions() {
866
+ if (!strapi2.plugin("i18n")) {
867
+ return {};
868
+ }
869
+ const allLocales = await strapi2.plugin("i18n").service("locales").find() || [];
870
+ return allLocales.reduce((acc, locale) => {
871
+ acc[locale.code] = { name: locale.name, code: locale.code };
872
+ return acc;
873
+ }, {});
874
+ },
875
+ async getContentTypesDataForActions(contentTypesUids) {
876
+ const contentManagerContentTypeService = strapi2.plugin("content-manager").service("content-types");
877
+ const contentTypesData = {};
878
+ for (const contentTypeUid of contentTypesUids) {
879
+ const contentTypeConfig = await contentManagerContentTypeService.findConfiguration({
880
+ uid: contentTypeUid
881
+ });
882
+ contentTypesData[contentTypeUid] = {
883
+ mainField: contentTypeConfig.settings.mainField,
884
+ displayName: strapi2.getModel(contentTypeUid).info.displayName
885
+ };
886
+ }
887
+ return contentTypesData;
888
+ },
889
+ getContentTypeModelsFromActions(actions) {
890
+ const contentTypeUids = actions.reduce((acc, action) => {
891
+ if (!acc.includes(action.contentType)) {
892
+ acc.push(action.contentType);
893
+ }
894
+ return acc;
895
+ }, []);
896
+ const contentTypeModelsMap = contentTypeUids.reduce(
897
+ (acc, contentTypeUid) => {
898
+ acc[contentTypeUid] = strapi2.getModel(contentTypeUid);
899
+ return acc;
900
+ },
901
+ {}
902
+ );
903
+ return contentTypeModelsMap;
904
+ },
905
+ async getAllComponents() {
906
+ const contentManagerComponentsService = strapi2.plugin("content-manager").service("components");
907
+ const components = await contentManagerComponentsService.findAllComponents();
908
+ const componentsMap = components.reduce(
909
+ (acc, component) => {
910
+ acc[component.uid] = component;
911
+ return acc;
912
+ },
913
+ {}
914
+ );
915
+ return componentsMap;
916
+ },
917
+ async delete(releaseId) {
918
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
919
+ where: { id: releaseId },
920
+ populate: {
921
+ actions: {
922
+ select: ["id"]
923
+ }
924
+ }
925
+ });
926
+ if (!release2) {
927
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
928
+ }
929
+ if (release2.releasedAt) {
930
+ throw new errors.ValidationError("Release already published");
931
+ }
932
+ await strapi2.db.transaction(async () => {
933
+ await strapi2.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
934
+ where: {
935
+ id: {
936
+ $in: release2.actions.map((action) => action.id)
937
+ }
938
+ }
939
+ });
940
+ await strapi2.db.query(RELEASE_MODEL_UID).delete({
941
+ where: {
942
+ id: releaseId
943
+ }
944
+ });
945
+ });
946
+ if (release2.scheduledAt) {
947
+ const schedulingService = getService("scheduling", { strapi: strapi2 });
948
+ await schedulingService.cancel(release2.id);
949
+ }
950
+ strapi2.telemetry.send("didDeleteContentRelease");
951
+ return release2;
952
+ },
953
+ async publish(releaseId) {
954
+ const {
955
+ release: release2,
956
+ error
957
+ } = await strapi2.db.transaction(async ({ trx }) => {
958
+ const lockedRelease = await strapi2.db?.queryBuilder(RELEASE_MODEL_UID).where({ id: releaseId }).select(["id", "name", "releasedAt", "status"]).first().transacting(trx).forUpdate().execute();
959
+ if (!lockedRelease) {
960
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
961
+ }
962
+ if (lockedRelease.releasedAt) {
963
+ throw new errors.ValidationError("Release already published");
964
+ }
965
+ if (lockedRelease.status === "failed") {
966
+ throw new errors.ValidationError("Release failed to publish");
967
+ }
968
+ try {
969
+ strapi2.log.info(`[Content Releases] Starting to publish release ${lockedRelease.name}`);
970
+ const { collectionTypeActions, singleTypeActions } = await getFormattedActions(releaseId);
971
+ await strapi2.db.transaction(async () => {
972
+ for (const { uid, action, id } of singleTypeActions) {
973
+ await publishSingleTypeAction(uid, action, id);
974
+ }
975
+ for (const contentTypeUid of Object.keys(collectionTypeActions)) {
976
+ const uid = contentTypeUid;
977
+ await publishCollectionTypeAction(
978
+ uid,
979
+ collectionTypeActions[uid].entriesToPublishIds,
980
+ collectionTypeActions[uid].entriesToUnpublishIds
981
+ );
982
+ }
983
+ });
984
+ const release22 = await strapi2.db.query(RELEASE_MODEL_UID).update({
985
+ where: {
986
+ id: releaseId
987
+ },
988
+ data: {
989
+ status: "done",
990
+ releasedAt: /* @__PURE__ */ new Date()
991
+ }
992
+ });
993
+ dispatchWebhook(ALLOWED_WEBHOOK_EVENTS.RELEASES_PUBLISH, {
994
+ isPublished: true,
995
+ release: release22
996
+ });
997
+ strapi2.telemetry.send("didPublishContentRelease");
998
+ return { release: release22, error: null };
999
+ } catch (error2) {
1000
+ dispatchWebhook(ALLOWED_WEBHOOK_EVENTS.RELEASES_PUBLISH, {
1001
+ isPublished: false,
1002
+ error: error2
1003
+ });
1004
+ await strapi2.db?.queryBuilder(RELEASE_MODEL_UID).where({ id: releaseId }).update({
1005
+ status: "failed"
1006
+ }).transacting(trx).execute();
1007
+ return {
1008
+ release: null,
1009
+ error: error2
1010
+ };
1011
+ }
1012
+ });
1013
+ if (error instanceof Error) {
1014
+ throw error;
1015
+ }
1016
+ return release2;
1017
+ },
1018
+ async updateAction(actionId, releaseId, update) {
1019
+ const updatedAction = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).update({
1020
+ where: {
1021
+ id: actionId,
1022
+ release: {
1023
+ id: releaseId,
1024
+ releasedAt: {
1025
+ $null: true
1026
+ }
1027
+ }
1028
+ },
1029
+ data: update
1030
+ });
1031
+ if (!updatedAction) {
1032
+ throw new errors.NotFoundError(
1033
+ `Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
1034
+ );
1035
+ }
1036
+ return updatedAction;
1037
+ },
1038
+ async deleteAction(actionId, releaseId) {
1039
+ const deletedAction = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).delete({
1040
+ where: {
1041
+ id: actionId,
1042
+ release: {
1043
+ id: releaseId,
1044
+ releasedAt: {
1045
+ $null: true
1046
+ }
1047
+ }
1048
+ }
1049
+ });
1050
+ if (!deletedAction) {
1051
+ throw new errors.NotFoundError(
1052
+ `Action with id ${actionId} not found in release with id ${releaseId} or it is already published`
1053
+ );
1054
+ }
1055
+ this.updateReleaseStatus(releaseId);
1056
+ return deletedAction;
1057
+ },
1058
+ async updateReleaseStatus(releaseId) {
1059
+ const [totalActions, invalidActions] = await Promise.all([
1060
+ this.countActions({
1061
+ filters: {
1062
+ release: releaseId
1063
+ }
1064
+ }),
1065
+ this.countActions({
1066
+ filters: {
1067
+ release: releaseId,
1068
+ isEntryValid: false
1069
+ }
1070
+ })
1071
+ ]);
1072
+ if (totalActions > 0) {
1073
+ if (invalidActions > 0) {
1074
+ return strapi2.db.query(RELEASE_MODEL_UID).update({
1075
+ where: {
1076
+ id: releaseId
1077
+ },
1078
+ data: {
1079
+ status: "blocked"
1080
+ }
1081
+ });
1082
+ }
1083
+ return strapi2.db.query(RELEASE_MODEL_UID).update({
1084
+ where: {
1085
+ id: releaseId
1086
+ },
1087
+ data: {
1088
+ status: "ready"
1089
+ }
1090
+ });
1091
+ }
1092
+ return strapi2.db.query(RELEASE_MODEL_UID).update({
1093
+ where: {
1094
+ id: releaseId
1095
+ },
1096
+ data: {
1097
+ status: "empty"
1098
+ }
1099
+ });
1100
+ }
1101
+ };
1102
+ };
1103
+ class AlreadyOnReleaseError extends errors.ApplicationError {
1104
+ constructor(message) {
1105
+ super(message);
1106
+ this.name = "AlreadyOnReleaseError";
1107
+ }
1108
+ }
1109
+ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1110
+ async validateUniqueEntry(releaseId, releaseActionArgs) {
1111
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
1112
+ where: {
1113
+ id: releaseId
1114
+ },
1115
+ populate: { actions: { populate: { entry: { select: ["id"] } } } }
1116
+ });
1117
+ if (!release2) {
1118
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
1119
+ }
1120
+ const isEntryInRelease = release2.actions.some(
1121
+ (action) => Number(action.entry.id) === Number(releaseActionArgs.entry.id) && action.contentType === releaseActionArgs.entry.contentType
1122
+ );
1123
+ if (isEntryInRelease) {
1124
+ throw new AlreadyOnReleaseError(
1125
+ `Entry with id ${releaseActionArgs.entry.id} and contentType ${releaseActionArgs.entry.contentType} already exists in release with id ${releaseId}`
1126
+ );
1127
+ }
1128
+ },
1129
+ validateEntryContentType(contentTypeUid) {
1130
+ const contentType = strapi2.contentType(contentTypeUid);
1131
+ if (!contentType) {
1132
+ throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);
1133
+ }
1134
+ if (!contentType.options?.draftAndPublish) {
1135
+ throw new errors.ValidationError(
1136
+ `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`
1137
+ );
1138
+ }
1139
+ },
1140
+ async validatePendingReleasesLimit() {
1141
+ const featureCfg = strapi2.ee.features.get("cms-content-releases");
1142
+ const maximumPendingReleases = typeof featureCfg === "object" && featureCfg?.options?.maximumReleases || 3;
1143
+ const [, pendingReleasesCount] = await strapi2.db.query(RELEASE_MODEL_UID).findWithCount({
1144
+ filters: {
1145
+ releasedAt: {
1146
+ $null: true
1147
+ }
1148
+ }
1149
+ });
1150
+ if (pendingReleasesCount >= maximumPendingReleases) {
1151
+ throw new errors.ValidationError("You have reached the maximum number of pending releases");
1152
+ }
1153
+ },
1154
+ async validateUniqueNameForPendingRelease(name, id) {
1155
+ const pendingReleases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
1156
+ where: {
1157
+ releasedAt: {
1158
+ $null: true
1159
+ },
1160
+ name,
1161
+ ...id && { id: { $ne: id } }
1162
+ }
1163
+ });
1164
+ const isNameUnique = pendingReleases.length === 0;
1165
+ if (!isNameUnique) {
1166
+ throw new errors.ValidationError(`Release with name ${name} already exists`);
1167
+ }
1168
+ },
1169
+ async validateScheduledAtIsLaterThanNow(scheduledAt) {
1170
+ if (scheduledAt && new Date(scheduledAt) <= /* @__PURE__ */ new Date()) {
1171
+ throw new errors.ValidationError("Scheduled at must be later than now");
1172
+ }
1173
+ }
1174
+ });
1175
+ const createSchedulingService = ({ strapi: strapi2 }) => {
1176
+ const scheduledJobs = /* @__PURE__ */ new Map();
1177
+ return {
1178
+ async set(releaseId, scheduleDate) {
1179
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId, releasedAt: null } });
1180
+ if (!release2) {
1181
+ throw new errors.NotFoundError(`No release found for id ${releaseId}`);
1182
+ }
1183
+ const job = scheduleJob(scheduleDate, async () => {
1184
+ try {
1185
+ await getService("release", { strapi: strapi2 }).publish(releaseId);
1186
+ } catch (error) {
1187
+ }
1188
+ this.cancel(releaseId);
1189
+ });
1190
+ if (scheduledJobs.has(releaseId)) {
1191
+ this.cancel(releaseId);
1192
+ }
1193
+ scheduledJobs.set(releaseId, job);
1194
+ return scheduledJobs;
1195
+ },
1196
+ cancel(releaseId) {
1197
+ if (scheduledJobs.has(releaseId)) {
1198
+ scheduledJobs.get(releaseId).cancel();
1199
+ scheduledJobs.delete(releaseId);
1200
+ }
1201
+ return scheduledJobs;
1202
+ },
1203
+ getAll() {
1204
+ return scheduledJobs;
1205
+ },
1206
+ /**
1207
+ * On bootstrap, we can use this function to make sure to sync the scheduled jobs from the database that are not yet released
1208
+ * This is useful in case the server was restarted and the scheduled jobs were lost
1209
+ * This also could be used to sync different Strapi instances in case of a cluster
1210
+ */
1211
+ async syncFromDatabase() {
1212
+ const releases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
1213
+ where: {
1214
+ scheduledAt: {
1215
+ $gte: /* @__PURE__ */ new Date()
1216
+ },
1217
+ releasedAt: null
1218
+ }
1219
+ });
1220
+ for (const release2 of releases) {
1221
+ this.set(release2.id, release2.scheduledAt);
1222
+ }
1223
+ return scheduledJobs;
1224
+ }
1225
+ };
1226
+ };
1227
+ const services = {
1228
+ release: createReleaseService,
1229
+ "release-validation": createReleaseValidationService,
1230
+ scheduling: createSchedulingService
1231
+ };
1232
+ const RELEASE_SCHEMA = yup.object().shape({
1233
+ name: yup.string().trim().required(),
1234
+ scheduledAt: yup.string().nullable(),
1235
+ isScheduled: yup.boolean().optional(),
1236
+ time: yup.string().when("isScheduled", {
1237
+ is: true,
1238
+ then: yup.string().trim().required(),
1239
+ otherwise: yup.string().nullable()
1240
+ }),
1241
+ timezone: yup.string().when("isScheduled", {
1242
+ is: true,
1243
+ then: yup.string().required().nullable(),
1244
+ otherwise: yup.string().nullable()
1245
+ }),
1246
+ date: yup.string().when("isScheduled", {
1247
+ is: true,
1248
+ then: yup.string().required().nullable(),
1249
+ otherwise: yup.string().nullable()
1250
+ })
1251
+ }).required().noUnknown();
1252
+ const validateRelease = validateYupSchema(RELEASE_SCHEMA);
1253
+ const releaseController = {
1254
+ async findMany(ctx) {
1255
+ const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
1256
+ ability: ctx.state.userAbility,
1257
+ model: RELEASE_MODEL_UID
1258
+ });
1259
+ await permissionsManager.validateQuery(ctx.query);
1260
+ const releaseService = getService("release", { strapi });
1261
+ const isFindManyForContentTypeEntry = Boolean(ctx.query?.contentTypeUid && ctx.query?.entryId);
1262
+ if (isFindManyForContentTypeEntry) {
1263
+ const query = await permissionsManager.sanitizeQuery(ctx.query);
1264
+ const contentTypeUid = query.contentTypeUid;
1265
+ const entryId = query.entryId;
1266
+ const hasEntryAttached = typeof query.hasEntryAttached === "string" ? JSON.parse(query.hasEntryAttached) : false;
1267
+ const data = hasEntryAttached ? await releaseService.findManyWithContentTypeEntryAttached(contentTypeUid, entryId) : await releaseService.findManyWithoutContentTypeEntryAttached(contentTypeUid, entryId);
1268
+ ctx.body = { data };
1269
+ } else {
1270
+ const query = await permissionsManager.sanitizeQuery(ctx.query);
1271
+ const { results, pagination } = await releaseService.findPage(query);
1272
+ const data = results.map((release2) => {
1273
+ const { actions, ...releaseData } = release2;
1274
+ return {
1275
+ ...releaseData,
1276
+ actions: {
1277
+ meta: {
1278
+ count: actions.count
1279
+ }
1280
+ }
1281
+ };
1282
+ });
1283
+ const pendingReleasesCount = await strapi.db.query(RELEASE_MODEL_UID).count({
1284
+ where: {
1285
+ releasedAt: null
1286
+ }
1287
+ });
1288
+ ctx.body = { data, meta: { pagination, pendingReleasesCount } };
1289
+ }
1290
+ },
1291
+ async findOne(ctx) {
1292
+ const id = ctx.params.id;
1293
+ const releaseService = getService("release", { strapi });
1294
+ const release2 = await releaseService.findOne(id, { populate: ["createdBy"] });
1295
+ if (!release2) {
1296
+ throw new errors.NotFoundError(`Release not found for id: ${id}`);
1297
+ }
1298
+ const count = await releaseService.countActions({
1299
+ filters: {
1300
+ release: id
1301
+ }
1302
+ });
1303
+ const sanitizedRelease = {
1304
+ ...release2,
1305
+ createdBy: release2.createdBy ? strapi.service("admin::user").sanitizeUser(release2.createdBy) : null
1306
+ };
1307
+ const data = {
1308
+ ...sanitizedRelease,
1309
+ actions: {
1310
+ meta: {
1311
+ count
1312
+ }
1313
+ }
1314
+ };
1315
+ ctx.body = { data };
1316
+ },
1317
+ async mapEntriesToReleases(ctx) {
1318
+ const { contentTypeUid, entriesIds } = ctx.query;
1319
+ if (!contentTypeUid || !entriesIds) {
1320
+ throw new errors.ValidationError("Missing required query parameters");
1321
+ }
1322
+ const releaseService = getService("release", { strapi });
1323
+ const releasesWithActions = await releaseService.findManyWithContentTypeEntryAttached(
1324
+ contentTypeUid,
1325
+ entriesIds
1326
+ );
1327
+ const mappedEntriesInReleases = releasesWithActions.reduce(
1328
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1329
+ (acc, release2) => {
1330
+ release2.actions.forEach((action) => {
1331
+ if (!acc[action.entry.id]) {
1332
+ acc[action.entry.id] = [{ id: release2.id, name: release2.name }];
1333
+ } else {
1334
+ acc[action.entry.id].push({ id: release2.id, name: release2.name });
1335
+ }
1336
+ });
1337
+ return acc;
1338
+ },
1339
+ // TODO: Fix for v5 removed mappedEntriedToRelease
1340
+ {}
1341
+ );
1342
+ ctx.body = {
1343
+ data: mappedEntriesInReleases
1344
+ };
1345
+ },
1346
+ async create(ctx) {
1347
+ const user = ctx.state.user;
1348
+ const releaseArgs = ctx.request.body;
1349
+ await validateRelease(releaseArgs);
1350
+ const releaseService = getService("release", { strapi });
1351
+ const release2 = await releaseService.create(releaseArgs, { user });
1352
+ const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
1353
+ ability: ctx.state.userAbility,
1354
+ model: RELEASE_MODEL_UID
1355
+ });
1356
+ ctx.created({
1357
+ data: await permissionsManager.sanitizeOutput(release2)
1358
+ });
1359
+ },
1360
+ async update(ctx) {
1361
+ const user = ctx.state.user;
1362
+ const releaseArgs = ctx.request.body;
1363
+ const id = ctx.params.id;
1364
+ await validateRelease(releaseArgs);
1365
+ const releaseService = getService("release", { strapi });
1366
+ const release2 = await releaseService.update(id, releaseArgs, { user });
1367
+ const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
1368
+ ability: ctx.state.userAbility,
1369
+ model: RELEASE_MODEL_UID
1370
+ });
1371
+ ctx.body = {
1372
+ data: await permissionsManager.sanitizeOutput(release2)
1373
+ };
1374
+ },
1375
+ async delete(ctx) {
1376
+ const id = ctx.params.id;
1377
+ const releaseService = getService("release", { strapi });
1378
+ const release2 = await releaseService.delete(id);
1379
+ ctx.body = {
1380
+ data: release2
1381
+ };
1382
+ },
1383
+ async publish(ctx) {
1384
+ const user = ctx.state.user;
1385
+ const id = ctx.params.id;
1386
+ const releaseService = getService("release", { strapi });
1387
+ const release2 = await releaseService.publish(id, { user });
1388
+ const [countPublishActions, countUnpublishActions] = await Promise.all([
1389
+ releaseService.countActions({
1390
+ filters: {
1391
+ release: id,
1392
+ type: "publish"
1393
+ }
1394
+ }),
1395
+ releaseService.countActions({
1396
+ filters: {
1397
+ release: id,
1398
+ type: "unpublish"
1399
+ }
1400
+ })
1401
+ ]);
1402
+ ctx.body = {
1403
+ data: release2,
1404
+ meta: {
1405
+ totalEntries: countPublishActions + countUnpublishActions,
1406
+ totalPublishedEntries: countPublishActions,
1407
+ totalUnpublishedEntries: countUnpublishActions
1408
+ }
1409
+ };
1410
+ }
1411
+ };
1412
+ const RELEASE_ACTION_SCHEMA = yup$1.object().shape({
1413
+ entry: yup$1.object().shape({
1414
+ id: yup$1.strapiID().required(),
1415
+ contentType: yup$1.string().required()
1416
+ }).required(),
1417
+ type: yup$1.string().oneOf(["publish", "unpublish"]).required()
1418
+ });
1419
+ const RELEASE_ACTION_UPDATE_SCHEMA = yup$1.object().shape({
1420
+ type: yup$1.string().oneOf(["publish", "unpublish"]).required()
1421
+ });
1422
+ const validateReleaseAction = validateYupSchema(RELEASE_ACTION_SCHEMA);
1423
+ const validateReleaseActionUpdateSchema = validateYupSchema(RELEASE_ACTION_UPDATE_SCHEMA);
1424
+ const releaseActionController = {
1425
+ async create(ctx) {
1426
+ const releaseId = ctx.params.releaseId;
1427
+ const releaseActionArgs = ctx.request.body;
1428
+ await validateReleaseAction(releaseActionArgs);
1429
+ const releaseService = getService("release", { strapi });
1430
+ const releaseAction2 = await releaseService.createAction(releaseId, releaseActionArgs);
1431
+ ctx.created({
1432
+ data: releaseAction2
1433
+ });
1434
+ },
1435
+ async createMany(ctx) {
1436
+ const releaseId = ctx.params.releaseId;
1437
+ const releaseActionsArgs = ctx.request.body;
1438
+ await Promise.all(
1439
+ releaseActionsArgs.map((releaseActionArgs) => validateReleaseAction(releaseActionArgs))
1440
+ );
1441
+ const releaseService = getService("release", { strapi });
1442
+ const releaseActions = await strapi.db.transaction(async () => {
1443
+ const releaseActions2 = await Promise.all(
1444
+ releaseActionsArgs.map(async (releaseActionArgs) => {
1445
+ try {
1446
+ const action = await releaseService.createAction(releaseId, releaseActionArgs);
1447
+ return action;
1448
+ } catch (error) {
1449
+ if (error instanceof AlreadyOnReleaseError) {
1450
+ return null;
1451
+ }
1452
+ throw error;
1453
+ }
1454
+ })
1455
+ );
1456
+ return releaseActions2;
1457
+ });
1458
+ const newReleaseActions = releaseActions.filter((action) => action !== null);
1459
+ ctx.created({
1460
+ data: newReleaseActions,
1461
+ meta: {
1462
+ entriesAlreadyInRelease: releaseActions.length - newReleaseActions.length,
1463
+ totalEntries: releaseActions.length
1464
+ }
1465
+ });
1466
+ },
1467
+ async findMany(ctx) {
1468
+ const releaseId = ctx.params.releaseId;
1469
+ const permissionsManager = strapi.service("admin::permission").createPermissionsManager({
1470
+ ability: ctx.state.userAbility,
1471
+ model: RELEASE_ACTION_MODEL_UID
1472
+ });
1473
+ const query = await permissionsManager.sanitizeQuery(ctx.query);
1474
+ const releaseService = getService("release", { strapi });
1475
+ const { results, pagination } = await releaseService.findActions(releaseId, {
1476
+ sort: query.groupBy === "action" ? "type" : query.groupBy,
1477
+ ...query
1478
+ });
1479
+ const contentTypeOutputSanitizers = results.reduce((acc, action) => {
1480
+ if (acc[action.contentType]) {
1481
+ return acc;
1482
+ }
1483
+ const contentTypePermissionsManager = strapi.service("admin::permission").createPermissionsManager({
1484
+ ability: ctx.state.userAbility,
1485
+ model: action.contentType
1486
+ });
1487
+ acc[action.contentType] = contentTypePermissionsManager.sanitizeOutput;
1488
+ return acc;
1489
+ }, {});
1490
+ const sanitizedResults = await async.map(results, async (action) => ({
1491
+ ...action,
1492
+ entry: await contentTypeOutputSanitizers[action.contentType](action.entry)
1493
+ }));
1494
+ const groupedData = await releaseService.groupActions(sanitizedResults, query.groupBy);
1495
+ const contentTypes2 = releaseService.getContentTypeModelsFromActions(results);
1496
+ const components = await releaseService.getAllComponents();
1497
+ ctx.body = {
1498
+ data: groupedData,
1499
+ meta: {
1500
+ pagination,
1501
+ contentTypes: contentTypes2,
1502
+ components
1503
+ }
1504
+ };
1505
+ },
1506
+ async update(ctx) {
1507
+ const actionId = ctx.params.actionId;
1508
+ const releaseId = ctx.params.releaseId;
1509
+ const releaseActionUpdateArgs = ctx.request.body;
1510
+ await validateReleaseActionUpdateSchema(releaseActionUpdateArgs);
1511
+ const releaseService = getService("release", { strapi });
1512
+ const updatedAction = await releaseService.updateAction(
1513
+ actionId,
1514
+ releaseId,
1515
+ releaseActionUpdateArgs
1516
+ );
1517
+ ctx.body = {
1518
+ data: updatedAction
1519
+ };
1520
+ },
1521
+ async delete(ctx) {
1522
+ const actionId = ctx.params.actionId;
1523
+ const releaseId = ctx.params.releaseId;
1524
+ const releaseService = getService("release", { strapi });
1525
+ const deletedReleaseAction = await releaseService.deleteAction(actionId, releaseId);
1526
+ ctx.body = {
1527
+ data: deletedReleaseAction
1528
+ };
1529
+ }
1530
+ };
1531
+ const controllers = { release: releaseController, "release-action": releaseActionController };
1532
+ const release = {
1533
+ type: "admin",
1534
+ routes: [
1535
+ {
1536
+ method: "GET",
1537
+ path: "/mapEntriesToReleases",
1538
+ handler: "release.mapEntriesToReleases",
1539
+ config: {
1540
+ policies: [
1541
+ "admin::isAuthenticatedAdmin",
1542
+ {
1543
+ name: "admin::hasPermissions",
1544
+ config: {
1545
+ actions: ["plugin::content-releases.read"]
1546
+ }
1547
+ }
1548
+ ]
1549
+ }
1550
+ },
1551
+ {
1552
+ method: "POST",
1553
+ path: "/",
1554
+ handler: "release.create",
1555
+ config: {
1556
+ policies: [
1557
+ "admin::isAuthenticatedAdmin",
1558
+ {
1559
+ name: "admin::hasPermissions",
1560
+ config: {
1561
+ actions: ["plugin::content-releases.create"]
1562
+ }
1563
+ }
1564
+ ]
1565
+ }
1566
+ },
1567
+ {
1568
+ method: "GET",
1569
+ path: "/",
1570
+ handler: "release.findMany",
1571
+ config: {
1572
+ policies: [
1573
+ "admin::isAuthenticatedAdmin",
1574
+ {
1575
+ name: "admin::hasPermissions",
1576
+ config: {
1577
+ actions: ["plugin::content-releases.read"]
1578
+ }
1579
+ }
1580
+ ]
1581
+ }
1582
+ },
1583
+ {
1584
+ method: "GET",
1585
+ path: "/:id",
1586
+ handler: "release.findOne",
1587
+ config: {
1588
+ policies: [
1589
+ "admin::isAuthenticatedAdmin",
1590
+ {
1591
+ name: "admin::hasPermissions",
1592
+ config: {
1593
+ actions: ["plugin::content-releases.read"]
1594
+ }
1595
+ }
1596
+ ]
1597
+ }
1598
+ },
1599
+ {
1600
+ method: "PUT",
1601
+ path: "/:id",
1602
+ handler: "release.update",
1603
+ config: {
1604
+ policies: [
1605
+ "admin::isAuthenticatedAdmin",
1606
+ {
1607
+ name: "admin::hasPermissions",
1608
+ config: {
1609
+ actions: ["plugin::content-releases.update"]
1610
+ }
1611
+ }
1612
+ ]
1613
+ }
1614
+ },
1615
+ {
1616
+ method: "DELETE",
1617
+ path: "/:id",
1618
+ handler: "release.delete",
1619
+ config: {
1620
+ policies: [
1621
+ "admin::isAuthenticatedAdmin",
1622
+ {
1623
+ name: "admin::hasPermissions",
1624
+ config: {
1625
+ actions: ["plugin::content-releases.delete"]
1626
+ }
1627
+ }
1628
+ ]
1629
+ }
1630
+ },
1631
+ {
1632
+ method: "POST",
1633
+ path: "/:id/publish",
1634
+ handler: "release.publish",
1635
+ config: {
1636
+ policies: [
1637
+ "admin::isAuthenticatedAdmin",
1638
+ {
1639
+ name: "admin::hasPermissions",
1640
+ config: {
1641
+ actions: ["plugin::content-releases.publish"]
1642
+ }
1643
+ }
1644
+ ]
1645
+ }
1646
+ }
1647
+ ]
1648
+ };
1649
+ const releaseAction = {
1650
+ type: "admin",
1651
+ routes: [
1652
+ {
1653
+ method: "POST",
1654
+ path: "/:releaseId/actions",
1655
+ handler: "release-action.create",
1656
+ config: {
1657
+ policies: [
1658
+ "admin::isAuthenticatedAdmin",
1659
+ {
1660
+ name: "admin::hasPermissions",
1661
+ config: {
1662
+ actions: ["plugin::content-releases.create-action"]
1663
+ }
1664
+ }
1665
+ ]
1666
+ }
1667
+ },
1668
+ {
1669
+ method: "POST",
1670
+ path: "/:releaseId/actions/bulk",
1671
+ handler: "release-action.createMany",
1672
+ config: {
1673
+ policies: [
1674
+ "admin::isAuthenticatedAdmin",
1675
+ {
1676
+ name: "admin::hasPermissions",
1677
+ config: {
1678
+ actions: ["plugin::content-releases.create-action"]
1679
+ }
1680
+ }
1681
+ ]
1682
+ }
1683
+ },
1684
+ {
1685
+ method: "GET",
1686
+ path: "/:releaseId/actions",
1687
+ handler: "release-action.findMany",
1688
+ config: {
1689
+ policies: [
1690
+ "admin::isAuthenticatedAdmin",
1691
+ {
1692
+ name: "admin::hasPermissions",
1693
+ config: {
1694
+ actions: ["plugin::content-releases.read"]
1695
+ }
1696
+ }
1697
+ ]
1698
+ }
1699
+ },
1700
+ {
1701
+ method: "PUT",
1702
+ path: "/:releaseId/actions/:actionId",
1703
+ handler: "release-action.update",
1704
+ config: {
1705
+ policies: [
1706
+ "admin::isAuthenticatedAdmin",
1707
+ {
1708
+ name: "admin::hasPermissions",
1709
+ config: {
1710
+ actions: ["plugin::content-releases.update"]
1711
+ }
1712
+ }
1713
+ ]
1714
+ }
1715
+ },
1716
+ {
1717
+ method: "DELETE",
1718
+ path: "/:releaseId/actions/:actionId",
1719
+ handler: "release-action.delete",
1720
+ config: {
1721
+ policies: [
1722
+ "admin::isAuthenticatedAdmin",
1723
+ {
1724
+ name: "admin::hasPermissions",
1725
+ config: {
1726
+ actions: ["plugin::content-releases.delete-action"]
1727
+ }
1728
+ }
1729
+ ]
1730
+ }
1731
+ }
1732
+ ]
1733
+ };
1734
+ const routes = {
1735
+ release,
1736
+ "release-action": releaseAction
1737
+ };
1738
+ const getPlugin = () => {
1739
+ if (strapi.ee.features.isEnabled("cms-content-releases")) {
1740
+ return {
1741
+ register,
1742
+ bootstrap,
1743
+ destroy,
1744
+ contentTypes,
1745
+ services,
1746
+ controllers,
1747
+ routes
1748
+ };
1749
+ }
1750
+ return {
1751
+ // Always return register, it handles its own feature check
1752
+ register,
1753
+ // Always return contentTypes to avoid losing data when the feature is disabled
1754
+ contentTypes
1755
+ };
1756
+ };
1757
+ const index = getPlugin();
10
1758
  export {
11
1759
  index as default
12
1760
  };