@payloadcms/next 3.74.0-internal.b78b222 → 3.74.0
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/auth/login.d.ts +12 -9
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -2
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +1 -2
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +5 -7
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts +13 -2
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js +0 -6
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +0 -6
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +1 -7
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +7 -5
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Document/index.js +3 -3
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/renderDocumentSlots.d.ts +2 -3
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +2 -9
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +7 -7
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/package.json +7 -7
package/dist/auth/login.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type LoginWithEmail
|
|
3
|
-
collection:
|
|
4
|
-
config:
|
|
1
|
+
import type { CollectionSlug } from 'payload';
|
|
2
|
+
type LoginWithEmail = {
|
|
3
|
+
collection: CollectionSlug;
|
|
4
|
+
config: any;
|
|
5
5
|
email: string;
|
|
6
6
|
password: string;
|
|
7
7
|
username?: never;
|
|
8
8
|
};
|
|
9
|
-
type LoginWithUsername
|
|
10
|
-
collection:
|
|
11
|
-
config:
|
|
9
|
+
type LoginWithUsername = {
|
|
10
|
+
collection: CollectionSlug;
|
|
11
|
+
config: any;
|
|
12
12
|
email?: never;
|
|
13
13
|
password: string;
|
|
14
14
|
username: string;
|
|
15
15
|
};
|
|
16
|
-
type LoginArgs
|
|
17
|
-
export declare function login
|
|
16
|
+
type LoginArgs = LoginWithEmail | LoginWithUsername;
|
|
17
|
+
export declare function login({ collection, config, email, password, username }: LoginArgs): Promise<{
|
|
18
|
+
token?: string;
|
|
19
|
+
user: any;
|
|
20
|
+
}>;
|
|
18
21
|
export {};
|
|
19
22
|
//# sourceMappingURL=login.d.ts.map
|
package/dist/auth/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,cAAc,CAAA;IAC1B,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,cAAc,CAAA;IAC1B,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,KAAK,SAAS,GAAG,cAAc,GAAG,iBAAiB,CAAA;AAEnD,wBAAsB,KAAK,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC;IACjG,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;CACV,CAAC,CAqDD"}
|
package/dist/auth/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail = {\n collection: CollectionSlug\n config: any\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername = {\n collection: CollectionSlug\n config: any\n email?: never\n password: string\n username: string\n}\ntype LoginArgs = LoginWithEmail | LoginWithUsername\n\nexport async function login({ collection, config, email, password, username }: LoginArgs): Promise<{\n token?: string\n user: any\n}> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"mappings":"AAAA;;AAIA,SAASA,UAAU,QAAQ;AAE3B,SAASC,oBAAoB,QAAQ;AAmBrC,OAAO,eAAeC,MAAM;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAQ,CAAa;EAItF,MAAMC,OAAA,GAAU,MAAMR,UAAA,CAAW;IAAEI,MAAA;IAAQK,IAAA,EAAM;EAAK;EAEtD,MAAMC,UAAA,GAAaF,OAAA,CAAQG,WAAW,CAACR,UAAA,CAAW,EAAEC,MAAA,CAAOQ,IAAA;EAE3D,IAAI,CAACF,UAAA,EAAY;IACf,MAAM,IAAIG,KAAA,CAAM,wCAAwCV,UAAA,EAAY;EACtE;EAEA,MAAMW,iBAAA,GAAoBJ,UAAA,EAAYI,iBAAA,IAAqB;EAE3D,IAAIA,iBAAA,EAAmB;IACrB,IAAIA,iBAAA,CAAkBC,eAAe,EAAE;MACrC,IAAI,CAACV,KAAA,IAAS,CAACE,QAAA,EAAU;QACvB,MAAM,IAAIM,KAAA,CAAM;MAClB;IACF,OAAO;MACL,IAAI,CAACN,QAAA,EAAU;QACb,MAAM,IAAIM,KAAA,CAAM;MAClB;IACF;EACF,OAAO;IACL,IAAI,CAACR,KAAA,EAAO;MACV,MAAM,IAAIQ,KAAA,CAAM;IAClB;EACF;EAEA,IAAIG,SAAA;EAEJ,IAAIF,iBAAA,EAAmB;IACrBE,SAAA,GAAYT,QAAA,GAAW;MAAED,QAAA;MAAUC;IAAS,IAAI;MAAEF,KAAA;MAAOC;IAAS;EACpE,OAAO;IACLU,SAAA,GAAY;MAAEX,KAAA;MAAOC;IAAS;EAChC;EAEA,MAAMW,MAAA,GAAS,MAAMT,OAAA,CAAQN,KAAK,CAAC;IACjCC,UAAA;IACAe,IAAA,EAAMF;EACR;EAEA,IAAIC,MAAA,CAAOE,KAAK,EAAE;IAChB,MAAMlB,oBAAA,CAAqB;MACzBS,UAAA;MACAU,YAAA,EAAcZ,OAAA,CAAQJ,MAAM,CAACgB,YAAY;MACzCD,KAAA,EAAOF,MAAA,CAAOE;IAChB;EACF;EAEA,IAAI,8BAA8Bf,MAAA,IAAUA,MAAA,CAAOiB,wBAAwB,EAAE;IAC3E,OAAOJ,MAAA,CAAOE,KAAK;EACrB;EAEA,OAAOF,MAAA;AACT","ignoreList":[]}
|
package/dist/auth/logout.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
2
|
export declare function logout({ allSessions, config, }: {
|
|
3
3
|
allSessions?: boolean;
|
|
4
|
-
config:
|
|
4
|
+
config: Promise<SanitizedConfig> | SanitizedConfig;
|
|
5
5
|
}): Promise<{
|
|
6
6
|
message: string;
|
|
7
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,wBAAsB,MAAM,CAAC,EAC3B,WAAmB,EACnB,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;CACnD;;;GA8BA"}
|
package/dist/auth/logout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,UAAU,EAAEC,OAAA,IAAWC,WAAW,QAAQ;AAC9D,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAE5D,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,OAAO;EAC3BC,WAAA,GAAc,KAAK;EACnBC;AAAM,CAIP;EACC,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,UAAA,GAAa,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAEhD,IAAI,CAACW,UAAA,CAAWE,IAAI,EAAE;IACpB,OAAO;MAAEC,OAAA,EAAS;MAA2BC,OAAA,EAAS;IAAK;EAC7D;EAEA,MAAM;IAAEF;EAAI,CAAE,GAAGF,UAAA;EACjB,MAAMK,GAAA,GAAM,MAAMd,cAAA,CAAe;IAAEW;EAAK,GAAGJ,OAAA;EAC3C,MAAMQ,UAAA,GAAaR,OAAA,CAAQS,WAAW,CAACL,IAAA,CAAKI,UAAU,CAAC;EAEvD,MAAME,YAAA,GAAe,MAAMf,eAAA,CAAgB;IACzCG,WAAA;IACAU,UAAA;IACAD;EACF;EAEA,IAAI,CAACG,YAAA,EAAc;IACjB,OAAO;MAAEL,OAAA,EAAS;MAAiBC,OAAA,EAAS;IAAM;EACpD;EAEA,MAAMK,cAAA,GAAiB,MAAMf,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACa,YAAY;EAC7E,IAAID,cAAA,EAAgB;IAClB,MAAMtB,OAAA,GAAU,MAAMC,UAAA;IACtBD,OAAA,CAAQwB,MAAM,CAACF,cAAA,CAAeG,IAAI;EACpC;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
package/dist/auth/refresh.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAUA,wBAAsB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,GAAG,CAAA;CAAE;;;GAuCxD"}
|
package/dist/auth/refresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: any }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAAmB;EACvD,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,MAAA,GAAS,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAE5C,IAAI,CAACW,MAAA,CAAOE,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMC,cAAA,GAAiB,MAAMV,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACQ,YAAY;EAC7E,IAAI,CAACD,cAAA,EAAgB;IACnB,OAAO;MAAEE,OAAA,EAAS;MAAmCC,OAAA,EAAS;IAAM;EACtE;EAEA,MAAMC,UAAA,GAAyCR,MAAA,CAAOE,IAAI,CAACM,UAAU;EACrE,MAAMC,gBAAA,GAAmBX,OAAA,CAAQY,WAAW,CAACF,UAAA,CAAW;EAExD,IAAI,CAACC,gBAAA,EAAkBZ,MAAA,CAAOI,IAAA,EAAM;IAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCK,UAAA,EAAY;EACtE;EAEA,MAAMG,GAAA,GAAM,MAAMpB,cAAA,CAAe;IAAEW,IAAA,EAAMF,MAAA,CAAOE;EAAK,GAAGJ,OAAA;EAExD,MAAMc,aAAA,GAAgB,MAAMnB,gBAAA,CAAiB;IAC3Ce,UAAA,EAAYC,gBAAA;IACZE;EACF;EAEA,IAAI,CAACC,aAAA,EAAe;IAClB,OAAO;MAAEN,OAAA,EAAS;MAAwBC,OAAA,EAAS;IAAM;EAC3D;EAEA,MAAMZ,oBAAA,CAAqB;IACzBkB,UAAA,EAAYJ,gBAAA,CAAiBZ,MAAM,CAACI,IAAI;IACxCI,YAAA,EAAcP,OAAA,CAAQD,MAAM,CAACQ,YAAY;IACzCS,KAAA,EAAOF,aAAA,CAAcG;EACvB;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AA+BpE,eAAO,MAAM,qBAAqB,EAAE,qBAiCnC,CAAA"}
|
|
@@ -33,9 +33,6 @@ export const handleServerFunctions = async args => {
|
|
|
33
33
|
serverFunctions: extraServerFunctions
|
|
34
34
|
} = args;
|
|
35
35
|
const {
|
|
36
|
-
cookies,
|
|
37
|
-
locale,
|
|
38
|
-
permissions,
|
|
39
36
|
req
|
|
40
37
|
} = await initReq({
|
|
41
38
|
configPromise,
|
|
@@ -44,13 +41,14 @@ export const handleServerFunctions = async args => {
|
|
|
44
41
|
});
|
|
45
42
|
const augmentedArgs = {
|
|
46
43
|
...fnArgs,
|
|
47
|
-
cookies,
|
|
48
44
|
importMap,
|
|
49
|
-
locale,
|
|
50
|
-
permissions,
|
|
51
45
|
req
|
|
52
46
|
};
|
|
53
|
-
const
|
|
47
|
+
const serverFunctions = {
|
|
48
|
+
...baseServerFunctions,
|
|
49
|
+
...(extraServerFunctions || {})
|
|
50
|
+
};
|
|
51
|
+
const fn = serverFunctions[fnKey];
|
|
54
52
|
if (!fn) {
|
|
55
53
|
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
56
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","req","key","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { _internal_renderFieldHandler, copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { getDefaultLayoutHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js'\nimport { renderWidgetHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\nimport { slugifyHandler } from './slugify.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'table-state': buildTableStateHandler,\n}\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs: Parameters<ServerFunction>[0] = {\n ...fnArgs,\n importMap,\n req,\n }\n\n const serverFunctions = {\n ...baseServerFunctions,\n ...(extraServerFunctions || {}),\n }\n\n const fn = serverFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n return fn(augmentedArgs)\n}\n"],"mappings":"AAEA,SAASA,4BAA4B,EAAEC,yBAAyB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,uCAAuC,QAAQ;AACxD,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,OAAO,QAAQ;AACxB,SAASC,cAAc,QAAQ;AAE/B,MAAMC,mBAAA,GAAgE;EACpE,yBAAyBZ,yBAAA;EACzB,cAAcC,qBAAA;EACd,sBAAsBI,uBAAA;EACtB,yCAAyCF,uCAAA;EACzC,mBAAmBI,qBAAA;EACnB,yBAAyBC,0BAAA;EACzB,gBAAgBT,4BAAA;EAChB,eAAeU,iBAAA;EACf,iBAAiBH,mBAAA;EACjB,oBAAoBF,sBAAA;EACpBS,OAAA,EAASF,cAAA;EACT,eAAeT;AACjB;AAEA,OAAO,MAAMY,qBAAA,GAA+C,MAAOC,IAAA;EACjE,MAAM;IACJC,IAAA,EAAMC,KAAK;IACXF,IAAA,EAAMG,MAAM;IACZC,MAAA,EAAQC,aAAa;IACrBC,SAAS;IACTC,eAAA,EAAiBC;EAAoB,CACtC,GAAGR,IAAA;EAEJ,MAAM;IAAES;EAAG,CAAE,GAAG,MAAMd,OAAA,CAAQ;IAC5BU,aAAA;IACAC,SAAA;IACAI,GAAA,EAAK;EACP;EAEA,MAAMC,aAAA,GAA+C;IACnD,GAAGR,MAAM;IACTG,SAAA;IACAG;EACF;EAEA,MAAMF,eAAA,GAAkB;IACtB,GAAGV,mBAAmB;IACtB,IAAIW,oBAAA,IAAwB,CAAC,CAAC;EAChC;EAEA,MAAMI,EAAA,GAAKL,eAAe,CAACL,KAAA,CAAM;EAEjC,IAAI,CAACU,EAAA,EAAI;IACP,MAAM,IAAIC,KAAA,CAAM,4BAA4BX,KAAA,EAAO;EACrD;EAEA,OAAOU,EAAA,CAAGD,aAAA;AACZ","ignoreList":[]}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AcceptedLanguages } from '@payloadcms/translations';
|
|
2
|
+
import type { ImportMap, Locale, PayloadRequest, SanitizedConfig, SanitizedPermissions } from 'payload';
|
|
3
|
+
import { headers as getHeaders } from 'next/headers.js';
|
|
2
4
|
import { createLocalReq } from 'payload';
|
|
5
|
+
type Result = {
|
|
6
|
+
cookies: Map<string, string>;
|
|
7
|
+
headers: Awaited<ReturnType<typeof getHeaders>>;
|
|
8
|
+
languageCode: AcceptedLanguages;
|
|
9
|
+
locale?: Locale;
|
|
10
|
+
permissions: SanitizedPermissions;
|
|
11
|
+
req: PayloadRequest;
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* Initializes a full request object, including the `req` object and access control.
|
|
5
15
|
* As access control and getting the request locale is dependent on the current URL and
|
|
@@ -10,5 +20,6 @@ export declare const initReq: ({ canSetHeaders, configPromise, importMap, key, o
|
|
|
10
20
|
importMap: ImportMap;
|
|
11
21
|
key: string;
|
|
12
22
|
overrides?: Parameters<typeof createLocalReq>[0];
|
|
13
|
-
}) => Promise<
|
|
23
|
+
}) => Promise<Result>;
|
|
24
|
+
export {};
|
|
14
25
|
//# sourceMappingURL=initReq.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,0BAA0B,CAAA;AACnF,OAAO,KAAK,EACV,SAAS,EACT,MAAM,EAEN,cAAc,EACd,eAAe,EACf,oBAAoB,EAErB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAKhB,KAAK,MAAM,GAAG;IACZ,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAA;IAC/C,YAAY,EAAE,iBAAiB,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,oBAAoB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAcD;;;GAGG;AACH,eAAO,MAAM,OAAO,iEAMjB;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CACjD,KAAG,OAAO,CAAC,MAAM,CA0FjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type {
|
|
1
|
+
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type { AcceptedLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type {\n ImportMap,\n Locale,\n Payload,\n PayloadRequest,\n SanitizedConfig,\n SanitizedPermissions,\n TypedUser,\n} from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { headers as getHeaders } from 'next/headers.js'\nimport {\n createLocalReq,\n executeAuthStrategies,\n getAccessResults,\n getPayload,\n getRequestLanguage,\n parseCookies,\n} from 'payload'\n\nimport { getRequestLocale } from './getRequestLocale.js'\nimport { selectiveCache } from './selectiveCache.js'\n\ntype Result = {\n cookies: Map<string, string>\n headers: Awaited<ReturnType<typeof getHeaders>>\n languageCode: AcceptedLanguages\n locale?: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}\n\ntype PartialResult = {\n i18n: I18nClient\n languageCode: AcceptedLanguages\n payload: Payload\n responseHeaders: Headers\n user: null | TypedUser\n}\n\n// Create cache instances for different parts of our application\nconst partialReqCache = selectiveCache<PartialResult>('partialReq')\nconst reqCache = selectiveCache<Result>('req')\n\n/**\n * Initializes a full request object, including the `req` object and access control.\n * As access control and getting the request locale is dependent on the current URL and\n */\nexport const initReq = async function ({\n canSetHeaders,\n configPromise,\n importMap,\n key,\n overrides,\n}: {\n canSetHeaders?: boolean\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n key: string\n overrides?: Parameters<typeof createLocalReq>[0]\n}): Promise<Result> {\n const headers = await getHeaders()\n const cookies = parseCookies(headers)\n\n const partialResult = await partialReqCache.get(async () => {\n const config = await configPromise\n const payload = await getPayload({ config, cron: true, importMap })\n const languageCode = getRequestLanguage({\n config,\n cookies,\n headers,\n })\n\n const i18n: I18nClient = await initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers,\n payload,\n })\n\n return {\n i18n,\n languageCode,\n payload,\n responseHeaders,\n user,\n }\n }, 'global')\n\n return reqCache\n .get(async () => {\n const { i18n, languageCode, payload, responseHeaders, user } = partialResult\n\n const { req: reqOverrides, ...optionsOverrides } = overrides || {}\n\n const req = await createLocalReq(\n {\n req: {\n headers,\n host: headers.get('host'),\n i18n: i18n as I18n,\n responseHeaders,\n user,\n ...(reqOverrides || {}),\n },\n ...(optionsOverrides || {}),\n },\n payload,\n )\n\n const locale = await getRequestLocale({\n req,\n })\n\n req.locale = locale?.code\n\n const permissions = await getAccessResults({\n req,\n })\n\n return {\n cookies,\n headers,\n languageCode,\n locale,\n permissions,\n req,\n }\n }, key)\n .then((result) => {\n // CRITICAL: Create a shallow copy of req before returning to prevent\n // mutations from propagating to the cached req object.\n // This ensures parallel operations using the same cache key don't affect each other.\n return {\n ...result,\n req: {\n ...result.req,\n ...(result.req?.context\n ? {\n context: { ...result.req.context },\n }\n : {}),\n },\n }\n })\n}\n"],"mappings":"AAWA,SAASA,QAAQ,QAAQ;AACzB,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,YAAY,QACP;AAEP,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAmB/B;AACA,MAAMC,eAAA,GAAkBD,cAAA,CAA8B;AACtD,MAAME,QAAA,GAAWF,cAAA,CAAuB;AAExC;;;;AAIA,OAAO,MAAMG,OAAA,GAAU,eAAAA,CAAgB;EACrCC,aAAa;EACbC,aAAa;EACbC,SAAS;EACTC,GAAG;EACHC;AAAS,CAOV;EACC,MAAMjB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sB;IACF;IAEAA,GAAA,CAAII,MAAM,GAAGA,MAAA,EAAQC,IAAA;IAErB,MAAMC,WAAA,GAAc,MAAMhC,gBAAA,CAAiB;MACzC0B;IACF;IAEA,OAAO;MACLZ,OAAA;MACAlB,OAAA;MACAwB,YAAA;MACAU,MAAA;MACAE,WAAA;MACAN;IACF;EACF,GAAGd,GAAA,EACFqB,IAAI,CAAEC,MAAA;IACL;IACA;IACA;IACA,OAAO;MACL,GAAGA,MAAM;MACTR,GAAA,EAAK;QACH,GAAGQ,MAAA,CAAOR,GAAG;QACb,IAAIQ,MAAA,CAAOR,GAAG,EAAEJ,OAAA,GACZ;UACEA,OAAA,EAAS;YAAE,GAAGY,MAAA,CAAOR,GAAG,CAACJ;UAAQ;QACnC,IACA,CAAC,CAAC;MACR;IACF;EACF;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,8BA0CrE"}
|
|
@@ -15,9 +15,6 @@ export async function ModularDashboard(props) {
|
|
|
15
15
|
user
|
|
16
16
|
} = props;
|
|
17
17
|
const {
|
|
18
|
-
cookies,
|
|
19
|
-
locale,
|
|
20
|
-
permissions,
|
|
21
18
|
req
|
|
22
19
|
} = props.initPageResult;
|
|
23
20
|
const {
|
|
@@ -31,9 +28,6 @@ export async function ModularDashboard(props) {
|
|
|
31
28
|
Component: widgets.find(widget => widget.slug === widgetSlug)?.ComponentPath,
|
|
32
29
|
importMap,
|
|
33
30
|
serverProps: {
|
|
34
|
-
cookies,
|
|
35
|
-
locale,
|
|
36
|
-
permissions,
|
|
37
31
|
req,
|
|
38
32
|
widgetSlug
|
|
39
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RenderServerComponent","React","getPreferences","ModularDashboardClient","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","
|
|
1
|
+
{"version":3,"file":"index.js","names":["RenderServerComponent","React","getPreferences","ModularDashboardClient","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","req","initPageResult","i18n","layout","getItemsFromPreferences","getItemsFromConfig","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","clientWidgets","_","label","rest","t","_jsx","clientLayout","savedPreferences","collection","value","layouts","widgetInstances","widgetInstance","index","maxWidth","minWidth","width"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type {\n BasePayload,\n ClientWidget,\n DashboardConfig,\n PayloadRequest,\n TypedUser,\n Widget,\n WidgetInstance,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient, WidgetItem } from './index.client.js'\n\nimport { getPreferences } from '../../../../utilities/getPreferences.js'\nimport { ModularDashboardClient } from './index.client.js'\nimport './index.scss'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n req,\n widgetSlug,\n // TODO: widgets will support state in the future\n // widgetData: layoutItem.data,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { ComponentPath: _, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n\nasync function getItemsFromPreferences(\n payload: BasePayload,\n user: TypedUser,\n): Promise<null | WidgetItem[]> {\n const savedPreferences = await getPreferences(\n 'dashboard-layout',\n payload,\n user.id,\n user.collection,\n )\n if (\n !savedPreferences?.value ||\n typeof savedPreferences.value !== 'object' ||\n !('layouts' in savedPreferences.value)\n ) {\n return null\n }\n return savedPreferences.value.layouts as null | WidgetItem[]\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances: WidgetInstance[]\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((widget) => widget.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget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nB,MAAA,EAAQmB,QAAA,IAAY;MAC9BC,QAAA,EAAUpB,MAAA,EAAQoB,QAAA,IAAY;MAC9BC,KAAA,EAAOJ,cAAA,CAAeI,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,CA2B5C,CAAA"}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js
CHANGED
|
@@ -4,9 +4,6 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
|
|
|
4
4
|
* Used when resetting the dashboard to its default configuration.
|
|
5
5
|
*/
|
|
6
6
|
export const getDefaultLayoutHandler = async ({
|
|
7
|
-
cookies,
|
|
8
|
-
locale,
|
|
9
|
-
permissions,
|
|
10
7
|
req
|
|
11
8
|
}) => {
|
|
12
9
|
if (!req.user) {
|
|
@@ -27,9 +24,6 @@ export const getDefaultLayoutHandler = async ({
|
|
|
27
24
|
Component: widgets.find(widget => widget.slug === widgetSlug)?.ComponentPath,
|
|
28
25
|
importMap,
|
|
29
26
|
serverProps: {
|
|
30
|
-
cookies,
|
|
31
|
-
locale,
|
|
32
|
-
permissions,
|
|
33
27
|
req,
|
|
34
28
|
widgetSlug
|
|
35
29
|
}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ req }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n req,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AAUtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC;AAAG,CAAE;EAChB,IAAI,CAACA,GAAA,CAAIC,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AA,CAAeb,UAAU,IAAIc,KAAA,EAAO;MAC3CE,QAAA,EAAUT,MAAA,EAAQS,QAAA,IAAY;MAC9BC,QAAA,EAAUV,MAAA,EAAQU,QAAA,IAAY;MAC9BC,KAAA,EAAOL,cAAA,CAAeK,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IAGH;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IAGH;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,CAwE/B,CAAA"}
|
|
@@ -5,11 +5,8 @@ import React from 'react';
|
|
|
5
5
|
* Similar to render-field but specifically for dashboard widgets.
|
|
6
6
|
*/
|
|
7
7
|
export const renderWidgetHandler = ({
|
|
8
|
-
cookies,
|
|
9
|
-
locale,
|
|
10
|
-
permissions,
|
|
11
8
|
req,
|
|
12
|
-
widgetSlug
|
|
9
|
+
/* widgetData, */widgetSlug
|
|
13
10
|
}) => {
|
|
14
11
|
if (!req.user) {
|
|
15
12
|
throw new Error('Unauthorized');
|
|
@@ -41,9 +38,6 @@ export const renderWidgetHandler = ({
|
|
|
41
38
|
const serverProps = {
|
|
42
39
|
req,
|
|
43
40
|
// TODO: widgetData: widgetData || {},
|
|
44
|
-
cookies,
|
|
45
|
-
locale,
|
|
46
|
-
permissions,
|
|
47
41
|
widgetSlug
|
|
48
42
|
};
|
|
49
43
|
// Render the widget server component
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","renderWidgetHandler","
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","renderWidgetHandler","req","widgetSlug","user","Error","widgets","payload","config","admin","dashboard","importMap","widgetConfig","find","widget","slug","component","createElement","style","background","border","borderRadius","color","padding","textAlign","serverProps","Component","ComponentPath","error","errorMessage","message","String","logger","err","msg"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"sourcesContent":["import type { ServerFunction, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nexport type RenderWidgetServerFnArgs = {\n /**\n * Instance-specific data for this widget\n */\n // TODO: widgets will support state in the future\n // widgetData?: Record<string, unknown>\n /**\n * The slug of the widget to render\n */\n widgetSlug: string\n}\n\nexport type RenderWidgetServerFnReturnType = {\n component: React.ReactNode\n}\n\n/**\n * Server function to render a widget on-demand.\n * Similar to render-field but specifically for dashboard widgets.\n */\nexport const renderWidgetHandler: ServerFunction<\n RenderWidgetServerFnArgs,\n RenderWidgetServerFnReturnType\n> = ({ req, /* widgetData, */ widgetSlug }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { widgets } = req.payload.config.admin.dashboard\n const { importMap } = req.payload\n\n // Find the widget configuration\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n\n if (!widgetConfig) {\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-elevation-50)',\n border: '1px solid var(--theme-elevation-200)',\n borderRadius: '4px',\n color: 'var(--theme-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n `Widget \"${widgetSlug}\" not found`,\n ),\n }\n }\n\n try {\n // Create server props for the widget\n const serverProps: WidgetServerProps = {\n req,\n // TODO: widgetData: widgetData || {},\n widgetSlug,\n }\n\n // Render the widget server component\n const component = RenderServerComponent({\n Component: widgetConfig.ComponentPath,\n importMap,\n serverProps,\n })\n\n return { component }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n req.payload.logger.error({\n err: error,\n msg: `Error rendering widget \"${widgetSlug}\": ${errorMessage}`,\n })\n\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-error-50)',\n border: '1px solid var(--theme-error-200)',\n borderRadius: '4px',\n color: 'var(--theme-error-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n 'Error loading widget',\n ),\n }\n }\n}\n"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAkBlB;;;;AAIA,OAAO,MAAMC,mBAAA,GAGTA,CAAC;EAAEC,GAAG;EAAE,iBAAkBC;AAAU,CAAE;EACxC,IAAI,CAACD,GAAA,CAAIE,IAAI,EAAE;IACb,MAAM,IA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;MACF,GACA;IAEJ;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAUlE,eAAO,MAAM,qBAAqB,EAAE,4BA0HnC,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
2
|
-
import {
|
|
2
|
+
import { headers as getHeaders } from 'next/headers.js';
|
|
3
|
+
import { canAccessAdmin, getAccessResults, isEntityHidden, parseCookies } from 'payload';
|
|
3
4
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
4
5
|
import { renderDocument } from './index.js';
|
|
5
6
|
export const renderDocumentHandler = async args => {
|
|
6
7
|
const {
|
|
7
8
|
collectionSlug,
|
|
8
|
-
cookies,
|
|
9
9
|
disableActions,
|
|
10
10
|
docID,
|
|
11
11
|
drawerSlug,
|
|
@@ -13,7 +13,6 @@ export const renderDocumentHandler = async args => {
|
|
|
13
13
|
locale,
|
|
14
14
|
overrideEntityVisibility,
|
|
15
15
|
paramsOverride,
|
|
16
|
-
permissions,
|
|
17
16
|
redirectAfterCreate,
|
|
18
17
|
redirectAfterDelete,
|
|
19
18
|
redirectAfterDuplicate,
|
|
@@ -29,6 +28,8 @@ export const renderDocumentHandler = async args => {
|
|
|
29
28
|
searchParams = {},
|
|
30
29
|
versions
|
|
31
30
|
} = args;
|
|
31
|
+
const headers = await getHeaders();
|
|
32
|
+
const cookies = parseCookies(headers);
|
|
32
33
|
await canAccessAdmin({
|
|
33
34
|
req
|
|
34
35
|
});
|
|
@@ -87,6 +88,9 @@ export const renderDocumentHandler = async args => {
|
|
|
87
88
|
user
|
|
88
89
|
}) ? slug : null).filter(Boolean)
|
|
89
90
|
};
|
|
91
|
+
const permissions = await getAccessResults({
|
|
92
|
+
req
|
|
93
|
+
});
|
|
90
94
|
const {
|
|
91
95
|
data,
|
|
92
96
|
Document
|
|
@@ -110,13 +114,11 @@ export const renderDocumentHandler = async args => {
|
|
|
110
114
|
translations: undefined,
|
|
111
115
|
visibleEntities
|
|
112
116
|
},
|
|
113
|
-
locale,
|
|
114
117
|
overrideEntityVisibility,
|
|
115
118
|
params: paramsOverride ?? {
|
|
116
119
|
segments: ['collections', collectionSlug, String(docID)]
|
|
117
120
|
},
|
|
118
121
|
payload,
|
|
119
|
-
permissions,
|
|
120
122
|
redirectAfterCreate,
|
|
121
123
|
redirectAfterDelete,
|
|
122
124
|
redirectAfterDuplicate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","applyLocaleFiltering","renderDocument","renderDocumentHandler","args","collectionSlug","
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","canAccessAdmin","getAccessResults","isEntityHidden","parseCookies","applyLocaleFiltering","renderDocument","renderDocumentHandler","args","collectionSlug","disableActions","docID","drawerSlug","initialData","locale","overrideEntityVisibility","paramsOverride","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","searchParams","versions","cookies","clientConfig","importMap","preferences","preferencesKey","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","permissions","data","Document","documentSubViewType","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","String","viewType"],"sources":["../../../src/views/Document/handleServerFunction.tsx"],"sourcesContent":["import type { RenderDocumentServerFunction } from '@payloadcms/ui'\nimport type { DocumentPreferences, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { canAccessAdmin, getAccessResults, isEntityHidden, parseCookies } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderDocument } from './index.js'\n\nexport const renderDocumentHandler: RenderDocumentServerFunction = async (args) => {\n const {\n collectionSlug,\n disableActions,\n docID,\n drawerSlug,\n initialData,\n locale,\n overrideEntityVisibility,\n paramsOverride,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n searchParams = {},\n versions,\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: req.payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\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 documentSubViewType: 'default',\n drawerSlug,\n i18n,\n importMap: payload.importMap,\n initialData,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\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: paramsOverride ?? {\n segments: ['collections', collectionSlug, String(docID)],\n },\n payload,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams,\n versions,\n viewType: 'document',\n })\n\n return {\n data,\n Document,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAC/E,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,qBAAA,GAAsD,MAAOC,IAAA;EACxE,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,KAAK;IACLC,UAAU;IACVC,WAAW;IACXC,MAAM;IACNC,wBAAwB;IACxBC,cAAc;IACdC,mBAAmB;IACnBC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI,CACL;IACDC,YAAA,GAAe,CAAC,CAAC;IACjBC;EAAQ,CACT,GAAGlB,IAAA;EAEJ,MAAMT,OAAA,GAAU,MAAMC,UAAA;EAEtB,MAAM2B,OAAA,GAAUvB,YAAA,CAAaL,OAAA;EAE7B,MAAME,cAAA,CAAe;IAAEmB;EAAI;EAE3B,MAAMQ,YAAA,GAAe9B,eAAA,CAAgB;IACnCyB,MAAA;IACAF,IAAA;IACAQ,SAAA,EAAWT,GAAA,CAAIE,OAAO,CAACO,SAAS;IAChCL;EACF;EACA,MAAMnB,oBAAA,CAAqB;IAAEuB,YAAA;IAAcL,MAAA;IAAQH;EAAI;EAEvD,IAAIU,WAAA;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AA,EAAWP,OAAA,CAAQO,SAAS;IAC5BhB,WAAA;IACA6C,cAAA,EAAgB;MACdC,gBAAA,EAAkBrC,OAAA,EAASwB,WAAA,GAAcrC,cAAA,CAAe,EAAEc,MAAA;MAC1DI,OAAA;MACAhB,KAAA;MACAiD,YAAA,EAActC,OAAA,CAAQC,MAAM,CAAC8B,OAAO,CAACrB,IAAI,CAAE6B,MAAA,IAAWA,MAAA,CAAOb,IAAI,KAAKvC,cAAA;MACtEqD,eAAA,EAAiBC,SAAA;MACjBjD,MAAA;MACAwC,WAAA;MACAlC,GAAA;MACA4C,YAAA,EAAcD,SAAA;MACdlB;IACF;IACA9B,wBAAA;IACAkD,MAAA,EAAQjD,cAAA,IAAkB;MACxBkD,QAAA,EAAU,CAAC,eAAezD,cAAA,EAAgB0D,MAAA,CAAOxD,KAAA;IACnD;IACAW,OAAA;IACAL,mBAAA;IACAC,mBAAA;IACAC,sBAAA;IACAM,YAAA;IACAC,QAAA;IACA0C,QAAA,EAAU;EACZ;EAEA,OAAO;IACLb,IAAA;IACAC,QAAA;IACA1B;EACF;AACF","ignoreList":[]}
|
|
@@ -59,7 +59,8 @@ export const renderDocument = async ({
|
|
|
59
59
|
routes: {
|
|
60
60
|
admin: adminRoute,
|
|
61
61
|
api: apiRoute
|
|
62
|
-
}
|
|
62
|
+
},
|
|
63
|
+
serverURL
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
user
|
|
@@ -277,8 +278,7 @@ export const renderDocument = async ({
|
|
|
277
278
|
collectionConfig,
|
|
278
279
|
globalConfig,
|
|
279
280
|
hasSavePermission,
|
|
280
|
-
|
|
281
|
-
permissions,
|
|
281
|
+
permissions: docPermissions,
|
|
282
282
|
req
|
|
283
283
|
});
|
|
284
284
|
// Extract Description from documentSlots to pass to DocumentHeader
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\n })\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrE,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AA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,SAAA;YACAwH,WAAA,EAAa/C;UACf;;;OArCCzD,MAAA,EAAQmD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAesD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAM/H,cAAA,CAAe8H,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEAlJ,QAAA,CAAS;MAAEoJ,GAAA,EAAKF,KAAA;MAAOxG,OAAA,EAASsG,KAAA,CAAMxH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIwG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\n })\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrE,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,gBAAA,GAA6C,MAAOC,IAAA,IAASJ,gBAAA,CAAiBI,IAAA;AAQ3F;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAAAA,CAAO;EACnCC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,wBAAwB;EACxBC,MAAM;EACNC,mBAAmB;EACnBC,mBAAmB;EACnBC,sBAAsB;EACtBC,oBAAoB;EACpBC,YAAY;EACZC,QAAQ;EACRC;AAAQ,CASc;EAItB,MAAM;IACJC,gBAAgB;IAChBC,KAAA,EAAOC,UAAU;IACjBC,YAAY;IACZC,MAAM;IACN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,10 @@
|
|
|
1
|
-
import type { DocumentSlots,
|
|
1
|
+
import type { DocumentSlots, PayloadRequest, SanitizedCollectionConfig, SanitizedDocumentPermissions, SanitizedGlobalConfig, ServerFunction } from 'payload';
|
|
2
2
|
export declare const renderDocumentSlots: (args: {
|
|
3
3
|
collectionConfig?: SanitizedCollectionConfig;
|
|
4
4
|
globalConfig?: SanitizedGlobalConfig;
|
|
5
5
|
hasSavePermission: boolean;
|
|
6
6
|
id?: number | string;
|
|
7
|
-
|
|
8
|
-
permissions: SanitizedPermissions;
|
|
7
|
+
permissions: SanitizedDocumentPermissions;
|
|
9
8
|
req: PayloadRequest;
|
|
10
9
|
}) => DocumentSlots;
|
|
11
10
|
export declare const renderDocumentSlotsHandler: ServerFunction<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,WAAW,EAAE,4BAA4B,CAAA;IACzC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aA+KL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAsBA,CAAA"}
|
|
@@ -8,8 +8,6 @@ export const renderDocumentSlots = args => {
|
|
|
8
8
|
collectionConfig,
|
|
9
9
|
globalConfig,
|
|
10
10
|
hasSavePermission,
|
|
11
|
-
locale,
|
|
12
|
-
permissions,
|
|
13
11
|
req
|
|
14
12
|
} = args;
|
|
15
13
|
const components = {};
|
|
@@ -18,9 +16,7 @@ export const renderDocumentSlots = args => {
|
|
|
18
16
|
const serverProps = {
|
|
19
17
|
id,
|
|
20
18
|
i18n: req.i18n,
|
|
21
|
-
locale,
|
|
22
19
|
payload: req.payload,
|
|
23
|
-
permissions,
|
|
24
20
|
user: req.user
|
|
25
21
|
};
|
|
26
22
|
const BeforeDocumentControls = collectionConfig?.admin?.components?.edit?.beforeDocumentControls || globalConfig?.admin?.components?.elements?.beforeDocumentControls;
|
|
@@ -141,8 +137,6 @@ export const renderDocumentSlotsHandler = async args => {
|
|
|
141
137
|
const {
|
|
142
138
|
id,
|
|
143
139
|
collectionSlug,
|
|
144
|
-
locale,
|
|
145
|
-
permissions,
|
|
146
140
|
req
|
|
147
141
|
} = args;
|
|
148
142
|
const collectionConfig = req.payload.collections[collectionSlug]?.config;
|
|
@@ -150,9 +144,9 @@ export const renderDocumentSlotsHandler = async args => {
|
|
|
150
144
|
throw new Error(req.t('error:incorrectCollection'));
|
|
151
145
|
}
|
|
152
146
|
const {
|
|
147
|
+
docPermissions,
|
|
153
148
|
hasSavePermission
|
|
154
149
|
} = await getDocumentPermissions({
|
|
155
|
-
id,
|
|
156
150
|
collectionConfig,
|
|
157
151
|
data: {},
|
|
158
152
|
req
|
|
@@ -161,8 +155,7 @@ export const renderDocumentSlotsHandler = async args => {
|
|
|
161
155
|
id,
|
|
162
156
|
collectionConfig,
|
|
163
157
|
hasSavePermission,
|
|
164
|
-
|
|
165
|
-
permissions,
|
|
158
|
+
permissions: docPermissions,
|
|
166
159
|
req
|
|
167
160
|
});
|
|
168
161
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","locale","permissions","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","data"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n Locale,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n locale: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, locale, permissions, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n locale,\n payload: req.payload,\n permissions,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.elements?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, locale, permissions, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n}\n"],"mappings":"AAqBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAQUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAE5F,MAAMQ,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBT,gBAAA,EAAkBU,KAAA,EAAOC,OAAA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Ac,GAAG9D,qBAAA,CAAsB;MAChD0B,SAAA,EAAWpB,gBAAA,CAAiBqD,MAAM,CAAC3C,KAAK,CAACJ,UAAU,CAACiD,QAAQ;MAC5DlC,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMmD,0BAAA,GAGR,MAAO3D,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEsC,cAAc;IAAElC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAEzD,MAAME,gBAAA,GAAmBK,GAAA,CAAIS,OAAO,CAAC4C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAAC3D,gBAAA,EAAkB;IACrB,MAAM,IAAI4D,KAAA,CAAMvD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE9B;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzDG,EAAA;IACAC,gBAAA;IACA6D,IAAA,EAAM,CAAC;IACPxD;EACF;EAEA,OAAOR,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAC,MAAA;IACAC,WAAA;IACAC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.elements?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n}\n"],"mappings":"AAoBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAOUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAEvE,MAAMM,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBP,gBAAA,EAAkBQ,KAAA,EAAOC,OAAA,IAAWR,YAAA,EAAcO,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/BX,EAAA;IACAY,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdC,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBC,IAAA,EAAMV,GAAA,CAAIU;EAEZ;EAEA,MAAMC,sBAAA,GACJd,gBAAA,EAAkBQ,KAAA,EAAOJ,UAAA,EAAYW,IAAA,EAAMC,sBAAA,IAC3Cf,YAAA,EAAcO,KAAA,EAAOJ,UAAA,EAAYa,QAAA,EAAUD,sBAAA;EAE7C,IAAIF,sBAAA,EAAwB;IAC1BV,UAAA,CAAWU,sBAAsB,GAAGpB,qBAAA,CAAsB;MACxDwB,SAAA,EAAWJ,sBAAA;MACXK,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChC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6B,cAAc;IAAEzD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACA4D,IAAA,EAAM,CAAC;IACPzD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACA2D,WAAA,EAAaF,cAAA;IACbxD;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAerF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAuHtC,CAAA"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
2
|
-
import {
|
|
2
|
+
import { headers as getHeaders } from 'next/headers.js';
|
|
3
|
+
import { canAccessAdmin, getAccessResults, isEntityHidden, parseCookies, UnauthorizedError } from 'payload';
|
|
3
4
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
4
5
|
import { renderListView } from './index.js';
|
|
5
6
|
export const renderListHandler = async args => {
|
|
6
7
|
const {
|
|
7
8
|
collectionSlug,
|
|
8
|
-
cookies,
|
|
9
9
|
disableActions,
|
|
10
10
|
disableBulkDelete,
|
|
11
11
|
disableBulkEdit,
|
|
12
12
|
disableQueryPresets,
|
|
13
13
|
drawerSlug,
|
|
14
14
|
enableRowSelections,
|
|
15
|
-
locale,
|
|
16
15
|
overrideEntityVisibility,
|
|
17
|
-
permissions,
|
|
18
16
|
query,
|
|
19
17
|
redirectAfterDelete,
|
|
20
18
|
redirectAfterDuplicate,
|
|
@@ -31,6 +29,8 @@ export const renderListHandler = async args => {
|
|
|
31
29
|
if (!req.user) {
|
|
32
30
|
throw new UnauthorizedError();
|
|
33
31
|
}
|
|
32
|
+
const headers = await getHeaders();
|
|
33
|
+
const cookies = parseCookies(headers);
|
|
34
34
|
await canAccessAdmin({
|
|
35
35
|
req
|
|
36
36
|
});
|
|
@@ -86,6 +86,9 @@ export const renderListHandler = async args => {
|
|
|
86
86
|
user
|
|
87
87
|
}) ? slug : null).filter(Boolean)
|
|
88
88
|
};
|
|
89
|
+
const permissions = await getAccessResults({
|
|
90
|
+
req
|
|
91
|
+
});
|
|
89
92
|
const {
|
|
90
93
|
List
|
|
91
94
|
} = await renderListView({
|
|
@@ -103,19 +106,16 @@ export const renderListHandler = async args => {
|
|
|
103
106
|
cookies,
|
|
104
107
|
globalConfig: payload.config.globals.find(global => global.slug === collectionSlug),
|
|
105
108
|
languageOptions: undefined,
|
|
106
|
-
locale,
|
|
107
109
|
permissions,
|
|
108
110
|
req,
|
|
109
111
|
translations: undefined,
|
|
110
112
|
visibleEntities
|
|
111
113
|
},
|
|
112
|
-
locale,
|
|
113
114
|
overrideEntityVisibility,
|
|
114
115
|
params: {
|
|
115
116
|
segments: ['collections', collectionSlug]
|
|
116
117
|
},
|
|
117
118
|
payload,
|
|
118
|
-
permissions,
|
|
119
119
|
query,
|
|
120
120
|
redirectAfterDelete,
|
|
121
121
|
redirectAfterDuplicate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","canAccessAdmin","getAccessResults","isEntityHidden","parseCookies","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","overrideEntityVisibility","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","permissions","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport {\n canAccessAdmin,\n getAccessResults,\n isEntityHidden,\n parseCookies,\n UnauthorizedError,\n} from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n overrideEntityVisibility,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const 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 CollectionPreferences)\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 { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,iBAAiB,QACZ;AACP,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,wBA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"3.74.0
|
|
3
|
+
"version": "3.74.0",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"qs-esm": "7.0.2",
|
|
100
100
|
"sass": "1.77.4",
|
|
101
101
|
"uuid": "10.0.0",
|
|
102
|
-
"@payloadcms/graphql": "3.74.0
|
|
103
|
-
"@payloadcms/translations": "3.74.0
|
|
104
|
-
"@payloadcms/ui": "3.74.0
|
|
102
|
+
"@payloadcms/graphql": "3.74.0",
|
|
103
|
+
"@payloadcms/translations": "3.74.0",
|
|
104
|
+
"@payloadcms/ui": "3.74.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@babel/cli": "7.27.2",
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
"esbuild": "0.27.1",
|
|
119
119
|
"esbuild-sass-plugin": "3.3.1",
|
|
120
120
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
121
|
-
"
|
|
122
|
-
"
|
|
121
|
+
"payload": "3.74.0",
|
|
122
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"graphql": "^16.8.1",
|
|
126
126
|
"next": "^15.4.10 || >=16.1.1-canary.35 <16.2.0 || ^16.2.0",
|
|
127
|
-
"payload": "3.74.0
|
|
127
|
+
"payload": "3.74.0"
|
|
128
128
|
},
|
|
129
129
|
"engines": {
|
|
130
130
|
"node": "^18.20.2 || >=20.9.0"
|