@strapi/content-manager 0.0.0-experimental.f31889311d753b5f7d95198ae84d8fce1d156cd6 → 0.0.0-experimental.f74ae50eea1ce95176f088dba837e95b60fa2a4d

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 (117) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-BWOQWCv2.mjs → ComponentConfigurationPage-7-qB29e7.mjs} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-BWOQWCv2.mjs.map → ComponentConfigurationPage-7-qB29e7.mjs.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-BNxtMIfV.js → ComponentConfigurationPage-DP7AC0UU.js} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-BNxtMIfV.js.map → ComponentConfigurationPage-DP7AC0UU.js.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-GTp-Ucnw.mjs → EditConfigurationPage-CI4XoymK.mjs} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-GTp-Ucnw.mjs.map → EditConfigurationPage-CI4XoymK.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-D340bYlT.js → EditConfigurationPage-DITVliEI.js} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-D340bYlT.js.map → EditConfigurationPage-DITVliEI.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-CXkmnAvI.js → EditViewPage-CUS2EAhB.js} +24 -9
  10. package/dist/_chunks/EditViewPage-CUS2EAhB.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-BVMS5hT-.mjs → EditViewPage-Dzpno8xI.mjs} +24 -9
  12. package/dist/_chunks/EditViewPage-Dzpno8xI.mjs.map +1 -0
  13. package/dist/_chunks/{Field-nNgv5bpd.mjs → Field-B_jG_EV9.mjs} +134 -94
  14. package/dist/_chunks/Field-B_jG_EV9.mjs.map +1 -0
  15. package/dist/_chunks/{Field-Ibi32diw.js → Field-CtUU1Fg8.js} +136 -96
  16. package/dist/_chunks/Field-CtUU1Fg8.js.map +1 -0
  17. package/dist/_chunks/{Form-DodJsI2A.mjs → Form-BXHao2mZ.mjs} +35 -16
  18. package/dist/_chunks/Form-BXHao2mZ.mjs.map +1 -0
  19. package/dist/_chunks/{Form-Dhnh34ym.js → Form-DTqO0ymI.js} +35 -16
  20. package/dist/_chunks/Form-DTqO0ymI.js.map +1 -0
  21. package/dist/_chunks/{History-CKCSQXz_.mjs → History-2Ah2CQ4T.mjs} +4 -4
  22. package/dist/_chunks/{History-CKCSQXz_.mjs.map → History-2Ah2CQ4T.mjs.map} +1 -1
  23. package/dist/_chunks/{History-C9auUkDi.js → History-C_uSGzO5.js} +4 -4
  24. package/dist/_chunks/{History-C9auUkDi.js.map → History-C_uSGzO5.js.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-CKEC4ttG.mjs → ListConfigurationPage-BjSJlaoC.mjs} +14 -4
  26. package/dist/_chunks/ListConfigurationPage-BjSJlaoC.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-Bg4rWUjX.js → ListConfigurationPage-nyuP7OSy.js} +14 -4
  28. package/dist/_chunks/ListConfigurationPage-nyuP7OSy.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-B7_WJUjG.mjs → ListViewPage-B75x3nz2.mjs} +40 -36
  30. package/dist/_chunks/ListViewPage-B75x3nz2.mjs.map +1 -0
  31. package/dist/_chunks/{ListViewPage-C2gIeYHG.js → ListViewPage-DHgHD8Xg.js} +43 -39
  32. package/dist/_chunks/ListViewPage-DHgHD8Xg.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-DqgdUfyn.js → NoContentTypePage-CDUKdZ7d.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-DqgdUfyn.js.map → NoContentTypePage-CDUKdZ7d.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-Ckem6Ll6.mjs → NoContentTypePage-DUacQSyF.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-Ckem6Ll6.mjs.map → NoContentTypePage-DUacQSyF.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-BO-GEjA4.mjs → NoPermissionsPage-SFllMekk.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-BO-GEjA4.mjs.map → NoPermissionsPage-SFllMekk.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CF29Q-sW.js → NoPermissionsPage-zwIZydDI.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CF29Q-sW.js.map → NoPermissionsPage-zwIZydDI.js.map} +1 -1
  41. package/dist/_chunks/{Relations-DItV5eow.mjs → Relations-D2NRW8fC.mjs} +14 -10
  42. package/dist/_chunks/Relations-D2NRW8fC.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-C0uC9J4f.js → Relations-NFLaRNPr.js} +14 -10
  44. package/dist/_chunks/Relations-NFLaRNPr.js.map +1 -0
  45. package/dist/_chunks/{en-uOUIxfcQ.js → en-BlhnxQfj.js} +7 -6
  46. package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BlhnxQfj.js.map} +1 -1
  47. package/dist/_chunks/{en-BrCTWlZv.mjs → en-C8YBvRrK.mjs} +7 -6
  48. package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-C8YBvRrK.mjs.map} +1 -1
  49. package/dist/_chunks/{index-DrNe6ctw.mjs → index-C9HxCo5R.mjs} +1909 -1751
  50. package/dist/_chunks/index-C9HxCo5R.mjs.map +1 -0
  51. package/dist/_chunks/{index-Dd0nXyJF.js → index-ovJRE1FM.js} +1889 -1731
  52. package/dist/_chunks/index-ovJRE1FM.js.map +1 -0
  53. package/dist/_chunks/{layout-B3ez7kvr.mjs → layout-DaUjDiWQ.mjs} +8 -7
  54. package/dist/_chunks/layout-DaUjDiWQ.mjs.map +1 -0
  55. package/dist/_chunks/{layout-CLLtt_5O.js → layout-UNWstw_s.js} +8 -7
  56. package/dist/_chunks/layout-UNWstw_s.js.map +1 -0
  57. package/dist/_chunks/{relations-B0hlsUU_.mjs → relations-D8iFAeRu.mjs} +2 -2
  58. package/dist/_chunks/{relations-B0hlsUU_.mjs.map → relations-D8iFAeRu.mjs.map} +1 -1
  59. package/dist/_chunks/{relations-bRxcNv1q.js → relations-NN3coOG5.js} +2 -2
  60. package/dist/_chunks/{relations-bRxcNv1q.js.map → relations-NN3coOG5.js.map} +1 -1
  61. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  62. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  63. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  64. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  65. package/dist/admin/index.js +2 -1
  66. package/dist/admin/index.js.map +1 -1
  67. package/dist/admin/index.mjs +5 -4
  68. package/dist/admin/src/exports.d.ts +1 -1
  69. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  70. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  71. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  72. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  73. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  74. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  75. package/dist/admin/src/services/api.d.ts +1 -1
  76. package/dist/admin/src/services/components.d.ts +2 -2
  77. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  78. package/dist/admin/src/services/documents.d.ts +19 -17
  79. package/dist/admin/src/services/init.d.ts +1 -1
  80. package/dist/admin/src/services/relations.d.ts +2 -2
  81. package/dist/admin/src/services/uid.d.ts +3 -3
  82. package/dist/admin/src/utils/validation.d.ts +4 -1
  83. package/dist/server/index.js +60 -29
  84. package/dist/server/index.js.map +1 -1
  85. package/dist/server/index.mjs +60 -29
  86. package/dist/server/index.mjs.map +1 -1
  87. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  88. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  89. package/dist/server/src/history/services/history.d.ts.map +1 -1
  90. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  91. package/dist/server/src/history/services/utils.d.ts +1 -0
  92. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  93. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  94. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  95. package/dist/shared/contracts/collection-types.d.ts +3 -1
  96. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  97. package/package.json +11 -11
  98. package/dist/_chunks/EditViewPage-BVMS5hT-.mjs.map +0 -1
  99. package/dist/_chunks/EditViewPage-CXkmnAvI.js.map +0 -1
  100. package/dist/_chunks/Field-Ibi32diw.js.map +0 -1
  101. package/dist/_chunks/Field-nNgv5bpd.mjs.map +0 -1
  102. package/dist/_chunks/Form-Dhnh34ym.js.map +0 -1
  103. package/dist/_chunks/Form-DodJsI2A.mjs.map +0 -1
  104. package/dist/_chunks/ListConfigurationPage-Bg4rWUjX.js.map +0 -1
  105. package/dist/_chunks/ListConfigurationPage-CKEC4ttG.mjs.map +0 -1
  106. package/dist/_chunks/ListViewPage-B7_WJUjG.mjs.map +0 -1
  107. package/dist/_chunks/ListViewPage-C2gIeYHG.js.map +0 -1
  108. package/dist/_chunks/Relations-C0uC9J4f.js.map +0 -1
  109. package/dist/_chunks/Relations-DItV5eow.mjs.map +0 -1
  110. package/dist/_chunks/index-Dd0nXyJF.js.map +0 -1
  111. package/dist/_chunks/index-DrNe6ctw.mjs.map +0 -1
  112. package/dist/_chunks/layout-B3ez7kvr.mjs.map +0 -1
  113. package/dist/_chunks/layout-CLLtt_5O.js.map +0 -1
  114. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  115. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  116. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  117. package/strapi-server.js +0 -3
