@strapi/content-manager 0.0.0-experimental.3fd705928266d1b836afc8a30fceb35aac0ae2f8 → 0.0.0-experimental.438960f273755509510c3610187d9deb520ba2a0

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 (96) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js → ComponentConfigurationPage-3feZ0gyp.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js.map → ComponentConfigurationPage-3feZ0gyp.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs → ComponentConfigurationPage-DkUdgHD9.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs.map → ComponentConfigurationPage-DkUdgHD9.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js → EditConfigurationPage-B0KA-x9U.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js.map → EditConfigurationPage-B0KA-x9U.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs → EditConfigurationPage-Ox5wFgpq.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs.map → EditConfigurationPage-Ox5wFgpq.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-G9uNzwYL.js → EditViewPage-OMv9CogC.js} +15 -5
  10. package/dist/_chunks/EditViewPage-OMv9CogC.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-DeTn7rAF.mjs → EditViewPage-foKE8Al3.mjs} +15 -5
  12. package/dist/_chunks/EditViewPage-foKE8Al3.mjs.map +1 -0
  13. package/dist/_chunks/{Field-CnCKhI1R.mjs → Field-CLqZcnnc.mjs} +69 -25
  14. package/dist/_chunks/Field-CLqZcnnc.mjs.map +1 -0
  15. package/dist/_chunks/{Field-DDHUWEfV.js → Field-u09MCk3G.js} +69 -25
  16. package/dist/_chunks/Field-u09MCk3G.js.map +1 -0
  17. package/dist/_chunks/{Form-DYETaKUX.js → Form-B9c_Ti0q.js} +3 -3
  18. package/dist/_chunks/Form-B9c_Ti0q.js.map +1 -0
  19. package/dist/_chunks/{Form-IvVVwqRL.mjs → Form-CU4hRyJf.mjs} +3 -3
  20. package/dist/_chunks/Form-CU4hRyJf.mjs.map +1 -0
  21. package/dist/_chunks/{History-BMunT-do.mjs → History-BFyFzpSS.mjs} +25 -12
  22. package/dist/_chunks/History-BFyFzpSS.mjs.map +1 -0
  23. package/dist/_chunks/{History-CnZDctSO.js → History-OlickLyX.js} +24 -11
  24. package/dist/_chunks/History-OlickLyX.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-CDqkCxgV.mjs → ListConfigurationPage-Bu5Z_39o.mjs} +2 -2
  26. package/dist/_chunks/{ListConfigurationPage-CDqkCxgV.mjs.map → ListConfigurationPage-Bu5Z_39o.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-BynalOp8.js → ListConfigurationPage-D0AAi_cW.js} +2 -2
  28. package/dist/_chunks/{ListConfigurationPage-BynalOp8.js.map → ListConfigurationPage-D0AAi_cW.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-I88Ouzoq.js → ListViewPage--lV5p8Qi.js} +10 -6
  30. package/dist/_chunks/ListViewPage--lV5p8Qi.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-_5gS-DOF.mjs → ListViewPage-BAHxSPux.mjs} +10 -6
  32. package/dist/_chunks/ListViewPage-BAHxSPux.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs → NoContentTypePage-C6SMXW77.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs.map → NoContentTypePage-C6SMXW77.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js → NoContentTypePage-Dxl9oZqL.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js.map → NoContentTypePage-Dxl9oZqL.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js → NoPermissionsPage-BY1-rMng.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js.map → NoPermissionsPage-BY1-rMng.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs → NoPermissionsPage-o9BXzQeI.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs.map → NoPermissionsPage-o9BXzQeI.mjs.map} +1 -1
  41. package/dist/_chunks/{Relations-Chdt5qWc.mjs → Relations-BAK95JHc.mjs} +32 -23
  42. package/dist/_chunks/Relations-BAK95JHc.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-BPgFQeGj.js → Relations-CHfwGkBG.js} +32 -23
  44. package/dist/_chunks/Relations-CHfwGkBG.js.map +1 -0
  45. package/dist/_chunks/{en-BVzUkPxZ.js → en-Bm0D0IWz.js} +8 -8
  46. package/dist/_chunks/{en-BVzUkPxZ.js.map → en-Bm0D0IWz.js.map} +1 -1
  47. package/dist/_chunks/{en-CPTj6CjC.mjs → en-DKV44jRb.mjs} +8 -8
  48. package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-DKV44jRb.mjs.map} +1 -1
  49. package/dist/_chunks/{index-D4UGPFZC.mjs → index-CxlpxzA5.mjs} +940 -863
  50. package/dist/_chunks/index-CxlpxzA5.mjs.map +1 -0
  51. package/dist/_chunks/{index-BhbLFX4l.js → index-_Mlmsefd.js} +938 -861
  52. package/dist/_chunks/index-_Mlmsefd.js.map +1 -0
  53. package/dist/_chunks/{layout-D4HI4_PS.mjs → layout-Cr0H40au.mjs} +3 -3
  54. package/dist/_chunks/{layout-D4HI4_PS.mjs.map → layout-Cr0H40au.mjs.map} +1 -1
  55. package/dist/_chunks/{layout-CYA7s0qO.js → layout-vcHVgSr1.js} +3 -3
  56. package/dist/_chunks/{layout-CYA7s0qO.js.map → layout-vcHVgSr1.js.map} +1 -1
  57. package/dist/_chunks/{relations-1pXaYpBK.mjs → relations-Dq60voyX.mjs} +2 -2
  58. package/dist/_chunks/{relations-1pXaYpBK.mjs.map → relations-Dq60voyX.mjs.map} +1 -1
  59. package/dist/_chunks/{relations-DDZ9OxNo.js → relations-hXUB80SH.js} +2 -2
  60. package/dist/_chunks/{relations-DDZ9OxNo.js.map → relations-hXUB80SH.js.map} +1 -1
  61. package/dist/admin/index.js +2 -1
  62. package/dist/admin/index.js.map +1 -1
  63. package/dist/admin/index.mjs +3 -2
  64. package/dist/admin/src/exports.d.ts +1 -1
  65. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  66. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  67. package/dist/admin/src/preview/constants.d.ts +1 -0
  68. package/dist/admin/src/preview/index.d.ts +4 -0
  69. package/dist/server/index.js +45 -18
  70. package/dist/server/index.js.map +1 -1
  71. package/dist/server/index.mjs +45 -18
  72. package/dist/server/index.mjs.map +1 -1
  73. package/dist/server/src/bootstrap.d.ts.map +1 -1
  74. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  75. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  76. package/dist/server/src/history/services/history.d.ts.map +1 -1
  77. package/dist/server/src/preview/constants.d.ts +2 -0
  78. package/dist/server/src/preview/constants.d.ts.map +1 -0
  79. package/dist/server/src/preview/index.d.ts +4 -0
  80. package/dist/server/src/preview/index.d.ts.map +1 -0
  81. package/package.json +12 -12
  82. package/dist/_chunks/EditViewPage-DeTn7rAF.mjs.map +0 -1
  83. package/dist/_chunks/EditViewPage-G9uNzwYL.js.map +0 -1
  84. package/dist/_chunks/Field-CnCKhI1R.mjs.map +0 -1
  85. package/dist/_chunks/Field-DDHUWEfV.js.map +0 -1
  86. package/dist/_chunks/Form-DYETaKUX.js.map +0 -1
  87. package/dist/_chunks/Form-IvVVwqRL.mjs.map +0 -1
  88. package/dist/_chunks/History-BMunT-do.mjs.map +0 -1
  89. package/dist/_chunks/History-CnZDctSO.js.map +0 -1
  90. package/dist/_chunks/ListViewPage-I88Ouzoq.js.map +0 -1
  91. package/dist/_chunks/ListViewPage-_5gS-DOF.mjs.map +0 -1
  92. package/dist/_chunks/Relations-BPgFQeGj.js.map +0 -1
  93. package/dist/_chunks/Relations-Chdt5qWc.mjs.map +0 -1
  94. package/dist/_chunks/index-BhbLFX4l.js.map +0 -1
  95. package/dist/_chunks/index-D4UGPFZC.mjs.map +0 -1
  96. package/strapi-server.js +0 -3
