@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.
Files changed (93) hide show
  1. package/dist/_chunks/{App-bpzO2Ljh.mjs → App-PQlYzNfb.mjs} +181 -167
  2. package/dist/_chunks/App-PQlYzNfb.mjs.map +1 -0
  3. package/dist/_chunks/{App-p8aKBitd.js → App-lzeJz92X.js} +179 -165
  4. package/dist/_chunks/App-lzeJz92X.js.map +1 -0
  5. package/dist/_chunks/{index-AECgcaDa.mjs → index--4AgLDzb.mjs} +20 -26
  6. package/dist/_chunks/index--4AgLDzb.mjs.map +1 -0
  7. package/dist/_chunks/{index-fP3qoWZ4.js → index-Nf1JfI-m.js} +16 -22
  8. package/dist/_chunks/index-Nf1JfI-m.js.map +1 -0
  9. package/dist/admin/index.js +1 -1
  10. package/dist/admin/index.mjs +1 -1
  11. package/dist/admin/src/components/CMReleasesContainer.d.ts +1 -0
  12. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  13. package/dist/admin/src/components/ReleaseActionMenu.d.ts +26 -0
  14. package/dist/admin/src/components/ReleaseActionOptions.d.ts +9 -0
  15. package/dist/admin/src/components/ReleaseModal.d.ts +16 -0
  16. package/dist/admin/src/constants.d.ts +58 -0
  17. package/dist/admin/src/index.d.ts +3 -0
  18. package/dist/admin/src/pages/App.d.ts +1 -0
  19. package/dist/admin/src/pages/PurchaseContentReleases.d.ts +2 -0
  20. package/dist/admin/src/pages/ReleaseDetailsPage.d.ts +2 -0
  21. package/dist/admin/src/pages/ReleasesPage.d.ts +8 -0
  22. package/dist/admin/src/pages/tests/mockReleaseDetailsPageData.d.ts +181 -0
  23. package/dist/admin/src/pages/tests/mockReleasesPageData.d.ts +39 -0
  24. package/dist/admin/src/pluginId.d.ts +1 -0
  25. package/dist/admin/src/services/axios.d.ts +29 -0
  26. package/dist/admin/src/services/release.d.ts +369 -0
  27. package/dist/admin/src/store/hooks.d.ts +7 -0
  28. package/dist/admin/src/utils/time.d.ts +1 -0
  29. package/dist/server/index.js +92 -171
  30. package/dist/server/index.js.map +1 -1
  31. package/dist/server/index.mjs +93 -171
  32. package/dist/server/index.mjs.map +1 -1
  33. package/dist/server/src/bootstrap.d.ts +5 -0
  34. package/dist/server/src/bootstrap.d.ts.map +1 -0
  35. package/dist/server/src/constants.d.ts +12 -0
  36. package/dist/server/src/constants.d.ts.map +1 -0
  37. package/dist/server/src/content-types/index.d.ts +99 -0
  38. package/dist/server/src/content-types/index.d.ts.map +1 -0
  39. package/dist/server/src/content-types/release/index.d.ts +48 -0
  40. package/dist/server/src/content-types/release/index.d.ts.map +1 -0
  41. package/dist/server/src/content-types/release/schema.d.ts +47 -0
  42. package/dist/server/src/content-types/release/schema.d.ts.map +1 -0
  43. package/dist/server/src/content-types/release-action/index.d.ts +50 -0
  44. package/dist/server/src/content-types/release-action/index.d.ts.map +1 -0
  45. package/dist/server/src/content-types/release-action/schema.d.ts +49 -0
  46. package/dist/server/src/content-types/release-action/schema.d.ts.map +1 -0
  47. package/dist/server/src/controllers/index.d.ts +18 -0
  48. package/dist/server/src/controllers/index.d.ts.map +1 -0
  49. package/dist/server/src/controllers/release-action.d.ts +9 -0
  50. package/dist/server/src/controllers/release-action.d.ts.map +1 -0
  51. package/dist/server/src/controllers/release.d.ts +11 -0
  52. package/dist/server/src/controllers/release.d.ts.map +1 -0
  53. package/dist/server/src/controllers/validation/release-action.d.ts +3 -0
  54. package/dist/server/src/controllers/validation/release-action.d.ts.map +1 -0
  55. package/dist/server/src/controllers/validation/release.d.ts +2 -0
  56. package/dist/server/src/controllers/validation/release.d.ts.map +1 -0
  57. package/dist/server/src/destroy.d.ts +5 -0
  58. package/dist/server/src/destroy.d.ts.map +1 -0
  59. package/dist/server/src/index.d.ts +2092 -0
  60. package/dist/server/src/index.d.ts.map +1 -0
  61. package/dist/server/src/migrations/index.d.ts +10 -0
  62. package/dist/server/src/migrations/index.d.ts.map +1 -0
  63. package/dist/server/src/register.d.ts +5 -0
  64. package/dist/server/src/register.d.ts.map +1 -0
  65. package/dist/server/src/routes/index.d.ts +35 -0
  66. package/dist/server/src/routes/index.d.ts.map +1 -0
  67. package/dist/server/src/routes/release-action.d.ts +18 -0
  68. package/dist/server/src/routes/release-action.d.ts.map +1 -0
  69. package/dist/server/src/routes/release.d.ts +18 -0
  70. package/dist/server/src/routes/release.d.ts.map +1 -0
  71. package/dist/server/src/services/index.d.ts +1826 -0
  72. package/dist/server/src/services/index.d.ts.map +1 -0
  73. package/dist/server/src/services/release.d.ts +66 -0
  74. package/dist/server/src/services/release.d.ts.map +1 -0
  75. package/dist/server/src/services/scheduling.d.ts +18 -0
  76. package/dist/server/src/services/scheduling.d.ts.map +1 -0
  77. package/dist/server/src/services/validation.d.ts +14 -0
  78. package/dist/server/src/services/validation.d.ts.map +1 -0
  79. package/dist/server/src/utils/index.d.ts +14 -0
  80. package/dist/server/src/utils/index.d.ts.map +1 -0
  81. package/dist/shared/contracts/release-actions.d.ts +105 -0
  82. package/dist/shared/contracts/release-actions.d.ts.map +1 -0
  83. package/dist/shared/contracts/releases.d.ts +166 -0
  84. package/dist/shared/contracts/releases.d.ts.map +1 -0
  85. package/dist/shared/types.d.ts +24 -0
  86. package/dist/shared/types.d.ts.map +1 -0
  87. package/dist/shared/validation-schemas.d.ts +2 -0
  88. package/dist/shared/validation-schemas.d.ts.map +1 -0
  89. package/package.json +14 -21
  90. package/dist/_chunks/App-bpzO2Ljh.mjs.map +0 -1
  91. package/dist/_chunks/App-p8aKBitd.js.map +0 -1
  92. package/dist/_chunks/index-AECgcaDa.mjs.map +0 -1
  93. package/dist/_chunks/index-fP3qoWZ4.js.map +0 -1
