@payloadcms/next 3.0.0-beta.108 → 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/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/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/utilities/getRequestTheme.d.ts.map +1 -1
- package/dist/utilities/getRequestTheme.js +3 -0
- package/dist/utilities/getRequestTheme.js.map +1 -1
- 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 +31 -15
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +30 -65
- package/dist/views/Edit/Default/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/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +214 -203
- package/dist/views/LivePreview/index.client.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/package.json +6 -6
|
@@ -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,CAACT,GAAA,CAAIU,KAAK;EAE9B;EACA;EACA,IAAI,CAACT,OAAA,CAAQU,MAAM,CAACC,KAAK,IAAIT,MAAA,KAAWV,UAAA,CAAWY,qBAAqB,EAAE;IACxEC,YAAA,GAAe;EACjB;EAEA,IAAIO,QAAA,GAAkC;IACpCC,UAAA,EAAY;MACVC,IAAA,EAAMf,GAAA,EAAKI,aAAA,EAAeW,IAAA,IAAQC,SAAA;MAClCC,IAAA,EAAMjB,GAAC,IAAOA,GAAA,CAAII,aAAa,IAAIJ,GAAC,CAAII,aAAa,CAAca,IAAI,IAAKD,SAAA;MAC5EN,KAAA,EAAOT,OAAA,CAAQU,MAAM,CAACC,KAAK,GAAGZ,GAAA,CAAIU,KAAK,GAAGM,SAAA;MAC1CE,UAAA,EAAYf;IACd;IACAgB,SAAA,EAAWnB,GAAA,CAAImB,SAAS;IACxBZ,OAAA,EAASD,YAAA;IACTc,IAAA,EAAMpB,GAAA,CAAIoB;EACZ;EAEA,MAAMnB,OAAA,CAAQU,MAAM,CAACU,K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EAClF,GAAGN,eAAA;EAEH,MAAMa,UAAA,GAAa5D,eAAA,CAAgB;IACjCkD,OAAA,EAAS,IAAIW,OAAA,CAAQV,WAAA,CAAYD,OAAO;IACxC7C;EACF;EAEA,KAAK,MAAMyD,GAAA,IAAOZ,OAAA,EAAS;IACzBU,UAAA,CAAWG,MAAM,CAACD,GAAA,EAAKZ,OAAO,CAACY,GAAA,CAAI;EACrC;EAEA,OAAO,IAAIE,QAAA,CAASb,WAAA,CAAYc,IAAI,EAAE;IACpCf,OAAA,EAAS7C,GAAA,CAAI6D,eAAe,GAAGjE,YAAA,CAAaI,GAAA,CAAI6D,eAAe,EAAEN,UAAA,IAAcA,UAAA;IAC/EtD,MAAA,EAAQ6C,WAAA,CAAY7C;EACtB;AACF","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,CAAC;YACPC,KAAA,EAAOd,QAAA,CAASO,MAAM,CAACK,GAAA,CAAI,CAACG,IAAI;YAChCP,OAAA,EAASR,QAAA,CAASO,MAAM,CAACK,GAAA,CAAI,CAACJ;UAChC;UACA,OAAOG,GAAA;QACT,GAAG,EAAE;MACP;IACF;IAEA,IAAIK,KAAA,CAAMC,OAAO,CAACjB,QAAA,CAASQ,OAAO,GAAG;MACnC,OAAO;Q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AIuB,eAAe,GAAGhD,YAAA,CAAayB,GAAA,CAAIuB,eAAe,EAAEf,OAAA,IAAWA,OAAA;IAC5EF;EACF;AACF","ignoreList":[]}
|
|
@@ -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)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestTheme.js","names":["defaultTheme","acceptedThemes","getRequestTheme","config","cookies","headers","themeCookie","get","cookiePrefix","themeFromCookie","value","
|
|
1
|
+
{"version":3,"file":"getRequestTheme.js","names":["defaultTheme","acceptedThemes","getRequestTheme","config","cookies","headers","admin","theme","includes","themeCookie","get","cookiePrefix","themeFromCookie","value","themeFromHeader"],"sources":["../../src/utilities/getRequestTheme.ts"],"sourcesContent":["import type { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies.js'\nimport type { SanitizedConfig } from 'payload'\n\nimport { defaultTheme, type Theme } from '@payloadcms/ui'\n\ntype GetRequestLanguageArgs = {\n config: SanitizedConfig\n cookies: Map<string, string> | ReadonlyRequestCookies\n headers: Request['headers']\n}\n\nconst acceptedThemes: Theme[] = ['dark', 'light']\n\nexport const getRequestTheme = ({ config, cookies, headers }: GetRequestLanguageArgs): Theme => {\n if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {\n return config.admin.theme\n }\n\n const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`)\n\n const themeFromCookie: Theme = (\n typeof themeCookie === 'string' ? themeCookie : themeCookie?.value\n ) as Theme\n\n if (themeFromCookie && acceptedThemes.includes(themeFromCookie)) {\n return themeFromCookie\n }\n\n const themeFromHeader = headers.get('Sec-CH-Prefers-Color-Scheme') as Theme\n\n if (themeFromHeader && acceptedThemes.includes(themeFromHeader)) {\n return themeFromHeader\n }\n\n return defaultTheme\n}\n"],"mappings":"AAGA,SAASA,YAAY,QAAoB;AAQzC,MAAMC,cAAA,GAA0B,CAAC,QAAQ,QAAQ;AAEjD,OAAO,MAAMC,eAAA,GAAkBA,CAAC;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAO,CAA0B;EAClF,IAAIF,MAAA,CAAOG,KAAK,CAACC,KAAK,KAAK,SAASN,cAAA,CAAeO,QAAQ,CAACL,MAAA,CAAOG,KAAK,CAACC,KAAK,GAAG;IAC/E,OAAOJ,MAAA,CAAOG,KAAK,CAACC,KAAK;EAC3B;EAEA,MAAME,WAAA,GAAcL,OAAA,CAAQM,GAAG,CAAC,GAAGP,MAAA,CAAOQ,YAAY,IAAI,iBAAiB;EAE3E,MAAMC,eAAA,GACJ,OAAOH,WAAA,KAAgB,WAAWA,WAAA,GAAcA,WAAA,EAAaI,KAAA;EAG/D,IAAID,eAAA,IAAmBX,cAAA,CAAeO,QAAQ,CAACI,eAAA,GAAkB;IAC/D,OAAOA,eAAA;EACT;EAEA,MAAME,eAAA,GAAkBT,OAAA,CAAQK,GAAG,CAAC;EAEpC,IAAII,eAAA,IAAmBb,cAAA,CAAeO,QAAQ,CAACM,eAAA,GAAkB;IAC/D,OAAOA,eAAA;EACT;EAEA,OAAOd,YAAA;AACT","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { LanguageOptions } from 'payload';
|
|
2
|
+
import type { Config, LanguageOptions } from 'payload';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import './index.scss';
|
|
5
5
|
export declare const Settings: React.FC<{
|
|
6
6
|
readonly className?: string;
|
|
7
7
|
readonly i18n: I18n;
|
|
8
8
|
readonly languageOptions: LanguageOptions;
|
|
9
|
+
readonly theme: Config['admin']['theme'];
|
|
9
10
|
}>;
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGtD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAKrB,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;CACzC,CAaA,CAAA"}
|
|
@@ -8,7 +8,8 @@ export const Settings = props => {
|
|
|
8
8
|
const {
|
|
9
9
|
className,
|
|
10
10
|
i18n,
|
|
11
|
-
languageOptions
|
|
11
|
+
languageOptions,
|
|
12
|
+
theme
|
|
12
13
|
} = props;
|
|
13
14
|
return /*#__PURE__*/_jsxs("div", {
|
|
14
15
|
className: [baseClass, className].filter(Boolean).join(' '),
|
|
@@ -23,7 +24,7 @@ export const Settings = props => {
|
|
|
23
24
|
}), /*#__PURE__*/_jsx(LanguageSelector, {
|
|
24
25
|
languageOptions: languageOptions
|
|
25
26
|
})]
|
|
26
|
-
}), /*#__PURE__*/_jsx(ToggleTheme, {})]
|
|
27
|
+
}), theme === 'all' && /*#__PURE__*/_jsx(ToggleTheme, {})]
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["FieldLabel","React","ToggleTheme","LanguageSelector","baseClass","Settings","props","className","i18n","languageOptions","_jsxs","filter","Boolean","join","_jsx","t","field","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { LanguageOptions } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { ToggleTheme } from '../ToggleTheme/index.js'\nimport './index.scss'\nimport { LanguageSelector } from './LanguageSelector.js'\n\nconst baseClass = 'payload-settings'\n\nexport const Settings: React.FC<{\n readonly className?: string\n readonly i18n: I18n\n readonly languageOptions: LanguageOptions\n}> = (props) => {\n const { className, i18n, languageOptions } = props\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <h3>{i18n.t('general:payloadSettings')}</h3>\n <div className={`${baseClass}__language`}>\n <FieldLabel field={null} htmlFor=\"language-select\" label={i18n.t('general:language')} />\n <LanguageSelector languageOptions={languageOptions} />\n </div>\n <ToggleTheme
|
|
1
|
+
{"version":3,"file":"index.js","names":["FieldLabel","React","ToggleTheme","LanguageSelector","baseClass","Settings","props","className","i18n","languageOptions","theme","_jsxs","filter","Boolean","join","_jsx","t","field","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Config, LanguageOptions } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { ToggleTheme } from '../ToggleTheme/index.js'\nimport './index.scss'\nimport { LanguageSelector } from './LanguageSelector.js'\n\nconst baseClass = 'payload-settings'\n\nexport const Settings: React.FC<{\n readonly className?: string\n readonly i18n: I18n\n readonly languageOptions: LanguageOptions\n readonly theme: Config['admin']['theme']\n}> = (props) => {\n const { className, i18n, languageOptions, theme } = props\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <h3>{i18n.t('general:payloadSettings')}</h3>\n <div className={`${baseClass}__language`}>\n <FieldLabel field={null} htmlFor=\"language-select\" label={i18n.t('general:language')} />\n <LanguageSelector languageOptions={languageOptions} />\n </div>\n {theme === 'all' && <ToggleTheme />}\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAE5B,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,QAAA,GAKPC,KAAA;EACJ,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC,eAAe;IAAEC;EAAK,CAAE,GAAGJ,KAAA;EAEpD,oBACEK,KAAA,CAAC;IAAIJ,SAAA,EAAW,CAACH,SAAA,EAAWG,SAAA,CAAU,CAACK,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;4BAC1DC,IAAA,CAAC;gBAAIP,IAAA,CAAKQ,CAAC,CAAC;qBACZL,KAAA,CAAC;MAAIJ,SAAA,EAAW,GAAGH,SAAA,YAAqB;8BACtCW,IAAA,CAACf,UAAA;QAAWiB,KAAA,EAAO;QAAMC,OAAA,EAAQ;QAAkBC,KAAA,EAAOX,IAAA,CAAKQ,CAAC,CAAC;uBACjED,IAAA,CAACZ,gBAAA;QAAiBM,eAAA,EAAiBA;;QAEpCC,KAAA,KAAU,sBAASK,IAAA,CAACb,WAAA;;AAG3B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAU7C,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAU7C,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAkG5C,CAAA"}
|
|
@@ -36,6 +36,7 @@ export const Account = async ({
|
|
|
36
36
|
Account: CustomAccountComponent
|
|
37
37
|
} = {}
|
|
38
38
|
} = {},
|
|
39
|
+
theme,
|
|
39
40
|
user: userSlug
|
|
40
41
|
},
|
|
41
42
|
routes: {
|
|
@@ -82,7 +83,8 @@ export const Account = async ({
|
|
|
82
83
|
return /*#__PURE__*/_jsx(DocumentInfoProvider, {
|
|
83
84
|
AfterFields: /*#__PURE__*/_jsx(Settings, {
|
|
84
85
|
i18n: i18n,
|
|
85
|
-
languageOptions: languageOptions
|
|
86
|
+
languageOptions: languageOptions,
|
|
87
|
+
theme: theme
|
|
86
88
|
}),
|
|
87
89
|
apiURL: `${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`,
|
|
88
90
|
collectionSlug: userSlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderComponent","getCreateMappedComponent","notFound","React","DocumentHeader","getDocumentData","getDocumentPermissions","EditView","AccountClient","Settings","generateAccountMetadata","Account","initPageResult","params","searchParams","languageOptions","locale","permissions","req","i18n","payload","config","user","admin","components","views","CustomAccountComponent","userSlug","routes","api","serverURL","collectionConfig","collections","find","collection","slug","id","docPermissions","hasPublishPermission","hasSavePermission","data","formState","createMappedComponent","importMap","serverProps","routeSegments","mappedAccountComponent","Component","undefined","_jsx","AfterFields","apiURL","collectionSlug","toString","initialData","initialState","isEditing","_jsxs","depth","hideTabs","mappedComponent"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n RenderComponent,\n} from '@payloadcms/ui'\nimport { getCreateMappedComponent } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { EditView } from '../Edit/index.js'\nimport { AccountClient } from './index.client.js'\nimport { Settings } from './Settings/index.js'\n\nexport { generateAccountMetadata } from './meta.js'\n\nexport const Account: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: {
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderComponent","getCreateMappedComponent","notFound","React","DocumentHeader","getDocumentData","getDocumentPermissions","EditView","AccountClient","Settings","generateAccountMetadata","Account","initPageResult","params","searchParams","languageOptions","locale","permissions","req","i18n","payload","config","user","admin","components","views","CustomAccountComponent","theme","userSlug","routes","api","serverURL","collectionConfig","collections","find","collection","slug","id","docPermissions","hasPublishPermission","hasSavePermission","data","formState","createMappedComponent","importMap","serverProps","routeSegments","mappedAccountComponent","Component","undefined","_jsx","AfterFields","apiURL","collectionSlug","toString","initialData","initialState","isEditing","_jsxs","depth","hideTabs","mappedComponent"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n RenderComponent,\n} from '@payloadcms/ui'\nimport { getCreateMappedComponent } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { EditView } from '../Edit/index.js'\nimport { AccountClient } from './index.client.js'\nimport { Settings } from './Settings/index.js'\n\nexport { generateAccountMetadata } from './meta.js'\n\nexport const Account: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: {\n components: { views: { Account: CustomAccountComponent } = {} } = {},\n theme,\n user: userSlug,\n },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = config.collections.find((collection) => collection.slug === userSlug)\n\n if (collectionConfig && user?.id) {\n const { docPermissions, hasPublishPermission, hasSavePermission } =\n await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data: user,\n req,\n })\n\n const { data, formState } = await getDocumentData({\n id: user.id,\n collectionConfig,\n locale,\n req,\n })\n\n const createMappedComponent = getCreateMappedComponent({\n importMap: payload.importMap,\n serverProps: {\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: [],\n searchParams,\n user,\n },\n })\n\n const mappedAccountComponent = createMappedComponent(\n CustomAccountComponent?.Component,\n undefined,\n EditView,\n 'CustomAccountComponent.Component',\n )\n\n return (\n <DocumentInfoProvider\n AfterFields={<Settings i18n={i18n} languageOptions={languageOptions} theme={theme} />}\n apiURL={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n collectionSlug={userSlug}\n docPermissions={docPermissions}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={user?.id.toString()}\n initialData={data}\n initialState={formState}\n isEditing\n >\n <EditDepthProvider depth={1}>\n <DocumentHeader\n collectionConfig={collectionConfig}\n hideTabs\n i18n={i18n}\n payload={payload}\n permissions={permissions}\n />\n <HydrateAuthProvider permissions={permissions} />\n <RenderComponent mappedComponent={mappedAccountComponent} />\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"mappings":";AAEA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,eAAe,QACV;AACP,SAASC,wBAAwB,QAAQ;AACzC,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAEzB,SAASC,uBAAuB,QAAQ;AAExC,OAAO,MAAMC,OAAA,GAAoC,MAAAA,CAAO;EACtDC,cAAc;EACdC,MAAM;EACNC;AAAY,CACb;EACC,MAAM;IACJC,eAAe;IACfC,MAAM;IACNC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGV,cAAA;EAEJ,MAAM;IACJW,KAAA,EAAO;MACLC,UAAA,EAAY;QAAEC,KAAA,EAAO;UAAEd,OAAA,EAASe;QAAsB,CAAE,GAAG,CAAC;MAAC,CAAE,GAAG,CAAC,CAAC;MACpEC,KAAK;MACLL,IAAA,EAAMM;IAAQ,CACf;IACDC,MAAA,EAAQ;MAAEC;IAAG,CAAE;IACfC;EAAS,CACV,GAAGV,MAAA;EAEJ,MAAMW,gBAAA,GAAmBX,MAAA,CAAOY,WAAW,CAACC,IAAI,CAAEC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKR,QAAA;EAErF,IAAII,gBAAA,IAAoBV,IAAA,EAAMe,EAAA,EAAI;IAChC,MAAM;MAAEC,cAAc;MAAEC,oBAAoB;MAA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AC9C,cAAA;UACC4B,gBAAA,EAAkBA,gBAAA;UAClB4B,QAAQ;UACRzC,IAAA,EAAMA,IAAA;UACNC,OAAA,EAASA,OAAA;UACTH,WAAA,EAAaA;yBAEfiC,IAAA,CAACnD,mBAAA;UAAoBkB,WAAA,EAAaA;yBAClCiC,IAAA,CAAClD,eAAA;UAAgB6D,eAAA,EAAiBd;yBAClCG,IAAA,CAAC1C,aAAA;;;EAIT;EAEA,OAAON,QAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/CreateFirstUser/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/CreateFirstUser/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,SAAS,EACT,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAchB,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC3C,YAAY,EAAE,SAAS,CAAA;IACvB,iBAAiB,CAAC,EAAE,KAAK,GAAG,wBAAwB,CAAA;IACpD,QAAQ,EAAE,MAAM,CAAA;CACjB,CAuEA,CAAA"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { ConfirmPasswordField, Form, FormSubmit, PasswordField, RenderFields, useConfig, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { ConfirmPasswordField, Form, FormSubmit, PasswordField, RenderFields, useAuth, useConfig, useTranslation } from '@payloadcms/ui';
|
|
6
6
|
import { getFormState } from '@payloadcms/ui/shared';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { RenderEmailAndUsernameFields } from '../../elements/EmailAndUsername/index.js';
|
|
9
9
|
export const CreateFirstUserClient = t0 => {
|
|
10
|
-
const $ = _c(
|
|
10
|
+
const $ = _c(16);
|
|
11
11
|
const {
|
|
12
12
|
initialState,
|
|
13
13
|
loginWithUsername,
|
|
@@ -28,13 +28,16 @@ export const CreateFirstUserClient = t0 => {
|
|
|
28
28
|
const {
|
|
29
29
|
t
|
|
30
30
|
} = useTranslation();
|
|
31
|
+
const {
|
|
32
|
+
setUser
|
|
33
|
+
} = useAuth();
|
|
31
34
|
let t3;
|
|
32
|
-
if ($[0] !== userSlug || $[1] !== getEntityConfig || $[2] !== apiRoute || $[3] !== serverURL || $[4] !==
|
|
35
|
+
if ($[0] !== userSlug || $[1] !== getEntityConfig || $[2] !== apiRoute || $[3] !== serverURL || $[4] !== setUser || $[5] !== loginWithUsername || $[6] !== t || $[7] !== initialState || $[8] !== admin) {
|
|
33
36
|
const collectionConfig = getEntityConfig({
|
|
34
37
|
collectionSlug: userSlug
|
|
35
38
|
});
|
|
36
39
|
let t4;
|
|
37
|
-
if ($[
|
|
40
|
+
if ($[10] !== apiRoute || $[11] !== userSlug || $[12] !== serverURL) {
|
|
38
41
|
t4 = async t5 => {
|
|
39
42
|
const {
|
|
40
43
|
formState: prevFormState
|
|
@@ -53,19 +56,31 @@ export const CreateFirstUserClient = t0 => {
|
|
|
53
56
|
});
|
|
54
57
|
return state;
|
|
55
58
|
};
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
59
|
+
$[10] = apiRoute;
|
|
60
|
+
$[11] = userSlug;
|
|
61
|
+
$[12] = serverURL;
|
|
62
|
+
$[13] = t4;
|
|
60
63
|
} else {
|
|
61
|
-
t4 = $[
|
|
64
|
+
t4 = $[13];
|
|
62
65
|
}
|
|
63
66
|
const onChange = t4;
|
|
67
|
+
let t5;
|
|
68
|
+
if ($[14] !== setUser) {
|
|
69
|
+
t5 = data => {
|
|
70
|
+
setUser(data.user);
|
|
71
|
+
};
|
|
72
|
+
$[14] = setUser;
|
|
73
|
+
$[15] = t5;
|
|
74
|
+
} else {
|
|
75
|
+
t5 = $[15];
|
|
76
|
+
}
|
|
77
|
+
const handleFirstRegister = t5;
|
|
64
78
|
t3 = _jsxs(Form, {
|
|
65
79
|
action: `${serverURL}${apiRoute}/${userSlug}/first-register`,
|
|
66
80
|
initialState,
|
|
67
81
|
method: "POST",
|
|
68
82
|
onChange: [onChange],
|
|
83
|
+
onSuccess: handleFirstRegister,
|
|
69
84
|
redirect: admin,
|
|
70
85
|
validationOperation: "create",
|
|
71
86
|
children: [_jsx(RenderEmailAndUsernameFields, {
|
|
@@ -96,13 +111,14 @@ export const CreateFirstUserClient = t0 => {
|
|
|
96
111
|
$[1] = getEntityConfig;
|
|
97
112
|
$[2] = apiRoute;
|
|
98
113
|
$[3] = serverURL;
|
|
99
|
-
$[4] =
|
|
100
|
-
$[5] =
|
|
101
|
-
$[6] =
|
|
102
|
-
$[7] =
|
|
103
|
-
$[8] =
|
|
114
|
+
$[4] = setUser;
|
|
115
|
+
$[5] = loginWithUsername;
|
|
116
|
+
$[6] = t;
|
|
117
|
+
$[7] = initialState;
|
|
118
|
+
$[8] = admin;
|
|
119
|
+
$[9] = t3;
|
|
104
120
|
} else {
|
|
105
|
-
t3 = $[
|
|
121
|
+
t3 = $[9];
|
|
106
122
|
}
|
|
107
123
|
return t3;
|
|
108
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","names":["c","_c","ConfirmPasswordField","Form","FormSubmit","PasswordField","RenderFields","useConfig","useTranslation","getFormState","React","RenderEmailAndUsernameFields","CreateFirstUserClient","t0","$","initialState","loginWithUsername","userSlug","config","t1","getEntityConfig","routes","t2","serverURL","admin","api","apiRoute","t","t3","collectionConfig","collectionSlug","t4","t5","formState","prevFormState","state","body","operation","schemaPath","onChange","_jsxs","action","method","redirect","validationOperation","children","_jsx","className","readOnly","autoComplete","field","name","label","required","fields","forceRender","path","size"],"sources":["../../../src/views/CreateFirstUser/index.client.tsx"],"sourcesContent":["'use client'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["c","_c","ConfirmPasswordField","Form","FormSubmit","PasswordField","RenderFields","useAuth","useConfig","useTranslation","getFormState","React","RenderEmailAndUsernameFields","CreateFirstUserClient","t0","$","initialState","loginWithUsername","userSlug","config","t1","getEntityConfig","routes","t2","serverURL","admin","api","apiRoute","t","setUser","t3","collectionConfig","collectionSlug","t4","t5","formState","prevFormState","state","body","operation","schemaPath","onChange","data","user","handleFirstRegister","_jsxs","action","method","onSuccess","redirect","validationOperation","children","_jsx","className","readOnly","autoComplete","field","name","label","required","fields","forceRender","path","size"],"sources":["../../../src/views/CreateFirstUser/index.client.tsx"],"sourcesContent":["'use client'\nimport type {\n ClientCollectionConfig,\n ClientUser,\n FormState,\n LoginWithUsernameOptions,\n} from 'payload'\n\nimport {\n ConfirmPasswordField,\n Form,\n type FormProps,\n FormSubmit,\n PasswordField,\n RenderFields,\n useAuth,\n useConfig,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport React from 'react'\n\nimport { RenderEmailAndUsernameFields } from '../../elements/EmailAndUsername/index.js'\n\nexport const CreateFirstUserClient: React.FC<{\n initialState: FormState\n loginWithUsername?: false | LoginWithUsernameOptions\n userSlug: string\n}> = ({ initialState, loginWithUsername, userSlug }) => {\n const {\n config: {\n routes: { admin, api: apiRoute },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const { t } = useTranslation()\n const { setUser } = useAuth()\n\n const collectionConfig = getEntityConfig({ collectionSlug: userSlug }) as ClientCollectionConfig\n\n const onChange: FormProps['onChange'][0] = React.useCallback(\n async ({ formState: prevFormState }) => {\n const { state } = await getFormState({\n apiRoute,\n body: {\n collectionSlug: userSlug,\n formState: prevFormState,\n operation: 'create',\n schemaPath: `_${userSlug}.auth`,\n },\n serverURL,\n })\n return state\n },\n [apiRoute, userSlug, serverURL],\n )\n\n const handleFirstRegister = (data: { user: ClientUser }) => {\n setUser(data.user)\n }\n\n return (\n <Form\n action={`${serverURL}${apiRoute}/${userSlug}/first-register`}\n initialState={initialState}\n method=\"POST\"\n onChange={[onChange]}\n onSuccess={handleFirstRegister}\n redirect={admin}\n validationOperation=\"create\"\n >\n <RenderEmailAndUsernameFields\n className=\"emailAndUsername\"\n loginWithUsername={loginWithUsername}\n operation=\"create\"\n readOnly={false}\n />\n <PasswordField\n autoComplete={'off'}\n field={{\n name: 'password',\n label: t('authentication:newPassword'),\n required: true,\n }}\n />\n <ConfirmPasswordField />\n <RenderFields\n fields={collectionConfig.fields}\n forceRender\n operation=\"create\"\n path=\"\"\n readOnly={false}\n schemaPath={userSlug}\n />\n <FormSubmit size=\"large\">{t('general:create')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAQA,SACEC,oBAAoB,EACpBC,IAAI,EAEJC,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT;AACP,SAASC,YAAY,QAAQ;AAC7B,OAAOC,KAAA,MAAW;AAElB,SAASC,4BAA4B,QAAQ;AAE7C,OAAO,MAAMC,qBAAA,GAIRC,EAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EAAC;IAAAe,YAAA;IAAAC,iBAAA;IAAAC;EAAA,IAAAJ,EAA6C;EACjD;IAAAK,MAAA,EAAAC,EAAA;IAAAC;EAAA,IAMIb,SAAA;EALM;IAAAc,MAAA,EAAAC,EAAA;IAAAC;EAAA,IAAAJ,EAGP;EAFS;IAAAK,KAAA;IAAAC,GAAA,EAAAC;EAAA,IAAAJ,EAAwB;EAMpC;IAAAK;EAAA,IAAcnB,cAAA;EACd;IAAAoB;EAAA,IAAoBtB,OAAA;EAAA,IAAAuB,EAAA;EAAA,IAAAf,CAAA,QAAAG,QAAA,IAAAH,CAAA,QAAAM,eAAA,IAAAN,CAAA,QAAA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AAA,GACIA,QAAA;MAAAO,SAAA,EACAJ,mBAAA;MAAAK,QAAA,EACDxB,KAAA;MAAAyB,mBAAA,EACU;MAAAC,QAAA,GAEpBC,IAAA,CAAAxC,4BAAA;QAAAyC,SAAA,EACY;QAAApC,iBAAA;QAAAsB,SAAA,EAEA;QAAAe,QAAA;MAAA,C,GAGZF,IAAA,CAAA/C,aAAA;QAAAkD,YAAA,EACgB;QAAAC,KAAA;UAAAC,IAAA,EAEN;UAAAC,KAAA,EACC9B,CAAA,CAAE;UAAA+B,QAAA;QAAA;MAAA,C,GAIbP,IAAA,CAAAlD,oBAAA,IAAC,GACDkD,IAAA,CAAA9C,YAAA;QAAAsD,MAAA,EACU7B,gBAAA,CAAA6B,MAAA;QAAAC,WAAA;QAAAtB,SAAA,EAEE;QAAAuB,IAAA,EACL;QAAAR,QAAA;QAAAd,UAAA,EAEOtB;MAAA,C,GAEdkC,IAAA,CAAAhD,UAAA;QAAA2D,IAAA,EAAiB;QAAAZ,QAAA,EAASvB,CAAA,CAAE;MAAA,C;;;;;;;;;;;;;;;SAhC9BE,E;CAmCJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Default/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Default/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAA6D,MAAM,OAAO,CAAA;AAMjF,OAAO,cAAc,CAAA;AASrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAycnC,CAAA"}
|