@@ -31,7 +31,9 @@ type UseDocument = (args: UseDocumentArgs, opts?: UseDocumentOpts) => {
31
31
  * This is the schema of the content type, it is not the same as the layout.
32
32
  */
33
33
  schema?: Schema;
34
+ schemas?: Schema[];
34
35
  validate: (document: Document) => null | FormErrors;
36
+ hasError?: boolean;
35
37
  };
36
38
  /**
37
39
  * @alpha
@@ -78,10 +80,39 @@ declare const useDoc: () => {
78
80
  * This is the schema of the content type, it is not the same as the layout.
79
81
  */
80
82
  schema?: ContentType | undefined;
83
+ schemas?: ContentType[] | undefined;
81
84
  validate: (document: Document) => null | FormErrors;
85
+ hasError?: boolean | undefined;
82
86
  collectionType: string;
83
87
  model: string;
84
88
  id: string | undefined;
85
89
  };
86
- export { useDocument, useDoc };
90
+ /**
91
+ * @public
92
+ * @experimental
93
+ * Content manager context hooks for plugin development.
94
+ * Make sure to use this hook inside the content manager.
95
+ */
96
+ declare const useContentManagerContext: () => {
97
+ error: import("@reduxjs/toolkit").SerializedError | import("../utils/api").BaseQueryError | undefined;
98
+ isLoading: boolean;
99
+ model: string;
100
+ collectionType: string;
101
+ id: string | undefined;
102
+ slug: string;
103
+ isCreatingEntry: boolean;
104
+ isSingleType: boolean;
105
+ hasDraftAndPublish: boolean;
106
+ components: ComponentsDictionary;
107
+ contentType: ContentType | undefined;
108
+ contentTypes: ContentType[] | undefined;
109
+ form: import("@strapi/admin/strapi-admin").FormContextValue<import("@strapi/admin/strapi-admin").FormValues>;
110
+ layout: {
111
+ error?: import("@reduxjs/toolkit").SerializedError | import("../utils/api").BaseQueryError | undefined;
112
+ isLoading: boolean;
113
+ edit: import("./useDocumentLayout").EditLayout;
114
+ list: import("./useDocumentLayout").ListLayout;
115
+ };
116
+ };
117
+ export { useDocument, useDoc, useContentManagerContext };
87
118
  export type { UseDocument, UseDocumentArgs, Document, Schema, ComponentsDictionary };