@@ -1,8 +1,7 @@
1
- import { contentTypes as contentTypes$1, mapAsync, setCreatorFields, errors, validateYupSchema, yup as yup$1 } from "@strapi/utils";
1
+ import { async, setCreatorFields, convertQueryParams, errors, validateYupSchema, yup as yup$1 } from "@strapi/utils";
2
2
  import isEqual from "lodash/isEqual";
3
3
  import { difference, keys } from "lodash";
4
4
  import _ from "lodash/fp";
5
- import EE from "@strapi/strapi/dist/utils/ee";
6
5
  import { scheduleJob } from "node-schedule";
7
6
  import * as yup from "yup";
8
7
  const RELEASE_MODEL_UID = "plugin::content-releases.release";
@@ -60,7 +59,10 @@ const getService = (name, { strapi: strapi2 } = { strapi: global.strapi }) => {
60
59
  const getPopulatedEntry = async (contentTypeUid, entryId, { strapi: strapi2 } = { strapi: global.strapi }) => {
61
60
  const populateBuilderService = strapi2.plugin("content-manager").service("populate-builder");
62
61
  const populate = await populateBuilderService(contentTypeUid).populateDeep(Infinity).build();
63
- const entry = await strapi2.entityService.findOne(contentTypeUid, entryId, { populate });
62
+ const entry = await strapi2.db.query(contentTypeUid).findOne({
63
+ where: { id: entryId },
64
+ populate
65
+ });
64
66
  return entry;
65
67
  };
66
68
  const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 } = { strapi: global.strapi }) => {
@@ -77,28 +79,10 @@ const getEntryValidStatus = async (contentTypeUid, entry, { strapi: strapi2 } =
77
79
  return false;
78
80
  }
79
81
  };
