@strapi/content-manager 0.0.0-next.959c5589d0d3efa25d7ca014656d9ff48c173399 → 0.0.0-next.a4bb06d54b493ab973659d0200e0e42937988850

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 (195) 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-BLWQy8ru.js} +4 -5
  4. package/dist/_chunks/{ComponentConfigurationPage-gsCd80MU.js.map → ComponentConfigurationPage-BLWQy8ru.js.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs → ComponentConfigurationPage-CtIa3aa2.mjs} +3 -3
  6. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs.map → ComponentConfigurationPage-CtIa3aa2.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-BglmD_BF.mjs → EditConfigurationPage-DsPR2DVk.mjs} +3 -3
  11. package/dist/_chunks/{EditConfigurationPage-BglmD_BF.mjs.map → EditConfigurationPage-DsPR2DVk.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js → EditConfigurationPage-RQkymxCy.js} +4 -5
  13. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js.map → EditConfigurationPage-RQkymxCy.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-C4iTxUPU.js → EditViewPage-B-kExt8C.js} +38 -9
  15. package/dist/_chunks/EditViewPage-B-kExt8C.js.map +1 -0
  16. package/dist/_chunks/{EditViewPage-CiwVPMaK.mjs → EditViewPage-BPyVuPfM.mjs} +38 -8
  17. package/dist/_chunks/EditViewPage-BPyVuPfM.mjs.map +1 -0
  18. package/dist/_chunks/{Field-DhXEK8y1.js → Field-DPIsQRre.js} +177 -122
  19. package/dist/_chunks/Field-DPIsQRre.js.map +1 -0
  20. package/dist/_chunks/{Field-DIjL1b5d.mjs → Field-Dltnt1km.mjs} +175 -120
  21. package/dist/_chunks/Field-Dltnt1km.mjs.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-CwmJ4sWe.js → Form-BFi4MXMT.js} +5 -6
  25. package/dist/_chunks/{Form-CwmJ4sWe.js.map → Form-BFi4MXMT.js.map} +1 -1
  26. package/dist/_chunks/{Form-CmNesrvR.mjs → Form-C1IcWm1u.mjs} +3 -3
  27. package/dist/_chunks/{Form-CmNesrvR.mjs.map → Form-C1IcWm1u.mjs.map} +1 -1
  28. package/dist/_chunks/{History-D-99Wh30.mjs → History-04ChQ4pl.mjs} +50 -96
  29. package/dist/_chunks/History-04ChQ4pl.mjs.map +1 -0
  30. package/dist/_chunks/{History-BLCCNgCt.js → History-wjcK4L0C.js} +50 -97
  31. package/dist/_chunks/History-wjcK4L0C.js.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-JPWZz7Kg.mjs → ListConfigurationPage-BYqPYLSU.mjs} +6 -5
  33. package/dist/_chunks/ListConfigurationPage-BYqPYLSU.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-DxWpeZrO.js → ListConfigurationPage-CRbxIC3J.js} +6 -6
  35. package/dist/_chunks/ListConfigurationPage-CRbxIC3J.js.map +1 -0
  36. package/dist/_chunks/{ListViewPage-CIQekSFz.js → ListViewPage-D5NY9183.js} +64 -53
  37. package/dist/_chunks/ListViewPage-D5NY9183.js.map +1 -0
  38. package/dist/_chunks/{ListViewPage-DSK3f0ST.mjs → ListViewPage-FU2LBuhl.mjs} +63 -51
  39. package/dist/_chunks/ListViewPage-FU2LBuhl.mjs.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js → NoContentTypePage-BgQVE_Qb.js} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js.map → NoContentTypePage-BgQVE_Qb.js.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs → NoContentTypePage-DCKUkwb8.mjs} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs.map → NoContentTypePage-DCKUkwb8.mjs.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js → NoPermissionsPage-C5jwn70o.js} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js.map → NoPermissionsPage-C5jwn70o.js.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs → NoPermissionsPage-jqve7C8l.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs.map → NoPermissionsPage-jqve7C8l.mjs.map} +1 -1
  48. package/dist/_chunks/Preview-BMYN548c.mjs +294 -0
  49. package/dist/_chunks/Preview-BMYN548c.mjs.map +1 -0
  50. package/dist/_chunks/Preview-DaOihysv.js +312 -0
  51. package/dist/_chunks/Preview-DaOihysv.js.map +1 -0
  52. package/dist/_chunks/{Relations-eG-9p_qS.js → Relations-CTGM7Hv5.js} +10 -10
  53. package/dist/_chunks/Relations-CTGM7Hv5.js.map +1 -0
  54. package/dist/_chunks/{Relations-BBmhcWFV.mjs → Relations-gscPkxjF.mjs} +9 -8
  55. package/dist/_chunks/Relations-gscPkxjF.mjs.map +1 -0
  56. package/dist/_chunks/{en-Bm0D0IWz.js → en-BzQmavmK.js} +21 -4
  57. package/dist/_chunks/{en-Bm0D0IWz.js.map → en-BzQmavmK.js.map} +1 -1
  58. package/dist/_chunks/{en-DKV44jRb.mjs → en-CSxLmrh1.mjs} +21 -4
  59. package/dist/_chunks/{en-DKV44jRb.mjs.map → en-CSxLmrh1.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-Ca7YWlAA.js} +363 -193
  70. package/dist/_chunks/index-Ca7YWlAA.js.map +1 -0
  71. package/dist/_chunks/{index-BrUzbQ30.mjs → index-DqasUQ6Q.mjs} +366 -195
  72. package/dist/_chunks/index-DqasUQ6Q.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-lMc9i1-Z.js → layout-BW80JSCd.js} +5 -6
  78. package/dist/_chunks/{layout-lMc9i1-Z.js.map → layout-BW80JSCd.js.map} +1 -1
  79. package/dist/_chunks/{layout-_5-cXs34.mjs → layout-W3clJSCy.mjs} +4 -4
  80. package/dist/_chunks/{layout-_5-cXs34.mjs.map → layout-W3clJSCy.mjs.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-B_VLk-DD.mjs → relations-BlDkoeWh.mjs} +6 -3
  84. package/dist/_chunks/relations-BlDkoeWh.mjs.map +1 -0
  85. package/dist/_chunks/{relations-BRHithi8.js → relations-C9Usz9k5.js} +6 -3
  86. package/dist/_chunks/relations-C9Usz9k5.js.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 +2 -1
  94. package/dist/admin/index.js.map +1 -1
  95. package/dist/admin/index.mjs +5 -4
  96. package/dist/admin/src/content-manager.d.ts +3 -2
  97. package/dist/admin/src/exports.d.ts +1 -0
  98. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  99. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  100. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  101. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  102. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  103. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  104. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  105. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  106. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  107. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  108. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  109. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  110. package/dist/admin/src/preview/index.d.ts +1 -1
  111. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  112. package/dist/admin/src/preview/routes.d.ts +3 -0
  113. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  114. package/dist/admin/src/router.d.ts +1 -1
  115. package/dist/admin/src/services/api.d.ts +1 -1
  116. package/dist/admin/src/services/components.d.ts +2 -2
  117. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  118. package/dist/admin/src/services/documents.d.ts +16 -19
  119. package/dist/admin/src/services/init.d.ts +1 -1
  120. package/dist/admin/src/services/relations.d.ts +2 -2
  121. package/dist/admin/src/services/uid.d.ts +3 -3
  122. package/dist/server/index.js +516 -312
  123. package/dist/server/index.js.map +1 -1
  124. package/dist/server/index.mjs +517 -312
  125. package/dist/server/index.mjs.map +1 -1
  126. package/dist/server/src/controllers/index.d.ts.map +1 -1
  127. package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
  128. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  129. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  130. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  131. package/dist/server/src/history/services/history.d.ts +3 -3
  132. package/dist/server/src/history/services/history.d.ts.map +1 -1
  133. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  134. package/dist/server/src/history/services/utils.d.ts +6 -11
  135. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  136. package/dist/server/src/index.d.ts +3 -2
  137. package/dist/server/src/index.d.ts.map +1 -1
  138. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  139. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  140. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  141. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  142. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  143. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  144. package/dist/server/src/preview/index.d.ts.map +1 -1
  145. package/dist/server/src/preview/routes/index.d.ts +8 -0
  146. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  147. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  148. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  149. package/dist/server/src/preview/services/index.d.ts +16 -0
  150. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  151. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  152. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  153. package/dist/server/src/preview/services/preview.d.ts +12 -0
  154. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  155. package/dist/server/src/preview/utils.d.ts +19 -0
  156. package/dist/server/src/preview/utils.d.ts.map +1 -0
  157. package/dist/server/src/register.d.ts.map +1 -1
  158. package/dist/server/src/routes/index.d.ts.map +1 -1
  159. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  160. package/dist/server/src/services/document-metadata.d.ts +4 -2
  161. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  162. package/dist/server/src/services/index.d.ts +3 -2
  163. package/dist/server/src/services/index.d.ts.map +1 -1
  164. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  165. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  166. package/dist/server/src/services/utils/populate.d.ts +2 -2
  167. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  168. package/dist/shared/contracts/index.d.ts +1 -0
  169. package/dist/shared/contracts/index.d.ts.map +1 -1
  170. package/dist/shared/contracts/preview.d.ts +27 -0
  171. package/dist/shared/contracts/preview.d.ts.map +1 -0
  172. package/dist/shared/index.js +4 -0
  173. package/dist/shared/index.js.map +1 -1
  174. package/dist/shared/index.mjs +4 -0
  175. package/dist/shared/index.mjs.map +1 -1
  176. package/package.json +13 -12
  177. package/dist/_chunks/EditViewPage-C4iTxUPU.js.map +0 -1
  178. package/dist/_chunks/EditViewPage-CiwVPMaK.mjs.map +0 -1
  179. package/dist/_chunks/Field-DIjL1b5d.mjs.map +0 -1
  180. package/dist/_chunks/Field-DhXEK8y1.js.map +0 -1
  181. package/dist/_chunks/History-BLCCNgCt.js.map +0 -1
  182. package/dist/_chunks/History-D-99Wh30.mjs.map +0 -1
  183. package/dist/_chunks/ListConfigurationPage-DxWpeZrO.js.map +0 -1
  184. package/dist/_chunks/ListConfigurationPage-JPWZz7Kg.mjs.map +0 -1
  185. package/dist/_chunks/ListViewPage-CIQekSFz.js.map +0 -1
  186. package/dist/_chunks/ListViewPage-DSK3f0ST.mjs.map +0 -1
  187. package/dist/_chunks/Relations-BBmhcWFV.mjs.map +0 -1
  188. package/dist/_chunks/Relations-eG-9p_qS.js.map +0 -1
  189. package/dist/_chunks/index-BIWDoFLK.js.map +0 -1
  190. package/dist/_chunks/index-BrUzbQ30.mjs.map +0 -1
  191. package/dist/_chunks/relations-BRHithi8.js.map +0 -1
  192. package/dist/_chunks/relations-B_VLk-DD.mjs.map +0 -1
  193. package/dist/admin/src/preview/constants.d.ts +0 -1
  194. package/dist/server/src/preview/constants.d.ts +0 -2
  195. package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
