@strapi/content-manager 0.0.0-experimental.dd3311938ac827f1fa8560c8840a9a394f5896c0 → 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4
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.
- package/LICENSE +18 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js → ComponentConfigurationPage-5ukroXAh.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js.map → ComponentConfigurationPage-5ukroXAh.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs → ComponentConfigurationPage-BAgyHiMm.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs.map → ComponentConfigurationPage-BAgyHiMm.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs → EditConfigurationPage-DmoXawIh.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs.map → EditConfigurationPage-DmoXawIh.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js → EditConfigurationPage-Xp7lun0f.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js.map → EditConfigurationPage-Xp7lun0f.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DWb0DE7R.mjs → EditViewPage-BLsjc5F-.mjs} +46 -46
- package/dist/_chunks/EditViewPage-BLsjc5F-.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-CTTDHKkQ.js → EditViewPage-C-ukDOB7.js} +45 -45
- package/dist/_chunks/EditViewPage-C-ukDOB7.js.map +1 -0
- package/dist/_chunks/{Field-C5Z1Ivdv.js → Field-Bfph5SOd.js} +421 -141
- package/dist/_chunks/Field-Bfph5SOd.js.map +1 -0
- package/dist/_chunks/{Field-DnStdvQw.mjs → Field-Cs7duwWd.mjs} +422 -142
- package/dist/_chunks/Field-Cs7duwWd.mjs.map +1 -0
- package/dist/_chunks/{Form-B81OtW-k.js → Form-CPYqIWDG.js} +25 -26
- package/dist/_chunks/Form-CPYqIWDG.js.map +1 -0
- package/dist/_chunks/{Form-DqGgE55Q.mjs → Form-Dg_GS5TQ.mjs} +27 -28
- package/dist/_chunks/Form-Dg_GS5TQ.mjs.map +1 -0
- package/dist/_chunks/{History-4NbOq2dX.js → History-DNQkXANT.js} +51 -28
- package/dist/_chunks/History-DNQkXANT.js.map +1 -0
- package/dist/_chunks/{History-DS6-HCYX.mjs → History-wrnHqf09.mjs} +52 -29
- package/dist/_chunks/History-wrnHqf09.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CpfstlYY.js → ListConfigurationPage-CUQxfpjT.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-CUQxfpjT.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DQJJltko.mjs → ListConfigurationPage-DScmJVkW.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-DScmJVkW.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CA3I75m5.js → ListViewPage-BsLiH2-2.js} +59 -67
- package/dist/_chunks/ListViewPage-BsLiH2-2.js.map +1 -0
- package/dist/_chunks/{ListViewPage-nQrOQuVo.mjs → ListViewPage-C4IvrMgY.mjs} +60 -68
- package/dist/_chunks/ListViewPage-C4IvrMgY.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js → NoContentTypePage-BZ-PnGAf.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js.map → NoContentTypePage-BZ-PnGAf.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs → NoContentTypePage-Djg8nPlj.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs.map → NoContentTypePage-Djg8nPlj.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs → NoPermissionsPage-DSP7R-hv.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs.map → NoPermissionsPage-DSP7R-hv.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js → NoPermissionsPage-_lUqjGW3.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js.map → NoPermissionsPage-_lUqjGW3.js.map} +1 -1
- package/dist/_chunks/{Relations-BDRl99Ux.mjs → Relations-BZr8tL0R.mjs} +3 -3
- package/dist/_chunks/Relations-BZr8tL0R.mjs.map +1 -0
- package/dist/_chunks/{Relations-DG2jnOcr.js → Relations-CtELXYIK.js} +3 -3
- package/dist/_chunks/Relations-CtELXYIK.js.map +1 -0
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-BrCTWlZv.mjs} +5 -4
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
- package/dist/_chunks/{en-fbKQxLGn.js → en-uOUIxfcQ.js} +5 -4
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-uOUIxfcQ.js.map} +1 -1
- package/dist/_chunks/{index-BZoNZMXL.js → index-OerGjbAN.js} +365 -375
- package/dist/_chunks/index-OerGjbAN.js.map +1 -0
- package/dist/_chunks/{index-Drt2DN7v.mjs → index-c_5DdJi-.mjs} +380 -390
- package/dist/_chunks/index-c_5DdJi-.mjs.map +1 -0
- package/dist/_chunks/{layout-DEYBqgF1.js → layout-Ci7qHlFb.js} +7 -7
- package/dist/_chunks/layout-Ci7qHlFb.js.map +1 -0
- package/dist/_chunks/{layout-BzAbmoO6.mjs → layout-oPBiO7RY.mjs} +8 -8
- package/dist/_chunks/layout-oPBiO7RY.mjs.map +1 -0
- package/dist/_chunks/{relations-D26zVRdi.mjs → relations-BIdWFjdq.mjs} +2 -2
- package/dist/_chunks/{relations-D26zVRdi.mjs.map → relations-BIdWFjdq.mjs.map} +1 -1
- package/dist/_chunks/{relations-D0eZ4VWw.js → relations-COBpStiF.js} +2 -2
- package/dist/_chunks/{relations-D0eZ4VWw.js.map → relations-COBpStiF.js.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/server/index.js +41 -34
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +41 -34
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/_chunks/EditViewPage-CTTDHKkQ.js.map +0 -1
- package/dist/_chunks/EditViewPage-DWb0DE7R.mjs.map +0 -1
- package/dist/_chunks/Field-C5Z1Ivdv.js.map +0 -1
- package/dist/_chunks/Field-DnStdvQw.mjs.map +0 -1
- package/dist/_chunks/Form-B81OtW-k.js.map +0 -1
- package/dist/_chunks/Form-DqGgE55Q.mjs.map +0 -1
- package/dist/_chunks/History-4NbOq2dX.js.map +0 -1
- package/dist/_chunks/History-DS6-HCYX.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CpfstlYY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DQJJltko.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-CA3I75m5.js.map +0 -1
- package/dist/_chunks/ListViewPage-nQrOQuVo.mjs.map +0 -1
- package/dist/_chunks/Relations-BDRl99Ux.mjs.map +0 -1
- package/dist/_chunks/Relations-DG2jnOcr.js.map +0 -1
- package/dist/_chunks/index-BZoNZMXL.js.map +0 -1
- package/dist/_chunks/index-Drt2DN7v.mjs.map +0 -1
- package/dist/_chunks/layout-BzAbmoO6.mjs.map +0 -1
- package/dist/_chunks/layout-DEYBqgF1.js.map +0 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import {
|
2
|
+
import { ButtonProps } from '@strapi/design-system';
|
3
|
+
import { DialogOptions, ModalOptions, NotificationOptions } from '../../../EditView/components/DocumentActions';
|
3
4
|
import type { BulkActionComponent } from '../../../../content-manager';
|
4
5
|
interface BulkActionDescription {
|
5
6
|
dialog?: DialogOptions | NotificationOptions | ModalOptions;
|
@@ -14,35 +15,7 @@ interface BulkActionDescription {
|
|
14
15
|
/**
|
15
16
|
* @default 'secondary'
|
16
17
|
*/
|
17
|
-
variant?: '
|
18
|
-
}
|
19
|
-
interface DialogOptions {
|
20
|
-
type: 'dialog';
|
21
|
-
title: string;
|
22
|
-
content?: React.ReactNode;
|
23
|
-
onConfirm?: () => void | Promise<void>;
|
24
|
-
onCancel?: () => void | Promise<void>;
|
25
|
-
}
|
26
|
-
interface NotificationOptions {
|
27
|
-
type: 'notification';
|
28
|
-
title: string;
|
29
|
-
link?: {
|
30
|
-
label: string;
|
31
|
-
url: string;
|
32
|
-
target?: string;
|
33
|
-
};
|
34
|
-
content?: string;
|
35
|
-
onClose?: () => void;
|
36
|
-
status?: NotificationConfig['type'];
|
37
|
-
timeout?: number;
|
38
|
-
}
|
39
|
-
interface ModalOptions {
|
40
|
-
type: 'modal';
|
41
|
-
title: string;
|
42
|
-
content: React.ComponentType<{
|
43
|
-
onClose: () => void;
|
44
|
-
}>;
|
45
|
-
onClose?: () => void;
|
18
|
+
variant?: ButtonProps['variant'];
|
46
19
|
}
|
47
20
|
declare const BulkActionsRenderer: () => import("react/jsx-runtime").JSX.Element;
|
48
21
|
declare const Emphasis: (chunks: React.ReactNode) => import("react/jsx-runtime").JSX.Element;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
|
3
|
-
|
2
|
+
interface ConfirmBulkActionDialogProps {
|
3
|
+
endAction: React.ReactNode;
|
4
4
|
onToggleDialog: () => void;
|
5
5
|
isOpen?: boolean;
|
6
6
|
dialogBody: React.ReactNode;
|
package/dist/server/index.js
CHANGED
@@ -232,6 +232,10 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
232
232
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
233
233
|
switch (attribute.type) {
|
234
234
|
case "relation": {
|
235
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
236
|
+
if (isMorphRelation) {
|
237
|
+
break;
|
238
|
+
}
|
235
239
|
const isVisible2 = strapiUtils.contentTypes.isVisibleAttribute(model, attributeName);
|
236
240
|
if (isVisible2) {
|
237
241
|
acc[attributeName] = { fields: ["documentId", "locale", "publishedAt"] };
|
@@ -495,8 +499,6 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
495
499
|
deleteExpiredJob: null,
|
496
500
|
isInitialized: false
|
497
501
|
};
|
498
|
-
const query = strapi2.db.query(HISTORY_VERSION_UID);
|
499
|
-
const historyService = getService(strapi2, "history");
|
500
502
|
const serviceUtils = createServiceUtils({ strapi: strapi2 });
|
501
503
|
return {
|
502
504
|
async bootstrap() {
|
@@ -552,7 +554,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
552
554
|
}, {});
|
553
555
|
await strapi2.db.transaction(async ({ onCommit }) => {
|
554
556
|
onCommit(() => {
|
555
|
-
|
557
|
+
getService(strapi2, "history").createVersion({
|
556
558
|
contentType: contentTypeUid,
|
557
559
|
data: fp.omit(FIELDS_TO_IGNORE, document),
|
558
560
|
schema: fp.omit(FIELDS_TO_IGNORE, attributesSchema),
|
@@ -568,7 +570,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
568
570
|
state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
|
569
571
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
570
572
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
571
|
-
query.deleteMany({
|
573
|
+
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
572
574
|
where: {
|
573
575
|
created_at: {
|
574
576
|
$lt: expirationDate.toISOString()
|
@@ -1593,9 +1595,11 @@ const multipleLocaleSchema = strapiUtils.yup.lazy(
|
|
1593
1595
|
(value) => Array.isArray(value) ? strapiUtils.yup.array().of(singleLocaleSchema.required()) : singleLocaleSchema
|
1594
1596
|
);
|
1595
1597
|
const statusSchema = strapiUtils.yup.mixed().oneOf(["draft", "published"], "Invalid status");
|
1596
|
-
const getDocumentLocaleAndStatus = async (request, opts = { allowMultipleLocales: false }) => {
|
1598
|
+
const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultipleLocales: false }) => {
|
1597
1599
|
const { allowMultipleLocales } = opts;
|
1598
|
-
const { locale, status, ...rest } = request || {};
|
1600
|
+
const { locale, status: providedStatus, ...rest } = request || {};
|
1601
|
+
const defaultStatus = strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(model)) ? void 0 : "published";
|
1602
|
+
const status = providedStatus !== void 0 ? providedStatus : defaultStatus;
|
1599
1603
|
const schema = strapiUtils.yup.object().shape({
|
1600
1604
|
locale: allowMultipleLocales ? multipleLocaleSchema : singleLocaleSchema,
|
1601
1605
|
status: statusSchema
|
@@ -1643,7 +1647,7 @@ const createDocument = async (ctx, opts) => {
|
|
1643
1647
|
const setCreator = strapiUtils.setCreatorFields({ user });
|
1644
1648
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1645
1649
|
const sanitizedBody = await sanitizeFn(body);
|
1646
|
-
const { locale, status
|
1650
|
+
const { locale, status } = await getDocumentLocaleAndStatus(body, model);
|
1647
1651
|
return documentManager2.create(model, {
|
1648
1652
|
data: sanitizedBody,
|
1649
1653
|
locale,
|
@@ -1662,7 +1666,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1662
1666
|
}
|
1663
1667
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1664
1668
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1665
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1669
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1666
1670
|
const [documentVersion, documentExists] = await Promise.all([
|
1667
1671
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
1668
1672
|
documentManager2.exists(model, id)
|
@@ -1700,7 +1704,7 @@ const collectionTypes = {
|
|
1700
1704
|
}
|
1701
1705
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1702
1706
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1703
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
1707
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1704
1708
|
const { results: documents, pagination } = await documentManager2.findPage(
|
1705
1709
|
{ ...permissionQuery, populate, locale, status },
|
1706
1710
|
model
|
@@ -1735,7 +1739,7 @@ const collectionTypes = {
|
|
1735
1739
|
}
|
1736
1740
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1737
1741
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1738
|
-
const { locale, status
|
1742
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1739
1743
|
const version = await documentManager2.findOne(id, model, {
|
1740
1744
|
populate,
|
1741
1745
|
locale,
|
@@ -1802,7 +1806,7 @@ const collectionTypes = {
|
|
1802
1806
|
}
|
1803
1807
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1804
1808
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1805
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1809
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1806
1810
|
const document = await documentManager2.findOne(id, model, {
|
1807
1811
|
populate,
|
1808
1812
|
locale,
|
@@ -1847,7 +1851,7 @@ const collectionTypes = {
|
|
1847
1851
|
}
|
1848
1852
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1849
1853
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1850
|
-
const { locale } = await getDocumentLocaleAndStatus(ctx.query);
|
1854
|
+
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1851
1855
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1852
1856
|
if (documentLocales.length === 0) {
|
1853
1857
|
return ctx.notFound();
|
@@ -1880,7 +1884,7 @@ const collectionTypes = {
|
|
1880
1884
|
if (permissionChecker2.cannot.publish(document)) {
|
1881
1885
|
throw new strapiUtils.errors.ForbiddenError();
|
1882
1886
|
}
|
1883
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1887
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1884
1888
|
const publishResult = await documentManager2.publish(document.documentId, model, {
|
1885
1889
|
locale
|
1886
1890
|
// TODO: Allow setting creator fields on publish
|
@@ -1907,7 +1911,9 @@ const collectionTypes = {
|
|
1907
1911
|
}
|
1908
1912
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1909
1913
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1910
|
-
const { locale } = await getDocumentLocaleAndStatus(body, {
|
1914
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1915
|
+
allowMultipleLocales: true
|
1916
|
+
});
|
1911
1917
|
const entityPromises = documentIds.map(
|
1912
1918
|
(documentId) => documentManager2.findLocales(documentId, model, { populate, locale, isPublished: false })
|
1913
1919
|
);
|
@@ -1934,7 +1940,7 @@ const collectionTypes = {
|
|
1934
1940
|
if (permissionChecker2.cannot.unpublish()) {
|
1935
1941
|
return ctx.forbidden();
|
1936
1942
|
}
|
1937
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1943
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1938
1944
|
const entityPromises = documentIds.map(
|
1939
1945
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1940
1946
|
);
|
@@ -1967,7 +1973,7 @@ const collectionTypes = {
|
|
1967
1973
|
}
|
1968
1974
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
1969
1975
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1970
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1976
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1971
1977
|
const document = await documentManager2.findOne(id, model, {
|
1972
1978
|
populate,
|
1973
1979
|
locale,
|
@@ -2004,7 +2010,7 @@ const collectionTypes = {
|
|
2004
2010
|
}
|
2005
2011
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
2006
2012
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2007
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2013
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2008
2014
|
const document = await documentManager2.findOne(id, model, {
|
2009
2015
|
populate,
|
2010
2016
|
locale,
|
@@ -2035,7 +2041,7 @@ const collectionTypes = {
|
|
2035
2041
|
}
|
2036
2042
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2037
2043
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2038
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2044
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2039
2045
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2040
2046
|
populate,
|
2041
2047
|
locale
|
@@ -2062,7 +2068,7 @@ const collectionTypes = {
|
|
2062
2068
|
}
|
2063
2069
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2064
2070
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2065
|
-
const { locale, status
|
2071
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2066
2072
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2067
2073
|
if (!entity) {
|
2068
2074
|
return ctx.notFound();
|
@@ -2085,7 +2091,7 @@ const collectionTypes = {
|
|
2085
2091
|
if (permissionChecker2.cannot.read()) {
|
2086
2092
|
return ctx.forbidden();
|
2087
2093
|
}
|
2088
|
-
const
|
2094
|
+
const documents = await documentManager2.findMany(
|
2089
2095
|
{
|
2090
2096
|
filters: {
|
2091
2097
|
documentId: ids
|
@@ -2094,7 +2100,7 @@ const collectionTypes = {
|
|
2094
2100
|
},
|
2095
2101
|
model
|
2096
2102
|
);
|
2097
|
-
if (!
|
2103
|
+
if (!documents) {
|
2098
2104
|
return ctx.notFound();
|
2099
2105
|
}
|
2100
2106
|
const number = await documentManager2.countManyEntriesDraftRelations(ids, model, locale);
|
@@ -2590,7 +2596,7 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2590
2596
|
throw new strapiUtils.errors.ForbiddenError();
|
2591
2597
|
}
|
2592
2598
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.update(query);
|
2593
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2599
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2594
2600
|
const [documentVersion, otherDocumentVersion] = await Promise.all([
|
2595
2601
|
findDocument(sanitizedQuery, model, { locale, status: "draft" }),
|
2596
2602
|
// Find the first document to check if it exists
|
@@ -2631,7 +2637,7 @@ const singleTypes = {
|
|
2631
2637
|
return ctx.forbidden();
|
2632
2638
|
}
|
2633
2639
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
2634
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
2640
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
2635
2641
|
const version = await findDocument(permissionQuery, model, { locale, status });
|
2636
2642
|
if (!version) {
|
2637
2643
|
if (permissionChecker2.cannot.create()) {
|
@@ -2676,7 +2682,7 @@ const singleTypes = {
|
|
2676
2682
|
}
|
2677
2683
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2678
2684
|
const populate = await buildPopulateFromQuery(sanitizedQuery, model);
|
2679
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2685
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2680
2686
|
const documentLocales = await documentManager2.findLocales(void 0, model, {
|
2681
2687
|
populate,
|
2682
2688
|
locale
|
@@ -2713,7 +2719,7 @@ const singleTypes = {
|
|
2713
2719
|
if (permissionChecker2.cannot.publish(document)) {
|
2714
2720
|
throw new strapiUtils.errors.ForbiddenError();
|
2715
2721
|
}
|
2716
|
-
const { locale } = await getDocumentLocaleAndStatus(document);
|
2722
|
+
const { locale } = await getDocumentLocaleAndStatus(document, model);
|
2717
2723
|
const publishResult = await documentManager2.publish(document.documentId, model, { locale });
|
2718
2724
|
return publishResult.at(0);
|
2719
2725
|
});
|
@@ -2736,7 +2742,7 @@ const singleTypes = {
|
|
2736
2742
|
return ctx.forbidden();
|
2737
2743
|
}
|
2738
2744
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.unpublish(query);
|
2739
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2745
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2740
2746
|
const document = await findDocument(sanitizedQuery, model, { locale });
|
2741
2747
|
if (!document) {
|
2742
2748
|
return ctx.notFound();
|
@@ -2768,7 +2774,7 @@ const singleTypes = {
|
|
2768
2774
|
return ctx.forbidden();
|
2769
2775
|
}
|
2770
2776
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.discard(query);
|
2771
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2777
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2772
2778
|
const document = await findDocument(sanitizedQuery, model, { locale, status: "published" });
|
2773
2779
|
if (!document) {
|
2774
2780
|
return ctx.notFound();
|
@@ -2788,7 +2794,7 @@ const singleTypes = {
|
|
2788
2794
|
const { query } = ctx.request;
|
2789
2795
|
const documentManager2 = getService$1("document-manager");
|
2790
2796
|
const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
|
2791
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2797
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2792
2798
|
if (permissionChecker2.cannot.read()) {
|
2793
2799
|
return ctx.forbidden();
|
2794
2800
|
}
|
@@ -2809,7 +2815,7 @@ const uid$1 = {
|
|
2809
2815
|
async generateUID(ctx) {
|
2810
2816
|
const { contentTypeUID, field, data } = await validateGenerateUIDInput(ctx.request.body);
|
2811
2817
|
const { query = {} } = ctx.request;
|
2812
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2818
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2813
2819
|
await validateUIDField(contentTypeUID, field);
|
2814
2820
|
const uidService = getService$1("uid");
|
2815
2821
|
ctx.body = {
|
@@ -2821,7 +2827,7 @@ const uid$1 = {
|
|
2821
2827
|
ctx.request.body
|
2822
2828
|
);
|
2823
2829
|
const { query = {} } = ctx.request;
|
2824
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2830
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2825
2831
|
await validateUIDField(contentTypeUID, field);
|
2826
2832
|
const uidService = getService$1("uid");
|
2827
2833
|
const isAvailable = await uidService.checkUIDAvailability({
|
@@ -3746,6 +3752,10 @@ const getDeepPopulateDraftCount = (uid2) => {
|
|
3746
3752
|
const attribute = model.attributes[attributeName];
|
3747
3753
|
switch (attribute.type) {
|
3748
3754
|
case "relation": {
|
3755
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
3756
|
+
if (isMorphRelation) {
|
3757
|
+
break;
|
3758
|
+
}
|
3749
3759
|
if (isVisibleAttribute$1(model, attributeName)) {
|
3750
3760
|
populateAcc[attributeName] = {
|
3751
3761
|
count: true,
|
@@ -4231,10 +4241,7 @@ const documentManager = ({ strapi: strapi2 }) => {
|
|
4231
4241
|
async clone(id, body, uid2) {
|
4232
4242
|
const populate = await buildDeepPopulate(uid2);
|
4233
4243
|
const params = {
|
4234
|
-
data:
|
4235
|
-
...omitIdField(body),
|
4236
|
-
[PUBLISHED_AT_ATTRIBUTE]: null
|
4237
|
-
},
|
4244
|
+
data: omitIdField(body),
|
4238
4245
|
populate
|
4239
4246
|
};
|
4240
4247
|
return strapi2.documents(uid2).clone({ ...params, documentId: id }).then((result) => result?.entries.at(0));
|