80
- async function deleteActionsOnDisableDraftAndPublish({
81
- oldContentTypes,
82
- contentTypes: contentTypes2
83
- }) {
84
- if (!oldContentTypes) {
85
- return;
86
- }
87
- for (const uid in contentTypes2) {
88
- if (!oldContentTypes[uid]) {
89
- continue;
90
- }
91
- const oldContentType = oldContentTypes[uid];
92
- const contentType = contentTypes2[uid];
93
- if (contentTypes$1.hasDraftAndPublish(oldContentType) && !contentTypes$1.hasDraftAndPublish(contentType)) {
94
- await strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: uid }).execute();
95
- }
96
- }
97
- }
98
82
  async function deleteActionsOnDeleteContentType({ oldContentTypes, contentTypes: contentTypes2 }) {
99
83
  const deletedContentTypes = difference(keys(oldContentTypes), keys(contentTypes2)) ?? [];
100
84
  if (deletedContentTypes.length) {
101
- await mapAsync(deletedContentTypes, async (deletedContentTypeUID) => {
85
+ await async.map(deletedContentTypes, async (deletedContentTypeUID) => {
102
86
  return strapi.db?.queryBuilder(RELEASE_ACTION_MODEL_UID).delete().where({ contentType: deletedContentTypeUID }).execute();
103
87
  });
104
88
  }
@@ -117,7 +101,7 @@ async function migrateIsValidAndStatusReleases() {
117
101
  }
118
102
  }
119
103
  });
