@strapi/content-manager 0.0.0-experimental.cfda358b7f27015e34e739b8742a2962ae2e7aee → 0.0.0-experimental.d3cdf79a0d5f803dfeb6d0f055bb2f3b913bb015

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 (85) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js → ComponentConfigurationPage-BSEZcJVB.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js.map → ComponentConfigurationPage-BSEZcJVB.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs → ComponentConfigurationPage-BiASGi7x.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs.map → ComponentConfigurationPage-BiASGi7x.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js → EditConfigurationPage-D2rtvneE.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js.map → EditConfigurationPage-D2rtvneE.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs → EditConfigurationPage-vN4zupij.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs.map → EditConfigurationPage-vN4zupij.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-wujOq90c.js → EditViewPage-BwisF04Q.js} +3 -3
  10. package/dist/_chunks/{EditViewPage-wujOq90c.js.map → EditViewPage-BwisF04Q.js.map} +1 -1
  11. package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs → EditViewPage-_A31Cl4g.mjs} +3 -3
  12. package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs.map → EditViewPage-_A31Cl4g.mjs.map} +1 -1
  13. package/dist/_chunks/{Field-Byr3mPTl.mjs → Field-CvIunNOj.mjs} +23 -50
  14. package/dist/_chunks/Field-CvIunNOj.mjs.map +1 -0
  15. package/dist/_chunks/{Field-B5QXnctJ.js → Field-Dsu6-FrM.js} +23 -50
  16. package/dist/_chunks/Field-Dsu6-FrM.js.map +1 -0
  17. package/dist/_chunks/{Form-BZgvE8C8.mjs → Form-DK0fG0Gj.mjs} +2 -2
  18. package/dist/_chunks/{Form-BZgvE8C8.mjs.map → Form-DK0fG0Gj.mjs.map} +1 -1
  19. package/dist/_chunks/{Form-D7mexvm3.js → Form-DUwWcCmA.js} +2 -2
  20. package/dist/_chunks/{Form-D7mexvm3.js.map → Form-DUwWcCmA.js.map} +1 -1
  21. package/dist/_chunks/{History-DYl2A8Z_.js → History-CeCDhoJG.js} +4 -4
  22. package/dist/_chunks/{History-DYl2A8Z_.js.map → History-CeCDhoJG.js.map} +1 -1
  23. package/dist/_chunks/{History-CqNgxkqK.mjs → History-DP8gmXpm.mjs} +4 -4
  24. package/dist/_chunks/{History-CqNgxkqK.mjs.map → History-DP8gmXpm.mjs.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs → ListConfigurationPage-BCkO5iuN.mjs} +2 -2
  26. package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs.map → ListConfigurationPage-BCkO5iuN.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js → ListConfigurationPage-C-bAd44a.js} +2 -2
  28. package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js.map → ListConfigurationPage-C-bAd44a.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-BtSi8C1l.js → ListViewPage-BKTZFhsM.js} +3 -3
  30. package/dist/_chunks/{ListViewPage-BtSi8C1l.js.map → ListViewPage-BKTZFhsM.js.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs → ListViewPage-Cf_DgaFV.mjs} +3 -3
  32. package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs.map → ListViewPage-Cf_DgaFV.mjs.map} +1 -1
  33. package/dist/_chunks/{NoContentTypePage-CitJeOq4.js → NoContentTypePage-D3Cm3v3q.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-CitJeOq4.js.map → NoContentTypePage-D3Cm3v3q.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs → NoContentTypePage-nHIyvJcB.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs.map → NoContentTypePage-nHIyvJcB.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs → NoPermissionsPage-BALVSJ7x.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs.map → NoPermissionsPage-BALVSJ7x.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js → NoPermissionsPage-CChGWBj5.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js.map → NoPermissionsPage-CChGWBj5.js.map} +1 -1
  41. package/dist/_chunks/{Preview-BaYGJ0nb.mjs → Preview-C4NBzKUV.mjs} +5 -4
  42. package/dist/_chunks/Preview-C4NBzKUV.mjs.map +1 -0
  43. package/dist/_chunks/{Preview-DfNx8Ke-.js → Preview-CT28Ckpg.js} +5 -4
  44. package/dist/_chunks/Preview-CT28Ckpg.js.map +1 -0
  45. package/dist/_chunks/{Relations-DM2yUTST.mjs → Relations-C8uC89cT.mjs} +3 -3
  46. package/dist/_chunks/{Relations-DM2yUTST.mjs.map → Relations-C8uC89cT.mjs.map} +1 -1
  47. package/dist/_chunks/{Relations-DuKCaXrv.js → Relations-CvkPCng_.js} +3 -3
  48. package/dist/_chunks/{Relations-DuKCaXrv.js.map → Relations-CvkPCng_.js.map} +1 -1
  49. package/dist/_chunks/{index-BUWEmX8m.js → index-CnX_j5h-.js} +24 -12
  50. package/dist/_chunks/index-CnX_j5h-.js.map +1 -0
  51. package/dist/_chunks/{index-DVAIIsOs.mjs → index-Dh2aGTGJ.mjs} +24 -12
  52. package/dist/_chunks/index-Dh2aGTGJ.mjs.map +1 -0
  53. package/dist/_chunks/{layout-Bxsv5mP7.mjs → layout-B5qsPihj.mjs} +3 -3
  54. package/dist/_chunks/{layout-Bxsv5mP7.mjs.map → layout-B5qsPihj.mjs.map} +1 -1
  55. package/dist/_chunks/{layout-C3fN7Ejz.js → layout-B_qdWGny.js} +3 -3
  56. package/dist/_chunks/{layout-C3fN7Ejz.js.map → layout-B_qdWGny.js.map} +1 -1
  57. package/dist/_chunks/{relations-BPZKAoEY.js → relations-ChcieiF5.js} +2 -2
  58. package/dist/_chunks/{relations-BPZKAoEY.js.map → relations-ChcieiF5.js.map} +1 -1
  59. package/dist/_chunks/{relations-o3pPhzY4.mjs → relations-DMXpNY-e.mjs} +2 -2
  60. package/dist/_chunks/{relations-o3pPhzY4.mjs.map → relations-DMXpNY-e.mjs.map} +1 -1
  61. package/dist/admin/index.js +1 -1
  62. package/dist/admin/index.mjs +1 -1
  63. package/dist/server/index.js +77 -63
  64. package/dist/server/index.js.map +1 -1
  65. package/dist/server/index.mjs +78 -64
  66. package/dist/server/index.mjs.map +1 -1
  67. package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
  68. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  69. package/dist/server/src/index.d.ts +3 -2
  70. package/dist/server/src/index.d.ts.map +1 -1
  71. package/dist/server/src/services/document-metadata.d.ts +4 -2
  72. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  73. package/dist/server/src/services/index.d.ts +3 -2
  74. package/dist/server/src/services/index.d.ts.map +1 -1
  75. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  76. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  77. package/dist/server/src/services/utils/populate.d.ts +2 -2
  78. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  79. package/package.json +6 -7
  80. package/dist/_chunks/Field-B5QXnctJ.js.map +0 -1
  81. package/dist/_chunks/Field-Byr3mPTl.mjs.map +0 -1
  82. package/dist/_chunks/Preview-BaYGJ0nb.mjs.map +0 -1
  83. package/dist/_chunks/Preview-DfNx8Ke-.js.map +0 -1
  84. package/dist/_chunks/index-BUWEmX8m.js.map +0 -1
  85. package/dist/_chunks/index-DVAIIsOs.mjs.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";
