@strapi/content-manager 0.0.0-experimental.e350eaa6073e65190102b4b798c32c287053cc02 → 0.0.0-experimental.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 (83) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js → ComponentConfigurationPage-BlzvDpbX.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js.map → ComponentConfigurationPage-BlzvDpbX.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs → ComponentConfigurationPage-DaPOlQaD.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs.map → ComponentConfigurationPage-DaPOlQaD.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs → EditConfigurationPage-BZPXItXo.mjs} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs.map → EditConfigurationPage-BZPXItXo.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js → EditConfigurationPage-uy-v43AR.js} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js.map → EditConfigurationPage-uy-v43AR.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-wujOq90c.js → EditViewPage-DT6A4ayX.js} +3 -3
  10. package/dist/_chunks/{EditViewPage-wujOq90c.js.map → EditViewPage-DT6A4ayX.js.map} +1 -1
  11. package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs → EditViewPage-oOLeTySr.mjs} +3 -3
  12. package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs.map → EditViewPage-oOLeTySr.mjs.map} +1 -1
  13. package/dist/_chunks/{Field-Byr3mPTl.mjs → Field-D7dv2aUX.mjs} +23 -50
  14. package/dist/_chunks/Field-D7dv2aUX.mjs.map +1 -0
  15. package/dist/_chunks/{Field-B5QXnctJ.js → Field-kYFVIGiP.js} +23 -50
  16. package/dist/_chunks/Field-kYFVIGiP.js.map +1 -0
  17. package/dist/_chunks/{Form-BZgvE8C8.mjs → Form-BxR6sc29.mjs} +2 -2
  18. package/dist/_chunks/{Form-BZgvE8C8.mjs.map → Form-BxR6sc29.mjs.map} +1 -1
  19. package/dist/_chunks/{Form-D7mexvm3.js → Form-CCijSg3V.js} +2 -2
  20. package/dist/_chunks/{Form-D7mexvm3.js.map → Form-CCijSg3V.js.map} +1 -1
  21. package/dist/_chunks/{History-DYl2A8Z_.js → History-BMndx49M.js} +4 -4
  22. package/dist/_chunks/{History-DYl2A8Z_.js.map → History-BMndx49M.js.map} +1 -1
  23. package/dist/_chunks/{History-CqNgxkqK.mjs → History-D8F7aYQU.mjs} +4 -4
  24. package/dist/_chunks/{History-CqNgxkqK.mjs.map → History-D8F7aYQU.mjs.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js → ListConfigurationPage-DouY1EWM.js} +2 -2
  26. package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js.map → ListConfigurationPage-DouY1EWM.js.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs → ListConfigurationPage-DqAdSPwC.mjs} +2 -2
  28. package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs.map → ListConfigurationPage-DqAdSPwC.mjs.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-BtSi8C1l.js → ListViewPage-BPVmh9pq.js} +3 -3
  30. package/dist/_chunks/{ListViewPage-BtSi8C1l.js.map → ListViewPage-BPVmh9pq.js.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs → ListViewPage-C73F0jPh.mjs} +3 -3
  32. package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs.map → ListViewPage-C73F0jPh.mjs.map} +1 -1
  33. package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs → NoContentTypePage-B5w7iJOF.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs.map → NoContentTypePage-B5w7iJOF.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CitJeOq4.js → NoContentTypePage-BwcL--4H.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CitJeOq4.js.map → NoContentTypePage-BwcL--4H.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js → NoPermissionsPage-BMFKVcwJ.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js.map → NoPermissionsPage-BMFKVcwJ.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs → NoPermissionsPage-UnEgMGK4.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs.map → NoPermissionsPage-UnEgMGK4.mjs.map} +1 -1
  41. package/dist/_chunks/{Preview-DfNx8Ke-.js → Preview-B7PR3Ok_.js} +5 -4
  42. package/dist/_chunks/Preview-B7PR3Ok_.js.map +1 -0
  43. package/dist/_chunks/{Preview-BaYGJ0nb.mjs → Preview-DECOhK0D.mjs} +5 -4
  44. package/dist/_chunks/Preview-DECOhK0D.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-DM2yUTST.mjs → Relations-DinMQJ4B.mjs} +3 -3
  46. package/dist/_chunks/{Relations-DM2yUTST.mjs.map → Relations-DinMQJ4B.mjs.map} +1 -1
  47. package/dist/_chunks/{Relations-DuKCaXrv.js → Relations-lndx3aQk.js} +3 -3
  48. package/dist/_chunks/{Relations-DuKCaXrv.js.map → Relations-lndx3aQk.js.map} +1 -1
  49. package/dist/_chunks/{index-DVAIIsOs.mjs → index-C2SagWVW.mjs} +11 -11
  50. package/dist/_chunks/{index-DVAIIsOs.mjs.map → index-C2SagWVW.mjs.map} +1 -1
  51. package/dist/_chunks/{index-BUWEmX8m.js → index-Cnw4gqee.js} +11 -11
  52. package/dist/_chunks/{index-BUWEmX8m.js.map → index-Cnw4gqee.js.map} +1 -1
  53. package/dist/_chunks/{layout-Bxsv5mP7.mjs → layout-DY_D9MGA.mjs} +3 -3
  54. package/dist/_chunks/{layout-Bxsv5mP7.mjs.map → layout-DY_D9MGA.mjs.map} +1 -1
  55. package/dist/_chunks/{layout-C3fN7Ejz.js → layout-ivwIVPnV.js} +3 -3
  56. package/dist/_chunks/{layout-C3fN7Ejz.js.map → layout-ivwIVPnV.js.map} +1 -1
  57. package/dist/_chunks/{relations-BPZKAoEY.js → relations-B7C7O_Pv.js} +2 -2
  58. package/dist/_chunks/{relations-BPZKAoEY.js.map → relations-B7C7O_Pv.js.map} +1 -1
  59. package/dist/_chunks/{relations-o3pPhzY4.mjs → relations-Boc5Y9kX.mjs} +2 -2
  60. package/dist/_chunks/{relations-o3pPhzY4.mjs.map → relations-Boc5Y9kX.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 +74 -62
  64. package/dist/server/index.js.map +1 -1
  65. package/dist/server/index.mjs +75 -63
  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 -6
  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
@@ -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,15 @@ 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) }
4367
+ const locales = documents.map((d) => d.locale).filter(Boolean);
4368
+ return strapi2.query(uid2).findMany({
4369
+ where: {
4370
+ documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
4371
+ // NOTE: find the "opposite" status
4372
+ publishedAt: { $null: status === "published" },
4373
+ locale: { $in: locales }
4374
4374
  },
4375
- status: otherStatus,
4376
- locale,
4377
- fields: ["documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4375
+ select: ["id", "documentId", "locale", "updatedAt", "createdAt", "publishedAt"]
4378
4376
  });
4379
4377
  },
