@payloadcms/next 3.0.0-beta.107 → 3.0.0-beta.109
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.js +4 -4
- package/dist/cjs/withPayload.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +28 -24
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
- package/dist/elements/DocumentLocked/index.d.ts +12 -0
- package/dist/elements/DocumentLocked/index.d.ts.map +1 -0
- package/dist/elements/DocumentLocked/index.js +142 -0
- package/dist/elements/DocumentLocked/index.js.map +1 -0
- package/dist/elements/DocumentLocked/index.scss +37 -0
- package/dist/elements/DocumentTakeOver/index.d.ts +8 -0
- package/dist/elements/DocumentTakeOver/index.d.ts.map +1 -0
- package/dist/elements/DocumentTakeOver/index.js +98 -0
- package/dist/elements/DocumentTakeOver/index.js.map +1 -0
- package/dist/elements/DocumentTakeOver/index.scss +37 -0
- package/dist/elements/Nav/NavWrapper/index.scss +5 -0
- package/dist/elements/Nav/index.scss +5 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +52 -20
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +23 -11
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/collections/find.d.ts.map +1 -1
- package/dist/routes/rest/collections/find.js +3 -0
- package/dist/routes/rest/collections/find.js.map +1 -1
- package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findByID.js +2 -0
- package/dist/routes/rest/collections/findByID.js.map +1 -1
- package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/updateByID.js +2 -0
- package/dist/routes/rest/collections/updateByID.js.map +1 -1
- package/dist/routes/rest/globals/update.d.ts.map +1 -1
- package/dist/routes/rest/globals/update.js +2 -0
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/dist/routes/rest/routeError.d.ts +2 -7
- package/dist/routes/rest/routeError.d.ts.map +1 -1
- package/dist/routes/rest/routeError.js +33 -19
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts +13 -0
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts.map +1 -0
- package/dist/routes/rest/utilities/sanitizeJoinParams.js +17 -0
- package/dist/routes/rest/utilities/sanitizeJoinParams.js.map +1 -0
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +7 -3
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/templates/Default/index.scss +6 -1
- package/dist/utilities/getRequestTheme.d.ts.map +1 -1
- package/dist/utilities/getRequestTheme.js +3 -0
- package/dist/utilities/getRequestTheme.js.map +1 -1
- package/dist/utilities/initPage/index.d.ts.map +1 -1
- package/dist/utilities/initPage/index.js +22 -32
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/utilities/initReq.d.ts +11 -0
- package/dist/utilities/initReq.d.ts.map +1 -0
- package/dist/utilities/initReq.js +46 -0
- package/dist/utilities/initReq.js.map +1 -0
- package/dist/views/Account/Settings/index.d.ts +2 -1
- package/dist/views/Account/Settings/index.d.ts.map +1 -1
- package/dist/views/Account/Settings/index.js +3 -2
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +3 -1
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +35 -16
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/Dashboard/Default/index.d.ts +8 -1
- package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/index.js +14 -2
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/Default/index.scss +5 -0
- package/dist/views/Dashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/index.js +16 -1
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/getDocumentData.d.ts +5 -2
- package/dist/views/Document/getDocumentData.d.ts.map +1 -1
- package/dist/views/Document/getDocumentData.js +13 -2
- package/dist/views/Document/getDocumentData.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +127 -14
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +3 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.js +2 -2
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/Default/index.d.ts.map +1 -1
- package/dist/views/List/Default/index.js +62 -58
- package/dist/views/List/Default/index.js.map +1 -1
- package/dist/views/List/Default/index.scss +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +1 -0
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +214 -200
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/LivePreview/usePopupWindow.js +119 -74
- package/dist/views/LivePreview/usePopupWindow.js.map +1 -1
- package/dist/views/Login/LoginForm/index.js +2 -2
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +2 -0
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +8 -14
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +24 -3
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/types.d.ts +1 -0
- package/dist/views/Version/SelectComparison/types.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/types.js.map +1 -1
- package/dist/views/Versions/buildColumns.d.ts.map +1 -1
- package/dist/views/Versions/buildColumns.js +63 -48
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.d.ts.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +48 -20
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +23 -6
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +4 -4
- package/dist/withPayload.js.map +1 -1
- package/package.json +23 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAmEjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAsD9E,CAAA"}
|
|
@@ -6,33 +6,42 @@ import { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest
|
|
|
6
6
|
import { createPayloadRequest } from '../../utilities/createPayloadRequest.js';
|
|
7
7
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
8
8
|
import { mergeHeaders } from '../../utilities/mergeHeaders.js';
|
|
9
|
-
const handleError = async (
|
|
9
|
+
const handleError = async ({
|
|
10
|
+
err,
|
|
11
|
+
payload,
|
|
12
|
+
req
|
|
13
|
+
}) => {
|
|
10
14
|
const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR;
|
|
11
15
|
let errorMessage = err.message;
|
|
12
16
|
payload.logger.error(err.stack);
|
|
13
17
|
// Internal server errors can contain anything, including potentially sensitive data.
|
|
14
18
|
// Therefore, error details will be hidden from the response unless `config.debug` is `true`
|
|
15
|
-
if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
|
|
19
|
+
if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
|
|
16
20
|
errorMessage = 'Something went wrong.';
|
|
17
21
|
}
|
|
18
22
|
let response = {
|
|
19
23
|
extensions: {
|
|
20
24
|
name: err?.originalError?.name || undefined,
|
|
21
25
|
data: err && err.originalError && err.originalError.data || undefined,
|
|
22
|
-
stack: debug ? err.stack : undefined,
|
|
26
|
+
stack: payload.config.debug ? err.stack : undefined,
|
|
23
27
|
statusCode: status
|
|
24
28
|
},
|
|
25
29
|
locations: err.locations,
|
|
26
30
|
message: errorMessage,
|
|
27
31
|
path: err.path
|
|
28
32
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
await payload.config.hooks.afterError?.reduce(async (promise, hook) => {
|
|
34
|
+
await promise;
|
|
35
|
+
const result = await hook({
|
|
36
|
+
context: req.context,
|
|
37
|
+
error: err,
|
|
38
|
+
graphqlResult: response,
|
|
39
|
+
req
|
|
34
40
|
});
|
|
35
|
-
|
|
41
|
+
if (result) {
|
|
42
|
+
response = result.graphqlResult || response;
|
|
43
|
+
}
|
|
44
|
+
}, Promise.resolve());
|
|
36
45
|
return response;
|
|
37
46
|
};
|
|
38
47
|
let cached = global._payload_graphql;
|
|
@@ -82,7 +91,6 @@ export const POST = config => async request => {
|
|
|
82
91
|
const {
|
|
83
92
|
payload
|
|
84
93
|
} = req;
|
|
85
|
-
const afterErrorHook = typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null;
|
|
86
94
|
const headers = {};
|
|
87
95
|
const apiResponse = await createHandler({
|
|
88
96
|
context: {
|
|
@@ -97,7 +105,11 @@ export const POST = config => async request => {
|
|
|
97
105
|
}) : result;
|
|
98
106
|
if (response.errors) {
|
|
99
107
|
const errors = await Promise.all(result.errors.map(error => {
|
|
100
|
-
return handleError(
|
|
108
|
+
return handleError({
|
|
109
|
+
err: error,
|
|
110
|
+
payload,
|
|
111
|
+
req
|
|
112
|
+
});
|
|
101
113
|
}));
|
|
102
114
|
// errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult
|
|
103
115
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","
|
|
1
|
+
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","err","payload","req","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","config","debug","response","extensions","name","undefined","data","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","graphqlResult","Promise","resolve","cached","global","_payload_graphql","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","schema","e","POST","request","originalRequest","clone","validationRules","headers","apiResponse","onOperation","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","Response","body","responseHeaders"],"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { APIError, Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: GraphQLError\n payload: Payload\n req: PayloadRequest\n}): Promise<GraphQLFormattedError> => {\n const status = (err.originalError as APIError).status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && (err.originalError as APIError).data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError({ err: error, payload, req })\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n }\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,OAAOC,UAAA,MAAgB;AAEvB,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAE7B,MAAMC,WAAA,GAAc,MAAAA,CAAO;EACzBC,GAAG;EACHC,OAAO;EACPC;AAAG,CAKJ;EACC,MAAMC,MAAA,GAASH,GAAC,CAAII,aAAa,CAAcD,MAAM,IAAIV,UAAA,CAAWY,qBAAqB;EACzF,IAAIC,YAAA,GAAeN,GAAA,CAAIO,OAAO;EAC9BN,OAAA,CAAQO,MAAM,CAACC,KAAK,C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mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,IAAI,EAAE,sBA8BlB,CAAA"}
|
|
@@ -2,6 +2,7 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { findOperation } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
|
+
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
5
6
|
export const find = async ({
|
|
6
7
|
collection,
|
|
7
8
|
req
|
|
@@ -9,6 +10,7 @@ export const find = async ({
|
|
|
9
10
|
const {
|
|
10
11
|
depth,
|
|
11
12
|
draft,
|
|
13
|
+
joins,
|
|
12
14
|
limit,
|
|
13
15
|
page,
|
|
14
16
|
sort,
|
|
@@ -18,6 +20,7 @@ export const find = async ({
|
|
|
18
20
|
collection,
|
|
19
21
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
20
22
|
draft: draft === 'true',
|
|
23
|
+
joins: sanitizeJoinParams(joins),
|
|
21
24
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
22
25
|
page: isNumber(page) ? Number(page) : undefined,
|
|
23
26
|
req,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;
|
|
1
|
+
{"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","sanitizeJoinParams","find","collection","req","depth","draft","joins","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { JoinQuery, Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, joins, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n joins: sanitizeJoinParams(joins),\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,IAAA,GAA+B,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGP,GAAA,CAAIQ,KAAK;EAUnE,MAAMC,MAAA,GAAS,MAAMf,aAAA,CAAc;IACjCK,UAAA;IACAE,KAAA,EAAON,QAAA,CAASM,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCT,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAON,kBAAA,CAAmBM,KAAA;IAC1BC,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASM,MAAA,CAAON,KAAA,IAASO,SAAA;IACzCN,IAAA,EAAMV,QAAA,CAASU,IAAA,IAAQK,MAAA,CAAOL,IAAA,IAAQM,SAAA;IACtCX,GAAA;IACAM,IAAA;IACAC;EACF;EAEA,OAAOK,QAAA,CAASC,IAAI,CAACJ,MAAA,EAAQ;IAC3BK,OAAA,EAASlB,eAAA,CAAgB;MACvBkB,OAAA,EAAS,IAAIC,OAAA;MACbf;IACF;IACAgB,MAAA,EAAQvB,UAAA,CAAWwB;EACrB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAM/D,eAAO,MAAM,QAAQ,EAAE,4BA8BtB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { findByIDOperation } from 'payload';
|
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
+
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
6
7
|
export const findByID = async ({
|
|
7
8
|
id: incomingID,
|
|
8
9
|
collection,
|
|
@@ -22,6 +23,7 @@ export const findByID = async ({
|
|
|
22
23
|
collection,
|
|
23
24
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
24
25
|
draft: searchParams.get('draft') === 'true',
|
|
26
|
+
joins: sanitizeJoinParams(req.query.joins),
|
|
25
27
|
req
|
|
26
28
|
});
|
|
27
29
|
return Response.json(result, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeJoinParams","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","joins","query","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import type { JoinQuery } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\n\nexport const findByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n joins: sanitizeJoinParams(req.query.joins as JoinQuery),\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,QAAA,GAAyC,MAAAA,CAAO;EAC3DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMN,EAAA,GAAKH,oBAAA,CAAqB;IAC9BG,EAAA,EAAIC,UAAA;IACJM,cAAA,EAAgBL,UAAA,CAAWM,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASP,GAAA,CAAIO;EACf;EAEA,MAAMC,MAAA,GAAS,MAAMjB,iBAAA,CAAkB;IACrCM,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOV,QAAA,CAASU,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCC,KAAA,EAAOV,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCS,KAAA,EAAOjB,kBAAA,CAAmBK,GAAA,CAAIa,KAAK,CAACD,KAAK;IACzCZ;EACF;EAEA,OAAOc,QAAA,CAASC,IAAI,CAACP,MAAA,EAAQ;IAC3BQ,OAAA,EAASvB,eAAA,CAAgB;MACvBuB,OAAA,EAAS,IAAIC,OAAA;MACbjB;IACF;IACAkB,MAAA,EAAQ5B,UAAA,CAAW6B;EACrB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/updateByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/updateByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,4BAkDxB,CAAA"}
|
|
@@ -14,6 +14,7 @@ export const updateByID = async ({
|
|
|
14
14
|
const depth = searchParams.get('depth');
|
|
15
15
|
const autosave = searchParams.get('autosave') === 'true';
|
|
16
16
|
const draft = searchParams.get('draft') === 'true';
|
|
17
|
+
const publishSpecificLocale = req.query.publishSpecificLocale;
|
|
17
18
|
const id = sanitizeCollectionID({
|
|
18
19
|
id: incomingID,
|
|
19
20
|
collectionSlug: collection.config.slug,
|
|
@@ -26,6 +27,7 @@ export const updateByID = async ({
|
|
|
26
27
|
data: req.data,
|
|
27
28
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
28
29
|
draft,
|
|
30
|
+
publishSpecificLocale,
|
|
29
31
|
req
|
|
30
32
|
});
|
|
31
33
|
let message = req.t('general:updatedSuccessfully');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateByID.js","names":["httpStatus","updateByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","collectionSlug","config","slug","payload","doc","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,QAAA,GAAWH,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"updateByID.js","names":["httpStatus","updateByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","publishSpecificLocale","query","collectionSlug","config","slug","payload","doc","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n publishSpecificLocale,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,QAAA,GAAWH,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAMG,qBAAA,GAAwBN,GAAA,CAAIO,KAAK,CAACD,qBAAqB;EAE7D,MAAMT,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJU,cAAA,EAAgBT,UAAA,CAAWU,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASX,GAAA,CAAIW;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMpB,mBAAA,CAAoB;IACpCK,EAAA;IACAO,QAAA;IACAL,UAAA;IACAc,IAAA,EAAMb,GAAA,CAAIa,IAAI;IACdX,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASY,MAAA,CAAOZ,KAAA,IAASa,SAAA;IACzCV,KAAA;IACAC,qBAAA;IACAN;EACF;EAEA,IAAIgB,OAAA,GAAUhB,GAAA,CAAIiB,CAAC,CAAC;EAEpB,IAAIZ,KAAA,EAAO;IACTW,OAAA,GAAUhB,GAAA,CAAIiB,CAAC,CAAC;EAClB;EACA,IAAIb,QAAA,EAAU;IACZY,OAAA,GAAUhB,GAAA,CAAIiB,CAAC,CAAC;EAClB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEP,GAAA;IACAI;EACF,GACA;IACEI,OAAA,EAAS1B,eAAA,CAAgB;MACvB0B,OAAA,EAAS,IAAIC,OAAA;MACbrB;IACF;IACAsB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/update.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/update.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,MAAM,EAAE,kBAwCpB,CAAA"}
|
|
@@ -12,6 +12,7 @@ export const update = async ({
|
|
|
12
12
|
const depth = searchParams.get('depth');
|
|
13
13
|
const draft = searchParams.get('draft') === 'true';
|
|
14
14
|
const autosave = searchParams.get('autosave') === 'true';
|
|
15
|
+
const publishSpecificLocale = req.query.publishSpecificLocale;
|
|
15
16
|
const result = await updateOperationGlobal({
|
|
16
17
|
slug: globalConfig.slug,
|
|
17
18
|
autosave,
|
|
@@ -19,6 +20,7 @@ export const update = async ({
|
|
|
19
20
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
20
21
|
draft,
|
|
21
22
|
globalConfig,
|
|
23
|
+
publishSpecificLocale,
|
|
22
24
|
req
|
|
23
25
|
});
|
|
24
26
|
let message = req.t('general:updatedSuccessfully');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","names":["httpStatus","updateOperationGlobal","isNumber","headersWithCors","update","globalConfig","req","searchParams","depth","get","draft","autosave","result","slug","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/update.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateOperationGlobal } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft') === 'true'\n const autosave = searchParams.get('autosave') === 'true'\n\n const result = await updateOperationGlobal({\n slug: globalConfig.slug,\n autosave,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n globalConfig,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n message,\n result,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAA6B,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,QAAA,GAAWJ,YAAA,CAAaE,GAAG,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"update.js","names":["httpStatus","updateOperationGlobal","isNumber","headersWithCors","update","globalConfig","req","searchParams","depth","get","draft","autosave","publishSpecificLocale","query","result","slug","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/update.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateOperationGlobal } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft') === 'true'\n const autosave = searchParams.get('autosave') === 'true'\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\n\n const result = await updateOperationGlobal({\n slug: globalConfig.slug,\n autosave,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n globalConfig,\n publishSpecificLocale,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n message,\n result,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAA6B,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,QAAA,GAAWJ,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAMG,qBAAA,GAAwBN,GAAA,CAAIO,KAAK,CAACD,qBAAqB;EAE7D,MAAME,MAAA,GAAS,MAAMb,qBAAA,CAAsB;IACzCc,IAAA,EAAMV,YAAA,CAAaU,IAAI;IACvBJ,QAAA;IACAK,IAAA,EAAMV,GAAA,CAAIU,IAAI;IACdR,KAAA,EAAON,QAAA,CAASM,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCR,KAAA;IACAL,YAAA;IACAO,qBAAA;IACAN;EACF;EAEA,IAAIa,OAAA,GAAUb,GAAA,CAAIc,CAAC,CAAC;EAEpB,IAAIV,KAAA,EAAO;IACTS,OAAA,GAAUb,GAAA,CAAIc,CAAC,CAAC;EAClB;EACA,IAAIT,QAAA,EAAU;IACZQ,OAAA,GAAUb,GAAA,CAAIc,CAAC,CAAC;EAClB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEH,OAAA;IACAL;EACF,GACA;IACES,OAAA,EAASpB,eAAA,CAAgB;MACvBoB,OAAA,EAAS,IAAIC,OAAA;MACblB;IACF;IACAmB,MAAA,EAAQzB,UAAA,CAAW0B;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import type { Collection, PayloadRequest, SanitizedConfig } from 'payload';
|
|
2
2
|
import { APIError } from 'payload';
|
|
3
|
-
export
|
|
4
|
-
data?: any;
|
|
5
|
-
errors: unknown[];
|
|
6
|
-
stack?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const routeError: ({ collection, config: configArg, err, req, }: {
|
|
3
|
+
export declare const routeError: ({ collection, config: configArg, err, req: incomingReq, }: {
|
|
9
4
|
collection?: Collection;
|
|
10
5
|
config: Promise<SanitizedConfig> | SanitizedConfig;
|
|
11
6
|
err: APIError;
|
|
12
|
-
req:
|
|
7
|
+
req: PayloadRequest | Request;
|
|
13
8
|
}) => Promise<Response>;
|
|
14
9
|
//# sourceMappingURL=routeError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvF,OAAO,EAAE,QAAQ,EAAqC,MAAM,SAAS,CAAA;AAmErE,eAAO,MAAM,UAAU,8DAKpB;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,cAAc,GAAG,OAAO,CAAA;CAC9B,sBAkFA,CAAA"}
|
|
@@ -2,6 +2,7 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { APIError, APIErrorName, ValidationErrorName } from 'payload';
|
|
3
3
|
import { getPayloadHMR } from '../../utilities/getPayloadHMR.js';
|
|
4
4
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
5
|
+
import { mergeHeaders } from '../../utilities/mergeHeaders.js';
|
|
5
6
|
const formatErrors = incoming => {
|
|
6
7
|
if (incoming) {
|
|
7
8
|
// Cannot use `instanceof` to check error type: https://github.com/microsoft/TypeScript/issues/13965
|
|
@@ -52,9 +53,9 @@ export const routeError = async ({
|
|
|
52
53
|
collection,
|
|
53
54
|
config: configArg,
|
|
54
55
|
err,
|
|
55
|
-
req
|
|
56
|
+
req: incomingReq
|
|
56
57
|
}) => {
|
|
57
|
-
let payload =
|
|
58
|
+
let payload = 'payload' in incomingReq && incomingReq?.payload;
|
|
58
59
|
if (!payload) {
|
|
59
60
|
try {
|
|
60
61
|
payload = await getPayloadHMR({
|
|
@@ -68,6 +69,7 @@ export const routeError = async ({
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
}
|
|
72
|
+
const req = incomingReq;
|
|
71
73
|
req.payload = payload;
|
|
72
74
|
const headers = headersWithCors({
|
|
73
75
|
headers: new Headers(),
|
|
@@ -88,26 +90,38 @@ export const routeError = async ({
|
|
|
88
90
|
if (config.debug && config.debug === true) {
|
|
89
91
|
response.stack = err.stack;
|
|
90
92
|
}
|
|
91
|
-
if (collection
|
|
92
|
-
({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
if (collection) {
|
|
94
|
+
await collection.config.hooks.afterError?.reduce(async (promise, hook) => {
|
|
95
|
+
await promise;
|
|
96
|
+
const result = await hook({
|
|
97
|
+
collection: collection.config,
|
|
98
|
+
context: req.context,
|
|
99
|
+
error: err,
|
|
100
|
+
req,
|
|
101
|
+
result: response
|
|
102
|
+
});
|
|
103
|
+
if (result) {
|
|
104
|
+
response = result.response || response;
|
|
105
|
+
status = result.status || status;
|
|
106
|
+
}
|
|
107
|
+
}, Promise.resolve());
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
await config.hooks.afterError?.reduce(async (promise, hook) => {
|
|
110
|
+
await promise;
|
|
111
|
+
const result = await hook({
|
|
112
|
+
collection: collection?.config,
|
|
113
|
+
context: req.context,
|
|
114
|
+
error: err,
|
|
115
|
+
req,
|
|
116
|
+
result: response
|
|
107
117
|
});
|
|
108
|
-
|
|
118
|
+
if (result) {
|
|
119
|
+
response = result.response || response;
|
|
120
|
+
status = result.status || status;
|
|
121
|
+
}
|
|
122
|
+
}, Promise.resolve());
|
|
109
123
|
return Response.json(response, {
|
|
110
|
-
headers,
|
|
124
|
+
headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,
|
|
111
125
|
status
|
|
112
126
|
});
|
|
113
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeError.js","names":["httpStatus","APIError","APIErrorName","ValidationErrorName","getPayloadHMR","headersWithCors","formatErrors","incoming","proto","Object","getPrototypeOf","constructor","name","data","errors","message","keys","reduce","acc","key","push","field","path","Array","isArray","routeError","collection","config","configArg","err","req","payload","e","Response","json","status","INTERNAL_SERVER_ERROR","headers","Headers","logger","response","error","stack","debug","hooks","afterError","context"],"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError, APIErrorName, ValidationErrorName } from 'payload'\n\nimport { getPayloadHMR } from '../../utilities/getPayloadHMR.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\
|
|
1
|
+
{"version":3,"file":"routeError.js","names":["httpStatus","APIError","APIErrorName","ValidationErrorName","getPayloadHMR","headersWithCors","mergeHeaders","formatErrors","incoming","proto","Object","getPrototypeOf","constructor","name","data","errors","message","keys","reduce","acc","key","push","field","path","Array","isArray","routeError","collection","config","configArg","err","req","incomingReq","payload","e","Response","json","status","INTERNAL_SERVER_ERROR","headers","Headers","logger","response","error","stack","debug","hooks","afterError","promise","hook","result","context","Promise","resolve","responseHeaders"],"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, ErrorResult, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError, APIErrorName, ValidationErrorName } from 'payload'\n\nimport { getPayloadHMR } from '../../utilities/getPayloadHMR.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nconst formatErrors = (incoming: { [key: string]: unknown } | APIError): ErrorResult => {\n if (incoming) {\n // Cannot use `instanceof` to check error type: https://github.com/microsoft/TypeScript/issues/13965\n // Instead, get the prototype of the incoming error and check its constructor name\n const proto = Object.getPrototypeOf(incoming)\n\n // Payload 'ValidationError' and 'APIError'\n if (\n (proto.constructor.name === ValidationErrorName || proto.constructor.name === APIErrorName) &&\n incoming.data\n ) {\n return {\n errors: [\n {\n name: incoming.name,\n data: incoming.data,\n message: incoming.message,\n },\n ],\n }\n }\n\n // Mongoose 'ValidationError': https://mongoosejs.com/docs/api/error.html#Error.ValidationError\n if (proto.constructor.name === ValidationErrorName && 'errors' in incoming && incoming.errors) {\n return {\n errors: Object.keys(incoming.errors).reduce((acc, key) => {\n acc.push({\n field: incoming.errors[key].path,\n message: incoming.errors[key].message,\n })\n return acc\n }, []),\n }\n }\n\n if (Array.isArray(incoming.message)) {\n return {\n errors: incoming.message,\n }\n }\n\n if (incoming.name) {\n return {\n errors: [\n {\n message: incoming.message,\n },\n ],\n }\n }\n }\n\n return {\n errors: [\n {\n message: 'An unknown error occurred.',\n },\n ],\n }\n}\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req: incomingReq,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: PayloadRequest | Request\n}) => {\n let payload = 'payload' in incomingReq && incomingReq?.payload\n\n if (!payload) {\n try {\n payload = await getPayloadHMR({ config: configArg })\n } catch (e) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n const req = incomingReq as PayloadRequest\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config, logger } = payload\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection) {\n await collection.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n }\n\n await config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection?.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n\n return Response.json(response, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,\n status,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,QAAQ,EAAEC,YAAY,EAAEC,mBAAmB,QAAQ;AAE5D,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAE7B,MAAMC,YAAA,GAAgBC,QAAA;EACpB,IAAIA,QAAA,EAAU;IACZ;IACA;IACA,MAAMC,KAAA,GAAQC,MAAA,CAAOC,cAAc,CAACH,QAAA;IAEpC;IACA,IACE,CAACC,KAAA,CAAMG,WAAW,CAACC,IAAI,KAAKV,mBAAA,IAAuBM,KAAA,CAAMG,WAAW,CAACC,IAAI,KAAKX,YAAW,KACzFM,QAAA,CAASM,IAAI,EACb;MACA,OAAO;QACLC,MAAA,EAAQ,CACN;UACEF,IAAA,EAAML,QAAA,CAASK,IAAI;UACnBC,IAAA,EAAMN,QAAA,CAASM,IAAI;UACnBE,OAAA,EAASR,QAAA,CAASQ;QACpB;MAEJ;IACF;IAEA;IACA,IAAIP,KAAA,CAAMG,WAAW,CAACC,IAAI,KAAKV,mBAAA,IAAuB,YAAYK,QAAA,IAAYA,QAAA,CAASO,MAAM,EAAE;MAC7F,OAAO;QACLA,MAAA,EAAQL,MAAA,CAAOO,IAAI,CAACT,QAAA,CAASO,MAAM,EAAEG,MAAM,CAAC,CAACC,GAAA,EAAKC,GAAA;UAChDD,GAAA,CAAIE,IAAI,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AAQR;IACV;IAEA,IAAIQ,MAAA,EAAQ;MACVR,QAAA,GAAWQ,MAAC,CAAOR,QAAQ,IAAoBA,QAAA;MAC/CL,MAAA,GAASa,MAAA,CAAOb,MAAM,IAAIA,MAAA;IAC5B;EACF,GAAGe,OAAA,CAAQC,OAAO;EAElB,OAAOlB,QAAA,CAASC,IAAI,CAACM,QAAA,EAAU;IAC7BH,OAAA,EAASR,GAAA,CAAIuB,eAAe,GAAGhD,YAAA,CAAayB,GAAA,CAAIuB,eAAe,EAAEf,OAAA,IAAWA,OAAA;IAC5EF;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JoinQuery } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Convert request JoinQuery object from strings to numbers
|
|
4
|
+
* @param joins
|
|
5
|
+
*/
|
|
6
|
+
export declare const sanitizeJoinParams: (joins?: {
|
|
7
|
+
[schemaPath: string]: {
|
|
8
|
+
limit?: unknown;
|
|
9
|
+
sort?: string;
|
|
10
|
+
where?: unknown;
|
|
11
|
+
};
|
|
12
|
+
} | false) => JoinQuery;
|
|
13
|
+
//# sourceMappingURL=sanitizeJoinParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeJoinParams.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/utilities/sanitizeJoinParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,WAEzB;IACE,CAAC,UAAU,EAAE,MAAM,GAAG;QACpB,KAAK,CAAC,EAAE,OAAO,CAAA;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;CACF,GACD,KAAK,KACR,SAYF,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isNumber } from 'payload/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Convert request JoinQuery object from strings to numbers
|
|
4
|
+
* @param joins
|
|
5
|
+
*/
|
|
6
|
+
export const sanitizeJoinParams = (joins = {}) => {
|
|
7
|
+
const joinQuery = {};
|
|
8
|
+
Object.keys(joins).forEach(schemaPath => {
|
|
9
|
+
joinQuery[schemaPath] = {
|
|
10
|
+
limit: isNumber(joins[schemaPath]?.limit) ? Number(joins[schemaPath].limit) : undefined,
|
|
11
|
+
sort: joins[schemaPath]?.sort ? joins[schemaPath].sort : undefined,
|
|
12
|
+
where: joins[schemaPath]?.where ? joins[schemaPath].where : undefined
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
return joinQuery;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=sanitizeJoinParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeJoinParams.js","names":["isNumber","sanitizeJoinParams","joins","joinQuery","Object","keys","forEach","schemaPath","limit","Number","undefined","sort","where"],"sources":["../../../../src/routes/rest/utilities/sanitizeJoinParams.ts"],"sourcesContent":["import type { JoinQuery } from 'payload'\n\nimport { isNumber } from 'payload/shared'\n\n/**\n * Convert request JoinQuery object from strings to numbers\n * @param joins\n */\nexport const sanitizeJoinParams = (\n joins:\n | {\n [schemaPath: string]: {\n limit?: unknown\n sort?: string\n where?: unknown\n }\n }\n | false = {},\n): JoinQuery => {\n const joinQuery = {}\n\n Object.keys(joins).forEach((schemaPath) => {\n joinQuery[schemaPath] = {\n limit: isNumber(joins[schemaPath]?.limit) ? Number(joins[schemaPath].limit) : undefined,\n sort: joins[schemaPath]?.sort ? joins[schemaPath].sort : undefined,\n where: joins[schemaPath]?.where ? joins[schemaPath].where : undefined,\n }\n })\n\n return joinQuery\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ;AAEzB;;;;AAIA,OAAO,MAAMC,kBAAA,GAAqBA,CAChCC,KAAA,GAQY,CAAC,CAAC;EAEd,MAAMC,SAAA,GAAY,CAAC;EAEnBC,MAAA,CAAOC,IAAI,CAACH,KAAA,EAAOI,OAAO,CAAEC,UAAA;IAC1BJ,SAAS,CAACI,UAAA,CAAW,GAAG;MACtBC,KAAA,EAAOR,QAAA,CAASE,KAAK,CAACK,UAAA,CAAW,EAAEC,KAAA,IAASC,MAAA,CAAOP,KAAK,CAACK,UAAA,CAAW,CAACC,KAAK,IAAIE,SAAA;MAC9EC,IAAA,EAAMT,KAAK,CAACK,UAAA,CAAW,EAAEI,IAAA,GAAOT,KAAK,CAACK,UAAA,CAAW,CAACI,IAAI,GAAGD,SAAA;MACzDE,KAAA,EAAOV,KAAK,CAACK,UAAA,CAAW,EAAEK,KAAA,GAAQV,KAAK,CAACK,UAAA,CAAW,CAACK,KAAK,GAAGF;IAC9D;EACF;EAEA,OAAOP,SAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/Default/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAMrB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,eAAe,CAAA;CACjC,GAAG,WAAW,CAAA;AAEf,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/Default/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAMrB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,eAAe,CAAA;CACjC,GAAG,WAAW,CAAA;AAEf,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAwE1D,CAAA"}
|
|
@@ -55,9 +55,13 @@ export const DefaultTemplate = ({
|
|
|
55
55
|
children: [/*#__PURE__*/_jsx("div", {
|
|
56
56
|
className: `${baseClass}__nav-toggler-wrapper`,
|
|
57
57
|
id: "nav-toggler",
|
|
58
|
-
children: /*#__PURE__*/_jsx(
|
|
59
|
-
className: `${baseClass}__nav-toggler`,
|
|
60
|
-
|
|
58
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
59
|
+
className: `${baseClass}__nav-toggler-container`,
|
|
60
|
+
id: "nav-toggler",
|
|
61
|
+
children: /*#__PURE__*/_jsx(NavToggler, {
|
|
62
|
+
className: `${baseClass}__nav-toggler`,
|
|
63
|
+
children: /*#__PURE__*/_jsx(NavHamburger, {})
|
|
64
|
+
})
|
|
61
65
|
})
|
|
62
66
|
}), /*#__PURE__*/_jsxs(Wrapper, {
|
|
63
67
|
baseClass: baseClass,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["AppHeader","BulkUploadProvider","EntityVisibilityProvider","NavToggler","getCreateMappedComponent","RenderComponent","React","DefaultNav","NavHamburger","Wrapper","baseClass","DefaultTemplate","children","className","i18n","locale","params","payload","permissions","searchParams","user","visibleEntities","admin","components","header","CustomHeader","Nav","CustomNav","undefined","config","createMappedComponent","importMap","serverProps","MappedDefaultNav","MappedCustomHeader","_jsx","_jsxs","mappedComponent","style","position","id"],"sources":["../../../src/templates/Default/index.tsx"],"sourcesContent":["import type { MappedComponent, ServerProps, VisibleEntities } from 'payload'\n\nimport { AppHeader, BulkUploadProvider, EntityVisibilityProvider, NavToggler } from '@payloadcms/ui'\nimport { getCreateMappedComponent, RenderComponent } from '@payloadcms/ui/shared'\nimport React from 'react'\n\nimport { DefaultNav } from '../../elements/Nav/index.js'\nimport './index.scss'\nimport { NavHamburger } from './NavHamburger/index.js'\nimport { Wrapper } from './Wrapper/index.js'\n\nconst baseClass = 'template-default'\n\nexport type DefaultTemplateProps = {\n children?: React.ReactNode\n className?: string\n visibleEntities: VisibleEntities\n} & ServerProps\n\nexport const DefaultTemplate: React.FC<DefaultTemplateProps> = ({\n children,\n className,\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n visibleEntities,\n}) => {\n const {\n admin: {\n components: { header: CustomHeader, Nav: CustomNav } = {\n header: undefined,\n Nav: undefined,\n },\n } = {},\n } = payload.config || {}\n\n const createMappedComponent = getCreateMappedComponent({\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n })\n\n const MappedDefaultNav: MappedComponent = createMappedComponent(\n CustomNav,\n undefined,\n DefaultNav,\n 'CustomNav',\n )\n\n const MappedCustomHeader = createMappedComponent(\n CustomHeader,\n undefined,\n undefined,\n 'CustomHeader',\n )\n\n return (\n <EntityVisibilityProvider visibleEntities={visibleEntities}>\n <BulkUploadProvider>\n <RenderComponent mappedComponent={MappedCustomHeader} />\n <div style={{ position: 'relative' }}>\n <div className={`${baseClass}__nav-toggler-wrapper`} id=\"nav-toggler\">\n <
|
|
1
|
+
{"version":3,"file":"index.js","names":["AppHeader","BulkUploadProvider","EntityVisibilityProvider","NavToggler","getCreateMappedComponent","RenderComponent","React","DefaultNav","NavHamburger","Wrapper","baseClass","DefaultTemplate","children","className","i18n","locale","params","payload","permissions","searchParams","user","visibleEntities","admin","components","header","CustomHeader","Nav","CustomNav","undefined","config","createMappedComponent","importMap","serverProps","MappedDefaultNav","MappedCustomHeader","_jsx","_jsxs","mappedComponent","style","position","id"],"sources":["../../../src/templates/Default/index.tsx"],"sourcesContent":["import type { MappedComponent, ServerProps, VisibleEntities } from 'payload'\n\nimport { AppHeader, BulkUploadProvider, EntityVisibilityProvider, NavToggler } from '@payloadcms/ui'\nimport { getCreateMappedComponent, RenderComponent } from '@payloadcms/ui/shared'\nimport React from 'react'\n\nimport { DefaultNav } from '../../elements/Nav/index.js'\nimport './index.scss'\nimport { NavHamburger } from './NavHamburger/index.js'\nimport { Wrapper } from './Wrapper/index.js'\n\nconst baseClass = 'template-default'\n\nexport type DefaultTemplateProps = {\n children?: React.ReactNode\n className?: string\n visibleEntities: VisibleEntities\n} & ServerProps\n\nexport const DefaultTemplate: React.FC<DefaultTemplateProps> = ({\n children,\n className,\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n visibleEntities,\n}) => {\n const {\n admin: {\n components: { header: CustomHeader, Nav: CustomNav } = {\n header: undefined,\n Nav: undefined,\n },\n } = {},\n } = payload.config || {}\n\n const createMappedComponent = getCreateMappedComponent({\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n })\n\n const MappedDefaultNav: MappedComponent = createMappedComponent(\n CustomNav,\n undefined,\n DefaultNav,\n 'CustomNav',\n )\n\n const MappedCustomHeader = createMappedComponent(\n CustomHeader,\n undefined,\n undefined,\n 'CustomHeader',\n )\n\n return (\n <EntityVisibilityProvider visibleEntities={visibleEntities}>\n <BulkUploadProvider>\n <RenderComponent mappedComponent={MappedCustomHeader} />\n <div style={{ position: 'relative' }}>\n <div className={`${baseClass}__nav-toggler-wrapper`} id=\"nav-toggler\">\n <div className={`${baseClass}__nav-toggler-container`} id=\"nav-toggler\">\n <NavToggler className={`${baseClass}__nav-toggler`}>\n <NavHamburger />\n </NavToggler>\n </div>\n </div>\n <Wrapper baseClass={baseClass} className={className}>\n <RenderComponent mappedComponent={MappedDefaultNav} />\n\n <div className={`${baseClass}__wrap`}>\n <AppHeader />\n {children}\n </div>\n </Wrapper>\n </div>\n </BulkUploadProvider>\n </EntityVisibilityProvider>\n )\n}\n"],"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IAAA,CAAC;UAAItB,SAAA,EAAW,GAAGH,SAAA,uBAAgC;UAAE8B,EAAA,EAAG;oBACtD,aAAAL,IAAA,CAAC;YAAItB,SAAA,EAAW,GAAGH,SAAA,yBAAkC;YAAE8B,EAAA,EAAG;sBACxD,aAAAL,IAAA,CAAChC,UAAA;cAAWU,SAAA,EAAW,GAAGH,SAAA,eAAwB;wBAChD,aAAAyB,IAAA,CAAC3B,YAAA;;;yBAIP4B,KAAA,CAAC3B,OAAA;UAAQC,SAAA,EAAWA,SAAA;UAAWG,SAAA,EAAWA,SAAA;kCACxCsB,IAAA,CAAC9B,eAAA;YAAgBgC,eAAA,EAAiBJ;2BAElCG,KAAA,CAAC;YAAIvB,SAAA,EAAW,GAAGH,SAAA,QAAiB;oCAClCyB,IAAA,CAACnC,SAAA,OACAY,QAAA;;;;;;AAOf","ignoreList":[]}
|
|
@@ -20,12 +20,17 @@
|
|
|
20
20
|
justify-content: center;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
&__nav-toggler {
|
|
23
|
+
&__nav-toggler-container {
|
|
24
24
|
height: var(--app-header-height);
|
|
25
25
|
display: flex;
|
|
26
26
|
align-items: center;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
&__nav-toggler {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
&__wrap {
|
|
30
35
|
min-width: 0;
|
|
31
36
|
width: 100%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestTheme.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAA;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEzD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,sBAAsB,CAAA;IACrD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B,CAAA;AAID,eAAO,MAAM,eAAe,iCAAkC,sBAAsB,KAAG,
|
|
1
|
+
{"version":3,"file":"getRequestTheme.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAA;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEzD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,sBAAsB,CAAA;IACrD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B,CAAA;AAID,eAAO,MAAM,eAAe,iCAAkC,sBAAsB,KAAG,KAsBtF,CAAA"}
|
|
@@ -5,6 +5,9 @@ export const getRequestTheme = ({
|
|
|
5
5
|
cookies,
|
|
6
6
|
headers
|
|
7
7
|
}) => {
|
|
8
|
+
if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {
|
|
9
|
+
return config.admin.theme;
|
|
10
|
+
}
|
|
8
11
|
const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`);
|
|
9
12
|
const themeFromCookie = typeof themeCookie === 'string' ? themeCookie : themeCookie?.value;
|
|
10
13
|
if (themeFromCookie && acceptedThemes.includes(themeFromCookie)) {
|