@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
@@ -3929,6 +3929,12 @@ function getPopulateForRelation(attribute, model, attributeName, { countMany, co
3929
3929
  if (initialPopulate) {
3930
3930
  return initialPopulate;
3931
3931
  }
3932
+ if (attributeName === "localizations") {
3933
+ const validationPopulate = getPopulateForValidation(model.uid);
3934
+ return {
3935
+ populate: validationPopulate.populate
3936
+ };
3937
+ }
3932
3938
  if (!isVisibleAttribute$1(model, attributeName)) {
3933
3939
  return true;
3934
3940
  }
@@ -3988,6 +3994,9 @@ const getDeepPopulate = (uid2, {
3988
3994
  return {};
3989
3995
  }
3990
3996
  const model = strapi.getModel(uid2);
3997
+ if (!model) {
3998
+ return {};
3999
+ }
3991
4000
  return Object.keys(model.attributes).reduce(
3992
4001
  (populateAcc, attributeName) => fp.merge(
3993
4002
  populateAcc,
@@ -4007,40 +4016,46 @@ const getDeepPopulate = (uid2, {
4007
4016
  {}
4008
4017
  );
4009
4018
  };
4010
- const getValidatableFieldsPopulate = (uid2, {
4011
- initialPopulate = {},
4012
- countMany = false,
4013
- countOne = false,
4014
- maxLevel = Infinity
4015
- } = {}, level = 1) => {
4016
- if (level > maxLevel) {
4019
+ const getPopulateForValidation = (uid2) => {
4020
+ const model = strapi.getModel(uid2);
4021
+ if (!model) {
4017
4022
  return {};
4018
4023
  }
4019
- const model = strapi.getModel(uid2);
4020
4024
  return Object.entries(model.attributes).reduce((populateAcc, [attributeName, attribute]) => {
4021
- if (!getDoesAttributeRequireValidation(attribute)) {
4025
+ if (isScalarAttribute(attribute)) {
4026
+ if (getDoesAttributeRequireValidation(attribute)) {
4027
+ populateAcc.fields = populateAcc.fields || [];
4028
+ populateAcc.fields.push(attributeName);
4029
+ }
4022
4030
  return populateAcc;
4023
4031
  }
4024
- if (isScalarAttribute(attribute)) {
4025
- return fp.merge(populateAcc, {
4026
- [attributeName]: true
4027
- });
4032
+ if (isComponent(attribute)) {
4033
+ const component = attribute.component;
4034
+ const componentResult = getPopulateForValidation(component);
4035
+ if (Object.keys(componentResult).length > 0) {
4036
+ populateAcc.populate = populateAcc.populate || {};
4037
+ populateAcc.populate[attributeName] = componentResult;
4038
+ }
4039
+ return populateAcc;
4028
4040
  }
4029
- return fp.merge(
4030
- populateAcc,
4031
- getPopulateFor(
4032
- attributeName,
4033
- model,
4034
- {
4035
- // @ts-expect-error - improve types
4036
- initialPopulate: initialPopulate?.[attributeName],
4037
- countMany,
4038
- countOne,
4039
- maxLevel
4041
+ if (isDynamicZone(attribute)) {
4042
+ const components2 = attribute.components;
4043
+ const componentsResult = (components2 || []).reduce(
4044
+ (acc, componentUID) => {
4045
+ const componentResult = getPopulateForValidation(componentUID);
4046
+ if (Object.keys(componentResult).length > 0) {
4047
+ acc[componentUID] = componentResult;
4048
+ }
4049
+ return acc;
4040
4050
  },
4041
- level
4042
- )
4043
- );
4051
+ {}
4052
+ );
4053
+ if (Object.keys(componentsResult).length > 0) {
4054
+ populateAcc.populate = populateAcc.populate || {};
4055
+ populateAcc.populate[attributeName] = { on: componentsResult };
4056
+ }
4057
+ }
4058
+ return populateAcc;
4044
4059
  }, {});
4045
4060
  };
4046
4061
  const getDeepPopulateDraftCount = (uid2) => {
@@ -4282,7 +4297,6 @@ const AVAILABLE_LOCALES_FIELDS = [
4282
4297
  "locale",
4283
4298
  "updatedAt",
4284
4299
  "createdAt",
4285
- "status",
4286
4300
  "publishedAt",
4287
4301
  "documentId"
4288
4302
  ];
@@ -4303,36 +4317,20 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4303
4317
  /**
4304
4318
  * Returns available locales of a document for the current status
4305
4319
  */
4306
- async getAvailableLocales(uid2, version, allVersions, validatableFields = []) {
4320
+ async getAvailableLocales(uid2, version, allVersions) {
4307
4321
  const versionsByLocale = fp.groupBy("locale", allVersions);
4308
4322
  if (version.locale) {
4309
4323
  delete versionsByLocale[version.locale];
4310
4324
  }
4311
4325
  const model = strapi2.getModel(uid2);
4312
- const keysToKeep = [...AVAILABLE_LOCALES_FIELDS, ...validatableFields];
4313
- const traversalFunction = async (localeVersion) => strapiUtils.traverseEntity(
4314
- ({ key }, { remove }) => {
4315
- if (keysToKeep.includes(key)) {
4316
- return;
4317
- }
4318
- remove(key);
4319
- },
4320
- { schema: model, getModel: strapi2.getModel.bind(strapi2) },
4321
- // @ts-expect-error fix types DocumentVersion incompatible with Data
4322
- localeVersion
4323
- );
4324
4326
  const mappingResult = await strapiUtils.async.map(
4325
4327
  Object.values(versionsByLocale),
4326
4328
  async (localeVersions) => {
4327
- const mappedLocaleVersions = await strapiUtils.async.map(
4328
- localeVersions,
4329
- traversalFunction
4330
- );
4331
4329
  if (!strapiUtils.contentTypes.hasDraftAndPublish(model)) {
4332
- return mappedLocaleVersions[0];
4330
+ return localeVersions[0];
4333
4331
  }
4334
- const draftVersion = mappedLocaleVersions.find((v) => v.publishedAt === null);
4335
- const otherVersions = mappedLocaleVersions.filter((v) => v.id !== draftVersion?.id);
4332
+ const draftVersion = localeVersions.find((v) => v.publishedAt === null);
4333
+ const otherVersions = localeVersions.filter((v) => v.id !== draftVersion?.id);
4336
4334
  if (!draftVersion) {
4337
4335
  return;
4338
4336
  }
@@ -4366,15 +4364,17 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4366
4364
  async getManyAvailableStatus(uid2, documents) {
4367
4365
  if (!documents.length) return [];
4368
4366
  const status = documents[0].publishedAt !== null ? "published" : "draft";
4369
- const locale = documents[0]?.locale;
4370
- const otherStatus = status === "published" ? "draft" : "published";
4371
- return strapi2.documents(uid2).findMany({
4372
- filters: {
4373
- documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) }
4374
- },
4375
- status: otherStatus,
4376
- locale,
4377
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4367
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4368
+ const where = {
4369
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4370
+ publishedAt: { $null: status === "published" }
4371
+ };
4372
+ if (locales.length) {
4373
+ where.locale = { $in: locales };
4374
+ }
4375
+ return strapi2.query(uid2).findMany({
4376
+ where,
4377
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4378
4378
  });
4379
4379
  },
4380
4380
  getStatus(version, otherDocumentStatuses) {
@@ -4400,11 +4400,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4400
4400
  // We could refactor this so the locales are only loaded when they're
4401
4401
  // needed. e.g. in the bulk locale action modal.
4402
4402
  async getMetadata(uid2, version, { availableLocales = true, availableStatus = true } = {}) {
4403
- const populate = getValidatableFieldsPopulate(uid2);
4404
- const versions = await strapi2.db.query(uid2).findMany({
4405
- where: { documentId: version.documentId },
4403
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4404
+ const params = {
4406
4405
  populate: {
4407
- // Populate only fields that require validation for bulk locale actions
4408
4406
  ...populate,
4409
4407
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4410
4408
  createdBy: {
@@ -4413,9 +4411,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4413
4411
  updatedBy: {
4414
4412
  select: ["id", "firstname", "lastname", "email"]
4415
4413
  }
4414
+ },
4415
+ fields: fp.uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4416
+ filters: {
4417
+ documentId: version.documentId
4416
4418
  }
4417
- });
4418
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4419
+ };
4420
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4421
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4422
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4419
4423
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4420
4424
  return {
4421
4425
  availableLocales: availableLocalesResult,
@@ -4442,6 +4446,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4442
4446
  opts.availableStatus = false;
4443
4447
  }
4444
4448
  const meta = await this.getMetadata(uid2, document, opts);
4449
+ if (document.localizations) {
4450
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4451
+ document.localizations = document.localizations.map((d) => {
4452
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4453
+ return {
4454
+ ...d,
4455
+ status: this.getStatus(d, status ? [status] : [])
4456
+ };
4457
+ });
4458
+ }
4445
4459
  return {
4446
4460
  data: {
4447
4461
  ...document,