@strapi/content-manager 0.0.0-experimental.9c7de54d8ce77e13047fc15ada33f937a068f1f2 → 0.0.0-experimental.9f812af47f0e9db3d5531382c836c2ac0776afdf

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 (180) hide show
  1. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  2. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-gsCd80MU.js → ComponentConfigurationPage-BSEZcJVB.js} +4 -5
  4. package/dist/_chunks/{ComponentConfigurationPage-gsCd80MU.js.map → ComponentConfigurationPage-BSEZcJVB.js.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs → ComponentConfigurationPage-BiASGi7x.mjs} +3 -3
  6. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs.map → ComponentConfigurationPage-BiASGi7x.mjs.map} +1 -1
  7. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  9. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  10. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js → EditConfigurationPage-D2rtvneE.js} +4 -5
  11. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js.map → EditConfigurationPage-D2rtvneE.js.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-BglmD_BF.mjs → EditConfigurationPage-vN4zupij.mjs} +3 -3
  13. package/dist/_chunks/{EditConfigurationPage-BglmD_BF.mjs.map → EditConfigurationPage-vN4zupij.mjs.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-C4iTxUPU.js → EditViewPage-BwisF04Q.js} +38 -9
  15. package/dist/_chunks/EditViewPage-BwisF04Q.js.map +1 -0
  16. package/dist/_chunks/{EditViewPage-CiwVPMaK.mjs → EditViewPage-_A31Cl4g.mjs} +38 -8
  17. package/dist/_chunks/EditViewPage-_A31Cl4g.mjs.map +1 -0
  18. package/dist/_chunks/{Field-DIjL1b5d.mjs → Field-CvIunNOj.mjs} +169 -117
  19. package/dist/_chunks/Field-CvIunNOj.mjs.map +1 -0
  20. package/dist/_chunks/{Field-DhXEK8y1.js → Field-Dsu6-FrM.js} +171 -119
  21. package/dist/_chunks/Field-Dsu6-FrM.js.map +1 -0
  22. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  23. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  24. package/dist/_chunks/{Form-CmNesrvR.mjs → Form-DK0fG0Gj.mjs} +3 -3
  25. package/dist/_chunks/{Form-CmNesrvR.mjs.map → Form-DK0fG0Gj.mjs.map} +1 -1
  26. package/dist/_chunks/{Form-CwmJ4sWe.js → Form-DUwWcCmA.js} +5 -6
  27. package/dist/_chunks/{Form-CwmJ4sWe.js.map → Form-DUwWcCmA.js.map} +1 -1
  28. package/dist/_chunks/{History-BLCCNgCt.js → History-CeCDhoJG.js} +22 -93
  29. package/dist/_chunks/History-CeCDhoJG.js.map +1 -0
  30. package/dist/_chunks/{History-D-99Wh30.mjs → History-DP8gmXpm.mjs} +22 -92
  31. package/dist/_chunks/History-DP8gmXpm.mjs.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-JPWZz7Kg.mjs → ListConfigurationPage-BCkO5iuN.mjs} +6 -5
  33. package/dist/_chunks/ListConfigurationPage-BCkO5iuN.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-DxWpeZrO.js → ListConfigurationPage-C-bAd44a.js} +6 -6
  35. package/dist/_chunks/ListConfigurationPage-C-bAd44a.js.map +1 -0
  36. package/dist/_chunks/{ListViewPage-CIQekSFz.js → ListViewPage-BKTZFhsM.js} +64 -53
  37. package/dist/_chunks/ListViewPage-BKTZFhsM.js.map +1 -0
  38. package/dist/_chunks/{ListViewPage-DSK3f0ST.mjs → ListViewPage-Cf_DgaFV.mjs} +63 -51
  39. package/dist/_chunks/ListViewPage-Cf_DgaFV.mjs.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js → NoContentTypePage-D3Cm3v3q.js} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js.map → NoContentTypePage-D3Cm3v3q.js.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs → NoContentTypePage-nHIyvJcB.mjs} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs.map → NoContentTypePage-nHIyvJcB.mjs.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs → NoPermissionsPage-BALVSJ7x.mjs} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs.map → NoPermissionsPage-BALVSJ7x.mjs.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js → NoPermissionsPage-CChGWBj5.js} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js.map → NoPermissionsPage-CChGWBj5.js.map} +1 -1
  48. package/dist/_chunks/Preview-C4NBzKUV.mjs +294 -0
  49. package/dist/_chunks/Preview-C4NBzKUV.mjs.map +1 -0
  50. package/dist/_chunks/Preview-CT28Ckpg.js +312 -0
  51. package/dist/_chunks/Preview-CT28Ckpg.js.map +1 -0
  52. package/dist/_chunks/{Relations-BBmhcWFV.mjs → Relations-C8uC89cT.mjs} +9 -8
  53. package/dist/_chunks/Relations-C8uC89cT.mjs.map +1 -0
  54. package/dist/_chunks/{Relations-eG-9p_qS.js → Relations-CvkPCng_.js} +10 -10
  55. package/dist/_chunks/Relations-CvkPCng_.js.map +1 -0
  56. package/dist/_chunks/{en-Bm0D0IWz.js → en-BK8Xyl5I.js} +16 -4
  57. package/dist/_chunks/{en-Bm0D0IWz.js.map → en-BK8Xyl5I.js.map} +1 -1
  58. package/dist/_chunks/{en-DKV44jRb.mjs → en-Dtk_ot79.mjs} +16 -4
  59. package/dist/_chunks/{en-DKV44jRb.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
  60. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  61. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  62. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  63. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  64. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  65. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  66. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  67. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  68. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  69. package/dist/_chunks/{index-BIWDoFLK.js → index-CnX_j5h-.js} +337 -182
  70. package/dist/_chunks/index-CnX_j5h-.js.map +1 -0
  71. package/dist/_chunks/{index-BrUzbQ30.mjs → index-Dh2aGTGJ.mjs} +340 -184
  72. package/dist/_chunks/index-Dh2aGTGJ.mjs.map +1 -0
  73. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  74. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  75. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  77. package/dist/_chunks/{layout-_5-cXs34.mjs → layout-B5qsPihj.mjs} +4 -4
  78. package/dist/_chunks/{layout-_5-cXs34.mjs.map → layout-B5qsPihj.mjs.map} +1 -1
  79. package/dist/_chunks/{layout-lMc9i1-Z.js → layout-B_qdWGny.js} +5 -6
  80. package/dist/_chunks/{layout-lMc9i1-Z.js.map → layout-B_qdWGny.js.map} +1 -1
  81. package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
  82. package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
  83. package/dist/_chunks/{relations-BRHithi8.js → relations-ChcieiF5.js} +6 -3
  84. package/dist/_chunks/relations-ChcieiF5.js.map +1 -0
  85. package/dist/_chunks/{relations-B_VLk-DD.mjs → relations-DMXpNY-e.mjs} +6 -3
  86. package/dist/_chunks/relations-DMXpNY-e.mjs.map +1 -0
  87. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
  88. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
  89. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  90. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  91. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  92. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  93. package/dist/admin/index.js +1 -1
  94. package/dist/admin/index.mjs +4 -4
  95. package/dist/admin/src/content-manager.d.ts +3 -2
  96. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  97. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  98. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  99. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  100. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  101. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  102. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  103. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  104. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  105. package/dist/admin/src/preview/index.d.ts +1 -1
  106. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  107. package/dist/admin/src/preview/routes.d.ts +3 -0
  108. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  109. package/dist/admin/src/router.d.ts +1 -1
  110. package/dist/admin/src/services/documents.d.ts +0 -3
  111. package/dist/server/index.js +438 -238
  112. package/dist/server/index.js.map +1 -1
  113. package/dist/server/index.mjs +439 -238
  114. package/dist/server/index.mjs.map +1 -1
  115. package/dist/server/src/controllers/index.d.ts.map +1 -1
  116. package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
  117. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  118. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  119. package/dist/server/src/history/services/utils.d.ts +2 -3
  120. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  121. package/dist/server/src/index.d.ts +3 -2
  122. package/dist/server/src/index.d.ts.map +1 -1
  123. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  124. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  125. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  126. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  127. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  128. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  129. package/dist/server/src/preview/index.d.ts.map +1 -1
  130. package/dist/server/src/preview/routes/index.d.ts +8 -0
  131. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  132. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  133. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  134. package/dist/server/src/preview/services/index.d.ts +16 -0
  135. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  136. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  137. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  138. package/dist/server/src/preview/services/preview.d.ts +12 -0
  139. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  140. package/dist/server/src/preview/utils.d.ts +19 -0
  141. package/dist/server/src/preview/utils.d.ts.map +1 -0
  142. package/dist/server/src/register.d.ts.map +1 -1
  143. package/dist/server/src/routes/index.d.ts.map +1 -1
  144. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  145. package/dist/server/src/services/document-metadata.d.ts +4 -2
  146. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  147. package/dist/server/src/services/index.d.ts +3 -2
  148. package/dist/server/src/services/index.d.ts.map +1 -1
  149. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  150. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  151. package/dist/server/src/services/utils/populate.d.ts +2 -2
  152. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  153. package/dist/shared/contracts/index.d.ts +1 -0
  154. package/dist/shared/contracts/index.d.ts.map +1 -1
  155. package/dist/shared/contracts/preview.d.ts +27 -0
  156. package/dist/shared/contracts/preview.d.ts.map +1 -0
  157. package/dist/shared/index.js +4 -0
  158. package/dist/shared/index.js.map +1 -1
  159. package/dist/shared/index.mjs +4 -0
  160. package/dist/shared/index.mjs.map +1 -1
  161. package/package.json +12 -10
  162. package/dist/_chunks/EditViewPage-C4iTxUPU.js.map +0 -1
  163. package/dist/_chunks/EditViewPage-CiwVPMaK.mjs.map +0 -1
  164. package/dist/_chunks/Field-DIjL1b5d.mjs.map +0 -1
  165. package/dist/_chunks/Field-DhXEK8y1.js.map +0 -1
  166. package/dist/_chunks/History-BLCCNgCt.js.map +0 -1
  167. package/dist/_chunks/History-D-99Wh30.mjs.map +0 -1
  168. package/dist/_chunks/ListConfigurationPage-DxWpeZrO.js.map +0 -1
  169. package/dist/_chunks/ListConfigurationPage-JPWZz7Kg.mjs.map +0 -1
  170. package/dist/_chunks/ListViewPage-CIQekSFz.js.map +0 -1
  171. package/dist/_chunks/ListViewPage-DSK3f0ST.mjs.map +0 -1
  172. package/dist/_chunks/Relations-BBmhcWFV.mjs.map +0 -1
  173. package/dist/_chunks/Relations-eG-9p_qS.js.map +0 -1
  174. package/dist/_chunks/index-BIWDoFLK.js.map +0 -1
  175. package/dist/_chunks/index-BrUzbQ30.mjs.map +0 -1
  176. package/dist/_chunks/relations-BRHithi8.js.map +0 -1
  177. package/dist/_chunks/relations-B_VLk-DD.mjs.map +0 -1
  178. package/dist/admin/src/preview/constants.d.ts +0 -1
  179. package/dist/server/src/preview/constants.d.ts +0 -2
  180. package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -10,8 +10,7 @@ const qs = require("qs");
10
10
  const slugify = require("@sindresorhus/slugify");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
- if (e && e.__esModule)
14
- return e;
13
+ if (e && e.__esModule) return e;
15
14
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
16
15
  if (e) {
17
16
  for (const k in e) {
@@ -33,10 +32,10 @@ const isNil__default = /* @__PURE__ */ _interopDefault(isNil);
33
32
  const ___default = /* @__PURE__ */ _interopDefault(_);
34
33
  const qs__default = /* @__PURE__ */ _interopDefault(qs);
35
34
  const slugify__default = /* @__PURE__ */ _interopDefault(slugify);
36
- const getService$1 = (name) => {
35
+ const getService$2 = (name) => {
37
36
  return strapi.plugin("content-manager").service(name);
38
37
  };
39
- function getService(strapi2, name) {
38
+ function getService$1(strapi2, name) {
40
39
  return strapi2.service(`plugin::content-manager.${name}`);
41
40
  }
42
41
  const historyRestoreVersionSchema = yup__namespace.object().shape({
@@ -72,7 +71,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
72
71
  if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
73
72
  throw new strapiUtils.errors.ForbiddenError("contentType and documentId are required");
74
73
  }
75
- const permissionChecker2 = getService$1("permission-checker").create({
74
+ const permissionChecker2 = getService$2("permission-checker").create({
76
75
  userAbility: ctx.state.userAbility,
77
76
  model: ctx.query.contentType
78
77
  });
@@ -80,7 +79,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
80
79
  return ctx.forbidden();
81
80
  }
82
81
  const query = await permissionChecker2.sanitizeQuery(ctx.query);
83
- const { results, pagination } = await getService(strapi2, "history").findVersionsPage({
82
+ const { results, pagination } = await getService$1(strapi2, "history").findVersionsPage({
84
83
  query: {
85
84
  ...query,
86
85
  ...getValidPagination({ page: query.page, pageSize: query.pageSize })
@@ -105,14 +104,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
105
104
  async restoreVersion(ctx) {
106
105
  const request = ctx.request;
107
106
  await validateRestoreVersion(request.body, "contentType is required");
108
- const permissionChecker2 = getService$1("permission-checker").create({
107
+ const permissionChecker2 = getService$2("permission-checker").create({
109
108
  userAbility: ctx.state.userAbility,
110
109
  model: request.body.contentType
111
110
  });
112
111
  if (permissionChecker2.cannot.update()) {
113
112
  throw new strapiUtils.errors.ForbiddenError();
114
113
  }
115
- const restoredDocument = await getService(strapi2, "history").restoreVersion(
114
+ const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
116
115
  request.params.versionId
117
116
  );
118
117
  return {
@@ -121,7 +120,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
121
120
  }
122
121
  };
123
122
  };
124
- const controllers$1 = {
123
+ const controllers$2 = {
125
124
  "history-version": createHistoryVersionController
126
125
  /**
127
126
  * Casting is needed because the types aren't aware that Strapi supports
@@ -167,8 +166,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
167
166
  };
168
167
  const getRelationRestoreValue = async (versionRelationData, attribute) => {
169
168
  if (Array.isArray(versionRelationData)) {
170
- if (versionRelationData.length === 0)
171
- return versionRelationData;
169
+ if (versionRelationData.length === 0) return versionRelationData;
172
170
  const existingAndMissingRelations = await Promise.all(
173
171
  versionRelationData.map((relation) => {
174
172
  return strapi2.documents(attribute.target).findOne({
@@ -203,8 +201,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
203
201
  const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
204
202
  const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
205
203
  const getLocaleDictionary = async () => {
206
- if (!localesService)
207
- return {};
204
+ if (!localesService) return {};
208
205
  const locales = await localesService.find() || [];
209
206
  return locales.reduce(
210
207
  (acc, locale) => {
@@ -228,6 +225,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
228
225
  const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
229
226
  return documentMetadataService.getStatus(document, meta.availableStatus);
230
227
  };
228
+ const getComponentFields = (componentUID) => {
229
+ return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
230
+ (fieldsAcc, [key, attribute]) => {
231
+ if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
232
+ fieldsAcc.push(key);
233
+ }
234
+ return fieldsAcc;
235
+ },
236
+ []
237
+ );
238
+ };
231
239
  const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
232
240
  const model = strapi2.getModel(uid2);
233
241
  const attributes = Object.entries(model.attributes);
@@ -251,13 +259,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
251
259
  }
252
260
  case "component": {
253
261
  const populate = getDeepPopulate2(attribute.component);
254
- acc[attributeName] = { populate };
262
+ acc[attributeName] = {
263
+ populate,
264
+ [fieldSelector]: getComponentFields(attribute.component)
265
+ };
255
266
  break;
256
267
  }
257
268
  case "dynamiczone": {
258
269
  const populatedComponents = (attribute.components || []).reduce(
259
270
  (acc2, componentUID) => {
260
- acc2[componentUID] = { populate: getDeepPopulate2(componentUID) };
271
+ acc2[componentUID] = {
272
+ populate: getDeepPopulate2(componentUID),
273
+ [fieldSelector]: getComponentFields(componentUID)
274
+ };
261
275
  return acc2;
262
276
  },
263
277
  {}
@@ -370,7 +384,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
370
384
  const attributeValue = entry.data[attributeKey];
371
385
  const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
372
386
  if (attributeSchema.type === "media") {
373
- const permissionChecker2 = getService$1("permission-checker").create({
387
+ const permissionChecker2 = getService$2("permission-checker").create({
374
388
  userAbility: params.state.userAbility,
375
389
  model: "plugin::upload.file"
376
390
  });
@@ -411,7 +425,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
411
425
  [attributeKey]: adminUsers
412
426
  };
413
427
  }
414
- const permissionChecker2 = getService$1("permission-checker").create({
428
+ const permissionChecker2 = getService$2("permission-checker").create({
415
429
  userAbility: params.state.userAbility,
416
430
  model: attributeSchema.target
417
431
  });
@@ -587,7 +601,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
587
601
  onCommit(async () => {
588
602
  for (const entry of localeEntries) {
589
603
  const status = await serviceUtils.getVersionStatus(uid2, entry);
590
- await getService(strapi2, "history").createVersion({
604
+ await getService$1(strapi2, "history").createVersion({
591
605
  contentType: uid2,
592
606
  data: fp.omit(FIELDS_TO_IGNORE, entry),
593
607
  relatedDocumentId: documentId,
@@ -600,15 +614,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
600
614
  });
601
615
  return result;
602
616
  });
603
- state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
617
+ state.deleteExpiredJob = nodeSchedule.scheduleJob("historyDaily", "0 0 * * *", () => {
604
618
  const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
605
619
  const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
606
620
  strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
607
621
  where: {
608
622
  created_at: {
609
- $lt: expirationDate.toISOString()
623
+ $lt: expirationDate
610
624
  }
611
625
  }
626
+ }).catch((error) => {
627
+ if (error instanceof Error) {
628
+ strapi2.log.error("Error deleting expired history versions", error.message);
629
+ }
612
630
  });
613
631
  });
614
632
  state.isInitialized = true;
@@ -620,17 +638,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
620
638
  }
621
639
  };
622
640
  };
623
- const services$1 = {
641
+ const services$2 = {
624
642
  history: createHistoryService,
625
643
  lifecycles: createLifecyclesService
626
644
  };
627
- const info = { pluginName: "content-manager", type: "admin" };
645
+ const info$1 = { pluginName: "content-manager", type: "admin" };
628
646
  const historyVersionRouter = {
629
647
  type: "admin",
630
648
  routes: [
631
649
  {
632
650
  method: "GET",
633
- info,
651
+ info: info$1,
634
652
  path: "/history-versions",
635
653
  handler: "history-version.findMany",
636
654
  config: {
@@ -639,7 +657,7 @@ const historyVersionRouter = {
639
657
  },
640
658
  {
641
659
  method: "PUT",
642
- info,
660
+ info: info$1,
643
661
  path: "/history-versions/:versionId/restore",
644
662
  handler: "history-version.restoreVersion",
645
663
  config: {
@@ -648,7 +666,7 @@ const historyVersionRouter = {
648
666
  }
649
667
  ]
650
668
  };
651
- const routes$1 = {
669
+ const routes$2 = {
652
670
  "history-version": historyVersionRouter
653
671
  };
654
672
  const historyVersion = {
@@ -702,14 +720,14 @@ const getFeature$1 = () => {
702
720
  strapi2.get("models").add(historyVersion);
703
721
  },
704
722
  bootstrap({ strapi: strapi2 }) {
705
- getService(strapi2, "lifecycles").bootstrap();
723
+ getService$1(strapi2, "lifecycles").bootstrap();
706
724
  },
707
725
  destroy({ strapi: strapi2 }) {
708
- getService(strapi2, "lifecycles").destroy();
726
+ getService$1(strapi2, "lifecycles").destroy();
709
727
  },
710
- controllers: controllers$1,
711
- services: services$1,
712
- routes: routes$1
728
+ controllers: controllers$2,
729
+ services: services$2,
730
+ routes: routes$2
713
731
  };
714
732
  }
715
733
  return {
@@ -719,33 +737,213 @@ const getFeature$1 = () => {
719
737
  };
720
738
  };
721
739
  const history = getFeature$1();
722
- const register = async ({ strapi: strapi2 }) => {
723
- await history.register?.({ strapi: strapi2 });
740
+ const info = { pluginName: "content-manager", type: "admin" };
741
+ const previewRouter = {
742
+ type: "admin",
743
+ routes: [
744
+ {
745
+ method: "GET",
746
+ info,
747
+ path: "/preview/url/:contentType",
748
+ handler: "preview.getPreviewUrl",
749
+ config: {
750
+ policies: ["admin::isAuthenticatedAdmin"]
751
+ }
752
+ }
753
+ ]
724
754
  };
725
- const ALLOWED_WEBHOOK_EVENTS = {
726
- ENTRY_PUBLISH: "entry.publish",
727
- ENTRY_UNPUBLISH: "entry.unpublish"
755
+ const routes$1 = {
756
+ preview: previewRouter
728
757
  };
729
- const FEATURE_ID = "preview";
730
- const getFeature = () => {
731
- if (!strapi.features.future.isEnabled(FEATURE_ID)) {
732
- return {};
758
+ function getService(strapi2, name) {
759
+ return strapi2.service(`plugin::content-manager.${name}`);
760
+ }
761
+ const getPreviewUrlSchema = yup__namespace.object().shape({
762
+ // Will be undefined for single types
763
+ documentId: yup__namespace.string(),
764
+ locale: yup__namespace.string().nullable(),
765
+ status: yup__namespace.string()
766
+ }).required();
767
+ const validatePreviewUrl = async (strapi2, uid2, params) => {
768
+ await strapiUtils.validateYupSchema(getPreviewUrlSchema)(params);
769
+ const newParams = fp.pick(["documentId", "locale", "status"], params);
770
+ const model = strapi2.getModel(uid2);
771
+ if (!model || model.modelType !== "contentType") {
772
+ throw new strapiUtils.errors.ValidationError("Invalid content type");
773
+ }
774
+ const isSingleType = model?.kind === "singleType";
775
+ if (!isSingleType && !params.documentId) {
776
+ throw new strapiUtils.errors.ValidationError("documentId is required for Collection Types");
733
777
  }
778
+ if (isSingleType) {
779
+ const doc = await strapi2.documents(uid2).findFirst();
780
+ if (!doc) {
781
+ throw new strapiUtils.errors.NotFoundError("Document not found");
782
+ }
783
+ newParams.documentId = doc?.documentId;
784
+ }
785
+ if (!newParams.status) {
786
+ const isDPEnabled = model?.options?.draftAndPublish;
787
+ newParams.status = isDPEnabled ? "draft" : "published";
788
+ }
789
+ return newParams;
790
+ };
791
+ const createPreviewController = () => {
734
792
  return {
735
- bootstrap() {
736
- console.log("Bootstrapping preview server");
793
+ /**
794
+ * Transforms an entry into a preview URL, so that it can be previewed
795
+ * in the Content Manager.
796
+ */
797
+ async getPreviewUrl(ctx) {
798
+ const uid2 = ctx.params.contentType;
799
+ const query = ctx.request.query;
800
+ const params = await validatePreviewUrl(strapi, uid2, query);
801
+ const previewService = getService(strapi, "preview");
802
+ const url = await previewService.getPreviewUrl(uid2, params);
803
+ if (!url) {
804
+ ctx.status = 204;
805
+ }
806
+ return {
807
+ data: { url }
808
+ };
809
+ }
810
+ };
811
+ };
812
+ const controllers$1 = {
813
+ preview: createPreviewController
814
+ /**
815
+ * Casting is needed because the types aren't aware that Strapi supports
816
+ * passing a controller factory as the value, instead of a controller object directly
817
+ */
818
+ };
819
+ const createPreviewService = ({ strapi: strapi2 }) => {
820
+ const config = getService(strapi2, "preview-config");
821
+ return {
822
+ async getPreviewUrl(uid2, params) {
823
+ const handler = config.getPreviewHandler();
824
+ try {
825
+ return handler(uid2, params);
826
+ } catch (error) {
827
+ strapi2.log.error(`Failed to get preview URL: ${error}`);
828
+ throw new strapiUtils.errors.ApplicationError("Failed to get preview URL");
829
+ }
830
+ return;
737
831
  }
738
832
  };
739
833
  };
834
+ const extendMiddlewareConfiguration = (middleware = { name: "", config: {} }) => {
835
+ const middlewares = strapi.config.get("middlewares");
836
+ const configuredMiddlewares = middlewares.map((currentMiddleware) => {
837
+ if (currentMiddleware === middleware.name) {
838
+ return middleware;
839
+ }
840
+ if (currentMiddleware.name === middleware.name) {
841
+ return fp.mergeWith(
842
+ (objValue, srcValue) => {
843
+ if (Array.isArray(objValue)) {
844
+ return objValue.concat(srcValue);
845
+ }
846
+ return void 0;
847
+ },
848
+ currentMiddleware,
849
+ middleware
850
+ );
851
+ }
852
+ return currentMiddleware;
853
+ });
854
+ strapi.config.set("middlewares", configuredMiddlewares);
855
+ };
856
+ const createPreviewConfigService = ({ strapi: strapi2 }) => {
857
+ return {
858
+ register() {
859
+ if (!this.isEnabled()) {
860
+ return;
861
+ }
862
+ const config = strapi2.config.get("admin.preview");
863
+ if (config.config?.allowedOrigins) {
864
+ extendMiddlewareConfiguration({
865
+ name: "strapi::security",
866
+ config: {
867
+ contentSecurityPolicy: {
868
+ directives: {
869
+ "frame-src": config.config.allowedOrigins
870
+ }
871
+ }
872
+ }
873
+ });
874
+ }
875
+ },
876
+ isEnabled() {
877
+ const config = strapi2.config.get("admin.preview");
878
+ if (!config) {
879
+ return false;
880
+ }
881
+ return config?.enabled ?? true;
882
+ },
883
+ /**
884
+ * Validate if the configuration is valid
885
+ */
886
+ validate() {
887
+ if (!this.isEnabled()) {
888
+ return;
889
+ }
890
+ const handler = this.getPreviewHandler();
891
+ if (typeof handler !== "function") {
892
+ throw new strapiUtils.errors.ValidationError(
893
+ "Preview configuration is invalid. Handler must be a function"
894
+ );
895
+ }
896
+ },
897
+ /**
898
+ * Utility to get the preview handler from the configuration
899
+ */
900
+ getPreviewHandler() {
901
+ const config = strapi2.config.get("admin.preview");
902
+ const emptyHandler = () => {
903
+ return void 0;
904
+ };
905
+ if (!this.isEnabled()) {
906
+ return emptyHandler;
907
+ }
908
+ return config?.config?.handler || emptyHandler;
909
+ }
910
+ };
911
+ };
912
+ const services$1 = {
913
+ preview: createPreviewService,
914
+ "preview-config": createPreviewConfigService
915
+ };
916
+ const getFeature = () => {
917
+ return {
918
+ register() {
919
+ const config = getService(strapi, "preview-config");
920
+ config.validate();
921
+ config.register();
922
+ },
923
+ bootstrap() {
924
+ },
925
+ routes: routes$1,
926
+ controllers: controllers$1,
927
+ services: services$1
928
+ };
929
+ };
740
930
  const preview = getFeature();
931
+ const register = async ({ strapi: strapi2 }) => {
932
+ await history.register?.({ strapi: strapi2 });
933
+ await preview.register?.({ strapi: strapi2 });
934
+ };
935
+ const ALLOWED_WEBHOOK_EVENTS = {
936
+ ENTRY_PUBLISH: "entry.publish",
937
+ ENTRY_UNPUBLISH: "entry.unpublish"
938
+ };
741
939
  const bootstrap = async () => {
742
940
  Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
743
941
  strapi.get("webhookStore").addAllowedEvent(key, value);
744
942
  });
745
- getService$1("field-sizes").setCustomFieldInputSizes();
746
- await getService$1("components").syncConfigurations();
747
- await getService$1("content-types").syncConfigurations();
748
- await getService$1("permission").registerPermissions();
943
+ getService$2("field-sizes").setCustomFieldInputSizes();
944
+ await getService$2("components").syncConfigurations();
945
+ await getService$2("content-types").syncConfigurations();
946
+ await getService$2("permission").registerPermissions();
749
947
  await history.bootstrap?.({ strapi });
750
948
  await preview.bootstrap?.({ strapi });
751
949
  };
@@ -1237,7 +1435,8 @@ const admin = {
1237
1435
  };
1238
1436
  const routes = {
1239
1437
  admin,
1240
- ...history.routes ? history.routes : {}
1438
+ ...history.routes ? history.routes : {},
1439
+ ...preview.routes ? preview.routes : {}
1241
1440
  };
1242
1441
  const hasPermissionsSchema = strapiUtils.yup.object({
1243
1442
  actions: strapiUtils.yup.array().of(strapiUtils.yup.string()),
@@ -1300,8 +1499,7 @@ const isSortable = (schema, name) => {
1300
1499
  if (!___default.default.has(schema.attributes, name)) {
1301
1500
  return false;
1302
1501
  }
1303
- if (schema.modelType === "component" && name === "id")
1304
- return false;
1502
+ if (schema.modelType === "component" && name === "id") return false;
1305
1503
  const attribute = schema.attributes[name];
1306
1504
  if (NON_SORTABLES.includes(attribute.type)) {
1307
1505
  return false;
@@ -1446,8 +1644,7 @@ const createDefaultSettings = async (schema) => {
1446
1644
  };
1447
1645
  };
1448
1646
  const syncSettings = async (configuration, schema) => {
1449
- if (fp.isEmpty(configuration.settings))
1450
- return createDefaultSettings(schema);
1647
+ if (fp.isEmpty(configuration.settings)) return createDefaultSettings(schema);
1451
1648
  const defaultField = getDefaultMainField(schema);
1452
1649
  const { mainField = defaultField, defaultSortBy = defaultField } = configuration.settings || {};
1453
1650
  return {
@@ -1494,7 +1691,7 @@ const createMetadasSchema = (schema) => {
1494
1691
  if (!value) {
1495
1692
  return strapiUtils.yup.string();
1496
1693
  }
1497
- const targetSchema = getService$1("content-types").findContentType(
1694
+ const targetSchema = getService$2("content-types").findContentType(
1498
1695
  schema.attributes[key].targetModel
1499
1696
  );
1500
1697
  if (!targetSchema) {
@@ -1623,8 +1820,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1623
1820
  }
1624
1821
  switch (attribute.type) {
1625
1822
  case "relation": {
1626
- if (canCreate(attributePath))
1627
- return body2;
1823
+ if (canCreate(attributePath)) return body2;
1628
1824
  return fp.set(attributePath, { set: [] }, body2);
1629
1825
  }
1630
1826
  case "component": {
@@ -1634,8 +1830,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1634
1830
  ]);
1635
1831
  }
1636
1832
  default: {
1637
- if (canCreate(attributePath))
1638
- return body2;
1833
+ if (canCreate(attributePath)) return body2;
1639
1834
  return fp.set(attributePath, null, body2);
1640
1835
  }
1641
1836
  }
@@ -1663,7 +1858,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
1663
1858
  }
1664
1859
  };
1665
1860
  const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
1666
- const documentMetadata2 = getService$1("document-metadata");
1861
+ const documentMetadata2 = getService$2("document-metadata");
1667
1862
  const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
1668
1863
  let {
1669
1864
  meta: { availableLocales, availableStatus }
@@ -1689,8 +1884,8 @@ const createDocument = async (ctx, opts) => {
1689
1884
  const { userAbility, user } = ctx.state;
1690
1885
  const { model } = ctx.params;
1691
1886
  const { body } = ctx.request;
1692
- const documentManager2 = getService$1("document-manager");
1693
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1887
+ const documentManager2 = getService$2("document-manager");
1888
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1694
1889
  if (permissionChecker2.cannot.create()) {
1695
1890
  throw new strapiUtils.errors.ForbiddenError();
1696
1891
  }
@@ -1710,13 +1905,13 @@ const updateDocument = async (ctx, opts) => {
1710
1905
  const { userAbility, user } = ctx.state;
1711
1906
  const { id, model } = ctx.params;
1712
1907
  const { body } = ctx.request;
1713
- const documentManager2 = getService$1("document-manager");
1714
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1908
+ const documentManager2 = getService$2("document-manager");
1909
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1715
1910
  if (permissionChecker2.cannot.update()) {
1716
1911
  throw new strapiUtils.errors.ForbiddenError();
1717
1912
  }
1718
1913
  const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
1719
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
1914
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1720
1915
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1721
1916
  const [documentVersion, documentExists] = await Promise.all([
1722
1917
  documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
@@ -1747,14 +1942,14 @@ const collectionTypes = {
1747
1942
  const { userAbility } = ctx.state;
1748
1943
  const { model } = ctx.params;
1749
1944
  const { query } = ctx.request;
1750
- const documentMetadata2 = getService$1("document-metadata");
1751
- const documentManager2 = getService$1("document-manager");
1752
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1945
+ const documentMetadata2 = getService$2("document-metadata");
1946
+ const documentManager2 = getService$2("document-manager");
1947
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1753
1948
  if (permissionChecker2.cannot.read()) {
1754
1949
  return ctx.forbidden();
1755
1950
  }
1756
1951
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
1757
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1952
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1758
1953
  const { locale, status } = await getDocumentLocaleAndStatus(query, model);
1759
1954
  const { results: documents, pagination } = await documentManager2.findPage(
1760
1955
  { ...permissionQuery, populate, locale, status },
@@ -1783,13 +1978,13 @@ const collectionTypes = {
1783
1978
  async findOne(ctx) {
1784
1979
  const { userAbility } = ctx.state;
1785
1980
  const { model, id } = ctx.params;
1786
- const documentManager2 = getService$1("document-manager");
1787
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1981
+ const documentManager2 = getService$2("document-manager");
1982
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1788
1983
  if (permissionChecker2.cannot.read()) {
1789
1984
  return ctx.forbidden();
1790
1985
  }
1791
1986
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
1792
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1987
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1793
1988
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
1794
1989
  const version = await documentManager2.findOne(id, model, {
1795
1990
  populate,
@@ -1820,7 +2015,7 @@ const collectionTypes = {
1820
2015
  async create(ctx) {
1821
2016
  const { userAbility } = ctx.state;
1822
2017
  const { model } = ctx.params;
1823
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2018
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1824
2019
  const [totalEntries, document] = await Promise.all([
1825
2020
  strapi.db.query(model).count(),
1826
2021
  createDocument(ctx)
@@ -1841,7 +2036,7 @@ const collectionTypes = {
1841
2036
  async update(ctx) {
1842
2037
  const { userAbility } = ctx.state;
1843
2038
  const { model } = ctx.params;
1844
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2039
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1845
2040
  const updatedVersion = await updateDocument(ctx);
1846
2041
  const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
1847
2042
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
@@ -1850,13 +2045,13 @@ const collectionTypes = {
1850
2045
  const { userAbility, user } = ctx.state;
1851
2046
  const { model, sourceId: id } = ctx.params;
1852
2047
  const { body } = ctx.request;
1853
- const documentManager2 = getService$1("document-manager");
1854
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2048
+ const documentManager2 = getService$2("document-manager");
2049
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1855
2050
  if (permissionChecker2.cannot.create()) {
1856
2051
  return ctx.forbidden();
1857
2052
  }
1858
2053
  const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
1859
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2054
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1860
2055
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1861
2056
  const document = await documentManager2.findOne(id, model, {
1862
2057
  populate,
@@ -1895,13 +2090,13 @@ const collectionTypes = {
1895
2090
  async delete(ctx) {
1896
2091
  const { userAbility } = ctx.state;
1897
2092
  const { id, model } = ctx.params;
1898
- const documentManager2 = getService$1("document-manager");
1899
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2093
+ const documentManager2 = getService$2("document-manager");
2094
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1900
2095
  if (permissionChecker2.cannot.delete()) {
1901
2096
  return ctx.forbidden();
1902
2097
  }
1903
2098
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
1904
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2099
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1905
2100
  const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
1906
2101
  const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
1907
2102
  if (documentLocales.length === 0) {
@@ -1923,14 +2118,14 @@ const collectionTypes = {
1923
2118
  const { userAbility } = ctx.state;
1924
2119
  const { id, model } = ctx.params;
1925
2120
  const { body } = ctx.request;
1926
- const documentManager2 = getService$1("document-manager");
1927
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2121
+ const documentManager2 = getService$2("document-manager");
2122
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1928
2123
  if (permissionChecker2.cannot.publish()) {
1929
2124
  return ctx.forbidden();
1930
2125
  }
1931
2126
  const publishedDocument = await strapi.db.transaction(async () => {
1932
2127
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1933
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2128
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1934
2129
  let document;
1935
2130
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1936
2131
  const isCreate = fp.isNil(id);
@@ -1978,13 +2173,13 @@ const collectionTypes = {
1978
2173
  const { body } = ctx.request;
1979
2174
  const { documentIds } = body;
1980
2175
  await validateBulkActionInput(body);
1981
- const documentManager2 = getService$1("document-manager");
1982
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2176
+ const documentManager2 = getService$2("document-manager");
2177
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1983
2178
  if (permissionChecker2.cannot.publish()) {
1984
2179
  return ctx.forbidden();
1985
2180
  }
1986
2181
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1987
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2182
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1988
2183
  const { locale } = await getDocumentLocaleAndStatus(body, model, {
1989
2184
  allowMultipleLocales: true
1990
2185
  });
@@ -2009,8 +2204,8 @@ const collectionTypes = {
2009
2204
  const { body } = ctx.request;
2010
2205
  const { documentIds } = body;
2011
2206
  await validateBulkActionInput(body);
2012
- const documentManager2 = getService$1("document-manager");
2013
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2207
+ const documentManager2 = getService$2("document-manager");
2208
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2014
2209
  if (permissionChecker2.cannot.unpublish()) {
2015
2210
  return ctx.forbidden();
2016
2211
  }
@@ -2039,8 +2234,8 @@ const collectionTypes = {
2039
2234
  const {
2040
2235
  body: { discardDraft, ...body }
2041
2236
  } = ctx.request;
2042
- const documentManager2 = getService$1("document-manager");
2043
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2237
+ const documentManager2 = getService$2("document-manager");
2238
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2044
2239
  if (permissionChecker2.cannot.unpublish()) {
2045
2240
  return ctx.forbidden();
2046
2241
  }
@@ -2048,7 +2243,7 @@ const collectionTypes = {
2048
2243
  return ctx.forbidden();
2049
2244
  }
2050
2245
  const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
2051
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2246
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2052
2247
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2053
2248
  const document = await documentManager2.findOne(id, model, {
2054
2249
  populate,
@@ -2079,13 +2274,13 @@ const collectionTypes = {
2079
2274
  const { userAbility } = ctx.state;
2080
2275
  const { id, model } = ctx.params;
2081
2276
  const { body } = ctx.request;
2082
- const documentManager2 = getService$1("document-manager");
2083
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2277
+ const documentManager2 = getService$2("document-manager");
2278
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2084
2279
  if (permissionChecker2.cannot.discard()) {
2085
2280
  return ctx.forbidden();
2086
2281
  }
2087
2282
  const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
2088
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2283
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2089
2284
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2090
2285
  const document = await documentManager2.findOne(id, model, {
2091
2286
  populate,
@@ -2110,13 +2305,13 @@ const collectionTypes = {
2110
2305
  const { query, body } = ctx.request;
2111
2306
  const { documentIds } = body;
2112
2307
  await validateBulkActionInput(body);
2113
- const documentManager2 = getService$1("document-manager");
2114
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2308
+ const documentManager2 = getService$2("document-manager");
2309
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2115
2310
  if (permissionChecker2.cannot.delete()) {
2116
2311
  return ctx.forbidden();
2117
2312
  }
2118
2313
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
2119
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2314
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2120
2315
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2121
2316
  const documentLocales = await documentManager2.findLocales(documentIds, model, {
2122
2317
  populate,
@@ -2137,13 +2332,13 @@ const collectionTypes = {
2137
2332
  async countDraftRelations(ctx) {
2138
2333
  const { userAbility } = ctx.state;
2139
2334
  const { model, id } = ctx.params;
2140
- const documentManager2 = getService$1("document-manager");
2141
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2335
+ const documentManager2 = getService$2("document-manager");
2336
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2142
2337
  if (permissionChecker2.cannot.read()) {
2143
2338
  return ctx.forbidden();
2144
2339
  }
2145
2340
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2146
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2341
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2147
2342
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
2148
2343
  const entity = await documentManager2.findOne(id, model, { populate, locale, status });
2149
2344
  if (!entity) {
@@ -2162,8 +2357,8 @@ const collectionTypes = {
2162
2357
  const ids = ctx.request.query.documentIds;
2163
2358
  const locale = ctx.request.query.locale;
2164
2359
  const { model } = ctx.params;
2165
- const documentManager2 = getService$1("document-manager");
2166
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2360
+ const documentManager2 = getService$2("document-manager");
2361
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2167
2362
  if (permissionChecker2.cannot.read()) {
2168
2363
  return ctx.forbidden();
2169
2364
  }
@@ -2187,13 +2382,13 @@ const collectionTypes = {
2187
2382
  };
2188
2383
  const components$1 = {
2189
2384
  findComponents(ctx) {
2190
- const components2 = getService$1("components").findAllComponents();
2191
- const { toDto } = getService$1("data-mapper");
2385
+ const components2 = getService$2("components").findAllComponents();
2386
+ const { toDto } = getService$2("data-mapper");
2192
2387
  ctx.body = { data: components2.map(toDto) };
2193
2388
  },
2194
2389
  async findComponentConfiguration(ctx) {
2195
2390
  const { uid: uid2 } = ctx.params;
2196
- const componentService = getService$1("components");
2391
+ const componentService = getService$2("components");
2197
2392
  const component = componentService.findComponent(uid2);
2198
2393
  if (!component) {
2199
2394
  return ctx.notFound("component.notFound");
@@ -2210,7 +2405,7 @@ const components$1 = {
2210
2405
  async updateComponentConfiguration(ctx) {
2211
2406
  const { uid: uid2 } = ctx.params;
2212
2407
  const { body } = ctx.request;
2213
- const componentService = getService$1("components");
2408
+ const componentService = getService$2("components");
2214
2409
  const component = componentService.findComponent(uid2);
2215
2410
  if (!component) {
2216
2411
  return ctx.notFound("component.notFound");
@@ -2244,12 +2439,12 @@ const contentTypes = {
2244
2439
  } catch (error) {
2245
2440
  return ctx.send({ error }, 400);
2246
2441
  }
2247
- const contentTypes2 = getService$1("content-types").findContentTypesByKind(kind);
2248
- const { toDto } = getService$1("data-mapper");
2442
+ const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
2443
+ const { toDto } = getService$2("data-mapper");
2249
2444
  ctx.body = { data: contentTypes2.map(toDto) };
2250
2445
  },
2251
2446
  async findContentTypesSettings(ctx) {
2252
- const { findAllContentTypes, findConfiguration } = getService$1("content-types");
2447
+ const { findAllContentTypes, findConfiguration } = getService$2("content-types");
2253
2448
  const contentTypes2 = await findAllContentTypes();
2254
2449
  const configurations = await Promise.all(
2255
2450
  contentTypes2.map(async (contentType) => {
@@ -2263,7 +2458,7 @@ const contentTypes = {
2263
2458
  },
2264
2459
  async findContentTypeConfiguration(ctx) {
2265
2460
  const { uid: uid2 } = ctx.params;
2266
- const contentTypeService = getService$1("content-types");
2461
+ const contentTypeService = getService$2("content-types");
2267
2462
  const contentType = await contentTypeService.findContentType(uid2);
2268
2463
  if (!contentType) {
2269
2464
  return ctx.notFound("contentType.notFound");
@@ -2285,13 +2480,13 @@ const contentTypes = {
2285
2480
  const { userAbility } = ctx.state;
2286
2481
  const { uid: uid2 } = ctx.params;
2287
2482
  const { body } = ctx.request;
2288
- const contentTypeService = getService$1("content-types");
2289
- const metricsService = getService$1("metrics");
2483
+ const contentTypeService = getService$2("content-types");
2484
+ const metricsService = getService$2("metrics");
2290
2485
  const contentType = await contentTypeService.findContentType(uid2);
2291
2486
  if (!contentType) {
2292
2487
  return ctx.notFound("contentType.notFound");
2293
2488
  }
2294
- if (!getService$1("permission").canConfigureContentType({ userAbility, contentType })) {
2489
+ if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
2295
2490
  return ctx.forbidden();
2296
2491
  }
2297
2492
  let input;
@@ -2324,10 +2519,10 @@ const contentTypes = {
2324
2519
  };
2325
2520
  const init = {
2326
2521
  getInitData(ctx) {
2327
- const { toDto } = getService$1("data-mapper");
2328
- const { findAllComponents } = getService$1("components");
2329
- const { getAllFieldSizes } = getService$1("field-sizes");
2330
- const { findAllContentTypes } = getService$1("content-types");
2522
+ const { toDto } = getService$2("data-mapper");
2523
+ const { findAllComponents } = getService$2("components");
2524
+ const { getAllFieldSizes } = getService$2("field-sizes");
2525
+ const { findAllContentTypes } = getService$2("content-types");
2331
2526
  ctx.body = {
2332
2527
  data: {
2333
2528
  fieldSizes: getAllFieldSizes(),
@@ -2363,7 +2558,7 @@ const addFiltersClause = (params, filtersClause) => {
2363
2558
  params.filters.$and.push(filtersClause);
2364
2559
  };
2365
2560
  const sanitizeMainField = (model, mainField, userAbility) => {
2366
- const permissionChecker2 = getService$1("permission-checker").create({
2561
+ const permissionChecker2 = getService$2("permission-checker").create({
2367
2562
  userAbility,
2368
2563
  model: model.uid
2369
2564
  });
@@ -2381,7 +2576,7 @@ const addStatusToRelations = async (targetUid, relations2) => {
2381
2576
  if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(targetUid))) {
2382
2577
  return relations2;
2383
2578
  }
2384
- const documentMetadata2 = getService$1("document-metadata");
2579
+ const documentMetadata2 = getService$2("document-metadata");
2385
2580
  if (!relations2.length) {
2386
2581
  return relations2;
2387
2582
  }
@@ -2428,8 +2623,7 @@ const validateStatus = (sourceUid, status) => {
2428
2623
  const sourceModel = strapi.getModel(sourceUid);
2429
2624
  const isDP = strapiUtils.contentTypes.hasDraftAndPublish;
2430
2625
  const isSourceDP = isDP(sourceModel);
2431
- if (!isSourceDP)
2432
- return { status: void 0 };
2626
+ if (!isSourceDP) return { status: void 0 };
2433
2627
  switch (status) {
2434
2628
  case "published":
2435
2629
  return { status: "published" };
@@ -2459,7 +2653,7 @@ const relations = {
2459
2653
  ctx.request?.query?.locale
2460
2654
  );
2461
2655
  const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
2462
- const permissionChecker2 = getService$1("permission-checker").create({
2656
+ const permissionChecker2 = getService$2("permission-checker").create({
2463
2657
  userAbility,
2464
2658
  model
2465
2659
  });
@@ -2484,7 +2678,7 @@ const relations = {
2484
2678
  where.id = id;
2485
2679
  }
2486
2680
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2487
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2681
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2488
2682
  const currentEntity = await strapi.db.query(model).findOne({
2489
2683
  where,
2490
2684
  populate
@@ -2499,7 +2693,7 @@ const relations = {
2499
2693
  }
2500
2694
  entryId = currentEntity.id;
2501
2695
  }
2502
- const modelConfig = isComponent2 ? await getService$1("components").findConfiguration(sourceSchema) : await getService$1("content-types").findConfiguration(sourceSchema);
2696
+ const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
2503
2697
  const targetSchema = strapi.getModel(targetUid);
2504
2698
  const mainField = fp.flow(
2505
2699
  fp.prop(`metadatas.${targetField}.edit.mainField`),
@@ -2553,7 +2747,7 @@ const relations = {
2553
2747
  }
2554
2748
  } = await this.extractAndValidateRequestInfo(ctx, id);
2555
2749
  const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
2556
- const permissionChecker2 = getService$1("permission-checker").create({
2750
+ const permissionChecker2 = getService$2("permission-checker").create({
2557
2751
  userAbility: ctx.state.userAbility,
2558
2752
  model: targetUid
2559
2753
  });
@@ -2632,7 +2826,7 @@ const relations = {
2632
2826
  } = await this.extractAndValidateRequestInfo(ctx, id);
2633
2827
  const { uid: sourceUid } = sourceSchema;
2634
2828
  const { uid: targetUid } = targetSchema;
2635
- const permissionQuery = await getService$1("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2829
+ const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2636
2830
  const dbQuery = strapi.db.query(sourceUid);
2637
2831
  const loadRelations = strapiUtils.relations.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
2638
2832
  const filters = {};
@@ -2673,10 +2867,10 @@ const relations = {
2673
2867
  }
2674
2868
  };
2675
2869
  const buildPopulateFromQuery = async (query, model) => {
2676
- return getService$1("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2870
+ return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2677
2871
  };
2678
2872
  const findDocument = async (query, uid2, opts = {}) => {
2679
- const documentManager2 = getService$1("document-manager");
2873
+ const documentManager2 = getService$2("document-manager");
2680
2874
  const populate = await buildPopulateFromQuery(query, uid2);
2681
2875
  return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
2682
2876
  };
@@ -2684,8 +2878,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
2684
2878
  const { user, userAbility } = ctx.state;
2685
2879
  const { model } = ctx.params;
2686
2880
  const { body, query } = ctx.request;
2687
- const documentManager2 = getService$1("document-manager");
2688
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2881
+ const documentManager2 = getService$2("document-manager");
2882
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2689
2883
  if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
2690
2884
  throw new strapiUtils.errors.ForbiddenError();
2691
2885
  }
@@ -2726,7 +2920,7 @@ const singleTypes = {
2726
2920
  const { userAbility } = ctx.state;
2727
2921
  const { model } = ctx.params;
2728
2922
  const { query = {} } = ctx.request;
2729
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2923
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2730
2924
  if (permissionChecker2.cannot.read()) {
2731
2925
  return ctx.forbidden();
2732
2926
  }
@@ -2760,7 +2954,7 @@ const singleTypes = {
2760
2954
  async createOrUpdate(ctx) {
2761
2955
  const { userAbility } = ctx.state;
2762
2956
  const { model } = ctx.params;
2763
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2957
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2764
2958
  const document = await createOrUpdateDocument(ctx);
2765
2959
  const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
2766
2960
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
@@ -2769,8 +2963,8 @@ const singleTypes = {
2769
2963
  const { userAbility } = ctx.state;
2770
2964
  const { model } = ctx.params;
2771
2965
  const { query = {} } = ctx.request;
2772
- const documentManager2 = getService$1("document-manager");
2773
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2966
+ const documentManager2 = getService$2("document-manager");
2967
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2774
2968
  if (permissionChecker2.cannot.delete()) {
2775
2969
  return ctx.forbidden();
2776
2970
  }
@@ -2798,8 +2992,8 @@ const singleTypes = {
2798
2992
  const { userAbility } = ctx.state;
2799
2993
  const { model } = ctx.params;
2800
2994
  const { query = {} } = ctx.request;
2801
- const documentManager2 = getService$1("document-manager");
2802
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2995
+ const documentManager2 = getService$2("document-manager");
2996
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2803
2997
  if (permissionChecker2.cannot.publish()) {
2804
2998
  return ctx.forbidden();
2805
2999
  }
@@ -2827,8 +3021,8 @@ const singleTypes = {
2827
3021
  body: { discardDraft, ...body },
2828
3022
  query = {}
2829
3023
  } = ctx.request;
2830
- const documentManager2 = getService$1("document-manager");
2831
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3024
+ const documentManager2 = getService$2("document-manager");
3025
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2832
3026
  if (permissionChecker2.cannot.unpublish()) {
2833
3027
  return ctx.forbidden();
2834
3028
  }
@@ -2862,8 +3056,8 @@ const singleTypes = {
2862
3056
  const { userAbility } = ctx.state;
2863
3057
  const { model } = ctx.params;
2864
3058
  const { body, query = {} } = ctx.request;
2865
- const documentManager2 = getService$1("document-manager");
2866
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3059
+ const documentManager2 = getService$2("document-manager");
3060
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2867
3061
  if (permissionChecker2.cannot.discard()) {
2868
3062
  return ctx.forbidden();
2869
3063
  }
@@ -2886,8 +3080,8 @@ const singleTypes = {
2886
3080
  const { userAbility } = ctx.state;
2887
3081
  const { model } = ctx.params;
2888
3082
  const { query } = ctx.request;
2889
- const documentManager2 = getService$1("document-manager");
2890
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3083
+ const documentManager2 = getService$2("document-manager");
3084
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2891
3085
  const { locale } = await getDocumentLocaleAndStatus(query, model);
2892
3086
  if (permissionChecker2.cannot.read()) {
2893
3087
  return ctx.forbidden();
@@ -2911,7 +3105,7 @@ const uid$1 = {
2911
3105
  const { query = {} } = ctx.request;
2912
3106
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2913
3107
  await validateUIDField(contentTypeUID, field);
2914
- const uidService = getService$1("uid");
3108
+ const uidService = getService$2("uid");
2915
3109
  ctx.body = {
2916
3110
  data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
2917
3111
  };
@@ -2923,7 +3117,7 @@ const uid$1 = {
2923
3117
  const { query = {} } = ctx.request;
2924
3118
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2925
3119
  await validateUIDField(contentTypeUID, field);
2926
- const uidService = getService$1("uid");
3120
+ const uidService = getService$2("uid");
2927
3121
  const isAvailable = await uidService.checkUIDAvailability({
2928
3122
  contentTypeUID,
2929
3123
  field,
@@ -2944,7 +3138,8 @@ const controllers = {
2944
3138
  relations,
2945
3139
  "single-types": singleTypes,
2946
3140
  uid: uid$1,
2947
- ...history.controllers ? history.controllers : {}
3141
+ ...history.controllers ? history.controllers : {},
3142
+ ...preview.controllers ? preview.controllers : {}
2948
3143
  };
2949
3144
  const keys = {
2950
3145
  CONFIGURATION: "configuration"
@@ -3073,18 +3268,15 @@ async function syncMetadatas(configuration, schema) {
3073
3268
  ___default.default.set(updatedMeta, ["list", "searchable"], false);
3074
3269
  ___default.default.set(acc, [key], updatedMeta);
3075
3270
  }
3076
- if (!___default.default.has(edit, "mainField"))
3077
- return acc;
3271
+ if (!___default.default.has(edit, "mainField")) return acc;
3078
3272
  if (!isRelation$1(attr)) {
3079
3273
  ___default.default.set(updatedMeta, "edit", ___default.default.omit(edit, ["mainField"]));
3080
3274
  ___default.default.set(acc, [key], updatedMeta);
3081
3275
  return acc;
3082
3276
  }
3083
- if (edit.mainField === "id")
3084
- return acc;
3277
+ if (edit.mainField === "id") return acc;
3085
3278
  const targetSchema = getTargetSchema(attr.targetModel);
3086
- if (!targetSchema)
3087
- return acc;
3279
+ if (!targetSchema) return acc;
3088
3280
  if (!isSortable(targetSchema, edit.mainField) && !isListable(targetSchema, edit.mainField)) {
3089
3281
  ___default.default.set(updatedMeta, ["edit", "mainField"], getDefaultMainField(targetSchema));
3090
3282
  ___default.default.set(acc, [key], updatedMeta);
@@ -3095,12 +3287,12 @@ async function syncMetadatas(configuration, schema) {
3095
3287
  return ___default.default.assign(metasWithDefaults, updatedMetas);
3096
3288
  }
3097
3289
  const getTargetSchema = (targetModel) => {
3098
- return getService$1("content-types").findContentType(targetModel);
3290
+ return getService$2("content-types").findContentType(targetModel);
3099
3291
  };
3100
3292
  const DEFAULT_LIST_LENGTH = 4;
3101
3293
  const MAX_ROW_SIZE = 12;
3102
3294
  const isAllowedFieldSize = (type, size) => {
3103
- const { getFieldSize } = getService$1("field-sizes");
3295
+ const { getFieldSize } = getService$2("field-sizes");
3104
3296
  const fieldSize = getFieldSize(type);
3105
3297
  if (!fieldSize.isResizable && size !== fieldSize.default) {
3106
3298
  return false;
@@ -3108,7 +3300,7 @@ const isAllowedFieldSize = (type, size) => {
3108
3300
  return size <= MAX_ROW_SIZE;
3109
3301
  };
3110
3302
  const getDefaultFieldSize = (attribute) => {
3111
- const { hasFieldSize, getFieldSize } = getService$1("field-sizes");
3303
+ const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
3112
3304
  return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
3113
3305
  };
3114
3306
  async function createDefaultLayouts(schema) {
@@ -3129,8 +3321,7 @@ function createDefaultEditLayout(schema) {
3129
3321
  return appendToEditLayout([], keys2, schema);
3130
3322
  }
3131
3323
  function syncLayouts(configuration, schema) {
3132
- if (___default.default.isEmpty(configuration.layouts))
3133
- return createDefaultLayouts(schema);
3324
+ if (___default.default.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
3134
3325
  const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
3135
3326
  let cleanList = list.filter((attr) => isListable(schema, attr));
3136
3327
  const cleanEditRelations = editRelations.filter(
@@ -3141,9 +3332,8 @@ function syncLayouts(configuration, schema) {
3141
3332
  for (const row of edit) {
3142
3333
  const newRow = [];
3143
3334
  for (const el of row) {
3144
- if (!hasEditableAttribute(schema, el.name))
3145
- continue;
3146
- const { hasFieldSize } = getService$1("field-sizes");
3335
+ if (!hasEditableAttribute(schema, el.name)) continue;
3336
+ const { hasFieldSize } = getService$2("field-sizes");
3147
3337
  const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
3148
3338
  if (!isAllowedFieldSize(fieldType, el.size)) {
3149
3339
  elementsToReAppend.push(el.name);
@@ -3173,8 +3363,7 @@ function syncLayouts(configuration, schema) {
3173
3363
  };
3174
3364
  }
3175
3365
  const appendToEditLayout = (layout = [], keysToAppend, schema) => {
3176
- if (keysToAppend.length === 0)
3177
- return layout;
3366
+ if (keysToAppend.length === 0) return layout;
3178
3367
  let currentRowIndex = Math.max(layout.length - 1, 0);
3179
3368
  if (!layout[currentRowIndex]) {
3180
3369
  layout[currentRowIndex] = [];
@@ -3283,17 +3472,17 @@ const configurationService$1 = createConfigurationService({
3283
3472
  isComponent: true,
3284
3473
  prefix: STORE_KEY_PREFIX,
3285
3474
  getModels() {
3286
- const { toContentManagerModel } = getService$1("data-mapper");
3475
+ const { toContentManagerModel } = getService$2("data-mapper");
3287
3476
  return fp.mapValues(toContentManagerModel, strapi.components);
3288
3477
  }
3289
3478
  });
3290
3479
  const components = ({ strapi: strapi2 }) => ({
3291
3480
  findAllComponents() {
3292
- const { toContentManagerModel } = getService$1("data-mapper");
3481
+ const { toContentManagerModel } = getService$2("data-mapper");
3293
3482
  return Object.values(strapi2.components).map(toContentManagerModel);
3294
3483
  },
3295
3484
  findComponent(uid2) {
3296
- const { toContentManagerModel } = getService$1("data-mapper");
3485
+ const { toContentManagerModel } = getService$2("data-mapper");
3297
3486
  const component = strapi2.components[uid2];
3298
3487
  return fp.isNil(component) ? component : toContentManagerModel(component);
3299
3488
  },
@@ -3344,17 +3533,17 @@ const configurationService = createConfigurationService({
3344
3533
  storeUtils,
3345
3534
  prefix: "content_types",
3346
3535
  getModels() {
3347
- const { toContentManagerModel } = getService$1("data-mapper");
3536
+ const { toContentManagerModel } = getService$2("data-mapper");
3348
3537
  return fp.mapValues(toContentManagerModel, strapi.contentTypes);
3349
3538
  }
3350
3539
  });
3351
3540
  const service = ({ strapi: strapi2 }) => ({
3352
3541
  findAllContentTypes() {
3353
- const { toContentManagerModel } = getService$1("data-mapper");
3542
+ const { toContentManagerModel } = getService$2("data-mapper");
3354
3543
  return Object.values(strapi2.contentTypes).map(toContentManagerModel);
3355
3544
  },
3356
3545
  findContentType(uid2) {
3357
- const { toContentManagerModel } = getService$1("data-mapper");
3546
+ const { toContentManagerModel } = getService$2("data-mapper");
3358
3547
  const contentType = strapi2.contentTypes[uid2];
3359
3548
  return fp.isNil(contentType) ? contentType : toContentManagerModel(contentType);
3360
3549
  },
@@ -3383,7 +3572,7 @@ const service = ({ strapi: strapi2 }) => ({
3383
3572
  return this.findConfiguration(contentType);
3384
3573
  },
3385
3574
  findComponentsConfigurations(contentType) {
3386
- return getService$1("components").findComponentsConfigurations(contentType);
3575
+ return getService$2("components").findComponentsConfigurations(contentType);
3387
3576
  },
3388
3577
  syncConfigurations() {
3389
3578
  return configurationService.syncConfigurations();
@@ -3655,7 +3844,7 @@ const permission = ({ strapi: strapi2 }) => ({
3655
3844
  return userAbility.can(action);
3656
3845
  },
3657
3846
  async registerPermissions() {
3658
- const displayedContentTypes = getService$1("content-types").findDisplayedContentTypes();
3847
+ const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
3659
3848
  const contentTypesUids = displayedContentTypes.map(fp.prop("uid"));
3660
3849
  const actions = [
3661
3850
  {
@@ -3740,6 +3929,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
3740
3929
  if (initialPopulate) {
3741
3930
  return initialPopulate;
3742
3931
  }
3932
+ if (attributeName === "localizations") {
3933
+ const validationPopulate = getPopulateForValidation(model.uid);
3934
+ return {
3935
+ populate: validationPopulate.populate
3936
+ };
3937
+ }
3743
3938
  if (!isVisibleAttribute$1(model, attributeName)) {
3744
3939
  return true;
3745
3940
  }
@@ -3799,6 +3994,9 @@ const getDeepPopulate = (uid2, {
3799
3994
  return {};
3800
3995
  }
3801
3996
  const model = strapi.getModel(uid2);
3997
+ if (!model) {
3998
+ return {};
3999
+ }
3802
4000
  return Object.keys(model.attributes).reduce(
3803
4001
  (populateAcc, attributeName) => fp.merge(
3804
4002
  populateAcc,
@@ -3818,40 +4016,46 @@ const getDeepPopulate = (uid2, {
3818
4016
  {}
3819
4017
  );
3820
4018
  };
3821
- const getValidatableFieldsPopulate = (uid2, {
3822
- initialPopulate = {},
3823
- countMany = false,
3824
- countOne = false,
3825
- maxLevel = Infinity
3826
- } = {}, level = 1) => {
3827
- if (level > maxLevel) {
4019
+ const getPopulateForValidation = (uid2) => {
4020
+ const model = strapi.getModel(uid2);
4021
+ if (!model) {
3828
4022
  return {};
3829
4023
  }
3830
- const model = strapi.getModel(uid2);
3831
4024
  return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
3832
- if (!getDoesAttributeRequireValidation(attribute)) {
4025
+ if (isScalarAttribute(attribute)) {
4026
+ if (getDoesAttributeRequireValidation(attribute)) {
4027
+ populateAcc.fields = populateAcc.fields || [];
4028
+ populateAcc.fields.push(attributeName);
4029
+ }
3833
4030
  return populateAcc;
3834
4031
  }
3835
- if (isScalarAttribute(attribute)) {
3836
- return fp.merge(populateAcc, {
3837
- [attributeName]: true
3838
- });
4032
+ if (isComponent(attribute)) {
4033
+ const component = attribute.component;
4034
+ const componentResult = getPopulateForValidation(component);
4035
+ if (Object.keys(componentResult).length > 0) {
4036
+ populateAcc.populate = populateAcc.populate || {};
4037
+ populateAcc.populate[attributeName] = componentResult;
4038
+ }
4039
+ return populateAcc;
3839
4040
  }
3840
- return fp.merge(
3841
- populateAcc,
3842
- getPopulateFor(
3843
- attributeName,
3844
- model,
3845
- {
3846
- // @ts-expect-error - improve types
3847
- initialPopulate: initialPopulate?.[attributeName],
3848
- countMany,
3849
- countOne,
3850
- maxLevel
4041
+ if (isDynamicZone(attribute)) {
4042
+ const components2 = attribute.components;
4043
+ const componentsResult = (components2 || []).reduce(
4044
+ (acc, componentUID) => {
4045
+ const componentResult = getPopulateForValidation(componentUID);
4046
+ if (Object.keys(componentResult).length > 0) {
4047
+ acc[componentUID] = componentResult;
4048
+ }
4049
+ return acc;
3851
4050
  },
3852
- level
3853
- )
3854
- );
4051
+ {}
4052
+ );
4053
+ if (Object.keys(componentsResult).length > 0) {
4054
+ populateAcc.populate = populateAcc.populate || {};
4055
+ populateAcc.populate[attributeName] = { on: componentsResult };
4056
+ }
4057
+ }
4058
+ return populateAcc;
3855
4059
  }, {});
3856
4060
  };
3857
4061
  const getDeepPopulateDraftCount = (uid2) => {
@@ -3931,7 +4135,7 @@ const getQueryPopulate = async (uid2, query) => {
3931
4135
  return populateQuery;
3932
4136
  };
3933
4137
  const buildDeepPopulate = (uid2) => {
3934
- return getService$1("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
4138
+ return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
3935
4139
  };
3936
4140
  const populateBuilder = (uid2) => {
3937
4141
  let getInitialPopulate = async () => {
@@ -4093,7 +4297,6 @@ const AVAILABLE_LOCALES_FIELDS = [
4093
4297
  "locale",
4094
4298
  "updatedAt",
4095
4299
  "createdAt",
4096
- "status",
4097
4300
  "publishedAt",
4098
4301
  "documentId"
4099
4302
  ];
@@ -4114,36 +4317,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4114
4317
  /**
4115
4318
  * Returns available locales of a document for the current status
4116
4319
  */
4117
- async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
4320
+ async getAvailableLocales(uid2, version, allVersions) {
4118
4321
  const versionsByLocale = fp.groupBy("locale", allVersions);
4119
4322
  if (version.locale) {
4120
4323
  delete versionsByLocale[version.locale];
4121
4324
  }
4122
4325
  const model = strapi2.getModel(uid2);
4123
- const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
4124
- const traversalFunction = async (localeVersion) => strapiUtils.traverseEntity(
4125
- ({ key }, { remove }) => {
4126
- if (keysToKeep.includes(key)) {
4127
- return;
4128
- }
4129
- remove(key);
4130
- },
4131
- { schema: model, getModel: strapi2.getModel.bind(strapi2) },
4132
- // @ts-expect-error fix types DocumentVersion incompatible with Data
4133
- localeVersion
4134
- );
4135
4326
  const mappingResult = await strapiUtils.async.map(
4136
4327
  Object.values(versionsByLocale),
4137
4328
  async (localeVersions) => {
4138
- const mappedLocaleVersions = await strapiUtils.async.map(
4139
- localeVersions,
4140
- traversalFunction
4141
- );
4142
4329
  if (!strapiUtils.contentTypes.hasDraftAndPublish(model)) {
4143
- return mappedLocaleVersions[0];
4330
+ return localeVersions[0];
4144
4331
  }
4145
- const draftVersion = mappedLocaleVersions.find((v) => v.publishedAt === null);
4146
- const otherVersions = mappedLocaleVersions.filter((v) => v.id !== draftVersion?.id);
4332
+ const draftVersion = localeVersions.find((v) => v.publishedAt === null);
4333
+ const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
4147
4334
  if (!draftVersion) {
4148
4335
  return;
4149
4336
  }
@@ -4165,8 +4352,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4165
4352
  const matchStatus = status === "published" ? v.publishedAt !== null : v.publishedAt === null;
4166
4353
  return matchLocale && matchStatus;
4167
4354
  });
4168
- if (!availableStatus)
4169
- return availableStatus;
4355
+ if (!availableStatus) return availableStatus;
4170
4356
  return fp.pick(AVAILABLE_STATUS_FIELDS, availableStatus);
4171
4357
  },
4172
4358
  /**
@@ -4176,18 +4362,19 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4176
4362
  * @returns
4177
4363
  */
4178
4364
  async getManyAvailableStatus(uid2, documents) {
4179
- if (!documents.length)
4180
- return [];
4365
+ if (!documents.length) return [];
4181
4366
  const status = documents[0].publishedAt !== null ? "published" : "draft";
4182
- const locale = documents[0]?.locale;
4183
- const otherStatus = status === "published" ? "draft" : "published";
4184
- return strapi2.documents(uid2).findMany({
4185
- filters: {
4186
- documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) }
4187
- },
4188
- status: otherStatus,
4189
- locale,
4190
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4367
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4368
+ const where = {
4369
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4370
+ publishedAt: { $null: status === "published" }
4371
+ };
4372
+ if (locales.length) {
4373
+ where.locale = { $in: locales };
4374
+ }
4375
+ return strapi2.query(uid2).findMany({
4376
+ where,
4377
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4191
4378
  });
4192
4379
  },
4193
4380
  getStatus(version, otherDocumentStatuses) {
@@ -4204,10 +4391,8 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4204
4391
  } else if (otherVersion) {
4205
4392
  draftVersion = otherVersion;
4206
4393
  }
4207
- if (!draftVersion)
4208
- return CONTENT_MANAGER_STATUS.PUBLISHED;
4209
- if (!publishedVersion)
4210
- return CONTENT_MANAGER_STATUS.DRAFT;
4394
+ if (!draftVersion) return CONTENT_MANAGER_STATUS.PUBLISHED;
4395
+ if (!publishedVersion) return CONTENT_MANAGER_STATUS.DRAFT;
4211
4396
  const isDraftModified = getIsVersionLatestModification(draftVersion, publishedVersion);
4212
4397
  return isDraftModified ? CONTENT_MANAGER_STATUS.MODIFIED : CONTENT_MANAGER_STATUS.PUBLISHED;
4213
4398
  },
@@ -4215,11 +4400,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4215
4400
  // We could refactor this so the locales are only loaded when they're
4216
4401
  // needed. e.g. in the bulk locale action modal.
4217
4402
  async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
4218
- const populate = getValidatableFieldsPopulate(uid2);
4219
- const versions = await strapi2.db.query(uid2).findMany({
4220
- where: { documentId: version.documentId },
4403
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4404
+ const params = {
4221
4405
  populate: {
4222
- // Populate only fields that require validation for bulk locale actions
4223
4406
  ...populate,
4224
4407
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4225
4408
  createdBy: {
@@ -4228,9 +4411,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4228
4411
  updatedBy: {
4229
4412
  select: ["id", "firstname", "lastname", "email"]
4230
4413
  }
4414
+ },
4415
+ fields: fp.uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4416
+ filters: {
4417
+ documentId: version.documentId
4231
4418
  }
4232
- });
4233
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4419
+ };
4420
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4421
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4422
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4234
4423
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4235
4424
  return {
4236
4425
  availableLocales: availableLocalesResult,
@@ -4257,6 +4446,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4257
4446
  opts.availableStatus = false;
4258
4447
  }
4259
4448
  const meta = await this.getMetadata(uid2, document, opts);
4449
+ if (document.localizations) {
4450
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4451
+ document.localizations = document.localizations.map((d) => {
4452
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4453
+ return {
4454
+ ...d,
4455
+ status: this.getStatus(d, status ? [status] : [])
4456
+ };
4457
+ });
4458
+ }
4260
4459
  return {
4261
4460
  data: {
4262
4461
  ...document,
@@ -4474,7 +4673,8 @@ const services = {
4474
4673
  permission,
4475
4674
  "populate-builder": populateBuilder$1,
4476
4675
  uid,
4477
- ...history.services ? history.services : {}
4676
+ ...history.services ? history.services : {},
4677
+ ...preview.services ? preview.services : {}
4478
4678
  };
4479
4679
  const index = () => {
4480
4680
  return {