@@ -28,6 +28,7 @@ interface HeaderActionDescription {
28
28
  }>;
29
29
  onSelect?: (value: string) => void;
30
30
  value?: string;
31
+ customizeContent?: (value: string) => React.ReactNode;
31
32
  }
32
33
  declare const DEFAULT_HEADER_ACTIONS: DocumentActionComponent[];
33
34
  export { Header, DEFAULT_HEADER_ACTIONS };
@@ -0,0 +1 @@
1
+ export declare const FEATURE_ID = "preview";
@@ -0,0 +1,4 @@
1
+ declare const previewAdmin: {
2
+ bootstrap(app: Pick<import("@strapi/admin/strapi-admin").StrapiApp, "getPlugin" | "addSettingsLink" | "addSettingsLinks" | "registerHook">): {} | undefined;
3
+ };
4
+ export { previewAdmin };
@@ -393,7 +393,12 @@ const createHistoryService = ({ strapi: strapi2 }) => {
393
393
  if (userToPopulate == null) {
394
394
  return null;
395
395
  }
396
- return strapi2.query("admin::user").findOne({ where: { id: userToPopulate.id } });
396
+ return strapi2.query("admin::user").findOne({
397
+ where: {
398
+ ...userToPopulate.id ? { id: userToPopulate.id } : {},
399
+ ...userToPopulate.documentId ? { documentId: userToPopulate.documentId } : {}
400
+ }
401
+ });
397
402
  })