- import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1, traverseEntity, pagination } from "@strapi/utils";
2
- import { pick, omit, difference, castArray, intersection, pipe, propOr, isEqual, isEmpty, set, isNil as isNil$1, has, prop, assoc, mapValues, flow, uniq, uniqBy, concat, getOr, propEq, merge, groupBy } from "lodash/fp";
1
+ import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, traverseEntity, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1, pagination } from "@strapi/utils";
2
+ import { pick, omit, difference, castArray, mergeWith, intersection, pipe, propOr, isEqual, isEmpty, set, isNil as isNil$1, has, prop, assoc, mapValues, flow, uniq, uniqBy, concat, getOr, propEq, merge, groupBy } from "lodash/fp";
3
3
  import "@strapi/types";
4
4
  import * as yup from "yup";
5
5
  import { scheduleJob } from "node-schedule";
@@ -7,10 +7,10 @@ import isNil from "lodash/isNil";
7
7
  import _, { intersection as intersection$1, difference as difference$1 } from "lodash";
8
8
  import qs from "qs";
9
9
  import slugify from "@sindresorhus/slugify";
10
- const getService$1 = (name) => {
10
+ const getService$2 = (name) => {
11
11
  return strapi.plugin("content-manager").service(name);
12
12
  };
13
- function getService(strapi2, name) {
13
+ function getService$1(strapi2, name) {
14
14
  return strapi2.service(`plugin::content-manager.${name}`);
15
15
  }
16
16
  const historyRestoreVersionSchema = yup.object().shape({
@@ -46,7 +46,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
46
46
  if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
47
47
  throw new errors.ForbiddenError("contentType and documentId are required");
48
48
  }
49
- const permissionChecker2 = getService$1("permission-checker").create({
49
+ const permissionChecker2 = getService$2("permission-checker").create({
50
50
  userAbility: ctx.state.userAbility,
51
51
  model: ctx.query.contentType
52
52
  });
@@ -54,7 +54,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
54
54
  return ctx.forbidden();
55
55
  }
56
56
  const query = await permissionChecker2.sanitizeQuery(ctx.query);
57
- const { results, pagination: pagination2 } = await getService(strapi2, "history").findVersionsPage({
57
+ const { results, pagination: pagination2 } = await getService$1(strapi2, "history").findVersionsPage({
58
58
  query: {
59
59
  ...query,
60
60
  ...getValidPagination({ page: query.page, pageSize: query.pageSize })
@@ -79,14 +79,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
79
79
  async restoreVersion(ctx) {
80
80
  const request = ctx.request;
81
81
  await validateRestoreVersion(request.body, "contentType is required");
82
- const permissionChecker2 = getService$1("permission-checker").create({
82
+ const permissionChecker2 = getService$2("permission-checker").create({
83
83
  userAbility: ctx.state.userAbility,
84
84
  model: request.body.contentType
85
85
  });
86
86
  if (permissionChecker2.cannot.update()) {
87
87
  throw new errors.ForbiddenError();
88
88
  }
89
- const restoredDocument = await getService(strapi2, "history").restoreVersion(
89
+ const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
90
90
  request.params.versionId
91
91
  );
92
92
  return {
@@ -95,7 +95,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
95
95
  }
96
96
  };
97
97
  };
98
- const controllers$1 = {
98
+ const controllers$2 = {
99
99
  "history-version": createHistoryVersionController
100
100
  /**
101
101
  * Casting is needed because the types aren't aware that Strapi supports
@@ -141,8 +141,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
141
141
  };
142
142
  const getRelationRestoreValue = async (versionRelationData, attribute) => {
143
143
  if (Array.isArray(versionRelationData)) {
144
- if (versionRelationData.length === 0)
145
- return versionRelationData;
144
+ if (versionRelationData.length === 0) return versionRelationData;
146
145
  const existingAndMissingRelations = await Promise.all(
147
146
  versionRelationData.map((relation) => {
148
147
  return strapi2.documents(attribute.target).findOne({
@@ -151,19 +150,16 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
151
150
  });
152
151
  })
153
152
  );
154
- return existingAndMissingRelations.filter(
155
- (relation) => relation !== null
156
- );
153
+ return existingAndMissingRelations.filter((relation) => relation !== null);
157
154
  }
158
155
  return strapi2.documents(attribute.target).findOne({
159
156
  documentId: versionRelationData.documentId,
160
157
  locale: versionRelationData.locale || void 0
161
158
  });
162
159
  };
163
- const getMediaRestoreValue = async (versionRelationData, attribute) => {
164
- if (attribute.multiple) {
160
+ const getMediaRestoreValue = async (versionRelationData) => {
161
+ if (Array.isArray(versionRelationData)) {
165
162
  const existingAndMissingMedias = await Promise.all(
166
- // @ts-expect-error Fix the type definitions so this isn't any
167
163
  versionRelationData.map((media) => {
168
164
  return strapi2.db.query("plugin::upload.file").findOne({ where: { id: media.id } });
169
165
  })
@@ -177,8 +173,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
177
173
  const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
178
174
  const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
179
175
  const getLocaleDictionary = async () => {
180
- if (!localesService)
181
- return {};
176
+ if (!localesService) return {};
182
177
  const locales = await localesService.find() || [];
183
178
  return locales.reduce(
184
179
  (acc, locale) => {
@@ -202,6 +197,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
202
197
  const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
203
198
  return documentMetadataService.getStatus(document, meta.availableStatus);
204
199
  };
200
+ const getComponentFields = (componentUID) => {
201
+ return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
202
+ (fieldsAcc, [key, attribute]) => {
203
+ if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
204
+ fieldsAcc.push(key);
205
+ }
206
+ return fieldsAcc;
207
+ },
208
+ []
209
+ );
210
+ };
205
211
  const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
206
212
  const model = strapi2.getModel(uid2);
207
213
  const attributes = Object.entries(model.attributes);
@@ -225,13 +231,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
225
231
  }
226
232
  case "component": {
227
233
  const populate = getDeepPopulate2(attribute.component);
228
- acc[attributeName] = { populate };
234
+ acc[attributeName] = {
235
+ populate,
236
+ [fieldSelector]: getComponentFields(attribute.component)
237
+ };
229
238
  break;
230
239
  }
231
240
  case "dynamiczone": {
232
241
  const populatedComponents = (attribute.components || []).reduce(
233
242
  (acc2, componentUID) => {
234
- acc2[componentUID] = { populate: getDeepPopulate2(componentUID) };
243
+ acc2[componentUID] = {
244
+ populate: getDeepPopulate2(componentUID),
245
+ [fieldSelector]: getComponentFields(componentUID)
246
+ };
235
247
  return acc2;
236
248
  },
237
249
  {}
@@ -316,8 +328,8 @@ const createHistoryService = ({ strapi: strapi2 }) => {
316
328
  });
317
329
  },
318
330
  async findVersionsPage(params) {
319
- const model = strapi2.getModel(params.query.contentType);
320
- const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
331
+ const schema = strapi2.getModel(params.query.contentType);
332
+ const isLocalizedContentType = serviceUtils.isLocalizedContentType(schema);
321
333
  const defaultLocale = await serviceUtils.getDefaultLocale();
322
334
  let locale = null;
323
335
  if (isLocalizedContentType) {
@@ -338,32 +350,20 @@ const createHistoryService = ({ strapi: strapi2 }) => {
338
350
  }),
339
351
  serviceUtils.getLocaleDictionary()
340
352
  ]);
341
- const populateEntryRelations = async (entry) => {
342
- const entryWithRelations = await Object.entries(entry.schema).reduce(
343
- async (currentDataWithRelations, [attributeKey, attributeSchema]) => {
344
- const attributeValue = entry.data[attributeKey];
345
- const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
346
- if (attributeSchema.type === "media") {
347
- const permissionChecker2 = getService$1("permission-checker").create({
348
- userAbility: params.state.userAbility,
349
- model: "plugin::upload.file"
350
- });
351
- const response = await serviceUtils.buildMediaResponse(attributeValues);
352
- const sanitizedResults = await Promise.all(
353
- response.results.map((media) => permissionChecker2.sanitizeOutput(media))
354
- );
355
- return {
356
- ...await currentDataWithRelations,
357
- [attributeKey]: {
358
- results: sanitizedResults,
359
- meta: response.meta
360
- }
361
- };
353
+ const populateEntry = async (entry) => {
354
+ return traverseEntity(
355
+ async (options, utils) => {
356
+ if (!options.attribute) return;
357
+ if (!options.value) return;
358
+ const currentValue = Array.isArray(options.value) ? options.value : [options.value];
359
+ if (options.attribute.type === "component") {
360
+ utils.remove("id");
362
361
  }
363
- if (attributeSchema.type === "relation" && attributeSchema.relation !== "morphToOne" && attributeSchema.relation !== "morphToMany") {
364
- if (attributeSchema.target === "admin::user") {
362
+ if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
363
+ options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
364
+ if (options.attribute.target === "admin::user") {
365
365
  const adminUsers = await Promise.all(
366
- attributeValues.map((userToPopulate) => {
366
+ currentValue.map((userToPopulate) => {
367
367
  if (userToPopulate == null) {
368
368
  return null;
369
369
  }
@@ -375,46 +375,51 @@ const createHistoryService = ({ strapi: strapi2 }) => {
375
375
  });
376
376
  })
377
377
  );
378
- return {
379
- ...await currentDataWithRelations,
380
- /**
381
- * Ideally we would return the same "{results: [], meta: {}}" shape, however,
382
- * when sanitizing the data as a whole in the controller before sending to the client,
383
- * the data for admin relation user is completely sanitized if we return an object here as opposed to an array.
384
- */
385
- [attributeKey]: adminUsers
386
- };
378
+ utils.set(options.key, adminUsers);
387
379
  }
388
- const permissionChecker2 = getService$1("permission-checker").create({
380
+ const permissionChecker2 = getService$2("permission-checker").create({
389
381
  userAbility: params.state.userAbility,
390
- model: attributeSchema.target
382
+ model: options.attribute.target
391
383
  });
392
384
  const response = await serviceUtils.buildRelationReponse(
393
- attributeValues,
394
- attributeSchema
385
+ currentValue,
386
+ options.attribute
395
387
  );
396
388
  const sanitizedResults = await Promise.all(
397
389
  response.results.map((media) => permissionChecker2.sanitizeOutput(media))
398
390
  );
399
- return {
400
- ...await currentDataWithRelations,
401
- [attributeKey]: {
402
- results: sanitizedResults,
403
- meta: response.meta
404
- }
405
- };
391
+ utils.set(options.key, {
392
+ results: sanitizedResults,
393
+ meta: response.meta
394
+ });
406
395
  }
407
- return currentDataWithRelations;
396
+ if (options.attribute.type === "media") {
397
+ const permissionChecker2 = getService$2("permission-checker").create({
398
+ userAbility: params.state.userAbility,
399
+ model: "plugin::upload.file"
400
+ });
401
+ const response = await serviceUtils.buildMediaResponse(currentValue);
402
+ const sanitizedResults = await Promise.all(
403
+ response.results.map((media) => permissionChecker2.sanitizeOutput(media))
404
+ );
405
+ utils.set(options.key, {
406
+ results: sanitizedResults,
407
+ meta: response.meta
408
+ });
409
+ }
410
+ },
411
+ {
412
+ schema,
413
+ getModel: strapi2.getModel.bind(strapi2)
408
414
  },
409
- Promise.resolve(entry.data)
415
+ entry.data
410
416
  );
411
- return entryWithRelations;
412
417
  };
413
418
  const formattedResults = await Promise.all(
414
419
  results.map(async (result) => {
415
420
  return {
416
421
  ...result,
417
- data: await populateEntryRelations(result),
422
+ data: await populateEntry(result),
418
423
  meta: {
419
424
  unknownAttributes: serviceUtils.getSchemaAttributesDiff(
420
425
  result.schema,
@@ -445,30 +450,44 @@ const createHistoryService = ({ strapi: strapi2 }) => {
445
450
  // Clone to avoid mutating the original version data
446
451
  structuredClone(version.data)
447
452
  );
448
- const sanitizedSchemaAttributes = omit(
449
- FIELDS_TO_IGNORE,
450
- contentTypeSchemaAttributes
451
- );
452
- const reducer = async.reduce(Object.entries(sanitizedSchemaAttributes));
453
- const dataWithoutMissingRelations = await reducer(
454
- async (previousRelationAttributes, [name, attribute]) => {
455
- const versionRelationData = version.data[name];
456
- if (!versionRelationData) {
457
- return previousRelationAttributes;
453
+ const schema = structuredClone(version.schema);
454
+ schema.attributes = omit(FIELDS_TO_IGNORE, contentTypeSchemaAttributes);
455
+ const dataWithoutMissingRelations = await traverseEntity(
456
+ async (options, utils) => {
457
+ if (!options.attribute) return;
458
+ if (options.attribute.type === "component") {
459
+ utils.remove("id");
460
+ if (options.attribute.repeatable && options.value === null) {
461
+ utils.set(options.key, []);
462
+ }
458
463
  }
459
- if (attribute.type === "relation" && // TODO: handle polymorphic relations
460
- attribute.relation !== "morphToOne" && attribute.relation !== "morphToMany") {
461
- const data2 = await serviceUtils.getRelationRestoreValue(versionRelationData, attribute);
462
- previousRelationAttributes[name] = data2;
464
+ if (options.attribute.type === "dynamiczone") {
465
+ if (options.value === null) {
466
+ utils.set(options.key, []);
467
+ }
468
+ }
469
+ if (options.attribute.type === "relation" && // TODO: handle polymorphic relations
470
+ options.attribute.relation !== "morphToOne" && options.attribute.relation !== "morphToMany") {
471
+ if (!options.value) return;
472
+ const data2 = await serviceUtils.getRelationRestoreValue(
473
+ options.value,
474
+ options.attribute
475
+ );
476
+ utils.set(options.key, data2);
463
477
  }
464
- if (attribute.type === "media") {
465
- const data2 = await serviceUtils.getMediaRestoreValue(versionRelationData, attribute);
466
- previousRelationAttributes[name] = data2;
478
+ if (options.attribute.type === "media") {
479
+ if (!options.value) return;
480
+ const data2 = await serviceUtils.getMediaRestoreValue(
481
+ options.value
482
+ );
483
+ utils.set(options.key, data2);
467
484
  }
468
- return previousRelationAttributes;
469
485
  },
470
- // Clone to avoid mutating the original version data
471
- structuredClone(dataWithoutAddedAttributes)
486
+ {
487
+ schema,
488
+ getModel: strapi2.getModel.bind(strapi2)
489
+ },
490
+ dataWithoutAddedAttributes
472
491
  );
473
492
  const data = omit(["id", ...Object.keys(schemaDiff.removed)], dataWithoutMissingRelations);
474
493
  const restoredDocument = await strapi2.documents(version.contentType).update({
@@ -561,7 +580,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
561
580
  onCommit(async () => {
562
581
  for (const entry of localeEntries) {
563
582
  const status = await serviceUtils.getVersionStatus(uid2, entry);
564
- await getService(strapi2, "history").createVersion({
583
+ await getService$1(strapi2, "history").createVersion({
565
584
  contentType: uid2,
566
585
  data: omit(FIELDS_TO_IGNORE, entry),
567
586
  relatedDocumentId: documentId,
@@ -574,15 +593,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
574
593
  });
575
594
  return result;
576
595
  });
577
- state.deleteExpiredJob = scheduleJob("0 0 * * *", () => {
596
+ state.deleteExpiredJob = scheduleJob("historyDaily", "0 0 * * *", () => {
578
597
  const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
579
598
  const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
580
599
  strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
581
600
  where: {
582
601
  created_at: {
583
- $lt: expirationDate.toISOString()
602
+ $lt: expirationDate
584
603
  }
585
604
  }
605
+ }).catch((error) => {
606
+ if (error instanceof Error) {
607
+ strapi2.log.error("Error deleting expired history versions", error.message);
608
+ }
586
609
  });
587
610
  });
588
611
  state.isInitialized = true;
@@ -594,17 +617,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
594
617
  }
595
618
  };
596
619
  };
597
- const services$1 = {
620
+ const services$2 = {
598
621
  history: createHistoryService,
599
622
  lifecycles: createLifecyclesService
600
623
  };
601
- const info = { pluginName: "content-manager", type: "admin" };
624
+ const info$1 = { pluginName: "content-manager", type: "admin" };
602
625
  const historyVersionRouter = {
603
626
  type: "admin",
604
627
  routes: [
605
628
  {
606
629
  method: "GET",
607
- info,
630
+ info: info$1,
608
631
  path: "/history-versions",
609
632
  handler: "history-version.findMany",
610
633
  config: {
@@ -613,7 +636,7 @@ const historyVersionRouter = {
613
636
  },
614
637
  {
615
638
  method: "PUT",
616
- info,
639
+ info: info$1,
617
640
  path: "/history-versions/:versionId/restore",
618
641
  handler: "history-version.restoreVersion",
619
642
  config: {
@@ -622,7 +645,7 @@ const historyVersionRouter = {
622
645
  }
623
646
  ]
624
647
  };
625
- const routes$1 = {
648
+ const routes$2 = {
626
649
  "history-version": historyVersionRouter
627
650
  };
628
651
  const historyVersion = {
@@ -676,14 +699,14 @@ const getFeature$1 = () => {
676
699
  strapi2.get("models").add(historyVersion);
677
700
  },
678
701
  bootstrap({ strapi: strapi2 }) {
679
- getService(strapi2, "lifecycles").bootstrap();
702
+ getService$1(strapi2, "lifecycles").bootstrap();
680
703
  },
681
704
  destroy({ strapi: strapi2 }) {
682
- getService(strapi2, "lifecycles").destroy();
705
+ getService$1(strapi2, "lifecycles").destroy();
683
706
  },
684
- controllers: controllers$1,
685
- services: services$1,
686
- routes: routes$1
707
+ controllers: controllers$2,
708
+ services: services$2,
709
+ routes: routes$2
687
710
  };
688
711
  }
689
712
  return {
@@ -693,33 +716,213 @@ const getFeature$1 = () => {
693
716
  };
694
717
  };
695
718
  const history = getFeature$1();
696
- const register = async ({ strapi: strapi2 }) => {
697
- await history.register?.({ strapi: strapi2 });
719
+ const info = { pluginName: "content-manager", type: "admin" };
720
+ const previewRouter = {
721
+ type: "admin",
722
+ routes: [
723
+ {
724
+ method: "GET",
725
+ info,
726
+ path: "/preview/url/:contentType",
727
+ handler: "preview.getPreviewUrl",
728
+ config: {
729
+ policies: ["admin::isAuthenticatedAdmin"]
730
+ }
731
+ }
732
+ ]
698
733
  };
699
- const ALLOWED_WEBHOOK_EVENTS = {
700
- ENTRY_PUBLISH: "entry.publish",
701
- ENTRY_UNPUBLISH: "entry.unpublish"
734
+ const routes$1 = {
735
+ preview: previewRouter
702
736
  };
703
- const FEATURE_ID = "preview";
704
- const getFeature = () => {
705
- if (!strapi.features.future.isEnabled(FEATURE_ID)) {
706
- return {};
737
+ function getService(strapi2, name) {
738
+ return strapi2.service(`plugin::content-manager.${name}`);
739
+ }
740
+ const getPreviewUrlSchema = yup.object().shape({
741
+ // Will be undefined for single types
742
+ documentId: yup.string(),
743
+ locale: yup.string().nullable(),
744
+ status: yup.string()
745
+ }).required();
746
+ const validatePreviewUrl = async (strapi2, uid2, params) => {
747
+ await validateYupSchema(getPreviewUrlSchema)(params);
748
+ const newParams = pick(["documentId", "locale", "status"], params);
749
+ const model = strapi2.getModel(uid2);
750
+ if (!model || model.modelType !== "contentType") {
751
+ throw new errors.ValidationError("Invalid content type");
752
+ }
753
+ const isSingleType = model?.kind === "singleType";
754
+ if (!isSingleType && !params.documentId) {
755
+ throw new errors.ValidationError("documentId is required for Collection Types");
707
756
  }
757
+ if (isSingleType) {
758
+ const doc = await strapi2.documents(uid2).findFirst();
759
+ if (!doc) {
760
+ throw new errors.NotFoundError("Document not found");
761
+ }
762
+ newParams.documentId = doc?.documentId;
763
+ }
764
+ if (!newParams.status) {
765
+ const isDPEnabled = model?.options?.draftAndPublish;
766
+ newParams.status = isDPEnabled ? "draft" : "published";
767
+ }
768
+ return newParams;
769
+ };
770
+ const createPreviewController = () => {
708
771
  return {
709
- bootstrap() {
710
- console.log("Bootstrapping preview server");
772
+ /**
773
+ * Transforms an entry into a preview URL, so that it can be previewed
774
+ * in the Content Manager.
775
+ */
776
+ async getPreviewUrl(ctx) {
777
+ const uid2 = ctx.params.contentType;
778
+ const query = ctx.request.query;
779
+ const params = await validatePreviewUrl(strapi, uid2, query);
780
+ const previewService = getService(strapi, "preview");
781
+ const url = await previewService.getPreviewUrl(uid2, params);
782
+ if (!url) {
783
+ ctx.status = 204;
784
+ }
785
+ return {
786
+ data: { url }
787
+ };
788
+ }
789
+ };
790
+ };
791
+ const controllers$1 = {
792
+ preview: createPreviewController
793
+ /**
794
+ * Casting is needed because the types aren't aware that Strapi supports
795
+ * passing a controller factory as the value, instead of a controller object directly
796
+ */
797
+ };
798
+ const createPreviewService = ({ strapi: strapi2 }) => {
799
+ const config = getService(strapi2, "preview-config");
800
+ return {
801
+ async getPreviewUrl(uid2, params) {
802
+ const handler = config.getPreviewHandler();
803
+ try {
804
+ return handler(uid2, params);
805
+ } catch (error) {
806
+ strapi2.log.error(`Failed to get preview URL: ${error}`);
807
+ throw new errors.ApplicationError("Failed to get preview URL");
808
+ }
809
+ return;
810
+ }
811
+ };
812
+ };
813
+ const extendMiddlewareConfiguration = (middleware = { name: "", config: {} }) => {
814
+ const middlewares = strapi.config.get("middlewares");
815
+ const configuredMiddlewares = middlewares.map((currentMiddleware) => {
816
+ if (currentMiddleware === middleware.name) {
817
+ return middleware;
818
+ }
819
+ if (currentMiddleware.name === middleware.name) {
820
+ return mergeWith(
821
+ (objValue, srcValue) => {
822
+ if (Array.isArray(objValue)) {
823
+ return objValue.concat(srcValue);
824
+ }
825
+ return void 0;
826
+ },
827
+ currentMiddleware,
828
+ middleware
829
+ );
830
+ }
831
+ return currentMiddleware;
832
+ });
833
+ strapi.config.set("middlewares", configuredMiddlewares);
834
+ };
835
+ const createPreviewConfigService = ({ strapi: strapi2 }) => {
836
+ return {
837
+ register() {
838
+ if (!this.isEnabled()) {
839
+ return;
840
+ }
841
+ const config = strapi2.config.get("admin.preview");
842
+ if (config.config?.allowedOrigins) {
843
+ extendMiddlewareConfiguration({
844
+ name: "strapi::security",
845
+ config: {
846
+ contentSecurityPolicy: {
847
+ directives: {
848
+ "frame-src": config.config.allowedOrigins
849
+ }
850
+ }
851
+ }
852
+ });
853
+ }
854
+ },
855
+ isEnabled() {
856
+ const config = strapi2.config.get("admin.preview");
857
+ if (!config) {
858
+ return false;
859
+ }
860
+ return config?.enabled ?? true;
861
+ },
862
+ /**
863
+ * Validate if the configuration is valid
864
+ */
865
+ validate() {
866
+ if (!this.isEnabled()) {
867
+ return;
868
+ }
869
+ const handler = this.getPreviewHandler();
870
+ if (typeof handler !== "function") {
871
+ throw new errors.ValidationError(
872
+ "Preview configuration is invalid. Handler must be a function"
873
+ );
874
+ }
875
+ },
876
+ /**
877
+ * Utility to get the preview handler from the configuration
878
+ */
879
+ getPreviewHandler() {
880
+ const config = strapi2.config.get("admin.preview");
881
+ const emptyHandler = () => {
882
+ return void 0;
883
+ };
884
+ if (!this.isEnabled()) {
885
+ return emptyHandler;
886
+ }
887
+ return config?.config?.handler || emptyHandler;
711
888
  }
712
889
  };
713
890
  };
891
+ const services$1 = {
892
+ preview: createPreviewService,
893
+ "preview-config": createPreviewConfigService
894
+ };
895
+ const getFeature = () => {
896
+ return {
897
+ register() {
898
+ const config = getService(strapi, "preview-config");
899
+ config.validate();
900
+ config.register();
901
+ },
902
+ bootstrap() {
903
+ },
904
+ routes: routes$1,
905
+ controllers: controllers$1,
906
+ services: services$1
907
+ };
908
+ };
714
909
  const preview = getFeature();
910
+ const register = async ({ strapi: strapi2 }) => {
911
+ await history.register?.({ strapi: strapi2 });
912
+ await preview.register?.({ strapi: strapi2 });
913
+ };
914
+ const ALLOWED_WEBHOOK_EVENTS = {
915
+ ENTRY_PUBLISH: "entry.publish",
916
+ ENTRY_UNPUBLISH: "entry.unpublish"
917
+ };
715
918
  const bootstrap = async () => {
716
919
  Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
717
920
  strapi.get("webhookStore").addAllowedEvent(key, value);
718
921
  });
719
- getService$1("field-sizes").setCustomFieldInputSizes();
720
- await getService$1("components").syncConfigurations();
721
- await getService$1("content-types").syncConfigurations();
722
- await getService$1("permission").registerPermissions();
922
+ getService$2("field-sizes").setCustomFieldInputSizes();
923
+ await getService$2("components").syncConfigurations();
924
+ await getService$2("content-types").syncConfigurations();
925
+ await getService$2("permission").registerPermissions();
723
926
  await history.bootstrap?.({ strapi });
724
927
  await preview.bootstrap?.({ strapi });
725
928
  };
@@ -1211,7 +1414,8 @@ const admin = {
1211
1414
  };
1212
1415
  const routes = {
1213
1416
  admin,
1214
- ...history.routes ? history.routes : {}
1417
+ ...history.routes ? history.routes : {},
1418
+ ...preview.routes ? preview.routes : {}
1215
1419
  };
1216
1420
  const hasPermissionsSchema = yup$1.object({
1217
1421
  actions: yup$1.array().of(yup$1.string()),
@@ -1274,8 +1478,7 @@ const isSortable = (schema, name) => {
1274
1478
  if (!_.has(schema.attributes, name)) {
1275
1479
  return false;
1276
1480
  }
1277
- if (schema.modelType === "component" && name === "id")
1278
- return false;
1481
+ if (schema.modelType === "component" && name === "id") return false;
1279
1482
  const attribute = schema.attributes[name];
1280
1483
  if (NON_SORTABLES.includes(attribute.type)) {
1281
1484
  return false;
@@ -1420,8 +1623,7 @@ const createDefaultSettings = async (schema) => {
1420
1623
  };
1421
1624
  };
1422
1625
  const syncSettings = async (configuration, schema) => {
1423
- if (isEmpty(configuration.settings))
1424
- return createDefaultSettings(schema);
1626
+ if (isEmpty(configuration.settings)) return createDefaultSettings(schema);
1425
1627
  const defaultField = getDefaultMainField(schema);
1426
1628
  const { mainField = defaultField, defaultSortBy = defaultField } = configuration.settings || {};
1427
1629
  return {
@@ -1468,7 +1670,7 @@ const createMetadasSchema = (schema) => {
1468
1670
  if (!value) {
1469
1671
  return yup$1.string();
1470
1672
  }
1471
- const targetSchema = getService$1("content-types").findContentType(
1673
+ const targetSchema = getService$2("content-types").findContentType(
1472
1674
  schema.attributes[key].targetModel
1473
1675
  );
1474
1676
  if (!targetSchema) {
@@ -1597,8 +1799,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1597
1799
  }
1598
1800
  switch (attribute.type) {
1599
1801
  case "relation": {
1600
- if (canCreate(attributePath))
1601
- return body2;
1802
+ if (canCreate(attributePath)) return body2;
1602
1803
  return set(attributePath, { set: [] }, body2);
1603
1804
  }
1604
1805
  case "component": {
@@ -1608,8 +1809,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1608
1809
  ]);
1609
1810
  }
1610
1811
  default: {
1611
- if (canCreate(attributePath))
1612
- return body2;
1812
+ if (canCreate(attributePath)) return body2;
1613
1813
  return set(attributePath, null, body2);
1614
1814
  }
1615
1815
  }
@@ -1637,7 +1837,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
1637
1837
  }
1638
1838
  };
1639
1839
  const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
1640
- const documentMetadata2 = getService$1("document-metadata");
1840
+ const documentMetadata2 = getService$2("document-metadata");
1641
1841
  const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
1642
1842
  let {
1643
1843
  meta: { availableLocales, availableStatus }
@@ -1663,8 +1863,8 @@ const createDocument = async (ctx, opts) => {
1663
1863
  const { userAbility, user } = ctx.state;
1664
1864
  const { model } = ctx.params;
1665
1865
  const { body } = ctx.request;
1666
- const documentManager2 = getService$1("document-manager");
1667
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1866
+ const documentManager2 = getService$2("document-manager");
1867
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1668
1868
  if (permissionChecker2.cannot.create()) {
1669
1869
  throw new errors.ForbiddenError();
1670
1870
  }
@@ -1684,13 +1884,13 @@ const updateDocument = async (ctx, opts) => {
1684
1884
  const { userAbility, user } = ctx.state;
1685
1885
  const { id, model } = ctx.params;
1686
1886
  const { body } = ctx.request;
1687
- const documentManager2 = getService$1("document-manager");
1688
- 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 });
1689
1889
  if (permissionChecker2.cannot.update()) {
1690
1890
  throw new errors.ForbiddenError();
1691
1891
  }
1692
1892
  const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
1693
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
1893
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1694
1894
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1695
1895
  const [documentVersion, documentExists] = await Promise.all([
1696
1896
  documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
@@ -1721,14 +1921,14 @@ const collectionTypes = {
1721
1921
  const { userAbility } = ctx.state;
1722
1922
  const { model } = ctx.params;
1723
1923
  const { query } = ctx.request;
1724
- const documentMetadata2 = getService$1("document-metadata");
1725
- const documentManager2 = getService$1("document-manager");
1726
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1924
+ const documentMetadata2 = getService$2("document-metadata");
1925
+ const documentManager2 = getService$2("document-manager");
1926
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1727
1927
  if (permissionChecker2.cannot.read()) {
1728
1928
  return ctx.forbidden();
1729
1929
  }
1730
1930
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
1731
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1931
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1732
1932
  const { locale, status } = await getDocumentLocaleAndStatus(query, model);
1733
1933
  const { results: documents, pagination: pagination2 } = await documentManager2.findPage(
1734
1934
  { ...permissionQuery, populate, locale, status },
@@ -1757,13 +1957,13 @@ const collectionTypes = {
1757
1957
  async findOne(ctx) {
1758
1958
  const { userAbility } = ctx.state;
1759
1959
  const { model, id } = ctx.params;
1760
- const documentManager2 = getService$1("document-manager");
1761
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1960
+ const documentManager2 = getService$2("document-manager");
1961
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1762
1962
  if (permissionChecker2.cannot.read()) {
1763
1963
  return ctx.forbidden();
1764
1964
  }
1765
1965
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
1766
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1966
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1767
1967
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
1768
1968
  const version = await documentManager2.findOne(id, model, {
1769
1969
  populate,
@@ -1794,7 +1994,7 @@ const collectionTypes = {
1794
1994
  async create(ctx) {
1795
1995
  const { userAbility } = ctx.state;
1796
1996
  const { model } = ctx.params;
1797
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1997
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1798
1998
  const [totalEntries, document] = await Promise.all([
1799
1999
  strapi.db.query(model).count(),
1800
2000
  createDocument(ctx)
@@ -1815,7 +2015,7 @@ const collectionTypes = {
1815
2015
  async update(ctx) {
1816
2016
  const { userAbility } = ctx.state;
1817
2017
  const { model } = ctx.params;
1818
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2018
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1819
2019
  const updatedVersion = await updateDocument(ctx);
1820
2020
  const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
1821
2021
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
@@ -1824,13 +2024,13 @@ const collectionTypes = {
1824
2024
  const { userAbility, user } = ctx.state;
1825
2025
  const { model, sourceId: id } = ctx.params;
1826
2026
  const { body } = ctx.request;
1827
- const documentManager2 = getService$1("document-manager");
1828
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2027
+ const documentManager2 = getService$2("document-manager");
2028
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1829
2029
  if (permissionChecker2.cannot.create()) {
1830
2030
  return ctx.forbidden();
1831
2031
  }
1832
2032
  const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
1833
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2033
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1834
2034
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1835
2035
  const document = await documentManager2.findOne(id, model, {
1836
2036
  populate,
@@ -1869,13 +2069,13 @@ const collectionTypes = {
1869
2069
  async delete(ctx) {
1870
2070
  const { userAbility } = ctx.state;
1871
2071
  const { id, model } = ctx.params;
1872
- const documentManager2 = getService$1("document-manager");
1873
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2072
+ const documentManager2 = getService$2("document-manager");
2073
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1874
2074
  if (permissionChecker2.cannot.delete()) {
1875
2075
  return ctx.forbidden();
1876
2076
  }
1877
2077
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
1878
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2078
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1879
2079
  const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
1880
2080
  const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
1881
2081
  if (documentLocales.length === 0) {
@@ -1897,14 +2097,14 @@ const collectionTypes = {
1897
2097
  const { userAbility } = ctx.state;
1898
2098
  const { id, model } = ctx.params;
1899
2099
  const { body } = ctx.request;
1900
- const documentManager2 = getService$1("document-manager");
1901
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2100
+ const documentManager2 = getService$2("document-manager");
2101
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1902
2102
  if (permissionChecker2.cannot.publish()) {
1903
2103
  return ctx.forbidden();
1904
2104
  }
1905
2105
  const publishedDocument = await strapi.db.transaction(async () => {
1906
2106
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1907
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2107
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1908
2108
  let document;
1909
2109
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1910
2110
  const isCreate = isNil$1(id);
@@ -1952,13 +2152,13 @@ const collectionTypes = {
1952
2152
  const { body } = ctx.request;
1953
2153
  const { documentIds } = body;
1954
2154
  await validateBulkActionInput(body);
1955
- const documentManager2 = getService$1("document-manager");
1956
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2155
+ const documentManager2 = getService$2("document-manager");
2156
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1957
2157
  if (permissionChecker2.cannot.publish()) {
1958
2158
  return ctx.forbidden();
1959
2159
  }
1960
2160
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1961
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2161
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1962
2162
  const { locale } = await getDocumentLocaleAndStatus(body, model, {
1963
2163
  allowMultipleLocales: true
1964
2164
  });
@@ -1983,8 +2183,8 @@ const collectionTypes = {
1983
2183
  const { body } = ctx.request;
1984
2184
  const { documentIds } = body;
1985
2185
  await validateBulkActionInput(body);
1986
- const documentManager2 = getService$1("document-manager");
1987
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2186
+ const documentManager2 = getService$2("document-manager");
2187
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1988
2188
  if (permissionChecker2.cannot.unpublish()) {
1989
2189
  return ctx.forbidden();
1990
2190
  }
@@ -2013,8 +2213,8 @@ const collectionTypes = {
2013
2213
  const {
2014
2214
  body: { discardDraft, ...body }
2015
2215
  } = ctx.request;
2016
- const documentManager2 = getService$1("document-manager");
2017
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2216
+ const documentManager2 = getService$2("document-manager");
2217
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2018
2218
  if (permissionChecker2.cannot.unpublish()) {
2019
2219
  return ctx.forbidden();
2020
2220
  }
@@ -2022,7 +2222,7 @@ const collectionTypes = {
2022
2222
  return ctx.forbidden();
2023
2223
  }
2024
2224
  const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
2025
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2225
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2026
2226
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2027
2227
  const document = await documentManager2.findOne(id, model, {
2028
2228
  populate,
@@ -2053,13 +2253,13 @@ const collectionTypes = {
2053
2253
  const { userAbility } = ctx.state;
2054
2254
  const { id, model } = ctx.params;
2055
2255
  const { body } = ctx.request;
2056
- const documentManager2 = getService$1("document-manager");
2057
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2256
+ const documentManager2 = getService$2("document-manager");
2257
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2058
2258
  if (permissionChecker2.cannot.discard()) {
2059
2259
  return ctx.forbidden();
2060
2260
  }
2061
2261
  const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
2062
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2262
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2063
2263
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2064
2264
  const document = await documentManager2.findOne(id, model, {
2065
2265
  populate,
@@ -2084,13 +2284,13 @@ const collectionTypes = {
2084
2284
  const { query, body } = ctx.request;
2085
2285
  const { documentIds } = body;
2086
2286
  await validateBulkActionInput(body);
2087
- const documentManager2 = getService$1("document-manager");
2088
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2287
+ const documentManager2 = getService$2("document-manager");
2288
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2089
2289
  if (permissionChecker2.cannot.delete()) {
2090
2290
  return ctx.forbidden();
2091
2291
  }
2092
2292
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
2093
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2293
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2094
2294
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2095
2295
  const documentLocales = await documentManager2.findLocales(documentIds, model, {
2096
2296
  populate,
@@ -2111,13 +2311,13 @@ const collectionTypes = {
2111
2311
  async countDraftRelations(ctx) {
2112
2312
  const { userAbility } = ctx.state;
2113
2313
  const { model, id } = ctx.params;
2114
- const documentManager2 = getService$1("document-manager");
2115
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2314
+ const documentManager2 = getService$2("document-manager");
2315
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2116
2316
  if (permissionChecker2.cannot.read()) {
2117
2317
  return ctx.forbidden();
2118
2318
  }
2119
2319
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2120
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2320
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2121
2321
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
2122
2322
  const entity = await documentManager2.findOne(id, model, { populate, locale, status });
2123
2323
  if (!entity) {
@@ -2136,8 +2336,8 @@ const collectionTypes = {
2136
2336
  const ids = ctx.request.query.documentIds;
2137
2337
  const locale = ctx.request.query.locale;
2138
2338
  const { model } = ctx.params;
2139
- const documentManager2 = getService$1("document-manager");
2140
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2339
+ const documentManager2 = getService$2("document-manager");
2340
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2141
2341
  if (permissionChecker2.cannot.read()) {
2142
2342
  return ctx.forbidden();
2143
2343
  }
@@ -2161,13 +2361,13 @@ const collectionTypes = {
2161
2361
  };
2162
2362
  const components$1 = {
2163
2363
  findComponents(ctx) {
2164
- const components2 = getService$1("components").findAllComponents();
2165
- const { toDto } = getService$1("data-mapper");
2364
+ const components2 = getService$2("components").findAllComponents();
2365
+ const { toDto } = getService$2("data-mapper");
2166
2366
  ctx.body = { data: components2.map(toDto) };
2167
2367
  },
2168
2368
  async findComponentConfiguration(ctx) {
2169
2369
  const { uid: uid2 } = ctx.params;
2170
- const componentService = getService$1("components");
2370
+ const componentService = getService$2("components");
2171
2371
  const component = componentService.findComponent(uid2);
2172
2372
  if (!component) {
2173
2373
  return ctx.notFound("component.notFound");
@@ -2184,7 +2384,7 @@ const components$1 = {
2184
2384
  async updateComponentConfiguration(ctx) {
2185
2385
  const { uid: uid2 } = ctx.params;
2186
2386
  const { body } = ctx.request;
2187
- const componentService = getService$1("components");
2387
+ const componentService = getService$2("components");
2188
2388
  const component = componentService.findComponent(uid2);
2189
2389
  if (!component) {
2190
2390
  return ctx.notFound("component.notFound");
@@ -2218,12 +2418,12 @@ const contentTypes = {
2218
2418
  } catch (error) {
2219
2419
  return ctx.send({ error }, 400);
2220
2420
  }
2221
- const contentTypes2 = getService$1("content-types").findContentTypesByKind(kind);
2222
- const { toDto } = getService$1("data-mapper");
2421
+ const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
2422
+ const { toDto } = getService$2("data-mapper");
2223
2423
  ctx.body = { data: contentTypes2.map(toDto) };
2224
2424
  },
2225
2425
  async findContentTypesSettings(ctx) {
2226
- const { findAllContentTypes, findConfiguration } = getService$1("content-types");
2426
+ const { findAllContentTypes, findConfiguration } = getService$2("content-types");
2227
2427
  const contentTypes2 = await findAllContentTypes();
2228
2428
  const configurations = await Promise.all(
2229
2429
  contentTypes2.map(async (contentType) => {
@@ -2237,7 +2437,7 @@ const contentTypes = {
2237
2437
  },
2238
2438
  async findContentTypeConfiguration(ctx) {
2239
2439
  const { uid: uid2 } = ctx.params;
2240
- const contentTypeService = getService$1("content-types");
2440
+ const contentTypeService = getService$2("content-types");
2241
2441
  const contentType = await contentTypeService.findContentType(uid2);
2242
2442
  if (!contentType) {
2243
2443
  return ctx.notFound("contentType.notFound");
@@ -2259,13 +2459,13 @@ const contentTypes = {
2259
2459
  const { userAbility } = ctx.state;
2260
2460
  const { uid: uid2 } = ctx.params;
2261
2461
  const { body } = ctx.request;
2262
- const contentTypeService = getService$1("content-types");
2263
- const metricsService = getService$1("metrics");
2462
+ const contentTypeService = getService$2("content-types");
2463
+ const metricsService = getService$2("metrics");
2264
2464
  const contentType = await contentTypeService.findContentType(uid2);
2265
2465
  if (!contentType) {
2266
2466
  return ctx.notFound("contentType.notFound");
2267
2467
  }
2268
- if (!getService$1("permission").canConfigureContentType({ userAbility, contentType })) {
2468
+ if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
2269
2469
  return ctx.forbidden();
2270
2470
  }
2271
2471
  let input;
@@ -2298,10 +2498,10 @@ const contentTypes = {
2298
2498
  };
2299
2499
  const init = {
2300
2500
  getInitData(ctx) {
2301
- const { toDto } = getService$1("data-mapper");
2302
- const { findAllComponents } = getService$1("components");
2303
- const { getAllFieldSizes } = getService$1("field-sizes");
2304
- const { findAllContentTypes } = getService$1("content-types");
2501
+ const { toDto } = getService$2("data-mapper");
2502
+ const { findAllComponents } = getService$2("components");
2503
+ const { getAllFieldSizes } = getService$2("field-sizes");
2504
+ const { findAllContentTypes } = getService$2("content-types");
2305
2505
  ctx.body = {
2306
2506
  data: {
2307
2507
  fieldSizes: getAllFieldSizes(),
@@ -2337,7 +2537,7 @@ const addFiltersClause = (params, filtersClause) => {
2337
2537
  params.filters.$and.push(filtersClause);
2338
2538
  };
2339
2539
  const sanitizeMainField = (model, mainField, userAbility) => {
2340
- const permissionChecker2 = getService$1("permission-checker").create({
2540
+ const permissionChecker2 = getService$2("permission-checker").create({
2341
2541
  userAbility,
2342
2542
  model: model.uid
2343
2543
  });
@@ -2355,7 +2555,7 @@ const addStatusToRelations = async (targetUid, relations2) => {
2355
2555
  if (!contentTypes$1.hasDraftAndPublish(strapi.getModel(targetUid))) {
2356
2556
  return relations2;
2357
2557
  }
2358
- const documentMetadata2 = getService$1("document-metadata");
2558
+ const documentMetadata2 = getService$2("document-metadata");
2359
2559
  if (!relations2.length) {
2360
2560
  return relations2;
2361
2561
  }
@@ -2402,8 +2602,7 @@ const validateStatus = (sourceUid, status) => {
2402
2602
  const sourceModel = strapi.getModel(sourceUid);
2403
2603
  const isDP = contentTypes$1.hasDraftAndPublish;
2404
2604
  const isSourceDP = isDP(sourceModel);
2405
- if (!isSourceDP)
2406
- return { status: void 0 };
2605
+ if (!isSourceDP) return { status: void 0 };
2407
2606
  switch (status) {
2408
2607
  case "published":
2409
2608
  return { status: "published" };
@@ -2433,7 +2632,7 @@ const relations = {
2433
2632
  ctx.request?.query?.locale
2434
2633
  );
2435
2634
  const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
2436
- const permissionChecker2 = getService$1("permission-checker").create({
2635
+ const permissionChecker2 = getService$2("permission-checker").create({
2437
2636
  userAbility,
2438
2637
  model
2439
2638
  });
@@ -2458,7 +2657,7 @@ const relations = {
2458
2657
  where.id = id;
2459
2658
  }
2460
2659
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2461
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2660
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2462
2661
  const currentEntity = await strapi.db.query(model).findOne({
2463
2662
  where,
2464
2663
  populate
@@ -2473,7 +2672,7 @@ const relations = {
2473
2672
  }
2474
2673
  entryId = currentEntity.id;
2475
2674
  }
2476
- const modelConfig = isComponent2 ? await getService$1("components").findConfiguration(sourceSchema) : await getService$1("content-types").findConfiguration(sourceSchema);
2675
+ const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
2477
2676
  const targetSchema = strapi.getModel(targetUid);
2478
2677
  const mainField = flow(
2479
2678
  prop(`metadatas.${targetField}.edit.mainField`),
@@ -2527,7 +2726,7 @@ const relations = {
2527
2726
  }
2528
2727
  } = await this.extractAndValidateRequestInfo(ctx, id);
2529
2728
  const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
2530
- const permissionChecker2 = getService$1("permission-checker").create({
2729
+ const permissionChecker2 = getService$2("permission-checker").create({
2531
2730
  userAbility: ctx.state.userAbility,
2532
2731
  model: targetUid
2533
2732
  });
@@ -2606,7 +2805,7 @@ const relations = {
2606
2805
  } = await this.extractAndValidateRequestInfo(ctx, id);
2607
2806
  const { uid: sourceUid } = sourceSchema;
2608
2807
  const { uid: targetUid } = targetSchema;
2609
- const permissionQuery = await getService$1("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2808
+ const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2610
2809
  const dbQuery = strapi.db.query(sourceUid);
2611
2810
  const loadRelations = relations$1.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
2612
2811
  const filters = {};
@@ -2647,10 +2846,10 @@ const relations = {
2647
2846
  }
2648
2847
  };
2649
2848
  const buildPopulateFromQuery = async (query, model) => {
2650
- return getService$1("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2849
+ return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2651
2850
  };
2652
2851
  const findDocument = async (query, uid2, opts = {}) => {
2653
- const documentManager2 = getService$1("document-manager");
2852
+ const documentManager2 = getService$2("document-manager");
2654
2853
  const populate = await buildPopulateFromQuery(query, uid2);
2655
2854
  return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
2656
2855
  };
@@ -2658,8 +2857,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
2658
2857
  const { user, userAbility } = ctx.state;
2659
2858
  const { model } = ctx.params;
2660
2859
  const { body, query } = ctx.request;
2661
- const documentManager2 = getService$1("document-manager");
2662
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2860
+ const documentManager2 = getService$2("document-manager");
2861
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2663
2862
  if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
2664
2863
  throw new errors.ForbiddenError();
2665
2864
  }
@@ -2700,7 +2899,7 @@ const singleTypes = {
2700
2899
  const { userAbility } = ctx.state;
2701
2900
  const { model } = ctx.params;
2702
2901
  const { query = {} } = ctx.request;
2703
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2902
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2704
2903
  if (permissionChecker2.cannot.read()) {
2705
2904
  return ctx.forbidden();
2706
2905
  }
@@ -2734,7 +2933,7 @@ const singleTypes = {
2734
2933
  async createOrUpdate(ctx) {
2735
2934
  const { userAbility } = ctx.state;
2736
2935
  const { model } = ctx.params;
2737
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2936
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2738
2937
  const document = await createOrUpdateDocument(ctx);
2739
2938
  const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
2740
2939
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
@@ -2743,8 +2942,8 @@ const singleTypes = {
2743
2942
  const { userAbility } = ctx.state;
2744
2943
  const { model } = ctx.params;
2745
2944
  const { query = {} } = ctx.request;
2746
- const documentManager2 = getService$1("document-manager");
2747
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2945
+ const documentManager2 = getService$2("document-manager");
2946
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2748
2947
  if (permissionChecker2.cannot.delete()) {
2749
2948
  return ctx.forbidden();
2750
2949
  }
@@ -2772,8 +2971,8 @@ const singleTypes = {
2772
2971
  const { userAbility } = ctx.state;
2773
2972
  const { model } = ctx.params;
2774
2973
  const { query = {} } = ctx.request;
2775
- const documentManager2 = getService$1("document-manager");
2776
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2974
+ const documentManager2 = getService$2("document-manager");
2975
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2777
2976
  if (permissionChecker2.cannot.publish()) {
2778
2977
  return ctx.forbidden();
2779
2978
  }
@@ -2801,8 +3000,8 @@ const singleTypes = {
2801
3000
  body: { discardDraft, ...body },
2802
3001
  query = {}
2803
3002
  } = ctx.request;
2804
- const documentManager2 = getService$1("document-manager");
2805
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3003
+ const documentManager2 = getService$2("document-manager");
3004
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2806
3005
  if (permissionChecker2.cannot.unpublish()) {
2807
3006
  return ctx.forbidden();
2808
3007
  }
@@ -2836,8 +3035,8 @@ const singleTypes = {
2836
3035
  const { userAbility } = ctx.state;
2837
3036
  const { model } = ctx.params;
2838
3037
  const { body, query = {} } = ctx.request;
2839
- const documentManager2 = getService$1("document-manager");
2840
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3038
+ const documentManager2 = getService$2("document-manager");
3039
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2841
3040
  if (permissionChecker2.cannot.discard()) {
2842
3041
  return ctx.forbidden();
2843
3042
  }
@@ -2860,8 +3059,8 @@ const singleTypes = {
2860
3059
  const { userAbility } = ctx.state;
2861
3060
  const { model } = ctx.params;
2862
3061
  const { query } = ctx.request;
2863
- const documentManager2 = getService$1("document-manager");
2864
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3062
+ const documentManager2 = getService$2("document-manager");
3063
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2865
3064
  const { locale } = await getDocumentLocaleAndStatus(query, model);
2866
3065
  if (permissionChecker2.cannot.read()) {
2867
3066
  return ctx.forbidden();
@@ -2885,7 +3084,7 @@ const uid$1 = {
2885
3084
  const { query = {} } = ctx.request;
2886
3085
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2887
3086
  await validateUIDField(contentTypeUID, field);
2888
- const uidService = getService$1("uid");
3087
+ const uidService = getService$2("uid");
2889
3088
  ctx.body = {
2890
3089
  data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
2891
3090
  };
@@ -2897,7 +3096,7 @@ const uid$1 = {
2897
3096
  const { query = {} } = ctx.request;
2898
3097
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2899
3098
  await validateUIDField(contentTypeUID, field);
2900
- const uidService = getService$1("uid");
3099
+ const uidService = getService$2("uid");
2901
3100
  const isAvailable = await uidService.checkUIDAvailability({
2902
3101
  contentTypeUID,
2903
3102
  field,
@@ -2918,7 +3117,8 @@ const controllers = {
2918
3117
  relations,
2919
3118
  "single-types": singleTypes,
2920
3119
  uid: uid$1,
2921
- ...history.controllers ? history.controllers : {}
3120
+ ...history.controllers ? history.controllers : {},
3121
+ ...preview.controllers ? preview.controllers : {}
2922
3122
  };
2923
3123
  const keys = {
2924
3124
  CONFIGURATION: "configuration"
@@ -3047,18 +3247,15 @@ async function syncMetadatas(configuration, schema) {
3047
3247
  _.set(updatedMeta, ["list", "searchable"], false);
3048
3248
  _.set(acc, [key], updatedMeta);
3049
3249
  }
3050
- if (!_.has(edit, "mainField"))
3051
- return acc;
3250
+ if (!_.has(edit, "mainField")) return acc;
3052
3251
  if (!isRelation$1(attr)) {
3053
3252
  _.set(updatedMeta, "edit", _.omit(edit, ["mainField"]));
3054
3253
  _.set(acc, [key], updatedMeta);
3055
3254
  return acc;
3056
3255
  }
3057
- if (edit.mainField === "id")
3058
- return acc;
3256
+ if (edit.mainField === "id") return acc;
3059
3257
  const targetSchema = getTargetSchema(attr.targetModel);
3060
- if (!targetSchema)
3061
- return acc;
3258
+ if (!targetSchema) return acc;
3062
3259
  if (!isSortable(targetSchema, edit.mainField) && !isListable(targetSchema, edit.mainField)) {
3063
3260
  _.set(updatedMeta, ["edit", "mainField"], getDefaultMainField(targetSchema));
3064
3261
  _.set(acc, [key], updatedMeta);
@@ -3069,12 +3266,12 @@ async function syncMetadatas(configuration, schema) {
3069
3266
  return _.assign(metasWithDefaults, updatedMetas);
3070
3267
  }
3071
3268
  const getTargetSchema = (targetModel) => {
3072
- return getService$1("content-types").findContentType(targetModel);
3269
+ return getService$2("content-types").findContentType(targetModel);
3073
3270
  };
3074
3271
  const DEFAULT_LIST_LENGTH = 4;
3075
3272
  const MAX_ROW_SIZE = 12;
3076
3273
  const isAllowedFieldSize = (type, size) => {
3077
- const { getFieldSize } = getService$1("field-sizes");
3274
+ const { getFieldSize } = getService$2("field-sizes");
3078
3275
  const fieldSize = getFieldSize(type);
3079
3276
  if (!fieldSize.isResizable && size !== fieldSize.default) {
3080
3277
  return false;
@@ -3082,7 +3279,7 @@ const isAllowedFieldSize = (type, size) => {
3082
3279
  return size <= MAX_ROW_SIZE;
3083
3280
  };
3084
3281
  const getDefaultFieldSize = (attribute) => {
3085
- const { hasFieldSize, getFieldSize } = getService$1("field-sizes");
3282
+ const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
3086
3283
  return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
3087
3284
  };
3088
3285
  async function createDefaultLayouts(schema) {
@@ -3103,8 +3300,7 @@ function createDefaultEditLayout(schema) {
3103
3300
  return appendToEditLayout([], keys2, schema);
3104
3301
  }
3105
3302
  function syncLayouts(configuration, schema) {
3106
- if (_.isEmpty(configuration.layouts))
3107
- return createDefaultLayouts(schema);
3303
+ if (_.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
3108
3304
  const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
3109
3305
  let cleanList = list.filter((attr) => isListable(schema, attr));
3110
3306
  const cleanEditRelations = editRelations.filter(
@@ -3115,9 +3311,8 @@ function syncLayouts(configuration, schema) {
3115
3311
  for (const row of edit) {
3116
3312
  const newRow = [];
3117
3313
  for (const el of row) {
3118
- if (!hasEditableAttribute(schema, el.name))
3119
- continue;
3120
- const { hasFieldSize } = getService$1("field-sizes");
3314
+ if (!hasEditableAttribute(schema, el.name)) continue;
3315
+ const { hasFieldSize } = getService$2("field-sizes");
3121
3316
  const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
3122
3317
  if (!isAllowedFieldSize(fieldType, el.size)) {
3123
3318
  elementsToReAppend.push(el.name);
@@ -3147,8 +3342,7 @@ function syncLayouts(configuration, schema) {
3147
3342
  };
3148
3343
  }
3149
3344
  const appendToEditLayout = (layout = [], keysToAppend, schema) => {
3150
- if (keysToAppend.length === 0)
3151
- return layout;
3345
+ if (keysToAppend.length === 0) return layout;
3152
3346
  let currentRowIndex = Math.max(layout.length - 1, 0);
3153
3347
  if (!layout[currentRowIndex]) {
3154
3348
  layout[currentRowIndex] = [];
@@ -3257,17 +3451,17 @@ const configurationService$1 = createConfigurationService({
3257
3451
  isComponent: true,
3258
3452
  prefix: STORE_KEY_PREFIX,
3259
3453
  getModels() {
3260
- const { toContentManagerModel } = getService$1("data-mapper");
3454
+ const { toContentManagerModel } = getService$2("data-mapper");
3261
3455
  return mapValues(toContentManagerModel, strapi.components);
3262
3456
  }
3263
3457
  });
3264
3458
  const components = ({ strapi: strapi2 }) => ({
3265
3459
  findAllComponents() {
3266
- const { toContentManagerModel } = getService$1("data-mapper");
3460
+ const { toContentManagerModel } = getService$2("data-mapper");
3267
3461
  return Object.values(strapi2.components).map(toContentManagerModel);
3268
3462
  },
3269
3463
  findComponent(uid2) {
3270
- const { toContentManagerModel } = getService$1("data-mapper");
3464
+ const { toContentManagerModel } = getService$2("data-mapper");
3271
3465
  const component = strapi2.components[uid2];
3272
3466
  return isNil$1(component) ? component : toContentManagerModel(component);
3273
3467
  },
@@ -3318,17 +3512,17 @@ const configurationService = createConfigurationService({
3318
3512
  storeUtils,
3319
3513
  prefix: "content_types",
3320
3514
  getModels() {
3321
- const { toContentManagerModel } = getService$1("data-mapper");
3515
+ const { toContentManagerModel } = getService$2("data-mapper");
3322
3516
  return mapValues(toContentManagerModel, strapi.contentTypes);
3323
3517
  }
3324
3518
  });
3325
3519
  const service = ({ strapi: strapi2 }) => ({
3326
3520
  findAllContentTypes() {
3327
- const { toContentManagerModel } = getService$1("data-mapper");
3521
+ const { toContentManagerModel } = getService$2("data-mapper");
3328
3522
  return Object.values(strapi2.contentTypes).map(toContentManagerModel);
3329
3523
  },
3330
3524
  findContentType(uid2) {
3331
- const { toContentManagerModel } = getService$1("data-mapper");
3525
+ const { toContentManagerModel } = getService$2("data-mapper");
3332
3526
  const contentType = strapi2.contentTypes[uid2];
3333
3527
  return isNil$1(contentType) ? contentType : toContentManagerModel(contentType);
3334
3528
  },
@@ -3357,7 +3551,7 @@ const service = ({ strapi: strapi2 }) => ({
3357
3551
  return this.findConfiguration(contentType);
3358
3552
  },
3359
3553
  findComponentsConfigurations(contentType) {
3360
- return getService$1("components").findComponentsConfigurations(contentType);
3554
+ return getService$2("components").findComponentsConfigurations(contentType);
3361
3555
  },
3362
3556
  syncConfigurations() {
3363
3557
  return configurationService.syncConfigurations();
@@ -3629,7 +3823,7 @@ const permission = ({ strapi: strapi2 }) => ({
3629
3823
  return userAbility.can(action);
3630
3824
  },
3631
3825
  async registerPermissions() {
3632
- const displayedContentTypes = getService$1("content-types").findDisplayedContentTypes();
3826
+ const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
3633
3827
  const contentTypesUids = displayedContentTypes.map(prop("uid"));
3634
3828
  const actions = [
3635
3829
  {
@@ -3714,6 +3908,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
3714
3908
  if (initialPopulate) {
3715
3909
  return initialPopulate;
3716
3910
  }
3911
+ if (attributeName === "localizations") {
3912
+ const validationPopulate = getPopulateForValidation(model.uid);
3913
+ return {
3914
+ populate: validationPopulate.populate
3915
+ };
3916
+ }
3717
3917
  if (!isVisibleAttribute$1(model, attributeName)) {
3718
3918
  return true;
3719
3919
  }
@@ -3773,6 +3973,9 @@ const getDeepPopulate = (uid2, {
3773
3973
  return {};
3774
3974
  }
3775
3975
  const model = strapi.getModel(uid2);
3976
+ if (!model) {
3977
+ return {};
3978
+ }
3776
3979
  return Object.keys(model.attributes).reduce(
3777
3980
  (populateAcc, attributeName) => merge(
3778
3981
  populateAcc,
@@ -3792,40 +3995,46 @@ const getDeepPopulate = (uid2, {
3792
3995
  {}
3793
3996
  );
3794
3997
  };
3795
- const getValidatableFieldsPopulate = (uid2, {
3796
- initialPopulate = {},
3797
- countMany = false,
3798
- countOne = false,
3799
- maxLevel = Infinity
3800
- } = {}, level = 1) => {
3801
- if (level > maxLevel) {
3998
+ const getPopulateForValidation = (uid2) => {
3999
+ const model = strapi.getModel(uid2);
4000
+ if (!model) {
3802
4001
  return {};
3803
4002
  }
3804
- const model = strapi.getModel(uid2);
3805
4003
  return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
3806
- if (!getDoesAttributeRequireValidation(attribute)) {
4004
+ if (isScalarAttribute(attribute)) {
4005
+ if (getDoesAttributeRequireValidation(attribute)) {
4006
+ populateAcc.fields = populateAcc.fields || [];
4007
+ populateAcc.fields.push(attributeName);
4008
+ }
3807
4009
  return populateAcc;
3808
4010
  }
3809
- if (isScalarAttribute(attribute)) {
3810
- return merge(populateAcc, {
3811
- [attributeName]: true
3812
- });
4011
+ if (isComponent(attribute)) {
4012
+ const component = attribute.component;
4013
+ const componentResult = getPopulateForValidation(component);
4014
+ if (Object.keys(componentResult).length > 0) {
4015
+ populateAcc.populate = populateAcc.populate || {};
4016
+ populateAcc.populate[attributeName] = componentResult;
4017
+ }
4018
+ return populateAcc;
3813
4019
  }
3814
- return merge(
3815
- populateAcc,
3816
- getPopulateFor(
3817
- attributeName,
3818
- model,
3819
- {
3820
- // @ts-expect-error - improve types
3821
- initialPopulate: initialPopulate?.[attributeName],
3822
- countMany,
3823
- countOne,
3824
- maxLevel
4020
+ if (isDynamicZone(attribute)) {
4021
+ const components2 = attribute.components;
4022
+ const componentsResult = (components2 || []).reduce(
4023
+ (acc, componentUID) => {
4024
+ const componentResult = getPopulateForValidation(componentUID);
4025
+ if (Object.keys(componentResult).length > 0) {
4026
+ acc[componentUID] = componentResult;
4027
+ }
4028
+ return acc;
3825
4029
  },
3826
- level
3827
- )
3828
- );
4030
+ {}
4031
+ );
4032
+ if (Object.keys(componentsResult).length > 0) {
4033
+ populateAcc.populate = populateAcc.populate || {};
4034
+ populateAcc.populate[attributeName] = { on: componentsResult };
4035
+ }
4036
+ }
4037
+ return populateAcc;
3829
4038
  }, {});
3830
4039
  };
3831
4040
  const getDeepPopulateDraftCount = (uid2) => {
@@ -3905,7 +4114,7 @@ const getQueryPopulate = async (uid2, query) => {
3905
4114
  return populateQuery;
3906
4115
  };
3907
4116
  const buildDeepPopulate = (uid2) => {
3908
- return getService$1("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
4117
+ return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
3909
4118
  };
3910
4119
  const populateBuilder = (uid2) => {
3911
4120
  let getInitialPopulate = async () => {
@@ -4067,7 +4276,6 @@ const AVAILABLE_LOCALES_FIELDS = [
4067
4276
  "locale",
4068
4277
  "updatedAt",
4069
4278
  "createdAt",
4070
- "status",
4071
4279
  "publishedAt",
4072
4280
  "documentId"
4073
4281
  ];
@@ -4088,36 +4296,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4088
4296
  /**
4089
4297
  * Returns available locales of a document for the current status
4090
4298
  */
4091
- async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
4299
+ async getAvailableLocales(uid2, version, allVersions) {
4092
4300
  const versionsByLocale = groupBy("locale", allVersions);
4093
4301
  if (version.locale) {
4094
4302
  delete versionsByLocale[version.locale];
4095
4303
  }
4096
4304
  const model = strapi2.getModel(uid2);
4097
- const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
4098
- const traversalFunction = async (localeVersion) => traverseEntity(
4099
- ({ key }, { remove }) => {
4100
- if (keysToKeep.includes(key)) {
4101
- return;
4102
- }
4103
- remove(key);
4104
- },
4105
- { schema: model, getModel: strapi2.getModel.bind(strapi2) },
4106
- // @ts-expect-error fix types DocumentVersion incompatible with Data
4107
- localeVersion
4108
- );
4109
4305
  const mappingResult = await async.map(
4110
4306
  Object.values(versionsByLocale),
4111
4307
  async (localeVersions) => {
4112
- const mappedLocaleVersions = await async.map(
4113
- localeVersions,
4114
- traversalFunction
4115
- );
4116
4308
  if (!contentTypes$1.hasDraftAndPublish(model)) {
4117
- return mappedLocaleVersions[0];
4309
+ return localeVersions[0];
4118
4310
  }
4119
- const draftVersion = mappedLocaleVersions.find((v) => v.publishedAt === null);
4120
- const otherVersions = mappedLocaleVersions.filter((v) => v.id !== draftVersion?.id);
4311
+ const draftVersion = localeVersions.find((v) => v.publishedAt === null);
4312
+ const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
4121
4313
  if (!draftVersion) {
4122
4314
  return;
4123
4315
  }
@@ -4139,8 +4331,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4139
4331
  const matchStatus = status === "published" ? v.publishedAt !== null : v.publishedAt === null;
4140
4332
  return matchLocale && matchStatus;
4141
4333
  });
4142
- if (!availableStatus)
4143
- return availableStatus;
4334
+ if (!availableStatus) return availableStatus;
4144
4335
  return pick(AVAILABLE_STATUS_FIELDS, availableStatus);
4145
4336
  },
4146
4337
  /**
@@ -4150,18 +4341,19 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4150
4341
  * @returns
4151
4342
  */
4152
4343
  async getManyAvailableStatus(uid2, documents) {
4153
- if (!documents.length)
4154
- return [];
4344
+ if (!documents.length) return [];
4155
4345
  const status = documents[0].publishedAt !== null ? "published" : "draft";
4156
- const locale = documents[0]?.locale;
4157
- const otherStatus = status === "published" ? "draft" : "published";
4158
- return strapi2.documents(uid2).findMany({
4159
- filters: {
4160
- documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) }
4161
- },
4162
- status: otherStatus,
4163
- locale,
4164
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4346
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4347
+ const where = {
4348
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4349
+ publishedAt: { $null: status === "published" }
4350
+ };
4351
+ if (locales.length) {
4352
+ where.locale = { $in: locales };
4353
+ }
4354
+ return strapi2.query(uid2).findMany({
4355
+ where,
4356
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4165
4357
  });
4166
4358
  },
4167
4359
  getStatus(version, otherDocumentStatuses) {
@@ -4178,10 +4370,8 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4178
4370
  } else if (otherVersion) {
4179
4371
  draftVersion = otherVersion;
4180
4372
  }
4181
- if (!draftVersion)
4182
- return CONTENT_MANAGER_STATUS.PUBLISHED;
4183
- if (!publishedVersion)
4184
- return CONTENT_MANAGER_STATUS.DRAFT;
4373
+ if (!draftVersion) return CONTENT_MANAGER_STATUS.PUBLISHED;
4374
+ if (!publishedVersion) return CONTENT_MANAGER_STATUS.DRAFT;
4185
4375
  const isDraftModified = getIsVersionLatestModification(draftVersion, publishedVersion);
4186
4376
  return isDraftModified ? CONTENT_MANAGER_STATUS.MODIFIED : CONTENT_MANAGER_STATUS.PUBLISHED;
4187
4377
  },
@@ -4189,11 +4379,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4189
4379
  // We could refactor this so the locales are only loaded when they're
4190
4380
  // needed. e.g. in the bulk locale action modal.
4191
4381
  async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
4192
- const populate = getValidatableFieldsPopulate(uid2);
4193
- const versions = await strapi2.db.query(uid2).findMany({
4194
- where: { documentId: version.documentId },
4382
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4383
+ const params = {
4195
4384
  populate: {
4196
- // Populate only fields that require validation for bulk locale actions
4197
4385
  ...populate,
4198
4386
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4199
4387
  createdBy: {
@@ -4202,9 +4390,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4202
4390
  updatedBy: {
4203
4391
  select: ["id", "firstname", "lastname", "email"]
4204
4392
  }
4393
+ },
4394
+ fields: uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4395
+ filters: {
4396
+ documentId: version.documentId
4205
4397
  }
4206
- });
4207
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4398
+ };
4399
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4400
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4401
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4208
4402
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4209
4403
  return {
4210
4404
  availableLocales: availableLocalesResult,
@@ -4231,6 +4425,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4231
4425
  opts.availableStatus = false;
4232
4426
  }
4233
4427
  const meta = await this.getMetadata(uid2, document, opts);
4428
+ if (document.localizations) {
4429
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4430
+ document.localizations = document.localizations.map((d) => {
4431
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4432
+ return {
4433
+ ...d,
4434
+ status: this.getStatus(d, status ? [status] : [])
4435
+ };
4436
+ });
4437
+ }
4234
4438
  return {
4235
4439
  data: {
4236
4440
  ...document,
@@ -4448,7 +4652,8 @@ const services = {
4448
4652
  permission,
4449
4653
  "populate-builder": populateBuilder$1,
4450
4654
  uid,
4451
- ...history.services ? history.services : {}
4655
+ ...history.services ? history.services : {},
4656
+ ...preview.services ? preview.services : {}
4452
4657
  };
4453
4658
  const index = () => {
4454
4659
  return {