@strapi/content-manager 0.0.0-next.d65d44102fd32871728c0d74ec4f2519b7cc0a16 → 0.0.0-next.e8d8fc824d0f6a695b2a9ebaa4680ed21c3645ca

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 (110) 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-UduDBv3m.js → ComponentConfigurationPage-BlzvDpbX.js} +4 -5
  4. package/dist/_chunks/{ComponentConfigurationPage-UduDBv3m.js.map → ComponentConfigurationPage-BlzvDpbX.js.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-DhWA-JzT.mjs → ComponentConfigurationPage-DaPOlQaD.mjs} +3 -3
  6. package/dist/_chunks/{ComponentConfigurationPage-DhWA-JzT.mjs.map → ComponentConfigurationPage-DaPOlQaD.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-5tmx_7Hp.mjs → EditConfigurationPage-BZPXItXo.mjs} +3 -3
  11. package/dist/_chunks/{EditConfigurationPage-5tmx_7Hp.mjs.map → EditConfigurationPage-BZPXItXo.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-Cp9UzUfs.js → EditConfigurationPage-uy-v43AR.js} +4 -5
  13. package/dist/_chunks/{EditConfigurationPage-Cp9UzUfs.js.map → EditConfigurationPage-uy-v43AR.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-C7l2Emuj.js → EditViewPage-DT6A4ayX.js} +4 -5
  15. package/dist/_chunks/{EditViewPage-C7l2Emuj.js.map → EditViewPage-DT6A4ayX.js.map} +1 -1
  16. package/dist/_chunks/{EditViewPage-BKoISUOu.mjs → EditViewPage-oOLeTySr.mjs} +3 -3
  17. package/dist/_chunks/{EditViewPage-BKoISUOu.mjs.map → EditViewPage-oOLeTySr.mjs.map} +1 -1
  18. package/dist/_chunks/{Field-BZxzYf1x.mjs → Field-D7dv2aUX.mjs} +129 -96
  19. package/dist/_chunks/Field-D7dv2aUX.mjs.map +1 -0
  20. package/dist/_chunks/{Field-BPSJpDfE.js → Field-kYFVIGiP.js} +132 -99
  21. package/dist/_chunks/Field-kYFVIGiP.js.map +1 -0
  22. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  23. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  24. package/dist/_chunks/{Form-8qyOU6YG.mjs → Form-BxR6sc29.mjs} +3 -3
  25. package/dist/_chunks/{Form-8qyOU6YG.mjs.map → Form-BxR6sc29.mjs.map} +1 -1
  26. package/dist/_chunks/{Form-DLkqDd2G.js → Form-CCijSg3V.js} +5 -6
  27. package/dist/_chunks/{Form-DLkqDd2G.js.map → Form-CCijSg3V.js.map} +1 -1
  28. package/dist/_chunks/{History-DYMicybF.js → History-BMndx49M.js} +5 -6
  29. package/dist/_chunks/{History-DYMicybF.js.map → History-BMndx49M.js.map} +1 -1
  30. package/dist/_chunks/{History-N_kRb1Yr.mjs → History-D8F7aYQU.mjs} +4 -4
  31. package/dist/_chunks/{History-N_kRb1Yr.mjs.map → History-D8F7aYQU.mjs.map} +1 -1
  32. package/dist/_chunks/{ListConfigurationPage-rUF9iGWq.js → ListConfigurationPage-DouY1EWM.js} +4 -5
  33. package/dist/_chunks/{ListConfigurationPage-rUF9iGWq.js.map → ListConfigurationPage-DouY1EWM.js.map} +1 -1
  34. package/dist/_chunks/{ListConfigurationPage-BM3qVxug.mjs → ListConfigurationPage-DqAdSPwC.mjs} +3 -3
  35. package/dist/_chunks/{ListConfigurationPage-BM3qVxug.mjs.map → ListConfigurationPage-DqAdSPwC.mjs.map} +1 -1
  36. package/dist/_chunks/{ListViewPage-BSLzd7cZ.js → ListViewPage-BPVmh9pq.js} +4 -5
  37. package/dist/_chunks/{ListViewPage-BSLzd7cZ.js.map → ListViewPage-BPVmh9pq.js.map} +1 -1
  38. package/dist/_chunks/{ListViewPage-CWilGbZb.mjs → ListViewPage-C73F0jPh.mjs} +3 -3
  39. package/dist/_chunks/{ListViewPage-CWilGbZb.mjs.map → ListViewPage-C73F0jPh.mjs.map} +1 -1
  40. package/dist/_chunks/{NoContentTypePage-VWYlePwI.mjs → NoContentTypePage-B5w7iJOF.mjs} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-VWYlePwI.mjs.map → NoContentTypePage-B5w7iJOF.mjs.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-CQccVhIX.js → NoContentTypePage-BwcL--4H.js} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-CQccVhIX.js.map → NoContentTypePage-BwcL--4H.js.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-Af32Gg2m.js → NoPermissionsPage-BMFKVcwJ.js} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-Af32Gg2m.js.map → NoPermissionsPage-BMFKVcwJ.js.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-CS2tCmfr.mjs → NoPermissionsPage-UnEgMGK4.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-CS2tCmfr.mjs.map → NoPermissionsPage-UnEgMGK4.mjs.map} +1 -1
  48. package/dist/_chunks/{Preview-D4KzuJFL.js → Preview-B7PR3Ok_.js} +33 -12
  49. package/dist/_chunks/Preview-B7PR3Ok_.js.map +1 -0
  50. package/dist/_chunks/{Preview-kPkuZbBJ.mjs → Preview-DECOhK0D.mjs} +33 -11
  51. package/dist/_chunks/Preview-DECOhK0D.mjs.map +1 -0
  52. package/dist/_chunks/{Relations-5k27Rh54.mjs → Relations-DinMQJ4B.mjs} +6 -8
  53. package/dist/_chunks/{Relations-5k27Rh54.mjs.map → Relations-DinMQJ4B.mjs.map} +1 -1
  54. package/dist/_chunks/{Relations-D_Ki5aVM.js → Relations-lndx3aQk.js} +7 -10
  55. package/dist/_chunks/{Relations-D_Ki5aVM.js.map → Relations-lndx3aQk.js.map} +1 -1
  56. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  57. package/dist/_chunks/{index-BLPa8Dq-.mjs → index-C2SagWVW.mjs} +167 -114
  58. package/dist/_chunks/index-C2SagWVW.mjs.map +1 -0
  59. package/dist/_chunks/{index-DwOsF7wF.js → index-Cnw4gqee.js} +168 -116
  60. package/dist/_chunks/index-Cnw4gqee.js.map +1 -0
  61. package/dist/_chunks/{layout-2Si0j0jO.mjs → layout-DY_D9MGA.mjs} +4 -4
  62. package/dist/_chunks/{layout-2Si0j0jO.mjs.map → layout-DY_D9MGA.mjs.map} +1 -1
  63. package/dist/_chunks/{layout-CN2bFL9V.js → layout-ivwIVPnV.js} +5 -6
  64. package/dist/_chunks/{layout-CN2bFL9V.js.map → layout-ivwIVPnV.js.map} +1 -1
  65. package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
  66. package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
  67. package/dist/_chunks/{relations-B0E0XUY7.js → relations-B7C7O_Pv.js} +2 -2
  68. package/dist/_chunks/{relations-B0E0XUY7.js.map → relations-B7C7O_Pv.js.map} +1 -1
  69. package/dist/_chunks/{relations-CAxDjUJF.mjs → relations-Boc5Y9kX.mjs} +2 -2
  70. package/dist/_chunks/{relations-CAxDjUJF.mjs.map → relations-Boc5Y9kX.mjs.map} +1 -1
  71. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
  72. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
  73. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  74. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  75. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  76. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  77. package/dist/admin/index.js +1 -1
  78. package/dist/admin/index.mjs +1 -1
  79. package/dist/admin/src/content-manager.d.ts +3 -2
  80. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  81. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  82. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  83. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  84. package/dist/server/index.js +92 -102
  85. package/dist/server/index.js.map +1 -1
  86. package/dist/server/index.mjs +92 -101
  87. package/dist/server/index.mjs.map +1 -1
  88. package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
  89. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  90. package/dist/server/src/index.d.ts +3 -2
  91. package/dist/server/src/index.d.ts.map +1 -1
  92. package/dist/server/src/preview/index.d.ts.map +1 -1
  93. package/dist/server/src/services/document-metadata.d.ts +4 -2
  94. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  95. package/dist/server/src/services/index.d.ts +3 -2
  96. package/dist/server/src/services/index.d.ts.map +1 -1
  97. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  98. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  99. package/dist/server/src/services/utils/populate.d.ts +2 -2
  100. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  101. package/package.json +9 -7
  102. package/dist/_chunks/Field-BPSJpDfE.js.map +0 -1
  103. package/dist/_chunks/Field-BZxzYf1x.mjs.map +0 -1
  104. package/dist/_chunks/Preview-D4KzuJFL.js.map +0 -1
  105. package/dist/_chunks/Preview-kPkuZbBJ.mjs.map +0 -1
  106. package/dist/_chunks/index-BLPa8Dq-.mjs.map +0 -1
  107. package/dist/_chunks/index-DwOsF7wF.js.map +0 -1
  108. package/dist/admin/src/preview/constants.d.ts +0 -1
  109. package/dist/server/src/preview/constants.d.ts +0 -2
  110. package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -1,4 +1,4 @@
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";
1
+ import strapiUtils, { validateYupSchema, errors, async, contentTypes as contentTypes$1, yup as yup$1, validateYupSchemaSync, policy, traverse, setCreatorFields, isOperatorOfType, relations as relations$1, pagination } from "@strapi/utils";
2
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";
@@ -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({
@@ -177,8 +176,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
177
176
  const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
178
177
  const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
179
178
  const getLocaleDictionary = async () => {
180
- if (!localesService)
181
- return {};
179
+ if (!localesService) return {};
182
180
  const locales = await localesService.find() || [];
183
181
  return locales.reduce(
184
182
  (acc, locale) => {
@@ -714,7 +712,6 @@ const getFeature$1 = () => {
714
712
  };
715
713
  };
716
714
  const history = getFeature$1();
717
- const FEATURE_ID = "preview";
718
715
  const info = { pluginName: "content-manager", type: "admin" };
719
716
  const previewRouter = {
720
717
  type: "admin",
@@ -892,9 +889,6 @@ const services$1 = {
892
889
  "preview-config": createPreviewConfigService
893
890
  };
894
891
  const getFeature = () => {
895
- if (!strapi.features.future.isEnabled(FEATURE_ID)) {
896
- return {};
897
- }
898
892
  return {
899
893
  register() {
900
894
  const config = getService(strapi, "preview-config");
@@ -1480,8 +1474,7 @@ const isSortable = (schema, name) => {
1480
1474
  if (!_.has(schema.attributes, name)) {
1481
1475
  return false;
1482
1476
  }
1483
- if (schema.modelType === "component" && name === "id")
1484
- return false;
1477
+ if (schema.modelType === "component" && name === "id") return false;
1485
1478
  const attribute = schema.attributes[name];
1486
1479
  if (NON_SORTABLES.includes(attribute.type)) {
1487
1480
  return false;
@@ -1626,8 +1619,7 @@ const createDefaultSettings = async (schema) => {
1626
1619
  };
1627
1620
  };
1628
1621
  const syncSettings = async (configuration, schema) => {
1629
- if (isEmpty(configuration.settings))
1630
- return createDefaultSettings(schema);
1622
+ if (isEmpty(configuration.settings)) return createDefaultSettings(schema);
1631
1623
  const defaultField = getDefaultMainField(schema);
1632
1624
  const { mainField = defaultField, defaultSortBy = defaultField } = configuration.settings || {};
1633
1625
  return {
@@ -1803,8 +1795,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1803
1795
  }
1804
1796
  switch (attribute.type) {
1805
1797
  case "relation": {
1806
- if (canCreate(attributePath))
1807
- return body2;
1798
+ if (canCreate(attributePath)) return body2;
1808
1799
  return set(attributePath, { set: [] }, body2);
1809
1800
  }
1810
1801
  case "component": {
@@ -1814,8 +1805,7 @@ const excludeNotCreatableFields = (uid2, permissionChecker2) => (body, path = []
1814
1805
  ]);
1815
1806
  }
1816
1807
  default: {
1817
- if (canCreate(attributePath))
1818
- return body2;
1808
+ if (canCreate(attributePath)) return body2;
1819
1809
  return set(attributePath, null, body2);
1820
1810
  }
1821
1811
  }
@@ -2608,8 +2598,7 @@ const validateStatus = (sourceUid, status) => {
2608
2598
  const sourceModel = strapi.getModel(sourceUid);
2609
2599
  const isDP = contentTypes$1.hasDraftAndPublish;
2610
2600
  const isSourceDP = isDP(sourceModel);
2611
- if (!isSourceDP)
2612
- return { status: void 0 };
2601
+ if (!isSourceDP) return { status: void 0 };
2613
2602
  switch (status) {
2614
2603
  case "published":
2615
2604
  return { status: "published" };
@@ -3254,18 +3243,15 @@ async function syncMetadatas(configuration, schema) {
3254
3243
  _.set(updatedMeta, ["list", "searchable"], false);
3255
3244
  _.set(acc, [key], updatedMeta);
3256
3245
  }
3257
- if (!_.has(edit, "mainField"))
3258
- return acc;
3246
+ if (!_.has(edit, "mainField")) return acc;
3259
3247
  if (!isRelation$1(attr)) {
3260
3248
  _.set(updatedMeta, "edit", _.omit(edit, ["mainField"]));
3261
3249
  _.set(acc, [key], updatedMeta);
3262
3250
  return acc;
3263
3251
  }
3264
- if (edit.mainField === "id")
3265
- return acc;
3252
+ if (edit.mainField === "id") return acc;
3266
3253
  const targetSchema = getTargetSchema(attr.targetModel);
3267
- if (!targetSchema)
3268
- return acc;
3254
+ if (!targetSchema) return acc;
3269
3255
  if (!isSortable(targetSchema, edit.mainField) && !isListable(targetSchema, edit.mainField)) {
3270
3256
  _.set(updatedMeta, ["edit", "mainField"], getDefaultMainField(targetSchema));
3271
3257
  _.set(acc, [key], updatedMeta);
@@ -3310,8 +3296,7 @@ function createDefaultEditLayout(schema) {
3310
3296
  return appendToEditLayout([], keys2, schema);
3311
3297
  }
3312
3298
  function syncLayouts(configuration, schema) {
3313
- if (_.isEmpty(configuration.layouts))
3314
- return createDefaultLayouts(schema);
3299
+ if (_.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
3315
3300
  const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
3316
3301
  let cleanList = list.filter((attr) => isListable(schema, attr));
3317
3302
  const cleanEditRelations = editRelations.filter(
@@ -3322,8 +3307,7 @@ function syncLayouts(configuration, schema) {
3322
3307
  for (const row of edit) {
3323
3308
  const newRow = [];
3324
3309
  for (const el of row) {
3325
- if (!hasEditableAttribute(schema, el.name))
3326
- continue;
3310
+ if (!hasEditableAttribute(schema, el.name)) continue;
3327
3311
  const { hasFieldSize } = getService$2("field-sizes");
3328
3312
  const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
3329
3313
  if (!isAllowedFieldSize(fieldType, el.size)) {
@@ -3354,8 +3338,7 @@ function syncLayouts(configuration, schema) {
3354
3338
  };
3355
3339
  }
3356
3340
  const appendToEditLayout = (layout = [], keysToAppend, schema) => {
3357
- if (keysToAppend.length === 0)
3358
- return layout;
3341
+ if (keysToAppend.length === 0) return layout;
3359
3342
  let currentRowIndex = Math.max(layout.length - 1, 0);
3360
3343
  if (!layout[currentRowIndex]) {
3361
3344
  layout[currentRowIndex] = [];
@@ -3921,6 +3904,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
3921
3904
  if (initialPopulate) {
3922
3905
  return initialPopulate;
3923
3906
  }
3907
+ if (attributeName === "localizations") {
3908
+ const validationPopulate = getPopulateForValidation(model.uid);
3909
+ return {
3910
+ populate: validationPopulate.populate
3911
+ };
3912
+ }
3924
3913
  if (!isVisibleAttribute$1(model, attributeName)) {
3925
3914
  return true;
3926
3915
  }
@@ -3980,6 +3969,9 @@ const getDeepPopulate = (uid2, {
3980
3969
  return {};
3981
3970
  }
3982
3971
  const model = strapi.getModel(uid2);
3972
+ if (!model) {
3973
+ return {};
3974
+ }
3983
3975
  return Object.keys(model.attributes).reduce(
3984
3976
  (populateAcc, attributeName) => merge(
3985
3977
  populateAcc,
@@ -3999,40 +3991,46 @@ const getDeepPopulate = (uid2, {
3999
3991
  {}
4000
3992
  );
4001
3993
  };
4002
- const getValidatableFieldsPopulate = (uid2, {
4003
- initialPopulate = {},
4004
- countMany = false,
4005
- countOne = false,
4006
- maxLevel = Infinity
4007
- } = {}, level = 1) => {
4008
- if (level > maxLevel) {
3994
+ const getPopulateForValidation = (uid2) => {
3995
+ const model = strapi.getModel(uid2);
3996
+ if (!model) {
4009
3997
  return {};
4010
3998
  }
4011
- const model = strapi.getModel(uid2);
4012
3999
  return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
4013
- if (!getDoesAttributeRequireValidation(attribute)) {
4000
+ if (isScalarAttribute(attribute)) {
4001
+ if (getDoesAttributeRequireValidation(attribute)) {
4002
+ populateAcc.fields = populateAcc.fields || [];
4003
+ populateAcc.fields.push(attributeName);
4004
+ }
4014
4005
  return populateAcc;
4015
4006
  }
4016
- if (isScalarAttribute(attribute)) {
4017
- return merge(populateAcc, {
4018
- [attributeName]: true
4019
- });
4007
+ if (isComponent(attribute)) {
4008
+ const component = attribute.component;
4009
+ const componentResult = getPopulateForValidation(component);
4010
+ if (Object.keys(componentResult).length > 0) {
4011
+ populateAcc.populate = populateAcc.populate || {};
4012
+ populateAcc.populate[attributeName] = componentResult;
4013
+ }
4014
+ return populateAcc;
4020
4015
  }
4021
- return merge(
4022
- populateAcc,
4023
- getPopulateFor(
4024
- attributeName,
4025
- model,
4026
- {
4027
- // @ts-expect-error - improve types
4028
- initialPopulate: initialPopulate?.[attributeName],
4029
- countMany,
4030
- countOne,
4031
- maxLevel
4016
+ if (isDynamicZone(attribute)) {
4017
+ const components2 = attribute.components;
4018
+ const componentsResult = (components2 || []).reduce(
4019
+ (acc, componentUID) => {
4020
+ const componentResult = getPopulateForValidation(componentUID);
4021
+ if (Object.keys(componentResult).length > 0) {
4022
+ acc[componentUID] = componentResult;
4023
+ }
4024
+ return acc;
4032
4025
  },
4033
- level
4034
- )
4035
- );
4026
+ {}
4027
+ );
4028
+ if (Object.keys(componentsResult).length > 0) {
4029
+ populateAcc.populate = populateAcc.populate || {};
4030
+ populateAcc.populate[attributeName] = { on: componentsResult };
4031
+ }
4032
+ }
4033
+ return populateAcc;
4036
4034
  }, {});
4037
4035
  };
4038
4036
  const getDeepPopulateDraftCount = (uid2) => {
@@ -4274,7 +4272,6 @@ const AVAILABLE_LOCALES_FIELDS = [
4274
4272
  "locale",
4275
4273
  "updatedAt",
4276
4274
  "createdAt",
4277
- "status",
4278
4275
  "publishedAt",
4279
4276
  "documentId"
4280
4277
  ];
@@ -4295,36 +4292,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4295
4292
  /**
4296
4293
  * Returns available locales of a document for the current status
4297
4294
  */
4298
- async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
4295
+ async getAvailableLocales(uid2, version, allVersions) {
4299
4296
  const versionsByLocale = groupBy("locale", allVersions);
4300
4297
  if (version.locale) {
4301
4298
  delete versionsByLocale[version.locale];
4302
4299
  }
4303
4300
  const model = strapi2.getModel(uid2);
4304
- const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
4305
- const traversalFunction = async (localeVersion) => traverseEntity(
4306
- ({ key }, { remove }) => {
4307
- if (keysToKeep.includes(key)) {
4308
- return;
4309
- }
4310
- remove(key);
4311
- },
4312
- { schema: model, getModel: strapi2.getModel.bind(strapi2) },
4313
- // @ts-expect-error fix types DocumentVersion incompatible with Data
4314
- localeVersion
4315
- );
4316
4301
  const mappingResult = await async.map(
4317
4302
  Object.values(versionsByLocale),
4318
4303
  async (localeVersions) => {
4319
- const mappedLocaleVersions = await async.map(
4320
- localeVersions,
4321
- traversalFunction
4322
- );
4323
4304
  if (!contentTypes$1.hasDraftAndPublish(model)) {
4324
- return mappedLocaleVersions[0];
4305
+ return localeVersions[0];
4325
4306
  }
4326
- const draftVersion = mappedLocaleVersions.find((v) => v.publishedAt === null);
4327
- const otherVersions = mappedLocaleVersions.filter((v) => v.id !== draftVersion?.id);
4307
+ const draftVersion = localeVersions.find((v) => v.publishedAt === null);
4308
+ const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
4328
4309
  if (!draftVersion) {
4329
4310
  return;
4330
4311
  }
@@ -4346,8 +4327,7 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4346
4327
  const matchStatus = status === "published" ? v.publishedAt !== null : v.publishedAt === null;
4347
4328
  return matchLocale && matchStatus;
4348
4329
  });
4349
- if (!availableStatus)
4350
- return availableStatus;
4330
+ if (!availableStatus) return availableStatus;
4351
4331
  return pick(AVAILABLE_STATUS_FIELDS, availableStatus);
4352
4332
  },
4353
4333
  /**
@@ -4357,18 +4337,17 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4357
4337
  * @returns
4358
4338
  */
4359
4339
  async getManyAvailableStatus(uid2, documents) {
4360
- if (!documents.length)
4361
- return [];
4340
+ if (!documents.length) return [];
4362
4341
  const status = documents[0].publishedAt !== null ? "published" : "draft";
4363
- const locale = documents[0]?.locale;
4364
- const otherStatus = status === "published" ? "draft" : "published";
4365
- return strapi2.documents(uid2).findMany({
4366
- filters: {
4367
- documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) }
4342
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4343
+ return strapi2.query(uid2).findMany({
4344
+ where: {
4345
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4346
+ // NOTE: find the "opposite" status
4347
+ publishedAt: { $null: status === "published" },
4348
+ locale: { $in: locales }
4368
4349
  },
4369
- status: otherStatus,
4370
- locale,
4371
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4350
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4372
4351
  });
4373
4352
  },
4374
4353
  getStatus(version, otherDocumentStatuses) {
@@ -4385,10 +4364,8 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4385
4364
  } else if (otherVersion) {
4386
4365
  draftVersion = otherVersion;
4387
4366
  }
4388
- if (!draftVersion)
4389
- return CONTENT_MANAGER_STATUS.PUBLISHED;
4390
- if (!publishedVersion)
4391
- return CONTENT_MANAGER_STATUS.DRAFT;
4367
+ if (!draftVersion) return CONTENT_MANAGER_STATUS.PUBLISHED;
4368
+ if (!publishedVersion) return CONTENT_MANAGER_STATUS.DRAFT;
4392
4369
  const isDraftModified = getIsVersionLatestModification(draftVersion, publishedVersion);
4393
4370
  return isDraftModified ? CONTENT_MANAGER_STATUS.MODIFIED : CONTENT_MANAGER_STATUS.PUBLISHED;
4394
4371
  },
@@ -4396,11 +4373,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4396
4373
  // We could refactor this so the locales are only loaded when they're
4397
4374
  // needed. e.g. in the bulk locale action modal.
4398
4375
  async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
4399
- const populate = getValidatableFieldsPopulate(uid2);
4400
- const versions = await strapi2.db.query(uid2).findMany({
4401
- where: { documentId: version.documentId },
4376
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4377
+ const params = {
4402
4378
  populate: {
4403
- // Populate only fields that require validation for bulk locale actions
4404
4379
  ...populate,
4405
4380
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4406
4381
  createdBy: {
@@ -4409,9 +4384,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4409
4384
  updatedBy: {
4410
4385
  select: ["id", "firstname", "lastname", "email"]
4411
4386
  }
4387
+ },
4388
+ fields: uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4389
+ filters: {
4390
+ documentId: version.documentId
4412
4391
  }
4413
- });
4414
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4392
+ };
4393
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4394
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4395
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4415
4396
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4416
4397
  return {
4417
4398
  availableLocales: availableLocalesResult,
@@ -4438,6 +4419,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4438
4419
  opts.availableStatus = false;
4439
4420
  }
4440
4421
  const meta = await this.getMetadata(uid2, document, opts);
4422
+ if (document.localizations) {
4423
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4424
+ document.localizations = document.localizations.map((d) => {
4425
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4426
+ return {
4427
+ ...d,
4428
+ status: this.getStatus(d, status ? [status] : [])
4429
+ };
4430
+ });
4431
+ }
4441
4432
  return {
4442
4433
  data: {
4443
4434
  ...document,