@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
@@ -7,10 +7,10 @@ import isNil from "lodash/isNil";
7
7
  import _, { intersection as intersection$1, difference as difference$1 } from "lodash";
8
8
  import qs from "qs";
9
9
  import slugify from "@sindresorhus/slugify";
10
- const getService$1 = (name) => {
10
+ const getService$2 = (name) => {
11
11
  return strapi.plugin("content-manager").service(name);
12
12
  };
13
- function getService(strapi2, name) {
13
+ function getService$1(strapi2, name) {
14
14
  return strapi2.service(`plugin::content-manager.${name}`);
15
15
  }
16
16
  const historyRestoreVersionSchema = yup.object().shape({
@@ -46,7 +46,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
46
46
  if (!isSingleType && (!contentTypeUid || !ctx.query.documentId)) {
47
47
  throw new errors.ForbiddenError("contentType and documentId are required");
48
48
  }
49
- const permissionChecker2 = getService$1("permission-checker").create({
49
+ const permissionChecker2 = getService$2("permission-checker").create({
50
50
  userAbility: ctx.state.userAbility,
51
51
  model: ctx.query.contentType
52
52
  });
@@ -54,7 +54,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
54
54
  return ctx.forbidden();
55
55
  }
56
56
  const query = await permissionChecker2.sanitizeQuery(ctx.query);
57
- const { results, pagination: pagination2 } = await getService(strapi2, "history").findVersionsPage({
57
+ const { results, pagination: pagination2 } = await getService$1(strapi2, "history").findVersionsPage({
58
58
  query: {
59
59
  ...query,
60
60
  ...getValidPagination({ page: query.page, pageSize: query.pageSize })
@@ -79,14 +79,14 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
79
79
  async restoreVersion(ctx) {
80
80
  const request = ctx.request;
81
81
  await validateRestoreVersion(request.body, "contentType is required");
82
- const permissionChecker2 = getService$1("permission-checker").create({
82
+ const permissionChecker2 = getService$2("permission-checker").create({
83
83
  userAbility: ctx.state.userAbility,
84
84
  model: request.body.contentType
85
85
  });
86
86
  if (permissionChecker2.cannot.update()) {
87
87
  throw new errors.ForbiddenError();
88
88
  }
89
- const restoredDocument = await getService(strapi2, "history").restoreVersion(
89
+ const restoredDocument = await getService$1(strapi2, "history").restoreVersion(
90
90
  request.params.versionId
91
91
  );
92
92
  return {
@@ -95,7 +95,7 @@ const createHistoryVersionController = ({ strapi: strapi2 }) => {
95
95
  }
96
96
  };
97
97
  };
98
- const controllers$1 = {
98
+ const controllers$2 = {
99
99
  "history-version": createHistoryVersionController
100
100
  /**
101
101
  * Casting is needed because the types aren't aware that Strapi supports
@@ -202,6 +202,17 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
202
202
  const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
203
203
  return documentMetadataService.getStatus(document, meta.availableStatus);
204
204
  };
205
+ const getComponentFields = (componentUID) => {
206
+ return Object.entries(strapi2.getModel(componentUID).attributes).reduce(
207
+ (fieldsAcc, [key, attribute]) => {
208
+ if (!["relation", "media", "component", "dynamiczone"].includes(attribute.type)) {
209
+ fieldsAcc.push(key);
210
+ }
211
+ return fieldsAcc;
212
+ },
213
+ []
214
+ );
215
+ };
205
216
  const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
206
217
  const model = strapi2.getModel(uid2);
207
218
  const attributes = Object.entries(model.attributes);
@@ -225,13 +236,19 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
225
236
  }
226
237
  case "component": {
227
238
  const populate = getDeepPopulate2(attribute.component);
228
- acc[attributeName] = { populate };
239
+ acc[attributeName] = {
240
+ populate,
241
+ [fieldSelector]: getComponentFields(attribute.component)
242
+ };
229
243
  break;
230
244
  }
231
245
  case "dynamiczone": {
232
246
  const populatedComponents = (attribute.components || []).reduce(
233
247
  (acc2, componentUID) => {
234
- acc2[componentUID] = { populate: getDeepPopulate2(componentUID) };
248
+ acc2[componentUID] = {
249
+ populate: getDeepPopulate2(componentUID),
250
+ [fieldSelector]: getComponentFields(componentUID)
251
+ };
235
252
  return acc2;
236
253
  },
237
254
  {}
@@ -344,7 +361,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
344
361
  const attributeValue = entry.data[attributeKey];
345
362
  const attributeValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];
346
363
  if (attributeSchema.type === "media") {
347
- const permissionChecker2 = getService$1("permission-checker").create({
364
+ const permissionChecker2 = getService$2("permission-checker").create({
348
365
  userAbility: params.state.userAbility,
349
366
  model: "plugin::upload.file"
350
367
  });
@@ -385,7 +402,7 @@ const createHistoryService = ({ strapi: strapi2 }) => {
385
402
  [attributeKey]: adminUsers
386
403
  };
387
404
  }
388
- const permissionChecker2 = getService$1("permission-checker").create({
405
+ const permissionChecker2 = getService$2("permission-checker").create({
389
406
  userAbility: params.state.userAbility,
390
407
  model: attributeSchema.target
391
408
  });
@@ -561,7 +578,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
561
578
  onCommit(async () => {
562
579
  for (const entry of localeEntries) {
563
580
  const status = await serviceUtils.getVersionStatus(uid2, entry);
564
- await getService(strapi2, "history").createVersion({
581
+ await getService$1(strapi2, "history").createVersion({
565
582
  contentType: uid2,
566
583
  data: omit(FIELDS_TO_IGNORE, entry),
567
584
  relatedDocumentId: documentId,
@@ -574,15 +591,19 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
574
591
  });
575
592
  return result;
576
593
  });
577
- state.deleteExpiredJob = scheduleJob("0 0 * * *", () => {
594
+ state.deleteExpiredJob = scheduleJob("historyDaily", "0 0 * * *", () => {
578
595
  const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
579
596
  const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
580
597
  strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
581
598
  where: {
582
599
  created_at: {
583
- $lt: expirationDate.toISOString()
600
+ $lt: expirationDate
584
601
  }
585
602
  }
603
+ }).catch((error) => {
604
+ if (error instanceof Error) {
605
+ strapi2.log.error("Error deleting expired history versions", error.message);
606
+ }
586
607
  });
587
608
  });
588
609
  state.isInitialized = true;
@@ -594,17 +615,17 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
594
615
  }
595
616
  };
596
617
  };
597
- const services$1 = {
618
+ const services$2 = {
598
619
  history: createHistoryService,
599
620
  lifecycles: createLifecyclesService
600
621
  };
601
- const info = { pluginName: "content-manager", type: "admin" };
622
+ const info$1 = { pluginName: "content-manager", type: "admin" };
602
623
  const historyVersionRouter = {
603
624
  type: "admin",
604
625
  routes: [
605
626
  {
606
627
  method: "GET",
607
- info,
628
+ info: info$1,
608
629
  path: "/history-versions",
609
630
  handler: "history-version.findMany",
610
631
  config: {
@@ -613,7 +634,7 @@ const historyVersionRouter = {
613
634
  },
614
635
  {
615
636
  method: "PUT",
616
- info,
637
+ info: info$1,
617
638
  path: "/history-versions/:versionId/restore",
618
639
  handler: "history-version.restoreVersion",
619
640
  config: {
@@ -622,7 +643,7 @@ const historyVersionRouter = {
622
643
  }
623
644
  ]
624
645
  };
625
- const routes$1 = {
646
+ const routes$2 = {
626
647
  "history-version": historyVersionRouter
627
648
  };
628
649
  const historyVersion = {
@@ -669,21 +690,21 @@ const historyVersion = {
669
690
  }
670
691
  }
671
692
  };
672
- const getFeature = () => {
693
+ const getFeature$1 = () => {
673
694
  if (strapi.ee.features.isEnabled("cms-content-history")) {
674
695
  return {
675
696
  register({ strapi: strapi2 }) {
676
697
  strapi2.get("models").add(historyVersion);
677
698
  },
678
699
  bootstrap({ strapi: strapi2 }) {
679
- getService(strapi2, "lifecycles").bootstrap();
700
+ getService$1(strapi2, "lifecycles").bootstrap();
680
701
  },
681
702
  destroy({ strapi: strapi2 }) {
682
- getService(strapi2, "lifecycles").destroy();
703
+ getService$1(strapi2, "lifecycles").destroy();
683
704
  },
684
- controllers: controllers$1,
685
- services: services$1,
686
- routes: routes$1
705
+ controllers: controllers$2,
706
+ services: services$2,
707
+ routes: routes$2
687
708
  };
688
709
  }
689
710
  return {
@@ -692,7 +713,7 @@ const getFeature = () => {
692
713
  }
693
714
  };
694
715
  };
695
- const history = getFeature();
716
+ const history = getFeature$1();
696
717
  const register = async ({ strapi: strapi2 }) => {
697
718
  await history.register?.({ strapi: strapi2 });
698
719
  };
@@ -700,15 +721,165 @@ const ALLOWED_WEBHOOK_EVENTS = {
700
721
  ENTRY_PUBLISH: "entry.publish",
701
722
  ENTRY_UNPUBLISH: "entry.unpublish"
702
723
  };
724
+ const FEATURE_ID = "preview";
725
+ const info = { pluginName: "content-manager", type: "admin" };
726
+ const previewRouter = {
727
+ type: "admin",
728
+ routes: [
729
+ {
730
+ method: "GET",
731
+ info,
732
+ path: "/preview/url/:contentType",
733
+ handler: "preview.getPreviewUrl",
734
+ config: {
735
+ policies: ["admin::isAuthenticatedAdmin"]
736
+ }
737
+ }
738
+ ]
739
+ };
740
+ const routes$1 = {
741
+ preview: previewRouter
742
+ };
743
+ function getService(strapi2, name) {
744
+ return strapi2.service(`plugin::content-manager.${name}`);
745
+ }
746
+ const getPreviewUrlSchema = yup.object().shape({
747
+ // Will be undefined for single types
748
+ documentId: yup.string(),
749
+ locale: yup.string().nullable(),
750
+ status: yup.string()
751
+ }).required();
752
+ const validatePreviewUrl = async (strapi2, uid2, params) => {
753
+ await validateYupSchema(getPreviewUrlSchema)(params);
754
+ const newParams = pick(["documentId", "locale", "status"], params);
755
+ const model = strapi2.getModel(uid2);
756
+ if (!model || model.modelType !== "contentType") {
757
+ throw new errors.ValidationError("Invalid content type");
758
+ }
759
+ const isSingleType = model?.kind === "singleType";
760
+ if (!isSingleType && !params.documentId) {
761
+ throw new errors.ValidationError("documentId is required for Collection Types");
762
+ }
763
+ if (isSingleType) {
764
+ const doc = await strapi2.documents(uid2).findFirst();
765
+ if (!doc) {
766
+ throw new errors.NotFoundError("Document not found");
767
+ }
768
+ newParams.documentId = doc?.documentId;
769
+ }
770
+ return newParams;
771
+ };
772
+ const createPreviewController = () => {
773
+ return {
774
+ /**
775
+ * Transforms an entry into a preview URL, so that it can be previewed
776
+ * in the Content Manager.
777
+ */
778
+ async getPreviewUrl(ctx) {
779
+ const uid2 = ctx.params.contentType;
780
+ const query = ctx.request.query;
781
+ const params = await validatePreviewUrl(strapi, uid2, query);
782
+ const previewService = getService(strapi, "preview");
783
+ const url = await previewService.getPreviewUrl(uid2, params);
784
+ if (!url) {
785
+ ctx.status = 204;
786
+ }
787
+ return {
788
+ data: { url }
789
+ };
790
+ }
791
+ };
792
+ };
793
+ const controllers$1 = {
794
+ preview: createPreviewController
795
+ /**
796
+ * Casting is needed because the types aren't aware that Strapi supports
797
+ * passing a controller factory as the value, instead of a controller object directly
798
+ */
799
+ };
800
+ const createPreviewService = ({ strapi: strapi2 }) => {
801
+ const config = getService(strapi2, "preview-config");
802
+ return {
803
+ async getPreviewUrl(uid2, params) {
804
+ const handler = config.getPreviewHandler();
805
+ try {
806
+ return handler(uid2, params);
807
+ } catch (error) {
808
+ strapi2.log.error(`Failed to get preview URL: ${error}`);
809
+ throw new errors.ApplicationError("Failed to get preview URL");
810
+ }
811
+ return;
812
+ }
813
+ };
814
+ };
815
+ const createPreviewConfigService = ({ strapi: strapi2 }) => {
816
+ return {
817
+ isEnabled() {
818
+ const config = strapi2.config.get("admin.preview");
819
+ if (!config) {
820
+ return false;
821
+ }
822
+ return config?.enabled ?? true;
823
+ },
824
+ /**
825
+ * Validate if the configuration is valid
826
+ */
827
+ validate() {
828
+ if (!this.isEnabled()) {
829
+ return;
830
+ }
831
+ const handler = this.getPreviewHandler();
832
+ if (typeof handler !== "function") {
833
+ throw new errors.ValidationError(
834
+ "Preview configuration is invalid. Handler must be a function"
835
+ );
836
+ }
837
+ },
838
+ /**
839
+ * Utility to get the preview handler from the configuration
840
+ */
841
+ getPreviewHandler() {
842
+ const config = strapi2.config.get("admin.preview");
843
+ const emptyHandler = () => {
844
+ return void 0;
845
+ };
846
+ if (!this.isEnabled()) {
847
+ return emptyHandler;
848
+ }
849
+ return config?.config?.handler || emptyHandler;
850
+ }
851
+ };
852
+ };
853
+ const services$1 = {
854
+ preview: createPreviewService,
855
+ "preview-config": createPreviewConfigService
856
+ };
857
+ const getFeature = () => {
858
+ if (!strapi.features.future.isEnabled(FEATURE_ID)) {
859
+ return {};
860
+ }
861
+ return {
862
+ bootstrap() {
863
+ console.log("Bootstrapping preview server");
864
+ const config = getService(strapi, "preview-config");
865
+ config.validate();
866
+ },
867
+ routes: routes$1,
868
+ controllers: controllers$1,
869
+ services: services$1
870
+ };
871
+ };
872
+ const preview = getFeature();
703
873
  const bootstrap = async () => {
704
874
  Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
705
875
  strapi.get("webhookStore").addAllowedEvent(key, value);
706
876
  });
707
- getService$1("field-sizes").setCustomFieldInputSizes();
708
- await getService$1("components").syncConfigurations();
709
- await getService$1("content-types").syncConfigurations();
710
- await getService$1("permission").registerPermissions();
877
+ getService$2("field-sizes").setCustomFieldInputSizes();
878
+ await getService$2("components").syncConfigurations();
879
+ await getService$2("content-types").syncConfigurations();
880
+ await getService$2("permission").registerPermissions();
711
881
  await history.bootstrap?.({ strapi });
882
+ await preview.bootstrap?.({ strapi });
712
883
  };
713
884
  const destroy = async ({ strapi: strapi2 }) => {
714
885
  await history.destroy?.({ strapi: strapi2 });
@@ -1198,7 +1369,8 @@ const admin = {
1198
1369
  };
1199
1370
  const routes = {
1200
1371
  admin,
1201
- ...history.routes ? history.routes : {}
1372
+ ...history.routes ? history.routes : {},
1373
+ ...preview.routes ? preview.routes : {}
1202
1374
  };
1203
1375
  const hasPermissionsSchema = yup$1.object({
1204
1376
  actions: yup$1.array().of(yup$1.string()),
@@ -1455,7 +1627,7 @@ const createMetadasSchema = (schema) => {
1455
1627
  if (!value) {
1456
1628
  return yup$1.string();
1457
1629
  }
1458
- const targetSchema = getService$1("content-types").findContentType(
1630
+ const targetSchema = getService$2("content-types").findContentType(
1459
1631
  schema.attributes[key].targetModel
1460
1632
  );
1461
1633
  if (!targetSchema) {
@@ -1624,7 +1796,7 @@ const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultiple
1624
1796
  }
1625
1797
  };
1626
1798
  const formatDocumentWithMetadata = async (permissionChecker2, uid2, document, opts = {}) => {
1627
- const documentMetadata2 = getService$1("document-metadata");
1799
+ const documentMetadata2 = getService$2("document-metadata");
1628
1800
  const serviceOutput = await documentMetadata2.formatDocumentWithMetadata(uid2, document, opts);
1629
1801
  let {
1630
1802
  meta: { availableLocales, availableStatus }
@@ -1650,8 +1822,8 @@ const createDocument = async (ctx, opts) => {
1650
1822
  const { userAbility, user } = ctx.state;
1651
1823
  const { model } = ctx.params;
1652
1824
  const { body } = ctx.request;
1653
- const documentManager2 = getService$1("document-manager");
1654
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1825
+ const documentManager2 = getService$2("document-manager");
1826
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1655
1827
  if (permissionChecker2.cannot.create()) {
1656
1828
  throw new errors.ForbiddenError();
1657
1829
  }
@@ -1671,13 +1843,13 @@ const updateDocument = async (ctx, opts) => {
1671
1843
  const { userAbility, user } = ctx.state;
1672
1844
  const { id, model } = ctx.params;
1673
1845
  const { body } = ctx.request;
1674
- const documentManager2 = getService$1("document-manager");
1675
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1846
+ const documentManager2 = getService$2("document-manager");
1847
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1676
1848
  if (permissionChecker2.cannot.update()) {
1677
1849
  throw new errors.ForbiddenError();
1678
1850
  }
1679
1851
  const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
1680
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
1852
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1681
1853
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1682
1854
  const [documentVersion, documentExists] = await Promise.all([
1683
1855
  documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
@@ -1708,14 +1880,14 @@ const collectionTypes = {
1708
1880
  const { userAbility } = ctx.state;
1709
1881
  const { model } = ctx.params;
1710
1882
  const { query } = ctx.request;
1711
- const documentMetadata2 = getService$1("document-metadata");
1712
- const documentManager2 = getService$1("document-manager");
1713
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1883
+ const documentMetadata2 = getService$2("document-metadata");
1884
+ const documentManager2 = getService$2("document-manager");
1885
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1714
1886
  if (permissionChecker2.cannot.read()) {
1715
1887
  return ctx.forbidden();
1716
1888
  }
1717
1889
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
1718
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1890
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
1719
1891
  const { locale, status } = await getDocumentLocaleAndStatus(query, model);
1720
1892
  const { results: documents, pagination: pagination2 } = await documentManager2.findPage(
1721
1893
  { ...permissionQuery, populate, locale, status },
@@ -1744,13 +1916,13 @@ const collectionTypes = {
1744
1916
  async findOne(ctx) {
1745
1917
  const { userAbility } = ctx.state;
1746
1918
  const { model, id } = ctx.params;
1747
- const documentManager2 = getService$1("document-manager");
1748
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1919
+ const documentManager2 = getService$2("document-manager");
1920
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1749
1921
  if (permissionChecker2.cannot.read()) {
1750
1922
  return ctx.forbidden();
1751
1923
  }
1752
1924
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
1753
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1925
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1754
1926
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
1755
1927
  const version = await documentManager2.findOne(id, model, {
1756
1928
  populate,
@@ -1781,7 +1953,7 @@ const collectionTypes = {
1781
1953
  async create(ctx) {
1782
1954
  const { userAbility } = ctx.state;
1783
1955
  const { model } = ctx.params;
1784
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1956
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1785
1957
  const [totalEntries, document] = await Promise.all([
1786
1958
  strapi.db.query(model).count(),
1787
1959
  createDocument(ctx)
@@ -1802,7 +1974,7 @@ const collectionTypes = {
1802
1974
  async update(ctx) {
1803
1975
  const { userAbility } = ctx.state;
1804
1976
  const { model } = ctx.params;
1805
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1977
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1806
1978
  const updatedVersion = await updateDocument(ctx);
1807
1979
  const sanitizedVersion = await permissionChecker2.sanitizeOutput(updatedVersion);
1808
1980
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedVersion);
@@ -1811,13 +1983,13 @@ const collectionTypes = {
1811
1983
  const { userAbility, user } = ctx.state;
1812
1984
  const { model, sourceId: id } = ctx.params;
1813
1985
  const { body } = ctx.request;
1814
- const documentManager2 = getService$1("document-manager");
1815
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
1986
+ const documentManager2 = getService$2("document-manager");
1987
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1816
1988
  if (permissionChecker2.cannot.create()) {
1817
1989
  return ctx.forbidden();
1818
1990
  }
1819
1991
  const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
1820
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
1992
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1821
1993
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1822
1994
  const document = await documentManager2.findOne(id, model, {
1823
1995
  populate,
@@ -1856,13 +2028,13 @@ const collectionTypes = {
1856
2028
  async delete(ctx) {
1857
2029
  const { userAbility } = ctx.state;
1858
2030
  const { id, model } = ctx.params;
1859
- const documentManager2 = getService$1("document-manager");
1860
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2031
+ const documentManager2 = getService$2("document-manager");
2032
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1861
2033
  if (permissionChecker2.cannot.delete()) {
1862
2034
  return ctx.forbidden();
1863
2035
  }
1864
2036
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
1865
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2037
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
1866
2038
  const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
1867
2039
  const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
1868
2040
  if (documentLocales.length === 0) {
@@ -1884,14 +2056,14 @@ const collectionTypes = {
1884
2056
  const { userAbility } = ctx.state;
1885
2057
  const { id, model } = ctx.params;
1886
2058
  const { body } = ctx.request;
1887
- const documentManager2 = getService$1("document-manager");
1888
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2059
+ const documentManager2 = getService$2("document-manager");
2060
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1889
2061
  if (permissionChecker2.cannot.publish()) {
1890
2062
  return ctx.forbidden();
1891
2063
  }
1892
2064
  const publishedDocument = await strapi.db.transaction(async () => {
1893
2065
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1894
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2066
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1895
2067
  let document;
1896
2068
  const { locale } = await getDocumentLocaleAndStatus(body, model);
1897
2069
  const isCreate = isNil$1(id);
@@ -1939,13 +2111,13 @@ const collectionTypes = {
1939
2111
  const { body } = ctx.request;
1940
2112
  const { documentIds } = body;
1941
2113
  await validateBulkActionInput(body);
1942
- const documentManager2 = getService$1("document-manager");
1943
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2114
+ const documentManager2 = getService$2("document-manager");
2115
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1944
2116
  if (permissionChecker2.cannot.publish()) {
1945
2117
  return ctx.forbidden();
1946
2118
  }
1947
2119
  const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
1948
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
2120
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
1949
2121
  const { locale } = await getDocumentLocaleAndStatus(body, model, {
1950
2122
  allowMultipleLocales: true
1951
2123
  });
@@ -1970,8 +2142,8 @@ const collectionTypes = {
1970
2142
  const { body } = ctx.request;
1971
2143
  const { documentIds } = body;
1972
2144
  await validateBulkActionInput(body);
1973
- const documentManager2 = getService$1("document-manager");
1974
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2145
+ const documentManager2 = getService$2("document-manager");
2146
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
1975
2147
  if (permissionChecker2.cannot.unpublish()) {
1976
2148
  return ctx.forbidden();
1977
2149
  }
@@ -2000,8 +2172,8 @@ const collectionTypes = {
2000
2172
  const {
2001
2173
  body: { discardDraft, ...body }
2002
2174
  } = ctx.request;
2003
- const documentManager2 = getService$1("document-manager");
2004
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2175
+ const documentManager2 = getService$2("document-manager");
2176
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2005
2177
  if (permissionChecker2.cannot.unpublish()) {
2006
2178
  return ctx.forbidden();
2007
2179
  }
@@ -2009,7 +2181,7 @@ const collectionTypes = {
2009
2181
  return ctx.forbidden();
2010
2182
  }
2011
2183
  const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
2012
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2184
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2013
2185
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2014
2186
  const document = await documentManager2.findOne(id, model, {
2015
2187
  populate,
@@ -2040,13 +2212,13 @@ const collectionTypes = {
2040
2212
  const { userAbility } = ctx.state;
2041
2213
  const { id, model } = ctx.params;
2042
2214
  const { body } = ctx.request;
2043
- const documentManager2 = getService$1("document-manager");
2044
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2215
+ const documentManager2 = getService$2("document-manager");
2216
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2045
2217
  if (permissionChecker2.cannot.discard()) {
2046
2218
  return ctx.forbidden();
2047
2219
  }
2048
2220
  const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
2049
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2221
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2050
2222
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2051
2223
  const document = await documentManager2.findOne(id, model, {
2052
2224
  populate,
@@ -2071,13 +2243,13 @@ const collectionTypes = {
2071
2243
  const { query, body } = ctx.request;
2072
2244
  const { documentIds } = body;
2073
2245
  await validateBulkActionInput(body);
2074
- const documentManager2 = getService$1("document-manager");
2075
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2246
+ const documentManager2 = getService$2("document-manager");
2247
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2076
2248
  if (permissionChecker2.cannot.delete()) {
2077
2249
  return ctx.forbidden();
2078
2250
  }
2079
2251
  const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
2080
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2252
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2081
2253
  const { locale } = await getDocumentLocaleAndStatus(body, model);
2082
2254
  const documentLocales = await documentManager2.findLocales(documentIds, model, {
2083
2255
  populate,
@@ -2098,13 +2270,13 @@ const collectionTypes = {
2098
2270
  async countDraftRelations(ctx) {
2099
2271
  const { userAbility } = ctx.state;
2100
2272
  const { model, id } = ctx.params;
2101
- const documentManager2 = getService$1("document-manager");
2102
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2273
+ const documentManager2 = getService$2("document-manager");
2274
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2103
2275
  if (permissionChecker2.cannot.read()) {
2104
2276
  return ctx.forbidden();
2105
2277
  }
2106
2278
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2107
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2279
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2108
2280
  const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
2109
2281
  const entity = await documentManager2.findOne(id, model, { populate, locale, status });
2110
2282
  if (!entity) {
@@ -2123,8 +2295,8 @@ const collectionTypes = {
2123
2295
  const ids = ctx.request.query.documentIds;
2124
2296
  const locale = ctx.request.query.locale;
2125
2297
  const { model } = ctx.params;
2126
- const documentManager2 = getService$1("document-manager");
2127
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2298
+ const documentManager2 = getService$2("document-manager");
2299
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2128
2300
  if (permissionChecker2.cannot.read()) {
2129
2301
  return ctx.forbidden();
2130
2302
  }
@@ -2148,13 +2320,13 @@ const collectionTypes = {
2148
2320
  };
2149
2321
  const components$1 = {
2150
2322
  findComponents(ctx) {
2151
- const components2 = getService$1("components").findAllComponents();
2152
- const { toDto } = getService$1("data-mapper");
2323
+ const components2 = getService$2("components").findAllComponents();
2324
+ const { toDto } = getService$2("data-mapper");
2153
2325
  ctx.body = { data: components2.map(toDto) };
2154
2326
  },
2155
2327
  async findComponentConfiguration(ctx) {
2156
2328
  const { uid: uid2 } = ctx.params;
2157
- const componentService = getService$1("components");
2329
+ const componentService = getService$2("components");
2158
2330
  const component = componentService.findComponent(uid2);
2159
2331
  if (!component) {
2160
2332
  return ctx.notFound("component.notFound");
@@ -2171,7 +2343,7 @@ const components$1 = {
2171
2343
  async updateComponentConfiguration(ctx) {
2172
2344
  const { uid: uid2 } = ctx.params;
2173
2345
  const { body } = ctx.request;
2174
- const componentService = getService$1("components");
2346
+ const componentService = getService$2("components");
2175
2347
  const component = componentService.findComponent(uid2);
2176
2348
  if (!component) {
2177
2349
  return ctx.notFound("component.notFound");
@@ -2205,12 +2377,12 @@ const contentTypes = {
2205
2377
  } catch (error) {
2206
2378
  return ctx.send({ error }, 400);
2207
2379
  }
2208
- const contentTypes2 = getService$1("content-types").findContentTypesByKind(kind);
2209
- const { toDto } = getService$1("data-mapper");
2380
+ const contentTypes2 = getService$2("content-types").findContentTypesByKind(kind);
2381
+ const { toDto } = getService$2("data-mapper");
2210
2382
  ctx.body = { data: contentTypes2.map(toDto) };
2211
2383
  },
2212
2384
  async findContentTypesSettings(ctx) {
2213
- const { findAllContentTypes, findConfiguration } = getService$1("content-types");
2385
+ const { findAllContentTypes, findConfiguration } = getService$2("content-types");
2214
2386
  const contentTypes2 = await findAllContentTypes();
2215
2387
  const configurations = await Promise.all(
2216
2388
  contentTypes2.map(async (contentType) => {
@@ -2224,7 +2396,7 @@ const contentTypes = {
2224
2396
  },
2225
2397
  async findContentTypeConfiguration(ctx) {
2226
2398
  const { uid: uid2 } = ctx.params;
2227
- const contentTypeService = getService$1("content-types");
2399
+ const contentTypeService = getService$2("content-types");
2228
2400
  const contentType = await contentTypeService.findContentType(uid2);
2229
2401
  if (!contentType) {
2230
2402
  return ctx.notFound("contentType.notFound");
@@ -2246,13 +2418,13 @@ const contentTypes = {
2246
2418
  const { userAbility } = ctx.state;
2247
2419
  const { uid: uid2 } = ctx.params;
2248
2420
  const { body } = ctx.request;
2249
- const contentTypeService = getService$1("content-types");
2250
- const metricsService = getService$1("metrics");
2421
+ const contentTypeService = getService$2("content-types");
2422
+ const metricsService = getService$2("metrics");
2251
2423
  const contentType = await contentTypeService.findContentType(uid2);
2252
2424
  if (!contentType) {
2253
2425
  return ctx.notFound("contentType.notFound");
2254
2426
  }
2255
- if (!getService$1("permission").canConfigureContentType({ userAbility, contentType })) {
2427
+ if (!getService$2("permission").canConfigureContentType({ userAbility, contentType })) {
2256
2428
  return ctx.forbidden();
2257
2429
  }
2258
2430
  let input;
@@ -2285,10 +2457,10 @@ const contentTypes = {
2285
2457
  };
2286
2458
  const init = {
2287
2459
  getInitData(ctx) {
2288
- const { toDto } = getService$1("data-mapper");
2289
- const { findAllComponents } = getService$1("components");
2290
- const { getAllFieldSizes } = getService$1("field-sizes");
2291
- const { findAllContentTypes } = getService$1("content-types");
2460
+ const { toDto } = getService$2("data-mapper");
2461
+ const { findAllComponents } = getService$2("components");
2462
+ const { getAllFieldSizes } = getService$2("field-sizes");
2463
+ const { findAllContentTypes } = getService$2("content-types");
2292
2464
  ctx.body = {
2293
2465
  data: {
2294
2466
  fieldSizes: getAllFieldSizes(),
@@ -2324,7 +2496,7 @@ const addFiltersClause = (params, filtersClause) => {
2324
2496
  params.filters.$and.push(filtersClause);
2325
2497
  };
2326
2498
  const sanitizeMainField = (model, mainField, userAbility) => {
2327
- const permissionChecker2 = getService$1("permission-checker").create({
2499
+ const permissionChecker2 = getService$2("permission-checker").create({
2328
2500
  userAbility,
2329
2501
  model: model.uid
2330
2502
  });
@@ -2342,7 +2514,7 @@ const addStatusToRelations = async (targetUid, relations2) => {
2342
2514
  if (!contentTypes$1.hasDraftAndPublish(strapi.getModel(targetUid))) {
2343
2515
  return relations2;
2344
2516
  }
2345
- const documentMetadata2 = getService$1("document-metadata");
2517
+ const documentMetadata2 = getService$2("document-metadata");
2346
2518
  if (!relations2.length) {
2347
2519
  return relations2;
2348
2520
  }
@@ -2420,7 +2592,7 @@ const relations = {
2420
2592
  ctx.request?.query?.locale
2421
2593
  );
2422
2594
  const { status } = validateStatus(sourceUid, ctx.request?.query?.status);
2423
- const permissionChecker2 = getService$1("permission-checker").create({
2595
+ const permissionChecker2 = getService$2("permission-checker").create({
2424
2596
  userAbility,
2425
2597
  model
2426
2598
  });
@@ -2445,7 +2617,7 @@ const relations = {
2445
2617
  where.id = id;
2446
2618
  }
2447
2619
  const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
2448
- const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
2620
+ const populate = await getService$2("populate-builder")(model).populateFromQuery(permissionQuery).build();
2449
2621
  const currentEntity = await strapi.db.query(model).findOne({
2450
2622
  where,
2451
2623
  populate
@@ -2460,7 +2632,7 @@ const relations = {
2460
2632
  }
2461
2633
  entryId = currentEntity.id;
2462
2634
  }
2463
- const modelConfig = isComponent2 ? await getService$1("components").findConfiguration(sourceSchema) : await getService$1("content-types").findConfiguration(sourceSchema);
2635
+ const modelConfig = isComponent2 ? await getService$2("components").findConfiguration(sourceSchema) : await getService$2("content-types").findConfiguration(sourceSchema);
2464
2636
  const targetSchema = strapi.getModel(targetUid);
2465
2637
  const mainField = flow(
2466
2638
  prop(`metadatas.${targetField}.edit.mainField`),
@@ -2514,7 +2686,7 @@ const relations = {
2514
2686
  }
2515
2687
  } = await this.extractAndValidateRequestInfo(ctx, id);
2516
2688
  const { idsToOmit, idsToInclude, _q, ...query } = ctx.request.query;
2517
- const permissionChecker2 = getService$1("permission-checker").create({
2689
+ const permissionChecker2 = getService$2("permission-checker").create({
2518
2690
  userAbility: ctx.state.userAbility,
2519
2691
  model: targetUid
2520
2692
  });
@@ -2593,7 +2765,7 @@ const relations = {
2593
2765
  } = await this.extractAndValidateRequestInfo(ctx, id);
2594
2766
  const { uid: sourceUid } = sourceSchema;
2595
2767
  const { uid: targetUid } = targetSchema;
2596
- const permissionQuery = await getService$1("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2768
+ const permissionQuery = await getService$2("permission-checker").create({ userAbility, model: targetUid }).sanitizedQuery.read({ fields: fieldsToSelect });
2597
2769
  const dbQuery = strapi.db.query(sourceUid);
2598
2770
  const loadRelations = relations$1.isAnyToMany(attribute) ? (...args) => dbQuery.loadPages(...args) : (...args) => dbQuery.load(...args).then((res2) => ({ results: res2 ? [res2] : [] }));
2599
2771
  const filters = {};
@@ -2634,10 +2806,10 @@ const relations = {
2634
2806
  }
2635
2807
  };
2636
2808
  const buildPopulateFromQuery = async (query, model) => {
2637
- return getService$1("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2809
+ return getService$2("populate-builder")(model).populateFromQuery(query).populateDeep(Infinity).countRelations().build();
2638
2810
  };
2639
2811
  const findDocument = async (query, uid2, opts = {}) => {
2640
- const documentManager2 = getService$1("document-manager");
2812
+ const documentManager2 = getService$2("document-manager");
2641
2813
  const populate = await buildPopulateFromQuery(query, uid2);
2642
2814
  return documentManager2.findMany({ ...opts, populate }, uid2).then((documents) => documents[0]);
2643
2815
  };
@@ -2645,8 +2817,8 @@ const createOrUpdateDocument = async (ctx, opts) => {
2645
2817
  const { user, userAbility } = ctx.state;
2646
2818
  const { model } = ctx.params;
2647
2819
  const { body, query } = ctx.request;
2648
- const documentManager2 = getService$1("document-manager");
2649
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2820
+ const documentManager2 = getService$2("document-manager");
2821
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2650
2822
  if (permissionChecker2.cannot.create() && permissionChecker2.cannot.update()) {
2651
2823
  throw new errors.ForbiddenError();
2652
2824
  }
@@ -2687,7 +2859,7 @@ const singleTypes = {
2687
2859
  const { userAbility } = ctx.state;
2688
2860
  const { model } = ctx.params;
2689
2861
  const { query = {} } = ctx.request;
2690
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2862
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2691
2863
  if (permissionChecker2.cannot.read()) {
2692
2864
  return ctx.forbidden();
2693
2865
  }
@@ -2721,7 +2893,7 @@ const singleTypes = {
2721
2893
  async createOrUpdate(ctx) {
2722
2894
  const { userAbility } = ctx.state;
2723
2895
  const { model } = ctx.params;
2724
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2896
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2725
2897
  const document = await createOrUpdateDocument(ctx);
2726
2898
  const sanitizedDocument = await permissionChecker2.sanitizeOutput(document);
2727
2899
  ctx.body = await formatDocumentWithMetadata(permissionChecker2, model, sanitizedDocument);
@@ -2730,8 +2902,8 @@ const singleTypes = {
2730
2902
  const { userAbility } = ctx.state;
2731
2903
  const { model } = ctx.params;
2732
2904
  const { query = {} } = ctx.request;
2733
- const documentManager2 = getService$1("document-manager");
2734
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2905
+ const documentManager2 = getService$2("document-manager");
2906
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2735
2907
  if (permissionChecker2.cannot.delete()) {
2736
2908
  return ctx.forbidden();
2737
2909
  }
@@ -2759,8 +2931,8 @@ const singleTypes = {
2759
2931
  const { userAbility } = ctx.state;
2760
2932
  const { model } = ctx.params;
2761
2933
  const { query = {} } = ctx.request;
2762
- const documentManager2 = getService$1("document-manager");
2763
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2934
+ const documentManager2 = getService$2("document-manager");
2935
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2764
2936
  if (permissionChecker2.cannot.publish()) {
2765
2937
  return ctx.forbidden();
2766
2938
  }
@@ -2788,8 +2960,8 @@ const singleTypes = {
2788
2960
  body: { discardDraft, ...body },
2789
2961
  query = {}
2790
2962
  } = ctx.request;
2791
- const documentManager2 = getService$1("document-manager");
2792
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2963
+ const documentManager2 = getService$2("document-manager");
2964
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2793
2965
  if (permissionChecker2.cannot.unpublish()) {
2794
2966
  return ctx.forbidden();
2795
2967
  }
@@ -2823,8 +2995,8 @@ const singleTypes = {
2823
2995
  const { userAbility } = ctx.state;
2824
2996
  const { model } = ctx.params;
2825
2997
  const { body, query = {} } = ctx.request;
2826
- const documentManager2 = getService$1("document-manager");
2827
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
2998
+ const documentManager2 = getService$2("document-manager");
2999
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2828
3000
  if (permissionChecker2.cannot.discard()) {
2829
3001
  return ctx.forbidden();
2830
3002
  }
@@ -2847,8 +3019,8 @@ const singleTypes = {
2847
3019
  const { userAbility } = ctx.state;
2848
3020
  const { model } = ctx.params;
2849
3021
  const { query } = ctx.request;
2850
- const documentManager2 = getService$1("document-manager");
2851
- const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
3022
+ const documentManager2 = getService$2("document-manager");
3023
+ const permissionChecker2 = getService$2("permission-checker").create({ userAbility, model });
2852
3024
  const { locale } = await getDocumentLocaleAndStatus(query, model);
2853
3025
  if (permissionChecker2.cannot.read()) {
2854
3026
  return ctx.forbidden();
@@ -2872,7 +3044,7 @@ const uid$1 = {
2872
3044
  const { query = {} } = ctx.request;
2873
3045
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2874
3046
  await validateUIDField(contentTypeUID, field);
2875
- const uidService = getService$1("uid");
3047
+ const uidService = getService$2("uid");
2876
3048
  ctx.body = {
2877
3049
  data: await uidService.generateUIDField({ contentTypeUID, field, data, locale })
2878
3050
  };
@@ -2884,7 +3056,7 @@ const uid$1 = {
2884
3056
  const { query = {} } = ctx.request;
2885
3057
  const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
2886
3058
  await validateUIDField(contentTypeUID, field);
2887
- const uidService = getService$1("uid");
3059
+ const uidService = getService$2("uid");
2888
3060
  const isAvailable = await uidService.checkUIDAvailability({
2889
3061
  contentTypeUID,
2890
3062
  field,
@@ -2905,7 +3077,8 @@ const controllers = {
2905
3077
  relations,
2906
3078
  "single-types": singleTypes,
2907
3079
  uid: uid$1,
2908
- ...history.controllers ? history.controllers : {}
3080
+ ...history.controllers ? history.controllers : {},
3081
+ ...preview.controllers ? preview.controllers : {}
2909
3082
  };
2910
3083
  const keys = {
2911
3084
  CONFIGURATION: "configuration"
@@ -3056,12 +3229,12 @@ async function syncMetadatas(configuration, schema) {
3056
3229
  return _.assign(metasWithDefaults, updatedMetas);
3057
3230
  }
3058
3231
  const getTargetSchema = (targetModel) => {
3059
- return getService$1("content-types").findContentType(targetModel);
3232
+ return getService$2("content-types").findContentType(targetModel);
3060
3233
  };
3061
3234
  const DEFAULT_LIST_LENGTH = 4;
3062
3235
  const MAX_ROW_SIZE = 12;
3063
3236
  const isAllowedFieldSize = (type, size) => {
3064
- const { getFieldSize } = getService$1("field-sizes");
3237
+ const { getFieldSize } = getService$2("field-sizes");
3065
3238
  const fieldSize = getFieldSize(type);
3066
3239
  if (!fieldSize.isResizable && size !== fieldSize.default) {
3067
3240
  return false;
@@ -3069,7 +3242,7 @@ const isAllowedFieldSize = (type, size) => {
3069
3242
  return size <= MAX_ROW_SIZE;
3070
3243
  };
3071
3244
  const getDefaultFieldSize = (attribute) => {
3072
- const { hasFieldSize, getFieldSize } = getService$1("field-sizes");
3245
+ const { hasFieldSize, getFieldSize } = getService$2("field-sizes");
3073
3246
  return getFieldSize(hasFieldSize(attribute.customField) ? attribute.customField : attribute.type).default;
3074
3247
  };
3075
3248
  async function createDefaultLayouts(schema) {
@@ -3104,7 +3277,7 @@ function syncLayouts(configuration, schema) {
3104
3277
  for (const el of row) {
3105
3278
  if (!hasEditableAttribute(schema, el.name))
3106
3279
  continue;
3107
- const { hasFieldSize } = getService$1("field-sizes");
3280
+ const { hasFieldSize } = getService$2("field-sizes");
3108
3281
  const fieldType = hasFieldSize(schema.attributes[el.name].customField) ? schema.attributes[el.name].customField : schema.attributes[el.name].type;
3109
3282
  if (!isAllowedFieldSize(fieldType, el.size)) {
3110
3283
  elementsToReAppend.push(el.name);
@@ -3244,17 +3417,17 @@ const configurationService$1 = createConfigurationService({
3244
3417
  isComponent: true,
3245
3418
  prefix: STORE_KEY_PREFIX,
3246
3419
  getModels() {
3247
- const { toContentManagerModel } = getService$1("data-mapper");
3420
+ const { toContentManagerModel } = getService$2("data-mapper");
3248
3421
  return mapValues(toContentManagerModel, strapi.components);
3249
3422
  }
3250
3423
  });
3251
3424
  const components = ({ strapi: strapi2 }) => ({
3252
3425
  findAllComponents() {
3253
- const { toContentManagerModel } = getService$1("data-mapper");
3426
+ const { toContentManagerModel } = getService$2("data-mapper");
3254
3427
  return Object.values(strapi2.components).map(toContentManagerModel);
3255
3428
  },
3256
3429
  findComponent(uid2) {
3257
- const { toContentManagerModel } = getService$1("data-mapper");
3430
+ const { toContentManagerModel } = getService$2("data-mapper");
3258
3431
  const component = strapi2.components[uid2];
3259
3432
  return isNil$1(component) ? component : toContentManagerModel(component);
3260
3433
  },
@@ -3305,17 +3478,17 @@ const configurationService = createConfigurationService({
3305
3478
  storeUtils,
3306
3479
  prefix: "content_types",
3307
3480
  getModels() {
3308
- const { toContentManagerModel } = getService$1("data-mapper");
3481
+ const { toContentManagerModel } = getService$2("data-mapper");
3309
3482
  return mapValues(toContentManagerModel, strapi.contentTypes);
3310
3483
  }
3311
3484
  });
3312
3485
  const service = ({ strapi: strapi2 }) => ({
3313
3486
  findAllContentTypes() {
3314
- const { toContentManagerModel } = getService$1("data-mapper");
3487
+ const { toContentManagerModel } = getService$2("data-mapper");
3315
3488
  return Object.values(strapi2.contentTypes).map(toContentManagerModel);
3316
3489
  },
3317
3490
  findContentType(uid2) {
3318
- const { toContentManagerModel } = getService$1("data-mapper");
3491
+ const { toContentManagerModel } = getService$2("data-mapper");
3319
3492
  const contentType = strapi2.contentTypes[uid2];
3320
3493
  return isNil$1(contentType) ? contentType : toContentManagerModel(contentType);
3321
3494
  },
@@ -3344,7 +3517,7 @@ const service = ({ strapi: strapi2 }) => ({
3344
3517
  return this.findConfiguration(contentType);
3345
3518
  },
3346
3519
  findComponentsConfigurations(contentType) {
3347
- return getService$1("components").findComponentsConfigurations(contentType);
3520
+ return getService$2("components").findComponentsConfigurations(contentType);
3348
3521
  },
3349
3522
  syncConfigurations() {
3350
3523
  return configurationService.syncConfigurations();
@@ -3616,7 +3789,7 @@ const permission = ({ strapi: strapi2 }) => ({
3616
3789
  return userAbility.can(action);
3617
3790
  },
3618
3791
  async registerPermissions() {
3619
- const displayedContentTypes = getService$1("content-types").findDisplayedContentTypes();
3792
+ const displayedContentTypes = getService$2("content-types").findDisplayedContentTypes();
3620
3793
  const contentTypesUids = displayedContentTypes.map(prop("uid"));
3621
3794
  const actions = [
3622
3795
  {
@@ -3892,7 +4065,7 @@ const getQueryPopulate = async (uid2, query) => {
3892
4065
  return populateQuery;
3893
4066
  };
3894
4067
  const buildDeepPopulate = (uid2) => {
3895
- return getService$1("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
4068
+ return getService$2("populate-builder")(uid2).populateDeep(Infinity).countRelations().build();
3896
4069
  };
3897
4070
  const populateBuilder = (uid2) => {
3898
4071
  let getInitialPopulate = async () => {
@@ -4435,7 +4608,8 @@ const services = {
4435
4608
  permission,
4436
4609
  "populate-builder": populateBuilder$1,
4437
4610
  uid,
4438
- ...history.services ? history.services : {}
4611
+ ...history.services ? history.services : {},
4612
+ ...preview.services ? preview.services : {}
4439
4613
  };
4440
4614
  const index = () => {
4441
4615
  return {