@@ -3904,6 +3904,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
3904
3904
  if (initialPopulate) {
3905
3905
  return initialPopulate;
3906
3906
  }
3907
+ if (attributeName === "localizations") {
3908
+ const validationPopulate = getPopulateForValidation(model.uid);
3909
+ return {
3910
+ populate: validationPopulate.populate
3911
+ };
3912
+ }
3907
3913
  if (!isVisibleAttribute$1(model, attributeName)) {
3908
3914
  return true;
3909
3915
  }
@@ -3963,6 +3969,9 @@ const getDeepPopulate = (uid2, {
3963
3969
  return {};
3964
3970
  }
3965
3971
  const model = strapi.getModel(uid2);
3972
+ if (!model) {
3973
+ return {};
3974
+ }
3966
3975
  return Object.keys(model.attributes).reduce(
3967
3976
  (populateAcc, attributeName) => merge(
3968
3977
  populateAcc,
@@ -3982,40 +3991,46 @@ const getDeepPopulate = (uid2, {
3982
3991
  {}
3983
3992
  );
3984
3993
  };
3985
- const getValidatableFieldsPopulate = (uid2, {
3986
- initialPopulate = {},
3987
- countMany = false,
3988
- countOne = false,
3989
- maxLevel = Infinity
3990
- } = {}, level = 1) => {
3991
- if (level > maxLevel) {
3994
+ const getPopulateForValidation = (uid2) => {
3995
+ const model = strapi.getModel(uid2);
3996
+ if (!model) {
3992
3997
  return {};
3993
3998
  }
3994
- const model = strapi.getModel(uid2);
3995
3999
  return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
3996
- if (!getDoesAttributeRequireValidation(attribute)) {
4000
+ if (isScalarAttribute(attribute)) {
4001
+ if (getDoesAttributeRequireValidation(attribute)) {
4002
+ populateAcc.fields = populateAcc.fields || [];
4003
+ populateAcc.fields.push(attributeName);
4004
+ }
3997
4005
  return populateAcc;
3998
4006
  }
3999
- if (isScalarAttribute(attribute)) {
4000
- return merge(populateAcc, {
4001
- [attributeName]: true
4002
- });
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;
4003
4015
  }
4004
- return merge(
4005
- populateAcc,
4006
- getPopulateFor(
4007
- attributeName,
4008
- model,
4009
- {
4010
- // @ts-expect-error - improve types
4011
- initialPopulate: initialPopulate?.[attributeName],
4012
- countMany,
4013
- countOne,
4014
- 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;
4015
4025
  },
4016
- level
4017
- )
4018
- );
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;
4019
4034
  }, {});
4020
4035
  };
4021
4036
  const getDeepPopulateDraftCount = (uid2) => {
@@ -4257,7 +4272,6 @@ const AVAILABLE_LOCALES_FIELDS = [
4257
4272
  "locale",
4258
4273
  "updatedAt",
4259
4274
  "createdAt",
4260
- "status",
4261
4275
  "publishedAt",
4262
4276
  "documentId"
4263
4277
  ];
@@ -4278,36 +4292,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4278
4292
  /**
4279
4293
  * Returns available locales of a document for the current status
4280
4294
  */
4281
- async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
4295
+ async getAvailableLocales(uid2, version, allVersions) {
4282
4296
  const versionsByLocale = groupBy("locale", allVersions);
4283
4297
  if (version.locale) {
4284
4298
  delete versionsByLocale[version.locale];
4285
4299
  }
4286
4300
  const model = strapi2.getModel(uid2);
4287
- const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
4288
- const traversalFunction = async (localeVersion) => traverseEntity(
4289
- ({ key }, { remove }) => {
4290
- if (keysToKeep.includes(key)) {
4291
- return;
4292
- }
4293
- remove(key);
4294
- },
4295
- { schema: model, getModel: strapi2.getModel.bind(strapi2) },
4296
- // @ts-expect-error fix types DocumentVersion incompatible with Data
4297
- localeVersion
4298
- );
4299
4301
  const mappingResult = await async.map(
4300
4302
  Object.values(versionsByLocale),
4301
4303
  async (localeVersions) => {
4302
- const mappedLocaleVersions = await async.map(
4303
- localeVersions,
4304
- traversalFunction
4305
- );
4306
4304
  if (!contentTypes$1.hasDraftAndPublish(model)) {
4307
- return mappedLocaleVersions[0];
4305
+ return localeVersions[0];
4308
4306
  }
4309
- const draftVersion = mappedLocaleVersions.find((v) => v.publishedAt === null);
4310
- 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);
4311
4309
  if (!draftVersion) {
4312
4310
  return;
4313
4311
  }
@@ -4341,15 +4339,17 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4341
4339
  async getManyAvailableStatus(uid2, documents) {
4342
4340
  if (!documents.length) return [];
4343
4341
  const status = documents[0].publishedAt !== null ? "published" : "draft";
4344
- const locale = documents[0]?.locale;
4345
- const otherStatus = status === "published" ? "draft" : "published";
4346
- return strapi2.documents(uid2).findMany({
4347
- filters: {
4348
- documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) }
4349
- },
4350
- status: otherStatus,
4351
- locale,
4352
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4342
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4343
+ const where = {
4344
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4345
+ publishedAt: { $null: status === "published" }
4346
+ };
4347
+ if (locales.length) {
4348
+ where.locale = { $in: locales };
4349
+ }
4350
+ return strapi2.query(uid2).findMany({
4351
+ where,
4352
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4353
4353
  });
4354
4354
  },
4355
4355
  getStatus(version, otherDocumentStatuses) {
@@ -4375,11 +4375,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4375
4375
  // We could refactor this so the locales are only loaded when they're
4376
4376
  // needed. e.g. in the bulk locale action modal.
4377
4377
  async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
4378
- const populate = getValidatableFieldsPopulate(uid2);
4379
- const versions = await strapi2.db.query(uid2).findMany({
4380
- where: { documentId: version.documentId },
4378
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4379
+ const params = {
4381
4380
  populate: {
4382
- // Populate only fields that require validation for bulk locale actions
4383
4381
  ...populate,
4384
4382
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4385
4383
  createdBy: {
@@ -4388,9 +4386,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4388
4386
  updatedBy: {
4389
4387
  select: ["id", "firstname", "lastname", "email"]
4390
4388
  }
4389
+ },
4390
+ fields: uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4391
+ filters: {
4392
+ documentId: version.documentId
4391
4393
  }
4392
- });
4393
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4394
+ };
4395
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4396
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4397
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4394
4398
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4395
4399
  return {
4396
4400
  availableLocales: availableLocalesResult,
@@ -4417,6 +4421,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4417
4421
  opts.availableStatus = false;
4418
4422
  }
4419
4423
  const meta = await this.getMetadata(uid2, document, opts);
4424
+ if (document.localizations) {
4425
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4426
+ document.localizations = document.localizations.map((d) => {
4427
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4428
+ return {
4429
+ ...d,
4430
+ status: this.getStatus(d, status ? [status] : [])
4431
+ };
4432
+ });
4433
+ }
4420
4434
  return {
4421
4435
  data: {
4422
4436
  ...document,