@strapi/content-manager 0.0.0-experimental.de2b94258659463e5ddc5992e9a9490d66d950dd → 0.0.0-experimental.df298029ec6478763dcca7d59fafe8d2ae4ed60a

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 (135) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-CQDCxI8x.js → ComponentConfigurationPage-CpJNPBgk.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-CQDCxI8x.js.map → ComponentConfigurationPage-CpJNPBgk.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-jmWwucg_.mjs → ComponentConfigurationPage-TYDPg5WG.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-jmWwucg_.mjs.map → ComponentConfigurationPage-TYDPg5WG.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-Ce4bIm4n.js → EditConfigurationPage-CFDe6SA1.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-Ce4bIm4n.js.map → EditConfigurationPage-CFDe6SA1.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-W07CEdm2.mjs → EditConfigurationPage-DqL8Pq5r.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-W07CEdm2.mjs.map → EditConfigurationPage-DqL8Pq5r.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-al5OO1NR.mjs → EditViewPage-RXrFLav2.mjs} +3 -3
  10. package/dist/_chunks/{EditViewPage-al5OO1NR.mjs.map → EditViewPage-RXrFLav2.mjs.map} +1 -1
  11. package/dist/_chunks/{EditViewPage-CqHMM0P0.js → EditViewPage-khfP2CR3.js} +3 -3
  12. package/dist/_chunks/{EditViewPage-CqHMM0P0.js.map → EditViewPage-khfP2CR3.js.map} +1 -1
  13. package/dist/_chunks/{Field-EeG6NQ7x.mjs → Field--rQeS6Zj.mjs} +5 -5
  14. package/dist/_chunks/Field--rQeS6Zj.mjs.map +1 -0
  15. package/dist/_chunks/{Field-DSOUlTCm.js → Field-C1ftmTe9.js} +5 -5
  16. package/dist/_chunks/Field-C1ftmTe9.js.map +1 -0
  17. package/dist/_chunks/{Form-BAo9ANb_.mjs → Form-COtGXyUE.mjs} +2 -2
  18. package/dist/_chunks/{Form-BAo9ANb_.mjs.map → Form-COtGXyUE.mjs.map} +1 -1
  19. package/dist/_chunks/{Form-DAEfHKzm.js → Form-CwdX5oLw.js} +2 -2
  20. package/dist/_chunks/{Form-DAEfHKzm.js.map → Form-CwdX5oLw.js.map} +1 -1
  21. package/dist/_chunks/{History-BpLIu67W.mjs → History-BevwkPO1.mjs} +18 -34
  22. package/dist/_chunks/History-BevwkPO1.mjs.map +1 -0
  23. package/dist/_chunks/{History-CTFvy6XH.js → History-DKS2aqqM.js} +18 -34
  24. package/dist/_chunks/History-DKS2aqqM.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-DOqj5f8Y.mjs → ListConfigurationPage-DNfZDtDA.mjs} +3 -3
  26. package/dist/_chunks/{ListConfigurationPage-DOqj5f8Y.mjs.map → ListConfigurationPage-DNfZDtDA.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-CDzlMBz_.js → ListConfigurationPage-LSYSPZHH.js} +3 -3
  28. package/dist/_chunks/{ListConfigurationPage-CDzlMBz_.js.map → ListConfigurationPage-LSYSPZHH.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-BbXYNI0v.mjs → ListViewPage-C1PyuYRS.mjs} +15 -4
  30. package/dist/_chunks/{ListViewPage-BbXYNI0v.mjs.map → ListViewPage-C1PyuYRS.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-D0fpPYKp.js → ListViewPage-DlUpqLIo.js} +15 -4
  32. package/dist/_chunks/ListViewPage-DlUpqLIo.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-w2Q0VVOT.mjs → NoContentTypePage-C9q744z1.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-w2Q0VVOT.mjs.map → NoContentTypePage-C9q744z1.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-DTzkSAV5.js → NoContentTypePage-m8wt3sf6.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-DTzkSAV5.js.map → NoContentTypePage-m8wt3sf6.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-Km0Vk5Wp.mjs → NoPermissionsPage-8BM-LWta.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-Km0Vk5Wp.mjs.map → NoPermissionsPage-8BM-LWta.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-BoI2rU68.js → NoPermissionsPage-DLfPsA0Q.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-BoI2rU68.js.map → NoPermissionsPage-DLfPsA0Q.js.map} +1 -1
  41. package/dist/_chunks/{Relations-C_bpmSuQ.mjs → Relations-D25xRcFy.mjs} +25 -11
  42. package/dist/_chunks/Relations-D25xRcFy.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-D6Nz5ksc.js → Relations-OMriCP_L.js} +24 -10
  44. package/dist/_chunks/Relations-OMriCP_L.js.map +1 -0
  45. package/dist/_chunks/{en-Bm0D0IWz.js → en-Bdpa50w3.js} +6 -2
  46. package/dist/_chunks/{en-Bm0D0IWz.js.map → en-Bdpa50w3.js.map} +1 -1
  47. package/dist/_chunks/{en-DKV44jRb.mjs → en-CZw4xdPY.mjs} +6 -2
  48. package/dist/_chunks/{en-DKV44jRb.mjs.map → en-CZw4xdPY.mjs.map} +1 -1
  49. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  50. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  51. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  52. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  53. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  54. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  55. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  56. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  57. package/dist/_chunks/{index-DcQ6xogO.mjs → index-BvGihCJp.mjs} +111 -19
  58. package/dist/_chunks/index-BvGihCJp.mjs.map +1 -0
  59. package/dist/_chunks/{index-BsMu2oVP.js → index-DqZnjo8F.js} +109 -17
  60. package/dist/_chunks/index-DqZnjo8F.js.map +1 -0
  61. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  62. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  63. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  64. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  65. package/dist/_chunks/{layout-B4aCAdTt.js → layout-CmaemAO3.js} +3 -3
  66. package/dist/_chunks/{layout-B4aCAdTt.js.map → layout-CmaemAO3.js.map} +1 -1
  67. package/dist/_chunks/{layout-BavJ6v4B.mjs → layout-ykHSe2KQ.mjs} +3 -3
  68. package/dist/_chunks/{layout-BavJ6v4B.mjs.map → layout-ykHSe2KQ.mjs.map} +1 -1
  69. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  70. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  71. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  72. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  73. package/dist/_chunks/{relations-Lrm9nz_m.js → relations-D9fKsCLY.js} +3 -7
  74. package/dist/_chunks/relations-D9fKsCLY.js.map +1 -0
  75. package/dist/_chunks/{relations-DMG453Od.mjs → relations-u-Vz51Ea.mjs} +3 -7
  76. package/dist/_chunks/relations-u-Vz51Ea.mjs.map +1 -0
  77. package/dist/admin/index.js +1 -1
  78. package/dist/admin/index.mjs +1 -1
  79. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  80. package/dist/admin/src/preview/constants.d.ts +1 -0
  81. package/dist/admin/src/preview/index.d.ts +4 -0
  82. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  83. package/dist/server/index.js +304 -130
  84. package/dist/server/index.js.map +1 -1
  85. package/dist/server/index.mjs +304 -130
  86. package/dist/server/index.mjs.map +1 -1
  87. package/dist/server/src/bootstrap.d.ts.map +1 -1
  88. package/dist/server/src/controllers/index.d.ts.map +1 -1
  89. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  90. package/dist/server/src/history/services/utils.d.ts +2 -3
  91. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  92. package/dist/server/src/preview/constants.d.ts +2 -0
  93. package/dist/server/src/preview/constants.d.ts.map +1 -0
  94. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  95. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  96. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  97. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  98. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  99. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  100. package/dist/server/src/preview/index.d.ts +4 -0
  101. package/dist/server/src/preview/index.d.ts.map +1 -0
  102. package/dist/server/src/preview/routes/index.d.ts +8 -0
  103. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  104. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  105. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  106. package/dist/server/src/preview/services/index.d.ts +15 -0
  107. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  108. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  109. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  110. package/dist/server/src/preview/services/preview.d.ts +12 -0
  111. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  112. package/dist/server/src/preview/utils.d.ts +18 -0
  113. package/dist/server/src/preview/utils.d.ts.map +1 -0
  114. package/dist/server/src/routes/index.d.ts.map +1 -1
  115. package/dist/server/src/services/index.d.ts.map +1 -1
  116. package/dist/shared/contracts/index.d.ts +1 -0
  117. package/dist/shared/contracts/index.d.ts.map +1 -1
  118. package/dist/shared/contracts/preview.d.ts +27 -0
  119. package/dist/shared/contracts/preview.d.ts.map +1 -0
  120. package/dist/shared/index.js +4 -0
  121. package/dist/shared/index.js.map +1 -1
  122. package/dist/shared/index.mjs +4 -0
  123. package/dist/shared/index.mjs.map +1 -1
  124. package/package.json +7 -7
  125. package/dist/_chunks/Field-DSOUlTCm.js.map +0 -1
  126. package/dist/_chunks/Field-EeG6NQ7x.mjs.map +0 -1
  127. package/dist/_chunks/History-BpLIu67W.mjs.map +0 -1
  128. package/dist/_chunks/History-CTFvy6XH.js.map +0 -1
  129. package/dist/_chunks/ListViewPage-D0fpPYKp.js.map +0 -1
  130. package/dist/_chunks/Relations-C_bpmSuQ.mjs.map +0 -1
  131. package/dist/_chunks/Relations-D6Nz5ksc.js.map +0 -1
  132. package/dist/_chunks/index-BsMu2oVP.js.map +0 -1
  133. package/dist/_chunks/index-DcQ6xogO.mjs.map +0 -1
  134. package/dist/_chunks/relations-DMG453Od.mjs.map +0 -1
  135. package/dist/_chunks/relations-Lrm9nz_m.js.map +0 -1
