@payloadcms/next 3.5.0 → 3.5.1-canary.85da7f2
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/routes/rest/collections/preview.d.ts.map +1 -1
- package/dist/routes/rest/collections/preview.js +2 -6
- package/dist/routes/rest/collections/preview.js.map +1 -1
- package/dist/routes/rest/globals/preview.js +2 -2
- package/dist/routes/rest/globals/preview.js.map +1 -1
- package/dist/views/LivePreview/index.js +6 -5
- package/dist/views/LivePreview/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,OAAO,EAAE,4BA4CrB,CAAA"}
|
|
@@ -12,7 +12,7 @@ export const preview = async ({
|
|
|
12
12
|
searchParams
|
|
13
13
|
} = req;
|
|
14
14
|
const depth = searchParams.get('depth');
|
|
15
|
-
const
|
|
15
|
+
const doc = await findByIDOperation({
|
|
16
16
|
id,
|
|
17
17
|
collection,
|
|
18
18
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
@@ -24,15 +24,11 @@ export const preview = async ({
|
|
|
24
24
|
const token = extractJWT(req);
|
|
25
25
|
if (typeof generatePreviewURL === 'function') {
|
|
26
26
|
try {
|
|
27
|
-
previewURL = await generatePreviewURL(
|
|
27
|
+
previewURL = await generatePreviewURL(doc, {
|
|
28
28
|
locale: req.locale,
|
|
29
29
|
req,
|
|
30
30
|
token
|
|
31
31
|
});
|
|
32
|
-
// Support relative URLs by prepending the origin, if necessary
|
|
33
|
-
if (previewURL && previewURL.startsWith('/')) {
|
|
34
|
-
previewURL = `${req.protocol}//${req.host}${previewURL}`;
|
|
35
|
-
}
|
|
36
32
|
} catch (err) {
|
|
37
33
|
return routeError({
|
|
38
34
|
collection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findByIDOperation","isNumber","headersWithCors","routeError","preview","id","collection","req","searchParams","depth","get","
|
|
1
|
+
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findByIDOperation","isNumber","headersWithCors","routeError","preview","id","collection","req","searchParams","depth","get","doc","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","collections","find","slug","admin","token","locale","err","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT, findByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.collections.find(\n (config) => config.slug === collection.config.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(doc, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACv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;MACbtB;IACF;IACAuB,MAAA,EAAQhC,UAAA,CAAWiC;EACrB;AACF","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ export const preview = async ({
|
|
|
11
11
|
searchParams
|
|
12
12
|
} = req;
|
|
13
13
|
const depth = searchParams.get('depth');
|
|
14
|
-
const
|
|
14
|
+
const doc = await findOneOperation({
|
|
15
15
|
slug: globalConfig.slug,
|
|
16
16
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
17
17
|
draft: searchParams.get('draft') === 'true',
|
|
@@ -23,7 +23,7 @@ export const preview = async ({
|
|
|
23
23
|
const token = extractJWT(req);
|
|
24
24
|
if (typeof generatePreviewURL === 'function') {
|
|
25
25
|
try {
|
|
26
|
-
previewURL = await generatePreviewURL(
|
|
26
|
+
previewURL = await generatePreviewURL(doc, {
|
|
27
27
|
locale: req.locale,
|
|
28
28
|
req,
|
|
29
29
|
token
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findOneOperation","isNumber","headersWithCors","routeError","preview","globalConfig","req","searchParams","depth","get","
|
|
1
|
+
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findOneOperation","isNumber","headersWithCors","routeError","preview","globalConfig","req","searchParams","depth","get","doc","slug","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","globals","find","admin","token","locale","err","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT, findOneOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = await findOneOperation({\n slug: globalConfig.slug,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n globalConfig,\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.globals.find(\n (config) => config.slug === globalConfig.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(doc, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,UAAU,EAAEC,gBAAgB,QAAQ;AAC7C,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAE3B,OAAO,MAAMC,OAAA,GAA8B,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACrE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMC,GAAA,GAAM,MAAMV,gBAAA,CAAiB;IACjCW,IAAA,EAAMN,YAAA,CAAaM,IAAI;IACvBH,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASI,MAAA,CAAOJ,KAAA,IAASK,SAAA;IACzCC,KAAA,EAAOP,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCJ,YAAA;IACAC;EACF;EAEA,IAAIS,UAAA;EAEJ,MAAMC,kBAAA,GAAqBV,GAAA,CAAIW,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CACvDF,MAAA,IAAWA,MAAA,CAAOP,IAAI,KAAKN,YAAA,CAAaM,IAAI,GAC5CU,KAAA,EAAOjB,OAAA;EAEV,MAAMkB,KAAA,GAAQvB,UAAA,CAAWO,GAAA;EAEzB,IAAI,OAAOU,kBAAA,KAAuB,YAAY;IAC5C,IAAI;MACFD,UAAA,GAAa,MAAMC,kBAAA,CAAmBN,GAAA,EAAK;QACzCa,MAAA,EAAQjB,GAAA,CAAIiB,MAAM;QAClBjB,GAAA;QACAgB;MACF;IACF,EAAE,OAAOE,GAAA,EAAK;MACZ,OAAOrB,UAAA,CAAW;QAChBe,MAAA,EAAQZ,GAAA,CAAIW,OAAO,CAACC,MAAM;QAC1BM,GAAA;QACAlB;MACF;IACF;EACF;EAEA,OAAOmB,QAAA,CAASC,IAAI,CAACX,UAAA,EAAY;IAC/BY,OAAA,EAASzB,eAAA,CAAgB;MACvByB,OAAA,EAAS,IAAIC,OAAA;MACbtB;IACF;IACAuB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AACF","ignoreList":[]}
|
|
@@ -31,17 +31,18 @@ export const LivePreviewView = async props => {
|
|
|
31
31
|
label: 'Responsive',
|
|
32
32
|
width: '100%'
|
|
33
33
|
}];
|
|
34
|
-
|
|
34
|
+
const url = typeof livePreviewConfig?.url === 'function' ? await livePreviewConfig.url({
|
|
35
35
|
collectionConfig,
|
|
36
36
|
data: doc,
|
|
37
37
|
globalConfig,
|
|
38
38
|
locale,
|
|
39
|
+
req,
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated
|
|
42
|
+
* Use `req.payload` instead. This will be removed in the next major version.
|
|
43
|
+
*/
|
|
39
44
|
payload: initPageResult.req.payload
|
|
40
45
|
}) : livePreviewConfig?.url;
|
|
41
|
-
// Support relative URLs by prepending the origin, if necessary
|
|
42
|
-
if (url && url.startsWith('/')) {
|
|
43
|
-
url = `${initPageResult.req.protocol}//${initPageResult.req.host}${url}`;
|
|
44
|
-
}
|
|
45
46
|
return /*#__PURE__*/_jsx(LivePreviewClient, {
|
|
46
47
|
breakpoints: breakpoints,
|
|
47
48
|
initialData: doc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","LivePreviewClient","LivePreviewView","props","doc","initPageResult","collectionConfig","globalConfig","locale","req","livePreviewConfig","payload","config","admin","livePreview","breakpoints","name","height","label","width","url","data","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","LivePreviewClient","LivePreviewView","props","doc","initPageResult","collectionConfig","globalConfig","locale","req","livePreviewConfig","payload","config","admin","livePreview","breakpoints","name","height","label","width","url","data","_jsx","initialData"],"sources":["../../../src/views/LivePreview/index.tsx"],"sourcesContent":["import type { EditViewComponent, LivePreviewConfig, PayloadServerReactComponent } from 'payload'\n\nimport React from 'react'\n\nimport './index.scss'\nimport { LivePreviewClient } from './index.client.js'\n\nexport const LivePreviewView: PayloadServerReactComponent<EditViewComponent> = async (props) => {\n const { doc, initPageResult } = props\n\n const { collectionConfig, globalConfig, locale, req } = initPageResult\n\n let livePreviewConfig: LivePreviewConfig = req.payload.config?.admin?.livePreview\n\n if (collectionConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(collectionConfig.admin.livePreview || {}),\n }\n }\n\n if (globalConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(globalConfig.admin.livePreview || {}),\n }\n }\n\n const breakpoints: LivePreviewConfig['breakpoints'] = [\n ...(livePreviewConfig?.breakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ]\n\n const url =\n typeof livePreviewConfig?.url === 'function'\n ? await livePreviewConfig.url({\n collectionConfig,\n data: doc,\n globalConfig,\n locale,\n req,\n /**\n * @deprecated\n * Use `req.payload` instead. This will be removed in the next major version.\n */\n payload: initPageResult.req.payload,\n })\n : livePreviewConfig?.url\n\n return <LivePreviewClient breakpoints={breakpoints} initialData={doc} url={url} />\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAGlB,SAASC,iBAAiB,QAAQ;AAElC,OAAO,MAAMC,eAAA,GAAkE,MAAOC,KAAA;EACpF,MAAM;IAAEC,GAAG;IAAEC;EAAc,CAAE,GAAGF,KAAA;EAEhC,MAAM;IAAEG,gBAAgB;IAAEC,YAAY;IAAEC,MAAM;IAAEC;EAAG,CAAE,GAAGJ,cAAA;EAExD,IAAIK,iBAAA,GAAuCD,GAAA,CAAIE,OAAO,CAACC,MAAM,EAAEC,KAAA,EAAOC,WAAA;EAEtE,IAAIR,gBAAA,EAAkB;IACpBI,iBAAA,GAAoB;MAClB,IAAIA,iBAAA,IAAqB,CAAC,CAAC;MAC3B,IAAIJ,gBAAA,CAAiBO,KAAK,CAACC,WAAW,IAAI,CAAC,CAAC;IAC9C;EACF;EAEA,IAAIP,YAAA,EAAc;IAChBG,iBAAA,GAAoB;MAClB,IAAIA,iBAAA,IAAqB,CAAC,CAAC;MAC3B,IAAIH,YAAA,CAAaM,KAAK,CAACC,WAAW,IAAI,CAAC,CAAC;IAC1C;EACF;EAEA,MAAMC,WAAA,GAAgD,C,IAChDL,iBAAA,EAAmBK,WAAA,IAAe,EAAE,GACxC;IACEC,IAAA,EAAM;IACNC,MAAA,EAAQ;IACRC,KAAA,EAAO;IACPC,KAAA,EAAO;EACT,EACD;EAED,MAAMC,GAAA,GACJ,OAAOV,iBAAA,EAAmBU,GAAA,KAAQ,aAC9B,MAAMV,iBAAA,CAAkBU,GAAG,CAAC;IAC1Bd,gBAAA;IACAe,IAAA,EAAMjB,GAAA;IACNG,YAAA;IACAC,MAAA;IACAC,GAAA;IACA;;;;IAIAE,OAAA,EAASN,cAAA,CAAeI,GAAG,CAACE;EAC9B,KACAD,iBAAA,EAAmBU,GAAA;EAEzB,oBAAOE,IAAA,CAACrB,iBAAA;IAAkBc,WAAA,EAAaA,WAAA;IAAaQ,WAAA,EAAanB,GAAA;IAAKgB,GAAA,EAAKA;;AAC7E","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-canary.85da7f2",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"sass": "1.77.4",
|
|
80
80
|
"sonner": "^1.7.0",
|
|
81
81
|
"uuid": "10.0.0",
|
|
82
|
-
"@payloadcms/graphql": "3.5.
|
|
83
|
-
"@payloadcms/translations": "3.5.
|
|
84
|
-
"@payloadcms/ui": "3.5.
|
|
82
|
+
"@payloadcms/graphql": "3.5.1-canary.85da7f2",
|
|
83
|
+
"@payloadcms/translations": "3.5.1-canary.85da7f2",
|
|
84
|
+
"@payloadcms/ui": "3.5.1-canary.85da7f2"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@babel/cli": "7.25.9",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
"esbuild-sass-plugin": "3.3.1",
|
|
100
100
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
101
101
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
102
|
+
"@payloadcms/eslint-config": "3.0.0",
|
|
103
|
+
"payload": "3.5.1-canary.85da7f2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"graphql": "^16.8.1",
|
|
107
107
|
"next": "^15.0.0",
|
|
108
|
-
"payload": "3.5.
|
|
108
|
+
"payload": "3.5.1-canary.85da7f2"
|
|
109
109
|
},
|
|
110
110
|
"engines": {
|
|
111
111
|
"node": "^18.20.2 || >=20.9.0"
|