4380
4378
  getStatus(version, otherDocumentStatuses) {
@@ -4400,11 +4398,9 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4400
4398
  // We could refactor this so the locales are only loaded when they're
4401
4399
  // needed. e.g. in the bulk locale action modal.
4402
4400
  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 },
4401
+ const { populate = {}, fields = [] } = getPopulateForValidation(uid2);
4402
+ const params = {
4406
4403
  populate: {
4407
- // Populate only fields that require validation for bulk locale actions
4408
4404
  ...populate,
4409
4405
  // NOTE: creator fields are selected in this way to avoid exposing sensitive data
4410
4406
  createdBy: {
@@ -4413,9 +4409,15 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4413
4409
  updatedBy: {
4414
4410
  select: ["id", "firstname", "lastname", "email"]
4415
4411
  }
4412
+ },
4413
+ fields: fp.uniq([...AVAILABLE_LOCALES_FIELDS, ...fields]),
4414
+ filters: {
4415
+ documentId: version.documentId
4416
4416
  }
4417
- });
4418
- const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions, Object.keys(populate)) : [];
4417
+ };
4418
+ const dbParams = strapi2.get("query-params").transform(uid2, params);
4419
+ const versions = await strapi2.db.query(uid2).findMany(dbParams);
4420
+ const availableLocalesResult = availableLocales ? await this.getAvailableLocales(uid2, version, versions) : [];
4419
4421
  const availableStatusResult = availableStatus ? this.getAvailableStatus(version, versions) : null;
4420
4422
  return {
4421
4423
  availableLocales: availableLocalesResult,
@@ -4442,6 +4444,16 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
4442
4444
  opts.availableStatus = false;
4443
4445
  }
4444
4446
  const meta = await this.getMetadata(uid2, document, opts);
4447
+ if (document.localizations) {
4448
+ const otherStatus = await this.getManyAvailableStatus(uid2, document.localizations);
4449
+ document.localizations = document.localizations.map((d) => {
4450
+ const status = otherStatus.find((s) => s.documentId === d.documentId);
4451
+ return {
4452
+ ...d,
4453
+ status: this.getStatus(d, status ? [status] : [])
4454
+ };
4455
+ });
4456
+ }
4445
4457
  return {
4446
4458
  data: {
4447
4459
  ...document,