@payloadcms/next 3.12.0 → 3.12.1-canary.33ecab2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Data, DocumentPreferences, FormState, PayloadRequest } from 'payload';
|
|
1
|
+
import type { Data, DocumentPreferences, FormState, Locale, PayloadRequest } from 'payload';
|
|
2
2
|
type RenderDocumentResult = {
|
|
3
3
|
data: any;
|
|
4
4
|
Document: React.ReactNode;
|
|
@@ -11,6 +11,7 @@ export declare const renderDocumentHandler: (args: {
|
|
|
11
11
|
drawerSlug?: string;
|
|
12
12
|
initialData?: Data;
|
|
13
13
|
initialState?: FormState;
|
|
14
|
+
locale?: Locale;
|
|
14
15
|
overrideEntityVisibility?: boolean;
|
|
15
16
|
redirectAfterDelete: boolean;
|
|
16
17
|
redirectAfterDuplicate: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,cAAc,EAEf,MAAM,SAAS,CAAA;AAQhB,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,GAAG,CAAA;IACT,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,EAAE,mBAAmB,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAgB;IAChD,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,oBAAoB,CA+I/B,CAAA"}
|
|
@@ -9,6 +9,7 @@ export const renderDocumentHandler = async args => {
|
|
|
9
9
|
docID,
|
|
10
10
|
drawerSlug,
|
|
11
11
|
initialData,
|
|
12
|
+
locale,
|
|
12
13
|
overrideEntityVisibility,
|
|
13
14
|
redirectAfterDelete,
|
|
14
15
|
redirectAfterDuplicate,
|
|
@@ -120,6 +121,7 @@ export const renderDocumentHandler = async args => {
|
|
|
120
121
|
docID,
|
|
121
122
|
globalConfig: payload.config.globals.find(global => global.slug === collectionSlug),
|
|
122
123
|
languageOptions: undefined,
|
|
124
|
+
locale,
|
|
123
125
|
permissions,
|
|
124
126
|
req,
|
|
125
127
|
translations: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderDocument","renderDocumentHandler","args","collectionSlug","disableActions","docID","drawerSlug","initialData","overrideEntityVisibility","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferences","preferencesKey","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","data","Document","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams"],"sources":["../../../src/views/Document/handleServerFunction.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderDocument","renderDocumentHandler","args","collectionSlug","disableActions","docID","drawerSlug","initialData","locale","overrideEntityVisibility","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferences","preferencesKey","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","data","Document","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams"],"sources":["../../../src/views/Document/handleServerFunction.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n FormState,\n Locale,\n PayloadRequest,\n VisibleEntities,\n} from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { getAccessResults, isEntityHidden, parseCookies } from 'payload'\n\nimport { renderDocument } from './index.js'\n\ntype RenderDocumentResult = {\n data: any\n Document: React.ReactNode\n preferences: DocumentPreferences\n}\n\nexport const renderDocumentHandler = async (args: {\n collectionSlug: string\n disableActions?: boolean\n docID: string\n drawerSlug?: string\n initialData?: Data\n initialState?: FormState\n locale?: Locale\n overrideEntityVisibility?: boolean\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n req: PayloadRequest\n}): Promise<RenderDocumentResult> => {\n const {\n collectionSlug,\n disableActions,\n docID,\n drawerSlug,\n initialData,\n locale,\n overrideEntityVisibility,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: req.payload.importMap,\n })\n\n let preferences: DocumentPreferences\n\n if (docID) {\n const preferencesKey = `${collectionSlug}-edit-${docID}`\n\n preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as DocumentPreferences)\n }\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { data, Document } = await renderDocument({\n clientConfig,\n disableActions,\n drawerSlug,\n importMap: payload.importMap,\n initialData,\n initPageResult: {\n collectionConfig: payload.config.collections.find(\n (collection) => collection.slug === collectionSlug,\n ),\n cookies,\n docID,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug, docID],\n },\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n })\n\n return {\n data,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FE,MAAM,CAACC,OAAA;EACZ;EAEA,MAAME,WAAA,GAAc,MAAMxD,gBAAA,CAAiB;IACzCe;EACF;EAEA,MAAM;IAAE0C,IAAI;IAAEC;EAAQ,CAAE,GAAG,MAAMvD,cAAA,CAAe;IAC9CkC,YAAA;IACA9B,cAAA;IACAE,UAAA;IACA6B,SAAA,EAAWrB,OAAA,CAAQqB,SAAS;IAC5B5B,WAAA;IACAiD,cAAA,EAAgB;MACdC,gBAAA,EAAkB3C,OAAA,CAAQC,MAAM,CAACQ,WAAW,CAACK,IAAI,CAC9CT,UAAA,IAAeA,UAAA,CAAW6B,IAAI,KAAK7C,cAAA;MAEtCc,OAAA;MACAZ,KAAA;MACAqD,YAAA,EAAc5C,OAAA,CAAQC,MAAM,CAACqC,OAAO,CAACxB,IAAI,CAAE+B,MAAA,IAAWA,MAAA,CAAOX,IAAI,KAAK7C,cAAA;MACtEyD,eAAA,EAAiBC,SAAA;MACjBrD,MAAA;MACA6C,WAAA;MACAzC,GAAA;MACAkD,YAAA,EAAcD,SAAA;MACdf;IACF;IACArC,wBAAA;IACAsD,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAe7D,cAAA,EAAgBE,KAAA;IAC5C;IACAK,mBAAA;IACAC,sBAAA;IACAsD,YAAA,EAAc,CAAC;EACjB;EAEA,OAAO;IACLX,IAAA;IACAC,QAAA;IACAnB;EACF;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1-canary.33ecab2",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"sass": "1.77.4",
|
|
80
80
|
"sonner": "^1.7.0",
|
|
81
81
|
"uuid": "10.0.0",
|
|
82
|
-
"@payloadcms/graphql": "3.12.
|
|
83
|
-
"@payloadcms/translations": "3.12.
|
|
84
|
-
"@payloadcms/ui": "3.12.
|
|
82
|
+
"@payloadcms/graphql": "3.12.1-canary.33ecab2",
|
|
83
|
+
"@payloadcms/translations": "3.12.1-canary.33ecab2",
|
|
84
|
+
"@payloadcms/ui": "3.12.1-canary.33ecab2"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@babel/cli": "7.25.9",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
"esbuild-sass-plugin": "3.3.1",
|
|
100
100
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
101
101
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
102
|
+
"@payloadcms/eslint-config": "3.9.0",
|
|
103
|
+
"payload": "3.12.1-canary.33ecab2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"graphql": "^16.8.1",
|
|
107
107
|
"next": "^15.0.0",
|
|
108
|
-
"payload": "3.12.
|
|
108
|
+
"payload": "3.12.1-canary.33ecab2"
|
|
109
109
|
},
|
|
110
110
|
"engines": {
|
|
111
111
|
"node": "^18.20.2 || >=20.9.0"
|