@payloadcms/next 3.65.0-canary.0 → 3.65.0-canary.10
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/cjs/withPayload.cjs +112 -22
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/exports/utilities.d.ts +4 -3
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +16 -1
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/Document/getDocumentPermissions.d.ts +3 -0
- package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +21 -29
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +25 -5
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts +3 -20
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +14 -14
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +109 -21
- package/dist/withPayload.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
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,SAA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AA;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"}
|
|
@@ -90,6 +90,21 @@ export const initReq = async function ({
|
|
|
90
90
|
permissions,
|
|
91
91
|
req
|
|
92
92
|
};
|
|
93
|
-
}, key)
|
|
93
|
+
}, key).then(result => {
|
|
94
|
+
// CRITICAL: Create a shallow copy of req before returning to prevent
|
|
95
|
+
// mutations from propagating to the cached req object.
|
|
96
|
+
// This ensures parallel operations using the same cache key don't affect each other.
|
|
97
|
+
return {
|
|
98
|
+
...result,
|
|
99
|
+
req: {
|
|
100
|
+
...result.req,
|
|
101
|
+
...(result.req?.context ? {
|
|
102
|
+
context: {
|
|
103
|
+
...result.req.context
|
|
104
|
+
}
|
|
105
|
+
} : {})
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
});
|
|
94
109
|
};
|
|
95
110
|
//# sourceMappingURL=initReq.js.map
|
|
@@ -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"],"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.get(async () => {\n
|
|
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,OAAA,GAAU,MAAMC,UAAA;EACtB,MA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AAGA,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":[]}
|
|
@@ -3,6 +3,9 @@ export declare const getDocumentPermissions: (args: {
|
|
|
3
3
|
collectionConfig?: SanitizedCollectionConfig;
|
|
4
4
|
data: Data;
|
|
5
5
|
globalConfig?: SanitizedGlobalConfig;
|
|
6
|
+
/**
|
|
7
|
+
* When called for creating a new document, id is not provided.
|
|
8
|
+
*/
|
|
6
9
|
id?: number | string;
|
|
7
10
|
req: PayloadRequest;
|
|
8
11
|
}) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,
|
|
1
|
+
{"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAiFA,CAAA"}
|
|
@@ -17,28 +17,24 @@ export const getDocumentPermissions = async args => {
|
|
|
17
17
|
collection: {
|
|
18
18
|
config: collectionConfig
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
...
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
data: {
|
|
21
|
+
...data,
|
|
22
|
+
_status: 'draft'
|
|
23
|
+
},
|
|
24
|
+
req
|
|
27
25
|
});
|
|
28
26
|
if (collectionConfig.versions?.drafts) {
|
|
29
|
-
hasPublishPermission = await docAccessOperation({
|
|
27
|
+
hasPublishPermission = (await docAccessOperation({
|
|
30
28
|
id,
|
|
31
29
|
collection: {
|
|
32
30
|
config: collectionConfig
|
|
33
31
|
},
|
|
34
|
-
|
|
35
|
-
...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}).then(permissions => permissions.update);
|
|
32
|
+
data: {
|
|
33
|
+
...data,
|
|
34
|
+
_status: 'published'
|
|
35
|
+
},
|
|
36
|
+
req
|
|
37
|
+
})).update;
|
|
42
38
|
}
|
|
43
39
|
} catch (err) {
|
|
44
40
|
logError({
|
|
@@ -50,23 +46,19 @@ export const getDocumentPermissions = async args => {
|
|
|
50
46
|
if (globalConfig) {
|
|
51
47
|
try {
|
|
52
48
|
docPermissions = await docAccessOperationGlobal({
|
|
49
|
+
data,
|
|
53
50
|
globalConfig,
|
|
54
|
-
req
|
|
55
|
-
...req,
|
|
56
|
-
data
|
|
57
|
-
}
|
|
51
|
+
req
|
|
58
52
|
});
|
|
59
53
|
if (globalConfig.versions?.drafts) {
|
|
60
|
-
hasPublishPermission = await docAccessOperationGlobal({
|
|
54
|
+
hasPublishPermission = (await docAccessOperationGlobal({
|
|
55
|
+
data: {
|
|
56
|
+
...data,
|
|
57
|
+
_status: 'published'
|
|
58
|
+
},
|
|
61
59
|
globalConfig,
|
|
62
|
-
req
|
|
63
|
-
|
|
64
|
-
data: {
|
|
65
|
-
...data,
|
|
66
|
-
_status: 'published'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}).then(permissions => permissions.update);
|
|
60
|
+
req
|
|
61
|
+
})).update;
|
|
70
62
|
}
|
|
71
63
|
} catch (err) {
|
|
72
64
|
logError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","logError","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","collection","config","_status","versions","drafts","
|
|
1
|
+
{"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","logError","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","collection","config","_status","versions","drafts","update","err","payload","collectionSlug","slug","globalSlug"],"sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"sourcesContent":["import type {\n Data,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport {\n hasSavePermission as getHasSavePermission,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { docAccessOperation, docAccessOperationGlobal, logError } from 'payload'\n\nexport const getDocumentPermissions = async (args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Data\n globalConfig?: SanitizedGlobalConfig\n /**\n * When called for creating a new document, id is not provided.\n */\n id?: number | string\n req: PayloadRequest\n}): Promise<{\n docPermissions: SanitizedDocumentPermissions\n hasPublishPermission: boolean\n hasSavePermission: boolean\n}> => {\n const { id, collectionConfig, data = {}, globalConfig, req } = args\n\n let docPermissions: SanitizedDocumentPermissions\n let hasPublishPermission = false\n\n if (collectionConfig) {\n try {\n docPermissions = await docAccessOperation({\n id,\n collection: {\n config: collectionConfig,\n },\n data: {\n ...data,\n _status: 'draft',\n },\n req,\n })\n\n if (collectionConfig.versions?.drafts) {\n hasPublishPermission = (\n await docAccessOperation({\n id,\n collection: {\n config: collectionConfig,\n },\n data: {\n ...data,\n _status: 'published',\n },\n req,\n })\n ).update\n }\n } catch (err) {\n logError({ err, payload: req.payload })\n }\n }\n\n if (globalConfig) {\n try {\n docPermissions = await docAccessOperationGlobal({\n data,\n globalConfig,\n req,\n })\n\n if (globalConfig.versions?.drafts) {\n hasPublishPermission = (\n await docAccessOperationGlobal({\n data: {\n ...data,\n _status: 'published',\n },\n globalConfig,\n req,\n })\n ).update\n }\n } catch (err) {\n logError({ err, payload: req.payload })\n }\n }\n\n const hasSavePermission = getHasSavePermission({\n collectionSlug: collectionConfig?.slug,\n docPermissions,\n globalSlug: globalConfig?.slug,\n isEditing: getIsEditing({\n id,\n collectionSlug: collectionConfig?.slug,\n globalSlug: globalConfig?.slug,\n }),\n })\n\n return {\n docPermissions,\n hasPublishPermission,\n hasSavePermission,\n }\n}\n"],"mappings":"AAQA,SACEA,iBAAA,IAAqBC,oBAAoB,EACzCC,SAAA,IAAaC,YAAY,QACpB;AACP,SAASC,kBAAkB,EAAEC,wBAAwB,EAAEC,QAAQ,QAAQ;AAEvE,OAAO,MAAMC,sBAAA,GAAyB,MAAOC,IAAA;EAc3C,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,IAAA,GAAO,CAAC,CAAC;IAAEC,YAAY;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAE/D,IAAIM,cAAA;EACJ,IAAIC,oBAAA,GAAuB;EAE3B,IAAIL,gBAAA,EAAkB;IACpB,IAAI;MACFI,cAAA,GAAiB,MAAMV,kBAAA,CAAmB;QACxCK,EAAA;QACAO,UAAA,EAAY;UACVC,MAAA,EAAQP;QACV;QACAC,IAAA,EAAM;UACJ,GAAGA,IAAI;UACPO,OAAA,EAAS;QACX;QACAL;MACF;MAEA,IAAIH,gBAAA,CAAiBS,QAAQ,EAAEC,MAAA,EAAQ;QACrCL,oBAAA,GAAuB,CACrB,MAAMX,kBAAA,CAAmB;UACvBK,EAAA;UACAO,UAAA,EAAY;YACVC,MAAA,EAAQP;UACV;UACAC,IAAA,EAAM;YACJ,GAAGA,IAAI;YACPO,OAAA,EAAS;UACX;UACAL;QACF,EAAC,EACDQ,MAAM;MACV;IACF,EAAE,OAAOC,GAAA,EAAK;MACZhB,QAAA,CAAS;QAAEgB,GAAA;QAAKC,OAAA,EAASV,GAAA,CAAIU;MAAQ;IACvC;EACF;EAEA,IAAIX,YAAA,EAAc;IAChB,IAAI;MACFE,cAAA,GAAiB,MAAMT,wBAAA,CAAyB;QAC9CM,IAAA;QACAC,YAAA;QACAC;MACF;MAEA,IAAID,YAAA,CAAaO,QAAQ,EAAEC,MAAA,EAAQ;QACjCL,oBAAA,GAAuB,CACrB,MAAMV,wBAAA,CAAyB;UAC7BM,IAAA,EAAM;YACJ,GAAGA,IAAI;YACPO,OAAA,EAAS;UACX;UACAN,YAAA;UACAC;QACF,EAAC,EACDQ,MAAM;MACV;IACF,EAAE,OAAOC,GAAA,EAAK;MACZhB,QAAA,CAAS;QAAEgB,GAAA;QAAKC,OAAA,EAASV,GAAA,CAAIU;MAAQ;IACvC;EACF;EAEA,MAAMvB,iBAAA,GAAoBC,oBAAA,CAAqB;IAC7CuB,cAAA,EAAgBd,gBAAA,EAAkBe,IAAA;IAClCX,cAAA;IACAY,UAAA,EAAYd,YAAA,EAAca,IAAA;IAC1BvB,SAAA,EAAWC,YAAA,CAAa;MACtBM,EAAA;MACAe,cAAA,EAAgBd,gBAAA,EAAkBe,IAAA;MAClCC,UAAA,EAAYd,YAAA,EAAca;IAC5B;EACF;EAEA,OAAO;IACLX,cAAA;IACAC,oBAAA;IACAf;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,EAEvB,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAA;AAehB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAcrE,eAAO,MAAM,gBAAgB,EAAE,wBAAiE,CAAA;AAEhG,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,gBAAgB,CAAC,uBAAuB,CAAC,GACzC,KAAK,CAAC,EAAE,GACR,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,6PAgBxB;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ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C,CAAA;CAC5C,GAAG,oBAAoB,KAAG,OAAO,CAAC;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAqXA,CAAA;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,oBAAoB,+QAe7D"}
|
|
@@ -5,7 +5,7 @@ import { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc';
|
|
|
5
5
|
import { isEditing as getIsEditing } from '@payloadcms/ui/shared';
|
|
6
6
|
import { buildFormState } from '@payloadcms/ui/utilities/buildFormState';
|
|
7
7
|
import { notFound, redirect } from 'next/navigation.js';
|
|
8
|
-
import { logError } from 'payload';
|
|
8
|
+
import { isolateObjectProperty, logError } from 'payload';
|
|
9
9
|
import { formatAdminURL } from 'payload/shared';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { DocumentHeader } from '../../elements/DocumentHeader/index.js';
|
|
@@ -101,6 +101,26 @@ export const renderDocument = async ({
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string');
|
|
104
|
+
// CRITICAL FIX FOR TRANSACTION RACE CONDITION:
|
|
105
|
+
// When running parallel operations with Promise.all, if they share the same req object
|
|
106
|
+
// and one operation calls initTransaction() which MUTATES req.transactionID, that mutation
|
|
107
|
+
// is visible to all parallel operations. This causes:
|
|
108
|
+
// 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()
|
|
109
|
+
// which sets req.transactionID = Promise, then resolves it to a UUID
|
|
110
|
+
// 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID
|
|
111
|
+
// 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction
|
|
112
|
+
// 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!
|
|
113
|
+
//
|
|
114
|
+
// Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.
|
|
115
|
+
// This allows each operation to have its own transactionID without affecting the parent req.
|
|
116
|
+
// If parent req already has a transaction, preserve it (don't isolate), since this
|
|
117
|
+
// issue only arises when one of the operations calls initTransaction() themselves -
|
|
118
|
+
// because then, that operation will also try to commit/end the transaction itself.
|
|
119
|
+
// If the transactionID is already set, the parallel operations will not try to
|
|
120
|
+
// commit/end the transaction themselves, so we don't need to isolate the
|
|
121
|
+
// transactionID property.
|
|
122
|
+
const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID');
|
|
123
|
+
const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID');
|
|
104
124
|
const [docPreferences, {
|
|
105
125
|
docPermissions,
|
|
106
126
|
hasPublishPermission,
|
|
@@ -118,21 +138,21 @@ export const renderDocument = async ({
|
|
|
118
138
|
payload,
|
|
119
139
|
user
|
|
120
140
|
}),
|
|
121
|
-
// Get permissions
|
|
141
|
+
// Get permissions - isolated transactionID prevents cross-contamination
|
|
122
142
|
getDocumentPermissions({
|
|
123
143
|
id: idFromArgs,
|
|
124
144
|
collectionConfig,
|
|
125
145
|
data: doc,
|
|
126
146
|
globalConfig,
|
|
127
|
-
req
|
|
147
|
+
req: reqForPermissions
|
|
128
148
|
}),
|
|
129
|
-
// Fetch document lock state
|
|
149
|
+
// Fetch document lock state - isolated transactionID prevents cross-contamination
|
|
130
150
|
getIsLocked({
|
|
131
151
|
id: idFromArgs,
|
|
132
152
|
collectionConfig,
|
|
133
153
|
globalConfig,
|
|
134
154
|
isEditing,
|
|
135
|
-
req
|
|
155
|
+
req: reqForLockCheck
|
|
136
156
|
}),
|
|
137
157
|
// get entity preferences
|
|
138
158
|
getPreferences(collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`, payload, req.user.id, req.user.collection)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","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","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","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","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 { logError } from 'payload'\nimport { formatAdminURL } 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 serverURL,\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 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\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\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 (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\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 = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\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 =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\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 serverURL,\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,iBA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AAA,EAAKb,cAAA;mBAEJnB,UAAA,IAAc,CAACtF,UAAA,iBACd6G,IAAA,CAAC7H,cAAA;UACCuI,WAAA,EAAalB,WAAA;UACbxF,gBAAA,EAAkBA,gBAAA;UAClBG,YAAA,EAAcA,YAAA;UACdE,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA;yBAGT0F,IAAA,CAAC1I,mBAAA;UAAoB+C,WAAA,EAAaA;yBAClC2F,IAAA,CAAC3I,iBAAA;oBACEG,qBAAA,CAAsB;YACrBiI,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXpF,SAAA;YACAuH,WAAA,EAAahD;UACf;;;OArCCvD,MAAA,EAAQiD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAeuD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAM9H,cAAA,CAAe6H,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEA/I,QAAA,CAAS;MAAEiJ,GAAA,EAAKF,KAAA;MAAOvG,OAAA,EAASqG,KAAA,CAAMvH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIuG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjClJ,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","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","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","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 } 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 serverURL,\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 (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\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 = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\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 =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\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 serverURL,\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,QAAQ;AAC/B,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,IAAS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,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXvF,SAAA;YACA0H,WAAA,EAAahD;UACf;;;OArCC1D,MAAA,EAAQoD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAeuD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAMjI,cAAA,CAAegI,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;MAAO1G,OAAA,EAASwG,KAAA,CAAM1H,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAI0G,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
preferences: CollectionPreferences;
|
|
5
|
-
};
|
|
6
|
-
export declare const renderListHandler: ServerFunction<{
|
|
7
|
-
collectionSlug: string;
|
|
8
|
-
disableActions?: boolean;
|
|
9
|
-
disableBulkDelete?: boolean;
|
|
10
|
-
disableBulkEdit?: boolean;
|
|
11
|
-
disableQueryPresets?: boolean;
|
|
12
|
-
documentDrawerSlug: string;
|
|
13
|
-
drawerSlug?: string;
|
|
14
|
-
enableRowSelections: boolean;
|
|
15
|
-
overrideEntityVisibility?: boolean;
|
|
16
|
-
query: ListQuery;
|
|
17
|
-
redirectAfterDelete: boolean;
|
|
18
|
-
redirectAfterDuplicate: boolean;
|
|
19
|
-
}, Promise<RenderListResult>>;
|
|
20
|
-
export {};
|
|
1
|
+
import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui';
|
|
2
|
+
import type { ServerFunction } from 'payload';
|
|
3
|
+
export declare const renderListHandler: ServerFunction<RenderListServerFnArgs, Promise<RenderListServerFnReturnType>>;
|
|
21
4
|
//# sourceMappingURL=handleServerFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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;AASrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAmHtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","canAccessAdmin","getAccessResults","isEntityHidden","parseCookies","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 {
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","canAccessAdmin","getAccessResults","isEntityHidden","parseCookies","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 { canAccessAdmin, getAccessResults, isEntityHidden, parseCookies } 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 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,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAC/E,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,wBAAwB;IACxBC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGhB,IAAA;EAEJ,MAAMT,OAAA,GAAU,MAAMC,UAAA;EAEtB,MAAMyB,OAAA,GAAUrB,YAAA,CAAaL,O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MlD,gBAAA,CAAiB;IACzCkB;EACF;EAEA,MAAM;IAAEiC;EAAI,CAAE,GAAG,MAAM/C,cAAA,CAAe;IACpCoB,YAAA;IACAhB,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,mBAAA;IACAC,UAAA;IACAC,mBAAA;IACAM,IAAA;IACAM,SAAA,EAAWL,OAAA,CAAQK,SAAS;IAC5B2B,cAAA,EAAgB;MACdC,gBAAA,EAAkBjC,OAAA,EAASsB,WAAA,GAAcnC,cAAA,CAAe,EAAEc,MAAA;MAC1DE,OAAA;MACA+B,YAAA,EAAclC,OAAA,CAAQC,MAAM,CAAC4B,OAAO,CAACrB,IAAI,CAAE2B,MAAA,IAAWA,MAAA,CAAOX,IAAI,KAAKrC,cAAA;MACtEiD,eAAA,EAAiBC,SAAA;MACjBP,WAAA;MACAhC,GAAA;MACAwC,YAAA,EAAcD,SAAA;MACdhB;IACF;IACA3B,wBAAA;IACA6C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAerD,cAAA;IAC5B;IACAa,OAAA;IACAL,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA4C,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLX,IAAA;IACAxB;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutClient.d.ts","sourceRoot":"","sources":["../../../src/views/Logout/LogoutClient.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,cAAc,CAAA;AAIrB;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,
|
|
1
|
+
{"version":3,"file":"LogoutClient.d.ts","sourceRoot":"","sources":["../../../src/views/Logout/LogoutClient.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,cAAc,CAAA;AAIrB;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAyDA,CAAA"}
|
|
@@ -53,9 +53,9 @@ export const LogoutClient = props => {
|
|
|
53
53
|
} = useTranslation();
|
|
54
54
|
const router = useRouter();
|
|
55
55
|
let t1;
|
|
56
|
-
if ($[4] !==
|
|
56
|
+
if ($[4] !== logOut || $[5] !== loginRoute || $[6] !== router || $[7] !== startRouteTransition || $[8] !== t) {
|
|
57
57
|
t1 = async () => {
|
|
58
|
-
if (!
|
|
58
|
+
if (!navigatingToLoginRef.current) {
|
|
59
59
|
navigatingToLoginRef.current = true;
|
|
60
60
|
await logOut();
|
|
61
61
|
toast.success(t("authentication:loggedOutSuccessfully"));
|
|
@@ -63,22 +63,21 @@ export const LogoutClient = props => {
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
$[4] =
|
|
67
|
-
$[5] =
|
|
68
|
-
$[6] =
|
|
69
|
-
$[7] =
|
|
70
|
-
$[8] =
|
|
71
|
-
$[9] =
|
|
72
|
-
$[10] = t1;
|
|
66
|
+
$[4] = logOut;
|
|
67
|
+
$[5] = loginRoute;
|
|
68
|
+
$[6] = router;
|
|
69
|
+
$[7] = startRouteTransition;
|
|
70
|
+
$[8] = t;
|
|
71
|
+
$[9] = t1;
|
|
73
72
|
} else {
|
|
74
|
-
t1 = $[
|
|
73
|
+
t1 = $[9];
|
|
75
74
|
}
|
|
76
75
|
const handleLogOut = t1;
|
|
77
76
|
let t2;
|
|
78
77
|
let t3;
|
|
79
|
-
if ($[
|
|
78
|
+
if ($[10] !== handleLogOut || $[11] !== inactivity || $[12] !== isLoggedIn || $[13] !== loginRoute || $[14] !== router || $[15] !== startRouteTransition) {
|
|
80
79
|
t2 = () => {
|
|
81
|
-
if (isLoggedIn) {
|
|
80
|
+
if (isLoggedIn && !inactivity) {
|
|
82
81
|
handleLogOut();
|
|
83
82
|
} else {
|
|
84
83
|
if (!navigatingToLoginRef.current) {
|
|
@@ -87,8 +86,9 @@ export const LogoutClient = props => {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
};
|
|
90
|
-
t3 = [handleLogOut, isLoggedIn, loginRoute, router, startRouteTransition];
|
|
91
|
-
$[
|
|
89
|
+
t3 = [handleLogOut, isLoggedIn, loginRoute, router, startRouteTransition, inactivity];
|
|
90
|
+
$[10] = handleLogOut;
|
|
91
|
+
$[11] = inactivity;
|
|
92
92
|
$[12] = isLoggedIn;
|
|
93
93
|
$[13] = loginRoute;
|
|
94
94
|
$[14] = router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutClient.js","names":["c","_c","Button","LoadingOverlay","toast","useAuth","useRouteTransition","useTranslation","useRouter","formatAdminURL","React","useEffect","baseClass","LogoutClient","props","$","adminRoute","inactivity","redirect","logOut","user","startRouteTransition","id","isLoggedIn","Boolean","navigatingToLoginRef","useRef","t0","path","length","encodeURIComponent","loginRoute","useState","t","router","t1","current","success","push","handleLogOut","t2","t3","t4","_jsxs","className","children","_jsx","buttonStyle","el","size","url","animationDuration","loadingText"],"sources":["../../../src/views/Logout/LogoutClient.tsx"],"sourcesContent":["'use client'\nimport {\n Button,\n LoadingOverlay,\n toast,\n useAuth,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useEffect } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'logout'\n\n/**\n * This component should **just** be the inactivity route and do nothing with logging the user out.\n *\n * It currently handles too much, the auth provider should just log the user out and then\n * we could remove the useEffect in this file. So instead of the logout button\n * being an anchor link, it should be a button that calls `logOut` in the provider.\n *\n * This view is still useful if cookies attempt to refresh and fail, i.e. the user\n * is logged out due to inactivity.\n */\nexport const LogoutClient: React.FC<{\n adminRoute: string\n inactivity?: boolean\n redirect: string\n}> = (props) => {\n const { adminRoute, inactivity, redirect } = props\n\n const { logOut, user } = useAuth()\n\n const { startRouteTransition } = useRouteTransition()\n\n const isLoggedIn = React.useMemo(() => {\n return Boolean(user?.id)\n }, [user?.id])\n\n const navigatingToLoginRef = React.useRef(false)\n\n const [loginRoute] = React.useState(() =>\n formatAdminURL({\n adminRoute,\n path: `/login${
|
|
1
|
+
{"version":3,"file":"LogoutClient.js","names":["c","_c","Button","LoadingOverlay","toast","useAuth","useRouteTransition","useTranslation","useRouter","formatAdminURL","React","useEffect","baseClass","LogoutClient","props","$","adminRoute","inactivity","redirect","logOut","user","startRouteTransition","id","isLoggedIn","Boolean","navigatingToLoginRef","useRef","t0","path","length","encodeURIComponent","loginRoute","useState","t","router","t1","current","success","push","handleLogOut","t2","t3","t4","_jsxs","className","children","_jsx","buttonStyle","el","size","url","animationDuration","loadingText"],"sources":["../../../src/views/Logout/LogoutClient.tsx"],"sourcesContent":["'use client'\nimport {\n Button,\n LoadingOverlay,\n toast,\n useAuth,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useEffect } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'logout'\n\n/**\n * This component should **just** be the inactivity route and do nothing with logging the user out.\n *\n * It currently handles too much, the auth provider should just log the user out and then\n * we could remove the useEffect in this file. So instead of the logout button\n * being an anchor link, it should be a button that calls `logOut` in the provider.\n *\n * This view is still useful if cookies attempt to refresh and fail, i.e. the user\n * is logged out due to inactivity.\n */\nexport const LogoutClient: React.FC<{\n adminRoute: string\n inactivity?: boolean\n redirect: string\n}> = (props) => {\n const { adminRoute, inactivity, redirect } = props\n\n const { logOut, user } = useAuth()\n\n const { startRouteTransition } = useRouteTransition()\n\n const isLoggedIn = React.useMemo(() => {\n return Boolean(user?.id)\n }, [user?.id])\n\n const navigatingToLoginRef = React.useRef(false)\n\n const [loginRoute] = React.useState(() =>\n formatAdminURL({\n adminRoute,\n path: `/login${inactivity && redirect && redirect.length > 0\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''\n }`,\n }),\n )\n\n const { t } = useTranslation()\n const router = useRouter()\n\n const handleLogOut = React.useCallback(async () => {\n if (!navigatingToLoginRef.current) {\n navigatingToLoginRef.current = true\n await logOut()\n toast.success(t('authentication:loggedOutSuccessfully'))\n startRouteTransition(() => router.push(loginRoute))\n return\n }\n }, [logOut, loginRoute, router, startRouteTransition, t])\n\n useEffect(() => {\n if (isLoggedIn && !inactivity) {\n void handleLogOut()\n } else if (!navigatingToLoginRef.current) {\n navigatingToLoginRef.current = true\n startRouteTransition(() => router.push(loginRoute))\n }\n }, [handleLogOut, isLoggedIn, loginRoute, router, startRouteTransition, inactivity])\n\n if (!isLoggedIn && inactivity) {\n return (\n <div className={`${baseClass}__wrap`}>\n <h2>{t('authentication:loggedOutInactivity')}</h2>\n <Button buttonStyle=\"secondary\" el=\"link\" size=\"large\" url={loginRoute}>\n {t('authentication:logBackIn')}\n </Button>\n </div>\n )\n }\n\n return <LoadingOverlay animationDuration={'0ms'} loadingText={t('authentication:loggingOut')} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SACEC,MAAM,EACNC,cAAc,EACdC,KAAK,EACLC,OAAO,EACPC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,SAAS,QAAQ;AAIjC,MAAMC,SAAA,GAAY;AAElB;;;;;;;;;;AAUA,OAAO,MAAMC,YAAA,GAIRC,KAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EACH;IAAAe,UAAA;IAAAC,UAAA;IAAAC;EAAA,IA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AAC,KAAA,CAAC;QAAAC,SAAA,EAAe,GAAAhC,SAAA,QAAoB;QAAAiC,QAAA,GAClCC,IAAA,CAAC;UAAAD,QAAA,EAAIZ,CAAA,CAAE;QAAA,C,GACPa,IAAA,CAAA5C,MAAA;UAAA6C,WAAA,EAAoB;UAAAC,EAAA,EAAe;UAAAC,IAAA,EAAY;UAAAC,GAAA,EAAanB,UAAA;UAAAc,QAAA,EACzDZ,CAAA,CAAE;QAAA,C;;;;;;;;WAHPS,E;;;;IASGA,EAAA,GAAAI,IAAA,CAAA3C,cAAA;MAAAgD,iBAAA,EAAmC;MAAAC,WAAA,EAAoBnB,CAAA,CAAE;IAAA,C;;;;;;SAAzDS,E;CACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../src/withPayload.js"],"names":[],"mappings":"AAOO,yCANI,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,GAAzC,OAAO;CAA6F,GAElG,OAAO,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../src/withPayload.js"],"names":[],"mappings":"AAOO,yCANI,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,GAAzC,OAAO;CAA6F,GAElG,OAAO,MAAM,EAAE,UAAU,CA0PrC"}
|