398
403
  );
399
404
  return {
@@ -690,7 +695,7 @@ const historyVersion = {
690
695
  }
691
696
  }
692
697
  };
693
- const getFeature = () => {
698
+ const getFeature$1 = () => {
694
699
  if (strapi.ee.features.isEnabled("cms-content-history")) {
695
700
  return {
696
701
  register({ strapi: strapi2 }) {
@@ -713,7 +718,7 @@ const getFeature = () => {
713
718
  }
714
719
  };
715
720
  };
716
- const history = getFeature();
721
+ const history = getFeature$1();
717
722
  const register = async ({ strapi: strapi2 }) => {
718
723
  await history.register?.({ strapi: strapi2 });
719
724
  };
@@ -721,6 +726,18 @@ const ALLOWED_WEBHOOK_EVENTS = {
721
726
  ENTRY_PUBLISH: "entry.publish",
722
727
  ENTRY_UNPUBLISH: "entry.unpublish"
723
728
  };
729
+ const FEATURE_ID = "preview";
730
+ const getFeature = () => {
731
+ if (!strapi.features.future.isEnabled(FEATURE_ID)) {
732
+ return {};
733
+ }
734
+ return {
735
+ bootstrap() {
736
+ console.log("Bootstrapping preview server");
737
+ }
738
+ };
739
+ };
740
+ const preview = getFeature();
724
741
  const bootstrap = async () => {
725
742
  Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
726
743
  strapi.get("webhookStore").addAllowedEvent(key, value);
@@ -730,6 +747,7 @@ const bootstrap = async () => {
730
747
  await getService$1("content-types").syncConfigurations();
731
748
  await getService$1("permission").registerPermissions();
732
749
  await history.bootstrap?.({ strapi });
750
+ await preview.bootstrap?.({ strapi });
733
751
  };
734
752
  const destroy = async ({ strapi: strapi2 }) => {
735
753
  await history.destroy?.({ strapi: strapi2 });
@@ -1715,7 +1733,7 @@ const updateDocument = async (ctx, opts) => {
1715
1733
  throw new strapiUtils.errors.ForbiddenError();
1716
1734
  }
1717
1735
  const pickPermittedFields = documentVersion ? permissionChecker2.sanitizeUpdateInput(documentVersion) : permissionChecker2.sanitizeCreateInput;
1718
- const setCreator = strapiUtils.setCreatorFields({ user, isEdition: true });
1736
+ const setCreator = documentVersion ? strapiUtils.setCreatorFields({ user, isEdition: true }) : strapiUtils.setCreatorFields({ user });
1719
1737
  const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
1720
1738
  const sanitizedBody = await sanitizeFn(body);
1721
1739
  return documentManager2.update(documentVersion?.documentId || id, model, {
@@ -1924,11 +1942,17 @@ const collectionTypes = {
1924
1942
  }
1925
1943
  const isUpdate = !isCreate;
1926
1944
  if (isUpdate) {
1927
- document = await documentManager2.findOne(id, model, { populate, locale });
1928
- if (!document) {
1945
+ const documentExists = documentManager2.exists(model, id);
1946
+ if (!documentExists) {
1929
1947
  throw new strapiUtils.errors.NotFoundError("Document not found");
1930
1948
  }
1931
- if (permissionChecker2.can.update(document)) {
1949
+ document = await documentManager2.findOne(id, model, { populate, locale });
1950
+ if (!document) {
1951
+ if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
1952
+ throw new strapiUtils.errors.ForbiddenError();
1953
+ }
1954
+ document = await updateDocument(ctx);
1955
+ } else if (permissionChecker2.can.update(document)) {
1932
1956
  await updateDocument(ctx);
1933
1957
  }
1934
1958
  }
@@ -2382,11 +2406,8 @@ const validateLocale = (sourceUid, targetUid, locale) => {
2382
2406
  const isLocalized = strapi.plugin("i18n").service("content-types").isLocalizedContentType;
2383
2407
  const isSourceLocalized = isLocalized(sourceModel);
2384
2408
  const isTargetLocalized = isLocalized(targetModel);
2385
- let validatedLocale = locale;
2386
- if (!targetModel || !isTargetLocalized)
2387
- validatedLocale = void 0;
2388
2409
  return {
2389
- locale: validatedLocale,
2410
+ locale,
2390
2411
  isSourceLocalized,
2391
2412
  isTargetLocalized
2392
2413
  };
@@ -2489,7 +2510,7 @@ const relations = {
2489
2510
  attribute,
2490
2511
  fieldsToSelect,
2491
2512
  mainField,
2492
- source: { schema: sourceSchema },
2513
+ source: { schema: sourceSchema, isLocalized: isSourceLocalized },
2493
2514
  target: { schema: targetSchema, isLocalized: isTargetLocalized },
2494
2515
  sourceSchema,
2495
2516
  targetSchema,
@@ -2511,7 +2532,8 @@ const relations = {
2511
2532
  fieldsToSelect,
2512
2533
  mainField,
2513
2534
  source: {
2514
- schema: { uid: sourceUid, modelType: sourceModelType }
2535
+ schema: { uid: sourceUid, modelType: sourceModelType },
2536
+ isLocalized: isSourceLocalized
2515
2537
  },
2516
2538
  target: {
2517
2539
  schema: { uid: targetUid },
@@ -2549,12 +2571,16 @@ const relations = {
2549
2571
  } else {
2550
2572
  where.id = id;
2551
2573
  }
2552
- if (status) {
2553
- where[`${alias}.published_at`] = getPublishedAtClause(status, targetUid);
2574
+ const publishedAt = getPublishedAtClause(status, targetUid);
2575
+ if (!fp.isEmpty(publishedAt)) {
2576
+ where[`${alias}.published_at`] = publishedAt;
2554
2577
  }
2555
- if (filterByLocale) {
2578
+ if (isTargetLocalized && locale) {
2556
2579
  where[`${alias}.locale`] = locale;
2557
2580
  }
2581
+ if (isSourceLocalized && locale) {
2582
+ where.locale = locale;
2583
+ }
2558
2584
  if ((idsToInclude?.length ?? 0) !== 0) {
2559
2585
  where[`${alias}.id`].$notIn = idsToInclude;
2560
2586
  }
@@ -2572,7 +2598,8 @@ const relations = {
2572
2598
  id: { $notIn: fp.uniq(idsToOmit) }
2573
2599
  });
2574
2600
  }
2575
- const res = await strapi.db.query(targetUid).findPage(strapi.get("query-params").transform(targetUid, queryParams));
2601
+ const dbQuery = strapi.get("query-params").transform(targetUid, queryParams);
2602
+ const res = await strapi.db.query(targetUid).findPage(dbQuery);
2576
2603
  ctx.body = {
2577
2604
  ...res,
2578
2605
  results: await addStatusToRelations(targetUid, res.results)
@@ -2694,7 +2721,7 @@ const singleTypes = {
2694
2721
  permissionChecker2,
2695
2722
  model,
2696
2723
  // @ts-expect-error - fix types
2697
- { id: document.documentId, locale, publishedAt: null },
2724
+ { documentId: document.documentId, locale, publishedAt: null },
2698
2725
  { availableLocales: true, availableStatus: false }
2699
2726
  );
2700
2727
  ctx.body = { data: {}, meta };