120
- mapAsync(releasesWithoutStatus, async (release2) => {
104
+ async.map(releasesWithoutStatus, async (release2) => {
121
105
  const actions = release2.actions;
122
106
  const notValidatedActions = actions.filter((action) => action.isEntryValid === null);
123
107
  for (const action of notValidatedActions) {
@@ -148,7 +132,7 @@ async function migrateIsValidAndStatusReleases() {
148
132
  }
149
133
  }
150
134
  });
151
- mapAsync(publishedReleases, async (release2) => {
135
+ async.map(publishedReleases, async (release2) => {
152
136
  return strapi.db.query(RELEASE_MODEL_UID).update({
153
137
  where: {
154
138
  id: release2.id
@@ -161,11 +145,9 @@ async function migrateIsValidAndStatusReleases() {
161
145
  }
162
146
  async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: contentTypes2 }) {
163
147
  if (oldContentTypes !== void 0 && contentTypes2 !== void 0) {
164
- const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes).filter(
165
- (uid) => oldContentTypes[uid]?.options?.draftAndPublish
166
- );
148
+ const contentTypesWithDraftAndPublish = Object.keys(oldContentTypes);
167
149
  const releasesAffected = /* @__PURE__ */ new Set();
168
- mapAsync(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
150
+ async.map(contentTypesWithDraftAndPublish, async (contentTypeUID) => {
169
151
  const oldContentType = oldContentTypes[contentTypeUID];
170
152
  const contentType = contentTypes2[contentTypeUID];
171
153
  if (!isEqual(oldContentType?.attributes, contentType?.attributes)) {
@@ -178,8 +160,8 @@ async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: co
178
160
  release: true
179
161
  }
180
162
  });
181
- await mapAsync(actions, async (action) => {
182
- if (action.entry && action.release) {
163
+ await async.map(actions, async (action) => {
164
+ if (action.entry) {
183
165
  const populatedEntry = await getPopulatedEntry(contentTypeUID, action.entry.id, {
184
166
  strapi
185
167
  });
@@ -201,71 +183,21 @@ async function revalidateChangedContentTypes({ oldContentTypes, contentTypes: co
201
183
  });
202
184
  }
203
185
  }).then(() => {
204
- mapAsync(releasesAffected, async (releaseId) => {
186
+ async.map(releasesAffected, async (releaseId) => {
205
187
  return getService("release", { strapi }).updateReleaseStatus(releaseId);
206
188
  });
207
189
  });
208
190
  }
209
191
  }
210
- async function disableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
211
- if (!oldContentTypes) {
212
- return;
213
- }
214
- for (const uid in contentTypes2) {
215
- if (!oldContentTypes[uid]) {
216
- continue;
217
- }
218
- const oldContentType = oldContentTypes[uid];
219
- const contentType = contentTypes2[uid];
220
- const i18nPlugin = strapi.plugin("i18n");
221
- const { isLocalizedContentType } = i18nPlugin.service("content-types");
222
- if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {
223
- await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
224
- locale: null
225
- }).where({ contentType: uid }).execute();
226
- }
227
- }
228
- }
229
- async function enableContentTypeLocalized({ oldContentTypes, contentTypes: contentTypes2 }) {
230
- if (!oldContentTypes) {
231
- return;
232
- }
233
- for (const uid in contentTypes2) {
234
- if (!oldContentTypes[uid]) {
235
- continue;
236
- }
237
- const oldContentType = oldContentTypes[uid];
238
- const contentType = contentTypes2[uid];
239
- const i18nPlugin = strapi.plugin("i18n");
240
- const { isLocalizedContentType } = i18nPlugin.service("content-types");
241
- const { getDefaultLocale } = i18nPlugin.service("locales");
242
- if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {
243
- const defaultLocale = await getDefaultLocale();
244
- await strapi.db.queryBuilder(RELEASE_ACTION_MODEL_UID).update({
245
- locale: defaultLocale
246
- }).where({ contentType: uid }).execute();
247
- }
248
- }
249
- }
250
- const { features: features$2 } = require("@strapi/strapi/dist/utils/ee");
251
192
  const register = async ({ strapi: strapi2 }) => {
252
- if (features$2.isEnabled("cms-content-releases")) {
193
+ if (strapi2.ee.features.isEnabled("cms-content-releases")) {
253
194
  await strapi2.admin.services.permission.actionProvider.registerMany(ACTIONS);
254
- strapi2.hook("strapi::content-types.beforeSync").register(deleteActionsOnDisableDraftAndPublish).register(disableContentTypeLocalized);
255
- strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(enableContentTypeLocalized).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
256
- }
257
- if (strapi2.plugin("graphql")) {
258
- const graphqlExtensionService = strapi2.plugin("graphql").service("extension");
259
- graphqlExtensionService.shadowCRUD(RELEASE_MODEL_UID).disable();
260
- graphqlExtensionService.shadowCRUD(RELEASE_ACTION_MODEL_UID).disable();
195
+ strapi2.hook("strapi::content-types.afterSync").register(deleteActionsOnDeleteContentType).register(revalidateChangedContentTypes).register(migrateIsValidAndStatusReleases);
261
196
  }
262
197
  };
263
- const { features: features$1 } = require("@strapi/strapi/dist/utils/ee");
264
198
  const bootstrap = async ({ strapi: strapi2 }) => {
265
- if (features$1.isEnabled("cms-content-releases")) {
266
- const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes).filter(
267
- (uid) => strapi2.contentTypes[uid]?.options?.draftAndPublish
268
- );
199
+ if (strapi2.ee.features.isEnabled("cms-content-releases")) {
200
+ const contentTypesWithDraftAndPublish = Object.keys(strapi2.contentTypes);
269
201
  strapi2.db.lifecycles.subscribe({
270
202
  models: contentTypesWithDraftAndPublish,
271
203
  async afterDelete(event) {
@@ -301,7 +233,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
301
233
  */
302
234
  async beforeDeleteMany(event) {
303
235
  const { model, params } = event;
304
- if (model.kind === "collectionType" && model.options?.draftAndPublish) {
236
+ if (model.kind === "collectionType") {
305
237
  const { where } = params;
306
238
  const entriesToDelete = await strapi2.db.query(model.uid).findMany({ select: ["id"], where });
307
239
  event.state.entriesToDelete = entriesToDelete;
@@ -541,7 +473,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
541
473
  validateUniqueNameForPendingRelease(releaseWithCreatorFields.name),
542
474
  validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
543
475
  ]);
544
- const release2 = await strapi2.entityService.create(RELEASE_MODEL_UID, {
476
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).create({
545
477
  data: {
546
478
  ...releaseWithCreatorFields,
547
479
  status: "empty"
@@ -555,17 +487,19 @@ const createReleaseService = ({ strapi: strapi2 }) => {
555
487
  return release2;
556
488
  },
557
489
  async findOne(id, query = {}) {
558
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, id, {
559
- ...query
490
+ const dbQuery = convertQueryParams.transformParamsToQuery(RELEASE_MODEL_UID, query);
491
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
492
+ ...dbQuery,
493
+ where: { id }
560
494
  });
561
495
  return release2;
562
496
  },
563
497
  findPage(query) {
564
- return strapi2.entityService.findPage(RELEASE_MODEL_UID, {
565
- ...query,
498
+ const dbQuery = convertQueryParams.transformParamsToQuery(RELEASE_MODEL_UID, query ?? {});
499
+ return strapi2.db.query(RELEASE_MODEL_UID).findPage({
500
+ ...dbQuery,
566
501
  populate: {
567
502
  actions: {
568
- // @ts-expect-error Ignore missing properties
569
503
  count: true
570
504
  }
571
505
  }
@@ -657,19 +591,15 @@ const createReleaseService = ({ strapi: strapi2 }) => {
657
591
  validateUniqueNameForPendingRelease(releaseWithCreatorFields.name, id),
658
592
  validateScheduledAtIsLaterThanNow(releaseWithCreatorFields.scheduledAt)
659
593
  ]);
660
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, id);
594
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id } });
661
595
  if (!release2) {
662
596
  throw new errors.NotFoundError(`No release found for id ${id}`);
663
597
  }
664
598
  if (release2.releasedAt) {
665
599
  throw new errors.ValidationError("Release already published");
666
600
  }
667
- const updatedRelease = await strapi2.entityService.update(RELEASE_MODEL_UID, id, {
668
- /*
669
- * The type returned from the entity service: Partial<Input<"plugin::content-releases.release">>
670
- * is not compatible with the type we are passing here: UpdateRelease.Request['body']
671
- */
672
- // @ts-expect-error see above
601
+ const updatedRelease = await strapi2.db.query(RELEASE_MODEL_UID).update({
602
+ where: { id },
673
603
  data: releaseWithCreatorFields
674
604
  });
675
605
  if (strapi2.features.future.isEnabled("contentReleasesScheduling")) {
@@ -692,7 +622,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
692
622
  validateEntryContentType(action.entry.contentType),
693
623
  validateUniqueEntry(releaseId, action)
694
624
  ]);
695
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, releaseId);
625
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({ where: { id: releaseId } });
696
626
  if (!release2) {
697
627
  throw new errors.NotFoundError(`No release found for id ${releaseId}`);
698
628
  }
@@ -702,7 +632,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
702
632
  const { entry, type } = action;
703
633
  const populatedEntry = await getPopulatedEntry(entry.contentType, entry.id, { strapi: strapi2 });
704
634
  const isEntryValid = await getEntryValidStatus(entry.contentType, populatedEntry, { strapi: strapi2 });
705
- const releaseAction2 = await strapi2.entityService.create(RELEASE_ACTION_MODEL_UID, {
635
+ const releaseAction2 = await strapi2.db.query(RELEASE_ACTION_MODEL_UID).create({
706
636
  data: {
707
637
  type,
708
638
  contentType: entry.contentType,
@@ -715,32 +645,41 @@ const createReleaseService = ({ strapi: strapi2 }) => {
715
645
  },
716
646
  release: releaseId
717
647
  },
718
- populate: { release: { fields: ["id"] }, entry: { fields: ["id"] } }
648
+ populate: { release: { select: ["id"] }, entry: { select: ["id"] } }
719
649
  });
720
650
  this.updateReleaseStatus(releaseId);
721
651
  return releaseAction2;
722
652
  },
723
653
  async findActions(releaseId, query) {
724
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, releaseId, {
725
- fields: ["id"]
654
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
655
+ where: { id: releaseId },
656
+ select: ["id"]
726
657
  });
727
658
  if (!release2) {
728
659
  throw new errors.NotFoundError(`No release found for id ${releaseId}`);
729
660
  }
730
- return strapi2.entityService.findPage(RELEASE_ACTION_MODEL_UID, {
731
- ...query,
661
+ const dbQuery = convertQueryParams.transformParamsToQuery(
662
+ RELEASE_ACTION_MODEL_UID,
663
+ query ?? {}
664
+ );
665
+ return strapi2.db.query(RELEASE_ACTION_MODEL_UID).findPage({
666
+ ...dbQuery,
732
667
  populate: {
733
668
  entry: {
734
669
  populate: "*"
735
670
  }
736
671
  },
737
- filters: {
672
+ where: {
738
673
  release: releaseId
739
674
  }
740
675
  });
741
676
  },
742
677
  async countActions(query) {
743
- return strapi2.entityService.count(RELEASE_ACTION_MODEL_UID, query);
678
+ const dbQuery = convertQueryParams.transformParamsToQuery(
679
+ RELEASE_ACTION_MODEL_UID,
680
+ query ?? {}
681
+ );
682
+ return strapi2.db.query(RELEASE_ACTION_MODEL_UID).count(dbQuery);
744
683
  },
745
684
  async groupActions(actions, groupBy) {
746
685
  const contentTypeUids = actions.reduce((acc, action) => {
@@ -821,10 +760,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
821
760
  return componentsMap;
822
761
  },
823
762
  async delete(releaseId) {
824
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, releaseId, {
763
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
764
+ where: { id: releaseId },
825
765
  populate: {
826
766
  actions: {
827
- fields: ["id"]
767
+ select: ["id"]
828
768
  }
829
769
  }
830
770
  });
@@ -842,7 +782,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
842
782
  }
843
783
  }
844
784
  });
845
- await strapi2.entityService.delete(RELEASE_MODEL_UID, releaseId);
785
+ await strapi2.db.query(RELEASE_MODEL_UID).delete({
786
+ where: {
787
+ id: releaseId
788
+ }
789
+ });
846
790
  });
847
791
  if (strapi2.features.future.isEnabled("contentReleasesScheduling") && release2.scheduledAt) {
848
792
  const schedulingService = getService("scheduling", { strapi: strapi2 });
@@ -853,21 +797,18 @@ const createReleaseService = ({ strapi: strapi2 }) => {
853
797
  },
854
798
  async publish(releaseId) {
855
799
  try {
856
- const releaseWithPopulatedActionEntries = await strapi2.entityService.findOne(
857
- RELEASE_MODEL_UID,
858
- releaseId,
859
- {
860
- populate: {
861
- actions: {
862
- populate: {
863
- entry: {
864
- fields: ["id"]
865
- }
800
+ const releaseWithPopulatedActionEntries = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
801
+ where: { id: releaseId },
802
+ populate: {
803
+ actions: {
804
+ populate: {
805
+ entry: {
806
+ select: ["id"]
866
807
  }
867
808
  }
868
809
  }
869
810
  }
870
- );
811
+ });
871
812
  if (!releaseWithPopulatedActionEntries) {
872
813
  throw new errors.NotFoundError(`No release found for id ${releaseId}`);
873
814
  }
@@ -906,7 +847,7 @@ const createReleaseService = ({ strapi: strapi2 }) => {
906
847
  await strapi2.db.transaction(async () => {
907
848
  for (const { uid, action, id } of singleTypeActions) {
908
849
  const populate = await populateBuilderService(uid).populateDeep(Infinity).build();
909
- const entry = await strapi2.entityService.findOne(uid, id, { populate });
850
+ const entry = await strapi2.db.query(uid).findOne({ where: { id }, populate });
910
851
  try {
911
852
  if (action === "publish") {
912
853
  await entityManagerService.publish(entry, uid);
@@ -923,28 +864,22 @@ const createReleaseService = ({ strapi: strapi2 }) => {
923
864
  for (const contentTypeUid of Object.keys(collectionTypeActions)) {
924
865
  const populate = await populateBuilderService(contentTypeUid).populateDeep(Infinity).build();
925
866
  const { entriestoPublishIds, entriesToUnpublishIds } = collectionTypeActions[contentTypeUid];
926
- const entriesToPublish = await strapi2.entityService.findMany(
927
- contentTypeUid,
928
- {
929
- filters: {
930
- id: {
931
- $in: entriestoPublishIds
932
- }
933
- },
934
- populate
935
- }
936
- );
937
- const entriesToUnpublish = await strapi2.entityService.findMany(
938
- contentTypeUid,
939
- {
940
- filters: {
941
- id: {
942
- $in: entriesToUnpublishIds
943
- }
944
- },
945
- populate
946
- }
947
- );
867
+ const entriesToPublish = await strapi2.db.query(contentTypeUid).findMany({
868
+ where: {
869
+ id: {
870
+ $in: entriestoPublishIds
871
+ }
872
+ },
873
+ populate
874
+ });
875
+ const entriesToUnpublish = await strapi2.db.query(contentTypeUid).findMany({
876
+ where: {
877
+ id: {
878
+ $in: entriesToUnpublishIds
879
+ }
880
+ },
881
+ populate
882
+ });
948
883
  if (entriesToPublish.length > 0) {
949
884
  await entityManagerService.publishMany(entriesToPublish, contentTypeUid);
950
885
  }
@@ -953,17 +888,13 @@ const createReleaseService = ({ strapi: strapi2 }) => {
953
888
  }
954
889
  }
955
890
  });
956
- const release2 = await strapi2.entityService.update(RELEASE_MODEL_UID, releaseId, {
891
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).update({
892
+ where: { id: releaseId },
957
893
  data: {
958
- /*
959
- * The type returned from the entity service: Partial<Input<"plugin::content-releases.release">> looks like it's wrong
960
- */
961
- // @ts-expect-error see above
962
894
  releasedAt: /* @__PURE__ */ new Date()
963
895
  },
964
896
  populate: {
965
897
  actions: {
966
- // @ts-expect-error is not expecting count but it is working
967
898
  count: true
968
899
  }
969
900
  }
@@ -1079,8 +1010,11 @@ const createReleaseService = ({ strapi: strapi2 }) => {
1079
1010
  };
1080
1011
  const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1081
1012
  async validateUniqueEntry(releaseId, releaseActionArgs) {
1082
- const release2 = await strapi2.entityService.findOne(RELEASE_MODEL_UID, releaseId, {
1083
- populate: { actions: { populate: { entry: { fields: ["id"] } } } }
1013
+ const release2 = await strapi2.db.query(RELEASE_MODEL_UID).findOne({
1014
+ where: {
1015
+ id: releaseId
1016
+ },
1017
+ populate: { actions: { populate: { entry: { select: ["id"] } } } }
1084
1018
  });
1085
1019
  if (!release2) {
1086
1020
  throw new errors.NotFoundError(`No release found for id ${releaseId}`);
@@ -1099,17 +1033,9 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1099
1033
  if (!contentType) {
1100
1034
  throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);
1101
1035
  }
1102
- if (!contentType.options?.draftAndPublish) {
1103
- throw new errors.ValidationError(
1104
- `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`
1105
- );
1106
- }
1107
1036
  },
1108
1037
  async validatePendingReleasesLimit() {
1109
- const maximumPendingReleases = (
1110
- // @ts-expect-error - options is not typed into features
1111
- EE.features.get("cms-content-releases")?.options?.maximumReleases || 3
1112
- );
1038
+ const maximumPendingReleases = strapi2.ee.features.get("cms-content-releases")?.options?.maximumReleases || 3;
1113
1039
  const [, pendingReleasesCount] = await strapi2.db.query(RELEASE_MODEL_UID).findWithCount({
1114
1040
  filters: {
1115
1041
  releasedAt: {
@@ -1122,8 +1048,8 @@ const createReleaseValidationService = ({ strapi: strapi2 }) => ({
1122
1048
  }
1123
1049
  },
1124
1050
  async validateUniqueNameForPendingRelease(name, id) {
1125
- const pendingReleases = await strapi2.entityService.findMany(RELEASE_MODEL_UID, {
1126
- filters: {
1051
+ const pendingReleases = await strapi2.db.query(RELEASE_MODEL_UID).findMany({
1052
+ where: {
1127
1053
  releasedAt: {
1128
1054
  $null: true
1129
1055
  },
@@ -1250,7 +1176,7 @@ const releaseController = {
1250
1176
  }
1251
1177
  };
1252
1178
  });
1253
- const pendingReleasesCount = await strapi.query(RELEASE_MODEL_UID).count({
1179
+ const pendingReleasesCount = await strapi.db.query(RELEASE_MODEL_UID).count({
1254
1180
  where: {
1255
1181
  releasedAt: null
1256
1182
  }
@@ -1396,7 +1322,7 @@ const releaseActionController = {
1396
1322
  acc[action.contentType] = contentTypePermissionsManager.sanitizeOutput;
1397
1323
  return acc;
1398
1324
  }, {});
1399
- const sanitizedResults = await mapAsync(results, async (action) => ({
1325
+ const sanitizedResults = await async.map(results, async (action) => ({
1400
1326
  ...action,
1401
1327
  entry: await contentTypeOutputSanitizers[action.contentType](action.entry)
1402
1328
  }));
@@ -1612,9 +1538,8 @@ const routes = {
1612
1538
  release,
1613
1539
  "release-action": releaseAction
1614
1540
  };
1615
- const { features } = require("@strapi/strapi/dist/utils/ee");
1616
1541
  const getPlugin = () => {
1617
- if (features.isEnabled("cms-content-releases")) {
1542
+ if (strapi.ee.features.isEnabled("cms-content-releases")) {
1618
1543
  return {
1619
1544
  register,
1620
1545
  bootstrap,
@@ -1626,9 +1551,6 @@ const getPlugin = () => {
1626
1551
  };
1627
1552
  }
1628
1553
  return {
1629
- // Always return register, it handles its own feature check
1630
- register,
1631
- // Always return contentTypes to avoid losing data when the feature is disabled
1632
1554
  contentTypes
1633
1555
  };
1634
1556
  };