@payloadcms/next 3.64.0-internal.deef021 → 3.64.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/cjs/withPayload.cjs +1 -0
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/views/List/enrichDocsWithVersionStatus.d.ts +14 -0
- package/dist/views/List/enrichDocsWithVersionStatus.d.ts.map +1 -0
- package/dist/views/List/enrichDocsWithVersionStatus.js +96 -0
- package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -0
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +13 -0
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +9 -0
- package/dist/views/Root/index.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +1 -1
- package/dist/withPayload.js.map +1 -1
- package/package.json +7 -7
package/dist/cjs/withPayload.cjs
CHANGED
|
@@ -103,6 +103,7 @@ const withPayload = (nextConfig = {}, options = {})=>{
|
|
|
103
103
|
'@payloadcms/db-sqlite',
|
|
104
104
|
'@payloadcms/db-vercel-postgres',
|
|
105
105
|
'@payloadcms/drizzle',
|
|
106
|
+
'@payloadcms/db-d1-sqlite',
|
|
106
107
|
// External because they install @aws-sdk/client-s3:
|
|
107
108
|
'@payloadcms/payload-cloud',
|
|
108
109
|
// External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/withPayload.js"],"names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/withPayload.js"],"names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;QAwIH;eAAA;;QAvIaA;eAAAA;;;AAAN,MAAMA,cAAc,CAACC,aAAa,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;IACvD,MAAMC,MAAMF,WAAWE,GAAG,IAAI,CAAC;IAE/B,IAAIF,WAAWG,YAAY,EAAEC,YAAYC,SAAS;QAChDC,QAAQC,IAAI,CACV;QAEFL,IAAIM,uCAAuC,GAAG;IAChD;IAEA,MAAMC,kBAAkB;QACtBC,KAAK;QACLC,OAAO;IACT;IAEA;;GAEC,GACD,MAAMC,WAAW;QACf,GAAGZ,UAAU;QACbE;QACAW,WAAW;YACT,GAAIb,WAAWa,SAAS,IAAI,CAAC,CAAC;QAChC;QACAC,2BAA2B;YACzB,GAAId,WAAWc,yBAAyB,IAAI,CAAC,CAAC;YAC9C,QAAQ;mBACFd,WAAWc,yBAAyB,EAAE,CAAC,OAAO,IAAI,EAAE;gBACxD;gBACA;aACD;QACH;QACAC,2BAA2B;YACzB,GAAIf,WAAWe,yBAAyB,IAAI,CAAC,CAAC;YAC9C,QAAQ;mBAAKf,WAAWe,yBAAyB,EAAE,CAAC,OAAO,IAAI,EAAE;gBAAG;aAAiB;QACvF;QACA,+FAA+F;QAC/F,GAAIf,WAAWS,eAAe,KAAK,QAAQ;YAAEA,iBAAiB;QA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AC8B,cAAc,GAAGhC,WAAW+B,QAAQ;IACnD;IAEA,OAAOnB;AACT;MAEA,WAAeb","file":"withPayload.cjs","sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default true\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // These packages always need to be external, both during dev and production. This is because they install dependencies\n // that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).\n // We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed\n // by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,\n // as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users\n // to install the dependencies directly.\n // Thus, we externalize the \"entry-point\" = the package that is installed by the end user, which would be our db adapters.\n //\n //\n // External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):\n '@payloadcms/db-mongodb',\n // External because they install dependencies like drizzle, libsql, esbuild etc.:\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n '@payloadcms/db-d1-sqlite',\n // External because they install @aws-sdk/client-s3:\n '@payloadcms/payload-cloud',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n // TODO: We need to externalize @payloadcms/storage-s3 as well, once Next.js has the ability to exclude @payloadcms/storage-s3/client from being externalized.\n // Do not bundle additional server-only packages during dev to improve compilation speed\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false\n ? [\n 'payload',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [...(incomingWebpackConfig?.externals || []), 'require-in-the-middle'],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PaginatedDocs, PayloadRequest, SanitizedCollectionConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Enriches list view documents with correct draft status display.
|
|
4
|
+
* When draft=true is used in the query, Payload returns the latest draft version if it exists.
|
|
5
|
+
* This function checks if draft documents also have a published version to determine "changed" status.
|
|
6
|
+
*
|
|
7
|
+
* Performance: Uses a single query to find all documents with "changed" status instead of N queries.
|
|
8
|
+
*/
|
|
9
|
+
export declare function enrichDocsWithVersionStatus({ collectionConfig, data, req, }: {
|
|
10
|
+
collectionConfig: SanitizedCollectionConfig;
|
|
11
|
+
data: PaginatedDocs;
|
|
12
|
+
req: PayloadRequest;
|
|
13
|
+
}): Promise<PaginatedDocs>;
|
|
14
|
+
//# sourceMappingURL=enrichDocsWithVersionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichDocsWithVersionStatus.d.ts","sourceRoot":"","sources":["../../../src/views/List/enrichDocsWithVersionStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAEvF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAAC,EAChD,gBAAgB,EAChB,IAAI,EACJ,GAAG,GACJ,EAAE;IACD,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,IAAI,EAAE,aAAa,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmGzB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enriches list view documents with correct draft status display.
|
|
3
|
+
* When draft=true is used in the query, Payload returns the latest draft version if it exists.
|
|
4
|
+
* This function checks if draft documents also have a published version to determine "changed" status.
|
|
5
|
+
*
|
|
6
|
+
* Performance: Uses a single query to find all documents with "changed" status instead of N queries.
|
|
7
|
+
*/export async function enrichDocsWithVersionStatus({
|
|
8
|
+
collectionConfig,
|
|
9
|
+
data,
|
|
10
|
+
req
|
|
11
|
+
}) {
|
|
12
|
+
const draftsEnabled = collectionConfig?.versions?.drafts;
|
|
13
|
+
if (!draftsEnabled || !data?.docs?.length) {
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
// Find all draft documents
|
|
17
|
+
// When querying with draft:true, we get the latest draft if it exists
|
|
18
|
+
// We need to check if these drafts have a published version
|
|
19
|
+
const draftDocs = data.docs.filter(doc => doc._status === 'draft');
|
|
20
|
+
if (draftDocs.length === 0) {
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
const draftDocIds = draftDocs.map(doc => doc.id).filter(Boolean);
|
|
24
|
+
if (draftDocIds.length === 0) {
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
// OPTIMIZATION: Single query to find all document IDs that have BOTH:
|
|
28
|
+
// 1. A draft version (latest=true, _status='draft')
|
|
29
|
+
// 2. A published version (_status='published')
|
|
30
|
+
// These are the documents with "changed" status
|
|
31
|
+
try {
|
|
32
|
+
// TODO: This could be more efficient with a findDistinctVersions() API:
|
|
33
|
+
// const { values } = await req.payload.findDistinctVersions({
|
|
34
|
+
// collection: collectionConfig.slug,
|
|
35
|
+
// field: 'parent',
|
|
36
|
+
// where: {
|
|
37
|
+
// and: [
|
|
38
|
+
// { parent: { in: draftDocIds } },
|
|
39
|
+
// { 'version._status': { equals: 'published' } },
|
|
40
|
+
// ],
|
|
41
|
+
// },
|
|
42
|
+
// })
|
|
43
|
+
// const hasPublishedVersionSet = new Set(values)
|
|
44
|
+
//
|
|
45
|
+
// For now, we query all published versions but only select the 'parent' field
|
|
46
|
+
// to minimize data transfer, then deduplicate with a Set
|
|
47
|
+
const publishedVersions = await req.payload.findVersions({
|
|
48
|
+
collection: collectionConfig.slug,
|
|
49
|
+
depth: 0,
|
|
50
|
+
limit: 0,
|
|
51
|
+
pagination: false,
|
|
52
|
+
select: {
|
|
53
|
+
parent: true
|
|
54
|
+
},
|
|
55
|
+
where: {
|
|
56
|
+
and: [{
|
|
57
|
+
parent: {
|
|
58
|
+
in: draftDocIds
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
'version._status': {
|
|
62
|
+
equals: 'published'
|
|
63
|
+
}
|
|
64
|
+
}]
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Create a Set of document IDs that have published versions
|
|
68
|
+
const hasPublishedVersionSet = new Set(publishedVersions.docs.map(version => version.parent).filter(Boolean));
|
|
69
|
+
// Enrich documents with display status
|
|
70
|
+
const enrichedDocs = data.docs.map(doc => {
|
|
71
|
+
// If it's a draft and has a published version, show "changed"
|
|
72
|
+
if (doc._status === 'draft' && hasPublishedVersionSet.has(doc.id)) {
|
|
73
|
+
return {
|
|
74
|
+
...doc,
|
|
75
|
+
_displayStatus: 'changed'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
...doc,
|
|
80
|
+
_displayStatus: doc._status
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
...data,
|
|
85
|
+
docs: enrichedDocs
|
|
86
|
+
};
|
|
87
|
+
} catch (error) {
|
|
88
|
+
// If there's an error querying versions, just return the original data
|
|
89
|
+
req.payload.logger.error({
|
|
90
|
+
err: error,
|
|
91
|
+
msg: `Error checking version status for collection ${collectionConfig.slug}`
|
|
92
|
+
});
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=enrichDocsWithVersionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichDocsWithVersionStatus.js","names":["enrichDocsWithVersionStatus","collectionConfig","data","req","draftsEnabled","versions","drafts","docs","length","draftDocs","filter","doc","_status","draftDocIds","map","id","Boolean","publishedVersions","payload","findVersions","collection","slug","depth","limit","pagination","select","parent","where","and","in","equals","hasPublishedVersionSet","Set","version","enrichedDocs","has","_displayStatus","error","logger","err","msg"],"sources":["../../../src/views/List/enrichDocsWithVersionStatus.ts"],"sourcesContent":["import type { PaginatedDocs, PayloadRequest, SanitizedCollectionConfig } from 'payload'\n\n/**\n * Enriches list view documents with correct draft status display.\n * When draft=true is used in the query, Payload returns the latest draft version if it exists.\n * This function checks if draft documents also have a published version to determine \"changed\" status.\n *\n * Performance: Uses a single query to find all documents with \"changed\" status instead of N queries.\n */\nexport async function enrichDocsWithVersionStatus({\n collectionConfig,\n data,\n req,\n}: {\n collectionConfig: SanitizedCollectionConfig\n data: PaginatedDocs\n req: PayloadRequest\n}): Promise<PaginatedDocs> {\n const draftsEnabled = collectionConfig?.versions?.drafts\n\n if (!draftsEnabled || !data?.docs?.length) {\n return data\n }\n\n // Find all draft documents\n // When querying with draft:true, we get the latest draft if it exists\n // We need to check if these drafts have a published version\n const draftDocs = data.docs.filter((doc) => doc._status === 'draft')\n\n if (draftDocs.length === 0) {\n return data\n }\n\n const draftDocIds = draftDocs.map((doc) => doc.id).filter(Boolean)\n\n if (draftDocIds.length === 0) {\n return data\n }\n\n // OPTIMIZATION: Single query to find all document IDs that have BOTH:\n // 1. A draft version (latest=true, _status='draft')\n // 2. A published version (_status='published')\n // These are the documents with \"changed\" status\n try {\n // TODO: This could be more efficient with a findDistinctVersions() API:\n // const { values } = await req.payload.findDistinctVersions({\n // collection: collectionConfig.slug,\n // field: 'parent',\n // where: {\n // and: [\n // { parent: { in: draftDocIds } },\n // { 'version._status': { equals: 'published' } },\n // ],\n // },\n // })\n // const hasPublishedVersionSet = new Set(values)\n //\n // For now, we query all published versions but only select the 'parent' field\n // to minimize data transfer, then deduplicate with a Set\n const publishedVersions = await req.payload.findVersions({\n collection: collectionConfig.slug,\n depth: 0,\n limit: 0,\n pagination: false,\n select: {\n parent: true,\n },\n where: {\n and: [\n {\n parent: {\n in: draftDocIds,\n },\n },\n {\n 'version._status': {\n equals: 'published',\n },\n },\n ],\n },\n })\n\n // Create a Set of document IDs that have published versions\n const hasPublishedVersionSet = new Set(\n publishedVersions.docs.map((version) => version.parent).filter(Boolean),\n )\n\n // Enrich documents with display status\n const enrichedDocs = data.docs.map((doc) => {\n // If it's a draft and has a published version, show \"changed\"\n if (doc._status === 'draft' && hasPublishedVersionSet.has(doc.id)) {\n return {\n ...doc,\n _displayStatus: 'changed' as const,\n }\n }\n\n return {\n ...doc,\n _displayStatus: doc._status as 'draft' | 'published',\n }\n })\n\n return {\n ...data,\n docs: enrichedDocs,\n }\n } catch (error) {\n // If there's an error querying versions, just return the original data\n req.payload.logger.error({\n err: error,\n msg: `Error checking version status for collection ${collectionConfig.slug}`,\n })\n return data\n }\n}\n"],"mappings":"AAEA;;;;;;GAOA,OAAO,eAAeA,4BAA4B;EAChDC,gBAAgB;EAChBC,IAAI;EACJC;AAAG,CAKJ;EACC,MAAMC,aAAA,GAAgBH,gBAAA,EAAkBI,QAAA,EAAUC,MAAA;EAElD,IAAI,CAACF,aAAA,IAAiB,CAACF,IAAA,EAAMK,IAAA,EAAMC,MAAA,EAAQ;IACzC,OAAON,IAAA;EACT;EAEA;EACA;EACA;EACA,MAAMO,SAAA,GAAYP,IAAA,CAAK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AgBzB,GAAA,CAAIC;MACtB;IACF;IAEA,OAAO;MACL,GAAGV,IAAI;MACPK,IAAA,EAAM2B;IACR;EACF,EAAE,OAAOG,KAAA,EAAO;IACd;IACAlC,GAAA,CAAIe,OAAO,CAACoB,MAAM,CAACD,KAAK,CAAC;MACvBE,GAAA,EAAKF,KAAA;MACLG,GAAA,EAAK,gDAAgDvC,gBAAA,CAAiBoB,IAAI;IAC5E;IACA,OAAOnB,IAAA;EACT;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAIpB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EAEvB,gBAAgB,EAGjB,MAAM,SAAS,CAAA;AAehB,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAIpB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EAEvB,gBAAgB,EAGjB,MAAM,SAAS,CAAA;AAehB,OAAO,KAAmB,MAAM,OAAO,CAAA;AASvC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EACd,gBAAgB,GAChB,KAAK,CAAC,aAAa,CAAC,mBAAmB,GAAG,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,CAAC,CAAA;IAC9F,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,oBAAoB,CAAA;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CAqWA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAWjD,CAAA"}
|
package/dist/views/List/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { notFound } from 'next/navigation.js';
|
|
|
6
6
|
import { appendUploadSelectFields, combineWhereConstraints, formatAdminURL, isNumber, mergeListSearchAndWhere, transformColumnsToPreferences, transformColumnsToSearchParams } from 'payload/shared';
|
|
7
7
|
import React, { Fragment } from 'react';
|
|
8
8
|
import { getDocumentPermissions } from '../Document/getDocumentPermissions.js';
|
|
9
|
+
import { enrichDocsWithVersionStatus } from './enrichDocsWithVersionStatus.js';
|
|
9
10
|
import { handleGroupBy } from './handleGroupBy.js';
|
|
10
11
|
import { renderListViewSlots } from './renderListViewSlots.js';
|
|
11
12
|
import { resolveAllFilterOptions } from './resolveAllFilterOptions.js';
|
|
@@ -186,6 +187,12 @@ export const renderListView = async args => {
|
|
|
186
187
|
viewType,
|
|
187
188
|
where: whereWithMergedSearch
|
|
188
189
|
}));
|
|
190
|
+
// Enrich documents with correct display status for drafts
|
|
191
|
+
data = await enrichDocsWithVersionStatus({
|
|
192
|
+
collectionConfig,
|
|
193
|
+
data,
|
|
194
|
+
req
|
|
195
|
+
});
|
|
189
196
|
} else {
|
|
190
197
|
data = await req.payload.find({
|
|
191
198
|
collection: collectionSlug,
|
|
@@ -204,6 +211,12 @@ export const renderListView = async args => {
|
|
|
204
211
|
user,
|
|
205
212
|
where: whereWithMergedSearch
|
|
206
213
|
});
|
|
214
|
+
// Enrich documents with correct display status for drafts
|
|
215
|
+
data = await enrichDocsWithVersionStatus({
|
|
216
|
+
collectionConfig,
|
|
217
|
+
data,
|
|
218
|
+
req
|
|
219
|
+
});
|
|
207
220
|
({
|
|
208
221
|
columnState,
|
|
209
222
|
Table
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","getColumns","renderFilters","renderTable","upsertPreferences","notFound","appendUploadSelectFields","combineWhereConstraints","formatAdminURL","isNumber","mergeListSearchAndWhere","transformColumnsToPreferences","transformColumnsToSearchParams","React","Fragment","getDocumentPermissions","handleGroupBy","renderListViewSlots","resolveAllFilterOptions","transformColumnsToSelect","renderListView","args","clientConfig","ComponentOverride","customCellProps","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","trash","viewType","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","columnsFromQuery","columns","queryByGroup","JSON","parse","collectionPreferences","key","value","groupBy","limit","Number","undefined","preset","sort","page","admin","pagination","defaultLimit","defaultSort","routes","adminRoute","includes","baseFilterConstraint","baseFilter","baseListFilter","queryPreset","queryPresetPermissions","whereWithMergedSearch","search","where","and","deletedAt","exists","findByID","id","collection","depth","overrideAccess","find","c","data","then","docPermissions","err","logger","error","Table","columnState","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","clientCollectionConfig","select","enableListViewSelectAPI","fieldPermissions","fields","draft","fallbackLocale","includeLockStatus","orderableFieldName","orderable","useAsTitle","name","msg","renderedFilters","importMap","resolvedFilterOptions","staticDescription","description","t","newDocumentURL","path","hasCreatePermission","create","hasDeletePermission","delete","notFoundDocId","serverProps","listPreferences","listSearchableFields","listViewSlots","clientProps","isInDrawer","Boolean","stringify","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","ListView","RenderedList","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Column,\n ColumnPreference,\n ListQuery,\n ListViewClientProps,\n ListViewServerPropsOnly,\n PaginatedDocs,\n PayloadComponent,\n QueryPreset,\n SanitizedCollectionPermission,\n} from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getColumns, renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { notFound } from 'next/navigation.js'\nimport {\n appendUploadSelectFields,\n combineWhereConstraints,\n formatAdminURL,\n isNumber,\n mergeListSearchAndWhere,\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { handleGroupBy } from './handleGroupBy.js'\nimport { renderListViewSlots } from './renderListViewSlots.js'\nimport { resolveAllFilterOptions } from './resolveAllFilterOptions.js'\nimport { transformColumnsToSelect } from './transformColumnsToSelect.js'\n\n/**\n * @internal\n */\nexport type RenderListViewArgs = {\n /**\n * Allows providing your own list view component. This will override the default list view component and\n * the collection's configured list view component (if any).\n */\n ComponentOverride?:\n | PayloadComponent\n | React.ComponentType<ListViewClientProps | (ListViewClientProps & ListViewServerPropsOnly)>\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n /**\n * If not ListQuery is provided, `req.query` will be used.\n */\n query?: ListQuery\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n /**\n * @experimental This prop is subject to change in future releases.\n */\n trash?: boolean\n} & AdminViewServerProps\n\n/**\n * This function is responsible for rendering\n * the list view on the server for both:\n * - default list view\n * - list view within drawers\n *\n * @internal\n */\nexport const renderListView = async (\n args: RenderListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n ComponentOverride,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n trash,\n viewType,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query: ListQuery = queryFromArgs || queryFromReq\n\n const columnsFromQuery: ColumnPreference[] = transformColumnsToPreferences(query?.columns)\n\n query.queryByGroup =\n query?.queryByGroup && typeof query.queryByGroup === 'string'\n ? JSON.parse(query.queryByGroup)\n : query?.queryByGroup\n\n const collectionPreferences = await upsertPreferences<CollectionPreferences>({\n key: `collection-${collectionSlug}`,\n req,\n value: {\n columns: columnsFromQuery,\n groupBy: query?.groupBy,\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n preset: query?.preset,\n sort: query?.sort as string,\n },\n })\n\n query.preset = collectionPreferences?.preset\n\n query.page = isNumber(query?.page) ? Number(query.page) : 0\n\n query.limit = collectionPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n query.sort =\n collectionPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n query.groupBy = collectionPreferences?.groupBy\n\n query.columns = transformColumnsToSearchParams(collectionPreferences?.columns || [])\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const baseFilterConstraint = await (\n collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter\n )?.({\n limit: query.limit,\n page: query.page,\n req,\n sort: query.sort,\n })\n\n let queryPreset: QueryPreset | undefined\n let queryPresetPermissions: SanitizedCollectionPermission | undefined\n\n let whereWithMergedSearch = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: combineWhereConstraints([query?.where, baseFilterConstraint]),\n })\n\n if (trash === true) {\n whereWithMergedSearch = {\n and: [\n whereWithMergedSearch,\n {\n deletedAt: {\n exists: true,\n },\n },\n ],\n }\n }\n\n if (collectionPreferences?.preset) {\n try {\n queryPreset = (await payload.findByID({\n id: collectionPreferences?.preset,\n collection: 'payload-query-presets',\n depth: 0,\n overrideAccess: false,\n user,\n })) as QueryPreset\n\n if (queryPreset) {\n queryPresetPermissions = await getDocumentPermissions({\n id: queryPreset.id,\n collectionConfig: config.collections.find((c) => c.slug === 'payload-query-presets'),\n data: queryPreset,\n req,\n })?.then(({ docPermissions }) => docPermissions)\n }\n } catch (err) {\n req.payload.logger.error(`Error fetching query preset or preset permissions: ${err}`)\n }\n }\n\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[] = []\n let data: PaginatedDocs = {\n // no results default\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: query.limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const columns = getColumns({\n clientConfig,\n collectionConfig: clientCollectionConfig,\n collectionSlug,\n columns: collectionPreferences?.columns,\n i18n,\n permissions,\n })\n\n const select = collectionConfig.admin.enableListViewSelectAPI\n ? transformColumnsToSelect(columns)\n : undefined\n\n /** Force select image fields for list view thumbnails */\n appendUploadSelectFields({\n collectionConfig,\n select,\n })\n\n try {\n if (collectionConfig.admin.groupBy && query.groupBy) {\n ;({ columnState, data, Table } = await handleGroupBy({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n fieldPermissions: permissions?.collections?.[collectionSlug]?.fields,\n query,\n req,\n select,\n trash,\n user,\n viewType,\n where: whereWithMergedSearch,\n }))\n } else {\n data = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n req,\n select,\n sort: query?.sort,\n trash,\n user,\n where: whereWithMergedSearch,\n })\n ;({ columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data,\n drawerSlug,\n enableRowSelections,\n fieldPermissions: permissions?.collections?.[collectionSlug]?.fields,\n i18n: req.i18n,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n req,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n }))\n }\n } catch (err) {\n if (err.name !== 'QueryError') {\n // QueryErrors are expected when a user filters by a field they do not have access to\n req.payload.logger.error({\n err,\n msg: `There was an error fetching the list view data for collection ${collectionSlug}`,\n })\n throw err\n }\n }\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const resolvedFilterOptions = await resolveAllFilterOptions({\n fields: collectionConfig.fields,\n req,\n })\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n const hasDeletePermission = permissions?.collections?.[collectionSlug]?.delete\n\n // Check if there's a notFound query parameter (document ID that wasn't found)\n const notFoundDocId = typeof searchParams?.notFound === 'string' ? searchParams.notFound : null\n\n const serverProps: ListViewServerPropsOnly = {\n collectionConfig,\n data,\n i18n,\n limit: query.limit,\n listPreferences: collectionPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: {\n collectionSlug,\n hasCreatePermission,\n hasDeletePermission,\n newDocumentURL,\n },\n collectionConfig,\n description: staticDescription,\n notFoundDocId,\n payload,\n serverProps,\n })\n\n const isInDrawer = Boolean(drawerSlug)\n\n // Needed to prevent: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props.\n // Is there a way to avoid this? The `where` object is already seemingly plain, but is not bc it originates from the params.\n query.where = query?.where ? JSON.parse(JSON.stringify(query?.where || {})) : undefined\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n modifySearchParams={!isInDrawer}\n orderableFieldName={collectionConfig.orderable === true ? '_order' : undefined}\n query={query}\n >\n {RenderServerComponent({\n clientProps: {\n ...listViewSlots,\n collectionSlug,\n columnState,\n disableBulkDelete,\n disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,\n disableQueryPresets,\n enableRowSelections,\n hasCreatePermission,\n hasDeletePermission,\n listPreferences: collectionPreferences,\n newDocumentURL,\n queryPreset,\n queryPresetPermissions,\n renderedFilters,\n resolvedFilterOptions,\n Table,\n viewType,\n } satisfies ListViewClientProps,\n Component:\n ComponentOverride ?? collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps,\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<RenderListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found')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A6D,WAAA;cACA5E,iBAAA;cACAC,eAAA,EAAiBY,gBAAA,CAAiBZ,eAAe,IAAIA,eAAA;cACrDC,mBAAA;cACAE,mBAAA;cACAsG,mBAAA;cACAE,mBAAA;cACAI,eAAA,EAAiB9E,qBAAA;cACjBsE,cAAA;cACAlD,WAAA;cACAC,sBAAA;cACA2C,eAAA;cACAE,qBAAA;cACAzB,KAAA;cACA/D;YACF;YACA+G,SAAA,EACE7H,iBAAA,IAAqBe,gBAAA,EAAkB+B,KAAA,EAAOgF,UAAA,EAAYC,KAAA,EAAOC,IAAA,EAAMH,SAAA;YACzEI,QAAA,EAAU3J,eAAA;YACV+H,SAAA,EAAW9E,OAAA,CAAQ8E,SAAS;YAC5BY;UACF;;;IAIR;EACF;EAEA,MAAM,IAAInF,KAAA,CAAM;AAClB;AAEA,OAAO,MAAMoG,QAAA,GAAyC,MAAOpI,IAAA;EAC3D,IAAI;IACF,MAAM;MAAE2H,IAAA,EAAMU;IAAY,CAAE,GAAG,MAAMtI,cAAA,CAAe;MAAE,GAAGC,IAAI;MAAEQ,mBAAA,EAAqB;IAAK;IACzF,OAAO6H,YAAA;EACT,EAAE,OAAOvD,KAAA,EAAO;IACd,IAAIA,KAAA,CAAMwD,OAAO,KAAK,aAAa;MACjCtJ,QAAA;IACF,OAAO;MACLuJ,OAAA,CAAQzD,KAAK,CAACA,KAAA,EAAO;MAAA;IACvB;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","getColumns","renderFilters","renderTable","upsertPreferences","notFound","appendUploadSelectFields","combineWhereConstraints","formatAdminURL","isNumber","mergeListSearchAndWhere","transformColumnsToPreferences","transformColumnsToSearchParams","React","Fragment","getDocumentPermissions","enrichDocsWithVersionStatus","handleGroupBy","renderListViewSlots","resolveAllFilterOptions","transformColumnsToSelect","renderListView","args","clientConfig","ComponentOverride","customCellProps","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","trash","viewType","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","columnsFromQuery","columns","queryByGroup","JSON","parse","collectionPreferences","key","value","groupBy","limit","Number","undefined","preset","sort","page","admin","pagination","defaultLimit","defaultSort","routes","adminRoute","includes","baseFilterConstraint","baseFilter","baseListFilter","queryPreset","queryPresetPermissions","whereWithMergedSearch","search","where","and","deletedAt","exists","findByID","id","collection","depth","overrideAccess","find","c","data","then","docPermissions","err","logger","error","Table","columnState","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","clientCollectionConfig","select","enableListViewSelectAPI","fieldPermissions","fields","draft","fallbackLocale","includeLockStatus","orderableFieldName","orderable","useAsTitle","name","msg","renderedFilters","importMap","resolvedFilterOptions","staticDescription","description","t","newDocumentURL","path","hasCreatePermission","create","hasDeletePermission","delete","notFoundDocId","serverProps","listPreferences","listSearchableFields","listViewSlots","clientProps","isInDrawer","Boolean","stringify","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","ListView","RenderedList","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Column,\n ColumnPreference,\n ListQuery,\n ListViewClientProps,\n ListViewServerPropsOnly,\n PaginatedDocs,\n PayloadComponent,\n QueryPreset,\n SanitizedCollectionPermission,\n} from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getColumns, renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { notFound } from 'next/navigation.js'\nimport {\n appendUploadSelectFields,\n combineWhereConstraints,\n formatAdminURL,\n isNumber,\n mergeListSearchAndWhere,\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { enrichDocsWithVersionStatus } from './enrichDocsWithVersionStatus.js'\nimport { handleGroupBy } from './handleGroupBy.js'\nimport { renderListViewSlots } from './renderListViewSlots.js'\nimport { resolveAllFilterOptions } from './resolveAllFilterOptions.js'\nimport { transformColumnsToSelect } from './transformColumnsToSelect.js'\n\n/**\n * @internal\n */\nexport type RenderListViewArgs = {\n /**\n * Allows providing your own list view component. This will override the default list view component and\n * the collection's configured list view component (if any).\n */\n ComponentOverride?:\n | PayloadComponent\n | React.ComponentType<ListViewClientProps | (ListViewClientProps & ListViewServerPropsOnly)>\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n /**\n * If not ListQuery is provided, `req.query` will be used.\n */\n query?: ListQuery\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n /**\n * @experimental This prop is subject to change in future releases.\n */\n trash?: boolean\n} & AdminViewServerProps\n\n/**\n * This function is responsible for rendering\n * the list view on the server for both:\n * - default list view\n * - list view within drawers\n *\n * @internal\n */\nexport const renderListView = async (\n args: RenderListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n ComponentOverride,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n trash,\n viewType,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query: ListQuery = queryFromArgs || queryFromReq\n\n const columnsFromQuery: ColumnPreference[] = transformColumnsToPreferences(query?.columns)\n\n query.queryByGroup =\n query?.queryByGroup && typeof query.queryByGroup === 'string'\n ? JSON.parse(query.queryByGroup)\n : query?.queryByGroup\n\n const collectionPreferences = await upsertPreferences<CollectionPreferences>({\n key: `collection-${collectionSlug}`,\n req,\n value: {\n columns: columnsFromQuery,\n groupBy: query?.groupBy,\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n preset: query?.preset,\n sort: query?.sort as string,\n },\n })\n\n query.preset = collectionPreferences?.preset\n\n query.page = isNumber(query?.page) ? Number(query.page) : 0\n\n query.limit = collectionPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n query.sort =\n collectionPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n query.groupBy = collectionPreferences?.groupBy\n\n query.columns = transformColumnsToSearchParams(collectionPreferences?.columns || [])\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const baseFilterConstraint = await (\n collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter\n )?.({\n limit: query.limit,\n page: query.page,\n req,\n sort: query.sort,\n })\n\n let queryPreset: QueryPreset | undefined\n let queryPresetPermissions: SanitizedCollectionPermission | undefined\n\n let whereWithMergedSearch = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: combineWhereConstraints([query?.where, baseFilterConstraint]),\n })\n\n if (trash === true) {\n whereWithMergedSearch = {\n and: [\n whereWithMergedSearch,\n {\n deletedAt: {\n exists: true,\n },\n },\n ],\n }\n }\n\n if (collectionPreferences?.preset) {\n try {\n queryPreset = (await payload.findByID({\n id: collectionPreferences?.preset,\n collection: 'payload-query-presets',\n depth: 0,\n overrideAccess: false,\n user,\n })) as QueryPreset\n\n if (queryPreset) {\n queryPresetPermissions = await getDocumentPermissions({\n id: queryPreset.id,\n collectionConfig: config.collections.find((c) => c.slug === 'payload-query-presets'),\n data: queryPreset,\n req,\n })?.then(({ docPermissions }) => docPermissions)\n }\n } catch (err) {\n req.payload.logger.error(`Error fetching query preset or preset permissions: ${err}`)\n }\n }\n\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[] = []\n let data: PaginatedDocs = {\n // no results default\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: query.limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const columns = getColumns({\n clientConfig,\n collectionConfig: clientCollectionConfig,\n collectionSlug,\n columns: collectionPreferences?.columns,\n i18n,\n permissions,\n })\n\n const select = collectionConfig.admin.enableListViewSelectAPI\n ? transformColumnsToSelect(columns)\n : undefined\n\n /** Force select image fields for list view thumbnails */\n appendUploadSelectFields({\n collectionConfig,\n select,\n })\n\n try {\n if (collectionConfig.admin.groupBy && query.groupBy) {\n ;({ columnState, data, Table } = await handleGroupBy({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n fieldPermissions: permissions?.collections?.[collectionSlug]?.fields,\n query,\n req,\n select,\n trash,\n user,\n viewType,\n where: whereWithMergedSearch,\n }))\n\n // Enrich documents with correct display status for drafts\n data = await enrichDocsWithVersionStatus({\n collectionConfig,\n data,\n req,\n })\n } else {\n data = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n req,\n select,\n sort: query?.sort,\n trash,\n user,\n where: whereWithMergedSearch,\n })\n\n // Enrich documents with correct display status for drafts\n data = await enrichDocsWithVersionStatus({\n collectionConfig,\n data,\n req,\n })\n ;({ columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data,\n drawerSlug,\n enableRowSelections,\n fieldPermissions: permissions?.collections?.[collectionSlug]?.fields,\n i18n: req.i18n,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n req,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n }))\n }\n } catch (err) {\n if (err.name !== 'QueryError') {\n // QueryErrors are expected when a user filters by a field they do not have access to\n req.payload.logger.error({\n err,\n msg: `There was an error fetching the list view data for collection ${collectionSlug}`,\n })\n throw err\n }\n }\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const resolvedFilterOptions = await resolveAllFilterOptions({\n fields: collectionConfig.fields,\n req,\n })\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n const hasDeletePermission = permissions?.collections?.[collectionSlug]?.delete\n\n // Check if there's a notFound query parameter (document ID that wasn't found)\n const notFoundDocId = typeof searchParams?.notFound === 'string' ? searchParams.notFound : null\n\n const serverProps: ListViewServerPropsOnly = {\n collectionConfig,\n data,\n i18n,\n limit: query.limit,\n listPreferences: collectionPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: {\n collectionSlug,\n hasCreatePermission,\n hasDeletePermission,\n newDocumentURL,\n },\n collectionConfig,\n description: staticDescription,\n notFoundDocId,\n payload,\n serverProps,\n })\n\n const isInDrawer = Boolean(drawerSlug)\n\n // Needed to prevent: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props.\n // Is there a way to avoid this? The `where` object is already seemingly plain, but is not bc it originates from the params.\n query.where = query?.where ? JSON.parse(JSON.stringify(query?.where || {})) : undefined\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n modifySearchParams={!isInDrawer}\n orderableFieldName={collectionConfig.orderable === true ? '_order' : undefined}\n query={query}\n >\n {RenderServerComponent({\n clientProps: {\n ...listViewSlots,\n collectionSlug,\n columnState,\n disableBulkDelete,\n disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,\n disableQueryPresets,\n enableRowSelections,\n hasCreatePermission,\n hasDeletePermission,\n listPreferences: collectionPreferences,\n newDocumentURL,\n queryPreset,\n queryPresetPermissions,\n renderedFilters,\n resolvedFilterOptions,\n Table,\n viewType,\n } satisfies ListViewClientProps,\n Component:\n ComponentOverride ?? collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps,\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<RenderListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AAcA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,UAAU,EAAEC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC1E,SAASC,QAAQ,QAAQ;AACzB,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,cAAc,EACdC,QAAQ,EACRC,uBAAuB,EACvBC,6BAA6B,EAC7BC,8BAA8B,QACzB;AACP,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SA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,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,+BAiTA,CAAA"}
|
package/dist/views/Root/index.js
CHANGED
|
@@ -207,6 +207,15 @@ export const RootPage = async ({
|
|
|
207
207
|
config,
|
|
208
208
|
req
|
|
209
209
|
});
|
|
210
|
+
// Ensure locale on req is still valid after filtering locales
|
|
211
|
+
if (clientConfig.localization && req.locale && !clientConfig.localization.localeCodes.includes(req.locale)) {
|
|
212
|
+
redirect(`${currentRoute}${qs.stringify({
|
|
213
|
+
...searchParams,
|
|
214
|
+
locale: clientConfig.localization.localeCodes.includes(clientConfig.localization.defaultLocale) ? clientConfig.localization.defaultLocale : clientConfig.localization.localeCodes[0]
|
|
215
|
+
}, {
|
|
216
|
+
addQueryPrefix: true
|
|
217
|
+
})}`);
|
|
218
|
+
}
|
|
210
219
|
const visibleEntities = getVisibleEntities({
|
|
211
220
|
req
|
|
212
221
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","getVisibleEntities","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","createFirstUserRoute","usersCollection","disableLocalStrategy","auth","clientConfig","i18n","visibleEntities","folderID","RenderedView","clientProps","Fallback","serverProps","docID","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className","collectionSlug","globalSlug"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { getVisibleEntities } from '../../utilities/getVisibleEntities.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRoute }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRoute })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRoute,\n searchParams,\n user: req.user,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : req.user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n documentSubViewType,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={req.user}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,QAAQ;AACrD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGb,MAAA;EAEJ,MAAMG,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAMU,YAAA,GAAe5B,cAAA,CAAe;IAClC2B,UAAA;IACAE,IAAA,EAAMC,KAAA,CAAMC,OAAO,CAACd,MAAA,CAAOe,QAAQ,IAAI,IAAIf,MAAA,CAAOe,QAAQ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M,mBAAA,EAAqBA,mBAAA;MACrB+C,UAAA,EAAYhF,YAAA,EAAcK,IAAA;MAC1B8C,IAAA,EAAMtC,GAAA,CAAIsC,IAAI;MACdxC,MAAA,EAAQA,MAAA;MACRhC,MAAA,EAAQA,MAAA;MACRmC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBF,WAAA,EAAaA,WAAA;MACbC,GAAA,EAAKA,GAAA;MACLhC,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAM0B,GAAA,CAAI1B,IAAI;MACdkD,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVc,eAAA,EAAiB;QACf;QACA;QACAjD,WAAA,EAAaiD,eAAA,EAAiBjD,WAAA;QAC9BG,OAAA,EAAS8C,eAAA,EAAiB9C;MAC5B;gBAECgD;;;AAKX","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","getVisibleEntities","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","createFirstUserRoute","usersCollection","disableLocalStrategy","auth","clientConfig","i18n","localization","localeCodes","includes","defaultLocale","visibleEntities","folderID","RenderedView","clientProps","Fallback","serverProps","docID","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className","collectionSlug","globalSlug"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { getVisibleEntities } from '../../utilities/getVisibleEntities.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRoute }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRoute })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRoute,\n searchParams,\n user: req.user,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : req.user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Ensure locale on req is still valid after filtering locales\n if (\n clientConfig.localization &&\n req.locale &&\n !clientConfig.localization.localeCodes.includes(req.locale)\n ) {\n redirect(\n `${currentRoute}${qs.stringify(\n {\n ...searchParams,\n locale: clientConfig.localization.localeCodes.includes(\n clientConfig.localization.defaultLocale,\n )\n ? clientConfig.localization.defaultLocale\n : clientConfig.localization.localeCodes[0],\n },\n { addQueryPrefix: true },\n )}`,\n )\n }\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n documentSubViewType,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={req.user}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,QAAQ;AACrD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGb,MAAA;EAEJ,MAAMG,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAMU,YAAA,GAAe5B,cAAA,CAAe;IAClC2B,UAAA;I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QACT,GACA,EAAE;QAEJ1D,MAAA;QACAC,WAAA;QACAC,GAAA;QACA8D,YAAA,EAAc9D,GAAA,CAAIsC,IAAI,CAACwB,YAAY;QACnCnB;MACF;MACA7E,MAAA;MACAmC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBjC,YAAA;MACAwD;IACF;EACF;EAEA,oBACEyC,KAAA,CAAC1H,kBAAA;IAAmBoB,MAAA,EAAQ0E,YAAA;eACzB,CAACd,YAAA,iBAAgB2C,IAAA,CAACnH,KAAA,CAAMoH,QAAQ;gBAAEtB;QAClCtB,YAAA,KAAiB,0BAChB2C,IAAA,CAACjH,eAAA;MAAgBmH,SAAA,EAAW9C,iBAAA;gBAAoBuB;QAEjDtB,YAAA,KAAiB,0BAChB2C,IAAA,CAAClH,eAAA;MACCqH,cAAA,EAAgBpF,gBAAA,EAAkBO,IAAA;MAClCyD,KAAA,EAAO5B,WAAA,CAAYP,EAAE;MACrBM,mBAAA,EAAqBA,mBAAA;MACrBkD,UAAA,EAAYnF,YAAA,EAAcK,IAAA;MAC1B8C,IAAA,EAAMtC,GAAA,CAAIsC,IAAI;MACdxC,MAAA,EAAQA,MAAA;MACRhC,MAAA,EAAQA,MAAA;MACRmC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBF,WAAA,EAAaA,WAAA;MACbC,GAAA,EAAKA,GAAA;MACLhC,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAM0B,GAAA,CAAI1B,IAAI;MACdkD,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVkB,eAAA,EAAiB;QACf;QACA;QACArD,WAAA,EAAaqD,eAAA,EAAiBrD,WAAA;QAC9BG,OAAA,EAASkD,eAAA,EAAiBlD;MAC5B;gBAECoD;;;AAKX","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,CAuIrC"}
|
package/dist/withPayload.js
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
// External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):
|
|
65
65
|
'@payloadcms/db-mongodb',
|
|
66
66
|
// External because they install dependencies like drizzle, libsql, esbuild etc.:
|
|
67
|
-
'@payloadcms/db-postgres', '@payloadcms/db-sqlite', '@payloadcms/db-vercel-postgres', '@payloadcms/drizzle',
|
|
67
|
+
'@payloadcms/db-postgres', '@payloadcms/db-sqlite', '@payloadcms/db-vercel-postgres', '@payloadcms/drizzle', '@payloadcms/db-d1-sqlite',
|
|
68
68
|
// External because they install @aws-sdk/client-s3:
|
|
69
69
|
'@payloadcms/payload-cloud',
|
|
70
70
|
// External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
|
package/dist/withPayload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayload.js","names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"sources":["../src/withPayload.js"],"sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default true\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // These packages always need to be external, both during dev and production. This is because they install dependencies\n // that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).\n // We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed\n // by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,\n // as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users\n // to install the dependencies directly.\n // Thus, we externalize the \"entry-point\" = the package that is installed by the end user, which would be our db adapters.\n //\n //\n // External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):\n '@payloadcms/db-mongodb',\n // External because they install dependencies like drizzle, libsql, esbuild etc.:\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n // External because they install @aws-sdk/client-s3:\n '@payloadcms/payload-cloud',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n // TODO: We need to externalize @payloadcms/storage-s3 as well, once Next.js has the ability to exclude @payloadcms/storage-s3/client from being externalized.\n // Do not bundle additional server-only packages during dev to improve compilation speed\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false\n ? [\n 'payload',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [...(incomingWebpackConfig?.externals || []), 'require-in-the-middle'],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;;KAOA,OAAO,MAAMA,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,GAAA,GAAMF,UAAA,CAAWE,GAAG,IAAI,CAAC;EAE/B,IAAIF,UAAA,CAAWG,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAAG;EAChD;EAEA,MAAMC,eAAA,GAAkB;IACtBC,GAAA,EAAK;IACLC,KAAA,EAAO;EACT;EAEA;;;EAGA,MAAMC,QAAA,GAAW;IACf,GAAGZ,UAAU;IACbE,GAAA;IACAW,SAAA,EAAW;MACT,IAAIb,UAAA,CAAWa,SAAS,IAAI,CAAC,CAAC;IAChC;IACAC,yBAAA,EAA2B;MACzB,IAAId,UAAA,CAAWc,yBAAyB,IAAI,CAAC,CAAC;MAC9C,QAAQ,C,IACFd,UAAA,CAAWc,yBAAyB,GAAG,OAAO,IAAI,EAAE,GACxD,eACA;IAEJ;IACAC,yBAAA,EAA2B;MACzB,IAAIf,UAAA,CAAWe,yBAAyB,IAAI,CAAC,CAAC;MAC9C,QAAQ,C,IAAKf,UAAA,CAAWe,yBAAyB,GAAG,OAAO,IAAI,EAAE,GAAG;IACtE;IACA;IACA,IAAIf,UAAA,CAAW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AgB;QAClB;MAEJ;IACF;EACF;EAEA,IAAI9B,UAAA,CAAW+B,QAAQ,EAAE;IACvBnB,QAAA,CAASV,GAAG,CAAC8B,cAAc,GAAGhC,UAAA,CAAW+B,QAAQ;EACnD;EAEA,OAAOnB,QAAA;AACT;AAEA,eAAeb,WAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"withPayload.js","names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"sources":["../src/withPayload.js"],"sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default true\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // These packages always need to be external, both during dev and production. This is because they install dependencies\n // that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).\n // We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed\n // by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,\n // as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users\n // to install the dependencies directly.\n // Thus, we externalize the \"entry-point\" = the package that is installed by the end user, which would be our db adapters.\n //\n //\n // External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):\n '@payloadcms/db-mongodb',\n // External because they install dependencies like drizzle, libsql, esbuild etc.:\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n '@payloadcms/db-d1-sqlite',\n // External because they install @aws-sdk/client-s3:\n '@payloadcms/payload-cloud',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n // TODO: We need to externalize @payloadcms/storage-s3 as well, once Next.js has the ability to exclude @payloadcms/storage-s3/client from being externalized.\n // Do not bundle additional server-only packages during dev to improve compilation speed\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false\n ? [\n 'payload',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [...(incomingWebpackConfig?.externals || []), 'require-in-the-middle'],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;;KAOA,OAAO,MAAMA,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,GAAA,GAAMF,UAAA,CAAWE,GAAG,IAAI,CAAC;EAE/B,IAAIF,UAAA,CAAWG,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAA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;IACA;IACA;IACA;IACA;IACA;QACIC,OAAA,CAAQlB,GAAG,CAACmB,QAAQ,KAAK,iBAAiBpB,OAAA,CAAQqB,uBAAuB,KAAK,QAC9E,CACE,WACA,gCACA,4BACA,uBACA,+BAWD,GACD,EAAE,EACP;IACDC,OAAA,EAASA,CAACC,aAAA,EAAeC,cAAA;MACvB,MAAMC,qBAAA,GACJ,OAAO1B,UAAA,CAAWuB,OAAO,KAAK,aAC1BvB,UAAA,CAAWuB,OAAO,CAACC,aAAA,EAAeC,cAAA,IAClCD,aAAA;MAEN,OAAO;QACL,GAAGE,qBAAqB;QACxBC,SAAA,EAAW,C,IAAKD,qBAAA,EAAuBC,SAAA,IAAa,EAAE,GAAG,wBAAwB;QACjFC,OAAA,EAAS,C,IACHF,qBAAA,EAAuBE,OAAA,IAAW,EAAE;QACxC;QACA,IAAIH,cAAA,CAAeF,OAAO,CAACM,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB;MAEJ;IACF;EACF;EAEA,IAAI9B,UAAA,CAAW+B,QAAQ,EAAE;IACvBnB,QAAA,CAASV,GAAG,CAAC8B,cAAc,GAAGhC,UAAA,CAAW+B,QAAQ;EACnD;EAEA,OAAOnB,QAAA;AACT;AAEA,eAAeb,WAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.64.0
|
|
3
|
+
"version": "3.64.0",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"qs-esm": "7.0.2",
|
|
98
98
|
"sass": "1.77.4",
|
|
99
99
|
"uuid": "10.0.0",
|
|
100
|
-
"@payloadcms/graphql": "3.64.0
|
|
101
|
-
"@payloadcms/
|
|
102
|
-
"@payloadcms/
|
|
100
|
+
"@payloadcms/graphql": "3.64.0",
|
|
101
|
+
"@payloadcms/translations": "3.64.0",
|
|
102
|
+
"@payloadcms/ui": "3.64.0"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@babel/cli": "7.27.2",
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
"esbuild": "0.25.5",
|
|
117
117
|
"esbuild-sass-plugin": "3.3.1",
|
|
118
118
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
119
|
-
"
|
|
120
|
-
"
|
|
119
|
+
"payload": "3.64.0",
|
|
120
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"graphql": "^16.8.1",
|
|
124
124
|
"next": "^15.2.3",
|
|
125
|
-
"payload": "3.64.0
|
|
125
|
+
"payload": "3.64.0"
|
|
126
126
|
},
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": "^18.20.2 || >=20.9.0"
|