@@ -173,7 +173,9 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
173
173
  return strapi2.db.query("plugin::upload.file").findOne({ where: { id: versionRelationData.id } });
174
174
  };
175
175
  const localesService = strapi2.plugin("i18n")?.service("locales");
176
+ const i18nContentTypeService = strapi2.plugin("i18n")?.service("content-types");
176
177
  const getDefaultLocale = async () => localesService ? localesService.getDefaultLocale() : null;
178
+ const isLocalizedContentType = (model) => i18nContentTypeService ? i18nContentTypeService.isLocalizedContentType(model) : false;
177
179
  const getLocaleDictionary = async () => {
178
180
  if (!localesService)
179
181
  return {};
@@ -291,6 +293,7 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
291
293
  getRelationRestoreValue,
292
294
  getMediaRestoreValue,
293
295
  getDefaultLocale,
296
+ isLocalizedContentType,
294
297
  getLocaleDictionary,
295
298
  getRetentionDays,
296
299
  getVersionStatus,
@@ -313,7 +316,13 @@ const createHistoryService = ({ strapi: strapi2 }) => {
313
316
  });
314
317
  },
315
318
  async findVersionsPage(params) {
316
- const locale = params.query.locale || await serviceUtils.getDefaultLocale();
319
+ const model = strapi2.getModel(params.query.contentType);
320
+ const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
321
+ const defaultLocale = await serviceUtils.getDefaultLocale();
322
+ let locale = null;
323
+ if (isLocalizedContentType) {
324
+ locale = params.query.locale || defaultLocale;
325
+ }
317
326
  const [{ results, pagination: pagination2 }, localeDictionary] = await Promise.all([
318
327
  query.findPage({
319
328
  ...params.query,
@@ -529,11 +538,13 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
529
538
  }
530
539
  const uid2 = context.contentType.uid;
531
540
  const schemas = getSchemas(uid2);
541
+ const model = strapi2.getModel(uid2);
542
+ const isLocalizedContentType = serviceUtils.isLocalizedContentType(model);
532
543
  const localeEntries = await strapi2.db.query(uid2).findMany({
533
544
  where: {
534
545
  documentId,
535
- locale: { $in: locales },
536
- publishedAt: null
546
+ ...isLocalizedContentType ? { locale: { $in: locales } } : {},
547
+ ...contentTypes$1.hasDraftAndPublish(strapi2.contentTypes[uid2]) ? { publishedAt: null } : {}
537
548
  },
538
549
  populate: serviceUtils.getDeepPopulate(
539
550
  uid2,
@@ -1193,6 +1204,11 @@ const { createPolicy } = policy;
1193
1204
  const hasPermissions = createPolicy({
1194
1205
  name: "plugin::content-manager.hasPermissions",
1195
1206
  validator: validateHasPermissionsInput,
1207
+ /**
1208
+ * NOTE: Action aliases are currently not checked at this level (policy).
1209
+ * This is currently the intended behavior to avoid changing the behavior of API related permissions.
1210
+ * If you want to add support for it, please create a dedicated RFC with a list of potential side effect this could have.
1211
+ */
1196
1212
  handler(ctx, config = {}) {
1197
1213
  const { actions = [], hasAtLeastOne = false } = config;
1198
1214
  const { userAbility } = ctx.state;
@@ -1745,7 +1761,7 @@ const collectionTypes = {
1745
1761
  permissionChecker2,
1746
1762
  model,
1747
1763
  // @ts-expect-error TODO: fix
1748
- { id, locale, publishedAt: null },
1764
+ { documentId: id, locale, publishedAt: null },
1749
1765
  { availableLocales: true, availableStatus: false }
1750
1766
  );
1751
1767
  ctx.body = { data: {}, meta };
@@ -1882,11 +1898,17 @@ const collectionTypes = {
1882
1898
  }
1883
1899
  const isUpdate = !isCreate;
1884
1900
  if (isUpdate) {
1885
- document = await documentManager2.findOne(id, model, { populate, locale });
1886
- if (!document) {
1901
+ const documentExists = documentManager2.exists(model, id);
1902
+ if (!documentExists) {
1887
1903
  throw new errors.NotFoundError("Document not found");
1888
1904
  }
1889
- if (permissionChecker2.can.update(document)) {
1905
+ document = await documentManager2.findOne(id, model, { populate, locale });
1906
+ if (!document) {
1907
+ if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
1908
+ throw new errors.ForbiddenError();
1909
+ }
1910
+ document = await updateDocument(ctx);
1911
+ } else if (permissionChecker2.can.update(document)) {
1890
1912
  await updateDocument(ctx);
1891
1913
  }
1892
1914
  }
@@ -1948,7 +1970,9 @@ const collectionTypes = {
1948
1970
  if (permissionChecker2.cannot.unpublish()) {
1949
1971
  return ctx.forbidden();
1950
1972
  }
1951
- const { locale } = await getDocumentLocaleAndStatus(body, model);
1973
+ const { locale } = await getDocumentLocaleAndStatus(body, model, {
1974
+ allowMultipleLocales: true
1975
+ });
1952
1976
  const entityPromises = documentIds.map(
1953
1977
  (documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
1954
1978
  );
@@ -2299,20 +2323,13 @@ const sanitizeMainField = (model, mainField, userAbility) => {
2299
2323
  userAbility,
2300
2324
  model: model.uid
2301
2325
  });
2302
- if (!isListable(model, mainField)) {
2326
+ const isMainFieldListable = isListable(model, mainField);
2327
+ const canReadMainField = permissionChecker2.can.read(null, mainField);
2328
+ if (!isMainFieldListable || !canReadMainField) {
2303
2329
  return "id";
2304
2330
  }
2305
- if (permissionChecker2.cannot.read(null, mainField)) {
2306
- if (model.uid === "plugin::users-permissions.role") {
2307
- const userPermissionChecker = getService$1("permission-checker").create({
2308
- userAbility,
2309
- model: "plugin::users-permissions.user"
2310
- });
2311
- if (userPermissionChecker.can.read()) {
2312
- return "name";
2313
- }
2314
- }
2315
- return "id";
2331
+ if (model.uid === "plugin::users-permissions.role") {
2332
+ return "name";
2316
2333
  }
2317
2334
  return mainField;
2318
2335
  };
@@ -2512,8 +2529,9 @@ const relations = {
2512
2529
  } else {
2513
2530
  where.id = id;
2514
2531
  }
2515
- if (status) {
2516
- where[`${alias}.published_at`] = getPublishedAtClause(status, targetUid);
2532
+ const publishedAt = getPublishedAtClause(status, targetUid);
2533
+ if (!isEmpty(publishedAt)) {
2534
+ where[`${alias}.published_at`] = publishedAt;
2517
2535
  }
2518
2536
  if (filterByLocale) {
2519
2537
  where[`${alias}.locale`] = locale;
@@ -2570,9 +2588,7 @@ const relations = {
2570
2588
  addFiltersClause(permissionQuery, { id: { $in: loadedIds } });
2571
2589
  const sanitizedRes = await loadRelations({ id: entryId }, targetField, {
2572
2590
  ...strapi.get("query-params").transform(targetUid, permissionQuery),
2573
- ordering: "desc",
2574
- page: ctx.request.query.page,
2575
- pageSize: ctx.request.query.pageSize
2591
+ ordering: "desc"
2576
2592
  });
2577
2593
  const relationsUnion = uniqBy("id", concat(sanitizedRes.results, res.results));
2578
2594
  ctx.body = {
@@ -2659,7 +2675,7 @@ const singleTypes = {
2659
2675
  permissionChecker2,
2660
2676
  model,
2661
2677
  // @ts-expect-error - fix types
2662
- { id: document.documentId, locale, publishedAt: null },
2678
+ { documentId: document.documentId, locale, publishedAt: null },
2663
2679
  { availableLocales: true, availableStatus: false }
2664
2680
  );
2665
2681
  ctx.body = { data: {}, meta };
@@ -3478,12 +3494,27 @@ const createPermissionChecker = (strapi2) => ({ userAbility, model }) => {
3478
3494
  ability: userAbility,
3479
3495
  model
3480
3496
  });
3481
- const toSubject = (entity) => entity ? permissionsManager.toSubject(entity, model) : model;
3497
+ const { actionProvider } = strapi2.service("admin::permission");
3498
+ const toSubject = (entity) => {
3499
+ return entity ? permissionsManager.toSubject(entity, model) : model;
3500
+ };
3482
3501
  const can = (action, entity, field) => {
3483
- return userAbility.can(action, toSubject(entity), field);
3502
+ const subject = toSubject(entity);
3503
+ const aliases = actionProvider.unstable_aliases(action, model);
3504
+ return (
3505
+ // Test the original action to see if it passes
3506
+ userAbility.can(action, subject, field) || // Else try every known alias if at least one of them succeed, then the user "can"
3507
+ aliases.some((alias) => userAbility.can(alias, subject, field))
3508
+ );
3484
3509
  };
3485
3510
  const cannot = (action, entity, field) => {
3486
- return userAbility.cannot(action, toSubject(entity), field);
3511
+ const subject = toSubject(entity);
3512
+ const aliases = actionProvider.unstable_aliases(action, model);
3513
+ return (
3514
+ // Test both the original action
3515
+ userAbility.cannot(action, subject, field) && // and every known alias, if all of them fail (cannot), then the user truly "cannot"
3516
+ aliases.every((alias) => userAbility.cannot(alias, subject, field))
3517
+ );
3487
3518
  };
3488
3519
  const sanitizeOutput = (data, { action = ACTIONS.read } = {}) => {
3489
3520
  return permissionsManager.sanitizeOutput(data, { subject: toSubject(data), action });