@strapi/content-manager 0.0.0-experimental.da85533897155e719d784f0271223c866d2f69ab → 0.0.0-experimental.e02b4637b3906c6d31048d00600d09a23a0edc3d
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/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs → ComponentConfigurationPage-DfFSZQxe.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs.map → ComponentConfigurationPage-DfFSZQxe.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js → ComponentConfigurationPage-FqfsxQ1j.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js.map → ComponentConfigurationPage-FqfsxQ1j.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DValmA0m.js → EditConfigurationPage-Cn0e8t3I.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-DValmA0m.js.map → EditConfigurationPage-Cn0e8t3I.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs → EditConfigurationPage-DdPNAbl3.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs.map → EditConfigurationPage-DdPNAbl3.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-DiNFdFqP.mjs → EditViewPage-B82x_x1b.mjs} +15 -5
- package/dist/_chunks/EditViewPage-B82x_x1b.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-Dk7Eaft4.js → EditViewPage-DlxEHhUt.js} +15 -5
- package/dist/_chunks/EditViewPage-DlxEHhUt.js.map +1 -0
- package/dist/_chunks/{Field-DH2OaqUP.js → Field-COL25JiC.js} +76 -42
- package/dist/_chunks/Field-COL25JiC.js.map +1 -0
- package/dist/_chunks/{Field-Dv_HTFTa.mjs → Field-DufHXW17.mjs} +72 -38
- package/dist/_chunks/Field-DufHXW17.mjs.map +1 -0
- package/dist/_chunks/{Form-B_dUDizM.js → Form-BssUwrTO.js} +16 -8
- package/dist/_chunks/Form-BssUwrTO.js.map +1 -0
- package/dist/_chunks/{Form-Dy6P4HgH.mjs → Form-u_kAOhwB.mjs} +16 -8
- package/dist/_chunks/Form-u_kAOhwB.mjs.map +1 -0
- package/dist/_chunks/{History-BT4w83Oa.js → History-C9t9UqpO.js} +23 -10
- package/dist/_chunks/History-C9t9UqpO.js.map +1 -0
- package/dist/_chunks/{History-DrwsD1Vc.mjs → History-DRwA3oMM.mjs} +24 -11
- package/dist/_chunks/History-DRwA3oMM.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js → ListConfigurationPage-BXYPohh-.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js.map → ListConfigurationPage-BXYPohh-.js.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs → ListConfigurationPage-BxfQJzPk.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs.map → ListConfigurationPage-BxfQJzPk.mjs.map} +1 -1
- package/dist/_chunks/{ListViewPage-5a1vw-OK.mjs → ListViewPage-CELx2ysp.mjs} +24 -12
- package/dist/_chunks/ListViewPage-CELx2ysp.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BvpwNur7.js → ListViewPage-D2VD8Szg.js} +28 -16
- package/dist/_chunks/ListViewPage-D2VD8Szg.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js → NoContentTypePage-BV9IjJSM.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js.map → NoContentTypePage-BV9IjJSM.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs → NoContentTypePage-DtJ9jcfk.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs.map → NoContentTypePage-DtJ9jcfk.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs → NoPermissionsPage-DWleVYK7.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs.map → NoPermissionsPage-DWleVYK7.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js → NoPermissionsPage-Dp8NpF9I.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js.map → NoPermissionsPage-Dp8NpF9I.js.map} +1 -1
- package/dist/_chunks/{Relations-C7fPyh5P.mjs → Relations-BTcf5xaw.mjs} +32 -23
- package/dist/_chunks/Relations-BTcf5xaw.mjs.map +1 -0
- package/dist/_chunks/{Relations-CznVF6LS.js → Relations-DR7EUgyC.js} +32 -23
- package/dist/_chunks/Relations-DR7EUgyC.js.map +1 -0
- package/dist/_chunks/{en-otD_UBJi.js → en-Bm0D0IWz.js} +12 -11
- package/dist/_chunks/{en-otD_UBJi.js.map → en-Bm0D0IWz.js.map} +1 -1
- package/dist/_chunks/{en-CbaIuYoB.mjs → en-DKV44jRb.mjs} +12 -11
- package/dist/_chunks/{en-CbaIuYoB.mjs.map → en-DKV44jRb.mjs.map} +1 -1
- package/dist/_chunks/{index-D9UmmBcM.js → index-BdMf2lfT.js} +1990 -1875
- package/dist/_chunks/index-BdMf2lfT.js.map +1 -0
- package/dist/_chunks/{index-BJ6uTqLL.mjs → index-wnqzm4Q8.mjs} +1994 -1879
- package/dist/_chunks/index-wnqzm4Q8.mjs.map +1 -0
- package/dist/_chunks/{layout-uomiIGbG.mjs → layout-2CfjL0T9.mjs} +5 -4
- package/dist/_chunks/{layout-uomiIGbG.mjs.map → layout-2CfjL0T9.mjs.map} +1 -1
- package/dist/_chunks/{layout-kfu5Wtix.js → layout-B2MyZU-_.js} +5 -4
- package/dist/_chunks/{layout-kfu5Wtix.js.map → layout-B2MyZU-_.js.map} +1 -1
- package/dist/_chunks/{relations-DKENrxko.js → relations-BH7JJGGe.js} +2 -2
- package/dist/_chunks/{relations-DKENrxko.js.map → relations-BH7JJGGe.js.map} +1 -1
- package/dist/_chunks/{relations-DiDufGSA.mjs → relations-C0w0GcXi.mjs} +2 -2
- package/dist/_chunks/{relations-DiDufGSA.mjs.map → relations-C0w0GcXi.mjs.map} +1 -1
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/services/documents.d.ts +3 -1
- package/dist/server/index.js +34 -18
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +34 -18
- 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/relations.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/package.json +12 -12
- package/dist/_chunks/EditViewPage-DiNFdFqP.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-Dk7Eaft4.js.map +0 -1
- package/dist/_chunks/Field-DH2OaqUP.js.map +0 -1
- package/dist/_chunks/Field-Dv_HTFTa.mjs.map +0 -1
- package/dist/_chunks/Form-B_dUDizM.js.map +0 -1
- package/dist/_chunks/Form-Dy6P4HgH.mjs.map +0 -1
- package/dist/_chunks/History-BT4w83Oa.js.map +0 -1
- package/dist/_chunks/History-DrwsD1Vc.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-5a1vw-OK.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BvpwNur7.js.map +0 -1
- package/dist/_chunks/Relations-C7fPyh5P.mjs.map +0 -1
- package/dist/_chunks/Relations-CznVF6LS.js.map +0 -1
- package/dist/_chunks/index-BJ6uTqLL.mjs.map +0 -1
- package/dist/_chunks/index-D9UmmBcM.js.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useDebounce-DmuSJIF3.mjs","sources":["../../admin/src/utils/urls.ts","../../admin/src/hooks/usePrev.ts","../../admin/src/hooks/useDebounce.ts"],"sourcesContent":["const prefixFileUrlWithBackendUrl = (fileURL?: string): string | undefined => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n\nexport { prefixFileUrlWithBackendUrl };\n","import { useEffect, useRef } from 'react';\n\nexport const usePrev = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n","import { useEffect, useState } from 'react';\n\nexport function useDebounce<TValue>(value: TValue, delay: number): TValue {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n"],"names":[],"mappings":";AAAM,MAAA,8BAA8B,CAAC,YAAyC;AAC5E,SAAO,CAAC,CAAC,WAAW,QAAQ,WAAW,GAAG,IAAI,GAAG,OAAO,OAAO,UAAU,GAAG,OAAO,KAAK;AAC1F;ACAa,MAAA,UAAU,CAAI,UAA4B;AACrD,QAAM,MAAM;AAEZ,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAAA,GACb,CAAC,KAAK,CAAC;AAEV,SAAO,IAAI;AACb;ACRgB,SAAA,YAAoB,OAAe,OAAuB;AACxE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAE1D,YAAU,MAAM;AACR,UAAA,UAAU,WAAW,MAAM;AAC/B,wBAAkB,KAAK;AAAA,OACtB,KAAK;AAER,WAAO,MAAM;AACX,mBAAa,OAAO;AAAA,IAAA;AAAA,EACtB,GACC,CAAC,OAAO,KAAK,CAAC;AAEV,SAAA;AACT;"}
|
package/dist/admin/index.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
3
|
-
const index = require("../_chunks/index-
|
3
|
+
const index = require("../_chunks/index-BdMf2lfT.js");
|
4
4
|
require("@strapi/icons");
|
5
5
|
exports.DocumentRBAC = index.DocumentRBAC;
|
6
6
|
exports.buildValidParams = index.buildValidParams;
|
7
7
|
exports.default = index.index;
|
8
|
+
exports.unstable_useContentManagerContext = index.useContentManagerContext;
|
8
9
|
exports.unstable_useDocument = index.useDocument;
|
9
10
|
exports.unstable_useDocumentActions = index.useDocumentActions;
|
10
11
|
exports.unstable_useDocumentLayout = index.useDocumentLayout;
|
package/dist/admin/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
package/dist/admin/index.mjs
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
import { l, d, K, J,
|
1
|
+
import { l, d, K, L, J, M, h, f } from "../_chunks/index-wnqzm4Q8.mjs";
|
2
2
|
import "@strapi/icons";
|
3
3
|
export {
|
4
4
|
l as DocumentRBAC,
|
5
5
|
d as buildValidParams,
|
6
6
|
K as default,
|
7
|
+
L as unstable_useContentManagerContext,
|
7
8
|
J as unstable_useDocument,
|
8
|
-
|
9
|
+
M as unstable_useDocumentActions,
|
9
10
|
h as unstable_useDocumentLayout,
|
10
11
|
f as useDocumentRBAC
|
11
12
|
};
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* but should still export the same things.
|
5
5
|
*/
|
6
6
|
export { buildValidParams } from './utils/api';
|
7
|
-
export { useDocument as unstable_useDocument } from './hooks/useDocument';
|
7
|
+
export { useDocument as unstable_useDocument, useContentManagerContext as unstable_useContentManagerContext, } from './hooks/useDocument';
|
8
8
|
export { useDocumentActions as unstable_useDocumentActions } from './hooks/useDocumentActions';
|
9
9
|
export { useDocumentLayout as unstable_useDocumentLayout } from './hooks/useDocumentLayout';
|
10
10
|
export type { EditFieldLayout, EditLayout, ListFieldLayout, ListLayout, } from './hooks/useDocumentLayout';
|
@@ -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
|
-
|
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 };
|
@@ -6,20 +6,20 @@ interface HeaderProps {
|
|
6
6
|
title?: string;
|
7
7
|
}
|
8
8
|
declare const Header: ({ isCreating, status, title: documentTitle }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
9
|
-
interface
|
9
|
+
interface DialogOptions {
|
10
|
+
type: 'dialog';
|
11
|
+
title: string;
|
12
|
+
content?: React.ReactNode;
|
13
|
+
footer?: React.ReactNode;
|
14
|
+
}
|
15
|
+
interface HeaderActionDescription {
|
10
16
|
disabled?: boolean;
|
11
17
|
label: string;
|
12
18
|
icon?: React.ReactNode;
|
13
|
-
/**
|
14
|
-
* @default 'default'
|
15
|
-
*/
|
16
19
|
type?: 'icon' | 'default';
|
17
|
-
onClick?: (event: React.SyntheticEvent) => void;
|
18
|
-
|
19
|
-
|
20
|
-
disabled?: boolean;
|
21
|
-
label: string;
|
22
|
-
options: Array<{
|
20
|
+
onClick?: (event: React.SyntheticEvent) => Promise<boolean | void> | boolean | void;
|
21
|
+
dialog?: DialogOptions;
|
22
|
+
options?: Array<{
|
23
23
|
disabled?: boolean;
|
24
24
|
label: string;
|
25
25
|
startIcon?: React.ReactNode;
|
@@ -28,8 +28,8 @@ interface HeaderSelectAction {
|
|
28
28
|
}>;
|
29
29
|
onSelect?: (value: string) => void;
|
30
30
|
value?: string;
|
31
|
+
customizeContent?: (value: string) => React.ReactNode;
|
31
32
|
}
|
32
|
-
type HeaderActionDescription = HeaderButtonAction | HeaderSelectAction;
|
33
33
|
declare const DEFAULT_HEADER_ACTIONS: DocumentActionComponent[];
|
34
34
|
export { Header, DEFAULT_HEADER_ACTIONS };
|
35
35
|
export type { HeaderProps, HeaderActionDescription };
|
@@ -96,6 +96,8 @@ declare const useAutoCloneDocumentMutation: import("@reduxjs/toolkit/dist/query/
|
|
96
96
|
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations" | "UidAvailability", Unpublish.Response, "adminApi">>, useUnpublishManyDocumentsMutation: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseMutation<import("@reduxjs/toolkit/query").MutationDefinition<Pick<BulkUnpublish.Params, "model"> & {
|
97
97
|
documentIds: string[];
|
98
98
|
} & {
|
99
|
-
params?: {
|
99
|
+
params?: {
|
100
|
+
locale?: string | string[] | null | undefined;
|
101
|
+
} | undefined;
|
100
102
|
}, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations" | "UidAvailability", BulkUnpublish.Response, "adminApi">>;
|
101
103
|
export { useAutoCloneDocumentMutation, useCloneDocumentMutation, useCreateDocumentMutation, useDeleteDocumentMutation, useDeleteManyDocumentsMutation, useDiscardDocumentMutation, useGetAllDocumentsQuery, useLazyGetDocumentQuery, useGetDocumentQuery, useLazyGetDraftRelationCountQuery as useGetDraftRelationCountQuery, useGetManyDraftRelationCountQuery, usePublishDocumentMutation, usePublishManyDocumentsMutation, useUpdateDocumentMutation, useUnpublishDocumentMutation, useUnpublishManyDocumentsMutation, };
|
package/dist/server/index.js
CHANGED
@@ -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({
|
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 {
|
@@ -1715,7 +1720,7 @@ const updateDocument = async (ctx, opts) => {
|
|
1715
1720
|
throw new strapiUtils.errors.ForbiddenError();
|
1716
1721
|
}
|
1717
1722
|
const pickPermittedFields = documentVersion ? permissionChecker2.sanitizeUpdateInput(documentVersion) : permissionChecker2.sanitizeCreateInput;
|
1718
|
-
const setCreator = strapiUtils.setCreatorFields({ user, isEdition: true });
|
1723
|
+
const setCreator = documentVersion ? strapiUtils.setCreatorFields({ user, isEdition: true }) : strapiUtils.setCreatorFields({ user });
|
1719
1724
|
const sanitizeFn = strapiUtils.async.pipe(pickPermittedFields, setCreator);
|
1720
1725
|
const sanitizedBody = await sanitizeFn(body);
|
1721
1726
|
return documentManager2.update(documentVersion?.documentId || id, model, {
|
@@ -1787,7 +1792,7 @@ const collectionTypes = {
|
|
1787
1792
|
permissionChecker2,
|
1788
1793
|
model,
|
1789
1794
|
// @ts-expect-error TODO: fix
|
1790
|
-
{ id, locale, publishedAt: null },
|
1795
|
+
{ documentId: id, locale, publishedAt: null },
|
1791
1796
|
{ availableLocales: true, availableStatus: false }
|
1792
1797
|
);
|
1793
1798
|
ctx.body = { data: {}, meta };
|
@@ -1924,11 +1929,17 @@ const collectionTypes = {
|
|
1924
1929
|
}
|
1925
1930
|
const isUpdate = !isCreate;
|
1926
1931
|
if (isUpdate) {
|
1927
|
-
|
1928
|
-
if (!
|
1932
|
+
const documentExists = documentManager2.exists(model, id);
|
1933
|
+
if (!documentExists) {
|
1929
1934
|
throw new strapiUtils.errors.NotFoundError("Document not found");
|
1930
1935
|
}
|
1931
|
-
|
1936
|
+
document = await documentManager2.findOne(id, model, { populate, locale });
|
1937
|
+
if (!document) {
|
1938
|
+
if (permissionChecker2.cannot.create({ locale }) || permissionChecker2.cannot.publish({ locale })) {
|
1939
|
+
throw new strapiUtils.errors.ForbiddenError();
|
1940
|
+
}
|
1941
|
+
document = await updateDocument(ctx);
|
1942
|
+
} else if (permissionChecker2.can.update(document)) {
|
1932
1943
|
await updateDocument(ctx);
|
1933
1944
|
}
|
1934
1945
|
}
|
@@ -1990,7 +2001,9 @@ const collectionTypes = {
|
|
1990
2001
|
if (permissionChecker2.cannot.unpublish()) {
|
1991
2002
|
return ctx.forbidden();
|
1992
2003
|
}
|
1993
|
-
const { locale } = await getDocumentLocaleAndStatus(body, model
|
2004
|
+
const { locale } = await getDocumentLocaleAndStatus(body, model, {
|
2005
|
+
allowMultipleLocales: true
|
2006
|
+
});
|
1994
2007
|
const entityPromises = documentIds.map(
|
1995
2008
|
(documentId) => documentManager2.findLocales(documentId, model, { locale, isPublished: true })
|
1996
2009
|
);
|
@@ -2380,11 +2393,8 @@ const validateLocale = (sourceUid, targetUid, locale) => {
|
|
2380
2393
|
const isLocalized = strapi.plugin("i18n").service("content-types").isLocalizedContentType;
|
2381
2394
|
const isSourceLocalized = isLocalized(sourceModel);
|
2382
2395
|
const isTargetLocalized = isLocalized(targetModel);
|
2383
|
-
let validatedLocale = locale;
|
2384
|
-
if (!targetModel || !isTargetLocalized)
|
2385
|
-
validatedLocale = void 0;
|
2386
2396
|
return {
|
2387
|
-
locale
|
2397
|
+
locale,
|
2388
2398
|
isSourceLocalized,
|
2389
2399
|
isTargetLocalized
|
2390
2400
|
};
|
@@ -2487,7 +2497,7 @@ const relations = {
|
|
2487
2497
|
attribute,
|
2488
2498
|
fieldsToSelect,
|
2489
2499
|
mainField,
|
2490
|
-
source: { schema: sourceSchema },
|
2500
|
+
source: { schema: sourceSchema, isLocalized: isSourceLocalized },
|
2491
2501
|
target: { schema: targetSchema, isLocalized: isTargetLocalized },
|
2492
2502
|
sourceSchema,
|
2493
2503
|
targetSchema,
|
@@ -2509,7 +2519,8 @@ const relations = {
|
|
2509
2519
|
fieldsToSelect,
|
2510
2520
|
mainField,
|
2511
2521
|
source: {
|
2512
|
-
schema: { uid: sourceUid, modelType: sourceModelType }
|
2522
|
+
schema: { uid: sourceUid, modelType: sourceModelType },
|
2523
|
+
isLocalized: isSourceLocalized
|
2513
2524
|
},
|
2514
2525
|
target: {
|
2515
2526
|
schema: { uid: targetUid },
|
@@ -2547,12 +2558,16 @@ const relations = {
|
|
2547
2558
|
} else {
|
2548
2559
|
where.id = id;
|
2549
2560
|
}
|
2550
|
-
|
2551
|
-
|
2561
|
+
const publishedAt = getPublishedAtClause(status, targetUid);
|
2562
|
+
if (!fp.isEmpty(publishedAt)) {
|
2563
|
+
where[`${alias}.published_at`] = publishedAt;
|
2552
2564
|
}
|
2553
|
-
if (
|
2565
|
+
if (isTargetLocalized && locale) {
|
2554
2566
|
where[`${alias}.locale`] = locale;
|
2555
2567
|
}
|
2568
|
+
if (isSourceLocalized && locale) {
|
2569
|
+
where.locale = locale;
|
2570
|
+
}
|
2556
2571
|
if ((idsToInclude?.length ?? 0) !== 0) {
|
2557
2572
|
where[`${alias}.id`].$notIn = idsToInclude;
|
2558
2573
|
}
|
@@ -2570,7 +2585,8 @@ const relations = {
|
|
2570
2585
|
id: { $notIn: fp.uniq(idsToOmit) }
|
2571
2586
|
});
|
2572
2587
|
}
|
2573
|
-
const
|
2588
|
+
const dbQuery = strapi.get("query-params").transform(targetUid, queryParams);
|
2589
|
+
const res = await strapi.db.query(targetUid).findPage(dbQuery);
|
2574
2590
|
ctx.body = {
|
2575
2591
|
...res,
|
2576
2592
|
results: await addStatusToRelations(targetUid, res.results)
|
@@ -2692,7 +2708,7 @@ const singleTypes = {
|
|
2692
2708
|
permissionChecker2,
|
2693
2709
|
model,
|
2694
2710
|
// @ts-expect-error - fix types
|
2695
|
-
{
|
2711
|
+
{ documentId: document.documentId, locale, publishedAt: null },
|
2696
2712
|
{ availableLocales: true, availableStatus: false }
|
2697
2713
|
);
|
2698
2714
|
ctx.body = { data: {}, meta };
|