@strapi/content-manager 0.0.0-experimental.c3e9d4b26f9fd3d9eb530b5c11f9baa1d09b13ad → 0.0.0-experimental.cb311d9fcfbd8e441f790aea232f0a39bdd90e16
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-BMajAl1u.mjs → ComponentConfigurationPage-D0dyDTwq.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BMajAl1u.mjs.map → ComponentConfigurationPage-D0dyDTwq.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js → ComponentConfigurationPage-DL1MHO8i.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-y_7iLdmB.js.map → ComponentConfigurationPage-DL1MHO8i.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs → EditConfigurationPage-13b7S5Cq.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CcOoD26O.mjs.map → EditConfigurationPage-13b7S5Cq.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js → EditConfigurationPage-CMaOf-A-.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CPVB8Uqc.js.map → EditConfigurationPage-CMaOf-A-.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-CTTDHKkQ.js → EditViewPage-BSVmMpRd.js} +45 -45
- package/dist/_chunks/EditViewPage-BSVmMpRd.js.map +1 -0
- package/dist/_chunks/{EditViewPage-DWb0DE7R.mjs → EditViewPage-C3tIZ8F5.mjs} +46 -46
- package/dist/_chunks/EditViewPage-C3tIZ8F5.mjs.map +1 -0
- package/dist/_chunks/{Field-DnStdvQw.mjs → Field-BvuT8cGL.mjs} +422 -142
- package/dist/_chunks/Field-BvuT8cGL.mjs.map +1 -0
- package/dist/_chunks/{Field-C5Z1Ivdv.js → Field-DUCVth4C.js} +421 -141
- package/dist/_chunks/Field-DUCVth4C.js.map +1 -0
- package/dist/_chunks/{Form-DqGgE55Q.mjs → Form-BZmDNVr9.mjs} +27 -28
- package/dist/_chunks/Form-BZmDNVr9.mjs.map +1 -0
- package/dist/_chunks/{Form-B81OtW-k.js → Form-Cpl4W1ak.js} +25 -26
- package/dist/_chunks/Form-Cpl4W1ak.js.map +1 -0
- package/dist/_chunks/{History-DS6-HCYX.mjs → History-Cq_Hrzuu.mjs} +52 -29
- package/dist/_chunks/History-Cq_Hrzuu.mjs.map +1 -0
- package/dist/_chunks/{History-4NbOq2dX.js → History-D4U2YISB.js} +51 -28
- package/dist/_chunks/History-D4U2YISB.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CpfstlYY.js → ListConfigurationPage-Bny6CdWe.js} +48 -47
- package/dist/_chunks/ListConfigurationPage-Bny6CdWe.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DQJJltko.mjs → ListConfigurationPage-W-KQHmBv.mjs} +49 -49
- package/dist/_chunks/ListConfigurationPage-W-KQHmBv.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-nQrOQuVo.mjs → ListViewPage-HBBnJa8K.mjs} +67 -70
- package/dist/_chunks/ListViewPage-HBBnJa8K.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CA3I75m5.js → ListViewPage-O8F1pBJo.js} +65 -68
- package/dist/_chunks/ListViewPage-O8F1pBJo.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs → NoContentTypePage-B-gIhHWM.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DbnHE22g.mjs.map → NoContentTypePage-B-gIhHWM.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js → NoContentTypePage-CQWChGPw.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dldu-_Mx.js.map → NoContentTypePage-CQWChGPw.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js → NoPermissionsPage-CY46zxnM.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CO2MK200.js.map → NoPermissionsPage-CY46zxnM.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs → NoPermissionsPage-XhOPl8wx.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-fOIkQM0v.mjs.map → NoPermissionsPage-XhOPl8wx.mjs.map} +1 -1
- package/dist/_chunks/{Relations-DG2jnOcr.js → Relations-C4gGfZRv.js} +3 -3
- package/dist/_chunks/Relations-C4gGfZRv.js.map +1 -0
- package/dist/_chunks/{Relations-BDRl99Ux.mjs → Relations-vFZ6Wasg.mjs} +3 -3
- package/dist/_chunks/Relations-vFZ6Wasg.mjs.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-5EMXLEM_.js} +384 -388
- package/dist/_chunks/index-5EMXLEM_.js.map +1 -0
- package/dist/_chunks/{index-Drt2DN7v.mjs → index-Dpxg3ctD.mjs} +399 -403
- package/dist/_chunks/index-Dpxg3ctD.mjs.map +1 -0
- package/dist/_chunks/{layout-BzAbmoO6.mjs → layout-C0INpKap.mjs} +22 -10
- package/dist/_chunks/layout-C0INpKap.mjs.map +1 -0
- package/dist/_chunks/{layout-DEYBqgF1.js → layout-P3eKO1Qy.js} +20 -8
- package/dist/_chunks/layout-P3eKO1Qy.js.map +1 -0
- package/dist/_chunks/{relations-D0eZ4VWw.js → relations-B1y0K6LE.js} +2 -2
- package/dist/_chunks/{relations-D0eZ4VWw.js.map → relations-B1y0K6LE.js.map} +1 -1
- package/dist/_chunks/{relations-D26zVRdi.mjs → relations-FBRRBWeO.mjs} +2 -2
- package/dist/_chunks/{relations-D26zVRdi.mjs.map → relations-FBRRBWeO.mjs.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 +137 -87
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +138 -88
- 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 +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/document-metadata.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
@@ -41,11 +41,7 @@ export declare const CustomLinkIconButton: import("styled-components").IStyledCo
|
|
41
41
|
variant?: "secondary" | "tertiary" | undefined;
|
42
42
|
withTooltip?: boolean | undefined;
|
43
43
|
}, never>> & Omit<IconButtonComponent, keyof import("react").Component<any, {}, any>>, keyof import("react").Component<any, {}, any>>;
|
44
|
-
export declare const MainButtons: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("styled-components
|
45
|
-
ref?: import("react").RefObject<unknown> | ((instance: unknown) => void) | null | undefined;
|
46
|
-
}, never>, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<"div">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
|
47
|
-
ref?: import("react").RefObject<unknown> | ((instance: unknown) => void) | null | undefined;
|
48
|
-
}, never>> & Omit<import("@strapi/design-system").FlexComponent, keyof import("react").Component<any, {}, any>>, keyof import("react").Component<any, {}, any>>;
|
44
|
+
export declare const MainButtons: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<any, never>> | (import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<any, never>> & Omit<any, keyof import("react").Component<any, {}, any>>);
|
49
45
|
export declare const MoreButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("@strapi/design-system").TransientBoxProps & {
|
50
46
|
children?: import("react").ReactNode;
|
51
47
|
} & import("@strapi/design-system/dist/types").AsProp<"button"> & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
|
@@ -60,11 +56,7 @@ export declare const MoreButton: import("styled-components").IStyledComponent<"w
|
|
60
56
|
variant?: "secondary" | "tertiary" | undefined;
|
61
57
|
withTooltip?: boolean | undefined;
|
62
58
|
}, never>> & Omit<IconButtonComponent, keyof import("react").Component<any, {}, any>>;
|
63
|
-
export declare const IconButtonGroupMargin: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("styled-components
|
64
|
-
ref?: import("react").RefObject<unknown> | ((instance: unknown) => void) | null | undefined;
|
65
|
-
}, never>, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<"div">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
|
66
|
-
ref?: import("react").RefObject<unknown> | ((instance: unknown) => void) | null | undefined;
|
67
|
-
}, never>> & Omit<import("@strapi/design-system").FlexComponent, keyof import("react").Component<any, {}, any>>, keyof import("react").Component<any, {}, any>>;
|
59
|
+
export declare const IconButtonGroupMargin: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<any, never>> | (import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<any, never>> & Omit<any, keyof import("react").Component<any, {}, any>>);
|
68
60
|
export declare const ExpandButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<import("@strapi/design-system").BaseButtonProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
|
69
61
|
ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
|
70
62
|
}, never>> & Omit<(<C extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "button">(props: import("react").PropsWithoutRef<import("@strapi/design-system").BaseButtonProps<C>> & import("react").RefAttributes<unknown>) => import("react").ReactNode), keyof import("react").Component<any, {}, any>>;
|
@@ -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
@@ -226,20 +226,25 @@ const createServiceUtils = ({ strapi: strapi2 }) => {
|
|
226
226
|
const meta = await documentMetadataService.getMetadata(contentTypeUid, document);
|
227
227
|
return documentMetadataService.getStatus(document, meta.availableStatus);
|
228
228
|
};
|
229
|
-
const getDeepPopulate2 = (uid2) => {
|
229
|
+
const getDeepPopulate2 = (uid2, useDatabaseSyntax = false) => {
|
230
230
|
const model = strapi2.getModel(uid2);
|
231
231
|
const attributes = Object.entries(model.attributes);
|
232
|
+
const fieldSelector = useDatabaseSyntax ? "select" : "fields";
|
232
233
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
233
234
|
switch (attribute.type) {
|
234
235
|
case "relation": {
|
236
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
237
|
+
if (isMorphRelation) {
|
238
|
+
break;
|
239
|
+
}
|
235
240
|
const isVisible2 = strapiUtils.contentTypes.isVisibleAttribute(model, attributeName);
|
236
241
|
if (isVisible2) {
|
237
|
-
acc[attributeName] = {
|
242
|
+
acc[attributeName] = { [fieldSelector]: ["documentId", "locale", "publishedAt"] };
|
238
243
|
}
|
239
244
|
break;
|
240
245
|
}
|
241
246
|
case "media": {
|
242
|
-
acc[attributeName] = {
|
247
|
+
acc[attributeName] = { [fieldSelector]: ["id"] };
|
243
248
|
break;
|
244
249
|
}
|
245
250
|
case "component": {
|
@@ -490,13 +495,47 @@ const createHistoryService = ({ strapi: strapi2 }) => {
|
|
490
495
|
}
|
491
496
|
};
|
492
497
|
};
|
498
|
+
const shouldCreateHistoryVersion = (context) => {
|
499
|
+
if (!strapi.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
500
|
+
return false;
|
501
|
+
}
|
502
|
+
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
503
|
+
return false;
|
504
|
+
}
|
505
|
+
if (context.action === "update" && strapi.requestContext.get()?.request.url.endsWith("/actions/publish")) {
|
506
|
+
return false;
|
507
|
+
}
|
508
|
+
if (!context.contentType.uid.startsWith("api::")) {
|
509
|
+
return false;
|
510
|
+
}
|
511
|
+
return true;
|
512
|
+
};
|
513
|
+
const getSchemas = (uid2) => {
|
514
|
+
const attributesSchema = strapi.getModel(uid2).attributes;
|
515
|
+
const componentsSchemas = Object.keys(attributesSchema).reduce(
|
516
|
+
(currentComponentSchemas, key) => {
|
517
|
+
const fieldSchema = attributesSchema[key];
|
518
|
+
if (fieldSchema.type === "component") {
|
519
|
+
const componentSchema = strapi.getModel(fieldSchema.component).attributes;
|
520
|
+
return {
|
521
|
+
...currentComponentSchemas,
|
522
|
+
[fieldSchema.component]: componentSchema
|
523
|
+
};
|
524
|
+
}
|
525
|
+
return currentComponentSchemas;
|
526
|
+
},
|
527
|
+
{}
|
528
|
+
);
|
529
|
+
return {
|
530
|
+
schema: fp.omit(FIELDS_TO_IGNORE, attributesSchema),
|
531
|
+
componentsSchemas
|
532
|
+
};
|
533
|
+
};
|
493
534
|
const createLifecyclesService = ({ strapi: strapi2 }) => {
|
494
535
|
const state = {
|
495
536
|
deleteExpiredJob: null,
|
496
537
|
isInitialized: false
|
497
538
|
};
|
498
|
-
const query = strapi2.db.query(HISTORY_VERSION_UID);
|
499
|
-
const historyService = getService(strapi2, "history");
|
500
539
|
const serviceUtils = createServiceUtils({ strapi: strapi2 });
|
501
540
|
return {
|
502
541
|
async bootstrap() {
|
@@ -504,60 +543,43 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
504
543
|
return;
|
505
544
|
}
|
506
545
|
strapi2.documents.use(async (context, next) => {
|
507
|
-
if (!strapi2.requestContext.get()?.request.url.startsWith("/content-manager")) {
|
508
|
-
return next();
|
509
|
-
}
|
510
|
-
if (context.action !== "create" && context.action !== "update" && context.action !== "clone" && context.action !== "publish" && context.action !== "unpublish" && context.action !== "discardDraft") {
|
511
|
-
return next();
|
512
|
-
}
|
513
|
-
const contentTypeUid = context.contentType.uid;
|
514
|
-
if (!contentTypeUid.startsWith("api::")) {
|
515
|
-
return next();
|
516
|
-
}
|
517
546
|
const result = await next();
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
547
|
+
if (!shouldCreateHistoryVersion(context)) {
|
548
|
+
return result;
|
549
|
+
}
|
550
|
+
const documentId = context.action === "create" || context.action === "clone" ? result.documentId : context.params.documentId;
|
522
551
|
const defaultLocale = await serviceUtils.getDefaultLocale();
|
523
|
-
const
|
524
|
-
if (
|
525
|
-
|
526
|
-
"[Content manager history middleware]: An array of locales was provided, but only a single locale is supported for the findOne operation."
|
527
|
-
);
|
528
|
-
return next();
|
552
|
+
const locales = fp.castArray(context.params?.locale || defaultLocale);
|
553
|
+
if (!locales.length) {
|
554
|
+
return result;
|
529
555
|
}
|
530
|
-
const
|
531
|
-
|
532
|
-
|
533
|
-
|
556
|
+
const uid2 = context.contentType.uid;
|
557
|
+
const schemas = getSchemas(uid2);
|
558
|
+
const localeEntries = await strapi2.db.query(uid2).findMany({
|
559
|
+
where: {
|
560
|
+
documentId,
|
561
|
+
locale: { $in: locales },
|
562
|
+
publishedAt: null
|
563
|
+
},
|
564
|
+
populate: serviceUtils.getDeepPopulate(
|
565
|
+
uid2,
|
566
|
+
true
|
567
|
+
/* use database syntax */
|
568
|
+
)
|
534
569
|
});
|
535
|
-
const status = await serviceUtils.getVersionStatus(contentTypeUid, document);
|
536
|
-
const attributesSchema = strapi2.getModel(contentTypeUid).attributes;
|
537
|
-
const componentsSchemas = Object.keys(
|
538
|
-
attributesSchema
|
539
|
-
).reduce((currentComponentSchemas, key) => {
|
540
|
-
const fieldSchema = attributesSchema[key];
|
541
|
-
if (fieldSchema.type === "component") {
|
542
|
-
const componentSchema = strapi2.getModel(fieldSchema.component).attributes;
|
543
|
-
return {
|
544
|
-
...currentComponentSchemas,
|
545
|
-
[fieldSchema.component]: componentSchema
|
546
|
-
};
|
547
|
-
}
|
548
|
-
return currentComponentSchemas;
|
549
|
-
}, {});
|
550
570
|
await strapi2.db.transaction(async ({ onCommit }) => {
|
551
|
-
onCommit(() => {
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
571
|
+
onCommit(async () => {
|
572
|
+
for (const entry of localeEntries) {
|
573
|
+
const status = await serviceUtils.getVersionStatus(uid2, entry);
|
574
|
+
await getService(strapi2, "history").createVersion({
|
575
|
+
contentType: uid2,
|
576
|
+
data: fp.omit(FIELDS_TO_IGNORE, entry),
|
577
|
+
relatedDocumentId: documentId,
|
578
|
+
locale: entry.locale,
|
579
|
+
status,
|
580
|
+
...schemas
|
581
|
+
});
|
582
|
+
}
|
561
583
|
});
|
562
584
|
});
|
563
585
|
return result;
|
@@ -565,7 +587,7 @@ const createLifecyclesService = ({ strapi: strapi2 }) => {
|
|
565
587
|
state.deleteExpiredJob = nodeSchedule.scheduleJob("0 0 * * *", () => {
|
566
588
|
const retentionDaysInMilliseconds = serviceUtils.getRetentionDays() * 24 * 60 * 60 * 1e3;
|
567
589
|
const expirationDate = new Date(Date.now() - retentionDaysInMilliseconds);
|
568
|
-
query.deleteMany({
|
590
|
+
strapi2.db.query(HISTORY_VERSION_UID).deleteMany({
|
569
591
|
where: {
|
570
592
|
created_at: {
|
571
593
|
$lt: expirationDate.toISOString()
|
@@ -1590,9 +1612,11 @@ const multipleLocaleSchema = strapiUtils.yup.lazy(
|
|
1590
1612
|
(value) => Array.isArray(value) ? strapiUtils.yup.array().of(singleLocaleSchema.required()) : singleLocaleSchema
|
1591
1613
|
);
|
1592
1614
|
const statusSchema = strapiUtils.yup.mixed().oneOf(["draft", "published"], "Invalid status");
|
1593
|
-
const getDocumentLocaleAndStatus = async (request, opts = { allowMultipleLocales: false }) => {
|
1615
|
+
const getDocumentLocaleAndStatus = async (request, model, opts = { allowMultipleLocales: false }) => {
|
1594
1616
|
const { allowMultipleLocales } = opts;
|
1595
|
-
const { locale, status, ...rest } = request || {};
|
1617
|
+
const { locale, status: providedStatus, ...rest } = request || {};
|
1618
|
+
const defaultStatus = strapiUtils.contentTypes.hasDraftAndPublish(strapi.getModel(model)) ? void 0 : "published";
|
1619
|
+
const status = providedStatus !== void 0 ? providedStatus : defaultStatus;
|
1596
1620
|
const schema = strapiUtils.yup.object().shape({
|
1597
1621
|
locale: allowMultipleLocales ? multipleLocaleSchema : singleLocaleSchema,
|
1598
1622
|
status: statusSchema
|
@@ -1640,7 +1664,7 @@ const createDocument = async (ctx, opts) => {
|
|
1640
1664
|
const setCreator = strapiUtils.setCreatorFields({ user });
|
1641
1665
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1642
1666
|
const sanitizedBody = await sanitizeFn(body);
|
1643
|
-
const { locale, status
|
1667
|
+
const { locale, status } = await getDocumentLocaleAndStatus(body, model);
|
1644
1668
|
return documentManager2.create(model, {
|
1645
1669
|
data: sanitizedBody,
|
1646
1670
|
locale,
|
@@ -1659,7 +1683,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1659
1683
|
}
|
1660
1684
|
const permissionQuery = await permissionChecker2.sanitizedQuery.update(ctx.query);
|
1661
1685
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1662
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1686
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1663
1687
|
const [documentVersion, documentExists] = await Promise.all([
|
1664
1688
|
documentManager2.findOne(id, model, { populate, locale, status: "draft" }),
|
1665
1689
|
documentManager2.exists(model, id)
|
@@ -1697,7 +1721,7 @@ const collectionTypes = {
|
|
1697
1721
|
}
|
1698
1722
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
1699
1723
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(1).countRelations({ toOne: false, toMany: true }).build();
|
1700
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
1724
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
1701
1725
|
const { results: documents, pagination } = await documentManager2.findPage(
|
1702
1726
|
{ ...permissionQuery, populate, locale, status },
|
1703
1727
|
model
|
@@ -1732,7 +1756,7 @@ const collectionTypes = {
|
|
1732
1756
|
}
|
1733
1757
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
1734
1758
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1735
|
-
const { locale, status
|
1759
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1736
1760
|
const version = await documentManager2.findOne(id, model, {
|
1737
1761
|
populate,
|
1738
1762
|
locale,
|
@@ -1799,7 +1823,7 @@ const collectionTypes = {
|
|
1799
1823
|
}
|
1800
1824
|
const permissionQuery = await permissionChecker2.sanitizedQuery.create(ctx.query);
|
1801
1825
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1802
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1826
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1803
1827
|
const document = await documentManager2.findOne(id, model, {
|
1804
1828
|
populate,
|
1805
1829
|
locale,
|
@@ -1844,7 +1868,7 @@ const collectionTypes = {
|
|
1844
1868
|
}
|
1845
1869
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(ctx.query);
|
1846
1870
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1847
|
-
const { locale } = await getDocumentLocaleAndStatus(ctx.query);
|
1871
|
+
const { locale } = await getDocumentLocaleAndStatus(ctx.query, model);
|
1848
1872
|
const documentLocales = await documentManager2.findLocales(id, model, { populate, locale });
|
1849
1873
|
if (documentLocales.length === 0) {
|
1850
1874
|
return ctx.notFound();
|
@@ -1873,11 +1897,28 @@ const collectionTypes = {
|
|
1873
1897
|
const publishedDocument = await strapi.db.transaction(async () => {
|
1874
1898
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1875
1899
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1876
|
-
|
1900
|
+
let document;
|
1901
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1902
|
+
const isCreate = fp.isNil(id);
|
1903
|
+
if (isCreate) {
|
1904
|
+
if (permissionChecker2.cannot.create()) {
|
1905
|
+
throw new strapiUtils.errors.ForbiddenError();
|
1906
|
+
}
|
1907
|
+
document = await createDocument(ctx, { populate });
|
1908
|
+
}
|
1909
|
+
const isUpdate = !isCreate;
|
1910
|
+
if (isUpdate) {
|
1911
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
1912
|
+
if (!document) {
|
1913
|
+
throw new strapiUtils.errors.NotFoundError("Document not found");
|
1914
|
+
}
|
1915
|
+
if (permissionChecker2.can.update(document)) {
|
1916
|
+
await updateDocument(ctx);
|
1917
|
+
}
|
1918
|
+
}
|
1877
1919
|
if (permissionChecker2.cannot.publish(document)) {
|
1878
1920
|
throw new strapiUtils.errors.ForbiddenError();
|
1879
1921
|
}
|
1880
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1881
1922
|
const publishResult = await documentManager2.publish(document.documentId, model, {
|
1882
1923
|
locale
|
1883
1924
|
// TODO: Allow setting creator fields on publish
|
@@ -1904,7 +1945,9 @@ const collectionTypes = {
|
|
1904
1945
|
}
|
1905
1946
|
const permissionQuery = await permissionChecker2.sanitizedQuery.publish(ctx.query);
|
1906
1947
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).populateDeep(Infinity).countRelations().build();
|
1907
|
-
const { locale } = await getDocumentLocaleAndStatus(body, {
|
1948
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
1949
|
+
allowMultipleLocales: true
|
1950
|
+
});
|
1908
1951
|
const entityPromises = documentIds.map(
|
1909
1952
|
(documentId) => documentManager2.findLocales(documentId, model, { populate, locale, isPublished: false })
|
1910
1953
|
);
|
@@ -1931,7 +1974,7 @@ const collectionTypes = {
|
|
1931
1974
|
if (permissionChecker2.cannot.unpublish()) {
|
1932
1975
|
return ctx.forbidden();
|
1933
1976
|
}
|
1934
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
1977
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1935
1978
|
const entityPromises = documentIds.map(
|
1936
1979
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1937
1980
|
);
|
@@ -1964,7 +2007,7 @@ const collectionTypes = {
|
|
1964
2007
|
}
|
1965
2008
|
const permissionQuery = await permissionChecker2.sanitizedQuery.unpublish(ctx.query);
|
1966
2009
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
1967
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2010
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
1968
2011
|
const document = await documentManager2.findOne(id, model, {
|
1969
2012
|
populate,
|
1970
2013
|
locale,
|
@@ -2001,7 +2044,7 @@ const collectionTypes = {
|
|
2001
2044
|
}
|
2002
2045
|
const permissionQuery = await permissionChecker2.sanitizedQuery.discard(ctx.query);
|
2003
2046
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2004
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2047
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2005
2048
|
const document = await documentManager2.findOne(id, model, {
|
2006
2049
|
populate,
|
2007
2050
|
locale,
|
@@ -2032,7 +2075,7 @@ const collectionTypes = {
|
|
2032
2075
|
}
|
2033
2076
|
const permissionQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2034
2077
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2035
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2078
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2036
2079
|
const documentLocales = await documentManager2.findLocales(documentIds, model, {
|
2037
2080
|
populate,
|
2038
2081
|
locale
|
@@ -2059,7 +2102,7 @@ const collectionTypes = {
|
|
2059
2102
|
}
|
2060
2103
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(ctx.query);
|
2061
2104
|
const populate = await getService$1("populate-builder")(model).populateFromQuery(permissionQuery).build();
|
2062
|
-
const { locale, status
|
2105
|
+
const { locale, status } = await getDocumentLocaleAndStatus(ctx.query, model);
|
2063
2106
|
const entity = await documentManager2.findOne(id, model, { populate, locale, status });
|
2064
2107
|
if (!entity) {
|
2065
2108
|
return ctx.notFound();
|
@@ -2082,7 +2125,7 @@ const collectionTypes = {
|
|
2082
2125
|
if (permissionChecker2.cannot.read()) {
|
2083
2126
|
return ctx.forbidden();
|
2084
2127
|
}
|
2085
|
-
const
|
2128
|
+
const documents = await documentManager2.findMany(
|
2086
2129
|
{
|
2087
2130
|
filters: {
|
2088
2131
|
documentId: ids
|
@@ -2091,7 +2134,7 @@ const collectionTypes = {
|
|
2091
2134
|
},
|
2092
2135
|
model
|
2093
2136
|
);
|
2094
|
-
if (!
|
2137
|
+
if (!documents) {
|
2095
2138
|
return ctx.notFound();
|
2096
2139
|
}
|
2097
2140
|
const number = await documentManager2.countManyEntriesDraftRelations(ids, model, locale);
|
@@ -2587,7 +2630,7 @@ const createOrUpdateDocument = async (ctx, opts) => {
|
|
2587
2630
|
throw new strapiUtils.errors.ForbiddenError();
|
2588
2631
|
}
|
2589
2632
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.update(query);
|
2590
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2633
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2591
2634
|
const [documentVersion, otherDocumentVersion] = await Promise.all([
|
2592
2635
|
findDocument(sanitizedQuery, model, { locale, status: "draft" }),
|
2593
2636
|
// Find the first document to check if it exists
|
@@ -2628,7 +2671,7 @@ const singleTypes = {
|
|
2628
2671
|
return ctx.forbidden();
|
2629
2672
|
}
|
2630
2673
|
const permissionQuery = await permissionChecker2.sanitizedQuery.read(query);
|
2631
|
-
const { locale, status } = await getDocumentLocaleAndStatus(query);
|
2674
|
+
const { locale, status } = await getDocumentLocaleAndStatus(query, model);
|
2632
2675
|
const version = await findDocument(permissionQuery, model, { locale, status });
|
2633
2676
|
if (!version) {
|
2634
2677
|
if (permissionChecker2.cannot.create()) {
|
@@ -2673,7 +2716,7 @@ const singleTypes = {
|
|
2673
2716
|
}
|
2674
2717
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.delete(query);
|
2675
2718
|
const populate = await buildPopulateFromQuery(sanitizedQuery, model);
|
2676
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2719
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2677
2720
|
const documentLocales = await documentManager2.findLocales(void 0, model, {
|
2678
2721
|
populate,
|
2679
2722
|
locale
|
@@ -2710,7 +2753,7 @@ const singleTypes = {
|
|
2710
2753
|
if (permissionChecker2.cannot.publish(document)) {
|
2711
2754
|
throw new strapiUtils.errors.ForbiddenError();
|
2712
2755
|
}
|
2713
|
-
const { locale } = await getDocumentLocaleAndStatus(document);
|
2756
|
+
const { locale } = await getDocumentLocaleAndStatus(document, model);
|
2714
2757
|
const publishResult = await documentManager2.publish(document.documentId, model, { locale });
|
2715
2758
|
return publishResult.at(0);
|
2716
2759
|
});
|
@@ -2733,7 +2776,7 @@ const singleTypes = {
|
|
2733
2776
|
return ctx.forbidden();
|
2734
2777
|
}
|
2735
2778
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.unpublish(query);
|
2736
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2779
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2737
2780
|
const document = await findDocument(sanitizedQuery, model, { locale });
|
2738
2781
|
if (!document) {
|
2739
2782
|
return ctx.notFound();
|
@@ -2765,7 +2808,7 @@ const singleTypes = {
|
|
2765
2808
|
return ctx.forbidden();
|
2766
2809
|
}
|
2767
2810
|
const sanitizedQuery = await permissionChecker2.sanitizedQuery.discard(query);
|
2768
|
-
const { locale } = await getDocumentLocaleAndStatus(body);
|
2811
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model);
|
2769
2812
|
const document = await findDocument(sanitizedQuery, model, { locale, status: "published" });
|
2770
2813
|
if (!document) {
|
2771
2814
|
return ctx.notFound();
|
@@ -2785,7 +2828,7 @@ const singleTypes = {
|
|
2785
2828
|
const { query } = ctx.request;
|
2786
2829
|
const documentManager2 = getService$1("document-manager");
|
2787
2830
|
const permissionChecker2 = getService$1("permission-checker").create({ userAbility, model });
|
2788
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2831
|
+
const { locale } = await getDocumentLocaleAndStatus(query, model);
|
2789
2832
|
if (permissionChecker2.cannot.read()) {
|
2790
2833
|
return ctx.forbidden();
|
2791
2834
|
}
|
@@ -2806,7 +2849,7 @@ const uid$1 = {
|
|
2806
2849
|
async generateUID(ctx) {
|
2807
2850
|
const { contentTypeUID, field, data } = await validateGenerateUIDInput(ctx.request.body);
|
2808
2851
|
const { query = {} } = ctx.request;
|
2809
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2852
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2810
2853
|
await validateUIDField(contentTypeUID, field);
|
2811
2854
|
const uidService = getService$1("uid");
|
2812
2855
|
ctx.body = {
|
@@ -2818,7 +2861,7 @@ const uid$1 = {
|
|
2818
2861
|
ctx.request.body
|
2819
2862
|
);
|
2820
2863
|
const { query = {} } = ctx.request;
|
2821
|
-
const { locale } = await getDocumentLocaleAndStatus(query);
|
2864
|
+
const { locale } = await getDocumentLocaleAndStatus(query, contentTypeUID);
|
2822
2865
|
await validateUIDField(contentTypeUID, field);
|
2823
2866
|
const uidService = getService$1("uid");
|
2824
2867
|
const isAvailable = await uidService.checkUIDAvailability({
|
@@ -3743,6 +3786,10 @@ const getDeepPopulateDraftCount = (uid2) => {
|
|
3743
3786
|
const attribute = model.attributes[attributeName];
|
3744
3787
|
switch (attribute.type) {
|
3745
3788
|
case "relation": {
|
3789
|
+
const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
|
3790
|
+
if (isMorphRelation) {
|
3791
|
+
break;
|
3792
|
+
}
|
3746
3793
|
if (isVisibleAttribute$1(model, attributeName)) {
|
3747
3794
|
populateAcc[attributeName] = {
|
3748
3795
|
count: true,
|
@@ -4120,7 +4167,13 @@ const documentMetadata = ({ strapi: strapi2 }) => ({
|
|
4120
4167
|
*/
|
4121
4168
|
async formatDocumentWithMetadata(uid2, document, opts = {}) {
|
4122
4169
|
if (!document) {
|
4123
|
-
return
|
4170
|
+
return {
|
4171
|
+
data: document,
|
4172
|
+
meta: {
|
4173
|
+
availableLocales: [],
|
4174
|
+
availableStatus: []
|
4175
|
+
}
|
4176
|
+
};
|
4124
4177
|
}
|
4125
4178
|
const hasDraftAndPublish = strapiUtils.contentTypes.hasDraftAndPublish(strapi2.getModel(uid2));
|
4126
4179
|
if (!hasDraftAndPublish) {
|
@@ -4228,10 +4281,7 @@ const documentManager = ({ strapi: strapi2 }) => {
|
|
4228
4281
|
async clone(id, body, uid2) {
|
4229
4282
|
const populate = await buildDeepPopulate(uid2);
|
4230
4283
|
const params = {
|
4231
|
-
data:
|
4232
|
-
...omitIdField(body),
|
4233
|
-
[PUBLISHED_AT_ATTRIBUTE]: null
|
4234
|
-
},
|
4284
|
+
data: omitIdField(body),
|
4235
4285
|
populate
|
4236
4286
|
};
|
4237
4287
|
return strapi2.documents(uid2).clone({ ...params, documentId: id }).then((result) => result?.entries.at(0));
|