@@ -33,10 +33,10 @@ const isNil__default = /* @__PURE__ */ _interopDefault(isNil);
33
33
  const ___default = /* @__PURE__ */ _interopDefault(_);
34
34
  const qs__default = /* @__PURE__ */ _interopDefault(qs);
35
35
  const slugify__default = /* @__PURE__ */ _interopDefault(slugify);
36
- const getService$1 = (name) => {
36
+ const getService$2 = (name) => {
37
37
  return strapi.plugin("content-manager").service(name);
38
38
  };
39
- function getService(strapi2, name) {
39
+ function getService$1(strapi2, name) {
40
40
  return strapi2.service(`plugin::content-manager.${name}`);
41
41
  }
42
42
  const historyRestoreVersionSchema = yup__namespace.object().shape({
@@ -72,7 +72,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
72
72
  if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
73
73
  throw new strapiUtils.errors.ForbiddenError("contentType and documentId are required");
74
74
  }
75
- const permissionChecker2 = getService$1("permission-checker").create({
75
+ const permissionChecker2 = getService$2("permission-checker").create({
76
76
  userAbility: ctx.state.userAbility,
77
77
  model: ctx.query.contentType
78
78
  });
@@ -80,7 +80,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
80
80
  return ctx.forbidden();
81
81
  }
82
82
  const query = await permissionChecker2.sanitizeQuery(ctx.query);
83
- const { results, pagination } = await getService(strapi2, "history").findVersionsPage({
83
+ const { results, pagination } = await getService$1(strapi2, "history").findVersionsPage({
84
84
  query: {
85
85
  ...query,
86
86
  ...getValidPagination({ page: query.page, pageSize: query.pageSize })
@@ -105,14 +105,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
105
105
  async restoreVersion(ctx) {
106
106
  const request = ctx.request;
107
107
  await validateRestoreVersion(request.body, "contentType is required");
108
- const permissionChecker2 = getService$1("permission-checker").create({
108
+ const permissionChecker2 = getService$2("permission-checker").create({
109
109
  userAbility: ctx.state.userAbility,
110
110
  model: request.body.contentType
111
111
  });
112
112
  if (permissionChecker2.cannot.update()) {
113
113
  throw new strapiUtils.errors.ForbiddenError();
114
114
  }
115
- const restoredDocument = await getService(strapi2, "history").restoreVersion(
115
+ const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
116
116
  request.params.versionId
117
117
  );
118
118
  return {
@@ -121,7 +121,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
121
121
  }
122
122
  };
123
123
  };
124
- const controllers$1 = {
124
+ const controllers$2 = {
125
125
  "history-version": createHistoryVersionController
126
126
  /**
127
127
  * Casting is needed because the types aren't aware that Strapi supports
@@ -228,6 +228,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
228
228
  const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
229
229
  return documentMetadataService.getStatus(document, meta.availableStatus);
230
230
  };
231
+ const getComponentFields = (componentUID) => {
232
+ return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
233
+ (fieldsAcc, [key, attribute]) => {
234
+ if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
235
+ fieldsAcc.push(key);
236
+ }
237
+ return fieldsAcc;
238
+ },
239
+ []
240
+ );
241
+ };
231
242
  const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
232
243
  const model = strapi2.getModel(uid2);
233
244
  const attributes = Object.entries(model.attributes);
@@ -251,13 +262,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
251
262
  }
252
263
  case "component": {
253
264
  const populate = getDeepPopulate2(attribute.component);
254
- acc[attributeName] = { populate };
265
+ acc[attributeName] = {
266
+ populate,
267
+ [fieldSelector]: getComponentFields(attribute.component)
268
+ };
255
269
  break;
256
270
  }
257
271
  case "dynamiczone": {
258
272
  const populatedComponents = (attribute.components || []).reduce(
259
273
  (acc2, componentUID) => {
260
- acc2[componentUID] = { populate: getDeepPopulate2(componentUID) };
274
+ acc2[componentUID] = {
275
+ populate: getDeepPopulate2(componentUID),
276
+ [fieldSelector]: getComponentFields(componentUID)
277
+ };
261
278
  return acc2;
262
279
  },
263
280
  {}
@@ -370,7 +387,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
370
387
  const attributeValue = entry.data[attributeKey];
371
388
  const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
372
389
  if (attributeSchema.type === "media") {
373
- const permissionChecker2 = getService$1("permission-checker").create({
390
+ const permissionChecker2 = getService$2("permission-checker").create({
374
391
  userAbility: params.state.userAbility,
375
392
  model: "plugin::upload.file"
376
393
  });
@@ -411,7 +428,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
411
428
  [attributeKey]: adminUsers
412
429
  };
413
430
  }
414
- const permissionChecker2 = getService$1("permission-checker").create({
431
+ const permissionChecker2 = getService$2("permission-checker").create({
415
432
  userAbility: params.state.userAbility,
416
433
  model: attributeSchema.target
417
434
  });
@@ -587,7 +604,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
587
604
  onCommit(async () => {
588
605
  for (const entry of localeEntries) {
589
606
  const status = await serviceUtils.getVersionStatus(uid2, entry);
590
- await getService(strapi2, "history").createVersion({
607
+ await getService$1(strapi2, "history").createVersion({
591
608
  contentType: uid2,
592
609
  data: fp.omit(FIELDS_TO_IGNORE, entry),
593
610
  relatedDocumentId: documentId,
@@ -600,15 +617,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
600
617
  });
601
618
  return result;
602
619
  });
603
- state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
620
+ state.deleteExpiredJob = nodeSchedule.scheduleJob("historyDaily", "0 0 * * *", () => {
604
621
  const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
605
622
  const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
606
623
  strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
607
624
  where: {
608
625
  created_at: {
609
- $lt: expirationDate.toISOString()
626
+ $lt: expirationDate
610
627
  }
611
628
  }
629
+ }).catch((error) => {
630
+ if (error instanceof Error) {
631
+ strapi2.log.error("Error deleting expired history versions", error.message);
632
+ }
612
633
  });
613
634
  });
614
635
  state.isInitialized = true;
@@ -620,17 +641,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
620
641
  }
621
642
  };
622
643
  };
623
- const services$1 = {
644
+ const services$2 = {
624
645
  history: createHistoryService,
625
646
  lifecycles: createLifecyclesService
626
647
  };
627
- const info = { pluginName: "content-manager", type: "admin" };
648
+ const info$1 = { pluginName: "content-manager", type: "admin" };
628
649
  const historyVersionRouter = {
629
650
  type: "admin",
630
651
  routes: [
631
652
  {
632
653
  method: "GET",
633
- info,
654
+ info: info$1,
634
655
  path: "/history-versions",
635
656
  handler: "history-version.findMany",
636
657
  config: {
@@ -639,7 +660,7 @@ const historyVersionRouter = {
639
660
  },
640
661
  {
641
662
  method: "PUT",
642
- info,
663
+ info: info$1,
643
664
  path: "/history-versions/:versionId/restore",
644
665
  handler: "history-version.restoreVersion",
645
666
  config: {
@@ -648,7 +669,7 @@ const historyVersionRouter = {
648
669
  }
649
670
  ]
650
671
  };
651
- const routes$1 = {
672
+ const routes$2 = {
652
673
  "history-version": historyVersionRouter
653
674
  };
654
675
  const historyVersion = {
@@ -695,21 +716,21 @@ const historyVersion = {
695
716
  }
696
717
  }
697
718
  };
698
- const getFeature = () => {
719
+ const getFeature$1 = () => {
699
720
  if (strapi.ee.features.isEnabled("cms-content-history")) {
700
721
  return {
701
722
  register({ strapi: strapi2 }) {
702
723
  strapi2.get("models").add(historyVersion);
703
724
  },
704
725
  bootstrap({ strapi: strapi2 }) {
705
- getService(strapi2, "lifecycles").bootstrap();
726
+ getService$1(strapi2, "lifecycles").bootstrap();
706
727
  },
707
728
  destroy({ strapi: strapi2 }) {
708
- getService(strapi2, "lifecycles").destroy();
729
+ getService$1(strapi2, "lifecycles").destroy();
709
730
  },
710
- controllers: controllers$1,
711
- services: services$1,
712
- routes: routes$1
731
+ controllers: controllers$2,
732
+ services: services$2,
733
+ routes: routes$2
713
734
  };
714
735
  }
715
736
  return {
@@ -718,7 +739,7 @@ const getFeature = () => {
718
739
  }
719
740
  };
720
741
  };
721
- const history = getFeature();
742
+ const history = getFeature$1();
722
743
  const register = async ({ strapi: strapi2 }) => {
723
744
  await history.register?.({ strapi: strapi2 });
724
745
  };
@@ -726,15 +747,165 @@ const ALLOWED_WEBHOOK_EVENTS = {
726
747
  ENTRY_PUBLISH: "entry.publish",
727
748
  ENTRY_UNPUBLISH: "entry.unpublish"
728
749
  };
750
+ const FEATURE_ID = "preview";
751
+ const info = { pluginName: "content-manager", type: "admin" };
752
+ const previewRouter = {
753
+ type: "admin",
754
+ routes: [
755
+ {
756
+ method: "GET",
757
+ info,
758
+ path: "/preview/url/:contentType",
759
+ handler: "preview.getPreviewUrl",
760
+ config: {
761
+ policies: ["admin::isAuthenticatedAdmin"]
762
+ }
763
+ }
764
+ ]
765
+ };
766
+ const routes$1 = {
767
+ preview: previewRouter
768
+ };
769
+ function getService(strapi2, name) {
770
+ return strapi2.service(`plugin::content-manager.${name}`);
771
+ }
772
+ const getPreviewUrlSchema = yup__namespace.object().shape({
773
+ // Will be undefined for single types
774
+ documentId: yup__namespace.string(),
775
+ locale: yup__namespace.string().nullable(),
776
+ status: yup__namespace.string()
777
+ }).required();
778
+ const validatePreviewUrl = async (strapi2, uid2, params) => {
779
+ await strapiUtils.validateYupSchema(getPreviewUrlSchema)(params);
780
+ const newParams = fp.pick(["documentId", "locale", "status"], params);
781
+ const model = strapi2.getModel(uid2);
782
+ if (!model || model.modelType !== "contentType") {
783
+ throw new strapiUtils.errors.ValidationError("Invalid content type");
784
+ }
785
+ const isSingleType = model?.kind === "singleType";
786
+ if (!isSingleType && !params.documentId) {
787
+ throw new strapiUtils.errors.ValidationError("documentId is required for Collection Types");
788
+ }
789
+ if (isSingleType) {
790
+ const doc = await strapi2.documents(uid2).findFirst();
791
+ if (!doc) {
792
+ throw new strapiUtils.errors.NotFoundError("Document not found");
793
+ }
794
+ newParams.documentId = doc?.documentId;
795
+ }
796
+ return newParams;
797
+ };
798
+ const createPreviewController = () => {
799
+ return {
800
+ /**
801
+ * Transforms an entry into a preview URL, so that it can be previewed
802
+ * in the Content Manager.
803
+ */
804
+ async getPreviewUrl(ctx) {
805
+ const uid2 = ctx.params.contentType;
806
+ const query = ctx.request.query;
807
+ const params = await validatePreviewUrl(strapi, uid2, query);
808
+ const previewService = getService(strapi, "preview");
809
+ const url = await previewService.getPreviewUrl(uid2, params);
810
+ if (!url) {
811
+ ctx.status = 204;
812
+ }
813
+ return {
814
+ data: { url }
815
+ };
816
+ }
817
+ };
818
+ };
819
+ const controllers$1 = {
820
+ preview: createPreviewController
821
+ /**
822
+ * Casting is needed because the types aren't aware that Strapi supports
823
+ * passing a controller factory as the value, instead of a controller object directly
824
+ */
825
+ };
826
+ const createPreviewService = ({ strapi: strapi2 }) => {
827
+ const config = getService(strapi2, "preview-config");
828
+ return {
829
+ async getPreviewUrl(uid2, params) {
830
+ const handler = config.getPreviewHandler();
831
+ try {
832
+ return handler(uid2, params);
833
+ } catch (error) {
834
+ strapi2.log.error(`Failed to get preview URL: ${error}`);
835
+ throw new strapiUtils.errors.ApplicationError("Failed to get preview URL");
836
+ }
837
+ return;
838
+ }
839
+ };
840
+ };
841
+ const createPreviewConfigService = ({ strapi: strapi2 }) => {
842
+ return {
843
+ isEnabled() {
844
+ const config = strapi2.config.get("admin.preview");
845
+ if (!config) {
846
+ return false;
847
+ }
848
+ return config?.enabled ?? true;
849
+ },
850
+ /**
851
+ * Validate if the configuration is valid
852
+ */
853
+ validate() {
854
+ if (!this.isEnabled()) {
855
+ return;
856
+ }
857
+ const handler = this.getPreviewHandler();
858
+ if (typeof handler !== "function") {
859
+ throw new strapiUtils.errors.ValidationError(
860
+ "Preview configuration is invalid. Handler must be a function"
861
+ );
862
+ }
863
+ },
864
+ /**
865
+ * Utility to get the preview handler from the configuration
866
+ */
867
+ getPreviewHandler() {
868
+ const config = strapi2.config.get("admin.preview");
869
+ const emptyHandler = () => {
870
+ return void 0;
871
+ };
872
+ if (!this.isEnabled()) {
873
+ return emptyHandler;
874
+ }
875
+ return config?.config?.handler || emptyHandler;
876
+ }
877
+ };
878
+ };
879
+ const services$1 = {
880
+ preview: createPreviewService,
881
+ "preview-config": createPreviewConfigService
882
+ };
883
+ const getFeature = () => {
884
+ if (!strapi.features.future.isEnabled(FEATURE_ID)) {
885
+ return {};
886
+ }
887
+ return {
888
+ bootstrap() {
889
+ console.log("Bootstrapping preview server");
890
+ const config = getService(strapi, "preview-config");
891
+ config.validate();
892
+ },
893
+ routes: routes$1,
894
+ controllers: controllers$1,
895
+ services: services$1
896
+ };
897
+ };
898
+ const preview = getFeature();
729
899
  const bootstrap = async () => {
730
900
  Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
731
901
  strapi.get("webhookStore").addAllowedEvent(key, value);
732
902
  });
733
- getService$1("field-sizes").setCustomFieldInputSizes();
734
- await getService$1("components").syncConfigurations();
735
- await getService$1("content-types").syncConfigurations();
736
- await getService$1("permission").registerPermissions();
903
+ getService$2("field-sizes").setCustomFieldInputSizes();
904
+ await getService$2("components").syncConfigurations();
905
+ await getService$2("content-types").syncConfigurations();
906
+ await getService$2("permission").registerPermissions();
737
907
  await history.bootstrap?.({ strapi });
908
+ await preview.bootstrap?.({ strapi });
738
909
  };
739
910
  const destroy = async ({ strapi: strapi2 }) => {
740
911
  await history.destroy?.({ strapi: strapi2 });
@@ -1224,7 +1395,8 @@ const admin = {
1224
1395
  };
1225
1396
  const routes = {
1226
1397
  admin,
1227
- ...history.routes ? history.routes : {}
1398
+ ...history.routes ? history.routes : {},
1399
+ ...preview.routes ? preview.routes : {}
1228
1400
  };
1229
1401
  const hasPermissionsSchema = strapiUtils.yup.object({
1230
1402
  actions: strapiUtils.yup.array().of(strapiUtils.yup.string()),
@@ -1481,7 +1653,7 @@ const createMetadasSchema = (schema) => {
1481
1653
  if (!value) {
1482
1654
  return strapiUtils.yup.string();
1483
1655
  }
1484
- const targetSchema = getService$1("content-types").findContentType(
1656
+ const targetSchema = getService$2("content-types").findContentType(
1485
1657
  schema.attributes[key].targetModel
1486
1658
  );
1487
1659
  if (!targetSchema) {
@@ -1650,7 +1822,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
1650
1822
  }
1651
1823
  };
1652
1824
  const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
1653
- const documentMetadata2 = getService$1("document-metadata");
1825
+ const documentMetadata2 = getService$2("document-metadata");
1654
1826
  const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
1655
1827
  let {
1656
1828
  meta: { availableLocales, availableStatus }
@@ -1676,8 +1848,8 @@ const createDocument = async (ctx, opts) => {
1676
1848
  const { userAbility, user } = ctx.state;
1677
1849
  const { model } = ctx.params;
1678
1850
  const { body } = ctx.request;
1679
- const documentManager2 = getService$1("document-manager");
1680
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1851
+ const documentManager2 = getService$2("document-manager");
1852
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1681
1853
  if (permissionChecker2.cannot.create()) {
1682
1854
  throw new strapiUtils.errors.ForbiddenError();
1683
1855
  }
@@ -1697,13 +1869,13 @@ const updateDocument = async (ctx, opts) => {
1697
1869
  const { userAbility, user } = ctx.state;
1698
1870
  const { id, model } = ctx.params;
1699
1871
  const { body } = ctx.request;
1700
- const documentManager2 = getService$1("document-manager");
1701
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1872
+ const documentManager2 = getService$2("document-manager");
1873
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1702
1874
  if (permissionChecker2.cannot.update()) {
1703
1875
  throw new strapiUtils.errors.ForbiddenError();
1704
1876
  }
1705
1877
  const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
1706
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
1878
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1707
1879
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1708
1880
  const [documentVersion, documentExists] = await Promise.all([
1709
1881
  documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
@@ -1734,14 +1906,14 @@ const collectionTypes = {
1734
1906
  const { userAbility } = ctx.state;
1735
1907
  const { model } = ctx.params;
1736
1908
  const { query } = ctx.request;
1737
- const documentMetadata2 = getService$1("document-metadata");
1738
- const documentManager2 = getService$1("document-manager");
1739
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1909
+ const documentMetadata2 = getService$2("document-metadata");
1910
+ const documentManager2 = getService$2("document-manager");
1911
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1740
1912
  if (permissionChecker2.cannot.read()) {
1741
1913
  return ctx.forbidden();
1742
1914
  }
1743
1915
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
1744
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1916
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1745
1917
  const { locale, status } = await getDocumentLocaleAndStatus(query, model);
1746
1918
  const { results: documents, pagination } = await documentManager2.findPage(
1747
1919
  { ...permissionQuery, populate, locale, status },
@@ -1770,13 +1942,13 @@ const collectionTypes = {
1770
1942
  async findOne(ctx) {
1771
1943
  const { userAbility } = ctx.state;
1772
1944
  const { model, id } = ctx.params;
1773
- const documentManager2 = getService$1("document-manager");
1774
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1945
+ const documentManager2 = getService$2("document-manager");
1946
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1775
1947
  if (permissionChecker2.cannot.read()) {
1776
1948
  return ctx.forbidden();
1777
1949
  }
1778
1950
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
1779
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1951
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1780
1952
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
1781
1953
  const version = await documentManager2.findOne(id, model, {
1782
1954
  populate,
@@ -1807,7 +1979,7 @@ const collectionTypes = {
1807
1979
  async create(ctx) {
1808
1980
  const { userAbility } = ctx.state;
1809
1981
  const { model } = ctx.params;
1810
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1982
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1811
1983
  const [totalEntries, document] = await Promise.all([
1812
1984
  strapi.db.query(model).count(),
1813
1985
  createDocument(ctx)
@@ -1828,7 +2000,7 @@ const collectionTypes = {
1828
2000
  async update(ctx) {
1829
2001
  const { userAbility } = ctx.state;
1830
2002
  const { model } = ctx.params;
1831
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2003
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1832
2004
  const updatedVersion = await updateDocument(ctx);
1833
2005
  const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
1834
2006
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
@@ -1837,13 +2009,13 @@ const collectionTypes = {
1837
2009
  const { userAbility, user } = ctx.state;
1838
2010
  const { model, sourceId: id } = ctx.params;
1839
2011
  const { body } = ctx.request;
1840
- const documentManager2 = getService$1("document-manager");
1841
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2012
+ const documentManager2 = getService$2("document-manager");
2013
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1842
2014
  if (permissionChecker2.cannot.create()) {
1843
2015
  return ctx.forbidden();
1844
2016
  }
1845
2017
  const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
1846
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2018
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1847
2019
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1848
2020
  const document = await documentManager2.findOne(id, model, {
1849
2021
  populate,
@@ -1882,13 +2054,13 @@ const collectionTypes = {
1882
2054
  async delete(ctx) {
1883
2055
  const { userAbility } = ctx.state;
1884
2056
  const { id, model } = ctx.params;
1885
- const documentManager2 = getService$1("document-manager");
1886
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2057
+ const documentManager2 = getService$2("document-manager");
2058
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1887
2059
  if (permissionChecker2.cannot.delete()) {
1888
2060
  return ctx.forbidden();
1889
2061
  }
1890
2062
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
1891
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2063
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1892
2064
  const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
1893
2065
  const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
1894
2066
  if (documentLocales.length === 0) {
@@ -1910,14 +2082,14 @@ const collectionTypes = {
1910
2082
  const { userAbility } = ctx.state;
1911
2083
  const { id, model } = ctx.params;
1912
2084
  const { body } = ctx.request;
1913
- const documentManager2 = getService$1("document-manager");
1914
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2085
+ const documentManager2 = getService$2("document-manager");
2086
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1915
2087
  if (permissionChecker2.cannot.publish()) {
1916
2088
  return ctx.forbidden();
1917
2089
  }
1918
2090
  const publishedDocument = await strapi.db.transaction(async () => {
1919
2091
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1920
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2092
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1921
2093
  let document;
1922
2094
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1923
2095
  const isCreate = fp.isNil(id);
@@ -1965,13 +2137,13 @@ const collectionTypes = {
1965
2137
  const { body } = ctx.request;
1966
2138
  const { documentIds } = body;
1967
2139
  await validateBulkActionInput(body);
1968
- const documentManager2 = getService$1("document-manager");
1969
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2140
+ const documentManager2 = getService$2("document-manager");
2141
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1970
2142
  if (permissionChecker2.cannot.publish()) {
1971
2143
  return ctx.forbidden();
1972
2144
  }
1973
2145
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1974
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2146
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1975
2147
  const { locale } = await getDocumentLocaleAndStatus(body, model, {
1976
2148
  allowMultipleLocales: true
1977
2149
  });
@@ -1996,8 +2168,8 @@ const collectionTypes = {
1996
2168
  const { body } = ctx.request;
1997
2169
  const { documentIds } = body;
1998
2170
  await validateBulkActionInput(body);
1999
- const documentManager2 = getService$1("document-manager");
2000
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2171
+ const documentManager2 = getService$2("document-manager");
2172
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2001
2173
  if (permissionChecker2.cannot.unpublish()) {
2002
2174
  return ctx.forbidden();
2003
2175
  }
@@ -2026,8 +2198,8 @@ const collectionTypes = {
2026
2198
  const {
2027
2199
  body: { discardDraft, ...body }
2028
2200
  } = ctx.request;
2029
- const documentManager2 = getService$1("document-manager");
2030
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2201
+ const documentManager2 = getService$2("document-manager");
2202
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2031
2203
  if (permissionChecker2.cannot.unpublish()) {
2032
2204
  return ctx.forbidden();
2033
2205
  }
@@ -2035,7 +2207,7 @@ const collectionTypes = {
2035
2207
  return ctx.forbidden();
2036
2208
  }
2037
2209
  const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
2038
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2210
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2039
2211
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2040
2212
  const document = await documentManager2.findOne(id, model, {
2041
2213
  populate,
@@ -2066,13 +2238,13 @@ const collectionTypes = {
2066
2238
  const { userAbility } = ctx.state;
2067
2239
  const { id, model } = ctx.params;
2068
2240
  const { body } = ctx.request;
2069
- const documentManager2 = getService$1("document-manager");
2070
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2241
+ const documentManager2 = getService$2("document-manager");
2242
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2071
2243
  if (permissionChecker2.cannot.discard()) {
2072
2244
  return ctx.forbidden();
2073
2245
  }
2074
2246
  const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
2075
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2247
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2076
2248
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2077
2249
  const document = await documentManager2.findOne(id, model, {
2078
2250
  populate,
@@ -2097,13 +2269,13 @@ const collectionTypes = {
2097
2269
  const { query, body } = ctx.request;
2098
2270
  const { documentIds } = body;
2099
2271
  await validateBulkActionInput(body);
2100
- const documentManager2 = getService$1("document-manager");
2101
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2272
+ const documentManager2 = getService$2("document-manager");
2273
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2102
2274
  if (permissionChecker2.cannot.delete()) {
2103
2275
  return ctx.forbidden();
2104
2276
  }
2105
2277
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
2106
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2278
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2107
2279
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2108
2280
  const documentLocales = await documentManager2.findLocales(documentIds, model, {
2109
2281
  populate,
@@ -2124,13 +2296,13 @@ const collectionTypes = {
2124
2296
  async countDraftRelations(ctx) {
2125
2297
  const { userAbility } = ctx.state;
2126
2298
  const { model, id } = ctx.params;
2127
- const documentManager2 = getService$1("document-manager");
2128
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2299
+ const documentManager2 = getService$2("document-manager");
2300
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2129
2301
  if (permissionChecker2.cannot.read()) {
2130
2302
  return ctx.forbidden();
2131
2303
  }
2132
2304
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2133
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2305
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2134
2306
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
2135
2307
  const entity = await documentManager2.findOne(id, model, { populate, locale, status });
2136
2308
  if (!entity) {
@@ -2149,8 +2321,8 @@ const collectionTypes = {
2149
2321
  const ids = ctx.request.query.documentIds;
2150
2322
  const locale = ctx.request.query.locale;
2151
2323
  const { model } = ctx.params;
2152
- const documentManager2 = getService$1("document-manager");
2153
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2324
+ const documentManager2 = getService$2("document-manager");
2325
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2154
2326
  if (permissionChecker2.cannot.read()) {
2155
2327
  return ctx.forbidden();
2156
2328
  }
@@ -2174,13 +2346,13 @@ const collectionTypes = {
2174
2346
  };
2175
2347
  const components$1 = {
2176
2348
  findComponents(ctx) {
2177
- const components2 = getService$1("components").findAllComponents();
2178
- const { toDto } = getService$1("data-mapper");
2349
+ const components2 = getService$2("components").findAllComponents();
2350
+ const { toDto } = getService$2("data-mapper");
2179
2351
  ctx.body = { data: components2.map(toDto) };
2180
2352
  },
2181
2353
  async findComponentConfiguration(ctx) {
2182
2354
  const { uid: uid2 } = ctx.params;
2183
- const componentService = getService$1("components");
2355
+ const componentService = getService$2("components");
2184
2356
  const component = componentService.findComponent(uid2);
2185
2357
  if (!component) {
2186
2358
  return ctx.notFound("component.notFound");
@@ -2197,7 +2369,7 @@ const components$1 = {
2197
2369
  async updateComponentConfiguration(ctx) {
2198
2370
  const { uid: uid2 } = ctx.params;
2199
2371
  const { body } = ctx.request;
2200
- const componentService = getService$1("components");
2372
+ const componentService = getService$2("components");
2201
2373
  const component = componentService.findComponent(uid2);
2202
2374
  if (!component) {
2203
2375
  return ctx.notFound("component.notFound");
@@ -2231,12 +2403,12 @@ const contentTypes = {
2231
2403
  } catch (error) {
2232
2404
  return ctx.send({ error }, 400);
2233
2405
  }
2234
- const contentTypes2 = getService$1("content-types").findContentTypesByKind(kind);
2235
- const { toDto } = getService$1("data-mapper");
2406
+ const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
2407
+ const { toDto } = getService$2("data-mapper");
2236
2408
  ctx.body = { data: contentTypes2.map(toDto) };
2237
2409
  },
2238
2410
  async findContentTypesSettings(ctx) {
2239
- const { findAllContentTypes, findConfiguration } = getService$1("content-types");
2411
+ const { findAllContentTypes, findConfiguration } = getService$2("content-types");
2240
2412
  const contentTypes2 = await findAllContentTypes();
2241
2413
  const configurations = await Promise.all(
2242
2414
  contentTypes2.map(async (contentType) => {
@@ -2250,7 +2422,7 @@ const contentTypes = {
2250
2422
  },
2251
2423
  async findContentTypeConfiguration(ctx) {
2252
2424
  const { uid: uid2 } = ctx.params;
2253
- const contentTypeService = getService$1("content-types");
2425
+ const contentTypeService = getService$2("content-types");
2254
2426
  const contentType = await contentTypeService.findContentType(uid2);
2255
2427
  if (!contentType) {
2256
2428
  return ctx.notFound("contentType.notFound");
@@ -2272,13 +2444,13 @@ const contentTypes = {
2272
2444
  const { userAbility } = ctx.state;
2273
2445
  const { uid: uid2 } = ctx.params;
2274
2446
  const { body } = ctx.request;
2275
- const contentTypeService = getService$1("content-types");
2276
- const metricsService = getService$1("metrics");
2447
+ const contentTypeService = getService$2("content-types");
2448
+ const metricsService = getService$2("metrics");
2277
2449
  const contentType = await contentTypeService.findContentType(uid2);
2278
2450
  if (!contentType) {
2279
2451
  return ctx.notFound("contentType.notFound");
2280
2452
  }
2281
- if (!getService$1("permission").canConfigureContentType({ userAbility, contentType })) {
2453
+ if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
2282
2454
  return ctx.forbidden();
2283
2455
  }
2284
2456
  let input;
@@ -2311,10 +2483,10 @@ const contentTypes = {
2311
2483
  };
2312
2484
  const init = {
2313
2485
  getInitData(ctx) {
2314
- const { toDto } = getService$1("data-mapper");
2315
- const { findAllComponents } = getService$1("components");
2316
- const { getAllFieldSizes } = getService$1("field-sizes");
2317
- const { findAllContentTypes } = getService$1("content-types");
2486
+ const { toDto } = getService$2("data-mapper");
2487
+ const { findAllComponents } = getService$2("components");
2488
+ const { getAllFieldSizes } = getService$2("field-sizes");
2489
+ const { findAllContentTypes } = getService$2("content-types");
2318
2490
  ctx.body = {
2319
2491
  data: {
2320
2492
  fieldSizes: getAllFieldSizes(),
@@ -2350,7 +2522,7 @@ const addFiltersClause = (params, filtersClause) => {
2350
2522
  params.filters.$and.push(filtersClause);
2351
2523
  };
2352
2524
  const sanitizeMainField = (model, mainField, userAbility) => {
2353
- const permissionChecker2 = getService$1("permission-checker").create({
2525
+ const permissionChecker2 = getService$2("permission-checker").create({
2354
2526
  userAbility,
2355
2527
  model: model.uid
2356
2528
  });
@@ -2368,7 +2540,7 @@ const addStatusToRelations = async (targetUid, relations2) => {
2368
2540
  if (!strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(targetUid))) {
2369
2541
  return relations2;
2370
2542
  }
2371
- const documentMetadata2 = getService$1("document-metadata");
2543
+ const documentMetadata2 = getService$2("document-metadata");
2372
2544
  if (!relations2.length) {
2373
2545
  return relations2;
2374
2546
  }
@@ -2446,7 +2618,7 @@ const relations = {
2446
2618
  ctx.request?.query?.locale
2447
2619
  );
2448
2620
  const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
2449
- const permissionChecker2 = getService$1("permission-checker").create({
2621
+ const permissionChecker2 = getService$2("permission-checker").create({
2450
2622
  userAbility,
2451
2623
  model
2452
2624
  });
@@ -2471,7 +2643,7 @@ const relations = {
2471
2643
  where.id = id;
2472
2644
  }
2473
2645
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2474
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2646
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2475
2647
  const currentEntity = await strapi.db.query(model).findOne({
2476
2648
  where,
2477
2649
  populate
@@ -2486,7 +2658,7 @@ const relations = {
2486
2658
  }
2487
2659
  entryId = currentEntity.id;
2488
2660
  }
2489
- const modelConfig = isComponent2 ? await getService$1("components").findConfiguration(sourceSchema) : await getService$1("content-types").findConfiguration(sourceSchema);
2661
+ const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
2490
2662
  const targetSchema = strapi.getModel(targetUid);
2491
2663
  const mainField = fp.flow(
2492
2664
  fp.prop(`metadatas.${targetField}.edit.mainField`),
@@ -2540,7 +2712,7 @@ const relations = {
2540
2712
  }
2541
2713
  } = await this.extractAndValidateRequestInfo(ctx, id);
2542
2714
  const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
2543
- const permissionChecker2 = getService$1("permission-checker").create({
2715
+ const permissionChecker2 = getService$2("permission-checker").create({
2544
2716
  userAbility: ctx.state.userAbility,
2545
2717
  model: targetUid
2546
2718
  });
@@ -2619,7 +2791,7 @@ const relations = {
2619
2791
  } = await this.extractAndValidateRequestInfo(ctx, id);
2620
2792
  const { uid: sourceUid } = sourceSchema;
2621
2793
  const { uid: targetUid } = targetSchema;
2622
- const permissionQuery = await getService$1("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2794
+ const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2623
2795
  const dbQuery = strapi.db.query(sourceUid);
2624
2796
  const loadRelations = strapiUtils.relations.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
2625
2797
  const filters = {};
@@ -2660,10 +2832,10 @@ const relations = {
2660
2832
  }
2661
2833
  };
2662
2834
  const buildPopulateFromQuery = async (query, model) => {
2663
- return getService$1("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2835
+ return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2664
2836
  };
2665
2837
  const findDocument = async (query, uid2, opts = {}) => {
2666
- const documentManager2 = getService$1("document-manager");
2838
+ const documentManager2 = getService$2("document-manager");
2667
2839
  const populate = await buildPopulateFromQuery(query, uid2);
2668
2840
  return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
2669
2841
  };
@@ -2671,8 +2843,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
2671
2843
  const { user, userAbility } = ctx.state;
2672
2844
  const { model } = ctx.params;
2673
2845
  const { body, query } = ctx.request;
2674
- const documentManager2 = getService$1("document-manager");
2675
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2846
+ const documentManager2 = getService$2("document-manager");
2847
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2676
2848
  if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
2677
2849
  throw new strapiUtils.errors.ForbiddenError();
2678
2850
  }
@@ -2713,7 +2885,7 @@ const singleTypes = {
2713
2885
  const { userAbility } = ctx.state;
2714
2886
  const { model } = ctx.params;
2715
2887
  const { query = {} } = ctx.request;
2716
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2888
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2717
2889
  if (permissionChecker2.cannot.read()) {
2718
2890
  return ctx.forbidden();
2719
2891
  }
@@ -2747,7 +2919,7 @@ const singleTypes = {
2747
2919
  async createOrUpdate(ctx) {
2748
2920
  const { userAbility } = ctx.state;
2749
2921
  const { model } = ctx.params;
2750
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2922
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2751
2923
  const document = await createOrUpdateDocument(ctx);
2752
2924
  const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
2753
2925
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
@@ -2756,8 +2928,8 @@ const singleTypes = {
2756
2928
  const { userAbility } = ctx.state;
2757
2929
  const { model } = ctx.params;
2758
2930
  const { query = {} } = ctx.request;
2759
- const documentManager2 = getService$1("document-manager");
2760
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2931
+ const documentManager2 = getService$2("document-manager");
2932
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2761
2933
  if (permissionChecker2.cannot.delete()) {
2762
2934
  return ctx.forbidden();
2763
2935
  }
@@ -2785,8 +2957,8 @@ const singleTypes = {
2785
2957
  const { userAbility } = ctx.state;
2786
2958
  const { model } = ctx.params;
2787
2959
  const { query = {} } = ctx.request;
2788
- const documentManager2 = getService$1("document-manager");
2789
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2960
+ const documentManager2 = getService$2("document-manager");
2961
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2790
2962
  if (permissionChecker2.cannot.publish()) {
2791
2963
  return ctx.forbidden();
2792
2964
  }
@@ -2814,8 +2986,8 @@ const singleTypes = {
2814
2986
  body: { discardDraft, ...body },
2815
2987
  query = {}
2816
2988
  } = ctx.request;
2817
- const documentManager2 = getService$1("document-manager");
2818
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2989
+ const documentManager2 = getService$2("document-manager");
2990
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2819
2991
  if (permissionChecker2.cannot.unpublish()) {
2820
2992
  return ctx.forbidden();
2821
2993
  }
@@ -2849,8 +3021,8 @@ const singleTypes = {
2849
3021
  const { userAbility } = ctx.state;
2850
3022
  const { model } = ctx.params;
2851
3023
  const { body, query = {} } = ctx.request;
2852
- const documentManager2 = getService$1("document-manager");
2853
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3024
+ const documentManager2 = getService$2("document-manager");
3025
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2854
3026
  if (permissionChecker2.cannot.discard()) {
2855
3027
  return ctx.forbidden();
2856
3028
  }
@@ -2873,8 +3045,8 @@ const singleTypes = {
2873
3045
  const { userAbility } = ctx.state;
2874
3046
  const { model } = ctx.params;
2875
3047
  const { query } = ctx.request;
2876
- const documentManager2 = getService$1("document-manager");
2877
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3048
+ const documentManager2 = getService$2("document-manager");
3049
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2878
3050
  const { locale } = await getDocumentLocaleAndStatus(query, model);
2879
3051
  if (permissionChecker2.cannot.read()) {
2880
3052
  return ctx.forbidden();
@@ -2898,7 +3070,7 @@ const uid$1 = {
2898
3070
  const { query = {} } = ctx.request;
2899
3071
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2900
3072
  await validateUIDField(contentTypeUID, field);
2901
- const uidService = getService$1("uid");
3073
+ const uidService = getService$2("uid");
2902
3074
  ctx.body = {
2903
3075
  data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
2904
3076
  };
@@ -2910,7 +3082,7 @@ const uid$1 = {
2910
3082
  const { query = {} } = ctx.request;
2911
3083
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2912
3084
  await validateUIDField(contentTypeUID, field);
2913
- const uidService = getService$1("uid");
3085
+ const uidService = getService$2("uid");
2914
3086
  const isAvailable = await uidService.checkUIDAvailability({
2915
3087
  contentTypeUID,
2916
3088
  field,
@@ -2931,7 +3103,8 @@ const controllers = {
2931
3103
  relations,
2932
3104
  "single-types": singleTypes,
2933
3105
  uid: uid$1,
2934
- ...history.controllers ? history.controllers : {}
3106
+ ...history.controllers ? history.controllers : {},
3107
+ ...preview.controllers ? preview.controllers : {}
2935
3108
  };
2936
3109
  const keys = {
2937
3110
  CONFIGURATION: "configuration"
@@ -3082,12 +3255,12 @@ async function syncMetadatas(configuration, schema) {
3082
3255
  return ___default.default.assign(metasWithDefaults, updatedMetas);
3083
3256
  }
3084
3257
  const getTargetSchema = (targetModel) => {
3085
- return getService$1("content-types").findContentType(targetModel);
3258
+ return getService$2("content-types").findContentType(targetModel);
3086
3259
  };
3087
3260
  const DEFAULT_LIST_LENGTH = 4;
3088
3261
  const MAX_ROW_SIZE = 12;
3089
3262
  const isAllowedFieldSize = (type, size) => {
3090
- const { getFieldSize } = getService$1("field-sizes");
3263
+ const { getFieldSize } = getService$2("field-sizes");
3091
3264
  const fieldSize = getFieldSize(type);
3092
3265
  if (!fieldSize.isResizable && size !== fieldSize.default) {
3093
3266
  return false;
@@ -3095,7 +3268,7 @@ const isAllowedFieldSize = (type, size) => {
3095
3268
  return size <= MAX_ROW_SIZE;
3096
3269
  };
3097
3270
  const getDefaultFieldSize = (attribute) => {
3098
- const { hasFieldSize, getFieldSize } = getService$1("field-sizes");
3271
+ const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
3099
3272
  return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
3100
3273
  };
3101
3274
  async function createDefaultLayouts(schema) {
@@ -3130,7 +3303,7 @@ function syncLayouts(configuration, schema) {
3130
3303
  for (const el of row) {
3131
3304
  if (!hasEditableAttribute(schema, el.name))
3132
3305
  continue;
3133
- const { hasFieldSize } = getService$1("field-sizes");
3306
+ const { hasFieldSize } = getService$2("field-sizes");
3134
3307
  const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
3135
3308
  if (!isAllowedFieldSize(fieldType, el.size)) {
3136
3309
  elementsToReAppend.push(el.name);
@@ -3270,17 +3443,17 @@ const configurationService$1 = createConfigurationService({
3270
3443
  isComponent: true,
3271
3444
  prefix: STORE_KEY_PREFIX,
3272
3445
  getModels() {
3273
- const { toContentManagerModel } = getService$1("data-mapper");
3446
+ const { toContentManagerModel } = getService$2("data-mapper");
3274
3447
  return fp.mapValues(toContentManagerModel, strapi.components);
3275
3448
  }
3276
3449
  });
3277
3450
  const components = ({ strapi: strapi2 }) => ({
3278
3451
  findAllComponents() {
3279
- const { toContentManagerModel } = getService$1("data-mapper");
3452
+ const { toContentManagerModel } = getService$2("data-mapper");
3280
3453
  return Object.values(strapi2.components).map(toContentManagerModel);
3281
3454
  },
3282
3455
  findComponent(uid2) {
3283
- const { toContentManagerModel } = getService$1("data-mapper");
3456
+ const { toContentManagerModel } = getService$2("data-mapper");
3284
3457
  const component = strapi2.components[uid2];
3285
3458
  return fp.isNil(component) ? component : toContentManagerModel(component);
3286
3459
  },
@@ -3331,17 +3504,17 @@ const configurationService = createConfigurationService({
3331
3504
  storeUtils,
3332
3505
  prefix: "content_types",
3333
3506
  getModels() {
3334
- const { toContentManagerModel } = getService$1("data-mapper");
3507
+ const { toContentManagerModel } = getService$2("data-mapper");
3335
3508
  return fp.mapValues(toContentManagerModel, strapi.contentTypes);
3336
3509
  }
3337
3510
  });
3338
3511
  const service = ({ strapi: strapi2 }) => ({
3339
3512
  findAllContentTypes() {
3340
- const { toContentManagerModel } = getService$1("data-mapper");
3513
+ const { toContentManagerModel } = getService$2("data-mapper");
3341
3514
  return Object.values(strapi2.contentTypes).map(toContentManagerModel);
3342
3515
  },
3343
3516
  findContentType(uid2) {
3344
- const { toContentManagerModel } = getService$1("data-mapper");
3517
+ const { toContentManagerModel } = getService$2("data-mapper");
3345
3518
  const contentType = strapi2.contentTypes[uid2];
3346
3519
  return fp.isNil(contentType) ? contentType : toContentManagerModel(contentType);
3347
3520
  },
@@ -3370,7 +3543,7 @@ const service = ({ strapi: strapi2 }) => ({
3370
3543
  return this.findConfiguration(contentType);
3371
3544
  },
3372
3545
  findComponentsConfigurations(contentType) {
3373
- return getService$1("components").findComponentsConfigurations(contentType);
3546
+ return getService$2("components").findComponentsConfigurations(contentType);
3374
3547
  },
3375
3548
  syncConfigurations() {
3376
3549
  return configurationService.syncConfigurations();
@@ -3642,7 +3815,7 @@ const permission = ({ strapi: strapi2 }) => ({
3642
3815
  return userAbility.can(action);
3643
3816
  },
3644
3817
  async registerPermissions() {
3645
- const displayedContentTypes = getService$1("content-types").findDisplayedContentTypes();
3818
+ const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
3646
3819
  const contentTypesUids = displayedContentTypes.map(fp.prop("uid"));
3647
3820
  const actions = [
3648
3821
  {
@@ -3918,7 +4091,7 @@ const getQueryPopulate = async (uid2, query) => {
3918
4091
  return populateQuery;
3919
4092
  };
3920
4093
  const buildDeepPopulate = (uid2) => {
3921
- return getService$1("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
4094
+ return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
3922
4095
  };
3923
4096
  const populateBuilder = (uid2) => {
3924
4097
  let getInitialPopulate = async () => {
@@ -4461,7 +4634,8 @@ const services = {
4461
4634
  permission,
4462
4635
  "populate-builder": populateBuilder$1,
4463
4636
  uid,
4464
- ...history.services ? history.services : {}
4637
+ ...history.services ? history.services : {},
4638
+ ...preview.services ? preview.services : {}
4465
4639
  };
4466
4640
  const index = () => {
4467
4641
  return {